Completed
Push — master ( 012813...8fb9b9 )
by Yannick
08:10
created
js/map-marine.2d.js.php 1 patch
Braces   +42 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 setcookie("MapFormat",'2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8
-if (!isset($globalJsonCompress)) $compress = true;
9
-else $compress = $globalJsonCompress;
8
+if (!isset($globalJsonCompress)) {
9
+	$compress = true;
10
+} else {
11
+	$compress = $globalJsonCompress;
12
+}
10 13
 ?>
11 14
 
12 15
 
@@ -142,9 +145,13 @@  discard block
 block discarded – undo
142 145
 		    if (callsign != ""){ markerMarineLabel += callsign; }
143 146
 		    if (type != ""){ markerMarineLabel += ' - '+type; }
144 147
 <?php
145
-	if (isset($_COOKIE['MarineIconColor'])) $MarineIconColor = $_COOKIE['MarineIconColor'];
146
-	elseif (isset($globalMarineIconColor)) $MarineIconColor = $globalMarineIconColor;
147
-	else $MarineIconColor = '1a3151';
148
+	if (isset($_COOKIE['MarineIconColor'])) {
149
+		$MarineIconColor = $_COOKIE['MarineIconColor'];
150
+	} elseif (isset($globalMarineIconColor)) {
151
+		$MarineIconColor = $globalMarineIconColor;
152
+	} else {
153
+		$MarineIconColor = '1a3151';
154
+	}
148 155
 	if (!isset($ident) && !isset($fammarine_id)) {
149 156
 ?>
150 157
 		    info_marine_update(feature.properties.fc);
@@ -179,7 +186,12 @@  discard block
 block discarded – undo
179 186
 <?php
180 187
 		} else {
181 188
 ?>
182
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
189
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
190
+	print $archiveupdatetime*1000;
191
+} else {
192
+	print $globalMapRefresh*1000+20000;
193
+}
194
+?>+feature.properties.sqt*1000);
183 195
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
184 196
 <?php
185 197
 		}
@@ -228,7 +240,12 @@  discard block
 block discarded – undo
228 240
 <?php
229 241
 		} else {
230 242
 ?>
231
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
243
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
244
+	print $archiveupdatetime*1000;
245
+} else {
246
+	print $globalMapRefresh*1000+20000;
247
+}
248
+?>+feature.properties.sqt*1000);
232 249
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
233 250
 <?php
234 251
 		}
@@ -276,7 +293,12 @@  discard block
 block discarded – undo
276 293
 <?php
277 294
 		} else {
278 295
 ?>
279
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
296
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
297
+	print $archiveupdatetime*1000;
298
+} else {
299
+	print $globalMapRefresh*1000+20000;
300
+}
301
+?>+feature.properties.sqt*1000);
280 302
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
281 303
 <?php
282 304
 		}
@@ -559,14 +581,24 @@  discard block
 block discarded – undo
559 581
 	if (isset($archive) && $archive) {
560 582
 ?>
561 583
 //then load it again every 30 seconds
562
-//  var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
584
+//  var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) {
585
+	print ($globalMapRefresh*1000)/2;
586
+} else {
587
+	print '15000';
588
+}
589
+?>);
563 590
 reloadMarinePage = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php print $archiveupdatetime*1000; ?>);
564 591
 <?php
565 592
 	} else {
566 593
 ?>
567 594
 //then load it again every 30 seconds
568 595
 reloadMarinePage = setInterval(
569
-    function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
596
+    function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) {
597
+	print $globalMapRefresh*1000;
598
+} else {
599
+	print '30000';
600
+}
601
+?>);
570 602
 <?php
571 603
 	}
572 604
 ?>
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +931 added lines, -322 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 		curl_setopt($ch, CURLOPT_URL, $url);
17 17
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
18 18
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
19
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
19
+		if ($referer != '') {
20
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
21
+		}
20 22
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
21 23
 		curl_setopt($ch, CURLOPT_FILE, $fp);
22 24
 		curl_exec($ch);
@@ -27,12 +29,16 @@  discard block
 block discarded – undo
27 29
 	public static function gunzip($in_file,$out_file_name = '') {
28 30
 		//echo $in_file.' -> '.$out_file_name."\n";
29 31
 		$buffer_size = 4096; // read 4kb at a time
30
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32
+		if ($out_file_name == '') {
33
+			$out_file_name = str_replace('.gz', '', $in_file);
34
+		}
31 35
 		if ($in_file != '' && file_exists($in_file)) {
32 36
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
35
-			else {
37
+			if (function_exists('gzopen')) {
38
+				$file = gzopen($in_file,'rb');
39
+			} elseif (function_exists('gzopen64')) {
40
+				$file = gzopen64($in_file,'rb');
41
+			} else {
36 42
 				echo 'gzopen not available';
37 43
 				die;
38 44
 			}
@@ -53,8 +59,12 @@  discard block
 block discarded – undo
53 59
 			if ($res === TRUE) {
54 60
 				$zip->extractTo($path);
55 61
 				$zip->close();
56
-			} else return false;
57
-		} else return false;
62
+			} else {
63
+				return false;
64
+			}
65
+		} else {
66
+			return false;
67
+		}
58 68
 	}
59 69
 	
60 70
 	public static function connect_sqlite($database) {
@@ -69,7 +79,9 @@  discard block
 block discarded – undo
69 79
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 80
 		global $globalDebug, $globalTransaction;
71 81
 		//$query = 'TRUNCATE TABLE routes';
72
-		if ($globalDebug) echo " - Delete previous routes from DB -";
82
+		if ($globalDebug) {
83
+			echo " - Delete previous routes from DB -";
84
+		}
73 85
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
74 86
 		$Connection = new Connection();
75 87
 		try {
@@ -80,7 +92,9 @@  discard block
 block discarded – undo
80 92
                         return "error : ".$e->getMessage();
81 93
                 }
82 94
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
95
+    		if ($globalDebug) {
96
+    			echo " - Add routes to DB -";
97
+    		}
84 98
     		update_db::connect_sqlite($database_file);
85 99
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 100
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -95,15 +109,21 @@  discard block
 block discarded – undo
95 109
 		$Connection = new Connection();
96 110
 		$sth_dest = $Connection->db->prepare($query_dest);
97 111
 		try {
98
-			if ($globalTransaction) $Connection->db->beginTransaction();
112
+			if ($globalTransaction) {
113
+				$Connection->db->beginTransaction();
114
+			}
99 115
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 116
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 117
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$sth_dest->execute($query_dest_values);
103 119
             		}
104
-			if ($globalTransaction) $Connection->db->commit();
120
+			if ($globalTransaction) {
121
+				$Connection->db->commit();
122
+			}
105 123
 		} catch(PDOException $e) {
106
-			if ($globalTransaction) $Connection->db->rollBack(); 
124
+			if ($globalTransaction) {
125
+				$Connection->db->rollBack();
126
+			}
107 127
 			return "error : ".$e->getMessage();
108 128
 		}
109 129
                 return '';
@@ -111,7 +131,9 @@  discard block
 block discarded – undo
111 131
 	public static function retrieve_route_oneworld($database_file) {
112 132
 		global $globalDebug, $globalTransaction;
113 133
 		//$query = 'TRUNCATE TABLE routes';
114
-		if ($globalDebug) echo " - Delete previous routes from DB -";
134
+		if ($globalDebug) {
135
+			echo " - Delete previous routes from DB -";
136
+		}
115 137
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
116 138
 		$Connection = new Connection();
117 139
 		try {
@@ -122,14 +144,18 @@  discard block
 block discarded – undo
122 144
                         return "error : ".$e->getMessage();
123 145
                 }
124 146
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
147
+    		if ($globalDebug) {
148
+    			echo " - Add routes to DB -";
149
+    		}
126 150
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 151
 		$Spotter = new Spotter();
128 152
 		if ($fh = fopen($database_file,"r")) {
129 153
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 154
 			$Connection = new Connection();
131 155
 			$sth_dest = $Connection->db->prepare($query_dest);
132
-			if ($globalTransaction) $Connection->db->beginTransaction();
156
+			if ($globalTransaction) {
157
+				$Connection->db->beginTransaction();
158
+			}
133 159
 			while (!feof($fh)) {
134 160
 				$line = fgetcsv($fh,9999,',');
135 161
 				if ($line[0] != '') {
@@ -138,13 +164,17 @@  discard block
 block discarded – undo
138 164
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139 165
 							$sth_dest->execute($query_dest_values);
140 166
 						} catch(PDOException $e) {
141
-							if ($globalTransaction) $Connection->db->rollBack(); 
167
+							if ($globalTransaction) {
168
+								$Connection->db->rollBack();
169
+							}
142 170
 							return "error : ".$e->getMessage();
143 171
 						}
144 172
 					}
145 173
 				}
146 174
 			}
147
-			if ($globalTransaction) $Connection->db->commit();
175
+			if ($globalTransaction) {
176
+				$Connection->db->commit();
177
+			}
148 178
 		}
149 179
                 return '';
150 180
 	}
@@ -152,7 +182,9 @@  discard block
 block discarded – undo
152 182
 	public static function retrieve_route_skyteam($database_file) {
153 183
 		global $globalDebug, $globalTransaction;
154 184
 		//$query = 'TRUNCATE TABLE routes';
155
-		if ($globalDebug) echo " - Delete previous routes from DB -";
185
+		if ($globalDebug) {
186
+			echo " - Delete previous routes from DB -";
187
+		}
156 188
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
157 189
 		$Connection = new Connection();
158 190
 		try {
@@ -163,7 +195,9 @@  discard block
 block discarded – undo
163 195
                         return "error : ".$e->getMessage();
164 196
                 }
165 197
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
198
+    		if ($globalDebug) {
199
+    			echo " - Add routes to DB -";
200
+    		}
167 201
 
168 202
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 203
 		$Spotter = new Spotter();
@@ -172,7 +206,9 @@  discard block
 block discarded – undo
172 206
 			$Connection = new Connection();
173 207
 			$sth_dest = $Connection->db->prepare($query_dest);
174 208
 			try {
175
-				if ($globalTransaction) $Connection->db->beginTransaction();
209
+				if ($globalTransaction) {
210
+					$Connection->db->beginTransaction();
211
+				}
176 212
 				while (!feof($fh)) {
177 213
 					$line = fgetcsv($fh,9999,',');
178 214
 					if ($line[0] != '') {
@@ -183,9 +219,13 @@  discard block
 block discarded – undo
183 219
 						}
184 220
 					}
185 221
 				}
186
-				if ($globalTransaction) $Connection->db->commit();
222
+				if ($globalTransaction) {
223
+					$Connection->db->commit();
224
+				}
187 225
 			} catch(PDOException $e) {
188
-				if ($globalTransaction) $Connection->db->rollBack(); 
226
+				if ($globalTransaction) {
227
+					$Connection->db->rollBack();
228
+				}
189 229
 				return "error : ".$e->getMessage();
190 230
 			}
191 231
 		}
@@ -228,11 +268,16 @@  discard block
 block discarded – undo
228 268
 		$sth_dest = $Connection->db->prepare($query_dest);
229 269
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 270
 		try {
231
-			if ($globalTransaction) $Connection->db->beginTransaction();
271
+			if ($globalTransaction) {
272
+				$Connection->db->beginTransaction();
273
+			}
232 274
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 275
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234
-				if ($values['UserString4'] == 'M') $type = 'military';
235
-				else $type = null;
276
+				if ($values['UserString4'] == 'M') {
277
+					$type = 'military';
278
+				} else {
279
+					$type = null;
280
+				}
236 281
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 282
 				$sth_dest->execute($query_dest_values);
238 283
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -240,7 +285,9 @@  discard block
 block discarded – undo
240 285
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 286
 				}
242 287
             		}
243
-			if ($globalTransaction) $Connection->db->commit();
288
+			if ($globalTransaction) {
289
+				$Connection->db->commit();
290
+			}
244 291
 		} catch(PDOException $e) {
245 292
 			return "error : ".$e->getMessage();
246 293
 		}
@@ -277,7 +324,9 @@  discard block
 block discarded – undo
277 324
 			$Connection = new Connection();
278 325
 			$sth_dest = $Connection->db->prepare($query_dest);
279 326
 			try {
280
-				if ($globalTransaction) $Connection->db->beginTransaction();
327
+				if ($globalTransaction) {
328
+					$Connection->db->beginTransaction();
329
+				}
281 330
             			while (!feof($fh)) {
282 331
             				$values = array();
283 332
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -288,7 +337,9 @@  discard block
 block discarded – undo
288 337
             				// Check if we can find ICAO, else set it to GLID
289 338
             				$aircraft_name_split = explode(' ',$aircraft_name);
290 339
             				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
340
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
341
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
342
+            				}
292 343
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293 344
             				$sth_search = $Connection->db->prepare($query_search);
294 345
 					try {
@@ -301,7 +352,9 @@  discard block
 block discarded – undo
301 352
 					} catch(PDOException $e) {
302 353
 						return "error : ".$e->getMessage();
303 354
 					}
304
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
355
+					if (!isset($values['ICAOTypeCode'])) {
356
+						$values['ICAOTypeCode'] = 'GLID';
357
+					}
305 358
 					// Add data to db
306 359
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 360
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -310,7 +363,9 @@  discard block
 block discarded – undo
310 363
 						$sth_dest->execute($query_dest_values);
311 364
 					}
312 365
 				}
313
-				if ($globalTransaction) $Connection->db->commit();
366
+				if ($globalTransaction) {
367
+					$Connection->db->commit();
368
+				}
314 369
 			} catch(PDOException $e) {
315 370
 				return "error : ".$e->getMessage();
316 371
 			}
@@ -346,7 +401,9 @@  discard block
 block discarded – undo
346 401
 			$Connection = new Connection();
347 402
 			$sth_dest = $Connection->db->prepare($query_dest);
348 403
 			try {
349
-				if ($globalTransaction) $Connection->db->beginTransaction();
404
+				if ($globalTransaction) {
405
+					$Connection->db->beginTransaction();
406
+				}
350 407
 				$tmp = fgetcsv($fh,9999,',',"'");
351 408
             			while (!feof($fh)) {
352 409
             				$line = fgetcsv($fh,9999,',',"'");
@@ -359,13 +416,17 @@  discard block
 block discarded – undo
359 416
             				// Check if we can find ICAO, else set it to GLID
360 417
             				$aircraft_name_split = explode(' ',$aircraft_name);
361 418
             				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
419
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
420
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				}
363 422
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364 423
             				$sth_search = $Connection->db->prepare($query_search);
365 424
 					try {
366 425
                                     		$sth_search->execute();
367 426
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
427
+	            				if (isset($result['icao']) && $result['icao'] != '') {
428
+	            					$values['ICAOTypeCode'] = $result['icao'];
429
+	            				}
369 430
 					} catch(PDOException $e) {
370 431
 						return "error : ".$e->getMessage();
371 432
 					}
@@ -378,7 +439,9 @@  discard block
 block discarded – undo
378 439
 						$sth_dest->execute($query_dest_values);
379 440
 					}
380 441
 				}
381
-				if ($globalTransaction) $Connection->db->commit();
442
+				if ($globalTransaction) {
443
+					$Connection->db->commit();
444
+				}
382 445
 			} catch(PDOException $e) {
383 446
 				return "error : ".$e->getMessage();
384 447
 			}
@@ -417,7 +480,9 @@  discard block
 block discarded – undo
417 480
 			$sth_dest = $Connection->db->prepare($query_dest);
418 481
 			$sth_modes = $Connection->db->prepare($query_modes);
419 482
 			try {
420
-				if ($globalTransaction) $Connection->db->beginTransaction();
483
+				if ($globalTransaction) {
484
+					$Connection->db->beginTransaction();
485
+				}
421 486
 				$tmp = fgetcsv($fh,9999,',','"');
422 487
             			while (!feof($fh)) {
423 488
             				$line = fgetcsv($fh,9999,',','"');
@@ -427,16 +492,22 @@  discard block
 block discarded – undo
427 492
             				    $values['registration'] = $line[0];
428 493
             				    $values['base'] = $line[4];
429 494
             				    $values['owner'] = $line[5];
430
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
431
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
+            				    if ($line[6] == '') {
496
+            				    	$values['date_first_reg'] = null;
497
+            				    } else {
498
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
499
+					    }
432 500
 					    $values['cancel'] = $line[7];
433 501
 					} elseif ($country == 'EI') {
434 502
 					    // TODO : add modeS & reg to aircraft_modes
435 503
             				    $values['registration'] = $line[0];
436 504
             				    $values['base'] = $line[3];
437 505
             				    $values['owner'] = $line[2];
438
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
439
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
506
+            				    if ($line[1] == '') {
507
+            				    	$values['date_first_reg'] = null;
508
+            				    } else {
509
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
510
+					    }
440 511
 					    $values['cancel'] = '';
441 512
 					    $values['modes'] = $line[7];
442 513
 					    $values['icao'] = $line[8];
@@ -455,16 +526,22 @@  discard block
 block discarded – undo
455 526
             				    $values['registration'] = $line[3];
456 527
             				    $values['base'] = null;
457 528
             				    $values['owner'] = $line[5];
458
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
529
+            				    if ($line[18] == '') {
530
+            				    	$values['date_first_reg'] = null;
531
+            				    } else {
532
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
533
+					    }
460 534
 					    $values['cancel'] = '';
461 535
 					} elseif ($country == 'VH') {
462 536
 					    // TODO : add modeS & reg to aircraft_modes
463 537
             				    $values['registration'] = $line[0];
464 538
             				    $values['base'] = null;
465 539
             				    $values['owner'] = $line[12];
466
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
467
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
540
+            				    if ($line[28] == '') {
541
+            				    	$values['date_first_reg'] = null;
542
+            				    } else {
543
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
544
+					    }
468 545
 
469 546
 					    $values['cancel'] = $line[39];
470 547
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -483,29 +560,41 @@  discard block
 block discarded – undo
483 560
             				    $values['registration'] = $line[0];
484 561
             				    $values['base'] = null;
485 562
             				    $values['owner'] = $line[8];
486
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
487
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
563
+            				    if ($line[7] == '') {
564
+            				    	$values['date_first_reg'] = null;
565
+            				    } else {
566
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
567
+					    }
488 568
 					    $values['cancel'] = '';
489 569
 					} elseif ($country == 'PP') {
490 570
             				    $values['registration'] = $line[0];
491 571
             				    $values['base'] = null;
492 572
             				    $values['owner'] = $line[4];
493
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
494
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
573
+            				    if ($line[6] == '') {
574
+            				    	$values['date_first_reg'] = null;
575
+            				    } else {
576
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
577
+					    }
495 578
 					    $values['cancel'] = $line[7];
496 579
 					} elseif ($country == 'E7') {
497 580
             				    $values['registration'] = $line[0];
498 581
             				    $values['base'] = null;
499 582
             				    $values['owner'] = $line[4];
500
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
501
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
583
+            				    if ($line[5] == '') {
584
+            				    	$values['date_first_reg'] = null;
585
+            				    } else {
586
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
587
+					    }
502 588
 					    $values['cancel'] = '';
503 589
 					} elseif ($country == '8Q') {
504 590
             				    $values['registration'] = $line[0];
505 591
             				    $values['base'] = null;
506 592
             				    $values['owner'] = $line[3];
507
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
593
+            				    if ($line[7] == '') {
594
+            				    	$values['date_first_reg'] = null;
595
+            				    } else {
596
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
597
+					    }
509 598
 					    $values['cancel'] = '';
510 599
 					} elseif ($country == 'ZK') {
511 600
             				    $values['registration'] = $line[0];
@@ -550,7 +639,9 @@  discard block
 block discarded – undo
550 639
 						$sth_modes->execute($query_modes_values);
551 640
 					}
552 641
 				}
553
-				if ($globalTransaction) $Connection->db->commit();
642
+				if ($globalTransaction) {
643
+					$Connection->db->commit();
644
+				}
554 645
 			} catch(PDOException $e) {
555 646
 				return "error : ".$e->getMessage();
556 647
 			}
@@ -684,25 +775,45 @@  discard block
 block discarded – undo
684 775
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
685 776
 		$Connection = new Connection();
686 777
 		$sth_dest = $Connection->db->prepare($query_dest);
687
-		if ($globalTransaction) $Connection->db->beginTransaction();
778
+		if ($globalTransaction) {
779
+			$Connection->db->beginTransaction();
780
+		}
688 781
   
689 782
 		$i = 0;
690 783
 		while($row = sparql_fetch_array($result))
691 784
 		{
692 785
 			if ($i >= 1) {
693 786
 			//print_r($row);
694
-			if (!isset($row['iata'])) $row['iata'] = '';
695
-			if (!isset($row['icao'])) $row['icao'] = '';
696
-			if (!isset($row['type'])) $row['type'] = '';
697
-			if (!isset($row['altitude'])) $row['altitude'] = '';
787
+			if (!isset($row['iata'])) {
788
+				$row['iata'] = '';
789
+			}
790
+			if (!isset($row['icao'])) {
791
+				$row['icao'] = '';
792
+			}
793
+			if (!isset($row['type'])) {
794
+				$row['type'] = '';
795
+			}
796
+			if (!isset($row['altitude'])) {
797
+				$row['altitude'] = '';
798
+			}
698 799
 			if (isset($row['city_bis'])) {
699 800
 				$row['city'] = $row['city_bis'];
700 801
 			}
701
-			if (!isset($row['city'])) $row['city'] = '';
702
-			if (!isset($row['country'])) $row['country'] = '';
703
-			if (!isset($row['homepage'])) $row['homepage'] = '';
704
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
705
-			if (!isset($row['name'])) continue;
802
+			if (!isset($row['city'])) {
803
+				$row['city'] = '';
804
+			}
805
+			if (!isset($row['country'])) {
806
+				$row['country'] = '';
807
+			}
808
+			if (!isset($row['homepage'])) {
809
+				$row['homepage'] = '';
810
+			}
811
+			if (!isset($row['wikipedia_page'])) {
812
+				$row['wikipedia_page'] = '';
813
+			}
814
+			if (!isset($row['name'])) {
815
+				continue;
816
+			}
706 817
 			if (!isset($row['image'])) {
707 818
 				$row['image'] = '';
708 819
 				$row['image_thumb'] = '';
@@ -738,7 +849,9 @@  discard block
 block discarded – undo
738 849
 
739 850
 			$i++;
740 851
 		}
741
-		if ($globalTransaction) $Connection->db->commit();
852
+		if ($globalTransaction) {
853
+			$Connection->db->commit();
854
+		}
742 855
 		echo "Delete duplicate rows...\n";
743 856
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
744 857
 		try {
@@ -750,7 +863,9 @@  discard block
 block discarded – undo
750 863
                 }
751 864
 
752 865
 
753
-		if ($globalDebug) echo "Insert Not available Airport...\n";
866
+		if ($globalDebug) {
867
+			echo "Insert Not available Airport...\n";
868
+		}
754 869
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
755 870
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
756 871
 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
@@ -777,7 +892,9 @@  discard block
 block discarded – undo
777 892
 		$delimiter = ',';
778 893
 		$out_file = $tmp_dir.'airports.csv';
779 894
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
780
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
895
+		if (!file_exists($out_file) || !is_readable($out_file)) {
896
+			return FALSE;
897
+		}
781 898
 		echo "Add data from ourairports.com...\n";
782 899
 
783 900
 		$header = NULL;
@@ -787,8 +904,9 @@  discard block
 block discarded – undo
787 904
 			//$Connection->db->beginTransaction();
788 905
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
789 906
 			{
790
-				if(!$header) $header = $row;
791
-				else {
907
+				if(!$header) {
908
+					$header = $row;
909
+				} else {
792 910
 					$data = array();
793 911
 					$data = array_combine($header, $row);
794 912
 					try {
@@ -826,7 +944,9 @@  discard block
 block discarded – undo
826 944
 		echo "Download data from another free database...\n";
827 945
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
828 946
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
829
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
947
+		if (!file_exists($out_file) || !is_readable($out_file)) {
948
+			return FALSE;
949
+		}
830 950
 		update_db::unzip($out_file);
831 951
 		$header = NULL;
832 952
 		echo "Add data from another free database...\n";
@@ -837,8 +957,9 @@  discard block
 block discarded – undo
837 957
 			//$Connection->db->beginTransaction();
838 958
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
839 959
 			{
840
-				if(!$header) $header = $row;
841
-				else {
960
+				if(!$header) {
961
+					$header = $row;
962
+				} else {
842 963
 					$data = $row;
843 964
 
844 965
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -1014,7 +1135,9 @@  discard block
 block discarded – undo
1014 1135
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1015 1136
 		{
1016 1137
 			$i = 0;
1017
-			if ($globalTransaction) $Connection->db->beginTransaction();
1138
+			if ($globalTransaction) {
1139
+				$Connection->db->beginTransaction();
1140
+			}
1018 1141
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1019 1142
 			{
1020 1143
 				if ($i > 0) {
@@ -1027,7 +1150,9 @@  discard block
 block discarded – undo
1027 1150
 					}
1028 1151
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1029 1152
 					if (!empty($result_search)) {
1030
-						if ($globalDebug) echo '.';
1153
+						if ($globalDebug) {
1154
+							echo '.';
1155
+						}
1031 1156
 							//if ($globalDBdriver == 'mysql') {
1032 1157
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1033 1158
 							//} else {
@@ -1049,8 +1174,12 @@  discard block
 block discarded – undo
1049 1174
 						}
1050 1175
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1051 1176
 						if (!empty($result_search_mfr)) {
1052
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1053
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1177
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1178
+								$data[16] = $data[23];
1179
+							}
1180
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1181
+								$data[16] = $data[15];
1182
+							}
1054 1183
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1055 1184
 							try {
1056 1185
 								$sthf = $Connection->db->prepare($queryf);
@@ -1061,7 +1190,9 @@  discard block
 block discarded – undo
1061 1190
 						}
1062 1191
 					}
1063 1192
 					if (strtotime($data[29]) > time()) {
1064
-						if ($globalDebug) echo 'i';
1193
+						if ($globalDebug) {
1194
+							echo 'i';
1195
+						}
1065 1196
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1066 1197
 						try {
1067 1198
 							$sth = $Connection->db->prepare($query);
@@ -1072,13 +1203,19 @@  discard block
 block discarded – undo
1072 1203
 					}
1073 1204
 				}
1074 1205
 				if ($i % 90 == 0) {
1075
-					if ($globalTransaction) $Connection->db->commit();
1076
-					if ($globalTransaction) $Connection->db->beginTransaction();
1206
+					if ($globalTransaction) {
1207
+						$Connection->db->commit();
1208
+					}
1209
+					if ($globalTransaction) {
1210
+						$Connection->db->beginTransaction();
1211
+					}
1077 1212
 				}
1078 1213
 				$i++;
1079 1214
 			}
1080 1215
 			fclose($handle);
1081
-			if ($globalTransaction) $Connection->db->commit();
1216
+			if ($globalTransaction) {
1217
+				$Connection->db->commit();
1218
+			}
1082 1219
 		}
1083 1220
 		print_r($mfr);
1084 1221
 		return '';
@@ -1103,11 +1240,15 @@  discard block
 block discarded – undo
1103 1240
 			$i = 0;
1104 1241
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1105 1242
 			//$Connection->db->beginTransaction();
1106
-			if ($globalTransaction) $Connection->db->beginTransaction();
1243
+			if ($globalTransaction) {
1244
+				$Connection->db->beginTransaction();
1245
+			}
1107 1246
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1108 1247
 			{
1109 1248
 				if ($i > 0) {
1110
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1249
+					if ($data[1] == 'NULL') {
1250
+						$data[1] = $data[0];
1251
+					}
1111 1252
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1112 1253
 					try {
1113 1254
 						$sth = $Connection->db->prepare($query);
@@ -1119,7 +1260,9 @@  discard block
 block discarded – undo
1119 1260
 				$i++;
1120 1261
 			}
1121 1262
 			fclose($handle);
1122
-			if ($globalTransaction) $Connection->db->commit();
1263
+			if ($globalTransaction) {
1264
+				$Connection->db->commit();
1265
+			}
1123 1266
 		}
1124 1267
 		return '';
1125 1268
         }
@@ -1140,7 +1283,9 @@  discard block
 block discarded – undo
1140 1283
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1141 1284
 		{
1142 1285
 			$i = 0;
1143
-			if ($globalTransaction) $Connection->db->beginTransaction();
1286
+			if ($globalTransaction) {
1287
+				$Connection->db->beginTransaction();
1288
+			}
1144 1289
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1145 1290
 			{
1146 1291
 				if ($i > 0) {
@@ -1156,7 +1301,9 @@  discard block
 block discarded – undo
1156 1301
 				$i++;
1157 1302
 			}
1158 1303
 			fclose($handle);
1159
-			if ($globalTransaction) $Connection->db->commit();
1304
+			if ($globalTransaction) {
1305
+				$Connection->db->commit();
1306
+			}
1160 1307
 		}
1161 1308
 		return '';
1162 1309
         }
@@ -1181,7 +1328,9 @@  discard block
 block discarded – undo
1181 1328
 			$i = 0;
1182 1329
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1183 1330
 			//$Connection->db->beginTransaction();
1184
-			if ($globalTransaction) $Connection->db->beginTransaction();
1331
+			if ($globalTransaction) {
1332
+				$Connection->db->beginTransaction();
1333
+			}
1185 1334
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1186 1335
 			{
1187 1336
 				if ($i > 0) {
@@ -1196,7 +1345,9 @@  discard block
 block discarded – undo
1196 1345
 				$i++;
1197 1346
 			}
1198 1347
 			fclose($handle);
1199
-			if ($globalTransaction) $Connection->db->commit();
1348
+			if ($globalTransaction) {
1349
+				$Connection->db->commit();
1350
+			}
1200 1351
 		}
1201 1352
 		return '';
1202 1353
         }
@@ -1221,7 +1372,9 @@  discard block
 block discarded – undo
1221 1372
 			$i = 0;
1222 1373
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1223 1374
 			//$Connection->db->beginTransaction();
1224
-			if ($globalTransaction) $Connection->db->beginTransaction();
1375
+			if ($globalTransaction) {
1376
+				$Connection->db->beginTransaction();
1377
+			}
1225 1378
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1226 1379
 			{
1227 1380
 				if ($i > 0) {
@@ -1236,7 +1389,9 @@  discard block
 block discarded – undo
1236 1389
 				$i++;
1237 1390
 			}
1238 1391
 			fclose($handle);
1239
-			if ($globalTransaction) $Connection->db->commit();
1392
+			if ($globalTransaction) {
1393
+				$Connection->db->commit();
1394
+			}
1240 1395
 		}
1241 1396
 		return '';
1242 1397
         }
@@ -1255,7 +1410,9 @@  discard block
 block discarded – undo
1255 1410
 		$Connection = new Connection();
1256 1411
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1257 1412
 		{
1258
-			if ($globalTransaction) $Connection->db->beginTransaction();
1413
+			if ($globalTransaction) {
1414
+				$Connection->db->beginTransaction();
1415
+			}
1259 1416
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1260 1417
 			{
1261 1418
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1270,7 +1427,9 @@  discard block
 block discarded – undo
1270 1427
 				}
1271 1428
 			}
1272 1429
 			fclose($handle);
1273
-			if ($globalTransaction) $Connection->db->commit();
1430
+			if ($globalTransaction) {
1431
+				$Connection->db->commit();
1432
+			}
1274 1433
 		}
1275 1434
 		return '';
1276 1435
         }
@@ -1421,7 +1580,9 @@  discard block
 block discarded – undo
1421 1580
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1422 1581
 		{
1423 1582
 			$i = 0;
1424
-			if ($globalTransaction) $Connection->db->beginTransaction();
1583
+			if ($globalTransaction) {
1584
+				$Connection->db->beginTransaction();
1585
+			}
1425 1586
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1426 1587
 			{
1427 1588
 				$i++;
@@ -1449,7 +1610,9 @@  discard block
 block discarded – undo
1449 1610
 				}
1450 1611
 			}
1451 1612
 			fclose($handle);
1452
-			if ($globalTransaction) $Connection->db->commit();
1613
+			if ($globalTransaction) {
1614
+				$Connection->db->commit();
1615
+			}
1453 1616
 		}
1454 1617
 		return '';
1455 1618
         }
@@ -1472,7 +1635,9 @@  discard block
 block discarded – undo
1472 1635
 		$Connection = new Connection();
1473 1636
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1474 1637
 		{
1475
-			if ($globalTransaction) $Connection->db->beginTransaction();
1638
+			if ($globalTransaction) {
1639
+				$Connection->db->beginTransaction();
1640
+			}
1476 1641
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1477 1642
 			{
1478 1643
 				if(count($row) > 1) {
@@ -1486,7 +1651,9 @@  discard block
 block discarded – undo
1486 1651
 				}
1487 1652
 			}
1488 1653
 			fclose($handle);
1489
-			if ($globalTransaction) $Connection->db->commit();
1654
+			if ($globalTransaction) {
1655
+				$Connection->db->commit();
1656
+			}
1490 1657
 		}
1491 1658
 		return '';
1492 1659
         }
@@ -1506,8 +1673,9 @@  discard block
 block discarded – undo
1506 1673
 	        }
1507 1674
 
1508 1675
 
1509
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1510
-		else {
1676
+		if ($globalDBdriver == 'mysql') {
1677
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1678
+		} else {
1511 1679
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1512 1680
 			$query = "CREATE EXTENSION postgis";
1513 1681
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1526,20 +1694,30 @@  discard block
 block discarded – undo
1526 1694
 		global $tmp_dir, $globalDebug;
1527 1695
 		include_once('class.create_db.php');
1528 1696
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1529
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1697
+		if ($globalDebug) {
1698
+			echo "NOTAM from FlightAirMap website : Download...";
1699
+		}
1530 1700
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1531 1701
 		$error = '';
1532 1702
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1533
-			if ($globalDebug) echo "Gunzip...";
1703
+			if ($globalDebug) {
1704
+				echo "Gunzip...";
1705
+			}
1534 1706
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1535
-			if ($globalDebug) echo "Add to DB...";
1707
+			if ($globalDebug) {
1708
+				echo "Add to DB...";
1709
+			}
1536 1710
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1537 1711
 			$NOTAM = new NOTAM();
1538 1712
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1539
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1713
+		} else {
1714
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1715
+		}
1540 1716
 		if ($error != '') {
1541 1717
 			return $error;
1542
-		} elseif ($globalDebug) echo "Done\n";
1718
+		} elseif ($globalDebug) {
1719
+			echo "Done\n";
1720
+		}
1543 1721
 		return '';
1544 1722
 	}
1545 1723
 
@@ -1593,67 +1771,111 @@  discard block
 block discarded – undo
1593 1771
 		//if ($globalDebug) echo "IVAO : Download...";
1594 1772
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1595 1773
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1596
-			if ($globalDebug) echo "Unzip...";
1774
+			if ($globalDebug) {
1775
+				echo "Unzip...";
1776
+			}
1597 1777
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1598
-			if ($globalDebug) echo "Add to DB...";
1778
+			if ($globalDebug) {
1779
+				echo "Add to DB...";
1780
+			}
1599 1781
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1600
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1782
+			if ($globalDebug) {
1783
+				echo "Copy airlines logos to airlines images directory...";
1784
+			}
1601 1785
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1602
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1603
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1604
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1786
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1787
+					$error = "Failed to copy airlines logo.";
1788
+				}
1789
+			} else {
1790
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1791
+			}
1792
+		} else {
1793
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1794
+		}
1605 1795
 		if ($error != '') {
1606 1796
 			return $error;
1607
-		} elseif ($globalDebug) echo "Done\n";
1797
+		} elseif ($globalDebug) {
1798
+			echo "Done\n";
1799
+		}
1608 1800
 		return '';
1609 1801
 	}
1610 1802
 
1611 1803
 	public static function update_routes() {
1612 1804
 		global $tmp_dir, $globalDebug;
1613 1805
 		$error = '';
1614
-		if ($globalDebug) echo "Routes : Download...";
1806
+		if ($globalDebug) {
1807
+			echo "Routes : Download...";
1808
+		}
1615 1809
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1616 1810
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1617
-			if ($globalDebug) echo "Gunzip...";
1811
+			if ($globalDebug) {
1812
+				echo "Gunzip...";
1813
+			}
1618 1814
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1619
-			if ($globalDebug) echo "Add to DB...";
1815
+			if ($globalDebug) {
1816
+				echo "Add to DB...";
1817
+			}
1620 1818
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1621
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1819
+		} else {
1820
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1821
+		}
1622 1822
 		if ($error != '') {
1623 1823
 			return $error;
1624
-		} elseif ($globalDebug) echo "Done\n";
1824
+		} elseif ($globalDebug) {
1825
+			echo "Done\n";
1826
+		}
1625 1827
 		return '';
1626 1828
 	}
1627 1829
 	public static function update_oneworld() {
1628 1830
 		global $tmp_dir, $globalDebug;
1629 1831
 		$error = '';
1630
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1832
+		if ($globalDebug) {
1833
+			echo "Schedules Oneworld : Download...";
1834
+		}
1631 1835
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1632 1836
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1633
-			if ($globalDebug) echo "Gunzip...";
1837
+			if ($globalDebug) {
1838
+				echo "Gunzip...";
1839
+			}
1634 1840
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1635
-			if ($globalDebug) echo "Add to DB...";
1841
+			if ($globalDebug) {
1842
+				echo "Add to DB...";
1843
+			}
1636 1844
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1637
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1845
+		} else {
1846
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1847
+		}
1638 1848
 		if ($error != '') {
1639 1849
 			return $error;
1640
-		} elseif ($globalDebug) echo "Done\n";
1850
+		} elseif ($globalDebug) {
1851
+			echo "Done\n";
1852
+		}
1641 1853
 		return '';
1642 1854
 	}
1643 1855
 	public static function update_skyteam() {
1644 1856
 		global $tmp_dir, $globalDebug;
1645 1857
 		$error = '';
1646
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1858
+		if ($globalDebug) {
1859
+			echo "Schedules Skyteam : Download...";
1860
+		}
1647 1861
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1648 1862
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1649
-			if ($globalDebug) echo "Gunzip...";
1863
+			if ($globalDebug) {
1864
+				echo "Gunzip...";
1865
+			}
1650 1866
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1651
-			if ($globalDebug) echo "Add to DB...";
1867
+			if ($globalDebug) {
1868
+				echo "Add to DB...";
1869
+			}
1652 1870
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1653
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1871
+		} else {
1872
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1873
+		}
1654 1874
 		if ($error != '') {
1655 1875
 			return $error;
1656
-		} elseif ($globalDebug) echo "Done\n";
1876
+		} elseif ($globalDebug) {
1877
+			echo "Done\n";
1878
+		}
1657 1879
 		return '';
1658 1880
 	}
1659 1881
 	public static function update_ModeS() {
@@ -1670,355 +1892,619 @@  discard block
 block discarded – undo
1670 1892
 			exit;
1671 1893
 		} elseif ($globalDebug) echo "Done\n";
1672 1894
 */
1673
-		if ($globalDebug) echo "Modes : Download...";
1674
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1895
+		if ($globalDebug) {
1896
+			echo "Modes : Download...";
1897
+		}
1898
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1675 1899
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1676 1900
 
1677 1901
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1678 1902
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1679
-			if ($globalDebug) echo "Unzip...";
1680
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1903
+			if ($globalDebug) {
1904
+				echo "Unzip...";
1905
+			}
1906
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1681 1907
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1682
-			if ($globalDebug) echo "Add to DB...";
1908
+			if ($globalDebug) {
1909
+				echo "Add to DB...";
1910
+			}
1683 1911
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1684 1912
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1685
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1913
+		} else {
1914
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1915
+		}
1686 1916
 		if ($error != '') {
1687 1917
 			return $error;
1688
-		} elseif ($globalDebug) echo "Done\n";
1918
+		} elseif ($globalDebug) {
1919
+			echo "Done\n";
1920
+		}
1689 1921
 		return '';
1690 1922
 	}
1691 1923
 
1692 1924
 	public static function update_ModeS_faa() {
1693 1925
 		global $tmp_dir, $globalDebug;
1694
-		if ($globalDebug) echo "Modes FAA: Download...";
1926
+		if ($globalDebug) {
1927
+			echo "Modes FAA: Download...";
1928
+		}
1695 1929
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1696 1930
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1697
-			if ($globalDebug) echo "Unzip...";
1931
+			if ($globalDebug) {
1932
+				echo "Unzip...";
1933
+			}
1698 1934
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1699
-			if ($globalDebug) echo "Add to DB...";
1935
+			if ($globalDebug) {
1936
+				echo "Add to DB...";
1937
+			}
1700 1938
 			$error = update_db::modes_faa();
1701
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1939
+		} else {
1940
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1941
+		}
1702 1942
 		if ($error != '') {
1703 1943
 			return $error;
1704
-		} elseif ($globalDebug) echo "Done\n";
1944
+		} elseif ($globalDebug) {
1945
+			echo "Done\n";
1946
+		}
1705 1947
 		return '';
1706 1948
 	}
1707 1949
 
1708 1950
 	public static function update_ModeS_flarm() {
1709 1951
 		global $tmp_dir, $globalDebug;
1710
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1952
+		if ($globalDebug) {
1953
+			echo "Modes Flarmnet: Download...";
1954
+		}
1711 1955
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1712 1956
 		if (file_exists($tmp_dir.'data.fln')) {
1713
-			if ($globalDebug) echo "Add to DB...";
1957
+			if ($globalDebug) {
1958
+				echo "Add to DB...";
1959
+			}
1714 1960
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1715
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1961
+		} else {
1962
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1963
+		}
1716 1964
 		if ($error != '') {
1717 1965
 			return $error;
1718
-		} elseif ($globalDebug) echo "Done\n";
1966
+		} elseif ($globalDebug) {
1967
+			echo "Done\n";
1968
+		}
1719 1969
 		return '';
1720 1970
 	}
1721 1971
 
1722 1972
 	public static function update_ModeS_ogn() {
1723 1973
 		global $tmp_dir, $globalDebug;
1724
-		if ($globalDebug) echo "Modes OGN: Download...";
1974
+		if ($globalDebug) {
1975
+			echo "Modes OGN: Download...";
1976
+		}
1725 1977
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1726 1978
 		if (file_exists($tmp_dir.'ogn.csv')) {
1727
-			if ($globalDebug) echo "Add to DB...";
1979
+			if ($globalDebug) {
1980
+				echo "Add to DB...";
1981
+			}
1728 1982
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1729
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1983
+		} else {
1984
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1985
+		}
1730 1986
 		if ($error != '') {
1731 1987
 			return $error;
1732
-		} elseif ($globalDebug) echo "Done\n";
1988
+		} elseif ($globalDebug) {
1989
+			echo "Done\n";
1990
+		}
1733 1991
 		return '';
1734 1992
 	}
1735 1993
 
1736 1994
 	public static function update_owner() {
1737 1995
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1738 1996
 		
1739
-		if ($globalDebug) echo "Owner France: Download...";
1997
+		if ($globalDebug) {
1998
+			echo "Owner France: Download...";
1999
+		}
1740 2000
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1741 2001
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1742
-			if ($globalDebug) echo "Add to DB...";
2002
+			if ($globalDebug) {
2003
+				echo "Add to DB...";
2004
+			}
1743 2005
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1744
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2006
+		} else {
2007
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2008
+		}
1745 2009
 		if ($error != '') {
1746 2010
 			return $error;
1747
-		} elseif ($globalDebug) echo "Done\n";
2011
+		} elseif ($globalDebug) {
2012
+			echo "Done\n";
2013
+		}
1748 2014
 		
1749
-		if ($globalDebug) echo "Owner Ireland: Download...";
2015
+		if ($globalDebug) {
2016
+			echo "Owner Ireland: Download...";
2017
+		}
1750 2018
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1751 2019
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1752
-			if ($globalDebug) echo "Add to DB...";
2020
+			if ($globalDebug) {
2021
+				echo "Add to DB...";
2022
+			}
1753 2023
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1754
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2024
+		} else {
2025
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2026
+		}
1755 2027
 		if ($error != '') {
1756 2028
 			return $error;
1757
-		} elseif ($globalDebug) echo "Done\n";
1758
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2029
+		} elseif ($globalDebug) {
2030
+			echo "Done\n";
2031
+		}
2032
+		if ($globalDebug) {
2033
+			echo "Owner Switzerland: Download...";
2034
+		}
1759 2035
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1760 2036
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1761
-			if ($globalDebug) echo "Add to DB...";
2037
+			if ($globalDebug) {
2038
+				echo "Add to DB...";
2039
+			}
1762 2040
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1763
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2041
+		} else {
2042
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2043
+		}
1764 2044
 		if ($error != '') {
1765 2045
 			return $error;
1766
-		} elseif ($globalDebug) echo "Done\n";
1767
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2046
+		} elseif ($globalDebug) {
2047
+			echo "Done\n";
2048
+		}
2049
+		if ($globalDebug) {
2050
+			echo "Owner Czech Republic: Download...";
2051
+		}
1768 2052
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1769 2053
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1770
-			if ($globalDebug) echo "Add to DB...";
2054
+			if ($globalDebug) {
2055
+				echo "Add to DB...";
2056
+			}
1771 2057
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1772
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2058
+		} else {
2059
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2060
+		}
1773 2061
 		if ($error != '') {
1774 2062
 			return $error;
1775
-		} elseif ($globalDebug) echo "Done\n";
1776
-		if ($globalDebug) echo "Owner Australia: Download...";
2063
+		} elseif ($globalDebug) {
2064
+			echo "Done\n";
2065
+		}
2066
+		if ($globalDebug) {
2067
+			echo "Owner Australia: Download...";
2068
+		}
1777 2069
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1778 2070
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1779
-			if ($globalDebug) echo "Add to DB...";
2071
+			if ($globalDebug) {
2072
+				echo "Add to DB...";
2073
+			}
1780 2074
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1781
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2075
+		} else {
2076
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2077
+		}
1782 2078
 		if ($error != '') {
1783 2079
 			return $error;
1784
-		} elseif ($globalDebug) echo "Done\n";
1785
-		if ($globalDebug) echo "Owner Austria: Download...";
2080
+		} elseif ($globalDebug) {
2081
+			echo "Done\n";
2082
+		}
2083
+		if ($globalDebug) {
2084
+			echo "Owner Austria: Download...";
2085
+		}
1786 2086
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1787 2087
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1788
-			if ($globalDebug) echo "Add to DB...";
2088
+			if ($globalDebug) {
2089
+				echo "Add to DB...";
2090
+			}
1789 2091
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1790
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2092
+		} else {
2093
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2094
+		}
1791 2095
 		if ($error != '') {
1792 2096
 			return $error;
1793
-		} elseif ($globalDebug) echo "Done\n";
1794
-		if ($globalDebug) echo "Owner Chile: Download...";
2097
+		} elseif ($globalDebug) {
2098
+			echo "Done\n";
2099
+		}
2100
+		if ($globalDebug) {
2101
+			echo "Owner Chile: Download...";
2102
+		}
1795 2103
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1796 2104
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1797
-			if ($globalDebug) echo "Add to DB...";
2105
+			if ($globalDebug) {
2106
+				echo "Add to DB...";
2107
+			}
1798 2108
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1799
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2109
+		} else {
2110
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2111
+		}
1800 2112
 		if ($error != '') {
1801 2113
 			return $error;
1802
-		} elseif ($globalDebug) echo "Done\n";
1803
-		if ($globalDebug) echo "Owner Colombia: Download...";
2114
+		} elseif ($globalDebug) {
2115
+			echo "Done\n";
2116
+		}
2117
+		if ($globalDebug) {
2118
+			echo "Owner Colombia: Download...";
2119
+		}
1804 2120
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1805 2121
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1806
-			if ($globalDebug) echo "Add to DB...";
2122
+			if ($globalDebug) {
2123
+				echo "Add to DB...";
2124
+			}
1807 2125
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1808
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2126
+		} else {
2127
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2128
+		}
1809 2129
 		if ($error != '') {
1810 2130
 			return $error;
1811
-		} elseif ($globalDebug) echo "Done\n";
1812
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2131
+		} elseif ($globalDebug) {
2132
+			echo "Done\n";
2133
+		}
2134
+		if ($globalDebug) {
2135
+			echo "Owner Bosnia Herzegobina: Download...";
2136
+		}
1813 2137
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1814 2138
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1815
-			if ($globalDebug) echo "Add to DB...";
2139
+			if ($globalDebug) {
2140
+				echo "Add to DB...";
2141
+			}
1816 2142
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1817
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2143
+		} else {
2144
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2145
+		}
1818 2146
 		if ($error != '') {
1819 2147
 			return $error;
1820
-		} elseif ($globalDebug) echo "Done\n";
1821
-		if ($globalDebug) echo "Owner Brazil: Download...";
2148
+		} elseif ($globalDebug) {
2149
+			echo "Done\n";
2150
+		}
2151
+		if ($globalDebug) {
2152
+			echo "Owner Brazil: Download...";
2153
+		}
1822 2154
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1823 2155
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1824
-			if ($globalDebug) echo "Add to DB...";
2156
+			if ($globalDebug) {
2157
+				echo "Add to DB...";
2158
+			}
1825 2159
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1826
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2160
+		} else {
2161
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2162
+		}
1827 2163
 		if ($error != '') {
1828 2164
 			return $error;
1829
-		} elseif ($globalDebug) echo "Done\n";
1830
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2165
+		} elseif ($globalDebug) {
2166
+			echo "Done\n";
2167
+		}
2168
+		if ($globalDebug) {
2169
+			echo "Owner Cayman Islands: Download...";
2170
+		}
1831 2171
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1832 2172
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1833
-			if ($globalDebug) echo "Add to DB...";
2173
+			if ($globalDebug) {
2174
+				echo "Add to DB...";
2175
+			}
1834 2176
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1835
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2177
+		} else {
2178
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2179
+		}
1836 2180
 		if ($error != '') {
1837 2181
 			return $error;
1838
-		} elseif ($globalDebug) echo "Done\n";
1839
-		if ($globalDebug) echo "Owner Croatia: Download...";
2182
+		} elseif ($globalDebug) {
2183
+			echo "Done\n";
2184
+		}
2185
+		if ($globalDebug) {
2186
+			echo "Owner Croatia: Download...";
2187
+		}
1840 2188
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1841 2189
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1842
-			if ($globalDebug) echo "Add to DB...";
2190
+			if ($globalDebug) {
2191
+				echo "Add to DB...";
2192
+			}
1843 2193
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1844
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2194
+		} else {
2195
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2196
+		}
1845 2197
 		if ($error != '') {
1846 2198
 			return $error;
1847
-		} elseif ($globalDebug) echo "Done\n";
1848
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2199
+		} elseif ($globalDebug) {
2200
+			echo "Done\n";
2201
+		}
2202
+		if ($globalDebug) {
2203
+			echo "Owner Luxembourg: Download...";
2204
+		}
1849 2205
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1850 2206
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1851
-			if ($globalDebug) echo "Add to DB...";
2207
+			if ($globalDebug) {
2208
+				echo "Add to DB...";
2209
+			}
1852 2210
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1853
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2211
+		} else {
2212
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2213
+		}
1854 2214
 		if ($error != '') {
1855 2215
 			return $error;
1856
-		} elseif ($globalDebug) echo "Done\n";
1857
-		if ($globalDebug) echo "Owner Maldives: Download...";
2216
+		} elseif ($globalDebug) {
2217
+			echo "Done\n";
2218
+		}
2219
+		if ($globalDebug) {
2220
+			echo "Owner Maldives: Download...";
2221
+		}
1858 2222
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1859 2223
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1860
-			if ($globalDebug) echo "Add to DB...";
2224
+			if ($globalDebug) {
2225
+				echo "Add to DB...";
2226
+			}
1861 2227
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1862
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2228
+		} else {
2229
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2230
+		}
1863 2231
 		if ($error != '') {
1864 2232
 			return $error;
1865
-		} elseif ($globalDebug) echo "Done\n";
1866
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2233
+		} elseif ($globalDebug) {
2234
+			echo "Done\n";
2235
+		}
2236
+		if ($globalDebug) {
2237
+			echo "Owner New Zealand: Download...";
2238
+		}
1867 2239
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1868 2240
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1869
-			if ($globalDebug) echo "Add to DB...";
2241
+			if ($globalDebug) {
2242
+				echo "Add to DB...";
2243
+			}
1870 2244
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1871
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2245
+		} else {
2246
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2247
+		}
1872 2248
 		if ($error != '') {
1873 2249
 			return $error;
1874
-		} elseif ($globalDebug) echo "Done\n";
1875
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2250
+		} elseif ($globalDebug) {
2251
+			echo "Done\n";
2252
+		}
2253
+		if ($globalDebug) {
2254
+			echo "Owner Papua New Guinea: Download...";
2255
+		}
1876 2256
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1877 2257
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1878
-			if ($globalDebug) echo "Add to DB...";
2258
+			if ($globalDebug) {
2259
+				echo "Add to DB...";
2260
+			}
1879 2261
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1880
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2262
+		} else {
2263
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2264
+		}
1881 2265
 		if ($error != '') {
1882 2266
 			return $error;
1883
-		} elseif ($globalDebug) echo "Done\n";
1884
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2267
+		} elseif ($globalDebug) {
2268
+			echo "Done\n";
2269
+		}
2270
+		if ($globalDebug) {
2271
+			echo "Owner Slovakia: Download...";
2272
+		}
1885 2273
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1886 2274
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1887
-			if ($globalDebug) echo "Add to DB...";
2275
+			if ($globalDebug) {
2276
+				echo "Add to DB...";
2277
+			}
1888 2278
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1889
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2279
+		} else {
2280
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2281
+		}
1890 2282
 		if ($error != '') {
1891 2283
 			return $error;
1892
-		} elseif ($globalDebug) echo "Done\n";
1893
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2284
+		} elseif ($globalDebug) {
2285
+			echo "Done\n";
2286
+		}
2287
+		if ($globalDebug) {
2288
+			echo "Owner Ecuador: Download...";
2289
+		}
1894 2290
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1895 2291
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1896
-			if ($globalDebug) echo "Add to DB...";
2292
+			if ($globalDebug) {
2293
+				echo "Add to DB...";
2294
+			}
1897 2295
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1898
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2296
+		} else {
2297
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2298
+		}
1899 2299
 		if ($error != '') {
1900 2300
 			return $error;
1901
-		} elseif ($globalDebug) echo "Done\n";
1902
-		if ($globalDebug) echo "Owner Iceland: Download...";
2301
+		} elseif ($globalDebug) {
2302
+			echo "Done\n";
2303
+		}
2304
+		if ($globalDebug) {
2305
+			echo "Owner Iceland: Download...";
2306
+		}
1903 2307
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1904 2308
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1905
-			if ($globalDebug) echo "Add to DB...";
2309
+			if ($globalDebug) {
2310
+				echo "Add to DB...";
2311
+			}
1906 2312
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1907
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2313
+		} else {
2314
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2315
+		}
1908 2316
 		if ($error != '') {
1909 2317
 			return $error;
1910
-		} elseif ($globalDebug) echo "Done\n";
1911
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2318
+		} elseif ($globalDebug) {
2319
+			echo "Done\n";
2320
+		}
2321
+		if ($globalDebug) {
2322
+			echo "Owner Isle of Man: Download...";
2323
+		}
1912 2324
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1913 2325
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1914
-			if ($globalDebug) echo "Add to DB...";
2326
+			if ($globalDebug) {
2327
+				echo "Add to DB...";
2328
+			}
1915 2329
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1916
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2330
+		} else {
2331
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2332
+		}
1917 2333
 		if ($error != '') {
1918 2334
 			return $error;
1919
-		} elseif ($globalDebug) echo "Done\n";
2335
+		} elseif ($globalDebug) {
2336
+			echo "Done\n";
2337
+		}
1920 2338
 		if ($globalMasterSource) {
1921
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2339
+			if ($globalDebug) {
2340
+				echo "ModeS Netherlands: Download...";
2341
+			}
1922 2342
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1923 2343
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1924
-				if ($globalDebug) echo "Add to DB...";
2344
+				if ($globalDebug) {
2345
+					echo "Add to DB...";
2346
+				}
1925 2347
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1926
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2348
+			} else {
2349
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2350
+			}
1927 2351
 			if ($error != '') {
1928 2352
 				return $error;
1929
-			} elseif ($globalDebug) echo "Done\n";
1930
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2353
+			} elseif ($globalDebug) {
2354
+				echo "Done\n";
2355
+			}
2356
+			if ($globalDebug) {
2357
+				echo "ModeS Denmark: Download...";
2358
+			}
1931 2359
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1932 2360
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1933
-				if ($globalDebug) echo "Add to DB...";
2361
+				if ($globalDebug) {
2362
+					echo "Add to DB...";
2363
+				}
1934 2364
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1935
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2365
+			} else {
2366
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2367
+			}
1936 2368
 			if ($error != '') {
1937 2369
 				return $error;
1938
-			} elseif ($globalDebug) echo "Done\n";
1939
-		} elseif ($globalDebug) echo "Done\n";
2370
+			} elseif ($globalDebug) {
2371
+				echo "Done\n";
2372
+			}
2373
+		} elseif ($globalDebug) {
2374
+			echo "Done\n";
2375
+		}
1940 2376
 		return '';
1941 2377
 	}
1942 2378
 
1943 2379
 	public static function update_translation() {
1944 2380
 		global $tmp_dir, $globalDebug;
1945 2381
 		$error = '';
1946
-		if ($globalDebug) echo "Translation : Download...";
2382
+		if ($globalDebug) {
2383
+			echo "Translation : Download...";
2384
+		}
1947 2385
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1948 2386
 		if (file_exists($tmp_dir.'translation.zip')) {
1949
-			if ($globalDebug) echo "Unzip...";
2387
+			if ($globalDebug) {
2388
+				echo "Unzip...";
2389
+			}
1950 2390
 			update_db::unzip($tmp_dir.'translation.zip');
1951
-			if ($globalDebug) echo "Add to DB...";
2391
+			if ($globalDebug) {
2392
+				echo "Add to DB...";
2393
+			}
1952 2394
 			$error = update_db::translation();
1953
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2395
+		} else {
2396
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2397
+		}
1954 2398
 		if ($error != '') {
1955 2399
 			return $error;
1956
-		} elseif ($globalDebug) echo "Done\n";
2400
+		} elseif ($globalDebug) {
2401
+			echo "Done\n";
2402
+		}
1957 2403
 		return '';
1958 2404
 	}
1959 2405
 
1960 2406
 	public static function update_translation_fam() {
1961 2407
 		global $tmp_dir, $globalDebug;
1962
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2408
+		if ($globalDebug) {
2409
+			echo "Translation from FlightAirMap website : Download...";
2410
+		}
1963 2411
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1964 2412
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1965
-			if ($globalDebug) echo "Gunzip...";
2413
+			if ($globalDebug) {
2414
+				echo "Gunzip...";
2415
+			}
1966 2416
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1967
-			if ($globalDebug) echo "Add to DB...";
2417
+			if ($globalDebug) {
2418
+				echo "Add to DB...";
2419
+			}
1968 2420
 			$error = update_db::translation_fam();
1969
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2421
+		} else {
2422
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2423
+		}
1970 2424
 		if ($error != '') {
1971 2425
 			return $error;
1972
-		} elseif ($globalDebug) echo "Done\n";
2426
+		} elseif ($globalDebug) {
2427
+			echo "Done\n";
2428
+		}
1973 2429
 		return '';
1974 2430
 	}
1975 2431
 	public static function update_ModeS_fam() {
1976 2432
 		global $tmp_dir, $globalDebug;
1977
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2433
+		if ($globalDebug) {
2434
+			echo "ModeS from FlightAirMap website : Download...";
2435
+		}
1978 2436
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1979 2437
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1980
-			if ($globalDebug) echo "Gunzip...";
2438
+			if ($globalDebug) {
2439
+				echo "Gunzip...";
2440
+			}
1981 2441
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1982
-			if ($globalDebug) echo "Add to DB...";
2442
+			if ($globalDebug) {
2443
+				echo "Add to DB...";
2444
+			}
1983 2445
 			$error = update_db::modes_fam();
1984
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2446
+		} else {
2447
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2448
+		}
1985 2449
 		if ($error != '') {
1986 2450
 			return $error;
1987
-		} elseif ($globalDebug) echo "Done\n";
2451
+		} elseif ($globalDebug) {
2452
+			echo "Done\n";
2453
+		}
1988 2454
 		return '';
1989 2455
 	}
1990 2456
 	public static function update_owner_fam() {
1991 2457
 		global $tmp_dir, $globalDebug, $globalOwner;
1992
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2458
+		if ($globalDebug) {
2459
+			echo "owner from FlightAirMap website : Download...";
2460
+		}
1993 2461
 		if ($globalOwner === TRUE) {
1994 2462
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1995 2463
 		} else {
1996 2464
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1997 2465
 		}
1998 2466
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1999
-			if ($globalDebug) echo "Gunzip...";
2467
+			if ($globalDebug) {
2468
+				echo "Gunzip...";
2469
+			}
2000 2470
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
2001
-			if ($globalDebug) echo "Add to DB...";
2471
+			if ($globalDebug) {
2472
+				echo "Add to DB...";
2473
+			}
2002 2474
 			$error = update_db::owner_fam();
2003
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2475
+		} else {
2476
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2477
+		}
2004 2478
 		if ($error != '') {
2005 2479
 			return $error;
2006
-		} elseif ($globalDebug) echo "Done\n";
2480
+		} elseif ($globalDebug) {
2481
+			echo "Done\n";
2482
+		}
2007 2483
 		return '';
2008 2484
 	}
2009 2485
 	public static function update_routes_fam() {
2010 2486
 		global $tmp_dir, $globalDebug;
2011
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2487
+		if ($globalDebug) {
2488
+			echo "Routes from FlightAirMap website : Download...";
2489
+		}
2012 2490
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2013 2491
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2014
-			if ($globalDebug) echo "Gunzip...";
2492
+			if ($globalDebug) {
2493
+				echo "Gunzip...";
2494
+			}
2015 2495
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
2016
-			if ($globalDebug) echo "Add to DB...";
2496
+			if ($globalDebug) {
2497
+				echo "Add to DB...";
2498
+			}
2017 2499
 			$error = update_db::routes_fam();
2018
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2500
+		} else {
2501
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2502
+		}
2019 2503
 		if ($error != '') {
2020 2504
 			return $error;
2021
-		} elseif ($globalDebug) echo "Done\n";
2505
+		} elseif ($globalDebug) {
2506
+			echo "Done\n";
2507
+		}
2022 2508
 		return '';
2023 2509
 	}
2024 2510
 	public static function update_marine_identity_fam() {
@@ -2028,14 +2514,22 @@  discard block
 block discarded – undo
2028 2514
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2029 2515
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2030 2516
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2031
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2517
+				if ($globalDebug) {
2518
+					echo "Marine identity from FlightAirMap website : Download...";
2519
+				}
2032 2520
 				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2033 2521
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2034
-					if ($globalDebug) echo "Gunzip...";
2522
+					if ($globalDebug) {
2523
+						echo "Gunzip...";
2524
+					}
2035 2525
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2036
-					if ($globalDebug) echo "Add to DB...";
2526
+					if ($globalDebug) {
2527
+						echo "Add to DB...";
2528
+					}
2037 2529
 					$error = update_db::marine_identity_fam();
2038
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2530
+				} else {
2531
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2532
+				}
2039 2533
 				if ($error != '') {
2040 2534
 					return $error;
2041 2535
 				} elseif ($globalDebug) {
@@ -2048,17 +2542,25 @@  discard block
 block discarded – undo
2048 2542
 	}
2049 2543
 	public static function update_banned_fam() {
2050 2544
 		global $tmp_dir, $globalDebug;
2051
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2545
+		if ($globalDebug) {
2546
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2547
+		}
2052 2548
 		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv');
2053 2549
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2054 2550
 			//if ($globalDebug) echo "Gunzip...";
2055 2551
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2056
-			if ($globalDebug) echo "Add to DB...";
2552
+			if ($globalDebug) {
2553
+				echo "Add to DB...";
2554
+			}
2057 2555
 			$error = update_db::banned_fam();
2058
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2556
+		} else {
2557
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2558
+		}
2059 2559
 		if ($error != '') {
2060 2560
 			return $error;
2061
-		} elseif ($globalDebug) echo "Done\n";
2561
+		} elseif ($globalDebug) {
2562
+			echo "Done\n";
2563
+		}
2062 2564
 		return '';
2063 2565
 	}
2064 2566
 
@@ -2066,7 +2568,9 @@  discard block
 block discarded – undo
2066 2568
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2067 2569
 		include_once('class.create_db.php');
2068 2570
 		$error = '';
2069
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2571
+		if ($globalDebug) {
2572
+			echo "Airspace from FlightAirMap website : Download...";
2573
+		}
2070 2574
 		if ($globalDBdriver == 'mysql') {
2071 2575
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2072 2576
 		} else {
@@ -2082,9 +2586,13 @@  discard block
 block discarded – undo
2082 2586
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2083 2587
 				}
2084 2588
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2085
-					if ($globalDebug) echo "Gunzip...";
2589
+					if ($globalDebug) {
2590
+						echo "Gunzip...";
2591
+					}
2086 2592
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
2087
-					if ($globalDebug) echo "Add to DB...";
2593
+					if ($globalDebug) {
2594
+						echo "Add to DB...";
2595
+					}
2088 2596
 					$Connection = new Connection();
2089 2597
 					if ($Connection->tableExists('airspace')) {
2090 2598
 						$query = 'DROP TABLE airspace';
@@ -2097,31 +2605,47 @@  discard block
 block discarded – undo
2097 2605
 		    			}
2098 2606
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2099 2607
 					update_db::insert_airspace_version($airspace_md5);
2100
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2608
+				} else {
2609
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2610
+				}
2101 2611
 			}
2102
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2612
+		} else {
2613
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2614
+		}
2103 2615
 		if ($error != '') {
2104 2616
 			return $error;
2105
-		} elseif ($globalDebug) echo "Done\n";
2617
+		} elseif ($globalDebug) {
2618
+			echo "Done\n";
2619
+		}
2106 2620
 		return '';
2107 2621
 	}
2108 2622
 
2109 2623
 	public static function update_tle() {
2110 2624
 		global $tmp_dir, $globalDebug;
2111
-		if ($globalDebug) echo "Download TLE : Download...";
2625
+		if ($globalDebug) {
2626
+			echo "Download TLE : Download...";
2627
+		}
2112 2628
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2113 2629
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2114 2630
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2115 2631
 		foreach ($alltle as $filename) {
2116
-			if ($globalDebug) echo "downloading ".$filename.'...';
2632
+			if ($globalDebug) {
2633
+				echo "downloading ".$filename.'...';
2634
+			}
2117 2635
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2118 2636
 			if (file_exists($tmp_dir.$filename)) {
2119
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2637
+				if ($globalDebug) {
2638
+					echo "Add to DB ".$filename."...";
2639
+				}
2120 2640
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2121
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2641
+			} else {
2642
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2643
+			}
2122 2644
 			if ($error != '') {
2123 2645
 				echo $error."\n";
2124
-			} elseif ($globalDebug) echo "Done\n";
2646
+			} elseif ($globalDebug) {
2647
+				echo "Done\n";
2648
+			}
2125 2649
 		}
2126 2650
 		return '';
2127 2651
 	}
@@ -2129,10 +2653,14 @@  discard block
 block discarded – undo
2129 2653
 	public static function update_models() {
2130 2654
 		global $tmp_dir, $globalDebug;
2131 2655
 		$error = '';
2132
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2656
+		if ($globalDebug) {
2657
+			echo "Models from FlightAirMap website : Download...";
2658
+		}
2133 2659
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2134 2660
 		if (file_exists($tmp_dir.'models.md5sum')) {
2135
-			if ($globalDebug) echo "Check files...\n";
2661
+			if ($globalDebug) {
2662
+				echo "Check files...\n";
2663
+			}
2136 2664
 			$newmodelsdb = array();
2137 2665
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2138 2666
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2151,25 +2679,35 @@  discard block
 block discarded – undo
2151 2679
 			}
2152 2680
 			$diff = array_diff($newmodelsdb,$modelsdb);
2153 2681
 			foreach ($diff as $key => $value) {
2154
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2682
+				if ($globalDebug) {
2683
+					echo 'Downloading model '.$key.' ...'."\n";
2684
+				}
2155 2685
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2156 2686
 				
2157 2687
 			}
2158 2688
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2159
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2689
+		} else {
2690
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2691
+		}
2160 2692
 		if ($error != '') {
2161 2693
 			return $error;
2162
-		} elseif ($globalDebug) echo "Done\n";
2694
+		} elseif ($globalDebug) {
2695
+			echo "Done\n";
2696
+		}
2163 2697
 		return '';
2164 2698
 	}
2165 2699
 
2166 2700
 	public static function update_space_models() {
2167 2701
 		global $tmp_dir, $globalDebug;
2168 2702
 		$error = '';
2169
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2703
+		if ($globalDebug) {
2704
+			echo "Space models from FlightAirMap website : Download...";
2705
+		}
2170 2706
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2171 2707
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2172
-			if ($globalDebug) echo "Check files...\n";
2708
+			if ($globalDebug) {
2709
+				echo "Check files...\n";
2710
+			}
2173 2711
 			$newmodelsdb = array();
2174 2712
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2175 2713
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2188,25 +2726,35 @@  discard block
 block discarded – undo
2188 2726
 			}
2189 2727
 			$diff = array_diff($newmodelsdb,$modelsdb);
2190 2728
 			foreach ($diff as $key => $value) {
2191
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2729
+				if ($globalDebug) {
2730
+					echo 'Downloading space model '.$key.' ...'."\n";
2731
+				}
2192 2732
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2193 2733
 				
2194 2734
 			}
2195 2735
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2196
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2736
+		} else {
2737
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2738
+		}
2197 2739
 		if ($error != '') {
2198 2740
 			return $error;
2199
-		} elseif ($globalDebug) echo "Done\n";
2741
+		} elseif ($globalDebug) {
2742
+			echo "Done\n";
2743
+		}
2200 2744
 		return '';
2201 2745
 	}
2202 2746
 
2203 2747
 	public static function update_vehicules_models() {
2204 2748
 		global $tmp_dir, $globalDebug;
2205 2749
 		$error = '';
2206
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2750
+		if ($globalDebug) {
2751
+			echo "Vehicules models from FlightAirMap website : Download...";
2752
+		}
2207 2753
 		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2208 2754
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2209
-			if ($globalDebug) echo "Check files...\n";
2755
+			if ($globalDebug) {
2756
+				echo "Check files...\n";
2757
+			}
2210 2758
 			$newmodelsdb = array();
2211 2759
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2212 2760
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2225,15 +2773,21 @@  discard block
 block discarded – undo
2225 2773
 			}
2226 2774
 			$diff = array_diff($newmodelsdb,$modelsdb);
2227 2775
 			foreach ($diff as $key => $value) {
2228
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2776
+				if ($globalDebug) {
2777
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
2778
+				}
2229 2779
 				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2230 2780
 				
2231 2781
 			}
2232 2782
 			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2233
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2783
+		} else {
2784
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2785
+		}
2234 2786
 		if ($error != '') {
2235 2787
 			return $error;
2236
-		} elseif ($globalDebug) echo "Done\n";
2788
+		} elseif ($globalDebug) {
2789
+			echo "Done\n";
2790
+		}
2237 2791
 		return '';
2238 2792
 	}
2239 2793
 
@@ -2276,7 +2830,9 @@  discard block
 block discarded – undo
2276 2830
                 }
2277 2831
 
2278 2832
 		$error = '';
2279
-		if ($globalDebug) echo "Notam : Download...";
2833
+		if ($globalDebug) {
2834
+			echo "Notam : Download...";
2835
+		}
2280 2836
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2281 2837
 		if (file_exists($tmp_dir.'notam.rss')) {
2282 2838
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2291,14 +2847,30 @@  discard block
 block discarded – undo
2291 2847
 				$data['fir'] = $q[0];
2292 2848
 				$data['code'] = $q[1];
2293 2849
 				$ifrvfr = $q[2];
2294
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2295
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2296
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2297
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2298
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2299
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2300
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2301
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2850
+				if ($ifrvfr == 'IV') {
2851
+					$data['rules'] = 'IFR/VFR';
2852
+				}
2853
+				if ($ifrvfr == 'I') {
2854
+					$data['rules'] = 'IFR';
2855
+				}
2856
+				if ($ifrvfr == 'V') {
2857
+					$data['rules'] = 'VFR';
2858
+				}
2859
+				if ($q[4] == 'A') {
2860
+					$data['scope'] = 'Airport warning';
2861
+				}
2862
+				if ($q[4] == 'E') {
2863
+					$data['scope'] = 'Enroute warning';
2864
+				}
2865
+				if ($q[4] == 'W') {
2866
+					$data['scope'] = 'Navigation warning';
2867
+				}
2868
+				if ($q[4] == 'AE') {
2869
+					$data['scope'] = 'Airport/Enroute warning';
2870
+				}
2871
+				if ($q[4] == 'AW') {
2872
+					$data['scope'] = 'Airport/Navigation warning';
2873
+				}
2302 2874
 				//$data['scope'] = $q[4];
2303 2875
 				$data['lower_limit'] = $q[5];
2304 2876
 				$data['upper_limit'] = $q[6];
@@ -2306,8 +2878,12 @@  discard block
 block discarded – undo
2306 2878
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2307 2879
 				$latitude = $Common->convertDec($las,'latitude');
2308 2880
 				$longitude = $Common->convertDec($lns,'longitude');
2309
-				if ($lac == 'S') $latitude = '-'.$latitude;
2310
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2881
+				if ($lac == 'S') {
2882
+					$latitude = '-'.$latitude;
2883
+				}
2884
+				if ($lnc == 'W') {
2885
+					$longitude = '-'.$longitude;
2886
+				}
2311 2887
 				$data['center_latitude'] = $latitude;
2312 2888
 				$data['center_longitude'] = $longitude;
2313 2889
 				$data['radius'] = intval($radius);
@@ -2337,10 +2913,14 @@  discard block
 block discarded – undo
2337 2913
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2338 2914
 				unset($data);
2339 2915
 			} 
2340
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2916
+		} else {
2917
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2918
+		}
2341 2919
 		if ($error != '') {
2342 2920
 			return $error;
2343
-		} elseif ($globalDebug) echo "Done\n";
2921
+		} elseif ($globalDebug) {
2922
+			echo "Done\n";
2923
+		}
2344 2924
 		return '';
2345 2925
 	}
2346 2926
 	
@@ -2365,7 +2945,9 @@  discard block
 block discarded – undo
2365 2945
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2366 2946
 		$airspace_json = json_decode($airspace_lst,true);
2367 2947
 		foreach ($airspace_json['records'] as $airspace) {
2368
-			if ($globalDebug) echo $airspace['name']."...\n";
2948
+			if ($globalDebug) {
2949
+				echo $airspace['name']."...\n";
2950
+			}
2369 2951
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2370 2952
 			if (file_exists($tmp_dir.$airspace['name'])) {
2371 2953
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2409,8 +2991,11 @@  discard block
 block discarded – undo
2409 2991
                         return "error : ".$e->getMessage();
2410 2992
                 }
2411 2993
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2412
-                if ($row['nb'] > 0) return false;
2413
-                else return true;
2994
+                if ($row['nb'] > 0) {
2995
+                	return false;
2996
+                } else {
2997
+                	return true;
2998
+                }
2414 2999
 	}
2415 3000
 
2416 3001
 	public static function insert_last_update() {
@@ -2435,8 +3020,11 @@  discard block
 block discarded – undo
2435 3020
                         return "error : ".$e->getMessage();
2436 3021
                 }
2437 3022
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2438
-                if ($row['nb'] > 0) return true;
2439
-                else return false;
3023
+                if ($row['nb'] > 0) {
3024
+                	return true;
3025
+                } else {
3026
+                	return false;
3027
+                }
2440 3028
 	}
2441 3029
 
2442 3030
 	public static function check_marine_identity_version($version) {
@@ -2449,8 +3037,11 @@  discard block
 block discarded – undo
2449 3037
                         return "error : ".$e->getMessage();
2450 3038
                 }
2451 3039
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2452
-                if ($row['nb'] > 0) return true;
2453
-                else return false;
3040
+                if ($row['nb'] > 0) {
3041
+                	return true;
3042
+                } else {
3043
+                	return false;
3044
+                }
2454 3045
 	}
2455 3046
 
2456 3047
 
@@ -2493,8 +3084,11 @@  discard block
 block discarded – undo
2493 3084
                         return "error : ".$e->getMessage();
2494 3085
                 }
2495 3086
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2496
-                if ($row['nb'] > 0) return false;
2497
-                else return true;
3087
+                if ($row['nb'] > 0) {
3088
+                	return false;
3089
+                } else {
3090
+                	return true;
3091
+                }
2498 3092
 	}
2499 3093
 
2500 3094
 	public static function insert_last_notam_update() {
@@ -2523,8 +3117,11 @@  discard block
 block discarded – undo
2523 3117
                         return "error : ".$e->getMessage();
2524 3118
                 }
2525 3119
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2526
-                if ($row['nb'] > 0) return false;
2527
-                else return true;
3120
+                if ($row['nb'] > 0) {
3121
+                	return false;
3122
+                } else {
3123
+                	return true;
3124
+                }
2528 3125
 	}
2529 3126
 
2530 3127
 	public static function insert_last_airspace_update() {
@@ -2554,8 +3151,11 @@  discard block
 block discarded – undo
2554 3151
                         return "error : ".$e->getMessage();
2555 3152
                 }
2556 3153
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2557
-                if ($row['nb'] > 0) return false;
2558
-                else return true;
3154
+                if ($row['nb'] > 0) {
3155
+                	return false;
3156
+                } else {
3157
+                	return true;
3158
+                }
2559 3159
 	}
2560 3160
 
2561 3161
 	public static function insert_last_owner_update() {
@@ -2584,8 +3184,11 @@  discard block
 block discarded – undo
2584 3184
                         return "error : ".$e->getMessage();
2585 3185
                 }
2586 3186
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2587
-                if ($row['nb'] > 0) return false;
2588
-                else return true;
3187
+                if ($row['nb'] > 0) {
3188
+                	return false;
3189
+                } else {
3190
+                	return true;
3191
+                }
2589 3192
 	}
2590 3193
 
2591 3194
 	public static function insert_last_schedules_update() {
@@ -2614,8 +3217,11 @@  discard block
 block discarded – undo
2614 3217
                         return "error : ".$e->getMessage();
2615 3218
                 }
2616 3219
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2617
-                if ($row['nb'] > 0) return false;
2618
-                else return true;
3220
+                if ($row['nb'] > 0) {
3221
+                	return false;
3222
+                } else {
3223
+                	return true;
3224
+                }
2619 3225
 	}
2620 3226
 
2621 3227
 	public static function insert_last_tle_update() {
@@ -2644,8 +3250,11 @@  discard block
 block discarded – undo
2644 3250
                         return "error : ".$e->getMessage();
2645 3251
                 }
2646 3252
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2647
-                if ($row['nb'] > 0) return false;
2648
-                else return true;
3253
+                if ($row['nb'] > 0) {
3254
+                	return false;
3255
+                } else {
3256
+                	return true;
3257
+                }
2649 3258
 	}
2650 3259
 
2651 3260
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +358 added lines, -132 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,35 +1751,55 @@  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('marine_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
 		} else {
1683 1783
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1684
-			if ($error != '') return $error;
1784
+			if ($error != '') {
1785
+				return $error;
1786
+			}
1685 1787
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1686
-			if ($error != '') return $error;
1788
+			if ($error != '') {
1789
+				return $error;
1790
+			}
1687 1791
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1688
-			if ($error != '') return $error;
1792
+			if ($error != '') {
1793
+				return $error;
1794
+			}
1689 1795
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1690
-			if ($error != '') return $error;
1796
+			if ($error != '') {
1797
+				return $error;
1798
+			}
1691 1799
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1692
-			if ($error != '') return $error;
1800
+			if ($error != '') {
1801
+				return $error;
1802
+			}
1693 1803
 		}
1694 1804
 		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) {
1695 1805
 			// Add index key
@@ -1719,8 +1829,11 @@  discard block
 block discarded – undo
1719 1829
     	    if ($Connection->tableExists('aircraft')) {
1720 1830
     		if (!$Connection->tableExists('config')) {
1721 1831
     		    $version = '1';
1722
-    		    if ($update) return self::update_from_1();
1723
-    		    else return $version;
1832
+    		    if ($update) {
1833
+    		    	return self::update_from_1();
1834
+    		    } else {
1835
+    		    	return $version;
1836
+    		    }
1724 1837
 		} else {
1725 1838
     		    $Connection = new Connection();
1726 1839
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1734,154 +1847,267 @@  discard block
 block discarded – undo
1734 1847
     		    if ($update) {
1735 1848
     			if ($result['value'] == '2') {
1736 1849
     			    $error = self::update_from_2();
1737
-    			    if ($error != '') return $error;
1738
-    			    else return self::check_version(true);
1850
+    			    if ($error != '') {
1851
+    			    	return $error;
1852
+    			    } else {
1853
+    			    	return self::check_version(true);
1854
+    			    }
1739 1855
     			} elseif ($result['value'] == '3') {
1740 1856
     			    $error = self::update_from_3();
1741
-    			    if ($error != '') return $error;
1742
-    			    else return self::check_version(true);
1857
+    			    if ($error != '') {
1858
+    			    	return $error;
1859
+    			    } else {
1860
+    			    	return self::check_version(true);
1861
+    			    }
1743 1862
     			} elseif ($result['value'] == '4') {
1744 1863
     			    $error = self::update_from_4();
1745
-    			    if ($error != '') return $error;
1746
-    			    else return self::check_version(true);
1864
+    			    if ($error != '') {
1865
+    			    	return $error;
1866
+    			    } else {
1867
+    			    	return self::check_version(true);
1868
+    			    }
1747 1869
     			} elseif ($result['value'] == '5') {
1748 1870
     			    $error = self::update_from_5();
1749
-    			    if ($error != '') return $error;
1750
-    			    else return self::check_version(true);
1871
+    			    if ($error != '') {
1872
+    			    	return $error;
1873
+    			    } else {
1874
+    			    	return self::check_version(true);
1875
+    			    }
1751 1876
     			} elseif ($result['value'] == '6') {
1752 1877
     			    $error = self::update_from_6();
1753
-    			    if ($error != '') return $error;
1754
-    			    else return self::check_version(true);
1878
+    			    if ($error != '') {
1879
+    			    	return $error;
1880
+    			    } else {
1881
+    			    	return self::check_version(true);
1882
+    			    }
1755 1883
     			} elseif ($result['value'] == '7') {
1756 1884
     			    $error = self::update_from_7();
1757
-    			    if ($error != '') return $error;
1758
-    			    else return self::check_version(true);
1885
+    			    if ($error != '') {
1886
+    			    	return $error;
1887
+    			    } else {
1888
+    			    	return self::check_version(true);
1889
+    			    }
1759 1890
     			} elseif ($result['value'] == '8') {
1760 1891
     			    $error = self::update_from_8();
1761
-    			    if ($error != '') return $error;
1762
-    			    else return self::check_version(true);
1892
+    			    if ($error != '') {
1893
+    			    	return $error;
1894
+    			    } else {
1895
+    			    	return self::check_version(true);
1896
+    			    }
1763 1897
     			} elseif ($result['value'] == '9') {
1764 1898
     			    $error = self::update_from_9();
1765
-    			    if ($error != '') return $error;
1766
-    			    else return self::check_version(true);
1899
+    			    if ($error != '') {
1900
+    			    	return $error;
1901
+    			    } else {
1902
+    			    	return self::check_version(true);
1903
+    			    }
1767 1904
     			} elseif ($result['value'] == '10') {
1768 1905
     			    $error = self::update_from_10();
1769
-    			    if ($error != '') return $error;
1770
-    			    else return self::check_version(true);
1906
+    			    if ($error != '') {
1907
+    			    	return $error;
1908
+    			    } else {
1909
+    			    	return self::check_version(true);
1910
+    			    }
1771 1911
     			} elseif ($result['value'] == '11') {
1772 1912
     			    $error = self::update_from_11();
1773
-    			    if ($error != '') return $error;
1774
-    			    else return self::check_version(true);
1913
+    			    if ($error != '') {
1914
+    			    	return $error;
1915
+    			    } else {
1916
+    			    	return self::check_version(true);
1917
+    			    }
1775 1918
     			} elseif ($result['value'] == '12') {
1776 1919
     			    $error = self::update_from_12();
1777
-    			    if ($error != '') return $error;
1778
-    			    else return self::check_version(true);
1920
+    			    if ($error != '') {
1921
+    			    	return $error;
1922
+    			    } else {
1923
+    			    	return self::check_version(true);
1924
+    			    }
1779 1925
     			} elseif ($result['value'] == '13') {
1780 1926
     			    $error = self::update_from_13();
1781
-    			    if ($error != '') return $error;
1782
-    			    else return self::check_version(true);
1927
+    			    if ($error != '') {
1928
+    			    	return $error;
1929
+    			    } else {
1930
+    			    	return self::check_version(true);
1931
+    			    }
1783 1932
     			} elseif ($result['value'] == '14') {
1784 1933
     			    $error = self::update_from_14();
1785
-    			    if ($error != '') return $error;
1786
-    			    else return self::check_version(true);
1934
+    			    if ($error != '') {
1935
+    			    	return $error;
1936
+    			    } else {
1937
+    			    	return self::check_version(true);
1938
+    			    }
1787 1939
     			} elseif ($result['value'] == '15') {
1788 1940
     			    $error = self::update_from_15();
1789
-    			    if ($error != '') return $error;
1790
-    			    else return self::check_version(true);
1941
+    			    if ($error != '') {
1942
+    			    	return $error;
1943
+    			    } else {
1944
+    			    	return self::check_version(true);
1945
+    			    }
1791 1946
     			} elseif ($result['value'] == '16') {
1792 1947
     			    $error = self::update_from_16();
1793
-    			    if ($error != '') return $error;
1794
-    			    else return self::check_version(true);
1948
+    			    if ($error != '') {
1949
+    			    	return $error;
1950
+    			    } else {
1951
+    			    	return self::check_version(true);
1952
+    			    }
1795 1953
     			} elseif ($result['value'] == '17') {
1796 1954
     			    $error = self::update_from_17();
1797
-    			    if ($error != '') return $error;
1798
-    			    else return self::check_version(true);
1955
+    			    if ($error != '') {
1956
+    			    	return $error;
1957
+    			    } else {
1958
+    			    	return self::check_version(true);
1959
+    			    }
1799 1960
     			} elseif ($result['value'] == '18') {
1800 1961
     			    $error = self::update_from_18();
1801
-    			    if ($error != '') return $error;
1802
-    			    else return self::check_version(true);
1962
+    			    if ($error != '') {
1963
+    			    	return $error;
1964
+    			    } else {
1965
+    			    	return self::check_version(true);
1966
+    			    }
1803 1967
     			} elseif ($result['value'] == '19') {
1804 1968
     			    $error = self::update_from_19();
1805
-    			    if ($error != '') return $error;
1806
-    			    else return self::check_version(true);
1969
+    			    if ($error != '') {
1970
+    			    	return $error;
1971
+    			    } else {
1972
+    			    	return self::check_version(true);
1973
+    			    }
1807 1974
     			} elseif ($result['value'] == '20') {
1808 1975
     			    $error = self::update_from_20();
1809
-    			    if ($error != '') return $error;
1810
-    			    else return self::check_version(true);
1976
+    			    if ($error != '') {
1977
+    			    	return $error;
1978
+    			    } else {
1979
+    			    	return self::check_version(true);
1980
+    			    }
1811 1981
     			} elseif ($result['value'] == '21') {
1812 1982
     			    $error = self::update_from_21();
1813
-    			    if ($error != '') return $error;
1814
-    			    else return self::check_version(true);
1983
+    			    if ($error != '') {
1984
+    			    	return $error;
1985
+    			    } else {
1986
+    			    	return self::check_version(true);
1987
+    			    }
1815 1988
     			} elseif ($result['value'] == '22') {
1816 1989
     			    $error = self::update_from_22();
1817
-    			    if ($error != '') return $error;
1818
-    			    else return self::check_version(true);
1990
+    			    if ($error != '') {
1991
+    			    	return $error;
1992
+    			    } else {
1993
+    			    	return self::check_version(true);
1994
+    			    }
1819 1995
     			} elseif ($result['value'] == '23') {
1820 1996
     			    $error = self::update_from_23();
1821
-    			    if ($error != '') return $error;
1822
-    			    else return self::check_version(true);
1997
+    			    if ($error != '') {
1998
+    			    	return $error;
1999
+    			    } else {
2000
+    			    	return self::check_version(true);
2001
+    			    }
1823 2002
     			} elseif ($result['value'] == '24') {
1824 2003
     			    $error = self::update_from_24();
1825
-    			    if ($error != '') return $error;
1826
-    			    else return self::check_version(true);
2004
+    			    if ($error != '') {
2005
+    			    	return $error;
2006
+    			    } else {
2007
+    			    	return self::check_version(true);
2008
+    			    }
1827 2009
     			} elseif ($result['value'] == '25') {
1828 2010
     			    $error = self::update_from_25();
1829
-    			    if ($error != '') return $error;
1830
-    			    else return self::check_version(true);
2011
+    			    if ($error != '') {
2012
+    			    	return $error;
2013
+    			    } else {
2014
+    			    	return self::check_version(true);
2015
+    			    }
1831 2016
     			} elseif ($result['value'] == '26') {
1832 2017
     			    $error = self::update_from_26();
1833
-    			    if ($error != '') return $error;
1834
-    			    else return self::check_version(true);
2018
+    			    if ($error != '') {
2019
+    			    	return $error;
2020
+    			    } else {
2021
+    			    	return self::check_version(true);
2022
+    			    }
1835 2023
     			} elseif ($result['value'] == '27') {
1836 2024
     			    $error = self::update_from_27();
1837
-    			    if ($error != '') return $error;
1838
-    			    else return self::check_version(true);
2025
+    			    if ($error != '') {
2026
+    			    	return $error;
2027
+    			    } else {
2028
+    			    	return self::check_version(true);
2029
+    			    }
1839 2030
     			} elseif ($result['value'] == '28') {
1840 2031
     			    $error = self::update_from_28();
1841
-    			    if ($error != '') return $error;
1842
-    			    else return self::check_version(true);
2032
+    			    if ($error != '') {
2033
+    			    	return $error;
2034
+    			    } else {
2035
+    			    	return self::check_version(true);
2036
+    			    }
1843 2037
     			} elseif ($result['value'] == '29') {
1844 2038
     			    $error = self::update_from_29();
1845
-    			    if ($error != '') return $error;
1846
-    			    else return self::check_version(true);
2039
+    			    if ($error != '') {
2040
+    			    	return $error;
2041
+    			    } else {
2042
+    			    	return self::check_version(true);
2043
+    			    }
1847 2044
     			} elseif ($result['value'] == '30') {
1848 2045
     			    $error = self::update_from_30();
1849
-    			    if ($error != '') return $error;
1850
-    			    else return self::check_version(true);
2046
+    			    if ($error != '') {
2047
+    			    	return $error;
2048
+    			    } else {
2049
+    			    	return self::check_version(true);
2050
+    			    }
1851 2051
     			} elseif ($result['value'] == '31') {
1852 2052
     			    $error = self::update_from_31();
1853
-    			    if ($error != '') return $error;
1854
-    			    else return self::check_version(true);
2053
+    			    if ($error != '') {
2054
+    			    	return $error;
2055
+    			    } else {
2056
+    			    	return self::check_version(true);
2057
+    			    }
1855 2058
     			} elseif ($result['value'] == '32') {
1856 2059
     			    $error = self::update_from_32();
1857
-    			    if ($error != '') return $error;
1858
-    			    else return self::check_version(true);
2060
+    			    if ($error != '') {
2061
+    			    	return $error;
2062
+    			    } else {
2063
+    			    	return self::check_version(true);
2064
+    			    }
1859 2065
     			} elseif ($result['value'] == '33') {
1860 2066
     			    $error = self::update_from_33();
1861
-    			    if ($error != '') return $error;
1862
-    			    else return self::check_version(true);
2067
+    			    if ($error != '') {
2068
+    			    	return $error;
2069
+    			    } else {
2070
+    			    	return self::check_version(true);
2071
+    			    }
1863 2072
     			} elseif ($result['value'] == '34') {
1864 2073
     			    $error = self::update_from_34();
1865
-    			    if ($error != '') return $error;
1866
-    			    else return self::check_version(true);
2074
+    			    if ($error != '') {
2075
+    			    	return $error;
2076
+    			    } else {
2077
+    			    	return self::check_version(true);
2078
+    			    }
1867 2079
     			} elseif ($result['value'] == '35') {
1868 2080
     			    $error = self::update_from_35();
1869
-    			    if ($error != '') return $error;
1870
-    			    else return self::check_version(true);
2081
+    			    if ($error != '') {
2082
+    			    	return $error;
2083
+    			    } else {
2084
+    			    	return self::check_version(true);
2085
+    			    }
1871 2086
     			} elseif ($result['value'] == '36') {
1872 2087
     			    $error = self::update_from_36();
1873
-    			    if ($error != '') return $error;
1874
-    			    else return self::check_version(true);
2088
+    			    if ($error != '') {
2089
+    			    	return $error;
2090
+    			    } else {
2091
+    			    	return self::check_version(true);
2092
+    			    }
1875 2093
     			} elseif ($result['value'] == '37') {
1876 2094
     			    $error = self::update_from_37();
1877
-    			    if ($error != '') return $error;
1878
-    			    else return self::check_version(true);
1879
-    			} else return '';
2095
+    			    if ($error != '') {
2096
+    			    	return $error;
2097
+    			    } else {
2098
+    			    	return self::check_version(true);
2099
+    			    }
2100
+    			} else {
2101
+    				return '';
2102
+    			}
2103
+    		    } else {
2104
+    		    	return $result['value'];
1880 2105
     		    }
1881
-    		    else return $result['value'];
1882 2106
 		}
1883 2107
 		
1884
-	    } else return $version;
2108
+	    } else {
2109
+	    	return $version;
2110
+	    }
1885 2111
     	}
1886 2112
     	
1887 2113
 }
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +276 added lines, -108 removed lines patch added patch discarded remove patch
@@ -48,27 +48,52 @@  discard block
 block discarded – undo
48 48
 }
49 49
 header('Content-Type: text/javascript');
50 50
 
51
-if (!isset($globalJsonCompress)) $compress = true;
52
-else $compress = $globalJsonCompress;
51
+if (!isset($globalJsonCompress)) {
52
+	$compress = true;
53
+} else {
54
+	$compress = $globalJsonCompress;
55
+}
53 56
 
54 57
 $from_archive = false;
55 58
 $min = true;
56 59
 $allhistory = false;
57 60
 $filter['source'] = array();
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
60
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
62
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
63
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
67
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
61
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
62
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
63
+}
64
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
65
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
66
+}
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
68
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
69
+}
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
71
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
72
+}
73
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
74
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
75
+}
76
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
77
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
78
+}
79
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
80
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
81
+}
82
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
83
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
+}
85
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
86
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
87
+}
88
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
89
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
90
+}
68 91
 
69 92
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
70 93
 	$min = true;
71
-} else $min = false;
94
+} else {
95
+	$min = false;
96
+}
72 97
 
73 98
 if (isset($_GET['ident'])) {
74 99
 	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
@@ -157,21 +182,33 @@  discard block
 block discarded – undo
157 182
 		} else {
158 183
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
159 184
 		}
160
-	} else $flightcnt = count($spotter_array);
161
-	if ($flightcnt == '') $flightcnt = 0;
162
-} else $flightcnt = 0;
185
+	} else {
186
+		$flightcnt = count($spotter_array);
187
+	}
188
+	if ($flightcnt == '') {
189
+		$flightcnt = 0;
190
+	}
191
+	} else {
192
+	$flightcnt = 0;
193
+}
163 194
 
164 195
 $sqltime = round(microtime(true)-$begintime,2);
165 196
 
166
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
167
-else $usenextlatlon = true;
197
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
198
+	$usenextlatlon = false;
199
+} else {
200
+	$usenextlatlon = true;
201
+}
168 202
 $j = 0;
169 203
 $prev_flightaware_id = '';
170 204
 $aircrafts_shadow = array();
171 205
 $output = '{';
172 206
 	$output .= '"type": "FeatureCollection",';
173
-		if ($min) $output .= '"minimal": "true",';
174
-		else $output .= '"minimal": "false",';
207
+		if ($min) {
208
+			$output .= '"minimal": "true",';
209
+		} else {
210
+			$output .= '"minimal": "false",';
211
+		}
175 212
 		$output .= '"fc": "'.$flightcnt.'",';
176 213
 		$output .= '"sqt": "'.$sqltime.'",';
177 214
 
@@ -215,18 +252,29 @@  discard block
 block discarded – undo
215 252
 						}
216 253
 						$output .= '"properties": {';
217 254
 						if (isset($spotter_item['flightaware_id'])) {
218
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
219
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
255
+							if ($compress) {
256
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
257
+							} else {
258
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
259
+							}
220 260
 						} elseif (isset($spotter_item['famtrackid'])) {
221
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
222
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
261
+							if ($compress) {
262
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
263
+							} else {
264
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
265
+							}
223 266
 						} elseif (isset($spotter_item['fammarine_id'])) {
224
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
225
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
267
+							if ($compress) {
268
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
269
+							} else {
270
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
271
+							}
226 272
 						}
227 273
 							$output .= '"fc": "'.$flightcnt.'",';
228 274
 							$output .= '"sqt": "'.$sqltime.'",';
229
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
275
+							if (isset($begindate)) {
276
+								$output .= '"archive_date": "'.$begindate.'",';
277
+							}
230 278
 
231 279
 /*
232 280
 							if ($min) $output .= '"minimal": "true",';
@@ -234,13 +282,21 @@  discard block
 block discarded – undo
234 282
 */
235 283
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
236 284
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
237
-							if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",';
238
-							else $output .= '"callsign": "'.$spotter_item['ident'].'",';
285
+							if ($compress) {
286
+								$output .= '"c": "'.$spotter_item['ident'].'",';
287
+							} else {
288
+								$output .= '"callsign": "'.$spotter_item['ident'].'",';
289
+							}
239 290
 						} else {
240
-							if ($compress) $output .= '"c": "NA",';
241
-							else $output .= '"callsign": "NA",';
291
+							if ($compress) {
292
+								$output .= '"c": "NA",';
293
+							} else {
294
+								$output .= '"callsign": "NA",';
295
+							}
296
+						}
297
+						if (isset($spotter_item['registration'])) {
298
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
242 299
 						}
243
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
244 300
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
245 301
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
246 302
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -253,15 +309,21 @@  discard block
 block discarded – undo
253 309
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
254 310
 						}
255 311
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
256
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
257
-							else {
312
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
313
+								$spotter_item['aircraft_shadow'] = '';
314
+							} else {
258 315
 								$aircraft_icao = $spotter_item['aircraft_icao'];
259
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
260
-								else {
316
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
317
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
318
+								} else {
261 319
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
262
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
263
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
264
-									else $spotter_item['aircraft_shadow'] = '';
320
+									if (count($aircraft_info) > 0) {
321
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
322
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
323
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
324
+									} else {
325
+										$spotter_item['aircraft_shadow'] = '';
326
+									}
265 327
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
266 328
 								}
267 329
 							}
@@ -269,73 +331,139 @@  discard block
 block discarded – undo
269 331
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
270 332
 							if ($tracker) {
271 333
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
272
-									if ($compress) $output .= '"as": "ambulance.png",';
273
-									else $output .= '"aircraft_shadow": "ambulance.png",';
334
+									if ($compress) {
335
+										$output .= '"as": "ambulance.png",';
336
+									} else {
337
+										$output .= '"aircraft_shadow": "ambulance.png",';
338
+									}
274 339
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
275
-									if ($compress) $output .= '"as": "police.png",';
276
-									else $output .= '"aircraft_shadow": "police.png",';
340
+									if ($compress) {
341
+										$output .= '"as": "police.png",';
342
+									} else {
343
+										$output .= '"aircraft_shadow": "police.png",';
344
+									}
277 345
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
278
-									if ($compress) $output .= '"as": "ship.png",';
279
-									else $output .= '"aircraft_shadow": "ship.png",';
346
+									if ($compress) {
347
+										$output .= '"as": "ship.png",';
348
+									} else {
349
+										$output .= '"aircraft_shadow": "ship.png",';
350
+									}
280 351
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
281
-									if ($compress) $output .= '"as": "ship.png",';
282
-									else $output .= '"aircraft_shadow": "ship.png",';
352
+									if ($compress) {
353
+										$output .= '"as": "ship.png",';
354
+									} else {
355
+										$output .= '"aircraft_shadow": "ship.png",';
356
+									}
283 357
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
284
-									if ($compress) $output .= '"as": "ship.png",';
285
-									else $output .= '"aircraft_shadow": "ship.png",';
358
+									if ($compress) {
359
+										$output .= '"as": "ship.png",';
360
+									} else {
361
+										$output .= '"aircraft_shadow": "ship.png",';
362
+									}
286 363
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
287
-									if ($compress) $output .= '"as": "truck.png",';
288
-									else $output .= '"aircraft_shadow": "truck.png",';
364
+									if ($compress) {
365
+										$output .= '"as": "truck.png",';
366
+									} else {
367
+										$output .= '"aircraft_shadow": "truck.png",';
368
+									}
289 369
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
290
-									if ($compress) $output .= '"as": "truck.png",';
291
-									else $output .= '"aircraft_shadow": "truck.png",';
370
+									if ($compress) {
371
+										$output .= '"as": "truck.png",';
372
+									} else {
373
+										$output .= '"aircraft_shadow": "truck.png",';
374
+									}
292 375
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
293
-									if ($compress) $output .= '"as": "aircraft.png",';
294
-									else $output .= '"aircraft_shadow": "aircraft.png",';
376
+									if ($compress) {
377
+										$output .= '"as": "aircraft.png",';
378
+									} else {
379
+										$output .= '"aircraft_shadow": "aircraft.png",';
380
+									}
295 381
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
296
-									if ($compress) $output .= '"as": "aircraft.png",';
297
-									else $output .= '"aircraft_shadow": "aircraft.png",';
382
+									if ($compress) {
383
+										$output .= '"as": "aircraft.png",';
384
+									} else {
385
+										$output .= '"aircraft_shadow": "aircraft.png",';
386
+									}
298 387
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
299
-									if ($compress) $output .= '"as": "helico.png",';
300
-									else $output .= '"aircraft_shadow": "helico.png",';
388
+									if ($compress) {
389
+										$output .= '"as": "helico.png",';
390
+									} else {
391
+										$output .= '"aircraft_shadow": "helico.png",';
392
+									}
301 393
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
302
-									if ($compress) $output .= '"as": "rail.png",';
303
-									else $output .= '"aircraft_shadow": "rail.png",';
394
+									if ($compress) {
395
+										$output .= '"as": "rail.png",';
396
+									} else {
397
+										$output .= '"aircraft_shadow": "rail.png",';
398
+									}
304 399
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
305
-									if ($compress) $output .= '"as": "firetruck.png",';
306
-									else $output .= '"aircraft_shadow": "firetruck.png",';
400
+									if ($compress) {
401
+										$output .= '"as": "firetruck.png",';
402
+									} else {
403
+										$output .= '"aircraft_shadow": "firetruck.png",';
404
+									}
307 405
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
308
-									if ($compress) $output .= '"as": "bus.png",';
309
-									else $output .= '"aircraft_shadow": "bus.png",';
406
+									if ($compress) {
407
+										$output .= '"as": "bus.png",';
408
+									} else {
409
+										$output .= '"aircraft_shadow": "bus.png",';
410
+									}
310 411
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
311
-									if ($compress) $output .= '"as": "phone.png",';
312
-									else $output .= '"aircraft_shadow": "phone.png",';
412
+									if ($compress) {
413
+										$output .= '"as": "phone.png",';
414
+									} else {
415
+										$output .= '"aircraft_shadow": "phone.png",';
416
+									}
313 417
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
314
-									if ($compress) $output .= '"as": "jogger.png",';
315
-									else $output .= '"aircraft_shadow": "jogger.png",';
418
+									if ($compress) {
419
+										$output .= '"as": "jogger.png",';
420
+									} else {
421
+										$output .= '"aircraft_shadow": "jogger.png",';
422
+									}
316 423
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
317
-									if ($compress) $output .= '"as": "bike.png",';
318
-									else $output .= '"aircraft_shadow": "bike.png",';
424
+									if ($compress) {
425
+										$output .= '"as": "bike.png",';
426
+									} else {
427
+										$output .= '"aircraft_shadow": "bike.png",';
428
+									}
319 429
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
320
-									if ($compress) $output .= '"as": "motorcycle.png",';
321
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
430
+									if ($compress) {
431
+										$output .= '"as": "motorcycle.png",';
432
+									} else {
433
+										$output .= '"aircraft_shadow": "motorcycle.png",';
434
+									}
322 435
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
323
-									if ($compress) $output .= '"as": "balloon.png",';
324
-									else $output .= '"aircraft_shadow": "balloon.png",';
436
+									if ($compress) {
437
+										$output .= '"as": "balloon.png",';
438
+									} else {
439
+										$output .= '"aircraft_shadow": "balloon.png",';
440
+									}
325 441
 								} else {
326
-									if ($compress) $output .= '"as": "car.png",';
327
-									else $output .= '"aircraft_shadow": "car.png",';
442
+									if ($compress) {
443
+										$output .= '"as": "car.png",';
444
+									} else {
445
+										$output .= '"aircraft_shadow": "car.png",';
446
+									}
328 447
 								}
329 448
 							} elseif ($marine) {
330
-								if ($compress) $output .= '"as": "ship.png",';
331
-								else $output .= '"aircraft_shadow": "ship.png",';
449
+								if ($compress) {
450
+									$output .= '"as": "ship.png",';
451
+								} else {
452
+									$output .= '"aircraft_shadow": "ship.png",';
453
+								}
332 454
 							} else {
333
-								if ($compress) $output .= '"as": "default.png",';
334
-								else $output .= '"aircraft_shadow": "default.png",';
455
+								if ($compress) {
456
+									$output .= '"as": "default.png",';
457
+								} else {
458
+									$output .= '"aircraft_shadow": "default.png",';
459
+								}
335 460
 							}
336 461
 						} else {
337
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
338
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
462
+							if ($compress) {
463
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
464
+							} else {
465
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
466
+							}
339 467
 						}
340 468
 						if (isset($spotter_item['airline_name'])) {
341 469
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -343,8 +471,11 @@  discard block
 block discarded – undo
343 471
 							$output .= '"airline_name": "NA",';
344 472
 						}
345 473
 						if (isset($spotter_item['departure_airport'])) {
346
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
347
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
474
+							if ($compress) {
475
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
476
+							} else {
477
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
478
+							}
348 479
 						}
349 480
 						if (isset($spotter_item['departure_airport_city'])) {
350 481
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -356,8 +487,11 @@  discard block
 block discarded – undo
356 487
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
357 488
 						}
358 489
 						if (isset($spotter_item['arrival_airport'])) {
359
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
360
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
490
+							if ($compress) {
491
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
492
+							} else {
493
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
494
+							}
361 495
 						}
362 496
 						if (isset($spotter_item['arrival_airport_city'])) {
363 497
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -376,11 +510,17 @@  discard block
 block discarded – undo
376 510
 						}
377 511
 						
378 512
 						if (isset($spotter_item['altitude'])) {
379
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
380
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
513
+							if ($compress) {
514
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
515
+							} else {
516
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
517
+							}
518
+						}
519
+						if ($compress) {
520
+							$output .= '"h": "'.$spotter_item['heading'].'",';
521
+						} else {
522
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
381 523
 						}
382
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
383
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
384 524
 						
385 525
 						if (isset($archivespeed)) {
386 526
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -390,7 +530,9 @@  discard block
 block discarded – undo
390 530
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
391 531
 						}
392 532
 
393
-						if (!$min) $output .= '"image": "'.$image.'",';
533
+						if (!$min) {
534
+							$output .= '"image": "'.$image.'",';
535
+						}
394 536
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
395 537
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
396 538
 						}
@@ -398,8 +540,11 @@  discard block
 block discarded – undo
398 540
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
399 541
 						}
400 542
 						if (isset($spotter_item['squawk'])) {
401
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
402
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
543
+							if ($compress) {
544
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
545
+							} else {
546
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
547
+							}
403 548
 						}
404 549
 						if (isset($spotter_item['squawk_usage'])) {
405 550
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -418,14 +563,23 @@  discard block
 block discarded – undo
418 563
 						}
419 564
 						// type when not aircraft ?
420 565
 						if (isset($spotter_item['type'])) {
421
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
422
-							else $output .= '"type": "'.$spotter_item['type'].'"';
566
+							if ($compress) {
567
+								$output .= '"t": "'.$spotter_item['type'].'"';
568
+							} else {
569
+								$output .= '"type": "'.$spotter_item['type'].'"';
570
+							}
423 571
 						} elseif ($marine) {
424
-							if ($compress) $output .= '"t": "ship"';
425
-							else $output .= '"type": "ship"';
572
+							if ($compress) {
573
+								$output .= '"t": "ship"';
574
+							} else {
575
+								$output .= '"type": "ship"';
576
+							}
426 577
 						} else {
427
-							if ($compress) $output .= '"t": "aircraft"';
428
-							else $output .= '"type": "aircraft"';
578
+							if ($compress) {
579
+								$output .= '"t": "aircraft"';
580
+							} else {
581
+								$output .= '"type": "aircraft"';
582
+							}
429 583
 						}
430 584
 						$output .= '},';
431 585
 						$output .= '"geometry": {';
@@ -493,7 +647,9 @@  discard block
 block discarded – undo
493 647
 			}
494 648
 */
495 649
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
496
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
650
+				if ($history == '' && isset($_COOKIE['history'])) {
651
+					$history = $_COOKIE['history'];
652
+				}
497 653
 				
498 654
 				if (
499 655
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -525,8 +681,11 @@  discard block
 block discarded – undo
525 681
 									$output_history .= ']}},';
526 682
 									$output .= $output_history;
527 683
 								}
528
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
529
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
684
+								if ($compress) {
685
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
686
+								} else {
687
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
688
+								}
530 689
 							}
531 690
 							$output_history .= '[';
532 691
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -545,9 +704,14 @@  discard block
 block discarded – undo
545 704
 							$prev_alt = $alt;
546 705
 						} else {
547 706
 							if ($d == false) {
548
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
549
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
550
-							} else $d = true;
707
+								if ($compress) {
708
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
709
+								} else {
710
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
711
+								}
712
+							} else {
713
+								$d = true;
714
+							}
551 715
 							$output_history .= '[';
552 716
 							$output_history .=  $spotter_history['longitude'].', ';
553 717
 							$output_history .=  $spotter_history['latitude'];
@@ -568,7 +732,9 @@  discard block
 block discarded – undo
568 732
 							$output_historyd = '[';
569 733
 							$output_historyd .=  $spotter_item['longitude'].', ';
570 734
 							$output_historyd .=  $spotter_item['latitude'];
571
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
735
+							if (isset($spotter_history['altitude'])) {
736
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
737
+							}
572 738
 							$output_historyd .= '],';
573 739
 							//$output_history = $output_historyd.$output_history;
574 740
 							$output_history = $output_history.$output_historyd;
@@ -609,7 +775,9 @@  discard block
 block discarded – undo
609 775
 			$output .= ']';
610 776
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
611 777
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
612
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
778
+			if (isset($begindate)) {
779
+				$output .= '"archive_date": "'.$begindate.'",';
780
+			}
613 781
 			$output .= '"fc": "'.$j.'"';
614 782
 		} else {
615 783
 			$output .= '"features": ';
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +393 added lines, -101 removed lines patch added patch discarded remove patch
@@ -150,11 +150,26 @@  discard block
 block discarded – undo
150 150
 				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li>
151 151
 				<li><?php echo _("NOTAM scope:"); ?>
152 152
 					<select class="selectpicker" onchange="notamscope(this);">
153
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
154
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
155
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
156
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
157
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
153
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
154
+	print ' selected';
155
+}
156
+?>>All</option>
157
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
158
+	print ' selected';
159
+}
160
+?>>Airport/Enroute warning</option>
161
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
162
+	print ' selected';
163
+}
164
+?>>Airport warning</option>
165
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
166
+	print ' selected';
167
+}
168
+?>>Navigation warning</option>
169
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
170
+	print ' selected';
171
+}
172
+?>>Enroute warning</option>
158 173
 					</select
159 174
 				</li>
160 175
 			</ul>
@@ -182,7 +197,12 @@  discard block
 block discarded – undo
182 197
 		        <div class="form-group">
183 198
 			    <label>From (UTC):</label>
184 199
 		            <div class='input-group date' id='datetimepicker1'>
185
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
200
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) {
201
+	print $_POST['start_date'];
202
+} elseif (isset($_COOKIE['archive_begin'])) {
203
+	print date("m/d/Y h:i a",$_COOKIE['archive_begin']);
204
+}
205
+?>" required />
186 206
 		                <span class="input-group-addon">
187 207
             			    <span class="glyphicon glyphicon-calendar"></span>
188 208
 		                </span>
@@ -191,7 +211,12 @@  discard block
 block discarded – undo
191 211
 		        <div class="form-group">
192 212
 			    <label>To (UTC):</label>
193 213
 		            <div class='input-group date' id='datetimepicker2'>
194
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" />
214
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) {
215
+	print $_POST['end_date'];
216
+} elseif (isset($_COOKIE['archive_end'])) {
217
+	print date("m/d/Y h:i a",$_COOKIE['archive_end']);
218
+}
219
+?>" />
195 220
             			<span class="input-group-addon">
196 221
 		                    <span class="glyphicon glyphicon-calendar"></span>
197 222
             			</span>
@@ -217,8 +242,20 @@  discard block
 block discarded – undo
217 242
 
218 243
 		    <li><?php echo _("Playback speed:"); ?>
219 244
 			<div class="range">
220
-			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
221
-			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
245
+			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
246
+	print $_POST['archivespeed'];
247
+} elseif (isset($_COOKIE['archive_speed'])) {
248
+	print $_COOKIE['archive_speed'];
249
+} else {
250
+	print '1';
251
+}
252
+?>">
253
+			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
254
+	print $_COOKIE['archive_speed'];
255
+} else {
256
+	print '1';
257
+}
258
+?></output>
222 259
 			</div>
223 260
 		    </li>
224 261
 		    <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li>
@@ -240,15 +277,27 @@  discard block
 block discarded – undo
240 277
 		    <li><?php echo _("Type of Map:"); ?>
241 278
 			<select  class="selectpicker" onchange="mapType(this);">
242 279
 			    <?php
243
-				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
244
-				else $MapType = $_COOKIE['MapType'];
280
+				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
281
+					$MapType = $globalMapProvider;
282
+				} else {
283
+					$MapType = $_COOKIE['MapType'];
284
+				}
245 285
 			    ?>
246 286
 			    <?php
247 287
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
248 288
 			    ?>
249
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
250
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
251
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
289
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
290
+	print ' selected';
291
+}
292
+?>>Bing-Aerial</option>
293
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
294
+	print ' selected';
295
+}
296
+?>>Bing-Hybrid</option>
297
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
298
+	print ' selected';
299
+}
300
+?>>Bing-Road</option>
252 301
 			    <?php
253 302
 				}
254 303
 			    ?>
@@ -258,56 +307,131 @@  discard block
 block discarded – undo
258 307
 			    <?php
259 308
 				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
260 309
 			    ?>
261
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
262
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
263
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
310
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
311
+	print ' selected';
312
+}
313
+?>>Here-Aerial</option>
314
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
315
+	print ' selected';
316
+}
317
+?>>Here-Hybrid</option>
318
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
319
+	print ' selected';
320
+}
321
+?>>Here-Road</option>
264 322
 			    <?php
265 323
 				    }
266 324
 			    ?>
267 325
 			    <?php
268 326
 				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
269 327
 			    ?>
270
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
271
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
272
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
273
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
328
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
329
+	print ' selected';
330
+}
331
+?>>Google Roadmap</option>
332
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
333
+	print ' selected';
334
+}
335
+?>>Google Satellite</option>
336
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
337
+	print ' selected';
338
+}
339
+?>>Google Hybrid</option>
340
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
341
+	print ' selected';
342
+}
343
+?>>Google Terrain</option>
274 344
 			    <?php
275 345
 				    }
276 346
 			    ?>
277 347
 			    <?php
278 348
 				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
279 349
 			    ?>
280
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
281
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
282
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
350
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
351
+	print ' selected';
352
+}
353
+?>>MapQuest-OSM</option>
354
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
355
+	print ' selected';
356
+}
357
+?>>MapQuest-Aerial</option>
358
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
359
+	print ' selected';
360
+}
361
+?>>MapQuest-Hybrid</option>
283 362
 			    <?php
284 363
 				    }
285 364
 			    ?>
286
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
365
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
366
+	print ' selected';
367
+}
368
+?>>Yandex</option>
287 369
 			    <?php
288 370
 				}
289 371
 			    ?>
290 372
 			    <?php
291 373
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
292
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
293
-					else $MapBoxId = $_COOKIE['MapTypeId'];
374
+					if (!isset($_COOKIE['MapTypeId'])) {
375
+						$MapBoxId = 'default';
376
+					} else {
377
+						$MapBoxId = $_COOKIE['MapTypeId'];
378
+					}
294 379
 			    ?>
295
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
296
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
297
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
298
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
299
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
300
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
301
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
302
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
303
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
304
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
305
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
306
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
380
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
381
+	print ' selected';
382
+}
383
+?>>Mapbox default</option>
384
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
385
+	print ' selected';
386
+}
387
+?>>Mapbox streets</option>
388
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
389
+	print ' selected';
390
+}
391
+?>>Mapbox light</option>
392
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
393
+	print ' selected';
394
+}
395
+?>>Mapbox dark</option>
396
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
397
+	print ' selected';
398
+}
399
+?>>Mapbox satellite</option>
400
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
401
+	print ' selected';
402
+}
403
+?>>Mapbox streets-satellite</option>
404
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
405
+	print ' selected';
406
+}
407
+?>>Mapbox streets-basic</option>
408
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
409
+	print ' selected';
410
+}
411
+?>>Mapbox comic</option>
412
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
413
+	print ' selected';
414
+}
415
+?>>Mapbox outdoors</option>
416
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
417
+	print ' selected';
418
+}
419
+?>>Mapbox pencil</option>
420
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
421
+	print ' selected';
422
+}
423
+?>>Mapbox pirates</option>
424
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
425
+	print ' selected';
426
+}
427
+?>>Mapbox emerald</option>
307 428
 			    <?php
308 429
 				    }
309 430
 			    ?>
310
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
431
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
432
+	print ' selected';
433
+}
434
+?>>OpenStreetMap</option>
311 435
 			</select>
312 436
 		    </li>
313 437
 <?php
@@ -315,9 +439,18 @@  discard block
 block discarded – undo
315 439
 ?>
316 440
 		    <li><?php echo _("Type of Terrain:"); ?>
317 441
 			<select  class="selectpicker" onchange="terrainType(this);">
318
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
319
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
320
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
442
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
443
+	print ' selected';
444
+}
445
+?>>stk terrain</option>
446
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
447
+	print ' selected';
448
+}
449
+?>>ellipsoid</option>
450
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
451
+	print ' selected';
452
+}
453
+?>>vr terrain</option>
321 454
 			</select>
322 455
 		    </li>
323 456
 <?php
@@ -327,18 +460,36 @@  discard block
 block discarded – undo
327 460
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
328 461
 ?>
329 462
 		    
330
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
331
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li>
332
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
333
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
463
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
464
+	print 'checked';
465
+}
466
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
467
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) {
468
+	print 'checked';
469
+}
470
+?> ><?php echo _("Display flight path"); ?></label></div></li>
471
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) {
472
+	print 'checked';
473
+}
474
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
475
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
476
+	print 'checked';
477
+}
478
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
334 479
 <?php
335 480
     }
336 481
 ?>
337
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
482
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') {
483
+	print 'checked';
484
+}
485
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
338 486
 <?php
339 487
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
340 488
 ?>
341
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
489
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) {
490
+	print 'checked';
491
+}
492
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
342 493
 <?php
343 494
     }
344 495
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -352,17 +503,25 @@  discard block
 block discarded – undo
352 503
 			if (function_exists('array_column')) {
353 504
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
354 505
 		    ?>
355
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
506
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
507
+	print 'checked';
508
+}
509
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
356 510
 		    <?php
357 511
 			    }
358 512
 			} elseif (isset($globalSources)) {
359 513
 			    $dispolar = false;
360 514
 			    foreach ($globalSources as $testsource) {
361
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
515
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
516
+			        	$dispolar = true;
517
+			        }
362 518
 			    }
363 519
 			    if ($dispolar) {
364 520
 		    ?>
365
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
521
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
522
+	print 'checked';
523
+}
524
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
366 525
 		    <?php
367 526
 			    }
368 527
 		        }
@@ -374,12 +533,22 @@  discard block
 block discarded – undo
374 533
 		    <?php
375 534
 		        if (extension_loaded('gd') && function_exists('gd_info')) {
376 535
 		    ?>
377
-		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
536
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
537
+	print 'checked';
538
+}
539
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
378 540
 		    <?php 
379 541
 			if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
380 542
 		    ?>
381 543
 		    <li><?php echo _("Aircraft icon color:"); ?>
382
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
544
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
545
+	print $_COOKIE['IconColor'];
546
+} elseif (isset($globalAircraftIconColor)) {
547
+	print $globalAircraftIconColor;
548
+} else {
549
+	print '1a3151';
550
+}
551
+?>">
383 552
 		    </li>
384 553
 		    <?php
385 554
 			    }
@@ -390,7 +559,14 @@  discard block
 block discarded – undo
390 559
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
391 560
 		    ?>
392 561
 		    <li><?php echo _("Marine icon color:"); ?>
393
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
562
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
563
+	print $_COOKIE['MarineIconColor'];
564
+} elseif (isset($globalMarineIconColor)) {
565
+	print $globalMarineIconColor;
566
+} else {
567
+	print '1a3151';
568
+}
569
+?>">
394 570
 		    </li>
395 571
 		    <?php
396 572
 			    }
@@ -398,23 +574,57 @@  discard block
 block discarded – undo
398 574
 		    ?>
399 575
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
400 576
 			<div class="range">
401
-			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
402
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
577
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
578
+	print $_COOKIE['AirportZoom'];
579
+} elseif (isset($globalAirportZoom)) {
580
+	print $globalAirportZoom;
581
+} else {
582
+	print '7';
583
+}
584
+?>">
585
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
586
+	print $_COOKIE['AirportZoom'];
587
+} elseif (isset($globalAirportZoom)) {
588
+	print $globalAirportZoom;
589
+} else {
590
+	print '7';
591
+}
592
+?></output>
403 593
 			</div>
404 594
 		    </li>
405 595
 <?php
406 596
     } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
407 597
 ?>
408
-		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li>
598
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
599
+	print 'checked';
600
+}
601
+?> ><?php echo _("Force Aircraft color"); ?></li>
409 602
 		    <li><?php echo _("Aircraft icon color:"); ?>
410
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print 'ff0000'; ?>">
603
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
604
+	print $_COOKIE['IconColor'];
605
+} elseif (isset($globalAircraftIconColor)) {
606
+	print $globalAircraftIconColor;
607
+} else {
608
+	print 'ff0000';
609
+}
610
+?>">
411 611
 		    </li>
412 612
 <?php
413 613
 	if (isset($globalMarine) && $globalMarine === TRUE) {
414 614
 ?>
415
-		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Marine color"); ?></li>
615
+		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') {
616
+	print 'checked';
617
+}
618
+?> ><?php echo _("Force Marine color"); ?></li>
416 619
 		    <li><?php echo _("Marine icon color:"); ?>
417
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print 'ff0000'; ?>">
620
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
621
+	print $_COOKIE['MarineIconColor'];
622
+} elseif (isset($globalMarineIconColor)) {
623
+	print $globalMarineIconColor;
624
+} else {
625
+	print 'ff0000';
626
+}
627
+?>">
418 628
 		    </li>
419 629
 <?php
420 630
 	}
@@ -422,22 +632,46 @@  discard block
 block discarded – undo
422 632
 ?>
423 633
 		    <li><?php echo _("Distance unit:"); ?>
424 634
 			<select class="selectpicker" onchange="unitdistance(this);">
425
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
426
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
427
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
635
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
636
+	echo ' selected';
637
+}
638
+?>>km</option>
639
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
640
+	echo ' selected';
641
+}
642
+?>>nm</option>
643
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
644
+	echo ' selected';
645
+}
646
+?>>mi</option>
428 647
 		        </select>
429 648
 		    </li>
430 649
 		    <li><?php echo _("Altitude unit:"); ?>
431 650
 			<select class="selectpicker" onchange="unitaltitude(this);">
432
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
433
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
651
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
652
+	echo ' selected';
653
+}
654
+?>>m</option>
655
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
656
+	echo ' selected';
657
+}
658
+?>>feet</option>
434 659
 		        </select>
435 660
 		    </li>
436 661
 		    <li><?php echo _("Speed unit:"); ?>
437 662
 			<select class="selectpicker" onchange="unitspeed(this);">
438
-			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option>
439
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
440
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
663
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
664
+	echo ' selected';
665
+}
666
+?>>km/h</option>
667
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
668
+	echo ' selected';
669
+}
670
+?>>mph</option>
671
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
672
+	echo ' selected';
673
+}
674
+?>>knots</option>
441 675
 		        </select>
442 676
 		    </li>
443 677
 
@@ -452,9 +686,18 @@  discard block
 block discarded – undo
452 686
 		    <?php
453 687
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
454 688
 		    ?>
455
-			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
456
-			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
457
-			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
689
+			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) {
690
+	print 'checked';
691
+}
692
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
693
+			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) {
694
+	print 'checked';
695
+}
696
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
697
+			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) {
698
+	print 'checked';
699
+}
700
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
458 701
 		    <?php
459 702
 			}
460 703
 		    ?>
@@ -462,10 +705,16 @@  discard block
 block discarded – undo
462 705
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
463 706
 		    ?>
464 707
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
465
-			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
708
+			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) {
709
+	print 'checked';
710
+}
711
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
466 712
 			<?php } ?>
467 713
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
468
-			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li>
714
+			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) {
715
+	print 'checked';
716
+}
717
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
469 718
 			<?php } ?>
470 719
 		    <?php
471 720
 			}
@@ -482,7 +731,9 @@  discard block
 block discarded – undo
482 731
 				}
483 732
 				foreach($allairlinenames as $airline) {
484 733
 					$airline_name = $airline['airline_name'];
485
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
734
+					if (strlen($airline_name) > 30) {
735
+						$airline_name = substr($airline_name,0,30).'...';
736
+					}
486 737
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
487 738
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
488 739
 					} else {
@@ -500,7 +751,10 @@  discard block
 block discarded – undo
500 751
 		    <li><?php echo _("Display alliance:"); ?>
501 752
 		    <br/>
502 753
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
503
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
754
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
755
+	echo ' selected';
756
+}
757
+?>><?php echo _("All"); ?></option>
504 758
 			    <?php
505 759
 				foreach($allalliancenames as $alliance) {
506 760
 					$alliance_name = $alliance['alliance'];
@@ -541,10 +795,22 @@  discard block
 block discarded – undo
541 795
 		    ?>
542 796
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
543 797
 			<select class="selectpicker" onchange="airlinestype(this);">
544
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
545
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
546
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
547
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
798
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
799
+	echo ' selected';
800
+}
801
+?>><?php echo _("All"); ?></option>
802
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
803
+	echo ' selected';
804
+}
805
+?>><?php echo _("Passenger"); ?></option>
806
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
807
+	echo ' selected';
808
+}
809
+?>><?php echo _("Cargo"); ?></option>
810
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
811
+	echo ' selected';
812
+}
813
+?>><?php echo _("Military"); ?></option>
548 814
 			</select>
549 815
 		    </li>
550 816
 		    <?php
@@ -552,7 +818,10 @@  discard block
 block discarded – undo
552 818
 		    ?>
553 819
 		    <li>
554 820
 			<?php echo _("Display flight with ident:"); ?>
555
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
821
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
822
+	print $_COOKIE['filter_ident'];
823
+}
824
+?>" />
556 825
 		    </li>
557 826
 		</ul>
558 827
 	    </form>
@@ -568,7 +837,10 @@  discard block
 block discarded – undo
568 837
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
569 838
 	    <form>
570 839
 		<ul>
571
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
840
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') {
841
+	print 'checked';
842
+}
843
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
572 844
 		    <li><?php echo _("Type:"); ?>
573 845
 			<select class="selectpicker" multiple onchange="sattypes(this);">
574 846
 			    <?php
@@ -576,25 +848,45 @@  discard block
 block discarded – undo
576 848
 				$types = $Satellite->get_tle_types();
577 849
 				foreach ($types as $type) {
578 850
 					$type_name = $type['tle_type'];
579
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
580
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
581
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
582
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
583
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
584
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
585
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
586
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
587
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
588
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
589
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
590
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
591
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
592
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
593
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
594
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
595
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
596
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
597
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
851
+					if ($type_name == 'musson') {
852
+						$type_name = 'Russian LEO Navigation';
853
+					} else if ($type_name == 'nnss') {
854
+						$type_name = 'Navi Navigation Satellite System';
855
+					} else if ($type_name == 'sbas') {
856
+						$type_name = 'Satellite-Based Augmentation System';
857
+					} else if ($type_name == 'glo-ops') {
858
+						$type_name = 'Glonass Operational';
859
+					} else if ($type_name == 'gps-ops') {
860
+						$type_name = 'GPS Operational';
861
+					} else if ($type_name == 'argos') {
862
+						$type_name = 'ARGOS Data Collection System';
863
+					} else if ($type_name == 'tdrss') {
864
+						$type_name = 'Tracking and Data Relay Satellite System';
865
+					} else if ($type_name == 'sarsat') {
866
+						$type_name = 'Search & Rescue';
867
+					} else if ($type_name == 'dmc') {
868
+						$type_name = 'Disaster Monitoring';
869
+					} else if ($type_name == 'resource') {
870
+						$type_name = 'Earth Resources';
871
+					} else if ($type_name == 'stations') {
872
+						$type_name = 'Space Stations';
873
+					} else if ($type_name == 'geo') {
874
+						$type_name = 'Geostationary';
875
+					} else if ($type_name == 'amateur') {
876
+						$type_name = 'Amateur Radio';
877
+					} else if ($type_name == 'x-comm') {
878
+						$type_name = 'Experimental';
879
+					} else if ($type_name == 'other-comm') {
880
+						$type_name = 'Other Comm';
881
+					} else if ($type_name == 'science') {
882
+						$type_name = 'Space & Earth Science';
883
+					} else if ($type_name == 'military') {
884
+						$type_name = 'Miscellaneous Military';
885
+					} else if ($type_name == 'radar') {
886
+						$type_name = 'Radar Calibration';
887
+					} else if ($type_name == 'tle-new') {
888
+						$type_name = 'Last 30 days launches';
889
+					}
598 890
 					
599 891
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
600 892
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +893 added lines, -307 removed lines patch added patch discarded remove patch
@@ -13,13 +13,17 @@  discard block
 block discarded – undo
13 13
 require_once(dirname(__FILE__).'/../require/class.SBS.php');
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
16
+if (isset($globalTracker) && $globalTracker) {
17
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+}
17 19
 if (isset($globalMarine) && $globalMarine) {
18 20
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
19 21
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 22
 }
21 23
 
22
-if (!isset($globalDebug)) $globalDebug = FALSE;
24
+if (!isset($globalDebug)) {
25
+	$globalDebug = FALSE;
26
+}
23 27
 
24 28
 // Check if schema is at latest version
25 29
 $Connection = new Connection();
@@ -54,35 +58,62 @@  discard block
 block discarded – undo
54 58
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 59
 if (isset($options['s'])) {
56 60
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
-    else $globalSources[] = array('host' => $options['s']);
59
-} elseif (isset($options['source'])) {
61
+    if (isset($options['format'])) {
62
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+    } else {
64
+    	$globalSources[] = array('host' => $options['s']);
65
+    }
66
+    } elseif (isset($options['source'])) {
60 67
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
-    else $globalSources[] = array('host' => $options['source']);
63
-}
68
+    if (isset($options['format'])) {
69
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
70
+    } else {
71
+    	$globalSources[] = array('host' => $options['source']);
72
+    }
73
+    }
64 74
 if (isset($options['aprsserverhost'])) {
65 75
 	$globalServerAPRS = TRUE;
66 76
 	$globalServerAPRShost = $options['aprsserverhost'];
67 77
 }
68
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
69
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
70
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
71
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
72
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
73
-if (isset($options['server'])) $globalServer = TRUE;
74
-if (isset($options['idsource'])) $id_source = $options['idsource'];
75
-else $id_source = 1;
78
+if (isset($options['aprsserverport'])) {
79
+	$globalServerAPRSport = $options['aprsserverport'];
80
+}
81
+if (isset($options['aprsserverssid'])) {
82
+	$globalServerAPRSssid = $options['aprsserverssid'];
83
+}
84
+if (isset($options['aprsserverpass'])) {
85
+	$globalServerAPRSpass = $options['aprsserverpass'];
86
+}
87
+if (isset($options['noaprsserver'])) {
88
+	$globalServerAPRS = FALSE;
89
+}
90
+if (isset($options['nodaemon'])) {
91
+	$globalDaemon = FALSE;
92
+}
93
+if (isset($options['server'])) {
94
+	$globalServer = TRUE;
95
+}
96
+if (isset($options['idsource'])) {
97
+	$id_source = $options['idsource'];
98
+} else {
99
+	$id_source = 1;
100
+}
76 101
 if (isset($globalServer) && $globalServer) {
77
-    if ($globalDebug) echo "Using Server Mode\n";
102
+    if ($globalDebug) {
103
+    	echo "Using Server Mode\n";
104
+    }
78 105
     $SI=new SpotterServer();
79 106
 /*
80 107
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 108
     $SI = new adsb2aprs();
82 109
     $SI->connect();
83 110
 */
84
-} else $SI=new SpotterImport($Connection->db);
85
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
111
+} else {
112
+	$SI=new SpotterImport($Connection->db);
113
+}
114
+if (isset($globalTracker) && $globalTracker) {
115
+	$TI = new TrackerImport($Connection->db);
116
+}
86 117
 if (isset($globalMarine) && $globalMarine) {
87 118
     $AIS = new AIS();
88 119
     $MI = new MarineImport($Connection->db);
@@ -104,7 +135,9 @@  discard block
 block discarded – undo
104 135
 }
105 136
 
106 137
 // let's try and connect
107
-if ($globalDebug) echo "Connecting...\n";
138
+if ($globalDebug) {
139
+	echo "Connecting...\n";
140
+}
108 141
 $use_aprs = false;
109 142
 $aprs_full = false;
110 143
 $reset = 0;
@@ -113,7 +146,9 @@  discard block
 block discarded – undo
113 146
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114 147
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115 148
     $reset++;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
149
+    if ($globalDebug) {
150
+    	echo 'Connect to all...'."\n";
151
+    }
117 152
     foreach ($hosts as $id => $value) {
118 153
 	$host = $value['host'];
119 154
 	$globalSources[$id]['last_exec'] = 0;
@@ -123,27 +158,37 @@  discard block
 block discarded – undo
123 158
         	//$formats[$id] = 'deltadbtxt';
124 159
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 160
         	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
161
+        	if ($globalDebug) {
162
+        		echo "Connect to deltadb source (".$host.")...\n";
163
+        	}
127 164
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128 165
         	//$formats[$id] = 'vatsimtxt';
129 166
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 167
         	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
168
+        	if ($globalDebug) {
169
+        		echo "Connect to vatsim source (".$host.")...\n";
170
+        	}
132 171
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133 172
         	//$formats[$id] = 'aircraftlistjson';
134 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 174
         	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
175
+        	if ($globalDebug) {
176
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	}
137 178
     	    } else if (preg_match('/opensky/i',$host)) {
138 179
         	//$formats[$id] = 'aircraftlistjson';
139 180
         	$globalSources[$id]['format'] = 'opensky';
140 181
         	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
182
+        	if ($globalDebug) {
183
+        		echo "Connect to opensky source (".$host.")...\n";
184
+        	}
142 185
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143 186
         	//$formats[$id] = 'radarvirtueljson';
144 187
         	$globalSources[$id]['format'] = 'radarvirtueljson';
145 188
         	//$last_exec['radarvirtueljson'] = 0;
146
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
189
+        	if ($globalDebug) {
190
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
191
+        	}
147 192
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148 193
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149 194
         	    exit(0);
@@ -152,7 +197,9 @@  discard block
 block discarded – undo
152 197
         	//$formats[$id] = 'planeupdatefaa';
153 198
         	$globalSources[$id]['format'] = 'planeupdatefaa';
154 199
         	//$last_exec['planeupdatefaa'] = 0;
155
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
200
+        	if ($globalDebug) {
201
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
202
+        	}
156 203
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157 204
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158 205
         	    exit(0);
@@ -161,26 +208,36 @@  discard block
 block discarded – undo
161 208
         	//$formats[$id] = 'phpvmacars';
162 209
         	$globalSources[$id]['format'] = 'phpvmacars';
163 210
         	//$last_exec['phpvmacars'] = 0;
164
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
211
+        	if ($globalDebug) {
212
+        		echo "Connect to phpvmacars source (".$host.")...\n";
213
+        	}
165 214
             } else if (preg_match('/VAM-json.php$/i',$host)) {
166 215
         	//$formats[$id] = 'phpvmacars';
167 216
         	$globalSources[$id]['format'] = 'vam';
168
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
217
+        	if ($globalDebug) {
218
+        		echo "Connect to Vam source (".$host.")...\n";
219
+        	}
169 220
             } else if (preg_match('/whazzup/i',$host)) {
170 221
         	//$formats[$id] = 'whazzup';
171 222
         	$globalSources[$id]['format'] = 'whazzup';
172 223
         	//$last_exec['whazzup'] = 0;
173
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
224
+        	if ($globalDebug) {
225
+        		echo "Connect to whazzup source (".$host.")...\n";
226
+        	}
174 227
             } else if (preg_match('/recentpireps/i',$host)) {
175 228
         	//$formats[$id] = 'pirepsjson';
176 229
         	$globalSources[$id]['format'] = 'pirepsjson';
177 230
         	//$last_exec['pirepsjson'] = 0;
178
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
231
+        	if ($globalDebug) {
232
+        		echo "Connect to pirepsjson source (".$host.")...\n";
233
+        	}
179 234
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180 235
         	//$formats[$id] = 'fr24json';
181 236
         	$globalSources[$id]['format'] = 'fr24json';
182 237
         	//$last_exec['fr24json'] = 0;
183
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
238
+        	if ($globalDebug) {
239
+        		echo "Connect to fr24 source (".$host.")...\n";
240
+        	}
184 241
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185 242
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186 243
         	    exit(0);
@@ -189,7 +246,9 @@  discard block
 block discarded – undo
189 246
         	//$formats[$id] = 'fr24json';
190 247
         	$globalSources[$id]['format'] = 'myshiptracking';
191 248
         	//$last_exec['fr24json'] = 0;
192
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to myshiptracking source (".$host.")...\n";
251
+        	}
193 252
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
194 253
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
195 254
         	    exit(0);
@@ -198,17 +257,24 @@  discard block
 block discarded – undo
198 257
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199 258
         	//$formats[$id] = 'tsv';
200 259
         	$globalSources[$id]['format'] = 'tsv';
201
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
260
+        	if ($globalDebug) {
261
+        		echo "Connect to tsv source (".$host.")...\n";
262
+        	}
202 263
             }
203 264
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
204 265
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205 266
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
206 267
     		    if ($idf !== false) {
207 268
     			$httpfeeds[$id] = $idf;
208
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
269
+        		if ($globalDebug) {
270
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
271
+        		}
272
+    		    } elseif ($globalDebug) {
273
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
209 274
     		    }
210
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
+    		} elseif ($globalDebug) {
276
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
277
+    		}
212 278
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213 279
 	    $hostport = explode(':',$host);
214 280
 	    if (isset($hostport[1])) {
@@ -248,17 +314,25 @@  discard block
 block discarded – undo
248 314
         		//$formats[$id] = 'beast';
249 315
         		$globalSources[$id]['format'] = 'beast';
250 316
 		    //} else $formats[$id] = 'sbs';
251
-		    } else $globalSources[$id]['format'] = 'sbs';
317
+		    } else {
318
+		    	$globalSources[$id]['format'] = 'sbs';
319
+		    }
252 320
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
253 321
 		}
254
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
322
+		if ($globalDebug) {
323
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
324
+		}
255 325
             } else {
256
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
326
+		if ($globalDebug) {
327
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
328
+		}
257 329
     	    }
258 330
         }
259 331
     }
260 332
 }
261
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
333
+if (!isset($globalMinFetch)) {
334
+	$globalMinFetch = 15;
335
+}
262 336
 
263 337
 // Initialize all
264 338
 $status = array();
@@ -267,13 +341,19 @@  discard block
 block discarded – undo
267 341
 $formats = array();
268 342
 $last_exec = array();
269 343
 $time = time();
270
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
271
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
272
-else $timeout = 20;
344
+if (isset($globalSourcesTimeout)) {
345
+	$timeout = $globalSourcesTimeOut;
346
+} else if (isset($globalSBS1TimeOut)) {
347
+	$timeout = $globalSBS1TimeOut;
348
+} else {
349
+	$timeout = 20;
350
+}
273 351
 $errno = '';
274 352
 $errstr='';
275 353
 
276
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
354
+if (!isset($globalDaemon)) {
355
+	$globalDaemon = TRUE;
356
+}
277 357
 /* Initiate connections to all the hosts simultaneously */
278 358
 //connect_all($hosts);
279 359
 //connect_all($globalSources);
@@ -299,7 +379,9 @@  discard block
 block discarded – undo
299 379
     if (isset($source['format']) && $source['format'] == 'aprs') {
300 380
 	$aprs_connect = 0;
301 381
 	$use_aprs = true;
302
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
382
+	if (isset($source['port']) && $source['port'] == '10152') {
383
+		$aprs_full = true;
384
+	}
303 385
 	break;
304 386
     }
305 387
 }
@@ -310,25 +392,48 @@  discard block
 block discarded – undo
310 392
 	$aprs_connect = 0;
311 393
 	$aprs_keep = 120;
312 394
 	$aprs_last_tx = time();
313
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
314
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
315
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
316
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
317
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
318
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
319
-	if ($aprs_full) $aprs_filter = '';
320
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
321
-	else $aprs_pass = '-1';
395
+	if (isset($globalAPRSversion)) {
396
+		$aprs_version = $globalAPRSversion;
397
+	} else {
398
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
399
+	}
400
+	if (isset($globalAPRSssid)) {
401
+		$aprs_ssid = $globalAPRSssid;
402
+	} else {
403
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
404
+	}
405
+	if (isset($globalAPRSfilter)) {
406
+		$aprs_filter = $globalAPRSfilter;
407
+	} else {
408
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
409
+	}
410
+	if ($aprs_full) {
411
+		$aprs_filter = '';
412
+	}
413
+	if (isset($globalAPRSpass)) {
414
+		$aprs_pass = $globalAPRSpass;
415
+	} else {
416
+		$aprs_pass = '-1';
417
+	}
322 418
 
323
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
324
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
325
-}
419
+	if ($aprs_filter != '') {
420
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
421
+	} else {
422
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
423
+	}
424
+	}
326 425
 
327 426
 // connected - lets do some work
328
-if ($globalDebug) echo "Connected!\n";
427
+if ($globalDebug) {
428
+	echo "Connected!\n";
429
+}
329 430
 sleep(1);
330
-if ($globalDebug) echo "SCAN MODE \n\n";
331
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
431
+if ($globalDebug) {
432
+	echo "SCAN MODE \n\n";
433
+}
434
+if (!isset($globalCronEnd)) {
435
+	$globalCronEnd = 60;
436
+}
332 437
 $endtime = time()+$globalCronEnd;
333 438
 $i = 1;
334 439
 $tt = array();
@@ -342,10 +447,14 @@  discard block
 block discarded – undo
342 447
 
343 448
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
344 449
 while ($i > 0) {
345
-    if (!$globalDaemon) $i = $endtime-time();
450
+    if (!$globalDaemon) {
451
+    	$i = $endtime-time();
452
+    }
346 453
     // Delete old ATC
347 454
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
455
+	if ($globalDebug) {
456
+		echo 'Delete old ATC...'."\n";
457
+	}
349 458
         $ATC->deleteOldATC();
350 459
     }
351 460
     
@@ -353,10 +462,14 @@  discard block
 block discarded – undo
353 462
     if (count($last_exec) == count($globalSources)) {
354 463
 	$max = $globalMinFetch;
355 464
 	foreach ($last_exec as $last) {
356
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
465
+	    if ((time() - $last['last']) < $max) {
466
+	    	$max = time() - $last['last'];
467
+	    }
357 468
 	}
358 469
 	if ($max != $globalMinFetch) {
359
-	    if ($globalDebug) echo 'Sleeping...'."\n";
470
+	    if ($globalDebug) {
471
+	    	echo 'Sleeping...'."\n";
472
+	    }
360 473
 	    sleep($globalMinFetch-$max+2);
361 474
 	}
362 475
     }
@@ -365,11 +478,15 @@  discard block
 block discarded – undo
365 478
     //foreach ($formats as $id => $value) {
366 479
     foreach ($globalSources as $id => $value) {
367 480
 	date_default_timezone_set('UTC');
368
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
481
+	if (!isset($last_exec[$id]['last'])) {
482
+		$last_exec[$id]['last'] = 0;
483
+	}
369 484
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
370 485
 	    //$buffer = $Common->getData($hosts[$id]);
371 486
 	    $buffer = $Common->getData($value['host']);
372
-	    if ($buffer != '') $reset = 0;
487
+	    if ($buffer != '') {
488
+	    	$reset = 0;
489
+	    }
373 490
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374 491
 	    $buffer = explode('\n',$buffer);
375 492
 	    foreach ($buffer as $line) {
@@ -378,20 +495,41 @@  discard block
 block discarded – undo
378 495
 	            $data = array();
379 496
 	            $data['hex'] = $line[1]; // hex
380 497
 	            $data['ident'] = $line[2]; // ident
381
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
382
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
383
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
384
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
385
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
498
+	            if (isset($line[3])) {
499
+	            	$data['altitude'] = $line[3];
500
+	            }
501
+	            // altitude
502
+	            if (isset($line[4])) {
503
+	            	$data['speed'] = $line[4];
504
+	            }
505
+	            // speed
506
+	            if (isset($line[5])) {
507
+	            	$data['heading'] = $line[5];
508
+	            }
509
+	            // heading
510
+	            if (isset($line[6])) {
511
+	            	$data['latitude'] = $line[6];
512
+	            }
513
+	            // lat
514
+	            if (isset($line[7])) {
515
+	            	$data['longitude'] = $line[7];
516
+	            }
517
+	            // long
386 518
 	            $data['verticalrate'] = ''; // vertical rate
387 519
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
388 520
 	            $data['emergency'] = ''; // emergency
389 521
 		    $data['datetime'] = date('Y-m-d H:i:s');
390 522
 		    $data['format_source'] = 'deltadbtxt';
391 523
     		    $data['id_source'] = $id_source;
392
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
393
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
394
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
524
+		    if (isset($value['name']) && $value['name'] != '') {
525
+		    	$data['source_name'] = $value['name'];
526
+		    }
527
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
528
+		    	$data['noarchive'] = true;
529
+		    }
530
+		    if (isset($value['sourcestats'])) {
531
+		    	$data['sourcestats'] = $value['sourcestats'];
532
+		    }
395 533
     		    $SI->add($data);
396 534
 		    unset($data);
397 535
     		}
@@ -401,7 +539,9 @@  discard block
 block discarded – undo
401 539
 	    date_default_timezone_set('CET');
402 540
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
403 541
 	    date_default_timezone_set('UTC');
404
-	    if ($buffer != '') $reset = 0;
542
+	    if ($buffer != '') {
543
+	    	$reset = 0;
544
+	    }
405 545
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406 546
 	    $buffer = explode('\n',$buffer);
407 547
 	    foreach ($buffer as $line) {
@@ -410,16 +550,36 @@  discard block
 block discarded – undo
410 550
 		    $add = false;
411 551
 		    $ais_data = $AIS->parse_line(trim($line));
412 552
 		    $data = array();
413
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
414
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
415
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
416
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
417
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
418
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
419
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
420
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
421
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
553
+		    if (isset($ais_data['ident'])) {
554
+		    	$data['ident'] = $ais_data['ident'];
555
+		    }
556
+		    if (isset($ais_data['mmsi'])) {
557
+		    	$data['mmsi'] = $ais_data['mmsi'];
558
+		    }
559
+		    if (isset($ais_data['speed'])) {
560
+		    	$data['speed'] = $ais_data['speed'];
561
+		    }
562
+		    if (isset($ais_data['heading'])) {
563
+		    	$data['heading'] = $ais_data['heading'];
564
+		    }
565
+		    if (isset($ais_data['latitude'])) {
566
+		    	$data['latitude'] = $ais_data['latitude'];
567
+		    }
568
+		    if (isset($ais_data['longitude'])) {
569
+		    	$data['longitude'] = $ais_data['longitude'];
570
+		    }
571
+		    if (isset($ais_data['status'])) {
572
+		    	$data['status'] = $ais_data['status'];
573
+		    }
574
+		    if (isset($ais_data['type'])) {
575
+		    	$data['type'] = $ais_data['type'];
576
+		    }
577
+		    if (isset($ais_data['imo'])) {
578
+		    	$data['imo'] = $ais_data['imo'];
579
+		    }
580
+		    if (isset($ais_data['callsign'])) {
581
+		    	$data['callsign'] = $ais_data['callsign'];
582
+		    }
423 583
 		    if (isset($ais_data['timestamp'])) {
424 584
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
425 585
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -434,8 +594,12 @@  discard block
 block discarded – undo
434 594
     		    $data['id_source'] = $id_source;
435 595
 		    //print_r($data);
436 596
 		    echo 'Add...'."\n";
437
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
438
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
597
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
598
+		    	$data['noarchive'] = true;
599
+		    }
600
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
601
+		    	$MI->add($data);
602
+		    }
439 603
 		    unset($data);
440 604
 		}
441 605
     	    }
@@ -455,18 +619,42 @@  discard block
 block discarded – undo
455 619
 			    if ($line != '') {
456 620
 				$ais_data = $AIS->parse_line(trim($line));
457 621
 				$data = array();
458
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
459
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
460
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
461
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
462
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
463
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
464
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
465
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
466
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
467
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
468
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
469
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
622
+				if (isset($ais_data['ident'])) {
623
+					$data['ident'] = $ais_data['ident'];
624
+				}
625
+				if (isset($ais_data['mmsi'])) {
626
+					$data['mmsi'] = $ais_data['mmsi'];
627
+				}
628
+				if (isset($ais_data['speed'])) {
629
+					$data['speed'] = $ais_data['speed'];
630
+				}
631
+				if (isset($ais_data['heading'])) {
632
+					$data['heading'] = $ais_data['heading'];
633
+				}
634
+				if (isset($ais_data['latitude'])) {
635
+					$data['latitude'] = $ais_data['latitude'];
636
+				}
637
+				if (isset($ais_data['longitude'])) {
638
+					$data['longitude'] = $ais_data['longitude'];
639
+				}
640
+				if (isset($ais_data['status'])) {
641
+					$data['status'] = $ais_data['status'];
642
+				}
643
+				if (isset($ais_data['type'])) {
644
+					$data['type'] = $ais_data['type'];
645
+				}
646
+				if (isset($ais_data['imo'])) {
647
+					$data['imo'] = $ais_data['imo'];
648
+				}
649
+				if (isset($ais_data['callsign'])) {
650
+					$data['callsign'] = $ais_data['callsign'];
651
+				}
652
+				if (isset($ais_data['destination'])) {
653
+					$data['arrival_code'] = $ais_data['destination'];
654
+				}
655
+				if (isset($ais_data['eta_ts'])) {
656
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
657
+				}
470 658
 				if (isset($ais_data['timestamp'])) {
471 659
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
472 660
 				} else {
@@ -474,16 +662,23 @@  discard block
 block discarded – undo
474 662
 				}
475 663
 				$data['format_source'] = 'aisnmeahttp';
476 664
 				$data['id_source'] = $id_source;
477
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
665
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
666
+					$data['noarchive'] = true;
667
+				}
668
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
669
+					$MI->add($data);
670
+				}
479 671
 				unset($data);
480 672
 			    }
481 673
 			}
482 674
 		    }
483 675
 		} else {
484 676
 		    $format = $value['format'];
485
-		    if (isset($tt[$format])) $tt[$format]++;
486
-		    else $tt[$format] = 0;
677
+		    if (isset($tt[$format])) {
678
+		    	$tt[$format]++;
679
+		    } else {
680
+		    	$tt[$format] = 0;
681
+		    }
487 682
 		    if ($tt[$format] > 30) {
488 683
 			sleep(2);
489 684
 			$sourceeen[] = $value;
@@ -514,7 +709,9 @@  discard block
 block discarded – undo
514 709
 			$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
515 710
 			$data['format_source'] = 'myshiptracking';
516 711
 			$data['id_source'] = $id_source;
517
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
712
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
713
+				$data['noarchive'] = true;
714
+			}
518 715
 			$MI->add($data);
519 716
 			unset($data);
520 717
 		    }
@@ -535,7 +732,9 @@  discard block
 block discarded – undo
535 732
 			    $data['callsign'] = $line['callsign'];
536 733
 			    $data['mmsi'] = $line['mmsi'];
537 734
 			    $data['speed'] = $line['sog'];
538
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
735
+			    if ($line['heading'] != '511') {
736
+			    	$data['heading'] = $line['heading'];
737
+			    }
539 738
 			    $data['latitude'] = $line['latitude'];
540 739
 			    $data['longitude'] = $line['longitude'];
541 740
 			    $data['type_id'] = $line['shiptype'];
@@ -543,7 +742,9 @@  discard block
 block discarded – undo
543 742
 			    $data['datetime'] = $line['time'];
544 743
 			    $data['format_source'] = 'boatbeaconapp';
545 744
 			    $data['id_source'] = $id_source;
546
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
745
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
746
+			    	$data['noarchive'] = true;
747
+			    }
547 748
 			    $MI->add($data);
548 749
 			    unset($data);
549 750
 			}
@@ -556,7 +757,9 @@  discard block
 block discarded – undo
556 757
 	    echo 'download...';
557 758
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
558 759
 	    echo 'done !'."\n";
559
-	    if ($buffer != '') $reset = 0;
760
+	    if ($buffer != '') {
761
+	    	$reset = 0;
762
+	    }
560 763
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
561 764
 	    $buffer = explode('\n',$buffer);
562 765
 	    foreach ($buffer as $line) {
@@ -581,7 +784,9 @@  discard block
 block discarded – undo
581 784
 		    //$data['etaTime'] = substr($line,135,5);
582 785
 		    $data['format_source'] = 'shipplotter';
583 786
     		    $data['id_source'] = $id_source;
584
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
787
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
788
+		    	$data['noarchive'] = true;
789
+		    }
585 790
 		    //print_r($data);
586 791
 		    echo 'Add...'."\n";
587 792
 		    $MI->add($data);
@@ -601,16 +806,28 @@  discard block
 block discarded – undo
601 806
     		    $line = explode(':', $line);
602 807
     		    if (count($line) > 30 && $line[0] != 'callsign') {
603 808
 			$data = array();
604
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
605
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
809
+			if (isset($line[37]) && $line[37] != '') {
810
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
811
+			} else {
812
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
813
+			}
606 814
 			$data['pilot_id'] = $line[1];
607 815
 			$data['pilot_name'] = $line[2];
608 816
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
609 817
 			$data['ident'] = $line[0]; // ident
610
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
818
+			if ($line[7] != '' && $line[7] != 0) {
819
+				$data['altitude'] = $line[7];
820
+			}
821
+			// altitude
611 822
 			$data['speed'] = $line[8]; // speed
612
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
613
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
823
+			if (isset($line[45])) {
824
+				$data['heading'] = $line[45];
825
+			}
826
+			// heading
827
+			elseif (isset($line[38])) {
828
+				$data['heading'] = $line[38];
829
+			}
830
+			// heading
614 831
 			$data['latitude'] = $line[5]; // lat
615 832
 	        	$data['longitude'] = $line[6]; // long
616 833
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -626,7 +843,9 @@  discard block
 block discarded – undo
626 843
 			$data['frequency'] = $line[4];
627 844
 			$data['type'] = $line[18];
628 845
 			$data['range'] = $line[19];
629
-			if (isset($line[35])) $data['info'] = $line[35];
846
+			if (isset($line[35])) {
847
+				$data['info'] = $line[35];
848
+			}
630 849
     			$data['id_source'] = $id_source;
631 850
 	    		//$data['arrival_airport_time'] = ;
632 851
 	    		if ($line[9] != '') {
@@ -640,25 +859,44 @@  discard block
 block discarded – undo
640 859
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
641 860
 	    		*/
642 861
 	    		$data['format_source'] = $value['format'];
643
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
644
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
645
-    			if ($line[3] == 'PILOT') $SI->add($data);
646
-			elseif ($line[3] == 'ATC') {
862
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
863
+				$data['noarchive'] = true;
864
+			}
865
+			if (isset($value['name']) && $value['name'] != '') {
866
+				$data['source_name'] = $value['name'];
867
+			}
868
+    			if ($line[3] == 'PILOT') {
869
+    				$SI->add($data);
870
+    			} elseif ($line[3] == 'ATC') {
647 871
 				//print_r($data);
648 872
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
649 873
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
650 874
 				$typec = substr($data['ident'],-3);
651
-				if ($typec == 'APP') $data['type'] = 'Approach';
652
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
653
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
654
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
655
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
656
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
657
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
658
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
659
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
660
-				if (!isset($data['source_name'])) $data['source_name'] = '';
661
-				if (isset($ATC)) 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']);
875
+				if ($typec == 'APP') {
876
+					$data['type'] = 'Approach';
877
+				} elseif ($typec == 'TWR') {
878
+					$data['type'] = 'Tower';
879
+				} elseif ($typec == 'OBS') {
880
+					$data['type'] = 'Observer';
881
+				} elseif ($typec == 'GND') {
882
+					$data['type'] = 'Ground';
883
+				} elseif ($typec == 'DEL') {
884
+					$data['type'] = 'Delivery';
885
+				} elseif ($typec == 'DEP') {
886
+					$data['type'] = 'Departure';
887
+				} elseif ($typec == 'FSS') {
888
+					$data['type'] = 'Flight Service Station';
889
+				} elseif ($typec == 'CTR') {
890
+					$data['type'] = 'Control Radar or Centre';
891
+				} elseif ($data['type'] == '') {
892
+					$data['type'] = 'Observer';
893
+				}
894
+				if (!isset($data['source_name'])) {
895
+					$data['source_name'] = '';
896
+				}
897
+				if (isset($ATC)) {
898
+					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']);
899
+				}
662 900
 			}
663 901
     			unset($data);
664 902
     		    }
@@ -677,27 +915,61 @@  discard block
 block discarded – undo
677 915
 		foreach ($all_data['acList'] as $line) {
678 916
 		    $data = array();
679 917
 		    $data['hex'] = $line['Icao']; // hex
680
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
681
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
682
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
683
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
684
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
685
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
918
+		    if (isset($line['Call'])) {
919
+		    	$data['ident'] = $line['Call'];
920
+		    }
921
+		    // ident
922
+		    if (isset($line['Alt'])) {
923
+		    	$data['altitude'] = $line['Alt'];
924
+		    }
925
+		    // altitude
926
+		    if (isset($line['Spd'])) {
927
+		    	$data['speed'] = $line['Spd'];
928
+		    }
929
+		    // speed
930
+		    if (isset($line['Trak'])) {
931
+		    	$data['heading'] = $line['Trak'];
932
+		    }
933
+		    // heading
934
+		    if (isset($line['Lat'])) {
935
+		    	$data['latitude'] = $line['Lat'];
936
+		    }
937
+		    // lat
938
+		    if (isset($line['Long'])) {
939
+		    	$data['longitude'] = $line['Long'];
940
+		    }
941
+		    // long
686 942
 		    //$data['verticalrate'] = $line['']; // verticale rate
687
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
943
+		    if (isset($line['Sqk'])) {
944
+		    	$data['squawk'] = $line['Sqk'];
945
+		    }
946
+		    // squawk
688 947
 		    $data['emergency'] = ''; // emergency
689
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
948
+		    if (isset($line['Reg'])) {
949
+		    	$data['registration'] = $line['Reg'];
950
+		    }
690 951
 		    
691
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
692
-		    else $data['datetime'] = date('Y-m-d H:i:s');
952
+		    if (isset($line['PosTime'])) {
953
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
954
+		    } else {
955
+		    	$data['datetime'] = date('Y-m-d H:i:s');
956
+		    }
693 957
 		    
694 958
 		    //$data['datetime'] = date('Y-m-d H:i:s');
695
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
959
+		    if (isset($line['Type'])) {
960
+		    	$data['aircraft_icao'] = $line['Type'];
961
+		    }
696 962
 	    	    $data['format_source'] = 'aircraftlistjson';
697 963
 		    $data['id_source'] = $id_source;
698
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
699
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
700
-		    if (isset($data['latitude'])) $SI->add($data);
964
+		    if (isset($value['name']) && $value['name'] != '') {
965
+		    	$data['source_name'] = $value['name'];
966
+		    }
967
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
968
+		    	$data['noarchive'] = true;
969
+		    }
970
+		    if (isset($data['latitude'])) {
971
+		    	$SI->add($data);
972
+		    }
701 973
 		    unset($data);
702 974
 		}
703 975
 	    } elseif (is_array($all_data)) {
@@ -714,12 +986,19 @@  discard block
 block discarded – undo
714 986
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
715 987
 		    $data['squawk'] = $line['squawk']; // squawk
716 988
 		    $data['emergency'] = ''; // emergency
717
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
718
-		    else $data['datetime'] = date('Y-m-d H:i:s');
989
+		    if (isset($line['PosTime'])) {
990
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
991
+		    } else {
992
+		    	$data['datetime'] = date('Y-m-d H:i:s');
993
+		    }
719 994
 	    	    $data['format_source'] = 'aircraftlistjson';
720 995
     		    $data['id_source'] = $id_source;
721
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
722
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
996
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
997
+		    	$data['noarchive'] = true;
998
+		    }
999
+		    if (isset($value['name']) && $value['name'] != '') {
1000
+		    	$data['source_name'] = $value['name'];
1001
+		    }
723 1002
 		    $SI->add($data);
724 1003
 		    unset($data);
725 1004
 		}
@@ -755,8 +1034,12 @@  discard block
 block discarded – undo
755 1034
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
756 1035
 	    	    $data['format_source'] = 'planeupdatefaa';
757 1036
     		    $data['id_source'] = $id_source;
758
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
759
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1037
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1038
+		    	$data['noarchive'] = true;
1039
+		    }
1040
+		    if (isset($value['name']) && $value['name'] != '') {
1041
+		    	$data['source_name'] = $value['name'];
1042
+		    }
760 1043
 		    $SI->add($data);
761 1044
 		    unset($data);
762 1045
 		}
@@ -785,7 +1068,9 @@  discard block
 block discarded – undo
785 1068
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
786 1069
 	    	    $data['format_source'] = 'opensky';
787 1070
     		    $data['id_source'] = $id_source;
788
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1071
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1072
+		    	$data['noarchive'] = true;
1073
+		    }
789 1074
 		    $SI->add($data);
790 1075
 		    unset($data);
791 1076
 		}
@@ -797,7 +1082,9 @@  discard block
 block discarded – undo
797 1082
 	    //$buffer = $Common->getData($hosts[$id]);
798 1083
 	    $buffer = $Common->getData($value['host']);
799 1084
 	    $all_data = json_decode($buffer,true);
800
-	    if (!empty($all_data)) $reset = 0;
1085
+	    if (!empty($all_data)) {
1086
+	    	$reset = 0;
1087
+	    }
801 1088
 	    foreach ($all_data as $key => $line) {
802 1089
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
803 1090
 		    $data = array();
@@ -818,8 +1105,12 @@  discard block
 block discarded – undo
818 1105
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
819 1106
 	    	    $data['format_source'] = 'fr24json';
820 1107
     		    $data['id_source'] = $id_source;
821
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
822
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1108
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1109
+		    	$data['noarchive'] = true;
1110
+		    }
1111
+		    if (isset($value['name']) && $value['name'] != '') {
1112
+		    	$data['source_name'] = $value['name'];
1113
+		    }
823 1114
 		    $SI->add($data);
824 1115
 		    unset($data);
825 1116
 		}
@@ -843,24 +1134,42 @@  discard block
 block discarded – undo
843 1134
 		    if (isset($line['inf'])) {
844 1135
 			$data = array();
845 1136
 			$data['hex'] = $line['inf']['ia'];
846
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1137
+			if (isset($line['inf']['cs'])) {
1138
+				$data['ident'] = $line['inf']['cs'];
1139
+			}
1140
+			//$line[13]
847 1141
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
848
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
849
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1142
+	    		if (isset($line['inf']['gs'])) {
1143
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1144
+	    		}
1145
+	    		// speed
1146
+	    		if (isset($line['inf']['tr'])) {
1147
+	    			$data['heading'] = $line['inf']['tr'];
1148
+	    		}
1149
+	    		// heading
850 1150
 	    		$data['latitude'] = $line['pt'][0]; // lat
851 1151
 	    		$data['longitude'] = $line['pt'][1]; // long
852 1152
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
853
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1153
+	    		if (isset($line['inf']['sq'])) {
1154
+	    			$data['squawk'] = $line['inf']['sq'];
1155
+	    		}
1156
+	    		// squawk
854 1157
 	    		//$data['aircraft_icao'] = $line[8];
855
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1158
+	    		if (isset($line['inf']['rc'])) {
1159
+	    			$data['registration'] = $line['inf']['rc'];
1160
+	    		}
856 1161
 			//$data['departure_airport_iata'] = $line[11];
857 1162
 			//$data['arrival_airport_iata'] = $line[12];
858 1163
 	    		//$data['emergency'] = ''; // emergency
859 1164
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
860 1165
 	    		$data['format_source'] = 'radarvirtueljson';
861 1166
     			$data['id_source'] = $id_source;
862
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
863
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1167
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1168
+				$data['noarchive'] = true;
1169
+			}
1170
+			if (isset($value['name']) && $value['name'] != '') {
1171
+				$data['source_name'] = $value['name'];
1172
+			}
864 1173
 			$SI->add($data);
865 1174
 			unset($data);
866 1175
 		    }
@@ -881,30 +1190,65 @@  discard block
 block discarded – undo
881 1190
 		    $data['id'] = $line['id'];
882 1191
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
883 1192
 		    $data['ident'] = $line['callsign']; // ident
884
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
885
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
886
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
887
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
888
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
889
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1193
+		    if (isset($line['pilotid'])) {
1194
+		    	$data['pilot_id'] = $line['pilotid'];
1195
+		    }
1196
+		    // pilot id
1197
+		    if (isset($line['name'])) {
1198
+		    	$data['pilot_name'] = $line['name'];
1199
+		    }
1200
+		    // pilot name
1201
+		    if (isset($line['alt'])) {
1202
+		    	$data['altitude'] = $line['alt'];
1203
+		    }
1204
+		    // altitude
1205
+		    if (isset($line['gs'])) {
1206
+		    	$data['speed'] = $line['gs'];
1207
+		    }
1208
+		    // speed
1209
+		    if (isset($line['heading'])) {
1210
+		    	$data['heading'] = $line['heading'];
1211
+		    }
1212
+		    // heading
1213
+		    if (isset($line['route'])) {
1214
+		    	$data['waypoints'] = $line['route'];
1215
+		    }
1216
+		    // route
890 1217
 		    $data['latitude'] = $line['lat']; // lat
891 1218
 		    $data['longitude'] = $line['lon']; // long
892 1219
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
893 1220
 		    //$data['squawk'] = $line['squawk']; // squawk
894 1221
 		    //$data['emergency'] = ''; // emergency
895
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
896
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
897
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1222
+		    if (isset($line['depicao'])) {
1223
+		    	$data['departure_airport_icao'] = $line['depicao'];
1224
+		    }
1225
+		    if (isset($line['deptime'])) {
1226
+		    	$data['departure_airport_time'] = $line['deptime'];
1227
+		    }
1228
+		    if (isset($line['arricao'])) {
1229
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1230
+		    }
898 1231
 		    //$data['arrival_airport_time'] = $line['arrtime'];
899
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
900
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
901
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
902
-		    else $data['info'] = '';
1232
+		    if (isset($line['aircraft'])) {
1233
+		    	$data['aircraft_icao'] = $line['aircraft'];
1234
+		    }
1235
+		    if (isset($line['transponder'])) {
1236
+		    	$data['squawk'] = $line['transponder'];
1237
+		    }
1238
+		    if (isset($line['atis'])) {
1239
+		    	$data['info'] = $line['atis'];
1240
+		    } else {
1241
+		    	$data['info'] = '';
1242
+		    }
903 1243
 		    $data['format_source'] = 'pireps';
904 1244
     		    $data['id_source'] = $id_source;
905 1245
 		    $data['datetime'] = date('Y-m-d H:i:s');
906
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
907
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1246
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1247
+		    	$data['noarchive'] = true;
1248
+		    }
1249
+		    if (isset($value['name']) && $value['name'] != '') {
1250
+		    	$data['source_name'] = $value['name'];
1251
+		    }
908 1252
 		    if ($line['icon'] == 'plane') {
909 1253
 			$SI->add($data);
910 1254
 		    //    print_r($data);
@@ -913,16 +1257,28 @@  discard block
 block discarded – undo
913 1257
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
914 1258
 			$typec = substr($data['ident'],-3);
915 1259
 			$data['type'] = '';
916
-			if ($typec == 'APP') $data['type'] = 'Approach';
917
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
918
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
919
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
920
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
921
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
922
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
923
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
924
-			else $data['type'] = 'Observer';
925
-			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']);
1260
+			if ($typec == 'APP') {
1261
+				$data['type'] = 'Approach';
1262
+			} elseif ($typec == 'TWR') {
1263
+				$data['type'] = 'Tower';
1264
+			} elseif ($typec == 'OBS') {
1265
+				$data['type'] = 'Observer';
1266
+			} elseif ($typec == 'GND') {
1267
+				$data['type'] = 'Ground';
1268
+			} elseif ($typec == 'DEL') {
1269
+				$data['type'] = 'Delivery';
1270
+			} elseif ($typec == 'DEP') {
1271
+				$data['type'] = 'Departure';
1272
+			} elseif ($typec == 'FSS') {
1273
+				$data['type'] = 'Flight Service Station';
1274
+			} elseif ($typec == 'CTR') {
1275
+				$data['type'] = 'Control Radar or Centre';
1276
+			} else {
1277
+				$data['type'] = 'Observer';
1278
+			}
1279
+			if (isset($ATC)) {
1280
+				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']);
1281
+			}
926 1282
 		    }
927 1283
 		    unset($data);
928 1284
 		}
@@ -932,7 +1288,9 @@  discard block
 block discarded – undo
932 1288
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
933 1289
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
934 1290
 	    //$buffer = $Common->getData($hosts[$id]);
935
-	    if ($globalDebug) echo 'Get Data...'."\n";
1291
+	    if ($globalDebug) {
1292
+	    	echo 'Get Data...'."\n";
1293
+	    }
936 1294
 	    $buffer = $Common->getData($value['host']);
937 1295
 	    $all_data = json_decode($buffer,true);
938 1296
 	    if ($buffer != '' && is_array($all_data)) {
@@ -940,10 +1298,16 @@  discard block
 block discarded – undo
940 1298
 		foreach ($all_data as $line) {
941 1299
 	    	    $data = array();
942 1300
 	    	    //$data['id'] = $line['id']; // id not usable
943
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1301
+	    	    if (isset($line['pilotid'])) {
1302
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1303
+	    	    }
944 1304
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
945
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
946
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1305
+	    	    if (isset($line['pilotname'])) {
1306
+	    	    	$data['pilot_name'] = $line['pilotname'];
1307
+	    	    }
1308
+	    	    if (isset($line['pilotid'])) {
1309
+	    	    	$data['pilot_id'] = $line['pilotid'];
1310
+	    	    }
947 1311
 	    	    $data['ident'] = $line['flightnum']; // ident
948 1312
 	    	    $data['altitude'] = $line['alt']; // altitude
949 1313
 	    	    $data['speed'] = $line['gs']; // speed
@@ -961,28 +1325,44 @@  discard block
 block discarded – undo
961 1325
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
962 1326
     		    $data['arrival_airport_time'] = $line['arrtime'];
963 1327
     		    $data['registration'] = $line['aircraft'];
964
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
965
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1328
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1329
+		    	$data['noarchive'] = true;
1330
+		    }
1331
+		    if (isset($line['route'])) {
1332
+		    	$data['waypoints'] = $line['route'];
1333
+		    }
1334
+		    // route
966 1335
 		    if (isset($line['aircraftname'])) {
967 1336
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
968 1337
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
969 1338
 	    		$aircraft_data = explode('-',$line['aircraftname']);
970
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
971
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
972
-	    		else {
1339
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1340
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1341
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1342
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1343
+	    		} else {
973 1344
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
974
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
975
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1345
+	    		    if (isset($aircraft_data[1])) {
1346
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1347
+	    		    } else {
1348
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1349
+	    		    }
976 1350
 	    		}
977 1351
 	    	    }
978
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1352
+    		    if (isset($line['route'])) {
1353
+    		    	$data['waypoints'] = $line['route'];
1354
+    		    }
979 1355
     		    $data['id_source'] = $id_source;
980 1356
 	    	    $data['format_source'] = 'phpvmacars';
981
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1357
+		    if (isset($value['name']) && $value['name'] != '') {
1358
+		    	$data['source_name'] = $value['name'];
1359
+		    }
982 1360
 		    $SI->add($data);
983 1361
 		    unset($data);
984 1362
 		}
985
-		if ($globalDebug) echo 'No more data...'."\n";
1363
+		if ($globalDebug) {
1364
+			echo 'No more data...'."\n";
1365
+		}
986 1366
 		unset($buffer);
987 1367
 		unset($all_data);
988 1368
 	    }
@@ -990,7 +1370,9 @@  discard block
 block discarded – undo
990 1370
     	    $last_exec[$id]['last'] = time();
991 1371
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
992 1372
 	    //$buffer = $Common->getData($hosts[$id]);
993
-	    if ($globalDebug) echo 'Get Data...'."\n";
1373
+	    if ($globalDebug) {
1374
+	    	echo 'Get Data...'."\n";
1375
+	    }
994 1376
 	    $buffer = $Common->getData($value['host']);
995 1377
 	    $all_data = json_decode($buffer,true);
996 1378
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1019,16 +1401,25 @@  discard block
 block discarded – undo
1019 1401
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1020 1402
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1021 1403
     		    //$data['registration'] = $line['aircraft'];
1022
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1404
+		    if (isset($line['route'])) {
1405
+		    	$data['waypoints'] = $line['route'];
1406
+		    }
1407
+		    // route
1023 1408
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1024 1409
     		    $data['id_source'] = $id_source;
1025 1410
 	    	    $data['format_source'] = 'vam';
1026
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1027
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1411
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1412
+		    	$data['noarchive'] = true;
1413
+		    }
1414
+		    if (isset($value['name']) && $value['name'] != '') {
1415
+		    	$data['source_name'] = $value['name'];
1416
+		    }
1028 1417
 		    $SI->add($data);
1029 1418
 		    unset($data);
1030 1419
 		}
1031
-		if ($globalDebug) echo 'No more data...'."\n";
1420
+		if ($globalDebug) {
1421
+			echo 'No more data...'."\n";
1422
+		}
1032 1423
 		unset($buffer);
1033 1424
 		unset($all_data);
1034 1425
 	    }
@@ -1036,7 +1427,9 @@  discard block
 block discarded – undo
1036 1427
     	    $last_exec[$id]['last'] = time();
1037 1428
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1038 1429
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1039
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1430
+	    if (function_exists('pcntl_fork')) {
1431
+	    	pcntl_signal_dispatch();
1432
+	    }
1040 1433
     	    //$last_exec[$id]['last'] = time();
1041 1434
 
1042 1435
 	    //$read = array( $sockets[$id] );
@@ -1044,7 +1437,9 @@  discard block
 block discarded – undo
1044 1437
 	    $write = NULL;
1045 1438
 	    $e = NULL;
1046 1439
 	    $n = socket_select($read, $write, $e, $timeout);
1047
-	    if ($e != NULL) var_dump($e);
1440
+	    if ($e != NULL) {
1441
+	    	var_dump($e);
1442
+	    }
1048 1443
 	    if ($n > 0) {
1049 1444
 		$reset = 0;
1050 1445
 		foreach ($read as $nb => $r) {
@@ -1065,12 +1460,16 @@  discard block
 block discarded – undo
1065 1460
 		    //$SI::del();
1066 1461
 		    if ($format == 'vrstcp') {
1067 1462
 			$buffer = explode('},{',$buffer);
1068
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1463
+		    } else {
1464
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1465
+		    }
1069 1466
 		    // SBS format is CSV format
1070 1467
 		    if ($buffer !== FALSE && $buffer != '') {
1071 1468
 			$tt[$format] = 0;
1072 1469
 			if ($format == 'acarssbs3') {
1073
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1470
+			    if ($globalDebug) {
1471
+			    	echo 'ACARS : '.$buffer."\n";
1472
+			    }
1074 1473
 			    $ACARS->add(trim($buffer));
1075 1474
 			    $ACARS->deleteLiveAcarsData();
1076 1475
 			} elseif ($format == 'raw') {
@@ -1079,27 +1478,61 @@  discard block
 block discarded – undo
1079 1478
 			    if (is_array($data)) {
1080 1479
 				$data['datetime'] = date('Y-m-d H:i:s');
1081 1480
 				$data['format_source'] = 'raw';
1082
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1083
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1084
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1085
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1481
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1482
+					$data['source_name'] = $globalSources[$nb]['name'];
1483
+				}
1484
+				if (isset($globalSources[$nb]['sourcestats'])) {
1485
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1486
+				}
1487
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1488
+					$data['noarchive'] = true;
1489
+				}
1490
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1491
+					$SI->add($data);
1492
+				}
1086 1493
 			    }
1087 1494
 			} elseif ($format == 'ais') {
1088 1495
 			    $ais_data = $AIS->parse_line(trim($buffer));
1089 1496
 			    $data = array();
1090
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1091
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1092
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1093
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1094
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1095
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1096
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1097
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1098
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1099
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1100
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1101
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1102
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1497
+			    if (isset($ais_data['ident'])) {
1498
+			    	$data['ident'] = $ais_data['ident'];
1499
+			    }
1500
+			    if (isset($ais_data['mmsi'])) {
1501
+			    	$data['mmsi'] = $ais_data['mmsi'];
1502
+			    }
1503
+			    if (isset($ais_data['speed'])) {
1504
+			    	$data['speed'] = $ais_data['speed'];
1505
+			    }
1506
+			    if (isset($ais_data['heading'])) {
1507
+			    	$data['heading'] = $ais_data['heading'];
1508
+			    }
1509
+			    if (isset($ais_data['latitude'])) {
1510
+			    	$data['latitude'] = $ais_data['latitude'];
1511
+			    }
1512
+			    if (isset($ais_data['longitude'])) {
1513
+			    	$data['longitude'] = $ais_data['longitude'];
1514
+			    }
1515
+			    if (isset($ais_data['status'])) {
1516
+			    	$data['status'] = $ais_data['status'];
1517
+			    }
1518
+			    if (isset($ais_data['type'])) {
1519
+			    	$data['type'] = $ais_data['type'];
1520
+			    }
1521
+			    if (isset($ais_data['imo'])) {
1522
+			    	$data['imo'] = $ais_data['imo'];
1523
+			    }
1524
+			    if (isset($ais_data['callsign'])) {
1525
+			    	$data['callsign'] = $ais_data['callsign'];
1526
+			    }
1527
+			    if (isset($ais_data['destination'])) {
1528
+			    	$data['arrival_code'] = $ais_data['destination'];
1529
+			    }
1530
+			    if (isset($ais_data['eta_ts'])) {
1531
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1532
+			    }
1533
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1534
+			    	$data['noarchive'] = true;
1535
+			    }
1103 1536
 
1104 1537
 			    if (isset($ais_data['timestamp'])) {
1105 1538
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1108,7 +1541,9 @@  discard block
 block discarded – undo
1108 1541
 			    }
1109 1542
 			    $data['format_source'] = 'aisnmea';
1110 1543
     			    $data['id_source'] = $id_source;
1111
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1544
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1545
+			    	$MI->add($data);
1546
+			    }
1112 1547
 			    unset($data);
1113 1548
                         } elseif ($format == 'flightgearsp') {
1114 1549
                     	    //echo $buffer."\n";
@@ -1126,12 +1561,18 @@  discard block
 block discarded – undo
1126 1561
 				$data['speed'] = round($line[5]*1.94384);
1127 1562
 				$data['datetime'] = date('Y-m-d H:i:s');
1128 1563
 				$data['format_source'] = 'flightgearsp';
1129
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1130
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1564
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1565
+					$data['noarchive'] = true;
1566
+				}
1567
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1568
+					$SI->add($data);
1569
+				}
1131 1570
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1132 1571
 			    }
1133 1572
                         } elseif ($format == 'acars') {
1134
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1573
+                    	    if ($globalDebug) {
1574
+                    	    	echo 'ACARS : '.$buffer."\n";
1575
+                    	    }
1135 1576
 			    $ACARS->add(trim($buffer));
1136 1577
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1137 1578
 			    $ACARS->deleteLiveAcarsData();
@@ -1152,8 +1593,12 @@  discard block
 block discarded – undo
1152 1593
 				    $aircraft_type = $line[10];
1153 1594
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1154 1595
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1155
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1156
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1596
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1597
+				    	$data['noarchive'] = true;
1598
+				    }
1599
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1600
+				    	$SI->add($data);
1601
+				    }
1157 1602
 				}
1158 1603
 			    }
1159 1604
 			} elseif ($format == 'beast') {
@@ -1163,28 +1608,62 @@  discard block
 block discarded – undo
1163 1608
 			    foreach($buffer as $all_data) {
1164 1609
 				$line = json_decode('{'.$all_data.'}',true);
1165 1610
 				$data = array();
1166
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1167
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1168
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1169
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1170
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1171
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1172
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1611
+				if (isset($line['Icao'])) {
1612
+					$data['hex'] = $line['Icao'];
1613
+				}
1614
+				// hex
1615
+				if (isset($line['Call'])) {
1616
+					$data['ident'] = $line['Call'];
1617
+				}
1618
+				// ident
1619
+				if (isset($line['Alt'])) {
1620
+					$data['altitude'] = $line['Alt'];
1621
+				}
1622
+				// altitude
1623
+				if (isset($line['Spd'])) {
1624
+					$data['speed'] = $line['Spd'];
1625
+				}
1626
+				// speed
1627
+				if (isset($line['Trak'])) {
1628
+					$data['heading'] = $line['Trak'];
1629
+				}
1630
+				// heading
1631
+				if (isset($line['Lat'])) {
1632
+					$data['latitude'] = $line['Lat'];
1633
+				}
1634
+				// lat
1635
+				if (isset($line['Long'])) {
1636
+					$data['longitude'] = $line['Long'];
1637
+				}
1638
+				// long
1173 1639
 				//$data['verticalrate'] = $line['']; // verticale rate
1174
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1640
+				if (isset($line['Sqk'])) {
1641
+					$data['squawk'] = $line['Sqk'];
1642
+				}
1643
+				// squawk
1175 1644
 				$data['emergency'] = ''; // emergency
1176
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1645
+				if (isset($line['Reg'])) {
1646
+					$data['registration'] = $line['Reg'];
1647
+				}
1177 1648
 				/*
1178 1649
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1179 1650
 				else $data['datetime'] = date('Y-m-d H:i:s');
1180 1651
 				*/
1181 1652
 				$data['datetime'] = date('Y-m-d H:i:s');
1182
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1653
+				if (isset($line['Type'])) {
1654
+					$data['aircraft_icao'] = $line['Type'];
1655
+				}
1183 1656
 		    		$data['format_source'] = 'vrstcp';
1184 1657
 				$data['id_source'] = $id_source;
1185
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1186
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1187
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1658
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1659
+					$data['noarchive'] = true;
1660
+				}
1661
+				if (isset($value['name']) && $value['name'] != '') {
1662
+					$data['source_name'] = $value['name'];
1663
+				}
1664
+				if (isset($data['latitude']) && isset($data['hex'])) {
1665
+					$SI->add($data);
1666
+				}
1188 1667
 				unset($data);
1189 1668
 			    }
1190 1669
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1197,22 +1676,46 @@  discard block
 block discarded – undo
1197 1676
     				$data['hex'] = $lined['hexid'];
1198 1677
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1199 1678
     				$data['datetime'] = date('Y-m-d H:i:s');;
1200
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1201
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1202
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1203
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1204
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1205
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1206
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1679
+    				if (isset($lined['ident'])) {
1680
+    					$data['ident'] = $lined['ident'];
1681
+    				}
1682
+    				if (isset($lined['lat'])) {
1683
+    					$data['latitude'] = $lined['lat'];
1684
+    				}
1685
+    				if (isset($lined['lon'])) {
1686
+    					$data['longitude'] = $lined['lon'];
1687
+    				}
1688
+    				if (isset($lined['speed'])) {
1689
+    					$data['speed'] = $lined['speed'];
1690
+    				}
1691
+    				if (isset($lined['squawk'])) {
1692
+    					$data['squawk'] = $lined['squawk'];
1693
+    				}
1694
+    				if (isset($lined['alt'])) {
1695
+    					$data['altitude'] = $lined['alt'];
1696
+    				}
1697
+    				if (isset($lined['heading'])) {
1698
+    					$data['heading'] = $lined['heading'];
1699
+    				}
1207 1700
     				$data['id_source'] = $id_source;
1208 1701
     				$data['format_source'] = 'tsv';
1209
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1210
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1211
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1212
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1702
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1703
+    					$data['source_name'] = $globalSources[$nb]['name'];
1704
+    				}
1705
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1706
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1707
+    				}
1708
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1709
+					$data['noarchive'] = true;
1710
+				}
1711
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1712
+    					$SI->add($data);
1713
+    				}
1213 1714
     				unset($lined);
1214 1715
     				unset($data);
1215
-    			    } else $error = true;
1716
+    			    } else {
1717
+    			    	$error = true;
1718
+    			    }
1216 1719
 			} elseif ($format == 'aprs' && $use_aprs) {
1217 1720
 			    if ($aprs_connect == 0) {
1218 1721
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1237,32 +1740,66 @@  discard block
 block discarded – undo
1237 1740
 				    $aprs_last_tx = time();
1238 1741
 				    $data = array();
1239 1742
 				    //print_r($line);
1240
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1241
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1242
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1243
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1743
+				    if (isset($line['address'])) {
1744
+				    	$data['hex'] = $line['address'];
1745
+				    }
1746
+				    if (isset($line['mmsi'])) {
1747
+				    	$data['mmsi'] = $line['mmsi'];
1748
+				    }
1749
+				    if (isset($line['timestamp'])) {
1750
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1751
+				    } else {
1752
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1753
+				    }
1244 1754
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1245
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1755
+				    if (isset($line['ident'])) {
1756
+				    	$data['ident'] = $line['ident'];
1757
+				    }
1246 1758
 				    $data['latitude'] = $line['latitude'];
1247 1759
 				    $data['longitude'] = $line['longitude'];
1248 1760
 				    //$data['verticalrate'] = $line[16];
1249
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1250
-				    else $data['speed'] = 0;
1251
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1252
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1253
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1254
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1761
+				    if (isset($line['speed'])) {
1762
+				    	$data['speed'] = $line['speed'];
1763
+				    } else {
1764
+				    	$data['speed'] = 0;
1765
+				    }
1766
+				    if (isset($line['altitude'])) {
1767
+				    	$data['altitude'] = $line['altitude'];
1768
+				    }
1769
+				    if (isset($line['comment'])) {
1770
+				    	$data['comment'] = $line['comment'];
1771
+				    }
1772
+				    if (isset($line['symbol'])) {
1773
+				    	$data['type'] = $line['symbol'];
1774
+				    }
1775
+				    if (isset($line['heading'])) {
1776
+				    	$data['heading'] = $line['heading'];
1777
+				    }
1255 1778
 				    //else $data['heading'] = 0;
1256
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1257
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE)) $data['noarchive'] = true;
1258
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1779
+				    if (isset($line['stealth'])) {
1780
+				    	$data['aircraft_type'] = $line['stealth'];
1781
+				    }
1782
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE)) {
1783
+				    	$data['noarchive'] = true;
1784
+				    }
1785
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1786
+				    	$data['noarchive'] = true;
1787
+				    }
1259 1788
     				    $data['id_source'] = $id_source;
1260
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1261
-				    else $data['format_source'] = 'aprs';
1789
+    				    if (isset($line['format_source'])) {
1790
+    				    	$data['format_source'] = $line['format_source'];
1791
+    				    } else {
1792
+				    	$data['format_source'] = 'aprs';
1793
+				    }
1262 1794
 				    $data['source_name'] = $line['source'];
1263
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1264
-				    else $data['source_type'] = 'flarm';
1265
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1795
+				    if (isset($line['source_type'])) {
1796
+				    	$data['source_type'] = $line['source_type'];
1797
+				    } else {
1798
+				    	$data['source_type'] = 'flarm';
1799
+				    }
1800
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1801
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1802
+    				    }
1266 1803
 				    $currentdate = date('Y-m-d H:i:s');
1267 1804
 				    $aprsdate = strtotime($data['datetime']);
1268 1805
 				    // Accept data if time <= system time + 20s
@@ -1272,19 +1809,22 @@  discard block
 block discarded – undo
1272 1809
 					echo 'add...'."\n";
1273 1810
 					$send = $MI->add($data);
1274 1811
 				    } elseif (isset($line['stealth'])) {
1275
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1276
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1812
+					if ($line['stealth'] != 0) {
1813
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1814
+					} else {
1815
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1816
+					}
1277 1817
 				    //} 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')) {
1278 1818
 				    } 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') {
1279 1819
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1280
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1820
+					if (isset($globalTracker) && $globalTracker) {
1821
+						$send = $TI->add($data);
1822
+					}
1281 1823
 				    }
1282 1824
 				    unset($data);
1283
-				} 
1284
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1825
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1285 1826
 					echo '!! Weather Station not yet supported'."\n";
1286
-				}
1287
-				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')) {
1827
+				} 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')) {
1288 1828
 					echo '!! Car & Trucks not yet supported'."\n";
1289 1829
 				}
1290 1830
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1317,26 +1857,45 @@  discard block
 block discarded – undo
1317 1857
     				$data['ground'] = $line[21];
1318 1858
     				$data['emergency'] = $line[19];
1319 1859
     				$data['format_source'] = 'sbs';
1320
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1321
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1322
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1860
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1861
+					$data['source_name'] = $globalSources[$nb]['name'];
1862
+				}
1863
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1864
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1865
+    				}
1866
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1867
+					$data['noarchive'] = true;
1868
+				}
1323 1869
     				$data['id_source'] = $id_source;
1324
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1325
-    				else $error = true;
1870
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1871
+    					$send = $SI->add($data);
1872
+    				} else {
1873
+    					$error = true;
1874
+    				}
1326 1875
     				unset($data);
1327
-    			    } else $error = true;
1876
+    			    } else {
1877
+    			    	$error = true;
1878
+    			    }
1328 1879
 			    if ($error) {
1329 1880
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1330
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1881
+					if ($globalDebug) {
1882
+						echo "Not a message. Ignoring... \n";
1883
+					}
1331 1884
 				} else {
1332
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1885
+					if ($globalDebug) {
1886
+						echo "Wrong line format. Ignoring... \n";
1887
+					}
1333 1888
 					if ($globalDebug) {
1334 1889
 						echo $buffer;
1335 1890
 						//print_r($line);
1336 1891
 					}
1337 1892
 					//socket_close($r);
1338
-					if ($globalDebug) echo "Reconnect after an error...\n";
1339
-					if ($format == 'aprs') $aprs_connect = 0;
1893
+					if ($globalDebug) {
1894
+						echo "Reconnect after an error...\n";
1895
+					}
1896
+					if ($format == 'aprs') {
1897
+						$aprs_connect = 0;
1898
+					}
1340 1899
 					$sourceer[$nb] = $globalSources[$nb];
1341 1900
 					connect_all($sourceer);
1342 1901
 					$sourceer = array();
@@ -1344,10 +1903,14 @@  discard block
 block discarded – undo
1344 1903
 			    }
1345 1904
 			}
1346 1905
 			// Sleep for xxx microseconds
1347
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1906
+			if (isset($globalSBSSleep)) {
1907
+				usleep($globalSBSSleep);
1908
+			}
1348 1909
 		    } else {
1349 1910
 			if ($format == 'flightgearmp') {
1350
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1911
+			    	if ($globalDebug) {
1912
+			    		echo "Reconnect FlightGear MP...";
1913
+			    	}
1351 1914
 				//@socket_close($r);
1352 1915
 				sleep($globalMinFetch);
1353 1916
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1356,10 +1919,15 @@  discard block
 block discarded – undo
1356 1919
 				break;
1357 1920
 				
1358 1921
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1359
-			    if (isset($tt[$format])) $tt[$format]++;
1360
-			    else $tt[$format] = 0;
1922
+			    if (isset($tt[$format])) {
1923
+			    	$tt[$format]++;
1924
+			    } else {
1925
+			    	$tt[$format] = 0;
1926
+			    }
1361 1927
 			    if ($tt[$format] > 30) {
1362
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1928
+				if ($globalDebug) {
1929
+					echo "ERROR : Reconnect ".$format."...";
1930
+				}
1363 1931
 				//@socket_close($r);
1364 1932
 				sleep(2);
1365 1933
 				$aprs_connect = 0;
@@ -1376,11 +1944,17 @@  discard block
 block discarded – undo
1376 1944
 	    } else {
1377 1945
 		$error = socket_strerror(socket_last_error());
1378 1946
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1379
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1380
-			if (isset($globalDebug)) echo "Restarting...\n";
1947
+			if ($globalDebug) {
1948
+				echo "ERROR : socket_select give this error ".$error . "\n";
1949
+			}
1950
+			if (isset($globalDebug)) {
1951
+				echo "Restarting...\n";
1952
+			}
1381 1953
 			// Restart the script if possible
1382 1954
 			if (is_array($sockets)) {
1383
-			    if ($globalDebug) echo "Shutdown all sockets...";
1955
+			    if ($globalDebug) {
1956
+			    	echo "Shutdown all sockets...";
1957
+			    }
1384 1958
 			    
1385 1959
 			    foreach ($sockets as $sock) {
1386 1960
 				@socket_shutdown($sock,2);
@@ -1388,21 +1962,33 @@  discard block
 block discarded – undo
1388 1962
 			    }
1389 1963
 			    
1390 1964
 			}
1391
-			if ($globalDebug) echo "Restart all connections...";
1965
+			if ($globalDebug) {
1966
+				echo "Restart all connections...";
1967
+			}
1392 1968
 			sleep(2);
1393 1969
 			$time = time();
1394 1970
 			//connect_all($hosts);
1395 1971
 			$aprs_connect = 0;
1396
-			if ($reset%5 == 0) sleep(20);
1397
-			if ($reset%10 == 0) sleep(100);
1398
-			if ($reset%20 == 0) sleep(200);
1399
-			if ($reset > 100) exit('Too many attempts...');
1972
+			if ($reset%5 == 0) {
1973
+				sleep(20);
1974
+			}
1975
+			if ($reset%10 == 0) {
1976
+				sleep(100);
1977
+			}
1978
+			if ($reset%20 == 0) {
1979
+				sleep(200);
1980
+			}
1981
+			if ($reset > 100) {
1982
+				exit('Too many attempts...');
1983
+			}
1400 1984
 			connect_all($globalSources);
1401 1985
 		}
1402 1986
 	    }
1403 1987
 	}
1404 1988
 	if ($globalDaemon === false) {
1405
-	    if ($globalDebug) echo 'Check all...'."\n";
1989
+	    if ($globalDebug) {
1990
+	    	echo 'Check all...'."\n";
1991
+	    }
1406 1992
 	    $SI->checkAll();
1407 1993
 	}
1408 1994
     }
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +446 added lines, -119 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>
@@ -239,42 +287,86 @@  discard block
 block discarded – undo
239 287
 			<legend>Coverage area</legend>
240 288
 			<p>
241 289
 				<label for="latitudemax">The maximum latitude (north)</label>
242
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
290
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
291
+	print $globalLatitudeMax;
292
+}
293
+?>" />
243 294
 			</p>
244 295
 			<p>
245 296
 				<label for="latitudemin">The minimum latitude (south)</label>
246
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
297
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
298
+	print $globalLatitudeMin;
299
+}
300
+?>" />
247 301
 			</p>
248 302
 			<p>
249 303
 				<label for="longitudemax">The maximum longitude (west)</label>
250
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
304
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
305
+	print $globalLongitudeMax;
306
+}
307
+?>" />
251 308
 			</p>
252 309
 			<p>
253 310
 				<label for="longitudemin">The minimum longitude (east)</label>
254
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
311
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
312
+	print $globalLongitudeMin;
313
+}
314
+?>" />
255 315
 			</p>
256 316
 			<p>
257 317
 				<label for="latitudecenter">The latitude center</label>
258
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
318
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
319
+	print $globalCenterLatitude;
320
+}
321
+?>" />
259 322
 			</p>
260 323
 			<p>
261 324
 				<label for="longitudecenter">The longitude center</label>
262
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
325
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
326
+	print $globalCenterLongitude;
327
+}
328
+?>" />
263 329
 			</p>
264 330
 			<p>
265 331
 				<label for="livezoom">Default Zoom on live map</label>
266
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
332
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
333
+	print $globalLiveZoom;
334
+} else {
335
+	print '9';
336
+}
337
+?>" />
267 338
 			</p>
268 339
 			<p>
269 340
 				<label for="squawk_country">Country for squawk usage</label>
270 341
 				<select name="squawk_country" id="squawk_country">
271
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
272
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
273
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
274
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
275
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
276
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
277
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
342
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
343
+	print ' selected ';
344
+}
345
+?>>UK</option>
346
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
347
+	print ' selected ';
348
+}
349
+?>>NZ</option>
350
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
351
+	print ' selected ';
352
+}
353
+?>>US</option>
354
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
355
+	print ' selected ';
356
+}
357
+?>>AU</option>
358
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
359
+	print ' selected ';
360
+}
361
+?>>NL</option>
362
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
363
+	print ' selected ';
364
+}
365
+?>>FR</option>
366
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
367
+	print ' selected ';
368
+}
369
+?>>TR</option>
278 370
 				</select>
279 371
 			</p>
280 372
 		</fieldset>
@@ -283,15 +375,24 @@  discard block
 block discarded – undo
283 375
 			<p><i>Only put in DB flights that are inside a circle</i></p>
284 376
 			<p>
285 377
 				<label for="latitude">Center latitude</label>
286
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
378
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
379
+	echo $globalDistanceIgnore['latitude'];
380
+}
381
+?>" />
287 382
 			</p>
288 383
 			<p>
289 384
 				<label for="longitude">Center longitude</label>
290
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
385
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
386
+	echo $globalDistanceIgnore['longitude'];
387
+}
388
+?>" />
291 389
 			</p>
292 390
 			<p>
293 391
 				<label for="Distance">Distance (in km)</label>
294
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
392
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
393
+	echo $globalDistanceIgnore['distance'];
394
+}
395
+?>" />
295 396
 			</p>
296 397
 		</fieldset>
297 398
 		<fieldset id="sourceloc">
@@ -397,11 +498,17 @@  discard block
 block discarded – undo
397 498
 			<div id="flightaware_data">
398 499
 				<p>
399 500
 					<label for="flightawareusername">FlightAware username</label>
400
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
501
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
502
+	print $globalFlightAwareUsername;
503
+}
504
+?>" />
401 505
 				</p>
402 506
 				<p>
403 507
 					<label for="flightawarepassword">FlightAware password/API key</label>
404
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
508
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
509
+	print $globalFlightAwarePassword;
510
+}
511
+?>" />
405 512
 				</p>
406 513
 			</div>
407 514
 -->
@@ -461,28 +568,88 @@  discard block
 block discarded – undo
461 568
 								?>
462 569
 								<td>
463 570
 									<select name="format[]" id="format">
464
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
465
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
466
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
467
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
468
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
469
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
470
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
471
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
472
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
473
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
474
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
475
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
476
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
477
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
478
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
479
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
480
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
571
+										<option value="auto" <?php if (!isset($source['format'])) {
572
+	print 'selected';
573
+}
574
+?>>Auto</option>
575
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
576
+	print 'selected';
577
+}
578
+?>>SBS</option>
579
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
580
+	print 'selected';
581
+}
582
+?>>TSV</option>
583
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
584
+	print 'selected';
585
+}
586
+?>>Raw</option>
587
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
588
+	print 'selected';
589
+}
590
+?>>APRS</option>
591
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
592
+	print 'selected';
593
+}
594
+?>>Radarcape deltadb.txt</option>
595
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
596
+	print 'selected';
597
+}
598
+?>>Vatsim</option>
599
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
600
+	print 'selected';
601
+}
602
+?>>Virtual Radar Server AircraftList.json</option>
603
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
604
+	print 'selected';
605
+}
606
+?>>Virtual Radar Server TCP</option>
607
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
608
+	print 'selected';
609
+}
610
+?>>phpVMS</option>
611
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
612
+	print 'selected';
613
+}
614
+?>>Virtual Airlines Manager</option>
615
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
616
+	print 'selected';
617
+}
618
+?>>IVAO</option>
619
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
620
+	print 'selected';
621
+}
622
+?>>FlightGear Multiplayer</option>
623
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
624
+	print 'selected';
625
+}
626
+?>>FlightGear Singleplayer</option>
627
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
628
+	print 'selected';
629
+}
630
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
631
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
632
+	print 'selected';
633
+}
634
+?>>ACARS SBS-3 over TCP</option>
635
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
636
+	print 'selected';
637
+}
638
+?>>NMEA AIS over TCP</option>
481 639
 									</select>
482 640
 								</td>
483
-								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td>
484
-								<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>
485
-								<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>
641
+								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
642
+	print $source['name'];
643
+}
644
+?>" /></td>
645
+								<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']) {
646
+	print 'checked';
647
+}
648
+?> /></td>
649
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
650
+	print 'checked';
651
+}
652
+?> /></td>
486 653
 								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
487 654
 							</tr>
488 655
 <?php
@@ -531,11 +698,17 @@  discard block
 block discarded – undo
531 698
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
532 699
 					<p>
533 700
 						<label for="acarshost">ACARS UDP host</label>
534
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
701
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
702
+	print $globalACARSHost;
703
+}
704
+?>" />
535 705
 					</p>
536 706
 					<p>
537 707
 						<label for="acarsport">ACARS UDP port</label>
538
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
708
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
709
+	print $globalACARSPort;
710
+}
711
+?>" />
539 712
 					</p>
540 713
 				</fieldset>
541 714
 			</div>
@@ -615,13 +788,19 @@  discard block
 block discarded – undo
615 788
 			<div id="schedules_options">
616 789
 				<p>
617 790
 					<label for="britishairways">British Airways API Key</label>
618
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
791
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
792
+	print $globalBritishAirwaysKey;
793
+}
794
+?>" />
619 795
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
620 796
 				</p>
621 797
 				<!--
622 798
 				<p>
623 799
 					<label for="transavia">Transavia Test API Consumer Key</label>
624
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
800
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
801
+	print $globalTransaviaKey;
802
+}
803
+?>" />
625 804
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
626 805
 				</p>
627 806
 				-->
@@ -630,10 +809,16 @@  discard block
 block discarded – undo
630 809
 						<b>Lufthansa API Key</b>
631 810
 						<p>
632 811
 							<label for="lufthansakey">Key</label>
633
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
812
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
813
+	print $globalLufthansaKey['key'];
814
+}
815
+?>" />
634 816
 						</p><p>
635 817
 							<label for="lufthansasecret">Secret</label>
636
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
818
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
819
+	print $globalLufthansaKey['secret'];
820
+}
821
+?>" />
637 822
 						</p>
638 823
 					</div>
639 824
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -653,7 +838,10 @@  discard block
 block discarded – undo
653 838
 			</p>
654 839
 			<p>
655 840
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
656
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
841
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
842
+	print $globalNOTAMSource;
843
+}
844
+?>" />
657 845
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
658 846
 			</p>
659 847
 			<br />
@@ -669,14 +857,20 @@  discard block
 block discarded – undo
669 857
 			<div id="metarsrc">
670 858
 				<p>
671 859
 					<label for="metarsource">URL of your METAR source</label>
672
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
860
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
861
+	print $globalMETARurl;
862
+}
863
+?>" />
673 864
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
674 865
 				</p>
675 866
 			</div>
676 867
 			<br />
677 868
 			<p>
678 869
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
679
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
870
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
871
+	print $globalBitlyAccessToken;
872
+}
873
+?>" />
680 874
 			</p>
681 875
 			<br />
682 876
 			<p>
@@ -696,7 +890,12 @@  discard block
 block discarded – undo
696 890
 			</p>
697 891
 			<p>
698 892
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
699
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
893
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
894
+	print $globalArchiveMonths;
895
+} else {
896
+	echo '0';
897
+}
898
+?>" />
700 899
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
701 900
 			</p>
702 901
 			<p>
@@ -706,12 +905,22 @@  discard block
 block discarded – undo
706 905
 			</p>
707 906
 			<p>
708 907
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
709
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
908
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
909
+	print $globalArchiveKeepMonths;
910
+} else {
911
+	echo '0';
912
+}
913
+?>" />
710 914
 				<p class="help-block">0 to disable</p>
711 915
 			</p>
712 916
 			<p>
713 917
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
714
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
918
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
919
+	print $globalArchiveKeepTrackMonths;
920
+} else {
921
+	echo '0';
922
+}
923
+?>" />
715 924
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
716 925
 			</p>
717 926
 			<br />
@@ -721,7 +930,12 @@  discard block
 block discarded – undo
721 930
 				<p class="help-block">Uncheck if the script is running as cron job</p>
722 931
 				<div id="cronends"> 
723 932
 					<label for="cronend">Run script for xx seconds</label>
724
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
933
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
934
+	print $globalCronEnd;
935
+} else {
936
+	print '0';
937
+}
938
+?>" />
725 939
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
726 940
 				</div>
727 941
 			</p>
@@ -766,15 +980,30 @@  discard block
 block discarded – undo
766 980
 			<br />
767 981
 			<p>
768 982
 				<label for="refresh">Show flights detected since xxx seconds</label>
769
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
983
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
984
+	echo $globalLiveInterval;
985
+} else {
986
+	echo '200';
987
+}
988
+?>" />
770 989
 			</p>
771 990
 			<p>
772 991
 				<label for="maprefresh">Live map refresh (in seconds)</label>
773
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
992
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
993
+	echo $globalMapRefresh;
994
+} else {
995
+	echo '30';
996
+}
997
+?>" />
774 998
 			</p>
775 999
 			<p>
776 1000
 				<label for="mapidle">Map idle timeout (in minutes)</label>
777
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1001
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1002
+	echo $globalMapIdleTimeout;
1003
+} else {
1004
+	echo '30';
1005
+}
1006
+?>" />
778 1007
 				<p class="help-block">0 to disable</p>
779 1008
 			</p>
780 1009
 			<p>
@@ -784,12 +1013,20 @@  discard block
 block discarded – undo
784 1013
 			<br />
785 1014
 			<p>
786 1015
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
787
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1016
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1017
+	echo $globalClosestMinDist;
1018
+} else {
1019
+	echo '50';
1020
+}
1021
+?>" />
788 1022
 			</p>
789 1023
 			<br />
790 1024
 			<p>
791 1025
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
792
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1026
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1027
+	echo $globalAircraftSize;
1028
+}
1029
+?>" />
793 1030
 			</p>
794 1031
 			<br />
795 1032
 			<p>
@@ -797,7 +1034,12 @@  discard block
 block discarded – undo
797 1034
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
798 1035
 			?>
799 1036
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
800
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1037
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1038
+	echo $globalAircraftIconColor;
1039
+} else {
1040
+	echo '1a3151';
1041
+}
1042
+?>" />
801 1043
 			<?php
802 1044
 				if (!is_writable('../cache')) {
803 1045
 			?>
@@ -815,8 +1057,18 @@  discard block
 block discarded – undo
815 1057
 			<p>
816 1058
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
817 1059
 				<div class="range">
818
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
819
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1060
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1061
+	echo $globalAirportZoom;
1062
+} else {
1063
+	echo '7';
1064
+}
1065
+?>" />
1066
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1067
+	echo $globalAirportZoom;
1068
+} else {
1069
+	echo '7';
1070
+}
1071
+?></output>
820 1072
 				</div>
821 1073
 			</p>
822 1074
 		</fieldset>
@@ -844,8 +1096,12 @@  discard block
 block discarded – undo
844 1096
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
845 1097
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
846 1098
 
847
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
848
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1099
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1100
+		$error .= 'Mysql driver for PDO must be loaded';
1101
+	}
1102
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1103
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1104
+	}
849 1105
 	
850 1106
 	$_SESSION['database_root'] = $dbroot;
851 1107
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -912,15 +1168,23 @@  discard block
 block discarded – undo
912 1168
 	$source_city = $_POST['source_city'];
913 1169
 	$source_country = $_POST['source_country'];
914 1170
 	$source_ref = $_POST['source_ref'];
915
-	if (isset($source_id)) $source_id = $_POST['source_id'];
916
-	else $source_id = array();
1171
+	if (isset($source_id)) {
1172
+		$source_id = $_POST['source_id'];
1173
+	} else {
1174
+		$source_id = array();
1175
+	}
917 1176
 	
918 1177
 	$sources = array();
919 1178
 	foreach ($source_name as $keys => $name) {
920
-	    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]);
921
-	    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]);
1179
+	    if (isset($source_id[$keys])) {
1180
+	    	$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]);
1181
+	    } else {
1182
+	    	$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]);
1183
+	    }
1184
+	}
1185
+	if (count($sources) > 0) {
1186
+		$_SESSION['sources'] = $sources;
922 1187
 	}
923
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
924 1188
 
925 1189
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
926 1190
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -940,14 +1204,23 @@  discard block
 block discarded – undo
940 1204
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
941 1205
 
942 1206
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
943
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
944
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1207
+	if ($globalaircraft == 'aircraft') {
1208
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1209
+	} else {
1210
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1211
+	}
945 1212
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
946
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
947
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1213
+	if ($globaltracker == 'tracker') {
1214
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1215
+	} else {
1216
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1217
+	}
948 1218
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
949
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
950
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1219
+	if ($globalmarine == 'marine') {
1220
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1221
+	} else {
1222
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1223
+	}
951 1224
 
952 1225
 /*	
953 1226
 	$globalSBS1Hosts = array();
@@ -968,17 +1241,31 @@  discard block
 block discarded – undo
968 1241
 	$port = $_POST['port'];
969 1242
 	$name = $_POST['name'];
970 1243
 	$format = $_POST['format'];
971
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
972
-	else $sourcestats = array();
973
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
974
-	else $noarchive = array();
1244
+	if (isset($_POST['sourcestats'])) {
1245
+		$sourcestats = $_POST['sourcestats'];
1246
+	} else {
1247
+		$sourcestats = array();
1248
+	}
1249
+	if (isset($_POST['noarchive'])) {
1250
+		$noarchive = $_POST['noarchive'];
1251
+	} else {
1252
+		$noarchive = array();
1253
+	}
975 1254
 	$gSources = array();
976 1255
 	foreach ($host as $key => $h) {
977
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
978
-		else $cov = 'FALSE';
979
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
980
-		else $arch = 'FALSE';
981
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch);
1256
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1257
+			$cov = 'TRUE';
1258
+		} else {
1259
+			$cov = 'FALSE';
1260
+		}
1261
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1262
+			$arch = 'TRUE';
1263
+		} else {
1264
+			$arch = 'FALSE';
1265
+		}
1266
+		if ($h != '') {
1267
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch);
1268
+		}
982 1269
 	}
983 1270
 	$settings = array_merge($settings,array('globalSources' => $gSources));
984 1271
 
@@ -1003,7 +1290,9 @@  discard block
 block discarded – undo
1003 1290
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1004 1291
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1005 1292
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1006
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1293
+	} else {
1294
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1295
+	}
1007 1296
 
1008 1297
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1009 1298
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1042,7 +1331,9 @@  discard block
 block discarded – undo
1042 1331
 
1043 1332
 	// Create in settings.php keys not yet configurable if not already here
1044 1333
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1045
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1334
+	if (!isset($globalDebug)) {
1335
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1336
+	}
1046 1337
 
1047 1338
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1048 1339
 	if ($resetyearstats == 'resetyearstats') {
@@ -1079,27 +1370,43 @@  discard block
 block discarded – undo
1079 1370
 	}
1080 1371
 */
1081 1372
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1082
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1083
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1084
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1085
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1373
+	if ($globalsbs == 'sbs') {
1374
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1375
+	} else {
1376
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1377
+	}
1378
+	if ($globalaprs == 'aprs') {
1379
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1380
+	} else {
1381
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1382
+	}
1086 1383
 	if ($globalivao == 'ivao') {
1087 1384
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1088 1385
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1089
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1386
+	} else {
1387
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1388
+	}
1090 1389
 	if ($globalvatsim == 'vatsim') {
1091 1390
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1092 1391
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1093
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1392
+	} else {
1393
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1394
+	}
1094 1395
 	if ($globalphpvms == 'phpvms') {
1095 1396
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1096
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1397
+	} else {
1398
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1399
+	}
1097 1400
 	if ($globalvam == 'vam') {
1098 1401
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1099
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1402
+	} else {
1403
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1404
+	}
1100 1405
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1101 1406
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1102
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1407
+	} else {
1408
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1409
+	}
1103 1410
 	
1104 1411
 
1105 1412
 
@@ -1241,7 +1548,9 @@  discard block
 block discarded – undo
1241 1548
 		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1242 1549
 	}
1243 1550
 
1244
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1551
+	if (!isset($globalTransaction)) {
1552
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1553
+	}
1245 1554
 
1246 1555
 	// Set some defaults values...
1247 1556
 	if (!isset($globalAircraftImageSources)) {
@@ -1256,15 +1565,23 @@  discard block
 block discarded – undo
1256 1565
 
1257 1566
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1258 1567
 
1259
-	if ($error == '') settings::modify_settings($settings);
1260
-	if ($error == '') settings::comment_settings($settings_comment);
1568
+	if ($error == '') {
1569
+		settings::modify_settings($settings);
1570
+	}
1571
+	if ($error == '') {
1572
+		settings::comment_settings($settings_comment);
1573
+	}
1261 1574
 	if ($error != '') {
1262 1575
 		print '<div class="info column">'.$error.'</div>';
1263 1576
 		require('../footer.php');
1264 1577
 		exit;
1265 1578
 	} else {
1266
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1267
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1579
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1580
+			$_SESSION['waypoints'] = 1;
1581
+		}
1582
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1583
+			$_SESSION['owner'] = 1;
1584
+		}
1268 1585
 		if (isset($_POST['createdb'])) {
1269 1586
 			$_SESSION['install'] = 'database_create';
1270 1587
 		} else {
@@ -1305,10 +1622,18 @@  discard block
 block discarded – undo
1305 1622
 	$popw = false;
1306 1623
 	foreach ($_SESSION['done'] as $done) {
1307 1624
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1308
-	    if ($done == 'Create database') $pop = true;
1309
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1310
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1311
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1625
+	    if ($done == 'Create database') {
1626
+	    	$pop = true;
1627
+	    }
1628
+	    if ($_SESSION['install'] == 'database_create') {
1629
+	    	$pop = true;
1630
+	    }
1631
+	    if ($_SESSION['install'] == 'database_import') {
1632
+	    	$popi = true;
1633
+	    }
1634
+	    if ($_SESSION['install'] == 'waypoints') {
1635
+	    	$popw = true;
1636
+	    }
1312 1637
 	}
1313 1638
 	if ($pop) {
1314 1639
 	    sleep(5);
@@ -1319,7 +1644,9 @@  discard block
 block discarded – undo
1319 1644
 	} else if ($popw) {
1320 1645
 	    sleep(5);
1321 1646
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1322
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1647
+	} else {
1648
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1649
+	}
1323 1650
 	print '</div></ul>';
1324 1651
 	print '<div id="error"></div>';
1325 1652
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Braces   +203 added lines, -75 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24 24
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
25 25
 		$reg = $registration;
26
-		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
26
+		if ($reg == '' && $aircraft_icao != '') {
27
+			$reg = $aircraft_icao.$airline_icao;
28
+		}
27 29
 		$reg = trim($reg);
28 30
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
29 31
 			FROM spotter_image 
@@ -31,9 +33,13 @@  discard block
 block discarded – undo
31 33
 		$sth = $this->db->prepare($query);
32 34
 		$sth->execute(array(':registration' => $reg));
33 35
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
34
-		if (!empty($result)) return $result;
35
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
36
-		else return array();
36
+		if (!empty($result)) {
37
+			return $result;
38
+		} elseif ($registration != '') {
39
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
40
+		} else {
41
+			return array();
42
+		}
37 43
 	}
38 44
 
39 45
 	/**
@@ -76,8 +82,11 @@  discard block
 block discarded – undo
76 82
 	public function getExifCopyright($url) {
77 83
 		$exif = exif_read_data($url);
78 84
 		$copyright = '';
79
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
80
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
85
+		if (isset($exif['COMPUTED']['copyright'])) {
86
+			$copyright = $exif['COMPUTED']['copyright'];
87
+		} elseif (isset($exif['copyright'])) {
88
+			$copyright = $exif['copyright'];
89
+		}
81 90
 		if ($copyright != '') {
82 91
 			$copyright = str_replace('Copyright ','',$copyright);
83 92
 			$copyright = str_replace('© ','',$copyright);
@@ -95,17 +104,27 @@  discard block
 block discarded – undo
95 104
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
96 105
 	{
97 106
 		global $globalDebug,$globalAircraftImageFetch;
98
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
107
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
108
+			return '';
109
+		}
99 110
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
100 111
 		$registration = trim($registration);
101 112
 		//getting the aircraft image
102
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
103
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
104
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
113
+		if ($globalDebug && $registration != '') {
114
+			echo 'Try to find an aircraft image for '.$registration.'...';
115
+		} elseif ($globalDebug && $aircraft_icao != '') {
116
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
117
+		} elseif ($globalDebug && $airline_icao != '') {
118
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
119
+		}
105 120
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
106
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
121
+		if ($registration == '' && $aircraft_icao != '') {
122
+			$registration = $aircraft_icao.$airline_icao;
123
+		}
107 124
 		if ($image_url['original'] != '') {
108
-			if ($globalDebug) echo 'Found !'."\n";
125
+			if ($globalDebug) {
126
+				echo 'Found !'."\n";
127
+			}
109 128
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
110 129
 			try {
111 130
 				$sth = $this->db->prepare($query);
@@ -114,7 +133,9 @@  discard block
 block discarded – undo
114 133
 				echo $e->getMessage()."\n";
115 134
 				return "error";
116 135
 			}
117
-		} elseif ($globalDebug) echo "Not found :'(\n";
136
+		} elseif ($globalDebug) {
137
+			echo "Not found :'(\n";
138
+		}
118 139
 		return "success";
119 140
 	}
120 141
 
@@ -127,7 +148,9 @@  discard block
 block discarded – undo
127 148
 	public function addMarineImage($mmsi,$imo = '',$name = '')
128 149
 	{
129 150
 		global $globalDebug,$globalMarineImageFetch;
130
-		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return '';
151
+		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) {
152
+			return '';
153
+		}
131 154
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
132 155
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
133 156
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
@@ -137,16 +160,22 @@  discard block
 block discarded – undo
137 160
 			$identity = $Marine->getIdentity($mmsi);
138 161
 			if (isset($identity[0]['mmsi'])) {
139 162
 				$imo = $identity[0]['imo'];
140
-				if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name'];
163
+				if ($identity[0]['ship_name'] != '') {
164
+					$name = $identity[0]['ship_name'];
165
+				}
141 166
 			}
142 167
 		}
143 168
 		unset($Marine);
144 169
 
145 170
 		//getting the aircraft image
146
-		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
171
+		if ($globalDebug && $name != '') {
172
+			echo 'Try to find an vessel image for '.$name.'...';
173
+		}
147 174
 		$image_url = $this->findMarineImage($mmsi,$imo,$name);
148 175
 		if ($image_url['original'] != '') {
149
-			if ($globalDebug) echo 'Found !'."\n";
176
+			if ($globalDebug) {
177
+				echo 'Found !'."\n";
178
+			}
150 179
 			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
151 180
 			try {
152 181
 				$sth = $this->db->prepare($query);
@@ -155,7 +184,9 @@  discard block
 block discarded – undo
155 184
 				echo $e->getMessage()."\n";
156 185
 				return "error";
157 186
 			}
158
-		} elseif ($globalDebug) echo "Not found :'(\n";
187
+		} elseif ($globalDebug) {
188
+			echo "Not found :'(\n";
189
+		}
159 190
 		return "success";
160 191
 	}
161 192
 
@@ -170,41 +201,85 @@  discard block
 block discarded – undo
170 201
 	{
171 202
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO;
172 203
 		$Spotter = new Spotter($this->db);
173
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
204
+		if (!isset($globalIVAO)) {
205
+			$globalIVAO = FALSE;
206
+		}
174 207
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
175 208
 		if ($aircraft_registration != '') {
176
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
209
+			if (strpos($aircraft_registration,'/') !== false) {
210
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
211
+			}
177 212
 			$aircraft_registration = urlencode(trim($aircraft_registration));
178 213
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
179
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
180
-			else $aircraft_name = '';
181
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
182
-			else $aircraft_icao = '';
183
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
184
-			else $airline_icao = '';
214
+			if (isset($aircraft_info[0]['aircraft_name'])) {
215
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
216
+			} else {
217
+				$aircraft_name = '';
218
+			}
219
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
220
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
221
+			} else {
222
+				$aircraft_icao = '';
223
+			}
224
+			if (isset($aircraft_info[0]['airline_icao'])) {
225
+				$airline_icao = $aircraft_info[0]['airline_icao'];
226
+			} else {
227
+				$airline_icao = '';
228
+			}
185 229
 		} elseif ($aircraft_icao != '') {
186 230
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
187
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
188
-			else $aircraft_name = '';
231
+			if (isset($aircraft_info[0]['type'])) {
232
+				$aircraft_name = $aircraft_info[0]['type'];
233
+			} else {
234
+				$aircraft_name = '';
235
+			}
189 236
 			$aircraft_registration = $aircraft_icao;
190
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
237
+		} else {
238
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
239
+		}
191 240
 		unset($Spotter);
192
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
241
+		if (!isset($globalAircraftImageSources)) {
242
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
243
+		}
193 244
 		foreach ($globalAircraftImageSources as $source) {
194 245
 			$source = strtolower($source);
195
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
196
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
197
-			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
198
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
199
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
200
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
201
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
202
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
203
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
204
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
205
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
206
-		}
207
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
246
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
247
+				$images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
248
+			}
249
+			if ($source == 'planespotters' && !$globalIVAO) {
250
+				$images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
251
+			}
252
+			if ($source == 'flickr') {
253
+				$images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
254
+			}
255
+			if ($source == 'bing') {
256
+				$images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
257
+			}
258
+			if ($source == 'deviantart') {
259
+				$images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
260
+			}
261
+			if ($source == 'wikimedia') {
262
+				$images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
263
+			}
264
+			if ($source == 'jetphotos' && !$globalIVAO) {
265
+				$images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
266
+			}
267
+			if ($source == 'planepictures' && !$globalIVAO) {
268
+				$images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
269
+			}
270
+			if ($source == 'airportdata' && !$globalIVAO) {
271
+				$images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
272
+			}
273
+			if ($source == 'customsources') {
274
+				$images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
275
+			}
276
+			if (isset($images_array) && $images_array['original'] != '') {
277
+				return $images_array;
278
+			}
279
+		}
280
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
281
+			return $this->findAircraftImage($aircraft_icao);
282
+		}
208 283
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
209 284
 	}
210 285
 
@@ -224,7 +299,9 @@  discard block
 block discarded – undo
224 299
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
225 300
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
226 301
 		$name = trim($name);
227
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
302
+		if (strlen($name) < 4) {
303
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
304
+		}
228 305
 		/*
229 306
 		$Marine = new Marine($this->db);
230 307
 		if ($imo == '' || $name == '') {
@@ -236,15 +313,29 @@  discard block
 block discarded – undo
236 313
 		}
237 314
 		unset($Marine);
238 315
 		*/
239
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
316
+		if (!isset($globalMarineImageSources)) {
317
+			$globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
318
+		}
240 319
 		foreach ($globalMarineImageSources as $source) {
241 320
 			$source = strtolower($source);
242
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
243
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
244
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
245
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
246
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
247
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
321
+			if ($source == 'flickr') {
322
+				$images_array = $this->fromFlickr('marine',$mmsi,$name);
323
+			}
324
+			if ($source == 'bing') {
325
+				$images_array = $this->fromBing('marine',$mmsi,$name);
326
+			}
327
+			if ($source == 'deviantart') {
328
+				$images_array = $this->fromDeviantart('marine',$mmsi,$name);
329
+			}
330
+			if ($source == 'wikimedia') {
331
+				$images_array = $this->fromWikimedia('marine',$mmsi,$name);
332
+			}
333
+			if ($source == 'customsources') {
334
+				$images_array = $this->fromCustomSource('marine',$mmsi,$name);
335
+			}
336
+			if (isset($images_array) && $images_array['original'] != '') {
337
+				return $images_array;
338
+			}
248 339
 		}
249 340
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
250 341
 	}
@@ -407,11 +498,17 @@  discard block
 block discarded – undo
407 498
 	public function fromFlickr($type,$registration,$name='') {
408 499
 		$Common = new Common();
409 500
 		if ($type == 'aircraft') {
410
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
411
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
501
+			if ($name != '') {
502
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
503
+			} else {
504
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
505
+			}
412 506
 		} elseif ($type == 'marine') {
413
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.urlencode($name);
414
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',vessel';
507
+			if ($name != '') {
508
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.urlencode($name);
509
+			} else {
510
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',vessel';
511
+			}
415 512
 		}
416 513
 		$data = $Common->getData($url);
417 514
 		if ($xml = simplexml_load_string($data)) {
@@ -456,9 +553,14 @@  discard block
 block discarded – undo
456 553
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
457 554
 		global $globalImageBingKey;
458 555
 		$Common = new Common();
459
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
460
-		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
461
-		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
556
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
557
+			return false;
558
+		}
559
+		if ($aircraft_name != '') {
560
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
561
+		} else {
562
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
563
+		}
462 564
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
463 565
 		$data = $Common->getData($url,'get','',$headers);
464 566
 		$result = json_decode($data);
@@ -513,17 +615,25 @@  discard block
 block discarded – undo
513 615
 	public function fromWikimedia($type,$registration,$name='') {
514 616
 		$Common = new Common();
515 617
 		if ($type == 'aircraft') {
516
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
517
-			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
618
+			if ($name != '') {
619
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
620
+			} else {
621
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
622
+			}
518 623
 		} elseif ($type == 'marine') {
519
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'"';
520
-			else return false;
624
+			if ($name != '') {
625
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'"';
626
+			} else {
627
+				return false;
628
+			}
521 629
 		}
522 630
 		$data = $Common->getData($url);
523 631
 		$result = json_decode($data);
524 632
 		if (isset($result->query->search[0]->title)) {
525 633
 			$fileo = $result->query->search[0]->title;
526
-			if (substr($fileo,-3) == 'pdf') return false;
634
+			if (substr($fileo,-3) == 'pdf') {
635
+				return false;
636
+			}
527 637
 			$file = urlencode($fileo);
528 638
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
529 639
 			$data2 = $Common->getData($url2);
@@ -594,18 +704,27 @@  discard block
 block discarded – undo
594 704
 					$image_url = array();
595 705
 					$image_url['thumbnail'] = $url_thumbnail;
596 706
 					$image_url['original'] = $url;
597
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
598
-					else $exifCopyright = '';
599
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
600
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
601
-					else $image_url['copyright'] = $source['source_website'];
707
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
708
+						$exifCopyright = $this->getExifCopyright($url);
709
+					} else {
710
+						$exifCopyright = '';
711
+					}
712
+					if ($exifCopyright  != '') {
713
+						$image_url['copyright'] = $exifCopyright;
714
+					} elseif (isset($source['copyright'])) {
715
+						$image_url['copyright'] = $source['copyright'];
716
+					} else {
717
+						$image_url['copyright'] = $source['source_website'];
718
+					}
602 719
 					$image_url['source_website'] = $source['source_website'];
603 720
 					$image_url['source'] = $source['source'];
604 721
 					return $image_url;
605 722
 				}
606 723
 			}
607 724
 			return false;
608
-		} else return false;
725
+		} else {
726
+			return false;
727
+		}
609 728
 		if (!empty($globalMarineImageCustomSources) && $type == 'marine') {
610 729
 			$customsources = array();
611 730
 			if (!isset($globalMarineImageCustomSources[0])) {
@@ -630,18 +749,27 @@  discard block
 block discarded – undo
630 749
 					$image_url = array();
631 750
 					$image_url['thumbnail'] = $url_thumbnail;
632 751
 					$image_url['original'] = $url;
633
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
634
-					else $exifCopyright = '';
635
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
636
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
637
-					else $image_url['copyright'] = $source['source_website'];
752
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
753
+						$exifCopyright = $this->getExifCopyright($url);
754
+					} else {
755
+						$exifCopyright = '';
756
+					}
757
+					if ($exifCopyright  != '') {
758
+						$image_url['copyright'] = $exifCopyright;
759
+					} elseif (isset($source['copyright'])) {
760
+						$image_url['copyright'] = $source['copyright'];
761
+					} else {
762
+						$image_url['copyright'] = $source['source_website'];
763
+					}
638 764
 					$image_url['source_website'] = $source['source_website'];
639 765
 					$image_url['source'] = $source['source'];
640 766
 					return $image_url;
641 767
 				}
642 768
 			}
643 769
 			return false;
644
-		} else return false;
770
+		} else {
771
+			return false;
772
+		}
645 773
 	}
646 774
 }
647 775
 
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +352 added lines, -124 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	$dbc = $this->db;
64 64
 	$this->all_flights[$id]['schedule_check'] = true;
65 65
 	if ($globalSchedulesFetch) {
66
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
66
+	if ($globalDebug) {
67
+		echo 'Getting schedule info...'."\n";
68
+	}
67 69
 	$Spotter = new Spotter($dbc);
68 70
 	$Schedule = new Schedule($dbc);
69 71
 	$Translation = new Translation($dbc);
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	    if ($Schedule->checkSchedule($operator) == 0) {
75 77
 		$schedule = $Schedule->fetchSchedule($operator);
76 78
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
79
+		    if ($globalDebug) {
80
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
81
+		    }
78 82
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79 83
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80 84
 		    // Should also check if route schedule = route from DB
@@ -83,7 +87,9 @@  discard block
 block discarded – undo
83 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84 88
 			    if (trim($airport_icao) != '') {
85 89
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
92
+				}
87 93
 			    }
88 94
 			}
89 95
 		    }
@@ -92,17 +98,25 @@  discard block
 block discarded – undo
92 98
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93 99
 			    if (trim($airport_icao) != '') {
94 100
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
101
+				if ($globalDebug) {
102
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
103
+				}
96 104
 			    }
97 105
 			}
98 106
 		    }
99 107
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
100 108
 		}
101
-	    } else $scheduleexist = true;
102
-	} else $scheduleexist = true;
109
+	    } else {
110
+	    	$scheduleexist = true;
111
+	    }
112
+	} else {
113
+		$scheduleexist = true;
114
+	}
103 115
 	// close connection, at least one way will work ?
104 116
        if ($scheduleexist) {
105
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
117
+		if ($globalDebug) {
118
+			echo "-> get arrival/departure airport info for ".$ident."\n";
119
+		}
106 120
     		$sch = $Schedule->getSchedule($operator);
107 121
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
108 122
        }
@@ -124,14 +138,18 @@  discard block
 block discarded – undo
124 138
 
125 139
     public function checkAll() {
126 140
 	global $globalDebug, $globalNoImport;
127
-	if ($globalDebug) echo "Update last seen flights data...\n";
141
+	if ($globalDebug) {
142
+		echo "Update last seen flights data...\n";
143
+	}
128 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129 145
 	    foreach ($this->all_flights as $key => $flight) {
130 146
 		if (isset($this->all_flights[$key]['id'])) {
131 147
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 148
     		    $Spotter = new Spotter($this->db);
133 149
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
150
+        	    if (isset($this->all_flights[$key]['altitude'])) {
151
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
152
+        	    }
135 153
         	}
136 154
 	    }
137 155
 	}
@@ -139,24 +157,32 @@  discard block
 block discarded – undo
139 157
 
140 158
     public function arrival($key) {
141 159
 	global $globalClosestMinDist, $globalDebug;
142
-	if ($globalDebug) echo 'Update arrival...'."\n";
160
+	if ($globalDebug) {
161
+		echo 'Update arrival...'."\n";
162
+	}
143 163
 	$Spotter = new Spotter($this->db);
144 164
         $airport_icao = '';
145 165
         $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
166
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
167
+        	$globalClosestMinDist = 50;
168
+        }
147 169
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148 170
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149 171
     	    if (isset($closestAirports[0])) {
150 172
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 173
         	    $airport_icao = $closestAirports[0]['icao'];
152 174
         	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
175
+        	    if ($globalDebug) {
176
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        	    }
154 178
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155 179
         	    foreach ($closestAirports as $airport) {
156 180
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157 181
         		    $airport_icao = $airport['icao'];
158 182
         		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
183
+        		    if ($globalDebug) {
184
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        		    }
160 186
         		    break;
161 187
         		}
162 188
         	    }
@@ -164,14 +190,20 @@  discard block
 block discarded – undo
164 190
         		$airport_icao = $closestAirports[0]['icao'];
165 191
         		$airport_time = $this->all_flights[$key]['datetime'];
166 192
         	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
193
+        		if ($globalDebug) {
194
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
195
+        		}
168 196
         	}
169 197
     	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
198
+    		    if ($globalDebug) {
199
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
200
+    		    }
171 201
     	    }
172 202
 
173 203
         } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
204
+        	if ($globalDebug) {
205
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
206
+        	}
175 207
         }
176 208
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177 209
     }
@@ -181,12 +213,16 @@  discard block
 block discarded – undo
181 213
     public function del() {
182 214
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 215
 	// Delete old infos
184
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
216
+	if ($globalDebug) {
217
+		echo 'Delete old values and update latest data...'."\n";
218
+	}
185 219
 	foreach ($this->all_flights as $key => $flight) {
186 220
     	    if (isset($flight['lastupdate'])) {
187 221
         	if ($flight['lastupdate'] < (time()-3000)) {
188 222
             	    if (isset($this->all_flights[$key]['id'])) {
189
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
223
+            		if ($globalDebug) {
224
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
225
+            		}
190 226
 			/*
191 227
 			$SpotterLive = new SpotterLive();
192 228
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -197,7 +233,9 @@  discard block
 block discarded – undo
197 233
             		    $Spotter = new Spotter($this->db);
198 234
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199 235
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
200
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
236
+				if ($globalDebug && $result != 'success') {
237
+					echo '!!! ERROR : '.$result."\n";
238
+				}
201 239
 			    }
202 240
 			// Put in archive
203 241
 //				$Spotter->db = null;
@@ -212,8 +250,10 @@  discard block
 block discarded – undo
212 250
     public function add($line) {
213 251
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB;
214 252
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
215
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
216
-/*
253
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
254
+		$globalCoordMinChange = '0.02';
255
+	}
256
+	/*
217 257
 	$Spotter = new Spotter();
218 258
 	$dbc = $Spotter->db;
219 259
 	$SpotterLive = new SpotterLive($dbc);
@@ -241,11 +281,15 @@  discard block
 block discarded – undo
241 281
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
242 282
 		    $current_date = date('Y-m-d');
243 283
 		    $source = $line['source_name'];
244
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
284
+		    if ($source == '' || $line['format_source'] == 'aprs') {
285
+		    	$source = $line['format_source'];
286
+		    }
245 287
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
246 288
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
247 289
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
290
+		    } else {
291
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
292
+		    }
249 293
 		}
250 294
 		
251 295
 		/*
@@ -261,22 +305,35 @@  discard block
 block discarded – undo
261 305
 		//$this->db = $dbc;
262 306
 
263 307
 		//$hex = trim($line['hex']);
264
-	        if (!isset($line['id'])) $id = trim($line['hex']);
265
-	        else $id = trim($line['id']);
308
+	        if (!isset($line['id'])) {
309
+	        	$id = trim($line['hex']);
310
+	        } else {
311
+	        	$id = trim($line['id']);
312
+	        }
266 313
 		
267 314
 		if (!isset($this->all_flights[$id])) {
268 315
 		    $this->all_flights[$id] = array();
269 316
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270 317
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
318
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
319
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
320
+		    }
272 321
 		    if (!isset($line['id'])) {
273
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
322
+			if (!isset($globalDaemon)) {
323
+				$globalDaemon = TRUE;
324
+			}
325
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
275 326
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
276
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
327
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
328
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
329
+			}
277 330
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
331
+		     } else {
332
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
333
+		     }
334
+		    if ($globalAllFlights !== FALSE) {
335
+		    	$dataFound = true;
336
+		    }
280 337
 		}
281 338
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282 339
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -298,17 +355,27 @@  discard block
 block discarded – undo
298 355
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299 356
 			    }
300 357
 			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
358
+			    if ($globalDebugTimeElapsed) {
359
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+			    }
361
+			    if ($aircraft_icao != '') {
362
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
363
+			    }
303 364
 			}
304 365
 		    }
305
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
306
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
366
+		    if ($globalAllFlights !== FALSE) {
367
+		    	$dataFound = true;
368
+		    }
369
+		    if ($globalDebug) {
370
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
371
+		    }
307 372
 		}
308 373
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309 374
 			$icao = $line['aircraft_icao'];
310 375
 			$Spotter = new Spotter($this->db);
311
-			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
376
+			if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
377
+				$icao = $Spotter->aircraft_correct_icaotype[$icao];
378
+			}
312 379
 			$Spotter->db = null;
313 380
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
314 381
 		}
@@ -318,15 +385,24 @@  discard block
 block discarded – undo
318 385
 				$Spotter = new Spotter($this->db);
319 386
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
320 387
 				$Spotter->db = null;
321
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
388
+				if ($aircraft_icao != '') {
389
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
390
+				}
322 391
 			}
323 392
 		}
324 393
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
325
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
326
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
327
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
328
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
329
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
394
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
395
+				$aircraft_icao = 'GLID';
396
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
397
+				$aircraft_icao = 'UHEL';
398
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
399
+				$aircraft_icao = 'TOWPLANE';
400
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
401
+				$aircraft_icao = 'POWAIRC';
402
+			}
403
+			if (isset($aircraft_icao)) {
404
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
405
+			}
330 406
 		}
331 407
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
332 408
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -336,8 +412,11 @@  discard block
 block discarded – undo
336 412
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
337 413
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
338 414
 		    } else {
339
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
340
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
415
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
416
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
417
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
418
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
419
+				}
341 420
 				/*
342 421
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
343 422
 				print_r($this->all_flights[$id]);
@@ -346,9 +425,13 @@  discard block
 block discarded – undo
346 425
 				return '';
347 426
 		    }
348 427
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
349
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
428
+			if ($globalDebug) {
429
+				echo "!!! Date is too old ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
430
+			}
350 431
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
351
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
432
+			if ($globalDebug) {
433
+				echo "!!! Date is in the future ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
434
+			}
352 435
 		} elseif (!isset($line['datetime'])) {
353 436
 			date_default_timezone_set('UTC');
354 437
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -374,15 +457,25 @@  discard block
 block discarded – undo
374 457
 			    $timeelapsed = microtime(true);
375 458
             		    $Spotter = new Spotter($this->db);
376 459
             		    $fromsource = NULL;
377
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
378
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
379
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
380
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
381
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
460
+            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
461
+            		    	$fromsource = $globalAirlinesSource;
462
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
463
+            		    	$fromsource = 'vatsim';
464
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
465
+			    	$fromsource = 'ivao';
466
+			    } elseif (isset($globalVATSIM) && $globalVATSIM) {
467
+			    	$fromsource = 'vatsim';
468
+			    } elseif (isset($globalIVAO) && $globalIVAO) {
469
+			    	$fromsource = 'ivao';
470
+			    }
382 471
             		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
383
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
472
+			    if ($globalDebug && $result != 'success') {
473
+			    	echo '!!! ERROR : '.$result."\n";
474
+			    }
384 475
 			    $Spotter->db = null;
385
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
476
+			    if ($globalDebugTimeElapsed) {
477
+			    	echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
478
+			    }
386 479
 			}
387 480
 		    }
388 481
 
@@ -394,7 +487,9 @@  discard block
 block discarded – undo
394 487
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
395 488
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
396 489
   */
397
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
490
+		    if (!isset($this->all_flights[$id]['id'])) {
491
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
492
+		    }
398 493
 
399 494
 		    //$putinarchive = true;
400 495
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -412,7 +507,9 @@  discard block
 block discarded – undo
412 507
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
413 508
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
414 509
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
415
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
510
+				if ($globalDebugTimeElapsed) {
511
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
512
+				}
416 513
                         }
417 514
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
418 515
 			$timeelapsed = microtime(true);
@@ -426,7 +523,9 @@  discard block
 block discarded – undo
426 523
 				$Translation->db = null;
427 524
 			    }
428 525
 			    $Spotter->db = null;
429
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
526
+			    if ($globalDebugTimeElapsed) {
527
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
528
+			    }
430 529
                     	}
431 530
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
432 531
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -435,9 +534,13 @@  discard block
 block discarded – undo
435 534
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
436 535
 		    	    }
437 536
 			}
438
-			if (!isset($globalFork)) $globalFork = TRUE;
537
+			if (!isset($globalFork)) {
538
+				$globalFork = TRUE;
539
+			}
439 540
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
440
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
541
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
542
+					$this->get_Schedule($id,trim($line['ident']));
543
+				}
441 544
 			}
442 545
 		    }
443 546
 		}
@@ -453,16 +556,23 @@  discard block
 block discarded – undo
453 556
 		    // use datetime
454 557
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
455 558
 			$speed = $speed*3.6;
456
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
457
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
559
+			if ($speed < 1000) {
560
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
561
+			}
562
+  			if ($globalDebug) {
563
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
564
+  			}
458 565
 		    }
459 566
 		}
460 567
 
461 568
 
462 569
 
463 570
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
464
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
465
-	    	    else unset($timediff);
571
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
572
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
573
+	    	    } else {
574
+	    	    	unset($timediff);
575
+	    	    }
466 576
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
467 577
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
468 578
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -471,15 +581,23 @@  discard block
 block discarded – undo
471 581
 				$this->all_flights[$id]['putinarchive'] = true;
472 582
 				$this->tmd = 0;
473 583
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
474
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
584
+				    if ($globalDebug) {
585
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
586
+				    }
475 587
 				    $timeelapsed = microtime(true);
476 588
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
477 589
 					$Spotter = new Spotter($this->db);
478 590
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
479
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
591
+					if (!empty($all_country)) {
592
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
593
+					}
480 594
 					$Spotter->db = null;
481
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
482
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
595
+					if ($globalDebugTimeElapsed) {
596
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
597
+					}
598
+					if ($globalDebug) {
599
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
600
+					}
483 601
 				    }
484 602
 				}
485 603
 			    }
@@ -487,7 +605,9 @@  discard block
 block discarded – undo
487 605
 
488 606
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
489 607
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
490
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
608
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
609
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
610
+				}
491 611
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
492 612
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
493 613
 				    $dataFound = true;
@@ -509,9 +629,13 @@  discard block
 block discarded – undo
509 629
 			    */
510 630
 			}
511 631
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
512
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
632
+			    if ($line['longitude'] > 180) {
633
+			    	$line['longitude'] = $line['longitude'] - 360;
634
+			    }
513 635
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
514
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
636
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
637
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
638
+				}
515 639
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
516 640
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
517 641
 				    $dataFound = true;
@@ -542,7 +666,9 @@  discard block
 block discarded – undo
542 666
 		    }
543 667
 		}
544 668
 		if (isset($line['last_update']) && $line['last_update'] != '') {
545
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
669
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
670
+		    	$dataFound = true;
671
+		    }
546 672
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
547 673
 		}
548 674
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -564,41 +690,61 @@  discard block
 block discarded – undo
564 690
 			// Here we force archive of flight because after ground it's a new one (or should be)
565 691
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
566 692
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
567
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
568
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
569
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
693
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
694
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
695
+			} elseif (isset($line['id'])) {
696
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
697
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
698
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
699
+			}
700
+		    }
701
+		    if ($line['ground'] != 1) {
702
+		    	$line['ground'] = 0;
570 703
 		    }
571
-		    if ($line['ground'] != 1) $line['ground'] = 0;
572 704
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
573 705
 		    //$dataFound = true;
574 706
 		}
575 707
 		if (isset($line['squawk']) && $line['squawk'] != '') {
576 708
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
577
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
709
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
710
+			    	$this->all_flights[$id]['putinarchive'] = true;
711
+			    }
578 712
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
579 713
 			    $highlight = '';
580
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
581
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
582
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
714
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
715
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
716
+			    }
717
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
718
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
719
+			    }
720
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
721
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
722
+			    }
583 723
 			    if ($highlight != '') {
584 724
 				$timeelapsed = microtime(true);
585 725
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
586 726
 				    $Spotter = new Spotter($this->db);
587 727
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
588 728
 				    $Spotter->db = null;
589
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
729
+				    if ($globalDebugTimeElapsed) {
730
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
731
+				    }
590 732
 				}
591 733
 				//$putinarchive = true;
592 734
 				//$highlight = '';
593 735
 			    }
594 736
 			    
595
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
737
+		    } else {
738
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
739
+		    }
596 740
 		    //$dataFound = true;
597 741
 		}
598 742
 
599 743
 		if (isset($line['altitude']) && $line['altitude'] != '') {
600 744
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
601
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
745
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
746
+				$this->all_flights[$id]['putinarchive'] = true;
747
+			}
602 748
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
603 749
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
604 750
 			//$dataFound = true;
@@ -610,21 +756,30 @@  discard block
 block discarded – undo
610 756
 		}
611 757
 		
612 758
 		if (isset($line['heading']) && $line['heading'] != '') {
613
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
759
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
760
+		    	$this->all_flights[$id]['putinarchive'] = true;
761
+		    }
614 762
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
615 763
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
616 764
 		    //$dataFound = true;
617 765
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
618 766
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
619 767
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
620
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
621
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
768
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
769
+		    	$this->all_flights[$id]['putinarchive'] = true;
770
+		    }
771
+  		    if ($globalDebug) {
772
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
773
+  		    }
622 774
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
623 775
   		    // If not enough messages and ACARS set heading to 0
624 776
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
625 777
   		}
626
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
627
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
778
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
779
+			$dataFound = false;
780
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
781
+			$dataFound = false;
782
+		}
628 783
 
629 784
 //		print_r($this->all_flights[$id]);
630 785
 		//gets the callsign from the last hour
@@ -640,23 +795,38 @@  discard block
 block discarded – undo
640 795
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
641 796
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
642 797
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
643
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
798
+				    if ($globalDebug) {
799
+				    	echo "Check if aircraft is already in DB...";
800
+				    }
644 801
 				    $timeelapsed = microtime(true);
645 802
 				    $SpotterLive = new SpotterLive($this->db);
646 803
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
647 804
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
648
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
805
+					if ($globalDebugTimeElapsed) {
806
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
807
+					}
649 808
 				    } elseif (isset($line['id'])) {
650 809
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
651
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
810
+					if ($globalDebugTimeElapsed) {
811
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
812
+					}
652 813
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
653 814
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
654
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
655
-				    } else $recent_ident = '';
815
+					if ($globalDebugTimeElapsed) {
816
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
817
+					}
818
+				    } else {
819
+				    	$recent_ident = '';
820
+				    }
656 821
 				    $SpotterLive->db=null;
657
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
658
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
659
-				} else $recent_ident = '';
822
+				    if ($globalDebug && $recent_ident == '') {
823
+				    	echo " Not in DB.\n";
824
+				    } elseif ($globalDebug && $recent_ident != '') {
825
+				    	echo " Already in DB.\n";
826
+				    }
827
+				} else {
828
+					$recent_ident = '';
829
+				}
660 830
 			    } else {
661 831
 				$recent_ident = '';
662 832
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -664,7 +834,9 @@  discard block
 block discarded – undo
664 834
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
665 835
 			    if($recent_ident == "")
666 836
 			    {
667
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
837
+				if ($globalDebug) {
838
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
839
+				}
668 840
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
669 841
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
670 842
 				//adds the spotter data for the archive
@@ -708,31 +880,49 @@  discard block
 block discarded – undo
708 880
 				
709 881
 				if (!$ignoreImport) {
710 882
 				    $highlight = '';
711
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
712
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
713
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
714
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
883
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
884
+				    	$highlight = 'Squawk 7500 : Hijack';
885
+				    }
886
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
887
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
888
+				    }
889
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
890
+				    	$highlight = 'Squawk 7700 : Emergency';
891
+				    }
892
+				    if (!isset($this->all_flights[$id]['id'])) {
893
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
894
+				    }
715 895
 				    $timeelapsed = microtime(true);
716 896
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
717 897
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
718 898
 					    $Spotter = new Spotter($this->db);
719 899
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
720 900
 					    $Spotter->db = null;
721
-					    if ($globalDebug && isset($result)) echo $result."\n";
901
+					    if ($globalDebug && isset($result)) {
902
+					    	echo $result."\n";
903
+					    }
722 904
 					}
723 905
 				    }
724
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
906
+				    if ($globalDebugTimeElapsed) {
907
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
908
+				    }
725 909
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
726 910
 
727 911
 				    // Add source stat in DB
728 912
 				    $Stats = new Stats($this->db);
729 913
 				    if (!empty($this->stats)) {
730
-					if ($globalDebug) echo 'Add source stats : ';
914
+					if ($globalDebug) {
915
+						echo 'Add source stats : ';
916
+					}
731 917
 				        foreach($this->stats as $date => $data) {
732 918
 					    foreach($data as $source => $sourced) {
733 919
 					        //print_r($sourced);
734
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
735
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
920
+				    	        if (isset($sourced['polar'])) {
921
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
922
+				    	        }
923
+				    	        if (isset($sourced['hist'])) {
924
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
925
+				    	        }
736 926
 				    		if (isset($sourced['msg'])) {
737 927
 				    		    if (time() - $sourced['msg']['date'] > 10) {
738 928
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -745,13 +935,17 @@  discard block
 block discarded – undo
745 935
 			    			unset($this->stats[$date]);
746 936
 			    		    }
747 937
 				    	}
748
-				    	if ($globalDebug) echo 'Done'."\n";
938
+				    	if ($globalDebug) {
939
+				    		echo 'Done'."\n";
940
+				    	}
749 941
 
750 942
 				    }
751 943
 				    $Stats->db = null;
752 944
 				    }
753 945
 				    $this->del();
754
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
946
+				} elseif ($globalDebug) {
947
+					echo 'Ignore data'."\n";
948
+				}
755 949
 				//$ignoreImport = false;
756 950
 				$this->all_flights[$id]['addedSpotter'] = 1;
757 951
 				//print_r($this->all_flights[$id]);
@@ -768,7 +962,9 @@  discard block
 block discarded – undo
768 962
 			*/
769 963
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
770 964
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
771
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
965
+				    if ($globalDebug) {
966
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
967
+				    }
772 968
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
773 969
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
774 970
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -777,7 +973,9 @@  discard block
 block discarded – undo
777 973
 					    $SpotterLive->db=null;
778 974
 					}
779 975
 				    }
780
-				    if ($globalDebug) echo " Done\n";
976
+				    if ($globalDebug) {
977
+				    	echo " Done\n";
978
+				    }
781 979
 				    $this->last_delete = time();
782 980
 				}
783 981
 			    } else {
@@ -804,11 +1002,17 @@  discard block
 block discarded – undo
804 1002
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
805 1003
 		    if ($globalDebug) {
806 1004
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
807
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
808
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1005
+				if (isset($this->all_flights[$id]['source_name'])) {
1006
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
1007
+				} else {
1008
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1009
+				}
809 1010
 			} else {
810
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
811
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1011
+				if (isset($this->all_flights[$id]['source_name'])) {
1012
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1013
+				} else {
1014
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1015
+				}
812 1016
 			}
813 1017
 		    }
814 1018
 		    $ignoreImport = false;
@@ -854,22 +1058,30 @@  discard block
 block discarded – undo
854 1058
 
855 1059
 		    if (!$ignoreImport) {
856 1060
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
857
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1061
+				if (!isset($this->all_flights[$id]['id'])) {
1062
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1063
+				}
858 1064
 				$timeelapsed = microtime(true);
859 1065
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
860 1066
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
861
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1067
+					if ($globalDebug) {
1068
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1069
+					}
862 1070
 					$SpotterLive = new SpotterLive($this->db);
863 1071
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
864 1072
 					$SpotterLive->db = null;
865
-					if ($globalDebug) echo $result."\n";
1073
+					if ($globalDebug) {
1074
+						echo $result."\n";
1075
+					}
866 1076
 				    }
867 1077
 				}
868 1078
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
869 1079
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
870 1080
 				}
871 1081
 				$this->all_flights[$id]['putinarchive'] = false;
872
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1082
+				if ($globalDebugTimeElapsed) {
1083
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1084
+				}
873 1085
 
874 1086
 				// Put statistics in $this->stats variable
875 1087
 				//if ($line['format_source'] != 'aprs') {
@@ -877,7 +1089,9 @@  discard block
 block discarded – undo
877 1089
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
878 1090
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
879 1091
 					$source = $this->all_flights[$id]['source_name'];
880
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1092
+					if ($source == '') {
1093
+						$source = $this->all_flights[$id]['format_source'];
1094
+					}
881 1095
 					if (!isset($this->source_location[$source])) {
882 1096
 						$Location = new Source();
883 1097
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -898,7 +1112,9 @@  discard block
 block discarded – undo
898 1112
 					$stats_heading = round($stats_heading/22.5);
899 1113
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
900 1114
 					$current_date = date('Y-m-d');
901
-					if ($stats_heading == 16) $stats_heading = 0;
1115
+					if ($stats_heading == 16) {
1116
+						$stats_heading = 0;
1117
+					}
902 1118
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
903 1119
 						for ($i=0;$i<=15;$i++) {
904 1120
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -916,7 +1132,9 @@  discard block
 block discarded – undo
916 1132
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
917 1133
 						    end($this->stats[$current_date][$source]['hist']);
918 1134
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
919
-						} else $mini = 0;
1135
+						} else {
1136
+							$mini = 0;
1137
+						}
920 1138
 						for ($i=$mini;$i<=$distance;$i+=10) {
921 1139
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
922 1140
 						}
@@ -928,19 +1146,27 @@  discard block
 block discarded – undo
928 1146
 				}
929 1147
 
930 1148
 				$this->all_flights[$id]['lastupdate'] = time();
931
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1149
+				if ($this->all_flights[$id]['putinarchive']) {
1150
+					$send = true;
1151
+				}
932 1152
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
933
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1153
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1154
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1155
+			}
934 1156
 			//$this->del();
935 1157
 			
936 1158
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
937 1159
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
938
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1160
+				if ($globalDebug) {
1161
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1162
+				}
939 1163
 				$SpotterLive = new SpotterLive($this->db);
940 1164
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
941 1165
 				$SpotterLive->db = null;
942 1166
 				//SpotterLive->deleteLiveSpotterData();
943
-				if ($globalDebug) echo " Done\n";
1167
+				if ($globalDebug) {
1168
+					echo " Done\n";
1169
+				}
944 1170
 				$this->last_delete_hourly = time();
945 1171
 			    } else {
946 1172
 				$this->del();
@@ -952,7 +1178,9 @@  discard block
 block discarded – undo
952 1178
 		    //$ignoreImport = false;
953 1179
 		}
954 1180
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
955
-		if ($send) return $this->all_flights[$id];
1181
+		if ($send) {
1182
+			return $this->all_flights[$id];
1183
+		}
956 1184
 	    }
957 1185
 	}
958 1186
     }
Please login to merge, or discard this patch.