Completed
Push — master ( c396ef...4342b6 )
by Yannick
34:34
created
require/class.Accident.php 1 patch
Braces   +87 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
 	public function __construct($dbc = null) {
21 21
 		$Connection = new Connection($dbc);
22 22
 		$this->db = $Connection->db();
23
-		if ($this->db === null) die('Error: No DB connection. (Accident)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Accident)');
25
+		}
24 26
 	}
25 27
 
26 28
 	/*
@@ -126,8 +128,11 @@  discard block
 block discarded – undo
126 128
 				$data = array();
127 129
 				if ($row['registration'] != '') {
128 130
 					$image_array = $Image->getSpotterImage($row['registration']);
129
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
130
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
131
+					if (count($image_array) > 0) {
132
+						$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
133
+					} else {
134
+						$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
135
+					}
131 136
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
132 137
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
133 138
 					if (!empty($aircraft_info)) {
@@ -143,17 +148,30 @@  discard block
 block discarded – undo
143 148
 						$data['aircraft_base'] = $owner_data['base'];
144 149
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
145 150
 					}
146
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
147
-				if ($row['registration'] == '') $row['registration'] = 'NA';
148
-				if ($row['ident'] == '') $row['ident'] = 'NA';
151
+				} else {
152
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
153
+				}
154
+				if ($row['registration'] == '') {
155
+					$row['registration'] = 'NA';
156
+				}
157
+				if ($row['ident'] == '') {
158
+					$row['ident'] = 'NA';
159
+				}
149 160
 				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
150 161
 				if (isset($identicao[0])) {
151 162
 					if (substr($row['ident'],0,2) == 'AF') {
152
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
154
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
163
+						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
164
+							$icao = $row['ident'];
165
+						} else {
166
+							$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
167
+						}
168
+					} else {
169
+						$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
170
+					}
155 171
 					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
156
-				} else $icao = $row['ident'];
172
+				} else {
173
+					$icao = $row['ident'];
174
+				}
157 175
 				$icao = $Translation->checkTranslation($icao,false);
158 176
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
159 177
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -168,10 +186,14 @@  discard block
 block discarded – undo
168 186
 					//else echo 'No data...'."\n";
169 187
 				}
170 188
 				$data = array_merge($row,$data);
171
-				if ($data['ident'] == null) $data['ident'] = $icao;
189
+				if ($data['ident'] == null) {
190
+					$data['ident'] = $icao;
191
+				}
172 192
 				if ($data['title'] == null) {
173 193
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
174
-				} else $data['message'] = strtolower($data['title']);
194
+				} else {
195
+					$data['message'] = strtolower($data['title']);
196
+				}
175 197
 				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
176 198
 				$date = $data['date'];
177 199
 				if (isset($ids[$date])) {
@@ -190,8 +212,9 @@  discard block
 block discarded – undo
190 212
 		if (isset($result)) {
191 213
 			$result[0]['query_number_rows'] = $i;
192 214
 			return $result;
215
+		} else {
216
+			return array();
193 217
 		}
194
-		else return array();
195 218
 	}
196 219
 
197 220
 	/*
@@ -238,7 +261,9 @@  discard block
 block discarded – undo
238 261
 	*/
239 262
 	public function import($file) {
240 263
 		global $globalDebug;
241
-		if ($globalDebug) echo 'Import '.$file."\n";
264
+		if ($globalDebug) {
265
+			echo 'Import '.$file."\n";
266
+		}
242 267
 		$result = array();
243 268
 		if (file_exists($file)) {
244 269
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -249,8 +274,11 @@  discard block
 block discarded – undo
249 274
 				}
250 275
 				fclose($handle);
251 276
 			}
252
-			if (!empty($result)) $this->add($result,true);
253
-			elseif ($globalDebug) echo 'Nothing to import';
277
+			if (!empty($result)) {
278
+				$this->add($result,true);
279
+			} elseif ($globalDebug) {
280
+				echo 'Nothing to import';
281
+			}
254 282
 		}
255 283
 	}
256 284
 
@@ -286,14 +314,23 @@  discard block
 block discarded – undo
286 314
 					}
287 315
 				}
288 316
 				fclose($handle);
289
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
290
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
317
+			} elseif ($globalDebug) {
318
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
319
+			}
320
+		} elseif ($globalDebug) {
321
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
322
+		}
291 323
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
292
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
324
+		if (empty($result) && $globalDebug) {
325
+			echo 'Nothing to update';
326
+		}
293 327
 		foreach ($result as $file => $md5) {
294 328
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
295
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
296
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
329
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
330
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
331
+			} elseif ($globalDebug) {
332
+				echo 'Download '.$file.' failed';
333
+			}
297 334
 		}
298 335
 	}
299 336
 
@@ -310,13 +347,17 @@  discard block
 block discarded – undo
310 347
 		$Image = new Image($this->db);
311 348
 		$Spotter = new Spotter($this->db);
312 349
 
313
-		if (empty($crash)) return false;
350
+		if (empty($crash)) {
351
+			return false;
352
+		}
314 353
 		if ($new === false) {
315 354
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
316 355
 			$sthd = $Connection->db->prepare($query_delete);
317 356
 			$sthd->execute(array(':source' => $crash[0]['source']));
318 357
 		}
319
-		if ($globalTransaction) $Connection->db->beginTransaction();
358
+		if ($globalTransaction) {
359
+			$Connection->db->beginTransaction();
360
+		}
320 361
 		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
321 362
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
322 363
 		$sth_check = $Connection->db->prepare($query_check);
@@ -331,7 +372,9 @@  discard block
 block discarded – undo
331 372
 					return $value === "" ? NULL : $value;
332 373
 				}, $cr);
333 374
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
334
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
375
+					if (strpos($cr['registration'],'-') === FALSE) {
376
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
377
+					}
335 378
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
336 379
 					$sth_check->execute($query_check_values);
337 380
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
@@ -342,13 +385,19 @@  discard block
 block discarded – undo
342 385
 							if ($globalAircraftImageFetch) {
343 386
 								$imgchk = $Image->getSpotterImage($cr['registration']);
344 387
 								if (empty($imgchk)) {
345
-									if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
388
+									if ($globalDebug) {
389
+										echo "\t".'Get image for '.$cr['registration'].'...';
390
+									}
346 391
 									$Image->addSpotterImage($cr['registration']);
347
-									if ($globalDebug) echo "\t".'Done'."\n";
392
+									if ($globalDebug) {
393
+										echo "\t".'Done'."\n";
394
+									}
348 395
 								}
349 396
 								// elseif ($globalDebug) echo 'Image already in DB'."\n";
350 397
 							}
351
-							if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
398
+							if ($cr['title'] == '') {
399
+								$cr['title'] = $cr['registration'].' '.$cr['type'];
400
+							}
352 401
 							$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
353 402
 						}
354 403
 					}
@@ -358,9 +407,13 @@  discard block
 block discarded – undo
358 407
 					$Connection->db->beginTransaction();
359 408
 				}
360 409
 			}
361
-			if ($globalTransaction) $Connection->db->commit();
410
+			if ($globalTransaction) {
411
+				$Connection->db->commit();
412
+			}
362 413
 		} catch(PDOException $e) {
363
-			if ($globalTransaction) $Connection->db->rollBack();
414
+			if ($globalTransaction) {
415
+				$Connection->db->rollBack();
416
+			}
364 417
 			echo $e->getMessage();
365 418
 		}
366 419
 		$sth_check->closeCursor();
@@ -403,8 +456,11 @@  discard block
 block discarded – undo
403 456
 			return "error : ".$e->getMessage();
404 457
 		}
405 458
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
406
-		if ($row['nb'] > 0) return false;
407
-		else return true;
459
+		if ($row['nb'] > 0) {
460
+			return false;
461
+		} else {
462
+			return true;
463
+		}
408 464
 	}
409 465
 
410 466
     /**
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +170 added lines, -57 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (SpotterLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (SpotterLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -129,8 +133,11 @@  discard block
 block discarded – undo
129 133
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
130 134
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
131 135
 		}
132
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
133
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
136
+		if ($filter_query_where == '' && $where) {
137
+			$filter_query_where = ' WHERE';
138
+		} elseif ($filter_query_where != '' && $and) {
139
+			$filter_query_where .= ' AND';
140
+		}
134 141
 		if ($filter_query_where != '') {
135 142
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
136 143
 		}
@@ -173,9 +180,13 @@  discard block
 block discarded – undo
173 180
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
174 181
 			}
175 182
 		}
176
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
183
+		if ($orderby_query == '') {
184
+			$orderby_query = ' ORDER BY date DESC';
185
+		}
177 186
 
178
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
187
+		if (!isset($globalLiveInterval)) {
188
+			$globalLiveInterval = '200';
189
+		}
179 190
 		if ($globalDBdriver == 'mysql') {
180 191
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
181 192
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -199,7 +210,9 @@  discard block
 block discarded – undo
199 210
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
200 211
 		date_default_timezone_set('UTC');
201 212
 		$filter_query = $this->getFilter($filter,true,true);
202
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
213
+		if (!isset($globalLiveInterval)) {
214
+			$globalLiveInterval = '200';
215
+		}
203 216
 		if ($globalDBdriver == 'mysql') {
204 217
 			if (isset($globalArchive) && $globalArchive === TRUE) {
205 218
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
@@ -263,14 +276,22 @@  discard block
 block discarded – undo
263 276
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
264 277
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
265 278
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
266
-			if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') $usecoord = true;
279
+			if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') {
280
+				$usecoord = true;
281
+			}
267 282
 		}
268 283
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
269 284
 		$filter_query = $this->getFilter($filter,true,true);
270 285
 
271
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
272
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
273
-		if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit;
286
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
287
+			$globalLiveInterval = '200';
288
+		}
289
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
290
+			$globalMap3DAircraftsLimit = '300';
291
+		}
292
+		if ($limit == 0 || $limit == '') {
293
+			$limit = $globalMap3DAircraftsLimit;
294
+		}
274 295
 		if ($globalDBdriver == 'mysql') {
275 296
 			if (isset($globalArchive) && $globalArchive === TRUE) {
276 297
 				/*
@@ -283,26 +304,42 @@  discard block
 block discarded – undo
283 304
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
284 305
 				//if ($limit > 0) $query .= " LIMIT ".$limit;
285 306
 				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
286
-				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
287
-				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
307
+				if ($usecoord) {
308
+					$query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
309
+				}
310
+				if ($id != '') {
311
+					$query .= "OR spotter_archive.flightaware_id = :id ";
312
+				}
288 313
 				$query .= "UNION
289 314
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
290 315
 				FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
291
-				if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
292
-				if ($id != '') $query .= " OR spotter_live.flightaware_id = :id";
316
+				if ($usecoord) {
317
+					$query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
318
+				}
319
+				if ($id != '') {
320
+					$query .= " OR spotter_live.flightaware_id = :id";
321
+				}
293 322
 				//if ($limit > 0) $query .= " LIMIT ".$limit;
294 323
 				$query .= ") AS spotter 
295 324
 				WHERE latitude <> '0' AND longitude <> '0' 
296 325
 				ORDER BY flightaware_id, date";
297
-				if ($limit > 0) $query .= " LIMIT ".$limit;
326
+				if ($limit > 0) {
327
+					$query .= " LIMIT ".$limit;
328
+				}
298 329
 			} else {
299 330
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
300 331
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
301
-				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
302
-				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
332
+				if ($usecoord) {
333
+					$query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
334
+				}
335
+				if ($id != '') {
336
+					$query .= "OR spotter_live.flightaware_id = :id ";
337
+				}
303 338
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
304 339
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
305
-				if ($limit > 0) $query .= " LIMIT ".$limit;
340
+				if ($limit > 0) {
341
+					$query .= " LIMIT ".$limit;
342
+				}
306 343
 			}
307 344
 		} else {
308 345
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -320,29 +357,47 @@  discard block
 block discarded – undo
320 357
 				    FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
321 358
 				//if ($limit > 0) $query .= " ORDER BY spotter_live.date ASC LIMIT ".$limit;
322 359
 				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
323
-				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
324
-				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
360
+				if ($usecoord) {
361
+					$query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
362
+				}
363
+				if ($id != '') {
364
+					$query .= "OR spotter_archive.flightaware_id = :id ";
365
+				}
325 366
 				$query .= "UNION
326 367
 				    SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
327 368
 				    FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
328
-				if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
329
-				if ($id != '') $query .= " OR spotter_live.flightaware_id = :id";
369
+				if ($usecoord) {
370
+					$query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
371
+				}
372
+				if ($id != '') {
373
+					$query .= " OR spotter_live.flightaware_id = :id";
374
+				}
330 375
 				//if ($limit > 0) $query .= " ORDER BY date ASC LIMIT ".$limit;
331 376
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
332 377
 				$query .= "ORDER BY flightaware_id, date";
333
-				if ($limit > 0) $query .= " LIMIT ".$limit;
378
+				if ($limit > 0) {
379
+					$query .= " LIMIT ".$limit;
380
+				}
334 381
 			} else {
335 382
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
336 383
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date ";
337
-				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
338
-				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
384
+				if ($usecoord) {
385
+					$query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
386
+				}
387
+				if ($id != '') {
388
+					$query .= "OR spotter_live.flightaware_id = :id ";
389
+				}
339 390
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
340 391
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
341
-				if ($limit > 0) $query .= " LIMIT ".$limit;
392
+				if ($limit > 0) {
393
+					$query .= " LIMIT ".$limit;
394
+				}
342 395
 			}
343 396
 		}
344 397
 		$query_values = array();
345
-		if ($id != '') $query_values = array(':id' => $id);
398
+		if ($id != '') {
399
+			$query_values = array(':id' => $id);
400
+		}
346 401
 		try {
347 402
 			$sth = $this->db->prepare($query);
348 403
 			$sth->execute($query_values);
@@ -369,9 +424,15 @@  discard block
 block discarded – undo
369 424
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
370 425
 		$filter_query = $this->getFilter($filter,true,true);
371 426
 
372
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
373
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
374
-		if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit;
427
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
428
+			$globalLiveInterval = '200';
429
+		}
430
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
431
+			$globalMap3DAircraftsLimit = '300';
432
+		}
433
+		if ($limit == 0 || $limit == '') {
434
+			$limit = $globalMap3DAircraftsLimit;
435
+		}
375 436
 		if ($globalDBdriver == 'mysql') {
376 437
 			if (isset($globalArchive) && $globalArchive === TRUE) {
377 438
 				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration 
@@ -382,13 +443,17 @@  discard block
 block discarded – undo
382 443
 				$query .= ") AS spotter 
383 444
 				WHERE latitude <> '0' AND longitude <> '0' 
384 445
 				ORDER BY flightaware_id, date";
385
-				if ($limit > 0) $query .= " LIMIT ".$limit;
446
+				if ($limit > 0) {
447
+					$query .= " LIMIT ".$limit;
448
+				}
386 449
 			} else {
387 450
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
388 451
 				FROM spotter_live'.$filter_query.' spotter_live.flightaware_id = :id ';
389 452
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
390 453
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
391
-				if ($limit > 0) $query .= " LIMIT ".$limit;
454
+				if ($limit > 0) {
455
+					$query .= " LIMIT ".$limit;
456
+				}
392 457
 			}
393 458
 		} else {
394 459
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -404,13 +469,17 @@  discard block
 block discarded – undo
404 469
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
405 470
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
406 471
 				$query .= "ORDER BY flightaware_id, date";
407
-				if ($limit > 0) $query .= " LIMIT ".$limit;
472
+				if ($limit > 0) {
473
+					$query .= " LIMIT ".$limit;
474
+				}
408 475
 			} else {
409 476
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
410 477
 				FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id ";
411 478
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
412 479
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
413
-				if ($limit > 0) $query .= " LIMIT ".$limit;
480
+				if ($limit > 0) {
481
+					$query .= " LIMIT ".$limit;
482
+				}
414 483
 			}
415 484
 		}
416 485
 		$query_values = array(':id' => $id);
@@ -436,7 +505,9 @@  discard block
 block discarded – undo
436 505
 		global $globalDBdriver, $globalLiveInterval;
437 506
 		$filter_query = $this->getFilter($filter,true,true);
438 507
 
439
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
508
+		if (!isset($globalLiveInterval)) {
509
+			$globalLiveInterval = '200';
510
+		}
440 511
 		if ($globalDBdriver == 'mysql') {
441 512
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
442 513
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -467,7 +538,9 @@  discard block
 block discarded – undo
467 538
 	{
468 539
 		global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit;
469 540
 		$Spotter = new Spotter($this->db);
470
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
541
+		if (!isset($globalLiveInterval)) {
542
+			$globalLiveInterval = '200';
543
+		}
471 544
 		$filter_query = $this->getFilter($filter);
472 545
 
473 546
 		if (is_array($coord)) {
@@ -475,7 +548,9 @@  discard block
 block discarded – undo
475 548
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
476 549
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
477 550
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
478
-		} else return array();
551
+		} else {
552
+			return array();
553
+		}
479 554
 		if ($globalDBdriver == 'mysql') {
480 555
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
481 556
 		} else {
@@ -500,7 +575,9 @@  discard block
 block discarded – undo
500 575
 	public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array())
501 576
 	{
502 577
 		global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit;
503
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
578
+		if (!isset($globalLiveInterval)) {
579
+			$globalLiveInterval = '200';
580
+		}
504 581
 		$filter_query = $this->getFilter($filter,true,true);
505 582
 
506 583
 		if (is_array($coord)) {
@@ -508,7 +585,9 @@  discard block
 block discarded – undo
508 585
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
509 586
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
510 587
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
511
-		} else return array();
588
+		} else {
589
+			return array();
590
+		}
512 591
 		if ($globalDBdriver == 'mysql') {
513 592
 			if (isset($globalArchive) && $globalArchive === TRUE) {
514 593
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
@@ -763,11 +842,15 @@  discard block
 block discarded – undo
763 842
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
764 843
 		if ($globalDBdriver == 'mysql') {
765 844
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
766
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
845
+			if ($liveinterval) {
846
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
847
+			}
767 848
 			$query .= ' ORDER BY date';
768 849
 		} else {
769 850
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
770
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
851
+			if ($liveinterval) {
852
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
853
+			}
771 854
 			$query .= ' ORDER BY date';
772 855
 		}
773 856
 
@@ -862,7 +945,9 @@  discard block
 block discarded – undo
862 945
 				$i++;
863 946
 				$j++;
864 947
 				if ($j == 30) {
865
-					if ($globalDebug) echo ".";
948
+					if ($globalDebug) {
949
+						echo ".";
950
+					}
866 951
 				    	try {
867 952
 						
868 953
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -1237,7 +1322,9 @@  discard block
 block discarded – undo
1237 1322
 			{
1238 1323
 				return false;
1239 1324
 			}
1240
-		} else return '';
1325
+		} else {
1326
+			return '';
1327
+		}
1241 1328
 
1242 1329
 		if ($longitude != '')
1243 1330
 		{
@@ -1245,7 +1332,9 @@  discard block
 block discarded – undo
1245 1332
 			{
1246 1333
 				return false;
1247 1334
 			}
1248
-		} else return '';
1335
+		} else {
1336
+			return '';
1337
+		}
1249 1338
 
1250 1339
 		if ($waypoints != '')
1251 1340
 		{
@@ -1261,14 +1350,18 @@  discard block
 block discarded – undo
1261 1350
 			{
1262 1351
 				return false;
1263 1352
 			}
1264
-		} else $altitude = 0;
1353
+		} else {
1354
+			$altitude = 0;
1355
+		}
1265 1356
 		if ($altitude_real != '')
1266 1357
 		{
1267 1358
 			if (!is_numeric($altitude_real))
1268 1359
 			{
1269 1360
 				return false;
1270 1361
 			}
1271
-		} else $altitude_real = 0;
1362
+		} else {
1363
+			$altitude_real = 0;
1364
+		}
1272 1365
 
1273 1366
 		if ($heading != '')
1274 1367
 		{
@@ -1276,7 +1369,9 @@  discard block
 block discarded – undo
1276 1369
 			{
1277 1370
 				return false;
1278 1371
 			}
1279
-		} else $heading = 0;
1372
+		} else {
1373
+			$heading = 0;
1374
+		}
1280 1375
 
1281 1376
 		if ($groundspeed != '')
1282 1377
 		{
@@ -1284,9 +1379,13 @@  discard block
 block discarded – undo
1284 1379
 			{
1285 1380
 				return false;
1286 1381
 			}
1287
-		} else $groundspeed = 0;
1382
+		} else {
1383
+			$groundspeed = 0;
1384
+		}
1288 1385
 		date_default_timezone_set('UTC');
1289
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1386
+		if ($date == '') {
1387
+			$date = date("Y-m-d H:i:s", time());
1388
+		}
1290 1389
 
1291 1390
         
1292 1391
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1331,14 +1430,24 @@  discard block
 block discarded – undo
1331 1430
 		$arrival_airport_country = '';
1332 1431
 		
1333 1432
             	
1334
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1335
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1336
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1337
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1433
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1434
+            		$squawk = NULL;
1435
+            	}
1436
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1437
+            		$verticalrate = NULL;
1438
+            	}
1439
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1440
+            		$groundspeed = 0;
1441
+            	}
1442
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1443
+            		$heading = 0;
1444
+            	}
1338 1445
 		
1339 1446
 		$query = '';
1340 1447
 		if ($globalArchive) {
1341
-			if ($globalDebug) echo '-- Delete previous data -- ';
1448
+			if ($globalDebug) {
1449
+				echo '-- Delete previous data -- ';
1450
+			}
1342 1451
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1343 1452
 		}
1344 1453
 
@@ -1355,10 +1464,14 @@  discard block
 block discarded – undo
1355 1464
 			return "error : ".$e->getMessage();
1356 1465
 		}
1357 1466
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1358
-		    if ($globalDebug) echo '(Add to Spotter archive : ';
1467
+		    if ($globalDebug) {
1468
+		    	echo '(Add to Spotter archive : ';
1469
+		    }
1359 1470
 		    $SpotterArchive = new SpotterArchive($this->db);
1360 1471
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1361
-		    if ($globalDebug) echo $result.')';
1472
+		    if ($globalDebug) {
1473
+		    	echo $result.')';
1474
+		    }
1362 1475
 		} elseif ($globalDebug && $putinarchive !== true) {
1363 1476
 			echo '(Not adding to archive)';
1364 1477
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
require/class.ACARS.php 1 patch
Braces   +415 added lines, -263 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null,$fromACARSscript = false) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection. (ACARS)');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection. (ACARS)');
29
+		}
28 30
 		if ($fromACARSscript) {
29 31
 			$this->fromACARSscript = true;
30 32
 			$this->SI = new SpotterImport($this->db);
@@ -39,14 +41,19 @@  discard block
 block discarded – undo
39 41
 	*/
40 42
 	public function ident2icao($ident) {
41 43
 		if (substr($ident,0,2) == 'AF') {
42
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
44
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
45
+				$icao = $ident;
46
+			} else {
47
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
48
+			}
44 49
 		} else {
45 50
 			$Spotter = new Spotter($this->db);
46 51
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
47 52
 			if (isset($identicao[0])) {
48 53
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
49
-			} else $icao = $ident;
54
+			} else {
55
+				$icao = $ident;
56
+			}
50 57
 		}
51 58
 		return $icao;
52 59
 	}
@@ -120,14 +127,24 @@  discard block
 block discarded – undo
120 127
 		$message = '';
121 128
 		$result = array();
122 129
 		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
123
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
124
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
125
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
130
+		if ($n == 0) {
131
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
132
+		}
133
+		if ($n == 0) {
134
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
135
+		}
136
+		if ($n == 0) {
137
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
138
+		}
126 139
 		if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) {
127 140
 			$registration = str_replace('.','',$registration);
128 141
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
129
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
130
-		} else $message = $data;
142
+			if ($globalDebug) {
143
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
144
+			}
145
+		} else {
146
+			$message = $data;
147
+		}
131 148
 		$decode = array();
132 149
 		$found = false;
133 150
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -147,12 +164,21 @@  discard block
 block discarded – undo
147 164
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
148 165
 					$latitude = $la / 10000.0;
149 166
 					$longitude = $ln / 10000.0;
150
-					if ($lac == 'S') $latitude = '-'.$latitude;
151
-					if ($lnc == 'W') $longitude = '-'.$longitude;
167
+					if ($lac == 'S') {
168
+						$latitude = '-'.$latitude;
169
+					}
170
+					if ($lnc == 'W') {
171
+						$longitude = '-'.$longitude;
172
+					}
152 173
 					// Temp not always available
153
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
154
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
155
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
174
+					if ($globalDebug) {
175
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
176
+					}
177
+					if ($temp == '') {
178
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
179
+					} else {
180
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
181
+					}
156 182
 
157 183
 					//$icao = $Translation->checkTranslation($ident);
158 184
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -166,25 +192,35 @@  discard block
 block discarded – undo
166 192
 				$ahour = '';
167 193
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
168 194
 				if ($n == 4 && strlen($darr) == 4) {
169
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
170
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
171
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
195
+					if ($dhour != '') {
196
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
197
+					}
198
+					if ($ahour != '') {
199
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
200
+					}
201
+					if ($globalDebug) {
202
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
203
+					}
172 204
 					//$icao = ACARS->ident2icao($ident);
173 205
 					//$icao = $Translation->checkTranslation($ident);
174 206
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
175 207
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
176 208
 					$found = true;
177
-				}
178
-				elseif ($n == 2 || $n  == 4) {
179
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
180
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
209
+				} elseif ($n == 2 || $n  == 4) {
210
+					if ($dhour != '') {
211
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
212
+					}
213
+					if ($globalDebug) {
214
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
215
+					}
181 216
 					//$icao = ACARS->ident2icao($ident);
182 217
 					//$icao = $Translation->checkTranslation($ident);
183 218
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
184 219
 					$found = true;
185
-				}
186
-				elseif ($n == 1) {
187
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
220
+				} elseif ($n == 1) {
221
+					if ($globalDebug) {
222
+						echo 'airport arrival : '.$darr."\n";
223
+					}
188 224
 					//$icao = ACARS->ident2icao($ident);
189 225
 					//$icao = $Translation->checkTranslation($ident);
190 226
 					$decode = array('Arrival airport' => $darr);
@@ -202,7 +238,9 @@  discard block
 block discarded – undo
202 238
 				$darr = '';
203 239
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
204 240
 				if ($n == 4) {
205
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
241
+					if ($globalDebug) {
242
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
243
+					}
206 244
 					//$icao = ACARS->ident2icao($ident);
207 245
 					//$icao = $Translation->checkTranslation($ident);
208 246
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -236,14 +274,23 @@  discard block
 block discarded – undo
236 274
 				$apiste = '';
237 275
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
238 276
 				if ($n > 8) {
239
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
240
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
241
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
277
+					if ($globalDebug) {
278
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
279
+					}
280
+					if ($dhour != '') {
281
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
282
+					}
283
+					if ($ahour != '') {
284
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
285
+					}
242 286
 					$icao = trim($aident);
243 287
 
244 288
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
245
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
246
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
289
+					if ($ahour == '') {
290
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
291
+					} else {
292
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
293
+					}
247 294
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
248 295
 					$decode['icao'] = $icao;
249 296
 					$found = true;
@@ -265,9 +312,15 @@  discard block
 block discarded – undo
265 312
 					$lns = $lns.'.'.$lns;
266 313
 					$latitude = $las / 1000.0;
267 314
 					$longitude = $lns / 1000.0;
268
-					if ($lac == 'S') $latitude = '-'.$latitude;
269
-					if ($lnc == 'W') $longitude = '-'.$longitude;
270
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
315
+					if ($lac == 'S') {
316
+						$latitude = '-'.$latitude;
317
+					}
318
+					if ($lnc == 'W') {
319
+						$longitude = '-'.$longitude;
320
+					}
321
+					if ($globalDebug) {
322
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
323
+					}
271 324
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
272 325
 					$found = true;
273 326
 				}
@@ -285,7 +338,9 @@  discard block
 block discarded – undo
285 338
 				$darr = '';
286 339
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
287 340
 				if ($n == 4) {
288
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
341
+					if ($globalDebug) {
342
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
343
+					}
289 344
 					//$icao = $Translation->checkTranslation($ident);
290 345
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
291 346
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -298,7 +353,9 @@  discard block
 block discarded – undo
298 353
 				$darr = '';
299 354
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
300 355
 				if ($n == 4) {
301
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
356
+					if ($globalDebug) {
357
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
358
+					}
302 359
 					//$icao = $Translation->checkTranslation($ident);
303 360
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
304 361
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -311,7 +368,9 @@  discard block
 block discarded – undo
311 368
 				$darr = '';
312 369
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
313 370
 				if ($n == 2) {
314
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
371
+					if ($globalDebug) {
372
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
373
+					}
315 374
 					//$icao = $Translation->checkTranslation($ident);
316 375
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
317 376
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -325,7 +384,9 @@  discard block
 block discarded – undo
325 384
 				$darr = '';
326 385
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
327 386
 				if ($n == 6) {
328
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
387
+					if ($globalDebug) {
388
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
389
+					}
329 390
 					//$icao = $Translation->checkTranslation($ident);
330 391
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
331 392
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -338,7 +399,9 @@  discard block
 block discarded – undo
338 399
 				$darr = '';
339 400
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
340 401
 				if ($n == 7) {
341
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
402
+					if ($globalDebug) {
403
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
404
+					}
342 405
 					//$icao = $Translation->checkTranslation($ident);
343 406
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
344 407
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -366,8 +429,12 @@  discard block
 block discarded – undo
366 429
 					$decode['icao'] = $icao;
367 430
 					$latitude = $las / 100.0;
368 431
 					$longitude = $lns / 100.0;
369
-					if ($lac == 'S') $latitude = '-'.$latitude;
370
-					if ($lnc == 'W') $longitude = '-'.$longitude;
432
+					if ($lac == 'S') {
433
+						$latitude = '-'.$latitude;
434
+					}
435
+					if ($lnc == 'W') {
436
+						$longitude = '-'.$longitude;
437
+					}
371 438
 
372 439
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
373 440
 					$found = true;
@@ -385,8 +452,12 @@  discard block
 block discarded – undo
385 452
 				if ($n == 4) {
386 453
 					$latitude = $las;
387 454
 					$longitude = $lns;
388
-					if ($lac == 'S') $latitude = '-'.$latitude;
389
-					if ($lnc == 'W') $longitude = '-'.$longitude;
455
+					if ($lac == 'S') {
456
+						$latitude = '-'.$latitude;
457
+					}
458
+					if ($lnc == 'W') {
459
+						$longitude = '-'.$longitude;
460
+					}
390 461
 
391 462
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
392 463
 					$found = true;
@@ -402,7 +473,9 @@  discard block
 block discarded – undo
402 473
 				$darr = '';
403 474
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
404 475
 				if ($n == 5) {
405
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
476
+					if ($globalDebug) {
477
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
478
+					}
406 479
 					//$icao = $Translation->checkTranslation($ident);
407 480
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
408 481
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -423,7 +496,9 @@  discard block
 block discarded – undo
423 496
 				$aident = '';
424 497
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
425 498
 				if ($n == 8) {
426
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
499
+					if ($globalDebug) {
500
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
501
+					}
427 502
 					$icao = trim($aident);
428 503
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
429 504
 					$decode['icao'] = $icao;
@@ -440,7 +515,9 @@  discard block
 block discarded – undo
440 515
 				$darr = '';
441 516
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
442 517
 				if ($n == 5) {
443
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
518
+					if ($globalDebug) {
519
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
520
+					}
444 521
 					//$icao = $Translation->checkTranslation($ident);
445 522
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
446 523
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -455,7 +532,9 @@  discard block
 block discarded – undo
455 532
 				$darr = '';
456 533
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
457 534
 				if ($n == 3) {
458
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
535
+					if ($globalDebug) {
536
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
537
+					}
459 538
 					//$icao = $Translation->checkTranslation($ident);
460 539
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
461 540
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -470,7 +549,9 @@  discard block
 block discarded – undo
470 549
 				$darr = '';
471 550
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
472 551
 				if ($n == 3) {
473
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
552
+					if ($globalDebug) {
553
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
554
+					}
474 555
 					//$icao = $Translation->checkTranslation($ident);
475 556
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
476 557
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -480,7 +561,9 @@  discard block
 block discarded – undo
480 561
 			if (!$found) {
481 562
 				$n = sscanf($message,'MET01%4c',$airport);
482 563
 				if ($n == 1) {
483
-					if ($globalDebug) echo 'airport name : '.$airport;
564
+					if ($globalDebug) {
565
+						echo 'airport name : '.$airport;
566
+					}
484 567
 					$decode = array('Airport/Waypoint name' => $airport);
485 568
 					$found = true;
486 569
 				}
@@ -488,184 +571,126 @@  discard block
 block discarded – undo
488 571
 			if ($label == 'H1') {
489 572
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
490 573
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
491
-				}
492
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
574
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
493 575
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
494
-				}
495
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
576
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
496 577
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
497
-				}
498
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
578
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
499 579
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
500
-				}
501
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
580
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
502 581
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
503
-				}
504
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
582
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
505 583
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
506
-				}
507
-				elseif (preg_match(':^#M1AAEP:',$message)) {
584
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
508 585
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
509
-				}
510
-				elseif (preg_match(':^#M2APWD:',$message)) {
586
+				} elseif (preg_match(':^#M2APWD:',$message)) {
511 587
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
512
-				}
513
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
588
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
514 589
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
515
-				}
516
-				elseif (preg_match(':^#CF:',$message)) {
590
+				} elseif (preg_match(':^#CF:',$message)) {
517 591
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
518
-				}
519
-				elseif (preg_match(':^#DF:',$message)) {
592
+				} elseif (preg_match(':^#DF:',$message)) {
520 593
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
521
-				}
522
-				elseif (preg_match(':^#EC:',$message)) {
594
+				} elseif (preg_match(':^#EC:',$message)) {
523 595
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
524
-				}
525
-				elseif (preg_match(':^#EI:',$message)) {
596
+				} elseif (preg_match(':^#EI:',$message)) {
526 597
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
527
-				}
528
-				elseif (preg_match(':^#H1:',$message)) {
598
+				} elseif (preg_match(':^#H1:',$message)) {
529 599
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
530
-				}
531
-				elseif (preg_match(':^#H2:',$message)) {
600
+				} elseif (preg_match(':^#H2:',$message)) {
532 601
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
533
-				}
534
-				elseif (preg_match(':^#HD:',$message)) {
602
+				} elseif (preg_match(':^#HD:',$message)) {
535 603
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
536
-				}
537
-				elseif (preg_match(':^#M1:',$message)) {
604
+				} elseif (preg_match(':^#M1:',$message)) {
538 605
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
539
-				}
540
-				elseif (preg_match(':^#M2:',$message)) {
606
+				} elseif (preg_match(':^#M2:',$message)) {
541 607
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
542
-				}
543
-				elseif (preg_match(':^#M3:',$message)) {
608
+				} elseif (preg_match(':^#M3:',$message)) {
544 609
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
545
-				}
546
-				elseif (preg_match(':^#MD:',$message)) {
610
+				} elseif (preg_match(':^#MD:',$message)) {
547 611
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
548
-				}
549
-				elseif (preg_match(':^#PS:',$message)) {
612
+				} elseif (preg_match(':^#PS:',$message)) {
550 613
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
551
-				}
552
-				elseif (preg_match(':^#S1:',$message)) {
614
+				} elseif (preg_match(':^#S1:',$message)) {
553 615
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
554
-				}
555
-				elseif (preg_match(':^#S2:',$message)) {
616
+				} elseif (preg_match(':^#S2:',$message)) {
556 617
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
557
-				}
558
-				elseif (preg_match(':^#SD:',$message)) {
618
+				} elseif (preg_match(':^#SD:',$message)) {
559 619
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
560
-				}
561
-				elseif (preg_match(':^#T[0-8]:',$message)) {
620
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
562 621
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
563
-				}
564
-				elseif (preg_match(':^#WO:',$message)) {
622
+				} elseif (preg_match(':^#WO:',$message)) {
565 623
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
566
-				}
567
-				elseif (preg_match(':^#A1:',$message)) {
624
+				} elseif (preg_match(':^#A1:',$message)) {
568 625
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
569
-				}
570
-				elseif (preg_match(':^#A3:',$message)) {
626
+				} elseif (preg_match(':^#A3:',$message)) {
571 627
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
572
-				}
573
-				elseif (preg_match(':^#A4:',$message)) {
628
+				} elseif (preg_match(':^#A4:',$message)) {
574 629
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
575
-				}
576
-				elseif (preg_match(':^#A6:',$message)) {
630
+				} elseif (preg_match(':^#A6:',$message)) {
577 631
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
578
-				}
579
-				elseif (preg_match(':^#A8:',$message)) {
632
+				} elseif (preg_match(':^#A8:',$message)) {
580 633
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
581
-				}
582
-				elseif (preg_match(':^#A9:',$message)) {
634
+				} elseif (preg_match(':^#A9:',$message)) {
583 635
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
584
-				}
585
-				elseif (preg_match(':^#A0:',$message)) {
636
+				} elseif (preg_match(':^#A0:',$message)) {
586 637
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
587
-				}
588
-				elseif (preg_match(':^#AA:',$message)) {
638
+				} elseif (preg_match(':^#AA:',$message)) {
589 639
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
590
-				}
591
-				elseif (preg_match(':^#AB:',$message)) {
640
+				} elseif (preg_match(':^#AB:',$message)) {
592 641
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
593
-				}
594
-				elseif (preg_match(':^#AC:',$message)) {
642
+				} elseif (preg_match(':^#AC:',$message)) {
595 643
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
596
-				}
597
-				elseif (preg_match(':^#AD:',$message)) {
644
+				} elseif (preg_match(':^#AD:',$message)) {
598 645
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
599
-				}
600
-				elseif (preg_match(':^#AF:',$message)) {
646
+				} elseif (preg_match(':^#AF:',$message)) {
601 647
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
602
-				}
603
-				elseif (preg_match(':^#B1:',$message)) {
648
+				} elseif (preg_match(':^#B1:',$message)) {
604 649
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
605
-				}
606
-				elseif (preg_match(':^#B2:',$message)) {
650
+				} elseif (preg_match(':^#B2:',$message)) {
607 651
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
608
-				}
609
-				elseif (preg_match(':^#B3:',$message)) {
652
+				} elseif (preg_match(':^#B3:',$message)) {
610 653
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
611
-				}
612
-				elseif (preg_match(':^#B4:',$message)) {
654
+				} elseif (preg_match(':^#B4:',$message)) {
613 655
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
614
-				}
615
-				elseif (preg_match(':^#B6:',$message)) {
656
+				} elseif (preg_match(':^#B6:',$message)) {
616 657
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
617
-				}
618
-				elseif (preg_match(':^#B8:',$message)) {
658
+				} elseif (preg_match(':^#B8:',$message)) {
619 659
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
620
-				}
621
-				elseif (preg_match(':^#B9:',$message)) {
660
+				} elseif (preg_match(':^#B9:',$message)) {
622 661
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
623
-				}
624
-				elseif (preg_match(':^#B0:',$message)) {
662
+				} elseif (preg_match(':^#B0:',$message)) {
625 663
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
626
-				}
627
-				elseif (preg_match(':^#BA:',$message)) {
664
+				} elseif (preg_match(':^#BA:',$message)) {
628 665
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
629
-				}
630
-				elseif (preg_match(':^#BB:',$message)) {
666
+				} elseif (preg_match(':^#BB:',$message)) {
631 667
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
632
-				}
633
-				elseif (preg_match(':^#BC:',$message)) {
668
+				} elseif (preg_match(':^#BC:',$message)) {
634 669
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
635
-				}
636
-				elseif (preg_match(':^#BD:',$message)) {
670
+				} elseif (preg_match(':^#BD:',$message)) {
637 671
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
638
-				}
639
-				elseif (preg_match(':^#BE:',$message)) {
672
+				} elseif (preg_match(':^#BE:',$message)) {
640 673
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
641
-				}
642
-				elseif (preg_match(':^#BF:',$message)) {
674
+				} elseif (preg_match(':^#BF:',$message)) {
643 675
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
644
-				}
645
-				elseif (preg_match(':^#H3:',$message)) {
676
+				} elseif (preg_match(':^#H3:',$message)) {
646 677
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
647 678
 				}
648 679
 			}
649 680
 			if ($label == '10') {
650 681
 				if (preg_match(':^DTO01:',$message)) {
651 682
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
652
-				}
653
-				elseif (preg_match(':^AIS01:',$message)) {
683
+				} elseif (preg_match(':^AIS01:',$message)) {
654 684
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
655
-				}
656
-				elseif (preg_match(':^FTX01:',$message)) {
685
+				} elseif (preg_match(':^FTX01:',$message)) {
657 686
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
658
-				}
659
-				elseif (preg_match(':^FPL01:',$message)) {
687
+				} elseif (preg_match(':^FPL01:',$message)) {
660 688
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
661
-				}
662
-				elseif (preg_match(':^WAB01:',$message)) {
689
+				} elseif (preg_match(':^WAB01:',$message)) {
663 690
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
664
-				}
665
-				elseif (preg_match(':^MET01:',$message)) {
691
+				} elseif (preg_match(':^MET01:',$message)) {
666 692
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
667
-				}
668
-				elseif (preg_match(':^WAB02:',$message)) {
693
+				} elseif (preg_match(':^WAB02:',$message)) {
669 694
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
670 695
 				}
671 696
 			}
@@ -680,38 +705,28 @@  discard block
 block discarded – undo
680 705
 					$vsta = array('Version' => $version);
681 706
 					if ($state == 'E') {
682 707
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
683
-					}
684
-					elseif ($state == 'L') {
708
+					} elseif ($state == 'L') {
685 709
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
686
-					}
687
-					else {
710
+					} else {
688 711
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
689 712
 					}
690 713
 					if ($type == 'V') {
691 714
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
692
-					}
693
-					elseif ($type == 'S') {
715
+					} elseif ($type == 'S') {
694 716
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
695
-					}
696
-					elseif ($type == 'H') {
717
+					} elseif ($type == 'H') {
697 718
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
698
-					}
699
-					elseif ($type == 'G') {
719
+					} elseif ($type == 'G') {
700 720
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
701
-					}
702
-					elseif ($type == 'C') {
721
+					} elseif ($type == 'C') {
703 722
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
704
-					}
705
-					elseif ($type == '2') {
723
+					} elseif ($type == '2') {
706 724
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
707
-					}
708
-					elseif ($type == 'X') {
725
+					} elseif ($type == 'X') {
709 726
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
710
-					}
711
-					elseif ($type == 'I') {
727
+					} elseif ($type == 'I') {
712 728
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
713
-					}
714
-					else {
729
+					} else {
715 730
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
716 731
 					}
717 732
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -720,7 +735,9 @@  discard block
 block discarded – undo
720 735
 			}
721 736
 
722 737
 			$title = $this->getTitlefromLabel($label);
723
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
738
+			if ($title != '') {
739
+				$decode = array_merge(array('Message title' => $title),$decode);
740
+			}
724 741
 			/*
725 742
 			// Business jets always use GS0001
726 743
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -756,31 +773,54 @@  discard block
 block discarded – undo
756 773
 			$msg = $message['message'];
757 774
 			$decode = $message['decode'];
758 775
 			$registration = (string)$message['registration'];
759
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
760
-			else $latitude = '';
761
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
762
-			else $longitude = '';
763
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
764
-			else $airicao = '';
765
-			if (isset($decode['icao'])) $icao = $decode['icao'];
766
-			else $icao = $Translation->checkTranslation($ident);
776
+			if (isset($decode['latitude'])) {
777
+				$latitude = $decode['latitude'];
778
+			} else {
779
+				$latitude = '';
780
+			}
781
+			if (isset($decode['longitude'])) {
782
+				$longitude = $decode['longitude'];
783
+			} else {
784
+				$longitude = '';
785
+			}
786
+			if (isset($decode['airicao'])) {
787
+				$airicao = $decode['airicao'];
788
+			} else {
789
+				$airicao = '';
790
+			}
791
+			if (isset($decode['icao'])) {
792
+				$icao = $decode['icao'];
793
+			} else {
794
+				$icao = $Translation->checkTranslation($ident);
795
+			}
767 796
 			$image_array = $Image->getSpotterImage($registration);
768 797
 			if (!isset($image_array[0]['registration'])) {
769 798
 				$Image->addSpotterImage($registration);
770 799
 			}
771 800
 			// Business jets always use GS0001
772
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
773
-			if ($globalDebug && isset($info) && $info != '') echo $info;
774
-			if (count($decode) > 0) $decode_json = json_encode($decode);
775
-			else $decode_json = '';
801
+			if ($ident != 'GS0001') {
802
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
803
+			}
804
+			if ($globalDebug && isset($info) && $info != '') {
805
+				echo $info;
806
+			}
807
+			if (count($decode) > 0) {
808
+				$decode_json = json_encode($decode);
809
+			} else {
810
+				$decode_json = '';
811
+			}
776 812
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
777 813
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
778 814
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
779 815
 				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
780 816
 			}
781 817
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
782
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
783
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
818
+			if (!isset($globalACARSArchive)) {
819
+				$globalACARSArchive = array('10','80','81','82','3F');
820
+			}
821
+			if ($result && in_array($label,$globalACARSArchive)) {
822
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
823
+			}
784 824
 			if ($globalDebug && count($decode) > 0) {
785 825
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
786 826
 			}
@@ -805,7 +845,9 @@  discard block
 block discarded – undo
805 845
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
806 846
 			$Connection = new Connection($this->db);
807 847
 			$this->db = $Connection->db;
808
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
848
+			if ($globalDebug) {
849
+				echo "Test if not already in Live ACARS table...";
850
+			}
809 851
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
810 852
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
811 853
 			try {
@@ -816,7 +858,9 @@  discard block
 block discarded – undo
816 858
 				return false;
817 859
 			}
818 860
 			if ($stht->fetchColumn() == 0) {
819
-				if ($globalDebug) echo "Add Live ACARS data...";
861
+				if ($globalDebug) {
862
+					echo "Add Live ACARS data...";
863
+				}
820 864
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
821 865
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
822 866
 				try {
@@ -827,10 +871,14 @@  discard block
 block discarded – undo
827 871
 					return false;
828 872
 				}
829 873
 			} else {
830
-				if ($globalDebug) echo "Data already in DB...\n";
874
+				if ($globalDebug) {
875
+					echo "Data already in DB...\n";
876
+				}
831 877
 				return false;
832 878
 			}
833
-			if ($globalDebug) echo "Done\n";
879
+			if ($globalDebug) {
880
+				echo "Done\n";
881
+			}
834 882
 			return true;
835 883
 		}
836 884
 		return false;
@@ -864,7 +912,9 @@  discard block
 block discarded – undo
864 912
 			    	    }
865 913
 				    if ($stht->fetchColumn() == 0) {
866 914
 			*/
867
-			if ($globalDebug) echo "Add Live ACARS data...";
915
+			if ($globalDebug) {
916
+				echo "Add Live ACARS data...";
917
+			}
868 918
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
869 919
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
870 920
 			try {
@@ -873,7 +923,9 @@  discard block
 block discarded – undo
873 923
 			} catch(PDOException $e) {
874 924
 				return "error : ".$e->getMessage();
875 925
 			}
876
-			if ($globalDebug) echo "Done\n";
926
+			if ($globalDebug) {
927
+				echo "Done\n";
928
+			}
877 929
 		}
878 930
 		return '';
879 931
 	}
@@ -897,8 +949,11 @@  discard block
 block discarded – undo
897 949
 			return '';
898 950
 		}
899 951
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
900
-		if (count($row) > 0) return $row[0]['title'];
901
-		else return '';
952
+		if (count($row) > 0) {
953
+			return $row[0]['title'];
954
+		} else {
955
+			return '';
956
+		}
902 957
 	}
903 958
 
904 959
 	/**
@@ -917,8 +972,11 @@  discard block
 block discarded – undo
917 972
 			return array();
918 973
 		}
919 974
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
920
-		if (count($row) > 0) return $row;
921
-		else return array();
975
+		if (count($row) > 0) {
976
+			return $row;
977
+		} else {
978
+			return array();
979
+		}
922 980
 	}
923 981
 
924 982
 	/**
@@ -938,8 +996,11 @@  discard block
 block discarded – undo
938 996
 			return array();
939 997
 		}
940 998
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
941
-		if (count($row) > 0) return $row[0];
942
-		else return array();
999
+		if (count($row) > 0) {
1000
+			return $row[0];
1001
+		} else {
1002
+			return array();
1003
+		}
943 1004
 	}
944 1005
 
945 1006
     /**
@@ -987,19 +1048,35 @@  discard block
 block discarded – undo
987 1048
 			if ($row['registration'] != '') {
988 1049
 				$row['registration'] = str_replace('.','',$row['registration']);
989 1050
 				$image_array = $Image->getSpotterImage($row['registration']);
990
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
991
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
992
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
-			if ($row['registration'] == '') $row['registration'] = 'NA';
994
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1051
+				if (count($image_array) > 0) {
1052
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1053
+				} else {
1054
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1055
+				}
1056
+			} else {
1057
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1058
+			}
1059
+			if ($row['registration'] == '') {
1060
+				$row['registration'] = 'NA';
1061
+			}
1062
+			if ($row['ident'] == '') {
1063
+				$row['ident'] = 'NA';
1064
+			}
995 1065
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
996 1066
 			if (isset($identicao[0])) {
997 1067
 				if (substr($row['ident'],0,2) == 'AF') {
998
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1000
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1068
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1069
+						$icao = $row['ident'];
1070
+					} else {
1071
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1072
+					}
1073
+				} else {
1074
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1075
+				}
1001 1076
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1002
-			} else $icao = $row['ident'];
1077
+			} else {
1078
+				$icao = $row['ident'];
1079
+			}
1003 1080
 			$icao = $Translation->checkTranslation($icao,false);
1004 1081
 			$decode = json_decode($row['decode'],true);
1005 1082
 			$found = false;
@@ -1024,7 +1101,9 @@  discard block
 block discarded – undo
1024 1101
 					$found = true;
1025 1102
 				}
1026 1103
 			}
1027
-			if ($found) $row['decode'] = json_encode($decode);
1104
+			if ($found) {
1105
+				$row['decode'] = json_encode($decode);
1106
+			}
1028 1107
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1029 1108
 			$result[] = $data;
1030 1109
 			$i++;
@@ -1032,8 +1111,9 @@  discard block
 block discarded – undo
1032 1111
 		if (isset($result)) {
1033 1112
 			$result[0]['query_number_rows'] = $i;
1034 1113
 			return $result;
1114
+		} else {
1115
+			return array();
1035 1116
 		}
1036
-		else return array();
1037 1117
 	}
1038 1118
 
1039 1119
     /**
@@ -1086,31 +1166,51 @@  discard block
 block discarded – undo
1086 1166
 			if ($row['registration'] != '') {
1087 1167
 				$row['registration'] = str_replace('.','',$row['registration']);
1088 1168
 				$image_array = $Image->getSpotterImage($row['registration']);
1089
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1090
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1091
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1169
+				if (count($image_array) > 0) {
1170
+					$data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1171
+				} else {
1172
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1173
+				}
1174
+			} else {
1175
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1176
+			}
1092 1177
 			$icao = '';
1093
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1094
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1178
+			if ($row['registration'] == '') {
1179
+				$row['registration'] = 'NA';
1180
+			}
1181
+			if ($row['ident'] == '') {
1182
+				$row['ident'] = 'NA';
1183
+			}
1095 1184
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1096 1185
 			if (isset($identicao[0])) {
1097 1186
 				if (substr($row['ident'],0,2) == 'AF') {
1098
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1100
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1187
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1188
+						$icao = $row['ident'];
1189
+					} else {
1190
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1191
+					}
1192
+				} else {
1193
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1194
+				}
1101 1195
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1102
-			} else $icao = $row['ident'];
1196
+			} else {
1197
+				$icao = $row['ident'];
1198
+			}
1103 1199
 			$icao = $Translation->checkTranslation($icao);
1104 1200
 			$decode = json_decode($row['decode'],true);
1105 1201
 			$found = false;
1106 1202
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1107 1203
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1108
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1204
+				if (isset($airport_info[0]['icao'])) {
1205
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1206
+				}
1109 1207
 				$found = true;
1110 1208
 			}
1111 1209
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1112 1210
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1113
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1211
+				if (isset($airport_info[0]['icao'])) {
1212
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1213
+				}
1114 1214
 				$found = true;
1115 1215
 			}
1116 1216
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1120,7 +1220,9 @@  discard block
 block discarded – undo
1120 1220
 					$found = true;
1121 1221
 				}
1122 1222
 			}
1123
-			if ($found) $row['decode'] = json_encode($decode);
1223
+			if ($found) {
1224
+				$row['decode'] = json_encode($decode);
1225
+			}
1124 1226
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1125 1227
 			$result[] = $data;
1126 1228
 			$i++;
@@ -1128,7 +1230,9 @@  discard block
 block discarded – undo
1128 1230
 		if (!empty($result)) {
1129 1231
 			$result[0]['query_number_rows'] = $i;
1130 1232
 			return $result;
1131
-		} else return array();
1233
+		} else {
1234
+			return array();
1235
+		}
1132 1236
 	}
1133 1237
 
1134 1238
     /**
@@ -1147,25 +1251,37 @@  discard block
 block discarded – undo
1147 1251
 		$ident = trim($ident);
1148 1252
 		$Translation = new Translation($this->db);
1149 1253
 		$Spotter = new Spotter($this->db);
1150
-		if ($globalDebug) echo "Test if we add ModeS data...";
1254
+		if ($globalDebug) {
1255
+			echo "Test if we add ModeS data...";
1256
+		}
1151 1257
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1152
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1153
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1258
+		if ($icao == '') {
1259
+			$icao = $Translation->checkTranslation($ident);
1260
+		}
1261
+		if ($globalDebug) {
1262
+			echo '- Ident : '.$icao.' - ';
1263
+		}
1154 1264
 		if ($ident == '' || $registration == '') {
1155
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1265
+			if ($globalDebug) {
1266
+				echo "Ident or registration null, exit\n";
1267
+			}
1156 1268
 			return '';
1157 1269
 		}
1158 1270
 		$registration = str_replace('.','',$registration);
1159 1271
 		$ident = $Translation->ident2icao($ident);
1160 1272
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1161
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1273
+		if ($globalDebug) {
1274
+			echo "Check if needed to add translation ".$ident.'... ';
1275
+		}
1162 1276
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1163 1277
 		$querysi_values = array(':registration' => $registration);
1164 1278
 		try {
1165 1279
 			$sthsi = $this->db->prepare($querysi);
1166 1280
 			$sthsi->execute($querysi_values);
1167 1281
 		} catch(PDOException $e) {
1168
-			if ($globalDebug) echo $e->getMessage();
1282
+			if ($globalDebug) {
1283
+				echo $e->getMessage();
1284
+			}
1169 1285
 			return "error : ".$e->getMessage();
1170 1286
 		}
1171 1287
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1173,9 +1289,14 @@  discard block
 block discarded – undo
1173 1289
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1174 1290
 			$Translation = new Translation($this->db);
1175 1291
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1176
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1177
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1178
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1292
+			if ($globalDebug) {
1293
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1294
+			}
1295
+			if ($ident != $trans_ident) {
1296
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1297
+			} elseif ($trans_ident == $ident) {
1298
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1299
+			}
1179 1300
 		} else {
1180 1301
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1181 1302
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1184,32 +1305,46 @@  discard block
 block discarded – undo
1184 1305
 					$sth = $this->db->prepare($query);
1185 1306
 					$sth->execute($query_values);
1186 1307
 				} catch(PDOException $e) {
1187
-					if ($globalDebug) echo $e->getMessage();
1308
+					if ($globalDebug) {
1309
+						echo $e->getMessage();
1310
+					}
1188 1311
 					return "error : ".$e->getMessage();
1189 1312
 				}
1190 1313
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1191 1314
 				$sth->closeCursor();
1192
-				if (isset($result['modes'])) $hex = $result['modes'];
1193
-				else $hex = '';
1315
+				if (isset($result['modes'])) {
1316
+					$hex = $result['modes'];
1317
+				} else {
1318
+					$hex = '';
1319
+				}
1194 1320
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1195
-				if ($this->fromACARSscript) $this->SI->add($SI_data);
1321
+				if ($this->fromACARSscript) {
1322
+					$this->SI->add($SI_data);
1323
+				}
1196 1324
 			}
1197 1325
 		}
1198
-		if ($globalDebug) echo 'Done'."\n";
1326
+		if ($globalDebug) {
1327
+			echo 'Done'."\n";
1328
+		}
1199 1329
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1200 1330
 		$query_values = array(':ident' => $icao);
1201 1331
 		try {
1202 1332
 			$sth = $this->db->prepare($query);
1203 1333
 			$sth->execute($query_values);
1204 1334
 		} catch(PDOException $e) {
1205
-			if ($globalDebug) echo $e->getMessage();
1335
+			if ($globalDebug) {
1336
+				echo $e->getMessage();
1337
+			}
1206 1338
 			return "error : ".$e->getMessage();
1207 1339
 		}
1208 1340
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1209 1341
 		$sth->closeCursor();
1210 1342
 		if (isset($result['flightaware_id'])) {
1211
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1212
-			else $ModeS = '';
1343
+			if (isset($result['ModeS'])) {
1344
+				$ModeS = $result['ModeS'];
1345
+			} else {
1346
+				$ModeS = '';
1347
+			}
1213 1348
 			if ($ModeS == '') {
1214 1349
 				$id = explode('-',$result['flightaware_id']);
1215 1350
 				$ModeS = $id[0];
@@ -1222,24 +1357,32 @@  discard block
 block discarded – undo
1222 1357
 					$sthc = $this->db->prepare($queryc);
1223 1358
 					$sthc->execute($queryc_values);
1224 1359
 				} catch(PDOException $e) {
1225
-					if ($globalDebug) echo $e->getMessage();
1360
+					if ($globalDebug) {
1361
+						echo $e->getMessage();
1362
+					}
1226 1363
 					return "error : ".$e->getMessage();
1227 1364
 				}
1228 1365
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1229 1366
 				$sthc->closeCursor();
1230 1367
 				if (count($row) ==  0) {
1231
-					if ($globalDebug) echo " Add to ModeS table - ";
1368
+					if ($globalDebug) {
1369
+						echo " Add to ModeS table - ";
1370
+					}
1232 1371
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1233 1372
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1234 1373
 					try {
1235 1374
 						$sthi = $this->db->prepare($queryi);
1236 1375
 						$sthi->execute($queryi_values);
1237 1376
 					} catch(PDOException $e) {
1238
-						if ($globalDebug) echo $e->getMessage();
1377
+						if ($globalDebug) {
1378
+							echo $e->getMessage();
1379
+						}
1239 1380
 						return "error : ".$e->getMessage();
1240 1381
 					}
1241 1382
 				} else {
1242
-					if ($globalDebug) echo " Update ModeS table - ";
1383
+					if ($globalDebug) {
1384
+						echo " Update ModeS table - ";
1385
+					}
1243 1386
 					if ($ICAOTypeCode != '') {
1244 1387
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1245 1388
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1251,7 +1394,9 @@  discard block
 block discarded – undo
1251 1394
 						$sthi = $this->db->prepare($queryi);
1252 1395
 						$sthi->execute($queryi_values);
1253 1396
 					} catch(PDOException $e) {
1254
-						if ($globalDebug) echo $e->getMessage();
1397
+						if ($globalDebug) {
1398
+							echo $e->getMessage();
1399
+						}
1255 1400
 						return "error : ".$e->getMessage();
1256 1401
 					}
1257 1402
 				}
@@ -1272,7 +1417,9 @@  discard block
 block discarded – undo
1272 1417
 					    return "error : ".$e->getMessage();
1273 1418
 				}
1274 1419
 				*/
1275
-				if ($globalDebug) echo " Update Spotter_output table - ";
1420
+				if ($globalDebug) {
1421
+					echo " Update Spotter_output table - ";
1422
+				}
1276 1423
 				if ($ICAOTypeCode != '') {
1277 1424
 					if ($globalDBdriver == 'mysql') {
1278 1425
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1283,8 +1430,7 @@  discard block
 block discarded – undo
1283 1430
 				} else {
1284 1431
 					if ($globalDBdriver == 'mysql') {
1285 1432
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1286
-					}
1287
-					elseif ($globalDBdriver == 'pgsql') {
1433
+					} elseif ($globalDBdriver == 'pgsql') {
1288 1434
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1289 1435
 					}
1290 1436
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1293,14 +1439,20 @@  discard block
 block discarded – undo
1293 1439
 					$sthi = $this->db->prepare($queryi);
1294 1440
 					$sthi->execute($queryi_values);
1295 1441
 				} catch(PDOException $e) {
1296
-					if ($globalDebug) echo $e->getMessage();
1442
+					if ($globalDebug) {
1443
+						echo $e->getMessage();
1444
+					}
1297 1445
 					return "error : ".$e->getMessage();
1298 1446
 				}
1299 1447
 			}
1300 1448
 		} else {
1301
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1449
+			if ($globalDebug) {
1450
+				echo " Can't find ModeS in spotter_output - ";
1451
+			}
1452
+		}
1453
+		if ($globalDebug) {
1454
+			echo "Done\n";
1302 1455
 		}
1303
-		if ($globalDebug) echo "Done\n";
1304 1456
 		return '';
1305 1457
 	}
1306 1458
 }
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +1252 added lines, -433 removed lines patch added patch discarded remove patch
@@ -36,7 +36,9 @@  discard block
 block discarded – undo
36 36
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
37 37
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
38 38
 		curl_setopt($ch, CURLOPT_TIMEOUT, 200);
39
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
39
+		if ($referer != '') {
40
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
41
+		}
40 42
 		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');
41 43
 		curl_setopt($ch, CURLOPT_FILE, $fp);
42 44
 		curl_exec($ch);
@@ -47,12 +49,16 @@  discard block
 block discarded – undo
47 49
 	public static function gunzip($in_file,$out_file_name = '') {
48 50
 		//echo $in_file.' -> '.$out_file_name."\n";
49 51
 		$buffer_size = 4096; // read 4kb at a time
50
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
52
+		if ($out_file_name == '') {
53
+			$out_file_name = str_replace('.gz', '', $in_file);
54
+		}
51 55
 		if ($in_file != '' && file_exists($in_file)) {
52 56
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
53
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
54
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
55
-			else {
57
+			if (function_exists('gzopen')) {
58
+				$file = gzopen($in_file,'rb');
59
+			} elseif (function_exists('gzopen64')) {
60
+				$file = gzopen64($in_file,'rb');
61
+			} else {
56 62
 				echo 'gzopen not available';
57 63
 				die;
58 64
 			}
@@ -73,8 +79,12 @@  discard block
 block discarded – undo
73 79
 			if ($res === TRUE) {
74 80
 				$zip->extractTo($path);
75 81
 				$zip->close();
76
-			} else return false;
77
-		} else return false;
82
+			} else {
83
+				return false;
84
+			}
85
+		} else {
86
+			return false;
87
+		}
78 88
 	}
79 89
 	
80 90
 	public static function connect_sqlite($database) {
@@ -89,7 +99,9 @@  discard block
 block discarded – undo
89 99
 	public static function retrieve_route_sqlite_to_dest($database_file) {
90 100
 		global $globalDebug, $globalTransaction;
91 101
 		//$query = 'TRUNCATE TABLE routes';
92
-		if ($globalDebug) echo " - Delete previous routes from DB -";
102
+		if ($globalDebug) {
103
+			echo " - Delete previous routes from DB -";
104
+		}
93 105
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
94 106
 		$Connection = new Connection();
95 107
 		try {
@@ -100,7 +112,9 @@  discard block
 block discarded – undo
100 112
                         return "error : ".$e->getMessage();
101 113
                 }
102 114
 
103
-    		if ($globalDebug) echo " - Add routes to DB -";
115
+    		if ($globalDebug) {
116
+    			echo " - Add routes to DB -";
117
+    		}
104 118
     		update_db::connect_sqlite($database_file);
105 119
 		//$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';
106 120
 		$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";
@@ -115,15 +129,21 @@  discard block
 block discarded – undo
115 129
 		$Connection = new Connection();
116 130
 		$sth_dest = $Connection->db->prepare($query_dest);
117 131
 		try {
118
-			if ($globalTransaction) $Connection->db->beginTransaction();
132
+			if ($globalTransaction) {
133
+				$Connection->db->beginTransaction();
134
+			}
119 135
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
120 136
 				//$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);
121 137
 				$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);
122 138
 				$sth_dest->execute($query_dest_values);
123 139
             		}
124
-			if ($globalTransaction) $Connection->db->commit();
140
+			if ($globalTransaction) {
141
+				$Connection->db->commit();
142
+			}
125 143
 		} catch(PDOException $e) {
126
-			if ($globalTransaction) $Connection->db->rollBack(); 
144
+			if ($globalTransaction) {
145
+				$Connection->db->rollBack();
146
+			}
127 147
 			return "error : ".$e->getMessage();
128 148
 		}
129 149
                 return '';
@@ -131,7 +151,9 @@  discard block
 block discarded – undo
131 151
 	public static function retrieve_route_oneworld($database_file) {
132 152
 		global $globalDebug, $globalTransaction;
133 153
 		//$query = 'TRUNCATE TABLE routes';
134
-		if ($globalDebug) echo " - Delete previous routes from DB -";
154
+		if ($globalDebug) {
155
+			echo " - Delete previous routes from DB -";
156
+		}
135 157
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
136 158
 		$Connection = new Connection();
137 159
 		try {
@@ -142,14 +164,18 @@  discard block
 block discarded – undo
142 164
                         return "error : ".$e->getMessage();
143 165
                 }
144 166
 
145
-    		if ($globalDebug) echo " - Add routes to DB -";
167
+    		if ($globalDebug) {
168
+    			echo " - Add routes to DB -";
169
+    		}
146 170
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
147 171
 		$Spotter = new Spotter();
148 172
 		if ($fh = fopen($database_file,"r")) {
149 173
 			$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)';
150 174
 			$Connection = new Connection();
151 175
 			$sth_dest = $Connection->db->prepare($query_dest);
152
-			if ($globalTransaction) $Connection->db->beginTransaction();
176
+			if ($globalTransaction) {
177
+				$Connection->db->beginTransaction();
178
+			}
153 179
 			while (!feof($fh)) {
154 180
 				$line = fgetcsv($fh,9999,',');
155 181
 				if ($line[0] != '') {
@@ -158,13 +184,17 @@  discard block
 block discarded – undo
158 184
 							$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');
159 185
 							$sth_dest->execute($query_dest_values);
160 186
 						} catch(PDOException $e) {
161
-							if ($globalTransaction) $Connection->db->rollBack(); 
187
+							if ($globalTransaction) {
188
+								$Connection->db->rollBack();
189
+							}
162 190
 							return "error : ".$e->getMessage();
163 191
 						}
164 192
 					}
165 193
 				}
166 194
 			}
167
-			if ($globalTransaction) $Connection->db->commit();
195
+			if ($globalTransaction) {
196
+				$Connection->db->commit();
197
+			}
168 198
 		}
169 199
                 return '';
170 200
 	}
@@ -172,7 +202,9 @@  discard block
 block discarded – undo
172 202
 	public static function retrieve_route_skyteam($database_file) {
173 203
 		global $globalDebug, $globalTransaction;
174 204
 		//$query = 'TRUNCATE TABLE routes';
175
-		if ($globalDebug) echo " - Delete previous routes from DB -";
205
+		if ($globalDebug) {
206
+			echo " - Delete previous routes from DB -";
207
+		}
176 208
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
177 209
 		$Connection = new Connection();
178 210
 		try {
@@ -183,7 +215,9 @@  discard block
 block discarded – undo
183 215
                         return "error : ".$e->getMessage();
184 216
                 }
185 217
 
186
-    		if ($globalDebug) echo " - Add routes to DB -";
218
+    		if ($globalDebug) {
219
+    			echo " - Add routes to DB -";
220
+    		}
187 221
 
188 222
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
189 223
 		$Spotter = new Spotter();
@@ -192,7 +226,9 @@  discard block
 block discarded – undo
192 226
 			$Connection = new Connection();
193 227
 			$sth_dest = $Connection->db->prepare($query_dest);
194 228
 			try {
195
-				if ($globalTransaction) $Connection->db->beginTransaction();
229
+				if ($globalTransaction) {
230
+					$Connection->db->beginTransaction();
231
+				}
196 232
 				while (!feof($fh)) {
197 233
 					$line = fgetcsv($fh,9999,',');
198 234
 					if ($line[0] != '') {
@@ -203,9 +239,13 @@  discard block
 block discarded – undo
203 239
 						}
204 240
 					}
205 241
 				}
206
-				if ($globalTransaction) $Connection->db->commit();
242
+				if ($globalTransaction) {
243
+					$Connection->db->commit();
244
+				}
207 245
 			} catch(PDOException $e) {
208
-				if ($globalTransaction) $Connection->db->rollBack(); 
246
+				if ($globalTransaction) {
247
+					$Connection->db->rollBack();
248
+				}
209 249
 				return "error : ".$e->getMessage();
210 250
 			}
211 251
 		}
@@ -248,11 +288,16 @@  discard block
 block discarded – undo
248 288
 		$sth_dest = $Connection->db->prepare($query_dest);
249 289
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
250 290
 		try {
251
-			if ($globalTransaction) $Connection->db->beginTransaction();
291
+			if ($globalTransaction) {
292
+				$Connection->db->beginTransaction();
293
+			}
252 294
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
253 295
 			//$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']);
254
-				if ($values['UserString4'] == 'M') $type = 'military';
255
-				else $type = null;
296
+				if ($values['UserString4'] == 'M') {
297
+					$type = 'military';
298
+				} else {
299
+					$type = null;
300
+				}
256 301
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
257 302
 				$sth_dest->execute($query_dest_values);
258 303
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -260,7 +305,9 @@  discard block
 block discarded – undo
260 305
 				    $sth_dest_owner->execute($query_dest_owner_values);
261 306
 				}
262 307
             		}
263
-			if ($globalTransaction) $Connection->db->commit();
308
+			if ($globalTransaction) {
309
+				$Connection->db->commit();
310
+			}
264 311
 		} catch(PDOException $e) {
265 312
 			return "error : ".$e->getMessage();
266 313
 		}
@@ -297,7 +344,9 @@  discard block
 block discarded – undo
297 344
 			$Connection = new Connection();
298 345
 			$sth_dest = $Connection->db->prepare($query_dest);
299 346
 			try {
300
-				if ($globalTransaction) $Connection->db->beginTransaction();
347
+				if ($globalTransaction) {
348
+					$Connection->db->beginTransaction();
349
+				}
301 350
             			while (!feof($fh)) {
302 351
             				$values = array();
303 352
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -308,7 +357,9 @@  discard block
 block discarded – undo
308 357
             				// Check if we can find ICAO, else set it to GLID
309 358
             				$aircraft_name_split = explode(' ',$aircraft_name);
310 359
             				$search_more = '';
311
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
360
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
361
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
362
+            				}
312 363
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
313 364
             				$sth_search = $Connection->db->prepare($query_search);
314 365
 					try {
@@ -321,7 +372,9 @@  discard block
 block discarded – undo
321 372
 					} catch(PDOException $e) {
322 373
 						return "error : ".$e->getMessage();
323 374
 					}
324
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
375
+					if (!isset($values['ICAOTypeCode'])) {
376
+						$values['ICAOTypeCode'] = 'GLID';
377
+					}
325 378
 					// Add data to db
326 379
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
327 380
 						//$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']);
@@ -330,7 +383,9 @@  discard block
 block discarded – undo
330 383
 						$sth_dest->execute($query_dest_values);
331 384
 					}
332 385
 				}
333
-				if ($globalTransaction) $Connection->db->commit();
386
+				if ($globalTransaction) {
387
+					$Connection->db->commit();
388
+				}
334 389
 			} catch(PDOException $e) {
335 390
 				return "error : ".$e->getMessage();
336 391
 			}
@@ -366,7 +421,9 @@  discard block
 block discarded – undo
366 421
 			$Connection = new Connection();
367 422
 			$sth_dest = $Connection->db->prepare($query_dest);
368 423
 			try {
369
-				if ($globalTransaction) $Connection->db->beginTransaction();
424
+				if ($globalTransaction) {
425
+					$Connection->db->beginTransaction();
426
+				}
370 427
 				$tmp = fgetcsv($fh,9999,',',"'");
371 428
             			while (!feof($fh)) {
372 429
             				$line = fgetcsv($fh,9999,',',"'");
@@ -380,13 +437,17 @@  discard block
 block discarded – undo
380 437
             				// Check if we can find ICAO, else set it to GLID
381 438
             				$aircraft_name_split = explode(' ',$aircraft_name);
382 439
             				$search_more = '';
383
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
440
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
441
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
442
+            				}
384 443
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
385 444
             				$sth_search = $Connection->db->prepare($query_search);
386 445
 					try {
387 446
                                     		$sth_search->execute();
388 447
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
389
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
448
+	            				if (isset($result['icao']) && $result['icao'] != '') {
449
+	            					$values['ICAOTypeCode'] = $result['icao'];
450
+	            				}
390 451
 					} catch(PDOException $e) {
391 452
 						return "error : ".$e->getMessage();
392 453
 					}
@@ -399,7 +460,9 @@  discard block
 block discarded – undo
399 460
 						$sth_dest->execute($query_dest_values);
400 461
 					}
401 462
 				}
402
-				if ($globalTransaction) $Connection->db->commit();
463
+				if ($globalTransaction) {
464
+					$Connection->db->commit();
465
+				}
403 466
 			} catch(PDOException $e) {
404 467
 				return "error : ".$e->getMessage();
405 468
 			}
@@ -438,7 +501,9 @@  discard block
 block discarded – undo
438 501
 			$sth_dest = $Connection->db->prepare($query_dest);
439 502
 			$sth_modes = $Connection->db->prepare($query_modes);
440 503
 			try {
441
-				if ($globalTransaction) $Connection->db->beginTransaction();
504
+				if ($globalTransaction) {
505
+					$Connection->db->beginTransaction();
506
+				}
442 507
 				$tmp = fgetcsv($fh,9999,',','"');
443 508
             			while (!feof($fh)) {
444 509
             				$line = fgetcsv($fh,9999,',','"');
@@ -448,16 +513,22 @@  discard block
 block discarded – undo
448 513
             				    $values['registration'] = $line[0];
449 514
             				    $values['base'] = $line[4];
450 515
             				    $values['owner'] = $line[5];
451
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
452
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
516
+            				    if ($line[6] == '') {
517
+            				    	$values['date_first_reg'] = null;
518
+            				    } else {
519
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
520
+					    }
453 521
 					    $values['cancel'] = $line[7];
454 522
 					} elseif ($country == 'EI') {
455 523
 					    // TODO : add modeS & reg to aircraft_modes
456 524
             				    $values['registration'] = $line[0];
457 525
             				    $values['base'] = $line[3];
458 526
             				    $values['owner'] = $line[2];
459
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
460
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
527
+            				    if ($line[1] == '') {
528
+            				    	$values['date_first_reg'] = null;
529
+            				    } else {
530
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
531
+					    }
461 532
 					    $values['cancel'] = '';
462 533
 					    $values['modes'] = $line[7];
463 534
 					    $values['icao'] = $line[8];
@@ -476,16 +547,22 @@  discard block
 block discarded – undo
476 547
             				    $values['registration'] = $line[3];
477 548
             				    $values['base'] = null;
478 549
             				    $values['owner'] = $line[5];
479
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
480
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
550
+            				    if ($line[18] == '') {
551
+            				    	$values['date_first_reg'] = null;
552
+            				    } else {
553
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
554
+					    }
481 555
 					    $values['cancel'] = '';
482 556
 					} elseif ($country == 'VH') {
483 557
 					    // TODO : add modeS & reg to aircraft_modes
484 558
             				    $values['registration'] = $line[0];
485 559
             				    $values['base'] = null;
486 560
             				    $values['owner'] = $line[12];
487
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
488
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
561
+            				    if ($line[28] == '') {
562
+            				    	$values['date_first_reg'] = null;
563
+            				    } else {
564
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
565
+					    }
489 566
 
490 567
 					    $values['cancel'] = $line[39];
491 568
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -504,29 +581,41 @@  discard block
 block discarded – undo
504 581
             				    $values['registration'] = $line[0];
505 582
             				    $values['base'] = null;
506 583
             				    $values['owner'] = $line[8];
507
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
584
+            				    if ($line[7] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
588
+					    }
509 589
 					    $values['cancel'] = '';
510 590
 					} elseif ($country == 'PP') {
511 591
             				    $values['registration'] = $line[0];
512 592
             				    $values['base'] = null;
513 593
             				    $values['owner'] = $line[4];
514
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
515
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
594
+            				    if ($line[6] == '') {
595
+            				    	$values['date_first_reg'] = null;
596
+            				    } else {
597
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
598
+					    }
516 599
 					    $values['cancel'] = $line[7];
517 600
 					} elseif ($country == 'E7') {
518 601
             				    $values['registration'] = $line[0];
519 602
             				    $values['base'] = null;
520 603
             				    $values['owner'] = $line[4];
521
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
522
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
604
+            				    if ($line[5] == '') {
605
+            				    	$values['date_first_reg'] = null;
606
+            				    } else {
607
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
608
+					    }
523 609
 					    $values['cancel'] = '';
524 610
 					} elseif ($country == '8Q') {
525 611
             				    $values['registration'] = $line[0];
526 612
             				    $values['base'] = null;
527 613
             				    $values['owner'] = $line[3];
528
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
529
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
614
+            				    if ($line[7] == '') {
615
+            				    	$values['date_first_reg'] = null;
616
+            				    } else {
617
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
618
+					    }
530 619
 					    $values['cancel'] = '';
531 620
 					} elseif ($country == 'ZK') {
532 621
             				    $values['registration'] = $line[0];
@@ -571,7 +660,9 @@  discard block
 block discarded – undo
571 660
 						$sth_modes->execute($query_modes_values);
572 661
 					}
573 662
 				}
574
-				if ($globalTransaction) $Connection->db->commit();
663
+				if ($globalTransaction) {
664
+					$Connection->db->commit();
665
+				}
575 666
 			} catch(PDOException $e) {
576 667
 				return "error : ".$e->getMessage();
577 668
 			}
@@ -707,25 +798,45 @@  discard block
 block discarded – undo
707 798
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
708 799
 		$Connection = new Connection();
709 800
 		$sth_dest = $Connection->db->prepare($query_dest);
710
-		if ($globalTransaction) $Connection->db->beginTransaction();
801
+		if ($globalTransaction) {
802
+			$Connection->db->beginTransaction();
803
+		}
711 804
   
712 805
 		$i = 0;
713 806
 		while($row = sparql_fetch_array($result))
714 807
 		{
715 808
 			if ($i >= 1) {
716 809
 			//print_r($row);
717
-			if (!isset($row['iata'])) $row['iata'] = '';
718
-			if (!isset($row['icao'])) $row['icao'] = '';
719
-			if (!isset($row['type'])) $row['type'] = '';
720
-			if (!isset($row['altitude'])) $row['altitude'] = '';
810
+			if (!isset($row['iata'])) {
811
+				$row['iata'] = '';
812
+			}
813
+			if (!isset($row['icao'])) {
814
+				$row['icao'] = '';
815
+			}
816
+			if (!isset($row['type'])) {
817
+				$row['type'] = '';
818
+			}
819
+			if (!isset($row['altitude'])) {
820
+				$row['altitude'] = '';
821
+			}
721 822
 			if (isset($row['city_bis'])) {
722 823
 				$row['city'] = $row['city_bis'];
723 824
 			}
724
-			if (!isset($row['city'])) $row['city'] = '';
725
-			if (!isset($row['country'])) $row['country'] = '';
726
-			if (!isset($row['homepage'])) $row['homepage'] = '';
727
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
728
-			if (!isset($row['name'])) continue;
825
+			if (!isset($row['city'])) {
826
+				$row['city'] = '';
827
+			}
828
+			if (!isset($row['country'])) {
829
+				$row['country'] = '';
830
+			}
831
+			if (!isset($row['homepage'])) {
832
+				$row['homepage'] = '';
833
+			}
834
+			if (!isset($row['wikipedia_page'])) {
835
+				$row['wikipedia_page'] = '';
836
+			}
837
+			if (!isset($row['name'])) {
838
+				continue;
839
+			}
729 840
 			if (!isset($row['image'])) {
730 841
 				$row['image'] = '';
731 842
 				$row['image_thumb'] = '';
@@ -781,7 +892,9 @@  discard block
 block discarded – undo
781 892
 
782 893
 			$i++;
783 894
 		}
784
-		if ($globalTransaction) $Connection->db->commit();
895
+		if ($globalTransaction) {
896
+			$Connection->db->commit();
897
+		}
785 898
 		/*
786 899
 		echo "Delete duplicate rows...\n";
787 900
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -824,7 +937,9 @@  discard block
 block discarded – undo
824 937
 		$delimiter = ',';
825 938
 		$out_file = $tmp_dir.'airports.csv';
826 939
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
827
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
940
+		if (!file_exists($out_file) || !is_readable($out_file)) {
941
+			return FALSE;
942
+		}
828 943
 		echo "Add data from ourairports.com...\n";
829 944
 
830 945
 		$header = NULL;
@@ -834,8 +949,9 @@  discard block
 block discarded – undo
834 949
 			//$Connection->db->beginTransaction();
835 950
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
836 951
 			{
837
-				if(!$header) $header = $row;
838
-				else {
952
+				if(!$header) {
953
+					$header = $row;
954
+				} else {
839 955
 					$data = array();
840 956
 					$data = array_combine($header, $row);
841 957
 					try {
@@ -876,7 +992,9 @@  discard block
 block discarded – undo
876 992
 		echo "Download data from another free database...\n";
877 993
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
878 994
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
879
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
995
+		if (!file_exists($out_file) || !is_readable($out_file)) {
996
+			return FALSE;
997
+		}
880 998
 		update_db::unzip($out_file);
881 999
 		$header = NULL;
882 1000
 		echo "Add data from another free database...\n";
@@ -887,8 +1005,9 @@  discard block
 block discarded – undo
887 1005
 			//$Connection->db->beginTransaction();
888 1006
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
889 1007
 			{
890
-				if(!$header) $header = $row;
891
-				else {
1008
+				if(!$header) {
1009
+					$header = $row;
1010
+				} else {
892 1011
 					$data = $row;
893 1012
 
894 1013
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1082,7 +1201,9 @@  discard block
 block discarded – undo
1082 1201
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1083 1202
 		{
1084 1203
 			$i = 0;
1085
-			if ($globalTransaction) $Connection->db->beginTransaction();
1204
+			if ($globalTransaction) {
1205
+				$Connection->db->beginTransaction();
1206
+			}
1086 1207
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1087 1208
 			{
1088 1209
 				if ($i > 0) {
@@ -1095,7 +1216,9 @@  discard block
 block discarded – undo
1095 1216
 					}
1096 1217
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1097 1218
 					if (!empty($result_search)) {
1098
-						if ($globalDebug) echo '.';
1219
+						if ($globalDebug) {
1220
+							echo '.';
1221
+						}
1099 1222
 							//if ($globalDBdriver == 'mysql') {
1100 1223
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1101 1224
 							//} else {
@@ -1117,8 +1240,12 @@  discard block
 block discarded – undo
1117 1240
 						}
1118 1241
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1119 1242
 						if (!empty($result_search_mfr)) {
1120
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1121
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1243
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1244
+								$data[16] = $data[23];
1245
+							}
1246
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1247
+								$data[16] = $data[15];
1248
+							}
1122 1249
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1123 1250
 							try {
1124 1251
 								$sthf = $Connection->db->prepare($queryf);
@@ -1129,7 +1256,9 @@  discard block
 block discarded – undo
1129 1256
 						}
1130 1257
 					}
1131 1258
 					if (strtotime($data[29]) > time()) {
1132
-						if ($globalDebug) echo 'i';
1259
+						if ($globalDebug) {
1260
+							echo 'i';
1261
+						}
1133 1262
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1134 1263
 						try {
1135 1264
 							$sth = $Connection->db->prepare($query);
@@ -1140,13 +1269,19 @@  discard block
 block discarded – undo
1140 1269
 					}
1141 1270
 				}
1142 1271
 				if ($i % 90 == 0) {
1143
-					if ($globalTransaction) $Connection->db->commit();
1144
-					if ($globalTransaction) $Connection->db->beginTransaction();
1272
+					if ($globalTransaction) {
1273
+						$Connection->db->commit();
1274
+					}
1275
+					if ($globalTransaction) {
1276
+						$Connection->db->beginTransaction();
1277
+					}
1145 1278
 				}
1146 1279
 				$i++;
1147 1280
 			}
1148 1281
 			fclose($handle);
1149
-			if ($globalTransaction) $Connection->db->commit();
1282
+			if ($globalTransaction) {
1283
+				$Connection->db->commit();
1284
+			}
1150 1285
 		}
1151 1286
 		return '';
1152 1287
 	}
@@ -1166,11 +1301,15 @@  discard block
 block discarded – undo
1166 1301
 		if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE)
1167 1302
 		{
1168 1303
 			$i = 0;
1169
-			if ($globalTransaction) $Connection->db->beginTransaction();
1304
+			if ($globalTransaction) {
1305
+				$Connection->db->beginTransaction();
1306
+			}
1170 1307
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1171 1308
 			{
1172 1309
 				if ($i > 0) {
1173
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1310
+					if ($data[1] == 'NULL') {
1311
+						$data[1] = $data[0];
1312
+					}
1174 1313
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1175 1314
 					try {
1176 1315
 						$sth = $Connection->db->prepare($query);
@@ -1182,7 +1321,9 @@  discard block
 block discarded – undo
1182 1321
 				$i++;
1183 1322
 			}
1184 1323
 			fclose($handle);
1185
-			if ($globalTransaction) $Connection->db->commit();
1324
+			if ($globalTransaction) {
1325
+				$Connection->db->commit();
1326
+			}
1186 1327
 		}
1187 1328
 		return '';
1188 1329
 	}
@@ -1214,11 +1355,15 @@  discard block
 block discarded – undo
1214 1355
 		if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE)
1215 1356
 		{
1216 1357
 			$i = 0;
1217
-			if ($globalTransaction) $Connection->db->beginTransaction();
1358
+			if ($globalTransaction) {
1359
+				$Connection->db->beginTransaction();
1360
+			}
1218 1361
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1219 1362
 			{
1220 1363
 				if ($i > 0) {
1221
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1364
+					if ($data[1] == 'NULL') {
1365
+						$data[1] = $data[0];
1366
+					}
1222 1367
 					$query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1223 1368
 					try {
1224 1369
 						$sth = $Connection->db->prepare($query);
@@ -1230,7 +1375,9 @@  discard block
 block discarded – undo
1230 1375
 				$i++;
1231 1376
 			}
1232 1377
 			fclose($handle);
1233
-			if ($globalTransaction) $Connection->db->commit();
1378
+			if ($globalTransaction) {
1379
+				$Connection->db->commit();
1380
+			}
1234 1381
 		}
1235 1382
 		/*
1236 1383
 		$query = "UNLOCK TABLES";
@@ -1260,7 +1407,9 @@  discard block
 block discarded – undo
1260 1407
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1261 1408
 		{
1262 1409
 			$i = 0;
1263
-			if ($globalTransaction) $Connection->db->beginTransaction();
1410
+			if ($globalTransaction) {
1411
+				$Connection->db->beginTransaction();
1412
+			}
1264 1413
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1265 1414
 			{
1266 1415
 				if ($i > 0) {
@@ -1276,7 +1425,9 @@  discard block
 block discarded – undo
1276 1425
 				$i++;
1277 1426
 			}
1278 1427
 			fclose($handle);
1279
-			if ($globalTransaction) $Connection->db->commit();
1428
+			if ($globalTransaction) {
1429
+				$Connection->db->commit();
1430
+			}
1280 1431
 		}
1281 1432
 		return '';
1282 1433
         }
@@ -1296,7 +1447,9 @@  discard block
 block discarded – undo
1296 1447
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1297 1448
 		{
1298 1449
 			$i = 0;
1299
-			if ($globalTransaction) $Connection->db->beginTransaction();
1450
+			if ($globalTransaction) {
1451
+				$Connection->db->beginTransaction();
1452
+			}
1300 1453
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1301 1454
 			{
1302 1455
 				if ($i > 0) {
@@ -1306,19 +1459,25 @@  discard block
 block discarded – undo
1306 1459
 						$sth = $Connection->db->prepare($query);
1307 1460
 						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1308 1461
 					} catch(PDOException $e) {
1309
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1462
+						if ($globalDebug) {
1463
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1464
+						}
1310 1465
 						die();
1311 1466
 					}
1312 1467
 				}
1313 1468
 				if ($globalTransaction && $i % 2000 == 0) {
1314 1469
 					$Connection->db->commit();
1315
-					if ($globalDebug) echo '.';
1470
+					if ($globalDebug) {
1471
+						echo '.';
1472
+					}
1316 1473
 					$Connection->db->beginTransaction();
1317 1474
 				}
1318 1475
 				$i++;
1319 1476
 			}
1320 1477
 			fclose($handle);
1321
-			if ($globalTransaction) $Connection->db->commit();
1478
+			if ($globalTransaction) {
1479
+				$Connection->db->commit();
1480
+			}
1322 1481
 		}
1323 1482
 		return '';
1324 1483
 	}
@@ -1337,7 +1496,9 @@  discard block
 block discarded – undo
1337 1496
 		if (($handle = fopen($tmp_dir.'block.tsv', 'r')) !== FALSE)
1338 1497
 		{
1339 1498
 			$i = 0;
1340
-			if ($globalTransaction) $Connection->db->beginTransaction();
1499
+			if ($globalTransaction) {
1500
+				$Connection->db->beginTransaction();
1501
+			}
1341 1502
 			while (($data = fgets($handle, 1000)) !== FALSE)
1342 1503
 			{
1343 1504
 				$query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)';
@@ -1345,18 +1506,24 @@  discard block
 block discarded – undo
1345 1506
 					$sth = $Connection->db->prepare($query);
1346 1507
 					$sth->execute(array(':callSign' => trim($data),':source' => 'website_fam'));
1347 1508
 				} catch(PDOException $e) {
1348
-					if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data;
1509
+					if ($globalDebug) {
1510
+						echo "error: ".$e->getMessage()." - data: ".$data;
1511
+					}
1349 1512
 					die();
1350 1513
 				}
1351 1514
 				if ($globalTransaction && $i % 2000 == 0) {
1352 1515
 					$Connection->db->commit();
1353
-					if ($globalDebug) echo '.';
1516
+					if ($globalDebug) {
1517
+						echo '.';
1518
+					}
1354 1519
 					$Connection->db->beginTransaction();
1355 1520
 				}
1356 1521
 				$i++;
1357 1522
 			}
1358 1523
 			fclose($handle);
1359
-			if ($globalTransaction) $Connection->db->commit();
1524
+			if ($globalTransaction) {
1525
+				$Connection->db->commit();
1526
+			}
1360 1527
 		}
1361 1528
 		return '';
1362 1529
         }
@@ -1381,7 +1548,9 @@  discard block
 block discarded – undo
1381 1548
 			$i = 0;
1382 1549
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1383 1550
 			//$Connection->db->beginTransaction();
1384
-			if ($globalTransaction) $Connection->db->beginTransaction();
1551
+			if ($globalTransaction) {
1552
+				$Connection->db->beginTransaction();
1553
+			}
1385 1554
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1386 1555
 			{
1387 1556
 				if ($i > 0) {
@@ -1397,7 +1566,9 @@  discard block
 block discarded – undo
1397 1566
 				$i++;
1398 1567
 			}
1399 1568
 			fclose($handle);
1400
-			if ($globalTransaction) $Connection->db->commit();
1569
+			if ($globalTransaction) {
1570
+				$Connection->db->commit();
1571
+			}
1401 1572
 		}
1402 1573
 		return '';
1403 1574
         }
@@ -1417,7 +1588,9 @@  discard block
 block discarded – undo
1417 1588
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1418 1589
 		{
1419 1590
 			$i = 0;
1420
-			if ($globalTransaction) $Connection->db->beginTransaction();
1591
+			if ($globalTransaction) {
1592
+				$Connection->db->beginTransaction();
1593
+			}
1421 1594
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1422 1595
 			{
1423 1596
 				if ($i > 0) {
@@ -1434,7 +1607,9 @@  discard block
 block discarded – undo
1434 1607
 				$i++;
1435 1608
 			}
1436 1609
 			fclose($handle);
1437
-			if ($globalTransaction) $Connection->db->commit();
1610
+			if ($globalTransaction) {
1611
+				$Connection->db->commit();
1612
+			}
1438 1613
 		}
1439 1614
 		return '';
1440 1615
 	}
@@ -1453,7 +1628,9 @@  discard block
 block discarded – undo
1453 1628
 		$Connection = new Connection();
1454 1629
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1455 1630
 		{
1456
-			if ($globalTransaction) $Connection->db->beginTransaction();
1631
+			if ($globalTransaction) {
1632
+				$Connection->db->beginTransaction();
1633
+			}
1457 1634
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1458 1635
 			{
1459 1636
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1468,7 +1645,9 @@  discard block
 block discarded – undo
1468 1645
 				}
1469 1646
 			}
1470 1647
 			fclose($handle);
1471
-			if ($globalTransaction) $Connection->db->commit();
1648
+			if ($globalTransaction) {
1649
+				$Connection->db->commit();
1650
+			}
1472 1651
 		}
1473 1652
 		return '';
1474 1653
         }
@@ -1546,9 +1725,14 @@  discard block
 block discarded – undo
1546 1725
 				if ($i > 0 && $data[0] != '') {
1547 1726
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1548 1727
 					$period = str_replace(',','',$data[14]);
1549
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1550
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1551
-					else $launch_date = NULL;
1728
+					if (!empty($period) && strpos($period,'days')) {
1729
+						$period = str_replace(' days','',$period)*24*60;
1730
+					}
1731
+					if ($data[18] != '') {
1732
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1733
+					} else {
1734
+						$launch_date = NULL;
1735
+					}
1552 1736
 					$data = array_map(function($value) {
1553 1737
 						return trim($value) === '' ? null : $value;
1554 1738
 					}, $data);
@@ -1740,10 +1924,14 @@  discard block
 block discarded – undo
1740 1924
 				$owner_code = trim(substr($data,49,5));
1741 1925
 				
1742 1926
 				if (!isset($satcat_sources[$owner_code]) && $owner_code != 'TBD') {
1743
-					if ($globalDebug) echo $data.'owner_code: '.$owner_code."\n";
1927
+					if ($globalDebug) {
1928
+						echo $data.'owner_code: '.$owner_code."\n";
1929
+					}
1744 1930
 				}
1745 1931
 				if (!isset($satcat_launch_site[trim(substr($data,68,5))])) {
1746
-					if ($globalDebug) echo 'launch_site_code: '.trim(substr($data,68,5))."\n";
1932
+					if ($globalDebug) {
1933
+						echo 'launch_site_code: '.trim(substr($data,68,5))."\n";
1934
+					}
1747 1935
 				}
1748 1936
 				
1749 1937
 				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) {
@@ -1910,7 +2098,9 @@  discard block
 block discarded – undo
1910 2098
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1911 2099
 		{
1912 2100
 			$i = 0;
1913
-			if ($globalTransaction) $Connection->db->beginTransaction();
2101
+			if ($globalTransaction) {
2102
+				$Connection->db->beginTransaction();
2103
+			}
1914 2104
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1915 2105
 			{
1916 2106
 				$i++;
@@ -1938,7 +2128,9 @@  discard block
 block discarded – undo
1938 2128
 				}
1939 2129
 			}
1940 2130
 			fclose($handle);
1941
-			if ($globalTransaction) $Connection->db->commit();
2131
+			if ($globalTransaction) {
2132
+				$Connection->db->commit();
2133
+			}
1942 2134
 		}
1943 2135
 		return '';
1944 2136
 	}
@@ -1954,7 +2146,9 @@  discard block
 block discarded – undo
1954 2146
 		$Source->deleteLocationByType('fires');
1955 2147
 		$i = 0;
1956 2148
 		if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) {
1957
-			if ($globalTransaction) $Connection->db->beginTransaction();
2149
+			if ($globalTransaction) {
2150
+				$Connection->db->beginTransaction();
2151
+			}
1958 2152
 			while (($row = fgetcsv($handle,1000)) !== false) {
1959 2153
 				if ($i > 0 && $row[0] != '' && $row[8] != 'low') {
1960 2154
 					$description = array('bright_t14' => $row[2],'scan' => $row[3],'track' => $row[4],'sat' => $row[7],'confidence' => $row[8],'version' => $row[9],'bright_t15' => $row[10],'frp' => $row[11],'daynight' => $row[12]);
@@ -1969,7 +2163,9 @@  discard block
 block discarded – undo
1969 2163
 				}
1970 2164
 				$i++;
1971 2165
 			}
1972
-			if ($globalTransaction) $Connection->db->commit();
2166
+			if ($globalTransaction) {
2167
+				$Connection->db->commit();
2168
+			}
1973 2169
 		}
1974 2170
 	}
1975 2171
 
@@ -1990,7 +2186,9 @@  discard block
 block discarded – undo
1990 2186
 		$Connection = new Connection();
1991 2187
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1992 2188
 		{
1993
-			if ($globalTransaction) $Connection->db->beginTransaction();
2189
+			if ($globalTransaction) {
2190
+				$Connection->db->beginTransaction();
2191
+			}
1994 2192
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1995 2193
 			{
1996 2194
 				if(count($row) > 1) {
@@ -2004,7 +2202,9 @@  discard block
 block discarded – undo
2004 2202
 				}
2005 2203
 			}
2006 2204
 			fclose($handle);
2007
-			if ($globalTransaction) $Connection->db->commit();
2205
+			if ($globalTransaction) {
2206
+				$Connection->db->commit();
2207
+			}
2008 2208
 		}
2009 2209
 		return '';
2010 2210
         }
@@ -2024,8 +2224,9 @@  discard block
 block discarded – undo
2024 2224
 	        }
2025 2225
 
2026 2226
 
2027
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2028
-		else {
2227
+		if ($globalDBdriver == 'mysql') {
2228
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2229
+		} else {
2029 2230
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
2030 2231
 			$query = "CREATE EXTENSION postgis";
2031 2232
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -2044,7 +2245,9 @@  discard block
 block discarded – undo
2044 2245
 		global $tmp_dir, $globalDebug;
2045 2246
 		include_once('class.create_db.php');
2046 2247
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
2047
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2248
+		if ($globalDebug) {
2249
+			echo "NOTAM from FlightAirMap website : Download...";
2250
+		}
2048 2251
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
2049 2252
 		$error = '';
2050 2253
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
@@ -2054,20 +2257,34 @@  discard block
 block discarded – undo
2054 2257
 				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
2055 2258
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
2056 2259
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
2057
-						if ($globalDebug) echo "Gunzip...";
2260
+						if ($globalDebug) {
2261
+							echo "Gunzip...";
2262
+						}
2058 2263
 						update_db::gunzip($tmp_dir.'notam.txt.gz');
2059
-						if ($globalDebug) echo "Add to DB...";
2264
+						if ($globalDebug) {
2265
+							echo "Add to DB...";
2266
+						}
2060 2267
 						//$error = create_db::import_file($tmp_dir.'notam.sql');
2061 2268
 						$NOTAM = new NOTAM();
2062 2269
 						$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
2063 2270
 						update_db::insert_notam_version($notam_md5);
2064
-					} else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2065
-				} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2066
-			} elseif ($globalDebug) echo "No new version.";
2067
-		} else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2271
+					} else {
2272
+						$error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2273
+					}
2274
+				} else {
2275
+					$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2276
+				}
2277
+			} elseif ($globalDebug) {
2278
+				echo "No new version.";
2279
+			}
2280
+		} else {
2281
+			$error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2282
+		}
2068 2283
 		if ($error != '') {
2069 2284
 			return $error;
2070
-		} elseif ($globalDebug) echo "Done\n";
2285
+		} elseif ($globalDebug) {
2286
+			echo "Done\n";
2287
+		}
2071 2288
 		return '';
2072 2289
 	}
2073 2290
 
@@ -2122,68 +2339,114 @@  discard block
 block discarded – undo
2122 2339
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
2123 2340
 		if (extension_loaded('zip')) {
2124 2341
 			if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
2125
-				if ($globalDebug) echo "Unzip...";
2342
+				if ($globalDebug) {
2343
+					echo "Unzip...";
2344
+				}
2126 2345
 				update_db::unzip($tmp_dir.'ivae_feb2013.zip');
2127
-				if ($globalDebug) echo "Add to DB...";
2346
+				if ($globalDebug) {
2347
+					echo "Add to DB...";
2348
+				}
2128 2349
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2129
-				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2350
+				if ($globalDebug) {
2351
+					echo "Copy airlines logos to airlines images directory...";
2352
+				}
2130 2353
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2131
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2132
-				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2133
-			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2134
-		} else $error = "ZIP module not loaded but required for IVAO.";
2354
+					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2355
+						$error = "Failed to copy airlines logo.";
2356
+					}
2357
+				} else {
2358
+					$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2359
+				}
2360
+			} else {
2361
+				$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2362
+			}
2363
+		} else {
2364
+			$error = "ZIP module not loaded but required for IVAO.";
2365
+		}
2135 2366
 		if ($error != '') {
2136 2367
 			return $error;
2137
-		} elseif ($globalDebug) echo "Done\n";
2368
+		} elseif ($globalDebug) {
2369
+			echo "Done\n";
2370
+		}
2138 2371
 		return '';
2139 2372
 	}
2140 2373
 
2141 2374
 	public static function update_routes() {
2142 2375
 		global $tmp_dir, $globalDebug;
2143 2376
 		$error = '';
2144
-		if ($globalDebug) echo "Routes : Download...";
2377
+		if ($globalDebug) {
2378
+			echo "Routes : Download...";
2379
+		}
2145 2380
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2146 2381
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2147
-			if ($globalDebug) echo "Gunzip...";
2382
+			if ($globalDebug) {
2383
+				echo "Gunzip...";
2384
+			}
2148 2385
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
2149
-			if ($globalDebug) echo "Add to DB...";
2386
+			if ($globalDebug) {
2387
+				echo "Add to DB...";
2388
+			}
2150 2389
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
2151
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2390
+		} else {
2391
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2392
+		}
2152 2393
 		if ($error != '') {
2153 2394
 			return $error;
2154
-		} elseif ($globalDebug) echo "Done\n";
2395
+		} elseif ($globalDebug) {
2396
+			echo "Done\n";
2397
+		}
2155 2398
 		return '';
2156 2399
 	}
2157 2400
 	public static function update_oneworld() {
2158 2401
 		global $tmp_dir, $globalDebug;
2159 2402
 		$error = '';
2160
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2403
+		if ($globalDebug) {
2404
+			echo "Schedules Oneworld : Download...";
2405
+		}
2161 2406
 		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2162 2407
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2163
-			if ($globalDebug) echo "Gunzip...";
2408
+			if ($globalDebug) {
2409
+				echo "Gunzip...";
2410
+			}
2164 2411
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
2165
-			if ($globalDebug) echo "Add to DB...";
2412
+			if ($globalDebug) {
2413
+				echo "Add to DB...";
2414
+			}
2166 2415
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
2167
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2416
+		} else {
2417
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2418
+		}
2168 2419
 		if ($error != '') {
2169 2420
 			return $error;
2170
-		} elseif ($globalDebug) echo "Done\n";
2421
+		} elseif ($globalDebug) {
2422
+			echo "Done\n";
2423
+		}
2171 2424
 		return '';
2172 2425
 	}
2173 2426
 	public static function update_skyteam() {
2174 2427
 		global $tmp_dir, $globalDebug;
2175 2428
 		$error = '';
2176
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2429
+		if ($globalDebug) {
2430
+			echo "Schedules Skyteam : Download...";
2431
+		}
2177 2432
 		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2178 2433
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2179
-			if ($globalDebug) echo "Gunzip...";
2434
+			if ($globalDebug) {
2435
+				echo "Gunzip...";
2436
+			}
2180 2437
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
2181
-			if ($globalDebug) echo "Add to DB...";
2438
+			if ($globalDebug) {
2439
+				echo "Add to DB...";
2440
+			}
2182 2441
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
2183
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2442
+		} else {
2443
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2444
+		}
2184 2445
 		if ($error != '') {
2185 2446
 			return $error;
2186
-		} elseif ($globalDebug) echo "Done\n";
2447
+		} elseif ($globalDebug) {
2448
+			echo "Done\n";
2449
+		}
2187 2450
 		return '';
2188 2451
 	}
2189 2452
 	public static function update_ModeS() {
@@ -2200,340 +2463,590 @@  discard block
 block discarded – undo
2200 2463
 			exit;
2201 2464
 		} elseif ($globalDebug) echo "Done\n";
2202 2465
 */
2203
-		if ($globalDebug) echo "Modes : Download...";
2204
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2466
+		if ($globalDebug) {
2467
+			echo "Modes : Download...";
2468
+		}
2469
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2205 2470
 		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2206 2471
 
2207 2472
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2208 2473
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2209
-			if ($globalDebug) echo "Unzip...";
2210
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2474
+			if ($globalDebug) {
2475
+				echo "Unzip...";
2476
+			}
2477
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2211 2478
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2212
-			if ($globalDebug) echo "Add to DB...";
2479
+			if ($globalDebug) {
2480
+				echo "Add to DB...";
2481
+			}
2213 2482
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2214 2483
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2215
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2484
+		} else {
2485
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2486
+		}
2216 2487
 		if ($error != '') {
2217 2488
 			return $error;
2218
-		} elseif ($globalDebug) echo "Done\n";
2489
+		} elseif ($globalDebug) {
2490
+			echo "Done\n";
2491
+		}
2219 2492
 		return '';
2220 2493
 	}
2221 2494
 
2222 2495
 	public static function update_ModeS_faa() {
2223 2496
 		global $tmp_dir, $globalDebug;
2224
-		if ($globalDebug) echo "Modes FAA: Download...";
2497
+		if ($globalDebug) {
2498
+			echo "Modes FAA: Download...";
2499
+		}
2225 2500
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2226 2501
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2227
-			if ($globalDebug) echo "Unzip...";
2502
+			if ($globalDebug) {
2503
+				echo "Unzip...";
2504
+			}
2228 2505
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2229
-			if ($globalDebug) echo "Add to DB...";
2506
+			if ($globalDebug) {
2507
+				echo "Add to DB...";
2508
+			}
2230 2509
 			$error = update_db::modes_faa();
2231
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2510
+		} else {
2511
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2512
+		}
2232 2513
 		if ($error != '') {
2233 2514
 			return $error;
2234
-		} elseif ($globalDebug) echo "Done\n";
2515
+		} elseif ($globalDebug) {
2516
+			echo "Done\n";
2517
+		}
2235 2518
 		return '';
2236 2519
 	}
2237 2520
 
2238 2521
 	public static function update_ModeS_flarm() {
2239 2522
 		global $tmp_dir, $globalDebug;
2240
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2523
+		if ($globalDebug) {
2524
+			echo "Modes Flarmnet: Download...";
2525
+		}
2241 2526
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2242 2527
 		if (file_exists($tmp_dir.'data.fln')) {
2243
-			if ($globalDebug) echo "Add to DB...";
2528
+			if ($globalDebug) {
2529
+				echo "Add to DB...";
2530
+			}
2244 2531
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2245
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2532
+		} else {
2533
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2534
+		}
2246 2535
 		if ($error != '') {
2247 2536
 			return $error;
2248
-		} elseif ($globalDebug) echo "Done\n";
2537
+		} elseif ($globalDebug) {
2538
+			echo "Done\n";
2539
+		}
2249 2540
 		return '';
2250 2541
 	}
2251 2542
 
2252 2543
 	public static function update_ModeS_ogn() {
2253 2544
 		global $tmp_dir, $globalDebug;
2254
-		if ($globalDebug) echo "Modes OGN: Download...";
2545
+		if ($globalDebug) {
2546
+			echo "Modes OGN: Download...";
2547
+		}
2255 2548
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2256 2549
 		if (file_exists($tmp_dir.'ogn.csv')) {
2257
-			if ($globalDebug) echo "Add to DB...";
2550
+			if ($globalDebug) {
2551
+				echo "Add to DB...";
2552
+			}
2258 2553
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2259
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2554
+		} else {
2555
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2556
+		}
2260 2557
 		if ($error != '') {
2261 2558
 			return $error;
2262
-		} elseif ($globalDebug) echo "Done\n";
2559
+		} elseif ($globalDebug) {
2560
+			echo "Done\n";
2561
+		}
2263 2562
 		return '';
2264 2563
 	}
2265 2564
 
2266 2565
 	public static function update_owner() {
2267 2566
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2268 2567
 		
2269
-		if ($globalDebug) echo "Owner France: Download...";
2568
+		if ($globalDebug) {
2569
+			echo "Owner France: Download...";
2570
+		}
2270 2571
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2271 2572
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2272
-			if ($globalDebug) echo "Add to DB...";
2573
+			if ($globalDebug) {
2574
+				echo "Add to DB...";
2575
+			}
2273 2576
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2274
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2577
+		} else {
2578
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2579
+		}
2275 2580
 		if ($error != '') {
2276 2581
 			return $error;
2277
-		} elseif ($globalDebug) echo "Done\n";
2582
+		} elseif ($globalDebug) {
2583
+			echo "Done\n";
2584
+		}
2278 2585
 		
2279
-		if ($globalDebug) echo "Owner Ireland: Download...";
2586
+		if ($globalDebug) {
2587
+			echo "Owner Ireland: Download...";
2588
+		}
2280 2589
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2281 2590
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2282
-			if ($globalDebug) echo "Add to DB...";
2591
+			if ($globalDebug) {
2592
+				echo "Add to DB...";
2593
+			}
2283 2594
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2284
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2595
+		} else {
2596
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2597
+		}
2285 2598
 		if ($error != '') {
2286 2599
 			return $error;
2287
-		} elseif ($globalDebug) echo "Done\n";
2288
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2600
+		} elseif ($globalDebug) {
2601
+			echo "Done\n";
2602
+		}
2603
+		if ($globalDebug) {
2604
+			echo "Owner Switzerland: Download...";
2605
+		}
2289 2606
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2290 2607
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2291
-			if ($globalDebug) echo "Add to DB...";
2608
+			if ($globalDebug) {
2609
+				echo "Add to DB...";
2610
+			}
2292 2611
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2293
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2612
+		} else {
2613
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2614
+		}
2294 2615
 		if ($error != '') {
2295 2616
 			return $error;
2296
-		} elseif ($globalDebug) echo "Done\n";
2297
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2617
+		} elseif ($globalDebug) {
2618
+			echo "Done\n";
2619
+		}
2620
+		if ($globalDebug) {
2621
+			echo "Owner Czech Republic: Download...";
2622
+		}
2298 2623
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2299 2624
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2300
-			if ($globalDebug) echo "Add to DB...";
2625
+			if ($globalDebug) {
2626
+				echo "Add to DB...";
2627
+			}
2301 2628
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2302
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2629
+		} else {
2630
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2631
+		}
2303 2632
 		if ($error != '') {
2304 2633
 			return $error;
2305
-		} elseif ($globalDebug) echo "Done\n";
2306
-		if ($globalDebug) echo "Owner Australia: Download...";
2634
+		} elseif ($globalDebug) {
2635
+			echo "Done\n";
2636
+		}
2637
+		if ($globalDebug) {
2638
+			echo "Owner Australia: Download...";
2639
+		}
2307 2640
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2308 2641
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2309
-			if ($globalDebug) echo "Add to DB...";
2642
+			if ($globalDebug) {
2643
+				echo "Add to DB...";
2644
+			}
2310 2645
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2311
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2646
+		} else {
2647
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2648
+		}
2312 2649
 		if ($error != '') {
2313 2650
 			return $error;
2314
-		} elseif ($globalDebug) echo "Done\n";
2315
-		if ($globalDebug) echo "Owner Austria: Download...";
2651
+		} elseif ($globalDebug) {
2652
+			echo "Done\n";
2653
+		}
2654
+		if ($globalDebug) {
2655
+			echo "Owner Austria: Download...";
2656
+		}
2316 2657
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2317 2658
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2318
-			if ($globalDebug) echo "Add to DB...";
2659
+			if ($globalDebug) {
2660
+				echo "Add to DB...";
2661
+			}
2319 2662
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2320
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2663
+		} else {
2664
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2665
+		}
2321 2666
 		if ($error != '') {
2322 2667
 			return $error;
2323
-		} elseif ($globalDebug) echo "Done\n";
2324
-		if ($globalDebug) echo "Owner Chile: Download...";
2668
+		} elseif ($globalDebug) {
2669
+			echo "Done\n";
2670
+		}
2671
+		if ($globalDebug) {
2672
+			echo "Owner Chile: Download...";
2673
+		}
2325 2674
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2326 2675
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2327
-			if ($globalDebug) echo "Add to DB...";
2676
+			if ($globalDebug) {
2677
+				echo "Add to DB...";
2678
+			}
2328 2679
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2329
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2680
+		} else {
2681
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2682
+		}
2330 2683
 		if ($error != '') {
2331 2684
 			return $error;
2332
-		} elseif ($globalDebug) echo "Done\n";
2333
-		if ($globalDebug) echo "Owner Colombia: Download...";
2685
+		} elseif ($globalDebug) {
2686
+			echo "Done\n";
2687
+		}
2688
+		if ($globalDebug) {
2689
+			echo "Owner Colombia: Download...";
2690
+		}
2334 2691
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2335 2692
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2336
-			if ($globalDebug) echo "Add to DB...";
2693
+			if ($globalDebug) {
2694
+				echo "Add to DB...";
2695
+			}
2337 2696
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2338
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2697
+		} else {
2698
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2699
+		}
2339 2700
 		if ($error != '') {
2340 2701
 			return $error;
2341
-		} elseif ($globalDebug) echo "Done\n";
2342
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2702
+		} elseif ($globalDebug) {
2703
+			echo "Done\n";
2704
+		}
2705
+		if ($globalDebug) {
2706
+			echo "Owner Bosnia Herzegobina: Download...";
2707
+		}
2343 2708
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2344 2709
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2345
-			if ($globalDebug) echo "Add to DB...";
2710
+			if ($globalDebug) {
2711
+				echo "Add to DB...";
2712
+			}
2346 2713
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2347
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2714
+		} else {
2715
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2716
+		}
2348 2717
 		if ($error != '') {
2349 2718
 			return $error;
2350
-		} elseif ($globalDebug) echo "Done\n";
2351
-		if ($globalDebug) echo "Owner Brazil: Download...";
2719
+		} elseif ($globalDebug) {
2720
+			echo "Done\n";
2721
+		}
2722
+		if ($globalDebug) {
2723
+			echo "Owner Brazil: Download...";
2724
+		}
2352 2725
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2353 2726
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2354
-			if ($globalDebug) echo "Add to DB...";
2727
+			if ($globalDebug) {
2728
+				echo "Add to DB...";
2729
+			}
2355 2730
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2356
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2731
+		} else {
2732
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2733
+		}
2357 2734
 		if ($error != '') {
2358 2735
 			return $error;
2359
-		} elseif ($globalDebug) echo "Done\n";
2360
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2736
+		} elseif ($globalDebug) {
2737
+			echo "Done\n";
2738
+		}
2739
+		if ($globalDebug) {
2740
+			echo "Owner Cayman Islands: Download...";
2741
+		}
2361 2742
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2362 2743
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2363
-			if ($globalDebug) echo "Add to DB...";
2744
+			if ($globalDebug) {
2745
+				echo "Add to DB...";
2746
+			}
2364 2747
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2365
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2748
+		} else {
2749
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2750
+		}
2366 2751
 		if ($error != '') {
2367 2752
 			return $error;
2368
-		} elseif ($globalDebug) echo "Done\n";
2369
-		if ($globalDebug) echo "Owner Croatia: Download...";
2753
+		} elseif ($globalDebug) {
2754
+			echo "Done\n";
2755
+		}
2756
+		if ($globalDebug) {
2757
+			echo "Owner Croatia: Download...";
2758
+		}
2370 2759
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2371 2760
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2372
-			if ($globalDebug) echo "Add to DB...";
2761
+			if ($globalDebug) {
2762
+				echo "Add to DB...";
2763
+			}
2373 2764
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2374
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2765
+		} else {
2766
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2767
+		}
2375 2768
 		if ($error != '') {
2376 2769
 			return $error;
2377
-		} elseif ($globalDebug) echo "Done\n";
2378
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2770
+		} elseif ($globalDebug) {
2771
+			echo "Done\n";
2772
+		}
2773
+		if ($globalDebug) {
2774
+			echo "Owner Luxembourg: Download...";
2775
+		}
2379 2776
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2380 2777
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2381
-			if ($globalDebug) echo "Add to DB...";
2778
+			if ($globalDebug) {
2779
+				echo "Add to DB...";
2780
+			}
2382 2781
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2383
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2782
+		} else {
2783
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2784
+		}
2384 2785
 		if ($error != '') {
2385 2786
 			return $error;
2386
-		} elseif ($globalDebug) echo "Done\n";
2387
-		if ($globalDebug) echo "Owner Maldives: Download...";
2787
+		} elseif ($globalDebug) {
2788
+			echo "Done\n";
2789
+		}
2790
+		if ($globalDebug) {
2791
+			echo "Owner Maldives: Download...";
2792
+		}
2388 2793
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2389 2794
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2390
-			if ($globalDebug) echo "Add to DB...";
2795
+			if ($globalDebug) {
2796
+				echo "Add to DB...";
2797
+			}
2391 2798
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2392
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2799
+		} else {
2800
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2801
+		}
2393 2802
 		if ($error != '') {
2394 2803
 			return $error;
2395
-		} elseif ($globalDebug) echo "Done\n";
2396
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2804
+		} elseif ($globalDebug) {
2805
+			echo "Done\n";
2806
+		}
2807
+		if ($globalDebug) {
2808
+			echo "Owner New Zealand: Download...";
2809
+		}
2397 2810
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2398 2811
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2399
-			if ($globalDebug) echo "Add to DB...";
2812
+			if ($globalDebug) {
2813
+				echo "Add to DB...";
2814
+			}
2400 2815
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2401
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2816
+		} else {
2817
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2818
+		}
2402 2819
 		if ($error != '') {
2403 2820
 			return $error;
2404
-		} elseif ($globalDebug) echo "Done\n";
2405
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2821
+		} elseif ($globalDebug) {
2822
+			echo "Done\n";
2823
+		}
2824
+		if ($globalDebug) {
2825
+			echo "Owner Papua New Guinea: Download...";
2826
+		}
2406 2827
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2407 2828
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2408
-			if ($globalDebug) echo "Add to DB...";
2829
+			if ($globalDebug) {
2830
+				echo "Add to DB...";
2831
+			}
2409 2832
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2410
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2833
+		} else {
2834
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2835
+		}
2411 2836
 		if ($error != '') {
2412 2837
 			return $error;
2413
-		} elseif ($globalDebug) echo "Done\n";
2414
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2838
+		} elseif ($globalDebug) {
2839
+			echo "Done\n";
2840
+		}
2841
+		if ($globalDebug) {
2842
+			echo "Owner Slovakia: Download...";
2843
+		}
2415 2844
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2416 2845
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2417
-			if ($globalDebug) echo "Add to DB...";
2846
+			if ($globalDebug) {
2847
+				echo "Add to DB...";
2848
+			}
2418 2849
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2419
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2850
+		} else {
2851
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2852
+		}
2420 2853
 		if ($error != '') {
2421 2854
 			return $error;
2422
-		} elseif ($globalDebug) echo "Done\n";
2423
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2855
+		} elseif ($globalDebug) {
2856
+			echo "Done\n";
2857
+		}
2858
+		if ($globalDebug) {
2859
+			echo "Owner Ecuador: Download...";
2860
+		}
2424 2861
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2425 2862
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2426
-			if ($globalDebug) echo "Add to DB...";
2863
+			if ($globalDebug) {
2864
+				echo "Add to DB...";
2865
+			}
2427 2866
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2428
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2867
+		} else {
2868
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2869
+		}
2429 2870
 		if ($error != '') {
2430 2871
 			return $error;
2431
-		} elseif ($globalDebug) echo "Done\n";
2432
-		if ($globalDebug) echo "Owner Iceland: Download...";
2872
+		} elseif ($globalDebug) {
2873
+			echo "Done\n";
2874
+		}
2875
+		if ($globalDebug) {
2876
+			echo "Owner Iceland: Download...";
2877
+		}
2433 2878
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2434 2879
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2435
-			if ($globalDebug) echo "Add to DB...";
2880
+			if ($globalDebug) {
2881
+				echo "Add to DB...";
2882
+			}
2436 2883
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2437
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2884
+		} else {
2885
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2886
+		}
2438 2887
 		if ($error != '') {
2439 2888
 			return $error;
2440
-		} elseif ($globalDebug) echo "Done\n";
2441
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2889
+		} elseif ($globalDebug) {
2890
+			echo "Done\n";
2891
+		}
2892
+		if ($globalDebug) {
2893
+			echo "Owner Isle of Man: Download...";
2894
+		}
2442 2895
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2443 2896
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2444
-			if ($globalDebug) echo "Add to DB...";
2897
+			if ($globalDebug) {
2898
+				echo "Add to DB...";
2899
+			}
2445 2900
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2446
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2901
+		} else {
2902
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2903
+		}
2447 2904
 		if ($error != '') {
2448 2905
 			return $error;
2449
-		} elseif ($globalDebug) echo "Done\n";
2906
+		} elseif ($globalDebug) {
2907
+			echo "Done\n";
2908
+		}
2450 2909
 		if ($globalMasterSource) {
2451
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2910
+			if ($globalDebug) {
2911
+				echo "ModeS Netherlands: Download...";
2912
+			}
2452 2913
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2453 2914
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2454
-				if ($globalDebug) echo "Add to DB...";
2915
+				if ($globalDebug) {
2916
+					echo "Add to DB...";
2917
+				}
2455 2918
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2456
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2919
+			} else {
2920
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2921
+			}
2457 2922
 			if ($error != '') {
2458 2923
 				return $error;
2459
-			} elseif ($globalDebug) echo "Done\n";
2460
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2924
+			} elseif ($globalDebug) {
2925
+				echo "Done\n";
2926
+			}
2927
+			if ($globalDebug) {
2928
+				echo "ModeS Denmark: Download...";
2929
+			}
2461 2930
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2462 2931
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2463
-				if ($globalDebug) echo "Add to DB...";
2932
+				if ($globalDebug) {
2933
+					echo "Add to DB...";
2934
+				}
2464 2935
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2465
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2936
+			} else {
2937
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2938
+			}
2466 2939
 			if ($error != '') {
2467 2940
 				return $error;
2468
-			} elseif ($globalDebug) echo "Done\n";
2469
-		} elseif ($globalDebug) echo "Done\n";
2941
+			} elseif ($globalDebug) {
2942
+				echo "Done\n";
2943
+			}
2944
+		} elseif ($globalDebug) {
2945
+			echo "Done\n";
2946
+		}
2470 2947
 		return '';
2471 2948
 	}
2472 2949
 
2473 2950
 	public static function update_translation() {
2474 2951
 		global $tmp_dir, $globalDebug;
2475 2952
 		$error = '';
2476
-		if ($globalDebug) echo "Translation : Download...";
2953
+		if ($globalDebug) {
2954
+			echo "Translation : Download...";
2955
+		}
2477 2956
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2478 2957
 		if (file_exists($tmp_dir.'translation.zip')) {
2479
-			if ($globalDebug) echo "Unzip...";
2958
+			if ($globalDebug) {
2959
+				echo "Unzip...";
2960
+			}
2480 2961
 			update_db::unzip($tmp_dir.'translation.zip');
2481
-			if ($globalDebug) echo "Add to DB...";
2962
+			if ($globalDebug) {
2963
+				echo "Add to DB...";
2964
+			}
2482 2965
 			$error = update_db::translation();
2483
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2966
+		} else {
2967
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2968
+		}
2484 2969
 		if ($error != '') {
2485 2970
 			return $error;
2486
-		} elseif ($globalDebug) echo "Done\n";
2971
+		} elseif ($globalDebug) {
2972
+			echo "Done\n";
2973
+		}
2487 2974
 		return '';
2488 2975
 	}
2489 2976
 
2490 2977
 	public static function update_translation_fam() {
2491 2978
 		global $tmp_dir, $globalDebug;
2492 2979
 		$error = '';
2493
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2980
+		if ($globalDebug) {
2981
+			echo "Translation from FlightAirMap website : Download...";
2982
+		}
2494 2983
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2495 2984
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2496 2985
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2497 2986
 			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2498 2987
 			$translation_md5 = $translation_md5_file[0];
2499 2988
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2500
-				if ($globalDebug) echo "Gunzip...";
2989
+				if ($globalDebug) {
2990
+					echo "Gunzip...";
2991
+				}
2501 2992
 				update_db::gunzip($tmp_dir.'translation.tsv.gz');
2502
-				if ($globalDebug) echo "Add to DB...";
2993
+				if ($globalDebug) {
2994
+					echo "Add to DB...";
2995
+				}
2503 2996
 				$error = update_db::translation_fam();
2504
-			} else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2505
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2997
+			} else {
2998
+				$error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2999
+			}
3000
+		} else {
3001
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
3002
+		}
2506 3003
 		if ($error != '') {
2507 3004
 			return $error;
2508
-		} elseif ($globalDebug) echo "Done\n";
3005
+		} elseif ($globalDebug) {
3006
+			echo "Done\n";
3007
+		}
2509 3008
 		return '';
2510 3009
 	}
2511 3010
 	public static function update_ModeS_fam() {
2512 3011
 		global $tmp_dir, $globalDebug;
2513 3012
 		$error = '';
2514
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
3013
+		if ($globalDebug) {
3014
+			echo "ModeS from FlightAirMap website : Download...";
3015
+		}
2515 3016
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2516 3017
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2517 3018
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2518 3019
 			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2519 3020
 			$modes_md5 = $modes_md5_file[0];
2520 3021
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2521
-				if ($globalDebug) echo "Gunzip...";
3022
+				if ($globalDebug) {
3023
+					echo "Gunzip...";
3024
+				}
2522 3025
 				update_db::gunzip($tmp_dir.'modes.tsv.gz');
2523
-				if ($globalDebug) echo "Add to DB...";
3026
+				if ($globalDebug) {
3027
+					echo "Add to DB...";
3028
+				}
2524 3029
 				$error = update_db::modes_fam();
2525
-			} else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2526
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
3030
+			} else {
3031
+				$error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
3032
+			}
3033
+		} else {
3034
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
3035
+		}
2527 3036
 		if ($error != '') {
2528 3037
 			return $error;
2529
-		} elseif ($globalDebug) echo "Done\n";
3038
+		} elseif ($globalDebug) {
3039
+			echo "Done\n";
3040
+		}
2530 3041
 		return '';
2531 3042
 	}
2532 3043
 
2533 3044
 	public static function update_airlines_fam() {
2534 3045
 		global $tmp_dir, $globalDebug;
2535 3046
 		$error = '';
2536
-		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
3047
+		if ($globalDebug) {
3048
+			echo "Airlines from FlightAirMap website : Download...";
3049
+		}
2537 3050
 		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2538 3051
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2539 3052
 			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
@@ -2542,26 +3055,42 @@  discard block
 block discarded – undo
2542 3055
 				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2543 3056
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2544 3057
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2545
-						if ($globalDebug) echo "Gunzip...";
3058
+						if ($globalDebug) {
3059
+							echo "Gunzip...";
3060
+						}
2546 3061
 						update_db::gunzip($tmp_dir.'airlines.tsv.gz');
2547
-						if ($globalDebug) echo "Add to DB...";
3062
+						if ($globalDebug) {
3063
+							echo "Add to DB...";
3064
+						}
2548 3065
 						$error = update_db::airlines_fam();
2549 3066
 						update_db::insert_airlines_version($airlines_md5);
2550
-					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2551
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2552
-			} elseif ($globalDebug) echo "No update.";
2553
-		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
3067
+					} else {
3068
+						$error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
3069
+					}
3070
+			    } else {
3071
+			    	$error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
3072
+			    }
3073
+			} elseif ($globalDebug) {
3074
+				echo "No update.";
3075
+			}
3076
+		} else {
3077
+			$error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
3078
+		}
2554 3079
 		if ($error != '') {
2555 3080
 			return $error;
2556 3081
 		} else {
2557
-			if ($globalDebug) echo "Done\n";
3082
+			if ($globalDebug) {
3083
+				echo "Done\n";
3084
+			}
2558 3085
 		}
2559 3086
 		return '';
2560 3087
 	}
2561 3088
 
2562 3089
 	public static function update_owner_fam() {
2563 3090
 		global $tmp_dir, $globalDebug, $globalOwner;
2564
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
3091
+		if ($globalDebug) {
3092
+			echo "owner from FlightAirMap website : Download...";
3093
+		}
2565 3094
 		$error = '';
2566 3095
 		if ($globalOwner === TRUE) {
2567 3096
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
@@ -2574,55 +3103,89 @@  discard block
 block discarded – undo
2574 3103
 			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2575 3104
 			$owners_md5 = $owners_md5_file[0];
2576 3105
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2577
-				if ($globalDebug) echo "Gunzip...";
3106
+				if ($globalDebug) {
3107
+					echo "Gunzip...";
3108
+				}
2578 3109
 				update_db::gunzip($tmp_dir.'owners.tsv.gz');
2579
-				if ($globalDebug) echo "Add to DB...";
3110
+				if ($globalDebug) {
3111
+					echo "Add to DB...";
3112
+				}
2580 3113
 				$error = update_db::owner_fam();
2581
-			} else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2582
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3114
+			} else {
3115
+				$error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
3116
+			}
3117
+		} else {
3118
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3119
+		}
2583 3120
 		if ($error != '') {
2584 3121
 			return $error;
2585
-		} elseif ($globalDebug) echo "Done\n";
3122
+		} elseif ($globalDebug) {
3123
+			echo "Done\n";
3124
+		}
2586 3125
 		return '';
2587 3126
 	}
2588 3127
 	public static function update_routes_fam() {
2589 3128
 		global $tmp_dir, $globalDebug;
2590
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
3129
+		if ($globalDebug) {
3130
+			echo "Routes from FlightAirMap website : Download...";
3131
+		}
2591 3132
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2592 3133
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2593 3134
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2594 3135
 			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2595 3136
 			$routes_md5 = $routes_md5_file[0];
2596 3137
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2597
-				if ($globalDebug) echo "Gunzip...";
3138
+				if ($globalDebug) {
3139
+					echo "Gunzip...";
3140
+				}
2598 3141
 				update_db::gunzip($tmp_dir.'routes.tsv.gz');
2599
-				if ($globalDebug) echo "Add to DB...";
3142
+				if ($globalDebug) {
3143
+					echo "Add to DB...";
3144
+				}
2600 3145
 				$error = update_db::routes_fam();
2601
-			} else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2602
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3146
+			} else {
3147
+				$error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
3148
+			}
3149
+		} else {
3150
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3151
+		}
2603 3152
 		if ($error != '') {
2604 3153
 			return $error;
2605
-		} elseif ($globalDebug) echo "Done\n";
3154
+		} elseif ($globalDebug) {
3155
+			echo "Done\n";
3156
+		}
2606 3157
 		return '';
2607 3158
 	}
2608 3159
 	public static function update_block_fam() {
2609 3160
 		global $tmp_dir, $globalDebug;
2610
-		if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download...";
3161
+		if ($globalDebug) {
3162
+			echo "Blocked aircraft from FlightAirMap website : Download...";
3163
+		}
2611 3164
 		update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz');
2612 3165
 		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5');
2613 3166
 		if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) {
2614 3167
 			$block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2615 3168
 			$block_md5 = $block_md5_file[0];
2616 3169
 			if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) {
2617
-				if ($globalDebug) echo "Gunzip...";
3170
+				if ($globalDebug) {
3171
+					echo "Gunzip...";
3172
+				}
2618 3173
 				update_db::gunzip($tmp_dir.'block.tsv.gz');
2619
-				if ($globalDebug) echo "Add to DB...";
3174
+				if ($globalDebug) {
3175
+					echo "Add to DB...";
3176
+				}
2620 3177
 				$error = update_db::block_fam();
2621
-			} else $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed.";
2622
-		} else $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed.";
3178
+			} else {
3179
+				$error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed.";
3180
+			}
3181
+		} else {
3182
+			$error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed.";
3183
+		}
2623 3184
 		if ($error != '') {
2624 3185
 			return $error;
2625
-		} elseif ($globalDebug) echo "Done\n";
3186
+		} elseif ($globalDebug) {
3187
+			echo "Done\n";
3188
+		}
2626 3189
 		return '';
2627 3190
 	}
2628 3191
 	public static function update_marine_identity_fam() {
@@ -2632,21 +3195,33 @@  discard block
 block discarded – undo
2632 3195
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2633 3196
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2634 3197
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2635
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
3198
+				if ($globalDebug) {
3199
+					echo "Marine identity from FlightAirMap website : Download...";
3200
+				}
2636 3201
 				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2637 3202
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2638 3203
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2639
-						if ($globalDebug) echo "Gunzip...";
3204
+						if ($globalDebug) {
3205
+							echo "Gunzip...";
3206
+						}
2640 3207
 						update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2641
-						if ($globalDebug) echo "Add to DB...";
3208
+						if ($globalDebug) {
3209
+							echo "Add to DB...";
3210
+						}
2642 3211
 						$error = update_db::marine_identity_fam();
2643
-					} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
2644
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3212
+					} else {
3213
+						$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
3214
+					}
3215
+				} else {
3216
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3217
+				}
2645 3218
 				if ($error != '') {
2646 3219
 					return $error;
2647 3220
 				} else {
2648 3221
 					update_db::insert_marine_identity_version($marine_identity_md5);
2649
-					if ($globalDebug) echo "Done\n";
3222
+					if ($globalDebug) {
3223
+						echo "Done\n";
3224
+					}
2650 3225
 				}
2651 3226
 			}
2652 3227
 		}
@@ -2660,21 +3235,33 @@  discard block
 block discarded – undo
2660 3235
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2661 3236
 			$satellite_md5 = $satellite_md5_file[0];
2662 3237
 			if (!update_db::check_satellite_version($satellite_md5)) {
2663
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
3238
+				if ($globalDebug) {
3239
+					echo "Satellite from FlightAirMap website : Download...";
3240
+				}
2664 3241
 				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2665 3242
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2666 3243
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2667
-						if ($globalDebug) echo "Gunzip...";
3244
+						if ($globalDebug) {
3245
+							echo "Gunzip...";
3246
+						}
2668 3247
 						update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2669
-						if ($globalDebug) echo "Add to DB...";
3248
+						if ($globalDebug) {
3249
+							echo "Add to DB...";
3250
+						}
2670 3251
 						$error = update_db::satellite_fam();
2671
-					} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
2672
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3252
+					} else {
3253
+						$error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
3254
+					}
3255
+				} else {
3256
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3257
+				}
2673 3258
 				if ($error != '') {
2674 3259
 					return $error;
2675 3260
 				} else {
2676 3261
 					update_db::insert_satellite_version($satellite_md5);
2677
-					if ($globalDebug) echo "Done\n";
3262
+					if ($globalDebug) {
3263
+						echo "Done\n";
3264
+					}
2678 3265
 				}
2679 3266
 			}
2680 3267
 		}
@@ -2687,19 +3274,29 @@  discard block
 block discarded – undo
2687 3274
 			$diagrams_md5_file = explode(' ',file_get_contents($tmp_dir.'diagramspdf.md5'));
2688 3275
 			$diagrams_md5 = $diagrams_md5_file[0];
2689 3276
 			if (!update_db::check_diagrams_version($diagrams_md5)) {
2690
-				if ($globalDebug) echo "Airports diagrams from FlightAirMap website : Download...";
3277
+				if ($globalDebug) {
3278
+					echo "Airports diagrams from FlightAirMap website : Download...";
3279
+				}
2691 3280
 				update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf',$tmp_dir.'diagramspdf');
2692 3281
 				if (file_exists($tmp_dir.'diagramspdf')) {
2693 3282
 					if (md5_file($tmp_dir.'diagramspdf') == $diagrams_md5) {
2694
-						if ($globalDebug) echo "Add to DB...";
3283
+						if ($globalDebug) {
3284
+							echo "Add to DB...";
3285
+						}
2695 3286
 						$error = update_db::diagrams_fam();
2696
-					} else $error = "File ".$tmp_dir.'diagramspdf'." md5 failed. Download failed.";
2697
-				} else $error = "File ".$tmp_dir.'diagramspdf'." doesn't exist. Download failed.";
3287
+					} else {
3288
+						$error = "File ".$tmp_dir.'diagramspdf'." md5 failed. Download failed.";
3289
+					}
3290
+				} else {
3291
+					$error = "File ".$tmp_dir.'diagramspdf'." doesn't exist. Download failed.";
3292
+				}
2698 3293
 				if ($error != '') {
2699 3294
 					return $error;
2700 3295
 				} else {
2701 3296
 					update_db::insert_diagrams_version($diagrams_md5);
2702
-					if ($globalDebug) echo "Done\n";
3297
+					if ($globalDebug) {
3298
+						echo "Done\n";
3299
+					}
2703 3300
 				}
2704 3301
 			}
2705 3302
 		}
@@ -2707,17 +3304,25 @@  discard block
 block discarded – undo
2707 3304
 	}
2708 3305
 	public static function update_banned_fam() {
2709 3306
 		global $tmp_dir, $globalDebug;
2710
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
3307
+		if ($globalDebug) {
3308
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
3309
+		}
2711 3310
 		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2712 3311
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2713 3312
 			//if ($globalDebug) echo "Gunzip...";
2714 3313
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2715
-			if ($globalDebug) echo "Add to DB...";
3314
+			if ($globalDebug) {
3315
+				echo "Add to DB...";
3316
+			}
2716 3317
 			$error = update_db::banned_fam();
2717
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3318
+		} else {
3319
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3320
+		}
2718 3321
 		if ($error != '') {
2719 3322
 			return $error;
2720
-		} elseif ($globalDebug) echo "Done\n";
3323
+		} elseif ($globalDebug) {
3324
+			echo "Done\n";
3325
+		}
2721 3326
 		return '';
2722 3327
 	}
2723 3328
 
@@ -2725,7 +3330,9 @@  discard block
 block discarded – undo
2725 3330
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2726 3331
 		include_once('class.create_db.php');
2727 3332
 		$error = '';
2728
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
3333
+		if ($globalDebug) {
3334
+			echo "Airspace from FlightAirMap website : Download...";
3335
+		}
2729 3336
 		if ($globalDBdriver == 'mysql') {
2730 3337
 			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2731 3338
 		} else {
@@ -2742,9 +3349,13 @@  discard block
 block discarded – undo
2742 3349
 				}
2743 3350
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2744 3351
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
2745
-						if ($globalDebug) echo "Gunzip...";
3352
+						if ($globalDebug) {
3353
+							echo "Gunzip...";
3354
+						}
2746 3355
 						update_db::gunzip($tmp_dir.'airspace.sql.gz');
2747
-						if ($globalDebug) echo "Add to DB...";
3356
+						if ($globalDebug) {
3357
+							echo "Add to DB...";
3358
+						}
2748 3359
 						$Connection = new Connection();
2749 3360
 						if ($Connection->tableExists('airspace')) {
2750 3361
 							$query = 'DROP TABLE airspace';
@@ -2757,20 +3368,30 @@  discard block
 block discarded – undo
2757 3368
 						}
2758 3369
 						$error = create_db::import_file($tmp_dir.'airspace.sql');
2759 3370
 						update_db::insert_airspace_version($airspace_md5);
2760
-					} else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
2761
-				} else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3371
+					} else {
3372
+						$error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
3373
+					}
3374
+				} else {
3375
+					$error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3376
+				}
2762 3377
 			}
2763
-		} else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3378
+		} else {
3379
+			$error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3380
+		}
2764 3381
 		if ($error != '') {
2765 3382
 			return $error;
2766
-		} elseif ($globalDebug) echo "Done\n";
3383
+		} elseif ($globalDebug) {
3384
+			echo "Done\n";
3385
+		}
2767 3386
 		return '';
2768 3387
 	}
2769 3388
 
2770 3389
 	public static function update_geoid_fam() {
2771 3390
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2772 3391
 		$error = '';
2773
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3392
+		if ($globalDebug) {
3393
+			echo "Geoid from FlightAirMap website : Download...";
3394
+		}
2774 3395
 		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2775 3396
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2776 3397
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2779,80 +3400,126 @@  discard block
 block discarded – undo
2779 3400
 				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2780 3401
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2781 3402
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2782
-						if ($globalDebug) echo "Gunzip...";
3403
+						if ($globalDebug) {
3404
+							echo "Gunzip...";
3405
+						}
2783 3406
 						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2784 3407
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2785 3408
 							update_db::insert_geoid_version($geoid_md5);
2786
-						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
2787
-					} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
2788
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2789
-			} elseif ($globalDebug) echo 'No new version'."\n";
2790
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3409
+						} else {
3410
+							$error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
3411
+						}
3412
+					} else {
3413
+						$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
3414
+					}
3415
+				} else {
3416
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3417
+				}
3418
+			} elseif ($globalDebug) {
3419
+				echo 'No new version'."\n";
3420
+			}
3421
+		} else {
3422
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3423
+		}
2791 3424
 		if ($error != '') {
2792 3425
 			return $error;
2793
-		} elseif ($globalDebug) echo "Done\n";
3426
+		} elseif ($globalDebug) {
3427
+			echo "Done\n";
3428
+		}
2794 3429
 		return '';
2795 3430
 	}
2796 3431
 
2797 3432
 	public static function update_tle() {
2798 3433
 		global $tmp_dir, $globalDebug;
2799
-		if ($globalDebug) echo "Download TLE : Download...";
3434
+		if ($globalDebug) {
3435
+			echo "Download TLE : Download...";
3436
+		}
2800 3437
 		$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',
2801 3438
 		'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',
2802 3439
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2803 3440
 		foreach ($alltle as $filename) {
2804
-			if ($globalDebug) echo "downloading ".$filename.'...';
3441
+			if ($globalDebug) {
3442
+				echo "downloading ".$filename.'...';
3443
+			}
2805 3444
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2806 3445
 			if (file_exists($tmp_dir.$filename)) {
2807
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3446
+				if ($globalDebug) {
3447
+					echo "Add to DB ".$filename."...";
3448
+				}
2808 3449
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2809
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3450
+			} else {
3451
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3452
+			}
2810 3453
 			if ($error != '') {
2811 3454
 				echo $error."\n";
2812
-			} elseif ($globalDebug) echo "Done\n";
3455
+			} elseif ($globalDebug) {
3456
+				echo "Done\n";
3457
+			}
2813 3458
 		}
2814 3459
 		return '';
2815 3460
 	}
2816 3461
 
2817 3462
 	public static function update_ucsdb() {
2818 3463
 		global $tmp_dir, $globalDebug;
2819
-		if ($globalDebug) echo "Download UCS DB : Download...";
3464
+		if ($globalDebug) {
3465
+			echo "Download UCS DB : Download...";
3466
+		}
2820 3467
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/9-1-17-update/UCS_Satellite_Database_officialname_9-1-2017.txt',$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
2821 3468
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2822
-			if ($globalDebug) echo "Add to DB...";
3469
+			if ($globalDebug) {
3470
+				echo "Add to DB...";
3471
+			}
2823 3472
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
2824
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'." doesn't exist. Download failed.";
3473
+		} else {
3474
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'." doesn't exist. Download failed.";
3475
+		}
2825 3476
 		if ($error != '') {
2826 3477
 			echo $error."\n";
2827
-		} elseif ($globalDebug) echo "Done\n";
3478
+		} elseif ($globalDebug) {
3479
+			echo "Done\n";
3480
+		}
2828 3481
 		return '';
2829 3482
 	}
2830 3483
 
2831 3484
 	public static function update_celestrak() {
2832 3485
 		global $tmp_dir, $globalDebug;
2833
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3486
+		if ($globalDebug) {
3487
+			echo "Download Celestrak DB : Download...";
3488
+		}
2834 3489
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2835 3490
 		if (file_exists($tmp_dir.'satcat.txt')) {
2836
-			if ($globalDebug) echo "Add to DB...";
3491
+			if ($globalDebug) {
3492
+				echo "Add to DB...";
3493
+			}
2837 3494
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2838
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3495
+		} else {
3496
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3497
+		}
2839 3498
 		if ($error != '') {
2840 3499
 			echo $error."\n";
2841
-		} elseif ($globalDebug) echo "Done\n";
3500
+		} elseif ($globalDebug) {
3501
+			echo "Done\n";
3502
+		}
2842 3503
 		return '';
2843 3504
 	}
2844 3505
 
2845 3506
 	public static function update_models() {
2846 3507
 		global $tmp_dir, $globalDebug;
2847 3508
 		$error = '';
2848
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3509
+		if ($globalDebug) {
3510
+			echo "Models from FlightAirMap website : Download...";
3511
+		}
2849 3512
 		if (!is_writable(dirname(__FILE__).'/../models')) {
2850
-			if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !';
3513
+			if ($globalDebug) {
3514
+				echo dirname(__FILE__).'/../models'.' is not writable !';
3515
+			}
2851 3516
 			return '';
2852 3517
 		}
2853 3518
 		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2854 3519
 		if (file_exists($tmp_dir.'models.md5sum')) {
2855
-			if ($globalDebug) echo "Check files...\n";
3520
+			if ($globalDebug) {
3521
+				echo "Check files...\n";
3522
+			}
2856 3523
 			$newmodelsdb = array();
2857 3524
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2858 3525
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2871,18 +3538,28 @@  discard block
 block discarded – undo
2871 3538
 			}
2872 3539
 			$diff = array_diff($newmodelsdb,$modelsdb);
2873 3540
 			foreach ($diff as $key => $value) {
2874
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3541
+				if ($globalDebug) {
3542
+					echo 'Downloading model '.$key.' ...'."\n";
3543
+				}
2875 3544
 				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2876 3545
 			}
2877 3546
 			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2878
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3547
+		} else {
3548
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3549
+		}
2879 3550
 		if ($error != '') {
2880 3551
 			return $error;
2881
-		} elseif ($globalDebug) echo "Done\n";
2882
-		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
3552
+		} elseif ($globalDebug) {
3553
+			echo "Done\n";
3554
+		}
3555
+		if ($globalDebug) {
3556
+			echo "glTF 2.0 Models from FlightAirMap website : Download...";
3557
+		}
2883 3558
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2884 3559
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2885
-			if ($globalDebug) echo "Check files...\n";
3560
+			if ($globalDebug) {
3561
+				echo "Check files...\n";
3562
+			}
2886 3563
 			$newmodelsdb = array();
2887 3564
 			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2888 3565
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2901,29 +3578,43 @@  discard block
 block discarded – undo
2901 3578
 			}
2902 3579
 			$diff = array_diff($newmodelsdb,$modelsdb);
2903 3580
 			foreach ($diff as $key => $value) {
2904
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3581
+				if ($globalDebug) {
3582
+					echo 'Downloading model '.$key.' ...'."\n";
3583
+				}
2905 3584
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2906 3585
 				
2907 3586
 			}
2908 3587
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2909
-		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3588
+		} else {
3589
+			$error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3590
+		}
2910 3591
 		if ($error != '') {
2911 3592
 			return $error;
2912
-		} elseif ($globalDebug) echo "Done\n";
3593
+		} elseif ($globalDebug) {
3594
+			echo "Done\n";
3595
+		}
2913 3596
 		return '';
2914 3597
 	}
2915 3598
 	public static function update_weather_models() {
2916 3599
 		global $tmp_dir, $globalDebug;
2917 3600
 		$error = '';
2918
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3601
+		if ($globalDebug) {
3602
+			echo "Models from FlightAirMap website : Download...";
3603
+		}
2919 3604
 		if (!is_writable(dirname(__FILE__).'/../models/gltf2/weather')) {
2920
-			if ($globalDebug) echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !';
3605
+			if ($globalDebug) {
3606
+				echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !';
3607
+			}
2921 3608
 			return '';
2922 3609
 		}
2923
-		if ($globalDebug) echo "Weather Models from FlightAirMap website : Download...";
3610
+		if ($globalDebug) {
3611
+			echo "Weather Models from FlightAirMap website : Download...";
3612
+		}
2924 3613
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum');
2925 3614
 		if (file_exists($tmp_dir.'modelsweather.md5sum')) {
2926
-			if ($globalDebug) echo "Check files...\n";
3615
+			if ($globalDebug) {
3616
+				echo "Check files...\n";
3617
+			}
2927 3618
 			$newmodelsdb = array();
2928 3619
 			if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) {
2929 3620
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2942,25 +3633,35 @@  discard block
 block discarded – undo
2942 3633
 			}
2943 3634
 			$diff = array_diff($newmodelsdb,$modelsdb);
2944 3635
 			foreach ($diff as $key => $value) {
2945
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3636
+				if ($globalDebug) {
3637
+					echo 'Downloading model '.$key.' ...'."\n";
3638
+				}
2946 3639
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2947 3640
 				
2948 3641
 			}
2949 3642
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2950
-		} else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
3643
+		} else {
3644
+			$error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
3645
+		}
2951 3646
 		if ($error != '') {
2952 3647
 			return $error;
2953
-		} elseif ($globalDebug) echo "Done\n";
3648
+		} elseif ($globalDebug) {
3649
+			echo "Done\n";
3650
+		}
2954 3651
 		return '';
2955 3652
 	}
2956 3653
 
2957 3654
 	public static function update_liveries() {
2958 3655
 		global $tmp_dir, $globalDebug;
2959 3656
 		$error = '';
2960
-		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
3657
+		if ($globalDebug) {
3658
+			echo "Liveries from FlightAirMap website : Download...";
3659
+		}
2961 3660
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2962 3661
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2963
-			if ($globalDebug) echo "Check files...\n";
3662
+			if ($globalDebug) {
3663
+				echo "Check files...\n";
3664
+			}
2964 3665
 			$newmodelsdb = array();
2965 3666
 			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2966 3667
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2979,15 +3680,21 @@  discard block
 block discarded – undo
2979 3680
 			}
2980 3681
 			$diff = array_diff($newmodelsdb,$modelsdb);
2981 3682
 			foreach ($diff as $key => $value) {
2982
-				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
3683
+				if ($globalDebug) {
3684
+					echo 'Downloading liveries '.$key.' ...'."\n";
3685
+				}
2983 3686
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2984 3687
 				
2985 3688
 			}
2986 3689
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2987
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3690
+		} else {
3691
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3692
+		}
2988 3693
 		if ($error != '') {
2989 3694
 			return $error;
2990
-		} elseif ($globalDebug) echo "Done\n";
3695
+		} elseif ($globalDebug) {
3696
+			echo "Done\n";
3697
+		}
2991 3698
 		return '';
2992 3699
 	}
2993 3700
 
@@ -2995,13 +3702,19 @@  discard block
 block discarded – undo
2995 3702
 		global $tmp_dir, $globalDebug;
2996 3703
 		$error = '';
2997 3704
 		if (!is_writable(dirname(__FILE__).'/../models')) {
2998
-			if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !';
3705
+			if ($globalDebug) {
3706
+				echo dirname(__FILE__).'/../models'.' is not writable !';
3707
+			}
2999 3708
 			return '';
3000 3709
 		}
3001
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3710
+		if ($globalDebug) {
3711
+			echo "Space models from FlightAirMap website : Download...";
3712
+		}
3002 3713
 		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
3003 3714
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
3004
-			if ($globalDebug) echo "Check files...\n";
3715
+			if ($globalDebug) {
3716
+				echo "Check files...\n";
3717
+			}
3005 3718
 			$newmodelsdb = array();
3006 3719
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
3007 3720
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -3020,15 +3733,21 @@  discard block
 block discarded – undo
3020 3733
 			}
3021 3734
 			$diff = array_diff($newmodelsdb,$modelsdb);
3022 3735
 			foreach ($diff as $key => $value) {
3023
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3736
+				if ($globalDebug) {
3737
+					echo 'Downloading space model '.$key.' ...'."\n";
3738
+				}
3024 3739
 				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
3025 3740
 				
3026 3741
 			}
3027 3742
 			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
3028
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3743
+		} else {
3744
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3745
+		}
3029 3746
 		if ($error != '') {
3030 3747
 			return $error;
3031
-		} elseif ($globalDebug) echo "Done\n";
3748
+		} elseif ($globalDebug) {
3749
+			echo "Done\n";
3750
+		}
3032 3751
 		return '';
3033 3752
 	}
3034 3753
 
@@ -3036,13 +3755,19 @@  discard block
 block discarded – undo
3036 3755
 		global $tmp_dir, $globalDebug;
3037 3756
 		$error = '';
3038 3757
 		if (!is_writable(dirname(__FILE__).'/../models/vehicules')) {
3039
-			if ($globalDebug) echo dirname(__FILE__).'/../models/vehicules'.' is not writable !';
3758
+			if ($globalDebug) {
3759
+				echo dirname(__FILE__).'/../models/vehicules'.' is not writable !';
3760
+			}
3040 3761
 			return '';
3041 3762
 		}
3042
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3763
+		if ($globalDebug) {
3764
+			echo "Vehicules models from FlightAirMap website : Download...";
3765
+		}
3043 3766
 		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
3044 3767
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
3045
-			if ($globalDebug) echo "Check files...\n";
3768
+			if ($globalDebug) {
3769
+				echo "Check files...\n";
3770
+			}
3046 3771
 			$newmodelsdb = array();
3047 3772
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
3048 3773
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -3061,15 +3786,21 @@  discard block
 block discarded – undo
3061 3786
 			}
3062 3787
 			$diff = array_diff($newmodelsdb,$modelsdb);
3063 3788
 			foreach ($diff as $key => $value) {
3064
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3789
+				if ($globalDebug) {
3790
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3791
+				}
3065 3792
 				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
3066 3793
 				
3067 3794
 			}
3068 3795
 			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
3069
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3796
+		} else {
3797
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3798
+		}
3070 3799
 		if ($error != '') {
3071 3800
 			return $error;
3072
-		} elseif ($globalDebug) echo "Done\n";
3801
+		} elseif ($globalDebug) {
3802
+			echo "Done\n";
3803
+		}
3073 3804
 		return '';
3074 3805
 	}
3075 3806
 
@@ -3142,7 +3873,9 @@  discard block
 block discarded – undo
3142 3873
                 }
3143 3874
 
3144 3875
 		$error = '';
3145
-		if ($globalDebug) echo "Notam : Download...";
3876
+		if ($globalDebug) {
3877
+			echo "Notam : Download...";
3878
+		}
3146 3879
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
3147 3880
 		if (file_exists($tmp_dir.'notam.rss')) {
3148 3881
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -3157,14 +3890,30 @@  discard block
 block discarded – undo
3157 3890
 				$data['fir'] = $q[0];
3158 3891
 				$data['code'] = $q[1];
3159 3892
 				$ifrvfr = $q[2];
3160
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
3161
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
3162
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
3163
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
3164
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
3165
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
3166
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
3167
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3893
+				if ($ifrvfr == 'IV') {
3894
+					$data['rules'] = 'IFR/VFR';
3895
+				}
3896
+				if ($ifrvfr == 'I') {
3897
+					$data['rules'] = 'IFR';
3898
+				}
3899
+				if ($ifrvfr == 'V') {
3900
+					$data['rules'] = 'VFR';
3901
+				}
3902
+				if ($q[4] == 'A') {
3903
+					$data['scope'] = 'Airport warning';
3904
+				}
3905
+				if ($q[4] == 'E') {
3906
+					$data['scope'] = 'Enroute warning';
3907
+				}
3908
+				if ($q[4] == 'W') {
3909
+					$data['scope'] = 'Navigation warning';
3910
+				}
3911
+				if ($q[4] == 'AE') {
3912
+					$data['scope'] = 'Airport/Enroute warning';
3913
+				}
3914
+				if ($q[4] == 'AW') {
3915
+					$data['scope'] = 'Airport/Navigation warning';
3916
+				}
3168 3917
 				//$data['scope'] = $q[4];
3169 3918
 				$data['lower_limit'] = $q[5];
3170 3919
 				$data['upper_limit'] = $q[6];
@@ -3172,8 +3921,12 @@  discard block
 block discarded – undo
3172 3921
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
3173 3922
 				$latitude = $Common->convertDec($las,'latitude');
3174 3923
 				$longitude = $Common->convertDec($lns,'longitude');
3175
-				if ($lac == 'S') $latitude = '-'.$latitude;
3176
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3924
+				if ($lac == 'S') {
3925
+					$latitude = '-'.$latitude;
3926
+				}
3927
+				if ($lnc == 'W') {
3928
+					$longitude = '-'.$longitude;
3929
+				}
3177 3930
 				$data['center_latitude'] = $latitude;
3178 3931
 				$data['center_longitude'] = $longitude;
3179 3932
 				$data['radius'] = intval($radius);
@@ -3203,10 +3956,14 @@  discard block
 block discarded – undo
3203 3956
 				$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']);
3204 3957
 				unset($data);
3205 3958
 			} 
3206
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3959
+		} else {
3960
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3961
+		}
3207 3962
 		if ($error != '') {
3208 3963
 			return $error;
3209
-		} elseif ($globalDebug) echo "Done\n";
3964
+		} elseif ($globalDebug) {
3965
+			echo "Done\n";
3966
+		}
3210 3967
 		return '';
3211 3968
 	}
3212 3969
 	
@@ -3231,7 +3988,9 @@  discard block
 block discarded – undo
3231 3988
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3232 3989
 		$airspace_json = json_decode($airspace_lst,true);
3233 3990
 		foreach ($airspace_json['records'] as $airspace) {
3234
-			if ($globalDebug) echo $airspace['name']."...\n";
3991
+			if ($globalDebug) {
3992
+				echo $airspace['name']."...\n";
3993
+			}
3235 3994
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3236 3995
 			if (file_exists($tmp_dir.$airspace['name'])) {
3237 3996
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -3275,8 +4034,11 @@  discard block
 block discarded – undo
3275 4034
                         return "error : ".$e->getMessage();
3276 4035
                 }
3277 4036
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3278
-                if ($row['nb'] > 0) return false;
3279
-                else return true;
4037
+                if ($row['nb'] > 0) {
4038
+                	return false;
4039
+                } else {
4040
+                	return true;
4041
+                }
3280 4042
 	}
3281 4043
 
3282 4044
 	public static function insert_last_update() {
@@ -3301,8 +4063,11 @@  discard block
 block discarded – undo
3301 4063
                         return "error : ".$e->getMessage();
3302 4064
                 }
3303 4065
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3304
-                if ($row['nb'] > 0) return true;
3305
-                else return false;
4066
+                if ($row['nb'] > 0) {
4067
+                	return true;
4068
+                } else {
4069
+                	return false;
4070
+                }
3306 4071
 	}
3307 4072
 
3308 4073
 	public static function check_geoid_version($version) {
@@ -3315,8 +4080,11 @@  discard block
 block discarded – undo
3315 4080
                         return "error : ".$e->getMessage();
3316 4081
                 }
3317 4082
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3318
-                if ($row['nb'] > 0) return true;
3319
-                else return false;
4083
+                if ($row['nb'] > 0) {
4084
+                	return true;
4085
+                } else {
4086
+                	return false;
4087
+                }
3320 4088
 	}
3321 4089
 
3322 4090
 	public static function check_marine_identity_version($version) {
@@ -3329,8 +4097,11 @@  discard block
 block discarded – undo
3329 4097
 			return "error : ".$e->getMessage();
3330 4098
 		}
3331 4099
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3332
-		if ($row['nb'] > 0) return true;
3333
-		else return false;
4100
+		if ($row['nb'] > 0) {
4101
+			return true;
4102
+		} else {
4103
+			return false;
4104
+		}
3334 4105
 	}
3335 4106
 
3336 4107
 	public static function check_satellite_version($version) {
@@ -3343,8 +4114,11 @@  discard block
 block discarded – undo
3343 4114
 			return "error : ".$e->getMessage();
3344 4115
 		}
3345 4116
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3346
-		if ($row['nb'] > 0) return true;
3347
-		else return false;
4117
+		if ($row['nb'] > 0) {
4118
+			return true;
4119
+		} else {
4120
+			return false;
4121
+		}
3348 4122
 	}
3349 4123
 	public static function check_diagrams_version($version) {
3350 4124
 		$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'diagrams_version' AND value = :version";
@@ -3356,8 +4130,11 @@  discard block
 block discarded – undo
3356 4130
 			return "error : ".$e->getMessage();
3357 4131
 		}
3358 4132
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3359
-		if ($row['nb'] > 0) return true;
3360
-		else return false;
4133
+		if ($row['nb'] > 0) {
4134
+			return true;
4135
+		} else {
4136
+			return false;
4137
+		}
3361 4138
 	}
3362 4139
 
3363 4140
 	public static function check_airlines_version($version) {
@@ -3370,8 +4147,11 @@  discard block
 block discarded – undo
3370 4147
 			return "error : ".$e->getMessage();
3371 4148
 		}
3372 4149
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3373
-		if ($row['nb'] > 0) return true;
3374
-		else return false;
4150
+		if ($row['nb'] > 0) {
4151
+			return true;
4152
+		} else {
4153
+			return false;
4154
+		}
3375 4155
 	}
3376 4156
 
3377 4157
 	public static function check_notam_version($version) {
@@ -3384,8 +4164,11 @@  discard block
 block discarded – undo
3384 4164
 			return "error : ".$e->getMessage();
3385 4165
 		}
3386 4166
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3387
-		if ($row['nb'] > 0) return true;
3388
-		else return false;
4167
+		if ($row['nb'] > 0) {
4168
+			return true;
4169
+		} else {
4170
+			return false;
4171
+		}
3389 4172
 	}
3390 4173
 
3391 4174
 	public static function insert_airlines_version($version) {
@@ -3486,8 +4269,11 @@  discard block
 block discarded – undo
3486 4269
                         return "error : ".$e->getMessage();
3487 4270
                 }
3488 4271
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3489
-                if ($row['nb'] > 0) return false;
3490
-                else return true;
4272
+                if ($row['nb'] > 0) {
4273
+                	return false;
4274
+                } else {
4275
+                	return true;
4276
+                }
3491 4277
 	}
3492 4278
 
3493 4279
 	public static function insert_last_notam_update() {
@@ -3517,8 +4303,11 @@  discard block
 block discarded – undo
3517 4303
                         return "error : ".$e->getMessage();
3518 4304
                 }
3519 4305
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3520
-                if ($row['nb'] > 0) return false;
3521
-                else return true;
4306
+                if ($row['nb'] > 0) {
4307
+                	return false;
4308
+                } else {
4309
+                	return true;
4310
+                }
3522 4311
 	}
3523 4312
 
3524 4313
 	public static function insert_last_airspace_update() {
@@ -3548,8 +4337,11 @@  discard block
 block discarded – undo
3548 4337
                         return "error : ".$e->getMessage();
3549 4338
                 }
3550 4339
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3551
-                if ($row['nb'] > 0) return false;
3552
-                else return true;
4340
+                if ($row['nb'] > 0) {
4341
+                	return false;
4342
+                } else {
4343
+                	return true;
4344
+                }
3553 4345
 	}
3554 4346
 
3555 4347
 	public static function insert_last_geoid_update() {
@@ -3579,8 +4371,11 @@  discard block
 block discarded – undo
3579 4371
 			return "error : ".$e->getMessage();
3580 4372
 		}
3581 4373
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3582
-		if ($row['nb'] > 0) return false;
3583
-		else return true;
4374
+		if ($row['nb'] > 0) {
4375
+			return false;
4376
+		} else {
4377
+			return true;
4378
+		}
3584 4379
 	}
3585 4380
 
3586 4381
 	public static function insert_last_owner_update() {
@@ -3610,8 +4405,11 @@  discard block
 block discarded – undo
3610 4405
 			return "error : ".$e->getMessage();
3611 4406
 		}
3612 4407
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3613
-		if ($row['nb'] > 0) return false;
3614
-		else return true;
4408
+		if ($row['nb'] > 0) {
4409
+			return false;
4410
+		} else {
4411
+			return true;
4412
+		}
3615 4413
 	}
3616 4414
 
3617 4415
 	public static function insert_last_fires_update() {
@@ -3641,8 +4439,11 @@  discard block
 block discarded – undo
3641 4439
 			return "error : ".$e->getMessage();
3642 4440
 		}
3643 4441
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3644
-		if ($row['nb'] > 0) return false;
3645
-		else return true;
4442
+		if ($row['nb'] > 0) {
4443
+			return false;
4444
+		} else {
4445
+			return true;
4446
+		}
3646 4447
 	}
3647 4448
 
3648 4449
 	public static function insert_last_airlines_update() {
@@ -3672,8 +4473,11 @@  discard block
 block discarded – undo
3672 4473
                         return "error : ".$e->getMessage();
3673 4474
                 }
3674 4475
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3675
-                if ($row['nb'] > 0) return false;
3676
-                else return true;
4476
+                if ($row['nb'] > 0) {
4477
+                	return false;
4478
+                } else {
4479
+                	return true;
4480
+                }
3677 4481
 	}
3678 4482
 
3679 4483
 	public static function insert_last_schedules_update() {
@@ -3703,8 +4507,11 @@  discard block
 block discarded – undo
3703 4507
 			return "error : ".$e->getMessage();
3704 4508
 		}
3705 4509
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3706
-		if ($row['nb'] > 0) return false;
3707
-		else return true;
4510
+		if ($row['nb'] > 0) {
4511
+			return false;
4512
+		} else {
4513
+			return true;
4514
+		}
3708 4515
 	}
3709 4516
 
3710 4517
 	public static function insert_last_tle_update() {
@@ -3734,8 +4541,11 @@  discard block
 block discarded – undo
3734 4541
 			return "error : ".$e->getMessage();
3735 4542
 		}
3736 4543
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3737
-		if ($row['nb'] > 0) return false;
3738
-		else return true;
4544
+		if ($row['nb'] > 0) {
4545
+			return false;
4546
+		} else {
4547
+			return true;
4548
+		}
3739 4549
 	}
3740 4550
 
3741 4551
 	public static function insert_last_ucsdb_update() {
@@ -3765,8 +4575,11 @@  discard block
 block discarded – undo
3765 4575
 			return "error : ".$e->getMessage();
3766 4576
 		}
3767 4577
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3768
-		if ($row['nb'] > 0) return false;
3769
-		else return true;
4578
+		if ($row['nb'] > 0) {
4579
+			return false;
4580
+		} else {
4581
+			return true;
4582
+		}
3770 4583
 	}
3771 4584
 
3772 4585
 	public static function insert_last_celestrak_update() {
@@ -3796,8 +4609,11 @@  discard block
 block discarded – undo
3796 4609
 			return "error : ".$e->getMessage();
3797 4610
 		}
3798 4611
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3799
-		if ($row['nb'] > 0) return false;
3800
-		else return true;
4612
+		if ($row['nb'] > 0) {
4613
+			return false;
4614
+		} else {
4615
+			return true;
4616
+		}
3801 4617
 	}
3802 4618
 
3803 4619
 	public static function check_last_satellite_update() {
@@ -3815,8 +4631,11 @@  discard block
 block discarded – undo
3815 4631
 			return "error : ".$e->getMessage();
3816 4632
 		}
3817 4633
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3818
-		if ($row['nb'] > 0) return false;
3819
-		else return true;
4634
+		if ($row['nb'] > 0) {
4635
+			return false;
4636
+		} else {
4637
+			return true;
4638
+		}
3820 4639
 	}
3821 4640
 
3822 4641
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
airline-detailed.php 1 patch
Braces   +31 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		$limit_start = 0;
15 15
 		$limit_end = 25;
16 16
 		$absolute_difference = 25;
17
-	}  else {
17
+	} else {
18 18
 		$limit_explode = explode(",", $_GET['limit']);
19 19
 		$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
20 20
 		$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
 				$title = sprintf(_("Detailed View for %s (%s)"),$airline_info[0]['name'],$airline_info[0]['icao']);
56 56
 			} elseif (isset($spotter_array[0]['airline_name']) && isset($spotter_array[0]['airline_icao'])) {
57 57
 				$title = sprintf(_("Detailed View for %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']);
58
-			} else $title = '';
58
+			} else {
59
+				$title = '';
60
+			}
59 61
 		}
60 62
 		require_once('header.php');
61 63
 	  
@@ -76,7 +78,9 @@  discard block
 block discarded – undo
76 78
 		}
77 79
 		$Stats = new Stats();
78 80
 		$airline_names = $Stats->getAllAirlineNames();
79
-		if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames();
81
+		if (empty($airline_names)) {
82
+			$airline_names = $Spotter->getAllAirlineNames();
83
+		}
80 84
 		foreach($airline_names as $airline_name)
81 85
 		{
82 86
 			if($airline == $airline_name['airline_icao'])
@@ -108,12 +112,22 @@  discard block
 block discarded – undo
108 112
 					print '<div><span class="label">'._("Name").'</span>'.$airline_info[0]['name'].'</div>';
109 113
 					print '<div><span class="label">'._("Country").'</span>'.$airline_info[0]['country'].'</div>';
110 114
 					print '<div><span class="label">'._("ICAO").'</span>'.$airline_info[0]['icao'].'</div>';
111
-					if ($airline_info[0]['iata'] != '') print '<div><span class="label">'._("IATA").'</span>'.$airline_info[0]['iata'].'</div>';
112
-					if ($airline_info[0]['callsign'] != '') print '<div><span class="label">'._("Callsign").'</span>'.$airline_info[0]['callsign'].'</div>'; 
115
+					if ($airline_info[0]['iata'] != '') {
116
+						print '<div><span class="label">'._("IATA").'</span>'.$airline_info[0]['iata'].'</div>';
117
+					}
118
+					if ($airline_info[0]['callsign'] != '') {
119
+						print '<div><span class="label">'._("Callsign").'</span>'.$airline_info[0]['callsign'].'</div>';
120
+					}
113 121
 					print '<div><span class="label">'._("Type").'</span>'.ucwords($airline_info[0]['type']).'</div>';
114
-					if (isset($airline_info[0]['home_link']) && $airline_info[0]['home_link'] != '') print '<div><a href="'.$airline_info[0]['home_link'].'"><i class="fa fa-home"></i></a></div>';
115
-					if (isset($airline_info[0]['wikipedia_link']) && $airline_info[0]['wikipedia_link'] != '') print '<div><a href="'.$airline_info[0]['wikipedia_link'].'"><i class="fa fa-wikipedia-w"></i></a></div>';
116
-					if (isset($airline_info[0]['ban_eu']) && $airline_info[0]['ban_eu'] == 1) print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
122
+					if (isset($airline_info[0]['home_link']) && $airline_info[0]['home_link'] != '') {
123
+						print '<div><a href="'.$airline_info[0]['home_link'].'"><i class="fa fa-home"></i></a></div>';
124
+					}
125
+					if (isset($airline_info[0]['wikipedia_link']) && $airline_info[0]['wikipedia_link'] != '') {
126
+						print '<div><a href="'.$airline_info[0]['wikipedia_link'].'"><i class="fa fa-wikipedia-w"></i></a></div>';
127
+					}
128
+					if (isset($airline_info[0]['ban_eu']) && $airline_info[0]['ban_eu'] == 1) {
129
+						print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
130
+					}
117 131
 					print '</div>';
118 132
 				
119 133
 				} else {
@@ -129,10 +143,16 @@  discard block
 block discarded – undo
129 143
 					print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['airline_name'].'</div>';
130 144
 					print '<div><span class="label">'._("Country").'</span>'.$spotter_array[0]['airline_country'].'</div>';
131 145
 					print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['airline_icao'].'</div>';
132
-					if (isset($spotter_array[0]['airline_iata']) && $spotter_array[0]['airline_iata'] != '') print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>';
133
-					if (isset($spotter_array[0]['airline_callsign']) && $spotter_array[0]['airline_callsign'] != '') print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; 
146
+					if (isset($spotter_array[0]['airline_iata']) && $spotter_array[0]['airline_iata'] != '') {
147
+						print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>';
148
+					}
149
+					if (isset($spotter_array[0]['airline_callsign']) && $spotter_array[0]['airline_callsign'] != '') {
150
+						print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>';
151
+					}
134 152
 					print '<div><span class="label">'._("Type").'</span>'.ucwords($spotter_array[0]['airline_type']).'</div>';
135
-					if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
153
+					if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) {
154
+						print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
155
+					}
136 156
 					print '</div>';
137 157
 				}
138 158
 			} else {
Please login to merge, or discard this patch.
table-output.php 1 patch
Braces   +78 added lines, -29 removed lines patch added patch discarded remove patch
@@ -7,8 +7,10 @@  discard block
 block discarded – undo
7 7
 $showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
8 8
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
9 9
 	$showDuration = $Common->multiKeyExists($spotter_array,'race_time');
10
-	if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array,'duration');
11
-} else {
10
+	if ($showDuration === false) {
11
+		$showDuration = $Common->multiKeyExists($spotter_array,'duration');
12
+	}
13
+	} else {
12 14
 	$showDuration = $Common->multiKeyExists($spotter_array,'duration');
13 15
 }
14 16
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
@@ -16,7 +18,9 @@  discard block
 block discarded – undo
16 18
 }
17 19
 
18 20
 
19
-if (!isset($type)) $type = 'aircraft';
21
+if (!isset($type)) {
22
+	$type = 'aircraft';
23
+}
20 24
 
21 25
 if (!isset($_GET['sort'])) 
22 26
 {
@@ -592,7 +596,9 @@  discard block
 block discarded – undo
592 596
 	if (isset($globalTimezone))
593 597
 	{
594 598
 		date_default_timezone_set($globalTimezone);
595
-	} else date_default_timezone_set('UTC');
599
+	} else {
600
+		date_default_timezone_set('UTC');
601
+	}
596 602
 	if ($showSpecial === true)
597 603
 	{
598 604
 		print '<tr class="special">'."\n";
@@ -607,7 +613,9 @@  discard block
 block discarded – undo
607 613
 			print '<tr class="active">';
608 614
 		} elseif (isset($spotter_item['spotted_registration'])) {
609 615
 			print '<tr class="info">';
610
-		} else print '<tr>';
616
+		} else {
617
+			print '<tr>';
618
+		}
611 619
 	}
612 620
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") {
613 621
 		if ($type == 'aircraft') {
@@ -615,8 +623,9 @@  discard block
 block discarded – undo
615 623
 			{
616 624
 				print '<td class="aircraft_thumbnail">'."\n";
617 625
 				if ($spotter_item['image_source'] == 'planespotters') {
618
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
619
-					else {
626
+					if ($spotter_item['image_source_website'] != '') {
627
+						$image_src = $spotter_item['image_source_website'];
628
+					} else {
620 629
 						$planespotter_url_array = explode("_", $spotter_item['image']);
621 630
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
622 631
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -629,7 +638,9 @@  discard block
 block discarded – undo
629 638
 				} else {
630 639
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
631 640
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
632
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
641
+					} else {
642
+						$image_thumbnail = $spotter_item['image_thumbnail'];
643
+					}
633 644
 					if (isset($spotter_item['airline_name'])) {
634 645
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
635 646
 					} else {
@@ -655,7 +666,9 @@  discard block
 block discarded – undo
655 666
 				print '<td class="aircraft_thumbnail">'."\n";
656 667
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
657 668
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
658
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
669
+				} else {
670
+					$image_thumbnail = $spotter_item['image_thumbnail'];
671
+				}
659 672
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
660 673
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
661 674
 				} else {
@@ -677,7 +690,9 @@  discard block
 block discarded – undo
677 690
 				print '<td class="aircraft_thumbnail">'."\n";
678 691
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
679 692
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
680
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
693
+				} else {
694
+					$image_thumbnail = $spotter_item['image_thumbnail'];
695
+				}
681 696
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
682 697
 				print '</td>'."\n";
683 698
 			} else {
@@ -730,8 +745,9 @@  discard block
 block discarded – undo
730 745
 				print '<td class="aircraft_thumbnail">'."\n";
731 746
 				//print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
732 747
 				if ($spotter_item['image_source'] == 'planespotters') {
733
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
734
-					else {
748
+					if ($spotter_item['image_source_website'] != '') {
749
+						$image_src = $spotter_item['image_source_website'];
750
+					} else {
735 751
 						$planespotter_url_array = explode("_", $spotter_array[0]['image']);
736 752
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
737 753
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -748,7 +764,9 @@  discard block
 block discarded – undo
748 764
 				} else {
749 765
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
750 766
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
751
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
767
+					} else {
768
+						$image_thumbnail = $spotter_item['image_thumbnail'];
769
+					}
752 770
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
753 771
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
754 772
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -788,13 +806,19 @@  discard block
 block discarded – undo
788 806
 				print '<td class="aircraft_thumbnail">'."\n";
789 807
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
790 808
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
791
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
809
+				} else {
810
+					$image_thumbnail = $spotter_item['image_thumbnail'];
811
+				}
792 812
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
793 813
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n";
794
-					if ($spotter_item['image_copyright'] != '') print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
814
+					if ($spotter_item['image_copyright'] != '') {
815
+						print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
816
+					}
795 817
 				} else {
796 818
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['ident'].'" data-content="'._("Ident:").' '.$spotter_item['ident'].'" data-html="true" width="100px" />'."\n";
797
-					if ($spotter_item['image_copyright'] != '') print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
819
+					if ($spotter_item['image_copyright'] != '') {
820
+						print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
821
+					}
798 822
 				}
799 823
 				print '</td>'."\n";
800 824
 			} else {
@@ -812,7 +836,9 @@  discard block
 block discarded – undo
812 836
 				print '<td class="aircraft_thumbnail">'."\n";
813 837
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
814 838
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
815
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
839
+				} else {
840
+					$image_thumbnail = $spotter_item['image_thumbnail'];
841
+				}
816 842
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
817 843
 				print '</td>'."\n";
818 844
 			} else {
@@ -930,8 +956,11 @@  discard block
 block discarded – undo
930 956
 				print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n";
931 957
 			} else {
932 958
 				$aircraft_names = explode('/',$spotter_item['aircraft_name']);
933
-				if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n";
934
-				else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n";
959
+				if (count($aircraft_names) == 1) {
960
+					print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n";
961
+				} else {
962
+					print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n";
963
+				}
935 964
 			}
936 965
 			print '<span class="mobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n";
937 966
 		} elseif ($type == 'marine') {
@@ -974,15 +1003,21 @@  discard block
 block discarded – undo
974 1003
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
975 1004
 				if ($spotter_item['departure_airport_time'] > 2460) {
976 1005
 					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
977
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
1006
+				} else {
1007
+					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
1008
+				}
978 1009
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
979 1010
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
980
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1011
+				} else {
1012
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1013
+				}
981 1014
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
982 1015
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
983 1016
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
984 1017
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
985
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1018
+				} else {
1019
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1020
+				}
986 1021
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
987 1022
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
988 1023
 				if ($spotter_item['departure_airport_time'] > 2460) {
@@ -1004,7 +1039,9 @@  discard block
 block discarded – undo
1004 1039
 						$longitude = $spotter_item['longitude'];
1005 1040
 					}
1006 1041
 					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
1007
-				} else $distance = '';
1042
+				} else {
1043
+					$distance = '';
1044
+				}
1008 1045
 				if ($distance != '') {
1009 1046
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1010 1047
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
@@ -1031,7 +1068,9 @@  discard block
 block discarded – undo
1031 1068
 			} else {
1032 1069
 				if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) {
1033 1070
 					print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
1034
-					if (!isset($Spotter)) $Spotter = new Spotter();
1071
+					if (!isset($Spotter)) {
1072
+						$Spotter = new Spotter();
1073
+					}
1035 1074
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
1036 1075
 					if (isset($arrival_airport_info[0])) {
1037 1076
                         print '<br /><span class="nomobile">' . _("Real:") . ' <a href="' . $globalURL . '/airport/' . $spotter_item['real_arrival_airport'] . '">' . $arrival_airport_info[0]['city'] . ',' . $arrival_airport_info[0]['country'] . ' (' . $spotter_item['real_arrival_airport'] . ')</a></span>' . "\n";
@@ -1051,20 +1090,28 @@  discard block
 block discarded – undo
1051 1090
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
1052 1091
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1053 1092
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1054
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1093
+				} else {
1094
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
1095
+				}
1055 1096
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1056 1097
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1057
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1098
+				} else {
1099
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1100
+				}
1058 1101
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
1059 1102
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
1060 1103
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1061 1104
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1062
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1105
+				} else {
1106
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1107
+				}
1063 1108
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
1064 1109
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
1065 1110
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1066 1111
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1067
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1112
+				} else {
1113
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
1114
+				}
1068 1115
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
1069 1116
 			}
1070 1117
 			if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
@@ -1077,7 +1124,9 @@  discard block
 block discarded – undo
1077 1124
 						$longitude = $spotter_item['longitude'];
1078 1125
 					}
1079 1126
 					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
1080
-				} else $distance = '';
1127
+				} else {
1128
+					$distance = '';
1129
+				}
1081 1130
 				if ($distance != '') {
1082 1131
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1083 1132
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +1231 added lines, -414 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
26 28
 
27 29
 if ($globalInstalled === FALSE) {
28 30
     echo "This script MUST be run after install script. Use your web browser to run install/index.php";
@@ -68,66 +70,107 @@  discard block
 block discarded – undo
68 70
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 71
 if (isset($options['s'])) {
70 72
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
73
-} elseif (isset($options['source'])) {
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['s']);
77
+    }
78
+    } elseif (isset($options['source'])) {
74 79
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
77
-}
80
+    if (isset($options['format'])) {
81
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
82
+    } else {
83
+    	$globalSources[] = array('host' => $options['source']);
84
+    }
85
+    }
78 86
 if (isset($options['aprsserverhost'])) {
79 87
 	$globalServerAPRS = TRUE;
80 88
 	$globalServerAPRShost = $options['aprsserverhost'];
81 89
 }
82
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
83
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
84
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
85
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
90
+if (isset($options['aprsserverport'])) {
91
+	$globalServerAPRSport = $options['aprsserverport'];
92
+}
93
+if (isset($options['aprsserverssid'])) {
94
+	$globalServerAPRSssid = $options['aprsserverssid'];
95
+}
96
+if (isset($options['aprsserverpass'])) {
97
+	$globalServerAPRSpass = $options['aprsserverpass'];
98
+}
99
+if (isset($options['noaprsserver'])) {
100
+	$globalServerAPRS = FALSE;
101
+}
86 102
 if (isset($options['enable-aircraft'])) {
87
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
103
+	if ($globalDebug) {
104
+		echo 'Enable Aircraft mode'."\n";
105
+	}
88 106
 	$globalAircraft = TRUE; 
89 107
 }
90 108
 if (isset($options['disable-aircraft'])) {
91
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
109
+	if ($globalDebug) {
110
+		echo 'Disable Aircraft mode'."\n";
111
+	}
92 112
 	$globalAircraft = FALSE;
93 113
 }
94 114
 if (isset($options['enable-tracker'])) {
95
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
115
+	if ($globalDebug) {
116
+		echo 'Enable Tracker mode'."\n";
117
+	}
96 118
 	$globalTracker = TRUE; 
97 119
 }
98 120
 if (isset($options['disable-tracker'])) {
99
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
121
+	if ($globalDebug) {
122
+		echo 'Disable Tracker mode'."\n";
123
+	}
100 124
 	$globalTracker = FALSE;
101 125
 }
102 126
 if (isset($options['enable-marine'])) {
103
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
127
+	if ($globalDebug) {
128
+		echo 'Enable Marine mode'."\n";
129
+	}
104 130
 	$globalMarine = TRUE;
105 131
 }
106 132
 if (isset($options['disable-marine'])) {
107
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
133
+	if ($globalDebug) {
134
+		echo 'Disable Marine mode'."\n";
135
+	}
108 136
 	$globalMarine = FALSE;
109 137
 }
110
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
111
-if (isset($options['server'])) $globalServer = TRUE;
112
-if (isset($options['idsource'])) $id_source = $options['idsource'];
113
-else $id_source = 1;
138
+if (isset($options['nodaemon'])) {
139
+	$globalDaemon = FALSE;
140
+}
141
+if (isset($options['server'])) {
142
+	$globalServer = TRUE;
143
+}
144
+if (isset($options['idsource'])) {
145
+	$id_source = $options['idsource'];
146
+} else {
147
+	$id_source = 1;
148
+}
114 149
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
150
+    if ($globalDebug) {
151
+    	echo "Using Server Mode\n";
152
+    }
116 153
     $SI=new SpotterServer();
117 154
 /*
118 155
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 156
     $SI = new adsb2aprs();
120 157
     $SI->connect();
121 158
 */
122
-} else $SI=new SpotterImport($Connection->db);
159
+} else {
160
+	$SI=new SpotterImport($Connection->db);
161
+}
123 162
 
124
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
163
+if (isset($globalTracker) && $globalTracker) {
164
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
165
+}
125 166
 if (isset($globalMarine) && $globalMarine) {
126 167
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
127 168
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 169
 }
129 170
 
130
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
171
+if (isset($globalTracker) && $globalTracker) {
172
+	$TI = new TrackerImport($Connection->db);
173
+}
131 174
 if (isset($globalMarine) && $globalMarine) {
132 175
     $AIS = new AIS();
133 176
     $MI = new MarineImport($Connection->db);
@@ -152,7 +195,9 @@  discard block
 block discarded – undo
152 195
 }
153 196
 
154 197
 // let's try and connect
155
-if ($globalDebug) echo "Connecting...\n";
198
+if ($globalDebug) {
199
+	echo "Connecting...\n";
200
+}
156 201
 $use_aprs = false;
157 202
 $aprs_full = false;
158 203
 $reset = 0;
@@ -161,7 +206,9 @@  discard block
 block discarded – undo
161 206
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162 207
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163 208
     $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
209
+    if ($globalDebug) {
210
+    	echo 'Connect to all...'."\n";
211
+    }
165 212
     foreach ($hosts as $id => $value) {
166 213
 	$host = $value['host'];
167 214
 	$globalSources[$id]['last_exec'] = 0;
@@ -171,32 +218,44 @@  discard block
 block discarded – undo
171 218
         	//$formats[$id] = 'deltadbtxt';
172 219
         	$globalSources[$id]['format'] = 'deltadbtxt';
173 220
         	//$last_exec['deltadbtxt'] = 0;
174
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to deltadb source (".$host.")...\n";
223
+        	}
175 224
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176 225
         	//$formats[$id] = 'vatsimtxt';
177 226
         	$globalSources[$id]['format'] = 'vatsimtxt';
178 227
         	//$last_exec['vatsimtxt'] = 0;
179
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to vatsim source (".$host.")...\n";
230
+        	}
180 231
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181 232
         	//$formats[$id] = 'aircraftlistjson';
182 233
         	$globalSources[$id]['format'] = 'aircraftlistjson';
183 234
         	//$last_exec['aircraftlistjson'] = 0;
184
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
237
+        	}
185 238
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
186 239
         	//$formats[$id] = 'aircraftjson';
187 240
         	$globalSources[$id]['format'] = 'aircraftjson';
188 241
         	//$last_exec['aircraftlistjson'] = 0;
189
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to aircraft.json source (".$host.")...\n";
244
+        	}
190 245
     	    } else if (preg_match('/aircraft$/i',$host)) {
191 246
         	//$formats[$id] = 'planefinderclient';
192 247
         	$globalSources[$id]['format'] = 'planefinderclient';
193 248
         	//$last_exec['aircraftlistjson'] = 0;
194
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to planefinderclient source (".$host.")...\n";
251
+        	}
195 252
     	    } else if (preg_match('/opensky/i',$host)) {
196 253
         	//$formats[$id] = 'aircraftlistjson';
197 254
         	$globalSources[$id]['format'] = 'opensky';
198 255
         	//$last_exec['aircraftlistjson'] = 0;
199
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
256
+        	if ($globalDebug) {
257
+        		echo "Connect to opensky source (".$host.")...\n";
258
+        	}
200 259
     	    /*
201 260
     	    // Disabled for now, site change source format
202 261
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -213,7 +272,9 @@  discard block
 block discarded – undo
213 272
         	//$formats[$id] = 'planeupdatefaa';
214 273
         	$globalSources[$id]['format'] = 'planeupdatefaa';
215 274
         	//$last_exec['planeupdatefaa'] = 0;
216
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
275
+        	if ($globalDebug) {
276
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
277
+        	}
217 278
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
218 279
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
219 280
         	    exit(0);
@@ -222,37 +283,53 @@  discard block
 block discarded – undo
222 283
         	//$formats[$id] = 'phpvmacars';
223 284
         	$globalSources[$id]['format'] = 'phpvmacars';
224 285
         	//$last_exec['phpvmacars'] = 0;
225
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
286
+        	if ($globalDebug) {
287
+        		echo "Connect to phpvmacars source (".$host.")...\n";
288
+        	}
226 289
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227 290
         	//$formats[$id] = 'phpvmacars';
228 291
         	$globalSources[$id]['format'] = 'vaos';
229 292
         	//$last_exec['phpvmacars'] = 0;
230
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
293
+        	if ($globalDebug) {
294
+        		echo "Connect to vaos source (".$host.")...\n";
295
+        	}
231 296
             } else if (preg_match('/VAM-json.php$/i',$host)) {
232 297
         	//$formats[$id] = 'phpvmacars';
233 298
         	$globalSources[$id]['format'] = 'vam';
234
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
299
+        	if ($globalDebug) {
300
+        		echo "Connect to Vam source (".$host.")...\n";
301
+        	}
235 302
             } else if (preg_match('/whazzup/i',$host)) {
236 303
         	//$formats[$id] = 'whazzup';
237 304
         	$globalSources[$id]['format'] = 'whazzup';
238 305
         	//$last_exec['whazzup'] = 0;
239
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
306
+        	if ($globalDebug) {
307
+        		echo "Connect to whazzup source (".$host.")...\n";
308
+        	}
240 309
             } else if (preg_match('/blitzortung/i',$host)) {
241 310
         	$globalSources[$id]['format'] = 'blitzortung';
242
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
311
+        	if ($globalDebug) {
312
+        		echo "Connect to blitzortung source (".$host.")...\n";
313
+        	}
243 314
             } else if (preg_match('/airwhere/i',$host)) {
244 315
         	$globalSources[$id]['format'] = 'airwhere';
245
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to airwhere source (".$host.")...\n";
318
+        	}
246 319
             } else if (preg_match('/recentpireps/i',$host)) {
247 320
         	//$formats[$id] = 'pirepsjson';
248 321
         	$globalSources[$id]['format'] = 'pirepsjson';
249 322
         	//$last_exec['pirepsjson'] = 0;
250
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
323
+        	if ($globalDebug) {
324
+        		echo "Connect to pirepsjson source (".$host.")...\n";
325
+        	}
251 326
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252 327
         	//$formats[$id] = 'fr24json';
253 328
         	$globalSources[$id]['format'] = 'fr24json';
254 329
         	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
330
+        	if ($globalDebug) {
331
+        		echo "Connect to fr24 source (".$host.")...\n";
332
+        	}
256 333
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257 334
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 335
         	    exit(0);
@@ -261,7 +338,9 @@  discard block
 block discarded – undo
261 338
         	//$formats[$id] = 'fr24json';
262 339
         	$globalSources[$id]['format'] = 'myshiptracking';
263 340
         	//$last_exec['fr24json'] = 0;
264
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
341
+        	if ($globalDebug) {
342
+        		echo "Connect to myshiptracking source (".$host.")...\n";
343
+        	}
265 344
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
266 345
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
267 346
         	    exit(0);
@@ -270,17 +349,26 @@  discard block
 block discarded – undo
270 349
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271 350
         	//$formats[$id] = 'tsv';
272 351
         	$globalSources[$id]['format'] = 'tsv';
273
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
352
+        	if ($globalDebug) {
353
+        		echo "Connect to tsv source (".$host.")...\n";
354
+        	}
274 355
             }
275 356
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276 357
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
277 358
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278 359
     		    if ($idf !== false) {
279 360
     			$httpfeeds[$id] = $idf;
280
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
281
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
282
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
283
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
361
+        		if ($globalDebug) {
362
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
363
+        		}
364
+    		    } elseif ($globalDebug) {
365
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
366
+    		    }
367
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
368
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
369
+    		} elseif ($globalDebug) {
370
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
371
+    		}
284 372
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
285 373
 	    $hostport = explode(':',$host);
286 374
 	    if (isset($hostport[1])) {
@@ -320,19 +408,27 @@  discard block
 block discarded – undo
320 408
         		//$formats[$id] = 'beast';
321 409
         		$globalSources[$id]['format'] = 'beast';
322 410
 		    //} else $formats[$id] = 'sbs';
323
-		    } else $globalSources[$id]['format'] = 'sbs';
411
+		    } else {
412
+		    	$globalSources[$id]['format'] = 'sbs';
413
+		    }
324 414
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
325 415
 		}
326
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
416
+		if ($globalDebug) {
417
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
418
+		}
327 419
             } else {
328
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
420
+		if ($globalDebug) {
421
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
422
+		}
329 423
 		sleep(10);
330 424
 		connect_all($hosts);
331 425
     	    }
332 426
         }
333 427
     }
334 428
 }
335
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
429
+if (!isset($globalMinFetch)) {
430
+	$globalMinFetch = 15;
431
+}
336 432
 
337 433
 // Initialize all
338 434
 $status = array();
@@ -341,13 +437,19 @@  discard block
 block discarded – undo
341 437
 $formats = array();
342 438
 $last_exec = array();
343 439
 $time = time();
344
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
345
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
346
-else $timeout = 20;
440
+if (isset($globalSourcesTimeout)) {
441
+	$timeout = $globalSourcesTimeOut;
442
+} else if (isset($globalSBS1TimeOut)) {
443
+	$timeout = $globalSBS1TimeOut;
444
+} else {
445
+	$timeout = 20;
446
+}
347 447
 $errno = '';
348 448
 $errstr='';
349 449
 
350
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
450
+if (!isset($globalDaemon)) {
451
+	$globalDaemon = TRUE;
452
+}
351 453
 /* Initiate connections to all the hosts simultaneously */
352 454
 //connect_all($hosts);
353 455
 //connect_all($globalSources);
@@ -376,7 +478,9 @@  discard block
 block discarded – undo
376 478
     if (isset($source['format']) && $source['format'] == 'aprs') {
377 479
 	$aprs_connect = 0;
378 480
 	$use_aprs = true;
379
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
481
+	if (isset($source['port']) && $source['port'] == '10152') {
482
+		$aprs_full = true;
483
+	}
380 484
 	break;
381 485
     }
382 486
 }
@@ -387,25 +491,46 @@  discard block
 block discarded – undo
387 491
 	$aprs_connect = 0;
388 492
 	$aprs_keep = 120;
389 493
 	$aprs_last_tx = time();
390
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
391
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
392
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
393
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
394
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
395
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
396
-	if ($aprs_full) $aprs_filter = '';
397
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
398
-	else $aprs_pass = '-1';
494
+	if (isset($globalAPRSversion)) {
495
+		$aprs_version = $globalAPRSversion;
496
+	} else {
497
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
498
+	}
499
+	if (isset($globalAPRSssid)) {
500
+		$aprs_ssid = $globalAPRSssid;
501
+	} else {
502
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
503
+	}
504
+	if (isset($globalAPRSfilter)) {
505
+		$aprs_filter = $globalAPRSfilter;
506
+	} else {
507
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
508
+	}
509
+	if ($aprs_full) {
510
+		$aprs_filter = '';
511
+	}
512
+	if (isset($globalAPRSpass)) {
513
+		$aprs_pass = $globalAPRSpass;
514
+	} else {
515
+		$aprs_pass = '-1';
516
+	}
399 517
 
400
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
401
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
402
-}
518
+	if ($aprs_filter != '') {
519
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
520
+	} else {
521
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
522
+	}
523
+	}
403 524
 
404 525
 // connected - lets do some work
405 526
 //if ($globalDebug) echo "Connected!\n";
406 527
 sleep(1);
407
-if ($globalDebug) echo "SCAN MODE \n\n";
408
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
528
+if ($globalDebug) {
529
+	echo "SCAN MODE \n\n";
530
+}
531
+if (!isset($globalCronEnd)) {
532
+	$globalCronEnd = 60;
533
+}
409 534
 $endtime = time()+$globalCronEnd;
410 535
 $i = 1;
411 536
 $tt = array();
@@ -419,22 +544,32 @@  discard block
 block discarded – undo
419 544
 
420 545
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
421 546
 while ($i > 0) {
422
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
547
+    if (function_exists('pcntl_fork')) {
548
+    	pcntl_signal_dispatch();
549
+    }
423 550
 
424
-    if (!$globalDaemon) $i = $endtime-time();
551
+    if (!$globalDaemon) {
552
+    	$i = $endtime-time();
553
+    }
425 554
     // Delete old ATC
426 555
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
427
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
556
+	if ($globalDebug) {
557
+		echo 'Delete old ATC...'."\n";
558
+	}
428 559
         $ATC->deleteOldATC();
429 560
     }
430 561
     
431 562
     if (count($last_exec) == count($globalSources)) {
432 563
 	$max = $globalMinFetch;
433 564
 	foreach ($last_exec as $last) {
434
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
565
+	    if ((time() - $last['last']) < $max) {
566
+	    	$max = time() - $last['last'];
567
+	    }
435 568
 	}
436 569
 	if ($max < $globalMinFetch) {
437
-	    if ($globalDebug) echo 'Sleeping...'."\n";
570
+	    if ($globalDebug) {
571
+	    	echo 'Sleeping...'."\n";
572
+	    }
438 573
 	    sleep($globalMinFetch-$max+2);
439 574
 	}
440 575
     }
@@ -444,7 +579,9 @@  discard block
 block discarded – undo
444 579
     foreach ($globalSources as $id => $value) {
445 580
 	date_default_timezone_set('UTC');
446 581
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
447
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
582
+	if (!isset($last_exec[$id]['last'])) {
583
+		$last_exec[$id]['last'] = 0;
584
+	}
448 585
 	if ($value['format'] === 'deltadbtxt' && 
449 586
 	    (
450 587
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -453,7 +590,9 @@  discard block
 block discarded – undo
453 590
 	) {
454 591
         //$buffer = $Common->getData($hosts[$id]);
455 592
         $buffer = $Common->getData($value['host']);
456
-        if ($buffer != '') $reset = 0;
593
+        if ($buffer != '') {
594
+        	$reset = 0;
595
+        }
457 596
         $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
458 597
         $buffer = explode('\n', $buffer);
459 598
         foreach ($buffer as $line) {
@@ -462,20 +601,41 @@  discard block
 block discarded – undo
462 601
                 $data = array();
463 602
                 $data['hex'] = $line[1]; // hex
464 603
                 $data['ident'] = $line[2]; // ident
465
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
466
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
467
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
468
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
469
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
604
+                if (isset($line[3])) {
605
+                	$data['altitude'] = $line[3];
606
+                }
607
+                // altitude
608
+                if (isset($line[4])) {
609
+                	$data['speed'] = $line[4];
610
+                }
611
+                // speed
612
+                if (isset($line[5])) {
613
+                	$data['heading'] = $line[5];
614
+                }
615
+                // heading
616
+                if (isset($line[6])) {
617
+                	$data['latitude'] = $line[6];
618
+                }
619
+                // lat
620
+                if (isset($line[7])) {
621
+                	$data['longitude'] = $line[7];
622
+                }
623
+                // long
470 624
                 $data['verticalrate'] = ''; // vertical rate
471 625
                 //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
472 626
                 $data['emergency'] = ''; // emergency
473 627
                 $data['datetime'] = date('Y-m-d H:i:s');
474 628
                 $data['format_source'] = 'deltadbtxt';
475 629
                 $data['id_source'] = $id_source;
476
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
477
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
630
+                if (isset($value['name']) && $value['name'] != '') {
631
+                	$data['source_name'] = $value['name'];
632
+                }
633
+                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
634
+                	$data['noarchive'] = true;
635
+                }
636
+                if (isset($value['sourcestats'])) {
637
+                	$data['sourcestats'] = $value['sourcestats'];
638
+                }
479 639
                 $SI->add($data);
480 640
                 unset($data);
481 641
             }
@@ -510,11 +670,20 @@  discard block
 block discarded – undo
510 670
                     $data['format_source'] = 'radarcapejson';
511 671
                     $data['id_source'] = $id_source;
512 672
                     if (isset($value['name']) && $value['name'] != '') {
513
-                        if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
514
-                        else $data['source_name'] = $value['name'];
515
-                    } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
516
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
517
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
673
+                        if (isset($line['src']) && !$line['src'] == 'M') {
674
+                        	$data['source_name'] = $value['name'].'_MLAT';
675
+                        } else {
676
+                        	$data['source_name'] = $value['name'];
677
+                        }
678
+                    } elseif (isset($line['src']) && $line['src'] == 'M') {
679
+                    	$data['source_name'] = 'MLAT';
680
+                    }
681
+                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
682
+                    	$data['noarchive'] = true;
683
+                    }
684
+                    if (isset($value['sourcestats'])) {
685
+                    	$data['sourcestats'] = $value['sourcestats'];
686
+                    }
518 687
 
519 688
                     $SI->add($data);
520 689
                     unset($data);
@@ -530,7 +699,9 @@  discard block
 block discarded – undo
530 699
 	    date_default_timezone_set('CET');
531 700
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
532 701
 	    date_default_timezone_set('UTC');
533
-	    if ($buffer != '') $reset = 0;
702
+	    if ($buffer != '') {
703
+	    	$reset = 0;
704
+	    }
534 705
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
535 706
 	    $buffer = explode('\n',$buffer);
536 707
 	    foreach ($buffer as $line) {
@@ -539,18 +710,42 @@  discard block
 block discarded – undo
539 710
 		    $add = false;
540 711
 		    $ais_data = $AIS->parse_line(trim($line));
541 712
 		    $data = array();
542
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
543
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
544
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
545
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
546
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
547
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
548
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
549
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
550
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
551
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
552
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
553
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
713
+		    if (isset($ais_data['ident'])) {
714
+		    	$data['ident'] = $ais_data['ident'];
715
+		    }
716
+		    if (isset($ais_data['mmsi'])) {
717
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
718
+		    }
719
+		    if (isset($ais_data['speed'])) {
720
+		    	$data['speed'] = $ais_data['speed'];
721
+		    }
722
+		    if (isset($ais_data['heading'])) {
723
+		    	$data['heading'] = $ais_data['heading'];
724
+		    }
725
+		    if (isset($ais_data['latitude'])) {
726
+		    	$data['latitude'] = $ais_data['latitude'];
727
+		    }
728
+		    if (isset($ais_data['longitude'])) {
729
+		    	$data['longitude'] = $ais_data['longitude'];
730
+		    }
731
+		    if (isset($ais_data['status'])) {
732
+		    	$data['status'] = $ais_data['status'];
733
+		    }
734
+		    if (isset($ais_data['statusid'])) {
735
+		    	$data['status_id'] = $ais_data['statusid'];
736
+		    }
737
+		    if (isset($ais_data['type'])) {
738
+		    	$data['type'] = $ais_data['type'];
739
+		    }
740
+		    if (isset($ais_data['typeid'])) {
741
+		    	$data['type_id'] = $ais_data['typeid'];
742
+		    }
743
+		    if (isset($ais_data['imo'])) {
744
+		    	$data['imo'] = $ais_data['imo'];
745
+		    }
746
+		    if (isset($ais_data['callsign'])) {
747
+		    	$data['callsign'] = $ais_data['callsign'];
748
+		    }
554 749
 		    if (isset($ais_data['timestamp'])) {
555 750
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
556 751
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -564,8 +759,12 @@  discard block
 block discarded – undo
564 759
 		    $data['format_source'] = 'aisnmeatxt';
565 760
     		    $data['id_source'] = $id_source;
566 761
 		    //print_r($data);
567
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
568
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
762
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
763
+		    	$data['noarchive'] = true;
764
+		    }
765
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
766
+		    	$MI->add($data);
767
+		    }
569 768
 		    unset($data);
570 769
 		}
571 770
     	    }
@@ -588,20 +787,48 @@  discard block
 block discarded – undo
588 787
 			    if ($line != '') {
589 788
 				$ais_data = $AIS->parse_line(trim($line));
590 789
 				$data = array();
591
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
592
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
593
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
594
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
595
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
596
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
597
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
598
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
599
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
600
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
601
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
602
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
603
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
604
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
790
+				if (isset($ais_data['ident'])) {
791
+					$data['ident'] = $ais_data['ident'];
792
+				}
793
+				if (isset($ais_data['mmsi'])) {
794
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
795
+				}
796
+				if (isset($ais_data['speed'])) {
797
+					$data['speed'] = $ais_data['speed'];
798
+				}
799
+				if (isset($ais_data['heading'])) {
800
+					$data['heading'] = $ais_data['heading'];
801
+				}
802
+				if (isset($ais_data['latitude'])) {
803
+					$data['latitude'] = $ais_data['latitude'];
804
+				}
805
+				if (isset($ais_data['longitude'])) {
806
+					$data['longitude'] = $ais_data['longitude'];
807
+				}
808
+				if (isset($ais_data['status'])) {
809
+					$data['status'] = $ais_data['status'];
810
+				}
811
+				if (isset($ais_data['statusid'])) {
812
+					$data['status_id'] = $ais_data['statusid'];
813
+				}
814
+				if (isset($ais_data['type'])) {
815
+					$data['type'] = $ais_data['type'];
816
+				}
817
+				if (isset($ais_data['typeid'])) {
818
+					$data['type_id'] = $ais_data['typeid'];
819
+				}
820
+				if (isset($ais_data['imo'])) {
821
+					$data['imo'] = $ais_data['imo'];
822
+				}
823
+				if (isset($ais_data['callsign'])) {
824
+					$data['callsign'] = $ais_data['callsign'];
825
+				}
826
+				if (isset($ais_data['destination'])) {
827
+					$data['arrival_code'] = $ais_data['destination'];
828
+				}
829
+				if (isset($ais_data['eta_ts'])) {
830
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
831
+				}
605 832
 				if (isset($ais_data['timestamp'])) {
606 833
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
607 834
 				} else {
@@ -609,18 +836,27 @@  discard block
 block discarded – undo
609 836
 				}
610 837
 				$data['format_source'] = 'aisnmeahttp';
611 838
 				$data['id_source'] = $id_source;
612
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
613
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
839
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
840
+					$data['noarchive'] = true;
841
+				}
842
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
843
+					$MI->add($data);
844
+				}
614 845
 				unset($data);
615 846
 			    }
616 847
 			}
617 848
 		    }
618 849
 		} else {
619 850
 		    $format = $value['format'];
620
-		    if (isset($tt[$format])) $tt[$format]++;
621
-		    else $tt[$format] = 0;
851
+		    if (isset($tt[$format])) {
852
+		    	$tt[$format]++;
853
+		    } else {
854
+		    	$tt[$format] = 0;
855
+		    }
622 856
 		    if ($tt[$format] > 30) {
623
-			if ($globalDebug) echo 'Reconnect...'."\n";
857
+			if ($globalDebug) {
858
+				echo 'Reconnect...'."\n";
859
+			}
624 860
 			sleep(2);
625 861
 			//$sourceeen[] = $value;
626 862
 			//connect_all($sourceeen);
@@ -656,12 +892,18 @@  discard block
 block discarded – undo
656 892
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
657 893
 			    //$data['type_id'] = $line['TYPE'];
658 894
 			    $data['imo'] = $line['IMO'];
659
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
660
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
895
+			    if ($line['DEST'] != '') {
896
+			    	$data['arrival_code'] = $line['DEST'];
897
+			    }
898
+			    if ($line['ARV'] != '') {
899
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
900
+			    }
661 901
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
662 902
 			    $data['format_source'] = 'myshiptracking';
663 903
 			    $data['id_source'] = $id_source;
664
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
904
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
905
+			    	$data['noarchive'] = true;
906
+			    }
665 907
 			    $MI->add($data);
666 908
 			    unset($data);
667 909
 			}
@@ -686,7 +928,9 @@  discard block
 block discarded – undo
686 928
 			    $data['callsign'] = $line['callsign'];
687 929
 			    $data['mmsi'] = substr($line['mmsi'],-9);
688 930
 			    $data['speed'] = $line['sog'];
689
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
931
+			    if ($line['heading'] != '511') {
932
+			    	$data['heading'] = $line['heading'];
933
+			    }
690 934
 			    $data['latitude'] = $line['latitude'];
691 935
 			    $data['longitude'] = $line['longitude'];
692 936
 			    $data['type_id'] = $line['shiptype'];
@@ -694,7 +938,9 @@  discard block
 block discarded – undo
694 938
 			    $data['datetime'] = $line['time'];
695 939
 			    $data['format_source'] = 'boatbeaconapp';
696 940
 			    $data['id_source'] = $id_source;
697
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
941
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
942
+			    	$data['noarchive'] = true;
943
+			    }
698 944
 			    $MI->add($data);
699 945
 			    unset($data);
700 946
 			}
@@ -716,22 +962,44 @@  discard block
 block discarded – undo
716 962
 		    foreach ($all_data['features'] as $line) {
717 963
 			print_r($line);
718 964
 			$data = array();
719
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
720
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
721
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
722
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
723
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
724
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
965
+			if (isset($line['properties']['name'])) {
966
+				$data['ident'] = $line['properties']['name'];
967
+			}
968
+			if (isset($line['properties']['callsign'])) {
969
+				$data['callsign'] = $line['properties']['callsign'];
970
+			}
971
+			if (isset($line['properties']['mmsi'])) {
972
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
973
+			}
974
+			if (isset($line['properties']['imo'])) {
975
+				$data['imo'] = $line['properties']['imo'];
976
+			}
977
+			if (isset($line['properties']['speed'])) {
978
+				$data['speed'] = $line['properties']['speed'];
979
+			}
980
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
981
+				$data['heading'] = $line['properties']['heading'];
982
+			}
725 983
 			$data['latitude'] = $line['geometry']['coordinates'][1];
726 984
 			$data['longitude'] = $line['geometry']['coordinates'][0];
727
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
728
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
729
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
985
+			if (isset($line['properties']['vesselType'])) {
986
+				$data['type'] = $line['properties']['vesselType'];
987
+			}
988
+			if (isset($line['properties']['destination'])) {
989
+				$data['arrival_code'] = $line['properties']['destination'];
990
+			}
991
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
992
+				$data['arrival_date'] = $line['properties']['eta'];
993
+			}
730 994
 			$data['format_source'] = 'boatnerd';
731 995
 			$data['id_source'] = $id_source;
732 996
 			$data['datetime'] = date('Y-m-d H:i:s');
733
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
734
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
997
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
998
+				$data['noarchive'] = true;
999
+			}
1000
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
1001
+				$MI->add($data);
1002
+			}
735 1003
 			unset($data);
736 1004
 		    }
737 1005
 		}
@@ -744,11 +1012,17 @@  discard block
 block discarded – undo
744 1012
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
745 1013
 	    )
746 1014
 	) {
747
-	    if ($globalDebug) echo 'download...';
1015
+	    if ($globalDebug) {
1016
+	    	echo 'download...';
1017
+	    }
748 1018
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
749
-	    if ($globalDebug) echo 'done !'."\n";
1019
+	    if ($globalDebug) {
1020
+	    	echo 'done !'."\n";
1021
+	    }
750 1022
 	    // FIXME: Need more work
751
-	    if ($buffer != '') $reset = 0;
1023
+	    if ($buffer != '') {
1024
+	    	$reset = 0;
1025
+	    }
752 1026
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
753 1027
 	    $buffer = explode('\n',$buffer);
754 1028
 	    foreach ($buffer as $line) {
@@ -774,7 +1048,9 @@  discard block
 block discarded – undo
774 1048
 		    //$data['etaTime'] = substr($line,135,5);
775 1049
 		    $data['format_source'] = 'shipplotter';
776 1050
     		    $data['id_source'] = $id_source;
777
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1051
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1052
+		    	$data['noarchive'] = true;
1053
+		    }
778 1054
 		    //print_r($data);
779 1055
 		    //echo 'Add...'."\n";
780 1056
 		    $MI->add($data);
@@ -797,11 +1073,17 @@  discard block
 block discarded – undo
797 1073
 		}
798 1074
 	    }
799 1075
 
800
-	    if ($globalDebug) echo '! Download... ';
1076
+	    if ($globalDebug) {
1077
+	    	echo '! Download... ';
1078
+	    }
801 1079
 	    for ($i =0; $i <= 1; $i++) {
802
-		if ($globalDebug) echo 'Racetype: '.$i.' ';
1080
+		if ($globalDebug) {
1081
+			echo 'Racetype: '.$i.' ';
1082
+		}
803 1083
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
804
-	    if ($globalDebug) echo 'done'."\n";
1084
+	    if ($globalDebug) {
1085
+	    	echo 'done'."\n";
1086
+	    }
805 1087
 	    if ($buffer != '') {
806 1088
 		$all_data = json_decode($buffer,true);
807 1089
 		if (isset($all_data['missions'])) {
@@ -809,8 +1091,11 @@  discard block
 block discarded – undo
809 1091
 				$mission_user = $mission['usrname'];
810 1092
 				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
811 1093
 				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
812
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
813
-					else $racebuffer = '';
1094
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
1095
+						$racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
1096
+					} else {
1097
+						$racebuffer = '';
1098
+					}
814 1099
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
815 1100
 				} else {
816 1101
 					$bufferm = '';
@@ -874,7 +1159,9 @@  discard block
 block discarded – undo
874 1159
 								$data['captain_id'] = $sail['usrnr'];
875 1160
 								$data['captain_name'] = $sail['usrname'];
876 1161
 								$data['race_id'] = $sail['misnr'];
877
-								if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank'];
1162
+								if ($sail['rank'] != 'DNF') {
1163
+									$data['race_rank'] = $sail['rank'];
1164
+								}
878 1165
 								$data['race_time'] = $sail['racetime'];
879 1166
 								if ($mission_user != '') {
880 1167
 									$data['race_name'] = $mission_name.' ('.$mission_user.')';
@@ -884,7 +1171,9 @@  discard block
 block discarded – undo
884 1171
 								//$data['callsign'] = trim(substr($line,100,7);
885 1172
 								$data['format_source'] = 'sailaway';
886 1173
 								$data['id_source'] = $id_source;
887
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1174
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1175
+									$data['noarchive'] = true;
1176
+								}
888 1177
 								//print_r($data);
889 1178
 								//if ($data['race_id'] == '48') print_r($data);
890 1179
 								//echo 'Add...'."\n";
@@ -926,16 +1215,28 @@  discard block
 block discarded – undo
926 1215
     		    $line = explode(':', $line);
927 1216
     		    if (count($line) > 30 && $line[0] != 'callsign') {
928 1217
 			$data = array();
929
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
930
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1218
+			if (isset($line[37]) && $line[37] != '') {
1219
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1220
+			} else {
1221
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1222
+			}
931 1223
 			$data['pilot_id'] = $line[1];
932 1224
 			$data['pilot_name'] = $line[2];
933 1225
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
934 1226
 			$data['ident'] = $line[0]; // ident
935
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1227
+			if ($line[7] != '' && $line[7] != 0) {
1228
+				$data['altitude'] = $line[7];
1229
+			}
1230
+			// altitude
936 1231
 			$data['speed'] = $line[8]; // speed
937
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
938
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1232
+			if (isset($line[45])) {
1233
+				$data['heading'] = $line[45];
1234
+			}
1235
+			// heading
1236
+			elseif (isset($line[38])) {
1237
+				$data['heading'] = $line[38];
1238
+			}
1239
+			// heading
939 1240
 			$data['latitude'] = $line[5]; // lat
940 1241
 	        	$data['longitude'] = $line[6]; // long
941 1242
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -951,7 +1252,9 @@  discard block
 block discarded – undo
951 1252
 			$data['frequency'] = $line[4];
952 1253
 			$data['type'] = $line[18];
953 1254
 			$data['range'] = $line[19];
954
-			if (isset($line[35])) $data['info'] = $line[35];
1255
+			if (isset($line[35])) {
1256
+				$data['info'] = $line[35];
1257
+			}
955 1258
     			$data['id_source'] = $id_source;
956 1259
 	    		//$data['arrival_airport_time'] = ;
957 1260
 	    		if ($line[9] != '') {
@@ -965,27 +1268,47 @@  discard block
 block discarded – undo
965 1268
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
966 1269
 	    		*/
967 1270
 	    		$data['format_source'] = $value['format'];
968
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
969
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
970
-    			if ($line[3] === 'PILOT') $SI->add($data);
971
-			elseif ($line[3] === 'ATC') {
1271
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1272
+				$data['noarchive'] = true;
1273
+			}
1274
+			if (isset($value['name']) && $value['name'] != '') {
1275
+				$data['source_name'] = $value['name'];
1276
+			}
1277
+    			if ($line[3] === 'PILOT') {
1278
+    				$SI->add($data);
1279
+    			} elseif ($line[3] === 'ATC') {
972 1280
 				//print_r($data);
973 1281
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
974 1282
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
975 1283
 				$typec = substr($data['ident'],-3);
976
-				if ($typec === 'APP') $data['type'] = 'Approach';
977
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
978
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
979
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
980
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
981
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
982
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
983
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
984
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
985
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1284
+				if ($typec === 'APP') {
1285
+					$data['type'] = 'Approach';
1286
+				} elseif ($typec === 'TWR') {
1287
+					$data['type'] = 'Tower';
1288
+				} elseif ($typec === 'OBS') {
1289
+					$data['type'] = 'Observer';
1290
+				} elseif ($typec === 'GND') {
1291
+					$data['type'] = 'Ground';
1292
+				} elseif ($typec === 'DEL') {
1293
+					$data['type'] = 'Delivery';
1294
+				} elseif ($typec === 'DEP') {
1295
+					$data['type'] = 'Departure';
1296
+				} elseif ($typec === 'FSS') {
1297
+					$data['type'] = 'Flight Service Station';
1298
+				} elseif ($typec === 'CTR') {
1299
+					$data['type'] = 'Control Radar or Centre';
1300
+				} elseif ($data['type'] === '') {
1301
+					$data['type'] = 'Observer';
1302
+				}
1303
+				if (!isset($data['source_name'])) {
1304
+					$data['source_name'] = '';
1305
+				}
986 1306
 				if (isset($ATC)) {
987
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
988
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1307
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1308
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1309
+					} else {
1310
+						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']);
1311
+					}
989 1312
 				}
990 1313
 			}
991 1314
     			unset($data);
@@ -1012,14 +1335,20 @@  discard block
 block discarded – undo
1012 1335
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1013 1336
 			$data['latitude'] = (float)$line['pktLatitude'];
1014 1337
 			$data['longitude'] = (float)$line['pktLongitude'];
1015
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1016
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1338
+			if ((float)$line['pktTrack'] != 0) {
1339
+				$data['heading'] = (float)$line['pktTrack'];
1340
+			}
1341
+			if ((int)$line['pktSpeed'] != 0) {
1342
+				$data['speed'] = (int)$line['pktSpeed'];
1343
+			}
1017 1344
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1018 1345
 			$data['altitude_relative'] = 'AMSL';
1019 1346
 			$data['pilot_id'] = (int)$line['pktPilotID'];
1020 1347
 			$data['aircraft_icao'] = 'PARAGLIDER';
1021 1348
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1022
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1349
+			if (isset($pilot_data[4])) {
1350
+				$data['pilot_name'] = $pilot_data[4];
1351
+			}
1023 1352
 			$data['format_source'] = $value['format'];
1024 1353
 			$SI->add($data);
1025 1354
 			unset($data);
@@ -1067,25 +1396,59 @@  discard block
 block discarded – undo
1067 1396
 		    foreach ($all_data['acList'] as $line) {
1068 1397
 			$data = array();
1069 1398
 			$data['hex'] = $line['Icao']; // hex
1070
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1071
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1072
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1073
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1074
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1075
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1399
+			if (isset($line['Call'])) {
1400
+				$data['ident'] = $line['Call'];
1401
+			}
1402
+			// ident
1403
+			if (isset($line['Alt'])) {
1404
+				$data['altitude'] = $line['Alt'];
1405
+			}
1406
+			// altitude
1407
+			if (isset($line['Spd'])) {
1408
+				$data['speed'] = $line['Spd'];
1409
+			}
1410
+			// speed
1411
+			if (isset($line['Trak'])) {
1412
+				$data['heading'] = $line['Trak'];
1413
+			}
1414
+			// heading
1415
+			if (isset($line['Lat'])) {
1416
+				$data['latitude'] = $line['Lat'];
1417
+			}
1418
+			// lat
1419
+			if (isset($line['Long'])) {
1420
+				$data['longitude'] = $line['Long'];
1421
+			}
1422
+			// long
1076 1423
 			//$data['verticalrate'] = $line['']; // verticale rate
1077
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1424
+			if (isset($line['Sqk'])) {
1425
+				$data['squawk'] = $line['Sqk'];
1426
+			}
1427
+			// squawk
1078 1428
 			$data['emergency'] = ''; // emergency
1079
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1080
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1081
-			else $data['datetime'] = date('Y-m-d H:i:s');
1429
+			if (isset($line['Reg'])) {
1430
+				$data['registration'] = $line['Reg'];
1431
+			}
1432
+			if (isset($line['PosTime'])) {
1433
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1434
+			} else {
1435
+				$data['datetime'] = date('Y-m-d H:i:s');
1436
+			}
1082 1437
 			//$data['datetime'] = date('Y-m-d H:i:s');
1083
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1438
+			if (isset($line['Type'])) {
1439
+				$data['aircraft_icao'] = $line['Type'];
1440
+			}
1084 1441
 			$data['format_source'] = 'aircraftlistjson';
1085 1442
 			$data['id_source'] = $id_source;
1086
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1087
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1088
-			if (isset($data['latitude'])) $SI->add($data);
1443
+			if (isset($value['name']) && $value['name'] != '') {
1444
+				$data['source_name'] = $value['name'];
1445
+			}
1446
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1447
+				$data['noarchive'] = true;
1448
+			}
1449
+			if (isset($data['latitude'])) {
1450
+				$SI->add($data);
1451
+			}
1089 1452
 			unset($data);
1090 1453
 		    }
1091 1454
 		} elseif (is_array($all_data)) {
@@ -1102,17 +1465,26 @@  discard block
 block discarded – undo
1102 1465
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1103 1466
 			$data['squawk'] = $line['squawk']; // squawk
1104 1467
 			$data['emergency'] = ''; // emergency
1105
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1106
-			else $data['datetime'] = date('Y-m-d H:i:s');
1468
+			if (isset($line['PosTime'])) {
1469
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1470
+			} else {
1471
+				$data['datetime'] = date('Y-m-d H:i:s');
1472
+			}
1107 1473
 			$data['format_source'] = 'aircraftlistjson';
1108 1474
 			$data['id_source'] = $id_source;
1109
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1110
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1475
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1476
+				$data['noarchive'] = true;
1477
+			}
1478
+			if (isset($value['name']) && $value['name'] != '') {
1479
+				$data['source_name'] = $value['name'];
1480
+			}
1111 1481
 			$SI->add($data);
1112 1482
 			unset($data);
1113 1483
 		    }
1114 1484
 		}
1115
-	    } elseif ($globalDebug) echo 'No data'."\n";
1485
+	    } elseif ($globalDebug) {
1486
+	    	echo 'No data'."\n";
1487
+	    }
1116 1488
     	    //$last_exec['aircraftlistjson'] = time();
1117 1489
     	    $last_exec[$id]['last'] = time();
1118 1490
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1148,8 +1520,12 @@  discard block
 block discarded – undo
1148 1520
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1149 1521
 	    	    $data['format_source'] = 'planeupdatefaa';
1150 1522
     		    $data['id_source'] = $id_source;
1151
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1152
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1523
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1524
+		    	$data['noarchive'] = true;
1525
+		    }
1526
+		    if (isset($value['name']) && $value['name'] != '') {
1527
+		    	$data['source_name'] = $value['name'];
1528
+		    }
1153 1529
 		    $SI->add($data);
1154 1530
 		    unset($data);
1155 1531
 		}
@@ -1183,7 +1559,9 @@  discard block
 block discarded – undo
1183 1559
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1184 1560
 		    $data['format_source'] = 'opensky';
1185 1561
 		    $data['id_source'] = $id_source;
1186
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1562
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1563
+		    	$data['noarchive'] = true;
1564
+		    }
1187 1565
 		    $SI->add($data);
1188 1566
 		    unset($data);
1189 1567
 		}
@@ -1203,15 +1581,42 @@  discard block
 block discarded – undo
1203 1581
 		foreach ($all_data['aircraft'] as $key => $line) {
1204 1582
 		    $data = array();
1205 1583
 		    // add support for ground vehicule with ~ in front of hex
1206
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1207
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1208
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1209
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1210
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1211
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1212
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1213
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1214
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1584
+		    if (isset($line['hex'])) {
1585
+		    	$data['hex'] = $line['hex'];
1586
+		    }
1587
+		    // hex
1588
+		    if (isset($line['flight'])) {
1589
+		    	$data['ident'] = trim($line['flight']);
1590
+		    }
1591
+		    // ident
1592
+		    if (isset($line['altitude'])) {
1593
+		    	$data['altitude'] = $line['altitude'];
1594
+		    }
1595
+		    // altitude
1596
+		    if (isset($line['speed'])) {
1597
+		    	$data['speed'] = $line['speed'];
1598
+		    }
1599
+		    // speed
1600
+		    if (isset($line['track'])) {
1601
+		    	$data['heading'] = $line['track'];
1602
+		    }
1603
+		    // heading
1604
+		    if (isset($line['lat'])) {
1605
+		    	$data['latitude'] = $line['lat'];
1606
+		    }
1607
+		    // lat
1608
+		    if (isset($line['lon'])) {
1609
+		    	$data['longitude'] = $line['lon'];
1610
+		    }
1611
+		    // long
1612
+		    if (isset($line['vert_rate'])) {
1613
+		    	$data['verticalrate'] = $line['vert_rate'];
1614
+		    }
1615
+		    // verticale rate
1616
+		    if (isset($line['squawk'])) {
1617
+		    	$data['squawk'] = $line['squawk'];
1618
+		    }
1619
+		    // squawk
1215 1620
 		    //$data['emergency'] = ''; // emergency
1216 1621
 		    //$data['registration'] = $line[2];
1217 1622
 		    //$data['aircraft_icao'] = $line[0];
@@ -1219,10 +1624,17 @@  discard block
 block discarded – undo
1219 1624
 		    $data['format_source'] = 'aircraftjson';
1220 1625
 		    $data['id_source'] = $id_source;
1221 1626
 		    if (isset($value['name']) && $value['name'] != '') {
1222
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1223
-			    else $data['source_name'] = $value['name'];
1224
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1225
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1627
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1628
+			    	$data['source_name'] = $value['name'].'_MLAT';
1629
+			    } else {
1630
+			    	$data['source_name'] = $value['name'];
1631
+			    }
1632
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1633
+		    	$data['source_name'] = 'MLAT';
1634
+		    }
1635
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1636
+		    	$data['noarchive'] = true;
1637
+		    }
1226 1638
 		    $SI->add($data);
1227 1639
 		    unset($data);
1228 1640
 		}
@@ -1242,22 +1654,54 @@  discard block
 block discarded – undo
1242 1654
 		foreach ($all_data['aircraft'] as $key => $line) {
1243 1655
 		    $data = array();
1244 1656
 		    $data['hex'] = $key; // hex
1245
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1246
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1247
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1248
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1249
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1250
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1251
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1252
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1657
+		    if (isset($line['callsign'])) {
1658
+		    	$data['ident'] = trim($line['callsign']);
1659
+		    }
1660
+		    // ident
1661
+		    if (isset($line['altitude'])) {
1662
+		    	$data['altitude'] = $line['altitude'];
1663
+		    }
1664
+		    // altitude
1665
+		    if (isset($line['speed'])) {
1666
+		    	$data['speed'] = $line['speed'];
1667
+		    }
1668
+		    // speed
1669
+		    if (isset($line['heading'])) {
1670
+		    	$data['heading'] = $line['heading'];
1671
+		    }
1672
+		    // heading
1673
+		    if (isset($line['lat'])) {
1674
+		    	$data['latitude'] = $line['lat'];
1675
+		    }
1676
+		    // lat
1677
+		    if (isset($line['lon'])) {
1678
+		    	$data['longitude'] = $line['lon'];
1679
+		    }
1680
+		    // long
1681
+		    if (isset($line['vert_rate'])) {
1682
+		    	$data['verticalrate'] = $line['vert_rate'];
1683
+		    }
1684
+		    // verticale rate
1685
+		    if (isset($line['squawk'])) {
1686
+		    	$data['squawk'] = $line['squawk'];
1687
+		    }
1688
+		    // squawk
1253 1689
 		    //$data['emergency'] = ''; // emergency
1254
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1255
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1690
+		    if (isset($line['reg'])) {
1691
+		    	$data['registration'] = $line['reg'];
1692
+		    }
1693
+		    if (isset($line['type'])) {
1694
+		    	$data['aircraft_icao'] = $line['type'];
1695
+		    }
1256 1696
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1257 1697
 		    $data['format_source'] = 'planefinderclient';
1258 1698
 		    $data['id_source'] = $id_source;
1259
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1260
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1699
+		    if (isset($value['name']) && $value['name'] != '') {
1700
+		    	$data['source_name'] = $value['name'];
1701
+		    }
1702
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1703
+		    	$data['noarchive'] = true;
1704
+		    }
1261 1705
 		    $SI->add($data);
1262 1706
 		    unset($data);
1263 1707
 		}
@@ -1273,7 +1717,9 @@  discard block
 block discarded – undo
1273 1717
 	    //$buffer = $Common->getData($hosts[$id]);
1274 1718
 	    $buffer = $Common->getData($value['host']);
1275 1719
 	    $all_data = json_decode($buffer,true);
1276
-	    if (!empty($all_data)) $reset = 0;
1720
+	    if (!empty($all_data)) {
1721
+	    	$reset = 0;
1722
+	    }
1277 1723
 	    foreach ($all_data as $key => $line) {
1278 1724
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1279 1725
 		    $data = array();
@@ -1294,8 +1740,12 @@  discard block
 block discarded – undo
1294 1740
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1295 1741
 	    	    $data['format_source'] = 'fr24json';
1296 1742
     		    $data['id_source'] = $id_source;
1297
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1298
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1743
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1744
+		    	$data['noarchive'] = true;
1745
+		    }
1746
+		    if (isset($value['name']) && $value['name'] != '') {
1747
+		    	$data['source_name'] = $value['name'];
1748
+		    }
1299 1749
 		    $SI->add($data);
1300 1750
 		    unset($data);
1301 1751
 		}
@@ -1324,24 +1774,42 @@  discard block
 block discarded – undo
1324 1774
 		    if (isset($line['inf'])) {
1325 1775
 			$data = array();
1326 1776
 			$data['hex'] = $line['inf']['ia'];
1327
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1777
+			if (isset($line['inf']['cs'])) {
1778
+				$data['ident'] = $line['inf']['cs'];
1779
+			}
1780
+			//$line[13]
1328 1781
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1329
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1330
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1782
+	    		if (isset($line['inf']['gs'])) {
1783
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1784
+	    		}
1785
+	    		// speed
1786
+	    		if (isset($line['inf']['tr'])) {
1787
+	    			$data['heading'] = $line['inf']['tr'];
1788
+	    		}
1789
+	    		// heading
1331 1790
 	    		$data['latitude'] = $line['pt'][0]; // lat
1332 1791
 	    		$data['longitude'] = $line['pt'][1]; // long
1333 1792
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1334
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1793
+	    		if (isset($line['inf']['sq'])) {
1794
+	    			$data['squawk'] = $line['inf']['sq'];
1795
+	    		}
1796
+	    		// squawk
1335 1797
 	    		//$data['aircraft_icao'] = $line[8];
1336
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1798
+	    		if (isset($line['inf']['rc'])) {
1799
+	    			$data['registration'] = $line['inf']['rc'];
1800
+	    		}
1337 1801
 			//$data['departure_airport_iata'] = $line[11];
1338 1802
 			//$data['arrival_airport_iata'] = $line[12];
1339 1803
 	    		//$data['emergency'] = ''; // emergency
1340 1804
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1341 1805
 	    		$data['format_source'] = 'radarvirtueljson';
1342 1806
     			$data['id_source'] = $id_source;
1343
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1344
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1807
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1808
+				$data['noarchive'] = true;
1809
+			}
1810
+			if (isset($value['name']) && $value['name'] != '') {
1811
+				$data['source_name'] = $value['name'];
1812
+			}
1345 1813
 			$SI->add($data);
1346 1814
 			unset($data);
1347 1815
 		    }
@@ -1367,30 +1835,65 @@  discard block
 block discarded – undo
1367 1835
 		    $data['id'] = $line['id'];
1368 1836
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1369 1837
 		    $data['ident'] = $line['callsign']; // ident
1370
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1371
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1372
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1373
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1374
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1375
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1838
+		    if (isset($line['pilotid'])) {
1839
+		    	$data['pilot_id'] = $line['pilotid'];
1840
+		    }
1841
+		    // pilot id
1842
+		    if (isset($line['name'])) {
1843
+		    	$data['pilot_name'] = $line['name'];
1844
+		    }
1845
+		    // pilot name
1846
+		    if (isset($line['alt'])) {
1847
+		    	$data['altitude'] = $line['alt'];
1848
+		    }
1849
+		    // altitude
1850
+		    if (isset($line['gs'])) {
1851
+		    	$data['speed'] = $line['gs'];
1852
+		    }
1853
+		    // speed
1854
+		    if (isset($line['heading'])) {
1855
+		    	$data['heading'] = $line['heading'];
1856
+		    }
1857
+		    // heading
1858
+		    if (isset($line['route'])) {
1859
+		    	$data['waypoints'] = $line['route'];
1860
+		    }
1861
+		    // route
1376 1862
 		    $data['latitude'] = $line['lat']; // lat
1377 1863
 		    $data['longitude'] = $line['lon']; // long
1378 1864
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1379 1865
 		    //$data['squawk'] = $line['squawk']; // squawk
1380 1866
 		    //$data['emergency'] = ''; // emergency
1381
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1382
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1383
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1867
+		    if (isset($line['depicao'])) {
1868
+		    	$data['departure_airport_icao'] = $line['depicao'];
1869
+		    }
1870
+		    if (isset($line['deptime'])) {
1871
+		    	$data['departure_airport_time'] = $line['deptime'];
1872
+		    }
1873
+		    if (isset($line['arricao'])) {
1874
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1875
+		    }
1384 1876
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1385
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1386
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1387
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1388
-		    else $data['info'] = '';
1877
+		    if (isset($line['aircraft'])) {
1878
+		    	$data['aircraft_icao'] = $line['aircraft'];
1879
+		    }
1880
+		    if (isset($line['transponder'])) {
1881
+		    	$data['squawk'] = $line['transponder'];
1882
+		    }
1883
+		    if (isset($line['atis'])) {
1884
+		    	$data['info'] = $line['atis'];
1885
+		    } else {
1886
+		    	$data['info'] = '';
1887
+		    }
1389 1888
 		    $data['format_source'] = 'pireps';
1390 1889
     		    $data['id_source'] = $id_source;
1391 1890
 		    $data['datetime'] = date('Y-m-d H:i:s');
1392
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1393
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1891
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1892
+		    	$data['noarchive'] = true;
1893
+		    }
1894
+		    if (isset($value['name']) && $value['name'] != '') {
1895
+		    	$data['source_name'] = $value['name'];
1896
+		    }
1394 1897
 		    if ($line['icon'] === 'plane') {
1395 1898
 			$SI->add($data);
1396 1899
 		    //    print_r($data);
@@ -1399,16 +1902,28 @@  discard block
 block discarded – undo
1399 1902
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1400 1903
 			$typec = substr($data['ident'],-3);
1401 1904
 			$data['type'] = '';
1402
-			if ($typec === 'APP') $data['type'] = 'Approach';
1403
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1404
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1405
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1406
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1407
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1408
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1409
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1410
-			else $data['type'] = 'Observer';
1411
-			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']);
1905
+			if ($typec === 'APP') {
1906
+				$data['type'] = 'Approach';
1907
+			} elseif ($typec === 'TWR') {
1908
+				$data['type'] = 'Tower';
1909
+			} elseif ($typec === 'OBS') {
1910
+				$data['type'] = 'Observer';
1911
+			} elseif ($typec === 'GND') {
1912
+				$data['type'] = 'Ground';
1913
+			} elseif ($typec === 'DEL') {
1914
+				$data['type'] = 'Delivery';
1915
+			} elseif ($typec === 'DEP') {
1916
+				$data['type'] = 'Departure';
1917
+			} elseif ($typec === 'FSS') {
1918
+				$data['type'] = 'Flight Service Station';
1919
+			} elseif ($typec === 'CTR') {
1920
+				$data['type'] = 'Control Radar or Centre';
1921
+			} else {
1922
+				$data['type'] = 'Observer';
1923
+			}
1924
+			if (isset($ATC)) {
1925
+				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']);
1926
+			}
1412 1927
 		    }
1413 1928
 		    unset($data);
1414 1929
 		}
@@ -1423,7 +1938,9 @@  discard block
 block discarded – undo
1423 1938
 	    )
1424 1939
 	) {
1425 1940
 	    //$buffer = $Common->getData($hosts[$id]);
1426
-	    if ($globalDebug) echo 'Get Data...'."\n";
1941
+	    if ($globalDebug) {
1942
+	    	echo 'Get Data...'."\n";
1943
+	    }
1427 1944
 	    $buffer = $Common->getData($value['host']);
1428 1945
 	    $all_data = json_decode($buffer,true);
1429 1946
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1431,10 +1948,16 @@  discard block
 block discarded – undo
1431 1948
 		foreach ($all_data as $line) {
1432 1949
 	    	    $data = array();
1433 1950
 	    	    //$data['id'] = $line['id']; // id not usable
1434
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1951
+	    	    if (isset($line['pilotid'])) {
1952
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1953
+	    	    }
1435 1954
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1436
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1437
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1955
+	    	    if (isset($line['pilotname'])) {
1956
+	    	    	$data['pilot_name'] = $line['pilotname'];
1957
+	    	    }
1958
+	    	    if (isset($line['pilotid'])) {
1959
+	    	    	$data['pilot_id'] = $line['pilotid'];
1960
+	    	    }
1438 1961
 	    	    $data['ident'] = $line['flightnum']; // ident
1439 1962
 	    	    $data['altitude'] = $line['alt']; // altitude
1440 1963
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1450,7 +1973,9 @@  discard block
 block discarded – undo
1450 1973
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1451 1974
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1452 1975
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1453
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1976
+	    	    } else {
1977
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1978
+	    	    }
1454 1979
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1455 1980
 	    	    $data['departure_airport_time'] = $line['deptime'];
1456 1981
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1458,29 +1983,47 @@  discard block
 block discarded – undo
1458 1983
     		    if (isset($line['registration'])) {
1459 1984
     			$data['registration'] = $line['registration'];
1460 1985
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1461
-    		    } else $data['registration'] = $line['aircraft'];
1462
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1463
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1986
+    		    } else {
1987
+    		    	$data['registration'] = $line['aircraft'];
1988
+    		    }
1989
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1990
+		    	$data['noarchive'] = true;
1991
+		    }
1992
+		    if (isset($line['route'])) {
1993
+		    	$data['waypoints'] = $line['route'];
1994
+		    }
1995
+		    // route
1464 1996
 		    if (isset($line['aircraftname'])) {
1465 1997
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1466 1998
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1467 1999
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1468
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1469
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1470
-	    		else {
2000
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
2001
+	    			$data['aircraft_icao'] = $aircraft_data[0];
2002
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
2003
+	    			$data['aircraft_icao'] = $aircraft_data[1];
2004
+	    		} else {
1471 2005
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1472
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1473
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2006
+	    		    if (isset($aircraft_data[1])) {
2007
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
2008
+	    		    } else {
2009
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2010
+	    		    }
1474 2011
 	    		}
1475 2012
 	    	    }
1476
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
2013
+    		    if (isset($line['route'])) {
2014
+    		    	$data['waypoints'] = $line['route'];
2015
+    		    }
1477 2016
     		    $data['id_source'] = $id_source;
1478 2017
 	    	    $data['format_source'] = 'phpvmacars';
1479
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2018
+		    if (isset($value['name']) && $value['name'] != '') {
2019
+		    	$data['source_name'] = $value['name'];
2020
+		    }
1480 2021
 		    $SI->add($data);
1481 2022
 		    unset($data);
1482 2023
 		}
1483
-		if ($globalDebug) echo 'No more data...'."\n";
2024
+		if ($globalDebug) {
2025
+			echo 'No more data...'."\n";
2026
+		}
1484 2027
 		unset($buffer);
1485 2028
 		unset($all_data);
1486 2029
 	    }
@@ -1493,7 +2036,9 @@  discard block
 block discarded – undo
1493 2036
 	    )
1494 2037
 	) {
1495 2038
 	    //$buffer = $Common->getData($hosts[$id]);
1496
-	    if ($globalDebug) echo 'Get Data...'."\n";
2039
+	    if ($globalDebug) {
2040
+	    	echo 'Get Data...'."\n";
2041
+	    }
1497 2042
 	    $buffer = $Common->getData($value['host']);
1498 2043
 	    $all_data = json_decode($buffer,true);
1499 2044
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1504,10 +2049,16 @@  discard block
 block discarded – undo
1504 2049
 	    	    //$data['id'] = $line['id']; // id not usable
1505 2050
 	    	    $data['id'] = $line['id'];
1506 2051
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1507
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1508
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
2052
+	    	    if (isset($line['user']['username'])) {
2053
+	    	    	$data['pilot_name'] = $line['user']['username'];
2054
+	    	    }
2055
+	    	    if (isset($line['user_id'])) {
2056
+	    	    	$data['pilot_id'] = $line['user_id'];
2057
+	    	    }
1509 2058
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1510
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2059
+	    	    if (is_numeric($data['ident'])) {
2060
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2061
+	    	    }
1511 2062
 	    	    $data['altitude'] = $line['altitude']; // altitude
1512 2063
 	    	    $data['speed'] = $line['groundspeed']; // speed
1513 2064
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1520,7 +2071,9 @@  discard block
 block discarded – undo
1520 2071
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1521 2072
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1522 2073
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1523
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2074
+	    	    } else {
2075
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2076
+	    	    }
1524 2077
 	    	    
1525 2078
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1526 2079
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1528,17 +2081,26 @@  discard block
 block discarded – undo
1528 2081
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1529 2082
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1530 2083
 
1531
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1532
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
2084
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2085
+		    	$data['noarchive'] = true;
2086
+		    }
2087
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
2088
+		    	$data['waypoints'] = $line['bid']['route'];
2089
+		    }
2090
+		    // route
1533 2091
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1534 2092
 
1535 2093
     		    $data['id_source'] = $id_source;
1536 2094
 	    	    $data['format_source'] = 'vaos';
1537
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2095
+		    if (isset($value['name']) && $value['name'] != '') {
2096
+		    	$data['source_name'] = $value['name'];
2097
+		    }
1538 2098
 		    $SI->add($data);
1539 2099
 		    unset($data);
1540 2100
 		}
1541
-		if ($globalDebug) echo 'No more data...'."\n";
2101
+		if ($globalDebug) {
2102
+			echo 'No more data...'."\n";
2103
+		}
1542 2104
 		unset($buffer);
1543 2105
 		unset($all_data);
1544 2106
 	    }
@@ -1551,7 +2113,9 @@  discard block
 block discarded – undo
1551 2113
 	    )
1552 2114
 	) {
1553 2115
 	    //$buffer = $Common->getData($hosts[$id]);
1554
-	    if ($globalDebug) echo 'Get Data...'."\n";
2116
+	    if ($globalDebug) {
2117
+	    	echo 'Get Data...'."\n";
2118
+	    }
1555 2119
 	    $buffer = $Common->getData($value['host']);
1556 2120
 	    $all_data = json_decode($buffer,true);
1557 2121
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1580,16 +2144,25 @@  discard block
 block discarded – undo
1580 2144
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1581 2145
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1582 2146
     		    //$data['registration'] = $line['aircraft'];
1583
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2147
+		    if (isset($line['route'])) {
2148
+		    	$data['waypoints'] = $line['route'];
2149
+		    }
2150
+		    // route
1584 2151
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1585 2152
     		    $data['id_source'] = $id_source;
1586 2153
 	    	    $data['format_source'] = 'vam';
1587
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1588
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2154
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2155
+		    	$data['noarchive'] = true;
2156
+		    }
2157
+		    if (isset($value['name']) && $value['name'] != '') {
2158
+		    	$data['source_name'] = $value['name'];
2159
+		    }
1589 2160
 		    $SI->add($data);
1590 2161
 		    unset($data);
1591 2162
 		}
1592
-		if ($globalDebug) echo 'No more data...'."\n";
2163
+		if ($globalDebug) {
2164
+			echo 'No more data...'."\n";
2165
+		}
1593 2166
 		unset($buffer);
1594 2167
 		unset($all_data);
1595 2168
 	    }
@@ -1602,7 +2175,9 @@  discard block
 block discarded – undo
1602 2175
 	    )
1603 2176
 	) {
1604 2177
 	    //$buffer = $Common->getData($hosts[$id]);
1605
-	    if ($globalDebug) echo 'Get Data...'."\n";
2178
+	    if ($globalDebug) {
2179
+	    	echo 'Get Data...'."\n";
2180
+	    }
1606 2181
 	    $buffer = $Common->getData($value['host']);
1607 2182
 	    $all_data = json_decode($buffer,true);
1608 2183
 	    if ($buffer != '') {
@@ -1620,12 +2195,16 @@  discard block
 block discarded – undo
1620 2195
 			$data['id_source'] = $id_source;
1621 2196
 			$data['format_source'] = 'blitzortung';
1622 2197
 			$SI->add($data);
1623
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2198
+			if ($globalDebug) {
2199
+				echo '☈ Lightning added'."\n";
2200
+			}
1624 2201
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1625 2202
 			unset($data);
1626 2203
 		    }
1627 2204
 		}
1628
-		if ($globalDebug) echo 'No more data...'."\n";
2205
+		if ($globalDebug) {
2206
+			echo 'No more data...'."\n";
2207
+		}
1629 2208
 		unset($buffer);
1630 2209
 	    }
1631 2210
 	    $last_exec[$id]['last'] = time();
@@ -1654,10 +2233,15 @@  discard block
 block discarded – undo
1654 2233
                 }
1655 2234
             } else {
1656 2235
                 $format = $value['format'];
1657
-                if (isset($tt[$format])) $tt[$format]++;
1658
-                else $tt[$format] = 0;
2236
+                if (isset($tt[$format])) {
2237
+                	$tt[$format]++;
2238
+                } else {
2239
+                	$tt[$format] = 0;
2240
+                }
1659 2241
                 if ($tt[$format] > 30) {
1660
-                    if ($globalDebug) echo 'Reconnect...'."\n";
2242
+                    if ($globalDebug) {
2243
+                    	echo 'Reconnect...'."\n";
2244
+                    }
1661 2245
                     sleep(2);
1662 2246
                     //$sourceeen[] = $value;
1663 2247
                     //connect_all($sourceeen);
@@ -1674,7 +2258,9 @@  discard block
 block discarded – undo
1674 2258
 	    $write = NULL;
1675 2259
 	    $e = NULL;
1676 2260
 	    $n = socket_select($read, $write, $e, $timeout);
1677
-	    if ($e != NULL) var_dump($e);
2261
+	    if ($e != NULL) {
2262
+	    	var_dump($e);
2263
+	    }
1678 2264
 	    if ($n > 0) {
1679 2265
 		$reset = 0;
1680 2266
 		foreach ($read as $nb => $r) {
@@ -1696,13 +2282,17 @@  discard block
 block discarded – undo
1696 2282
 		    if ($buffer !== FALSE) {
1697 2283
 			if ($format === 'vrstcp') {
1698 2284
 			    $buffer = explode('},{',$buffer);
1699
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2285
+			} else {
2286
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2287
+			}
1700 2288
 		    }
1701 2289
 		    // SBS format is CSV format
1702 2290
 		    if ($buffer !== FALSE && $buffer !== '') {
1703 2291
 			$tt[$format] = 0;
1704 2292
 			if ($format === 'acarssbs3') {
1705
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2293
+			    if ($globalDebug) {
2294
+			    	echo 'ACARS : '.$buffer."\n";
2295
+			    }
1706 2296
 			    $ACARS->add(trim($buffer));
1707 2297
 			    $ACARS->deleteLiveAcarsData();
1708 2298
 			} elseif ($format === 'raw') {
@@ -1712,9 +2302,15 @@  discard block
 block discarded – undo
1712 2302
 				//if (!empty($data)) print_r($data);
1713 2303
 				$data['datetime'] = date('Y-m-d H:i:s');
1714 2304
 				$data['format_source'] = 'raw';
1715
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1716
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1717
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2305
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2306
+					$data['source_name'] = $globalSources[$nb]['name'];
2307
+				}
2308
+				if (isset($globalSources[$nb]['sourcestats'])) {
2309
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2310
+				}
2311
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2312
+					$data['noarchive'] = true;
2313
+				}
1718 2314
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1719 2315
 				$SI->add($data);
1720 2316
 				unset($data);
@@ -1722,22 +2318,54 @@  discard block
 block discarded – undo
1722 2318
 			} elseif ($format === 'ais') {
1723 2319
 			    $ais_data = $AIS->parse_line(trim($buffer));
1724 2320
 			    $data = array();
1725
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1726
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1727
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1728
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1729
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1730
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1731
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1732
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1733
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1734
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1735
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1736
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1737
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1738
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1739
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1740
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2321
+			    if (isset($ais_data['ident'])) {
2322
+			    	$data['ident'] = $ais_data['ident'];
2323
+			    }
2324
+			    if (isset($ais_data['mmsi'])) {
2325
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2326
+			    }
2327
+			    if (isset($ais_data['speed'])) {
2328
+			    	$data['speed'] = $ais_data['speed'];
2329
+			    }
2330
+			    if (isset($ais_data['heading'])) {
2331
+			    	$data['heading'] = $ais_data['heading'];
2332
+			    }
2333
+			    if (isset($ais_data['latitude'])) {
2334
+			    	$data['latitude'] = $ais_data['latitude'];
2335
+			    }
2336
+			    if (isset($ais_data['longitude'])) {
2337
+			    	$data['longitude'] = $ais_data['longitude'];
2338
+			    }
2339
+			    if (isset($ais_data['status'])) {
2340
+			    	$data['status'] = $ais_data['status'];
2341
+			    }
2342
+			    if (isset($ais_data['statusid'])) {
2343
+			    	$data['status_id'] = $ais_data['statusid'];
2344
+			    }
2345
+			    if (isset($ais_data['type'])) {
2346
+			    	$data['type'] = $ais_data['type'];
2347
+			    }
2348
+			    if (isset($ais_data['imo'])) {
2349
+			    	$data['imo'] = $ais_data['imo'];
2350
+			    }
2351
+			    if (isset($ais_data['callsign'])) {
2352
+			    	$data['callsign'] = $ais_data['callsign'];
2353
+			    }
2354
+			    if (isset($ais_data['destination'])) {
2355
+			    	$data['arrival_code'] = $ais_data['destination'];
2356
+			    }
2357
+			    if (isset($ais_data['eta_ts'])) {
2358
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2359
+			    }
2360
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2361
+			    	$data['noarchive'] = true;
2362
+			    }
2363
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2364
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2365
+			    }
2366
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2367
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2368
+			    }
1741 2369
 
1742 2370
 			    if (isset($ais_data['timestamp'])) {
1743 2371
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1746,7 +2374,9 @@  discard block
 block discarded – undo
1746 2374
 			    }
1747 2375
 			    $data['format_source'] = 'aisnmea';
1748 2376
     			    $data['id_source'] = $id_source;
1749
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2377
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2378
+			    	$MI->add($data);
2379
+			    }
1750 2380
 			    unset($data);
1751 2381
                         } elseif ($format === 'flightgearsp') {
1752 2382
                     	    //echo $buffer."\n";
@@ -1764,12 +2394,18 @@  discard block
 block discarded – undo
1764 2394
 				$data['speed'] = round($line[5]*1.94384);
1765 2395
 				$data['datetime'] = date('Y-m-d H:i:s');
1766 2396
 				$data['format_source'] = 'flightgearsp';
1767
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1768
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2397
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2398
+					$data['noarchive'] = true;
2399
+				}
2400
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2401
+					$SI->add($data);
2402
+				}
1769 2403
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1770 2404
 			    }
1771 2405
                         } elseif ($format === 'acars') {
1772
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2406
+                    	    if ($globalDebug) {
2407
+                    	    	echo 'ACARS : '.$buffer."\n";
2408
+                    	    }
1773 2409
 			    $ACARS->add(trim($buffer));
1774 2410
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1775 2411
 			    $ACARS->deleteLiveAcarsData();
@@ -1790,8 +2426,12 @@  discard block
 block discarded – undo
1790 2426
 				    $aircraft_type = $line[10];
1791 2427
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1792 2428
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1793
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1794
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2429
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2430
+				    	$data['noarchive'] = true;
2431
+				    }
2432
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2433
+				    	$SI->add($data);
2434
+				    }
1795 2435
 				}
1796 2436
 			    }
1797 2437
 			} elseif ($format === 'beast') {
@@ -1801,28 +2441,62 @@  discard block
 block discarded – undo
1801 2441
 			    foreach($buffer as $all_data) {
1802 2442
 				$line = json_decode('{'.$all_data.'}',true);
1803 2443
 				$data = array();
1804
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1805
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1806
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1807
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1808
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1809
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1810
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2444
+				if (isset($line['Icao'])) {
2445
+					$data['hex'] = $line['Icao'];
2446
+				}
2447
+				// hex
2448
+				if (isset($line['Call'])) {
2449
+					$data['ident'] = $line['Call'];
2450
+				}
2451
+				// ident
2452
+				if (isset($line['Alt'])) {
2453
+					$data['altitude'] = $line['Alt'];
2454
+				}
2455
+				// altitude
2456
+				if (isset($line['Spd'])) {
2457
+					$data['speed'] = $line['Spd'];
2458
+				}
2459
+				// speed
2460
+				if (isset($line['Trak'])) {
2461
+					$data['heading'] = $line['Trak'];
2462
+				}
2463
+				// heading
2464
+				if (isset($line['Lat'])) {
2465
+					$data['latitude'] = $line['Lat'];
2466
+				}
2467
+				// lat
2468
+				if (isset($line['Long'])) {
2469
+					$data['longitude'] = $line['Long'];
2470
+				}
2471
+				// long
1811 2472
 				//$data['verticalrate'] = $line['']; // verticale rate
1812
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2473
+				if (isset($line['Sqk'])) {
2474
+					$data['squawk'] = $line['Sqk'];
2475
+				}
2476
+				// squawk
1813 2477
 				$data['emergency'] = ''; // emergency
1814
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2478
+				if (isset($line['Reg'])) {
2479
+					$data['registration'] = $line['Reg'];
2480
+				}
1815 2481
 				/*
1816 2482
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1817 2483
 				else $data['datetime'] = date('Y-m-d H:i:s');
1818 2484
 				*/
1819 2485
 				$data['datetime'] = date('Y-m-d H:i:s');
1820
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2486
+				if (isset($line['Type'])) {
2487
+					$data['aircraft_icao'] = $line['Type'];
2488
+				}
1821 2489
 		    		$data['format_source'] = 'vrstcp';
1822 2490
 				$data['id_source'] = $id_source;
1823
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1824
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1825
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2491
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2492
+					$data['noarchive'] = true;
2493
+				}
2494
+				if (isset($value['name']) && $value['name'] != '') {
2495
+					$data['source_name'] = $value['name'];
2496
+				}
2497
+				if (isset($data['latitude']) && isset($data['hex'])) {
2498
+					$SI->add($data);
2499
+				}
1826 2500
 				unset($data);
1827 2501
 			    }
1828 2502
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1835,22 +2509,46 @@  discard block
 block discarded – undo
1835 2509
     				$data['hex'] = $lined['hexid'];
1836 2510
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1837 2511
     				$data['datetime'] = date('Y-m-d H:i:s');;
1838
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1839
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1840
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1841
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1842
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1843
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1844
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2512
+    				if (isset($lined['ident'])) {
2513
+    					$data['ident'] = $lined['ident'];
2514
+    				}
2515
+    				if (isset($lined['lat'])) {
2516
+    					$data['latitude'] = $lined['lat'];
2517
+    				}
2518
+    				if (isset($lined['lon'])) {
2519
+    					$data['longitude'] = $lined['lon'];
2520
+    				}
2521
+    				if (isset($lined['speed'])) {
2522
+    					$data['speed'] = $lined['speed'];
2523
+    				}
2524
+    				if (isset($lined['squawk'])) {
2525
+    					$data['squawk'] = $lined['squawk'];
2526
+    				}
2527
+    				if (isset($lined['alt'])) {
2528
+    					$data['altitude'] = $lined['alt'];
2529
+    				}
2530
+    				if (isset($lined['heading'])) {
2531
+    					$data['heading'] = $lined['heading'];
2532
+    				}
1845 2533
     				$data['id_source'] = $id_source;
1846 2534
     				$data['format_source'] = 'tsv';
1847
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1848
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1849
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1850
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2535
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2536
+    					$data['source_name'] = $globalSources[$nb]['name'];
2537
+    				}
2538
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2539
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2540
+    				}
2541
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2542
+					$data['noarchive'] = true;
2543
+				}
2544
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2545
+    					$SI->add($data);
2546
+    				}
1851 2547
     				unset($lined);
1852 2548
     				unset($data);
1853
-    			    } else $error = true;
2549
+    			    } else {
2550
+    			    	$error = true;
2551
+    			    }
1854 2552
 			} elseif ($format === 'aprs' && $use_aprs) {
1855 2553
 			    if ($aprs_connect === 0) {
1856 2554
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1876,47 +2574,96 @@  discard block
 block discarded – undo
1876 2574
 				    $aprs_last_tx = time();
1877 2575
 				    $data = array();
1878 2576
 				    //print_r($line);
1879
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1880
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1881
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1882
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1883
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1884
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1885
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1886
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1887
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1888
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2577
+				    if (isset($line['address'])) {
2578
+				    	$data['hex'] = $line['address'];
2579
+				    }
2580
+				    if (isset($line['mmsi'])) {
2581
+				    	$data['mmsi'] = $line['mmsi'];
2582
+				    }
2583
+				    if (isset($line['imo'])) {
2584
+				    	$data['imo'] = $line['imo'];
2585
+				    }
2586
+				    if (isset($line['squawk'])) {
2587
+				    	$data['squawk'] = $line['squawk'];
2588
+				    }
2589
+				    if (isset($line['arrival_code'])) {
2590
+				    	$data['arrival_code'] = $line['arrival_code'];
2591
+				    }
2592
+				    if (isset($line['arrival_date'])) {
2593
+				    	$data['arrival_date'] = $line['arrival_date'];
2594
+				    }
2595
+				    if (isset($line['typeid'])) {
2596
+				    	$data['type_id'] = $line['typeid'];
2597
+				    }
2598
+				    if (isset($line['statusid'])) {
2599
+				    	$data['status_id'] = $line['statusid'];
2600
+				    }
2601
+				    if (isset($line['timestamp'])) {
2602
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2603
+				    } else {
2604
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2605
+				    }
1889 2606
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1890
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2607
+				    if (isset($line['ident'])) {
2608
+				    	$data['ident'] = $line['ident'];
2609
+				    }
1891 2610
 				    $data['latitude'] = $line['latitude'];
1892 2611
 				    $data['longitude'] = $line['longitude'];
1893 2612
 				    //$data['verticalrate'] = $line[16];
1894
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2613
+				    if (isset($line['speed'])) {
2614
+				    	$data['speed'] = $line['speed'];
2615
+				    }
1895 2616
 				    //else $data['speed'] = 0;
1896
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1897
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1898
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2617
+				    if (isset($line['altitude'])) {
2618
+				    	$data['altitude'] = $line['altitude'];
2619
+				    }
2620
+				    if (isset($line['comment'])) {
2621
+				    	$data['comment'] = $line['comment'];
2622
+				    }
2623
+				    if (isset($line['symbol'])) {
2624
+				    	$data['type'] = $line['symbol'];
2625
+				    }
1899 2626
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1900 2627
 				    
1901
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2628
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2629
+				    	$data['heading'] = $line['heading'];
2630
+				    }
1902 2631
 				    //else echo 'No heading...'."\n";
1903 2632
 				    //else $data['heading'] = 0;
1904
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2633
+				    if (isset($line['stealth'])) {
2634
+				    	$data['aircraft_type'] = $line['stealth'];
2635
+				    }
1905 2636
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1906
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1907
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1908
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1909
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2637
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2638
+				    	$data['noarchive'] = true;
2639
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2640
+				    	$data['noarchive'] = false;
2641
+				    }
2642
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2643
+				    	$data['noarchive'] = true;
2644
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2645
+				    	$data['noarchive'] = false;
2646
+				    }
1910 2647
     				    $data['id_source'] = $id_source;
1911
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1912
-				    else $data['format_source'] = 'aprs';
2648
+    				    if (isset($line['format_source'])) {
2649
+    				    	$data['format_source'] = $line['format_source'];
2650
+    				    } else {
2651
+				    	$data['format_source'] = 'aprs';
2652
+				    }
1913 2653
 				    $data['source_name'] = $line['source'];
1914
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1915
-				    else $data['source_type'] = 'flarm';
1916
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2654
+				    if (isset($line['source_type'])) {
2655
+				    	$data['source_type'] = $line['source_type'];
2656
+				    } else {
2657
+				    	$data['source_type'] = 'flarm';
2658
+				    }
2659
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2660
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2661
+    				    }
1917 2662
 				    $currentdate = date('Y-m-d H:i:s');
1918 2663
 				    $aprsdate = strtotime($data['datetime']);
1919
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2664
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2665
+				    	$data['altitude_relative'] = 'AMSL';
2666
+				    }
1920 2667
 				    // Accept data if time <= system time + 20s
1921 2668
 				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1922 2669
 				    if (
@@ -1928,7 +2675,9 @@  discard block
 block discarded – undo
1928 2675
 					$send = $SI->add($data);
1929 2676
 				    } elseif ($data['source_type'] === 'ais') {
1930 2677
 					$data['type'] = '';
1931
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2678
+					if (isset($globalMarine) && $globalMarine) {
2679
+						$send = $MI->add($data);
2680
+					}
1932 2681
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1933 2682
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1934 2683
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1936,8 +2685,12 @@  discard block
 block discarded – undo
1936 2685
 					    $line['symbol'] === 'Glider' || 
1937 2686
 					    $line['symbol'] === 'No. Plane' || 
1938 2687
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1939
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1940
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2688
+					    if ($line['symbol'] === 'Ballon') {
2689
+					    	$data['aircraft_icao'] = 'BALL';
2690
+					    }
2691
+					    if ($line['symbol'] === 'Glider') {
2692
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2693
+					    }
1941 2694
 					    $send = $SI->add($data);
1942 2695
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1943 2696
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1968,9 +2721,13 @@  discard block
 block discarded – undo
1968 2721
 				    //} 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') {
1969 2722
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1970 2723
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1971
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2724
+					if (isset($globalTracker) && $globalTracker) {
2725
+						$send = $TI->add($data);
2726
+					}
1972 2727
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1973
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2728
+					if (!isset($data['altitude'])) {
2729
+						$data['altitude'] = 0;
2730
+					}
1974 2731
 					$Source->deleteOldLocationByType('gs');
1975 2732
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1976 2733
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1979,7 +2736,9 @@  discard block
 block discarded – undo
1979 2736
 					}
1980 2737
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1981 2738
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1982
-					if ($globalDebug) echo '# Weather Station added'."\n";
2739
+					if ($globalDebug) {
2740
+						echo '# Weather Station added'."\n";
2741
+					}
1983 2742
 					$Source->deleteOldLocationByType('wx');
1984 2743
 					$weather_data = json_encode($line);
1985 2744
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1989,7 +2748,9 @@  discard block
 block discarded – undo
1989 2748
 					}
1990 2749
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1991 2750
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1992
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2751
+					if ($globalDebug) {
2752
+						echo '☈ Lightning added'."\n";
2753
+					}
1993 2754
 					$Source->deleteOldLocationByType('lightning');
1994 2755
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1995 2756
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -2001,8 +2762,7 @@  discard block
 block discarded – undo
2001 2762
 				    	print_r($line);
2002 2763
 				    }
2003 2764
 				    unset($data);
2004
-				}
2005
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2765
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2006 2766
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2007 2767
 				}
2008 2768
 				/*
@@ -2011,7 +2771,9 @@  discard block
 block discarded – undo
2011 2771
 				}
2012 2772
 				*/
2013 2773
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2014
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2774
+				elseif ($line === true && $globalDebug) {
2775
+					echo '!! Failed : '.$buffer."!!\n";
2776
+				}
2015 2777
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2016 2778
 					$Source->deleteOldLocationByType('lightning');
2017 2779
 					$Source->deleteOldLocationByType('wx');
@@ -2048,27 +2810,47 @@  discard block
 block discarded – undo
2048 2810
     				$data['ground'] = $line[21];
2049 2811
     				$data['emergency'] = $line[19];
2050 2812
     				$data['format_source'] = 'sbs';
2051
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2052
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2053
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2054
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2813
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2814
+					$data['source_name'] = $globalSources[$nb]['name'];
2815
+				} elseif ($line[0] == 'MLAT') {
2816
+					$data['source_name'] = 'MLAT';
2817
+				}
2818
+				if (isset($globalSources[$nb]['sourcestats'])) {
2819
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2820
+				}
2821
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2822
+					$data['noarchive'] = true;
2823
+				}
2055 2824
     				$data['id_source'] = $id_source;
2056
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2057
-    				else $error = true;
2825
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2826
+    					$send = $SI->add($data);
2827
+    				} else {
2828
+    					$error = true;
2829
+    				}
2058 2830
     				unset($data);
2059
-    			    } else $error = true;
2831
+    			    } else {
2832
+    			    	$error = true;
2833
+    			    }
2060 2834
 			    if ($error) {
2061 2835
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2062
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2836
+					if ($globalDebug) {
2837
+						echo "Not a message. Ignoring... \n";
2838
+					}
2063 2839
 				} else {
2064
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2840
+					if ($globalDebug) {
2841
+						echo "Wrong line format. Ignoring... \n";
2842
+					}
2065 2843
 					if ($globalDebug) {
2066 2844
 						echo $buffer;
2067 2845
 						//print_r($line);
2068 2846
 					}
2069 2847
 					//socket_close($r);
2070
-					if ($globalDebug) echo "Reconnect after an error...\n";
2071
-					if ($format === 'aprs') $aprs_connect = 0;
2848
+					if ($globalDebug) {
2849
+						echo "Reconnect after an error...\n";
2850
+					}
2851
+					if ($format === 'aprs') {
2852
+						$aprs_connect = 0;
2853
+					}
2072 2854
 					$sourceer[$nb] = $globalSources[$nb];
2073 2855
 					connect_all($sourceer);
2074 2856
 					$sourceer = array();
@@ -2076,10 +2858,14 @@  discard block
 block discarded – undo
2076 2858
 			    }
2077 2859
 			}
2078 2860
 			// Sleep for xxx microseconds
2079
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2861
+			if (isset($globalSBSSleep)) {
2862
+				usleep($globalSBSSleep);
2863
+			}
2080 2864
 		    } else {
2081 2865
 			if ($format === 'flightgearmp') {
2082
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2866
+			    	if ($globalDebug) {
2867
+			    		echo "Reconnect FlightGear MP...";
2868
+			    	}
2083 2869
 				//@socket_close($r);
2084 2870
 				sleep($globalMinFetch);
2085 2871
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2088,10 +2874,15 @@  discard block
 block discarded – undo
2088 2874
 				break;
2089 2875
 				
2090 2876
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2091
-			    if (isset($tt[$format])) $tt[$format]++;
2092
-			    else $tt[$format] = 0;
2877
+			    if (isset($tt[$format])) {
2878
+			    	$tt[$format]++;
2879
+			    } else {
2880
+			    	$tt[$format] = 0;
2881
+			    }
2093 2882
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
2094
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2883
+				if ($globalDebug) {
2884
+					echo "ERROR : Reconnect ".$format."...";
2885
+				}
2095 2886
 				//@socket_close($r);
2096 2887
 				sleep(2);
2097 2888
 				$aprs_connect = 0;
@@ -2109,11 +2900,17 @@  discard block
 block discarded – undo
2109 2900
 	    } else {
2110 2901
 		$error = socket_strerror(socket_last_error());
2111 2902
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2112
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2113
-			if (isset($globalDebug)) echo "Restarting...\n";
2903
+			if ($globalDebug) {
2904
+				echo "ERROR : socket_select give this error ".$error . "\n";
2905
+			}
2906
+			if (isset($globalDebug)) {
2907
+				echo "Restarting...\n";
2908
+			}
2114 2909
 			// Restart the script if possible
2115 2910
 			if (is_array($sockets)) {
2116
-			    if ($globalDebug) echo "Shutdown all sockets...";
2911
+			    if ($globalDebug) {
2912
+			    	echo "Shutdown all sockets...";
2913
+			    }
2117 2914
 			    
2118 2915
 			    foreach ($sockets as $sock) {
2119 2916
 				@socket_shutdown($sock,2);
@@ -2121,25 +2918,45 @@  discard block
 block discarded – undo
2121 2918
 			    }
2122 2919
 			    
2123 2920
 			}
2124
-			if ($globalDebug) echo "Waiting...";
2921
+			if ($globalDebug) {
2922
+				echo "Waiting...";
2923
+			}
2125 2924
 			sleep(2);
2126 2925
 			$time = time();
2127 2926
 			//connect_all($hosts);
2128 2927
 			$aprs_connect = 0;
2129
-			if ($reset%5 === 0) sleep(20);
2130
-			if ($reset%10 === 0) sleep(100);
2131
-			if ($reset%20 === 0) sleep(200);
2132
-			if ($reset > 100) exit('Too many attempts...');
2133
-			if ($globalDebug) echo "Restart all connections...";
2928
+			if ($reset%5 === 0) {
2929
+				sleep(20);
2930
+			}
2931
+			if ($reset%10 === 0) {
2932
+				sleep(100);
2933
+			}
2934
+			if ($reset%20 === 0) {
2935
+				sleep(200);
2936
+			}
2937
+			if ($reset > 100) {
2938
+				exit('Too many attempts...');
2939
+			}
2940
+			if ($globalDebug) {
2941
+				echo "Restart all connections...";
2942
+			}
2134 2943
 			connect_all($globalSources);
2135 2944
 		}
2136 2945
 	    }
2137 2946
 	}
2138 2947
 	if ($globalDaemon === false) {
2139
-	    if ($globalDebug) echo 'Check all...'."\n";
2140
-	    if (isset($SI)) $SI->checkAll();
2141
-	    if (isset($TI)) $TI->checkAll();
2142
-	    if (isset($MI)) $MI->checkAll();
2948
+	    if ($globalDebug) {
2949
+	    	echo 'Check all...'."\n";
2950
+	    }
2951
+	    if (isset($SI)) {
2952
+	    	$SI->checkAll();
2953
+	    }
2954
+	    if (isset($TI)) {
2955
+	    	$TI->checkAll();
2956
+	    }
2957
+	    if (isset($MI)) {
2958
+	    	$MI->checkAll();
2959
+	    }
2143 2960
 	}
2144 2961
     }
2145 2962
 }
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +647 added lines, -172 removed lines patch added patch discarded remove patch
@@ -4,12 +4,22 @@  discard block
 block discarded – undo
4 4
 if (isset($_SESSION['error'])) {
5 5
 	header('Content-Encoding: none;');
6 6
 	echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.';
7
-	if (isset($_SESSION['error'])) unset($_SESSION['error']);
8
-	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
9
-	if (isset($_SESSION['next'])) unset($_SESSION['next']);
10
-	if (isset($_SESSION['install'])) unset($_SESSION['install']);
11
-	if (isset($_SESSION['identitied'])) unset($_SESSION['identified']);
12
-}
7
+	if (isset($_SESSION['error'])) {
8
+		unset($_SESSION['error']);
9
+	}
10
+	if (isset($_SESSION['errorlst'])) {
11
+		unset($_SESSION['errorlst']);
12
+	}
13
+	if (isset($_SESSION['next'])) {
14
+		unset($_SESSION['next']);
15
+	}
16
+	if (isset($_SESSION['install'])) {
17
+		unset($_SESSION['install']);
18
+	}
19
+	if (isset($_SESSION['identitied'])) {
20
+		unset($_SESSION['identified']);
21
+	}
22
+	}
13 23
 /*
14 24
 if (isset($_SESSION['errorlst'])) {
15 25
 	header('Content-Encoding: none;');
@@ -131,7 +141,9 @@  discard block
 block discarded – undo
131 141
 		if (count($alllng) != count($availablelng)) {
132 142
 			$notavailable = array();
133 143
 			foreach($alllng as $lng) {
134
-				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
144
+				if (!isset($availablelng[$lng])) {
145
+					$notavailable[] = $lng;
146
+				}
135 147
 			}
136 148
 			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
137 149
 		}
@@ -170,7 +182,10 @@  discard block
 block discarded – undo
170 182
 			<legend>Install script configuration</legend>
171 183
 			<p>
172 184
 				<label for="installpass">Install password</label>
173
-				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) print $globalInstallPassword; ?>" />
185
+				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) {
186
+	print $globalInstallPassword;
187
+}
188
+?>" />
174 189
 			</p>
175 190
 			<p class="help-block">Password needed to access this install script. If empty, to access this script,  you will need to change the $globalInstalled setting in require/settings.php to FALSE</p>
176 191
 		</fieldset>
@@ -200,31 +215,49 @@  discard block
 block discarded – undo
200 215
 			</div>
201 216
 			<p>
202 217
 				<label for="dbhost">Database hostname</label>
203
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
218
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
219
+	print $globalDBhost;
220
+}
221
+?>" />
204 222
 			</p>
205 223
 			<p>
206 224
 				<label for="dbport">Database port</label>
207
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
225
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
226
+	print $globalDBport;
227
+}
228
+?>" />
208 229
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
209 230
 			</p>
210 231
 			<p>
211 232
 				<label for="dbname">Database name</label>
212
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
233
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
234
+	print $globalDBname;
235
+}
236
+?>" />
213 237
 			</p>
214 238
 			<p>
215 239
 				<label for="dbuser">Database user</label>
216
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
240
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
241
+	print $globalDBuser;
242
+}
243
+?>" />
217 244
 			</p>
218 245
 			<p>
219 246
 				<label for="dbuserpass">Database user password</label>
220
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
247
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
248
+	print $globalDBpass;
249
+}
250
+?>" />
221 251
 			</p>
222 252
 		</fieldset>
223 253
 		<fieldset id="site">
224 254
 			<legend>Site configuration</legend>
225 255
 			<p>
226 256
 				<label for="sitename">Site name</label>
227
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
257
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
258
+	print $globalName;
259
+}
260
+?>" />
228 261
 			</p>
229 262
 			<p>
230 263
 				<label for="siteurl">Site directory</label>
@@ -237,18 +270,27 @@  discard block
 block discarded – undo
237 270
 					}
238 271
 				    }
239 272
 				?>
240
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
273
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
274
+	print $globalURL;
275
+}
276
+?>" />
241 277
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
242 278
 				<p class="help-block">Can be empty</p>
243 279
 			</p>
244 280
 			<p>
245 281
 				<label for="timezone">Timezone</label>
246
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
282
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
283
+	print $globalTimezone;
284
+}
285
+?>" />
247 286
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
248 287
 			</p>
249 288
 			<p>
250 289
 				<label for="language">Language</label>
251
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
290
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
291
+	print $globalLanguage;
292
+}
293
+?>" />
252 294
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
253 295
 			</p>
254 296
 		</fieldset>
@@ -268,11 +310,17 @@  discard block
 block discarded – undo
268 310
 			<div id="mapbox_data">
269 311
 				<p>
270 312
 					<label for="mapboxid">Mapbox id</label>
271
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
313
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
314
+	print $globalMapboxId;
315
+}
316
+?>" />
272 317
 				</p>
273 318
 				<p>
274 319
 					<label for="mapboxtoken">Mapbox token</label>
275
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
320
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
321
+	print $globalMapboxToken;
322
+}
323
+?>" />
276 324
 				</p>
277 325
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
278 326
 			</div>
@@ -280,7 +328,10 @@  discard block
 block discarded – undo
280 328
 			<div id="google_data">
281 329
 				<p>
282 330
 					<label for="googlekey">Google API key</label>
283
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
331
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
332
+	print $globalGoogleAPIKey;
333
+}
334
+?>" />
284 335
 					<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>
285 336
 				</p>
286 337
 			</div>
@@ -288,7 +339,10 @@  discard block
 block discarded – undo
288 339
 			<div id="bing_data">
289 340
 				<p>
290 341
 					<label for="bingkey">Bing Map key</label>
291
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
342
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
343
+	print $globalBingMapKey;
344
+}
345
+?>" />
292 346
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
293 347
 				</p>
294 348
 			</div>
@@ -296,7 +350,10 @@  discard block
 block discarded – undo
296 350
 			<div id="mapquest_data">
297 351
 				<p>
298 352
 					<label for="mapquestkey">MapQuest key</label>
299
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
353
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
354
+	print $globalMapQuestKey;
355
+}
356
+?>" />
300 357
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
301 358
 				</p>
302 359
 			</div>
@@ -304,11 +361,17 @@  discard block
 block discarded – undo
304 361
 			<div id="here_data">
305 362
 				<p>
306 363
 					<label for="hereappid">Here App_Id</label>
307
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
364
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
365
+	print $globalHereappId;
366
+}
367
+?>" />
308 368
 				</p>
309 369
 				<p>
310 370
 					<label for="hereappcode">Here App_Code</label>
311
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
371
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
372
+	print $globalHereappCode;
373
+}
374
+?>" />
312 375
 				</p>
313 376
 				<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>
314 377
 			</div>
@@ -316,7 +379,10 @@  discard block
 block discarded – undo
316 379
 			<div id="openweathermap_data">
317 380
 				<p>
318 381
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
319
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
382
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
383
+	print $globalOpenWeatherMapKey;
384
+}
385
+?>" />
320 386
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
321 387
 				</p>
322 388
 			</div>
@@ -345,42 +411,86 @@  discard block
 block discarded – undo
345 411
 			<legend>Coverage area</legend>
346 412
 			<p>
347 413
 				<label for="latitudemax">The maximum latitude (north)</label>
348
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
414
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
415
+	print $globalLatitudeMax;
416
+}
417
+?>" />
349 418
 			</p>
350 419
 			<p>
351 420
 				<label for="latitudemin">The minimum latitude (south)</label>
352
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
421
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
422
+	print $globalLatitudeMin;
423
+}
424
+?>" />
353 425
 			</p>
354 426
 			<p>
355 427
 				<label for="longitudemax">The maximum longitude (west)</label>
356
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
428
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
429
+	print $globalLongitudeMax;
430
+}
431
+?>" />
357 432
 			</p>
358 433
 			<p>
359 434
 				<label for="longitudemin">The minimum longitude (east)</label>
360
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
435
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
436
+	print $globalLongitudeMin;
437
+}
438
+?>" />
361 439
 			</p>
362 440
 			<p>
363 441
 				<label for="latitudecenter">The latitude center</label>
364
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
442
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
443
+	print $globalCenterLatitude;
444
+}
445
+?>" />
365 446
 			</p>
366 447
 			<p>
367 448
 				<label for="longitudecenter">The longitude center</label>
368
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
449
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
450
+	print $globalCenterLongitude;
451
+}
452
+?>" />
369 453
 			</p>
370 454
 			<p>
371 455
 				<label for="livezoom">Default Zoom on live map</label>
372
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
456
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
457
+	print $globalLiveZoom;
458
+} else {
459
+	print '9';
460
+}
461
+?>" />
373 462
 			</p>
374 463
 			<p>
375 464
 				<label for="squawk_country">Country for squawk usage</label>
376 465
 				<select name="squawk_country" id="squawk_country">
377
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
378
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
379
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
380
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
381
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
382
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
383
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
466
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
467
+	print ' selected ';
468
+}
469
+?>>UK</option>
470
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
471
+	print ' selected ';
472
+}
473
+?>>NZ</option>
474
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
475
+	print ' selected ';
476
+}
477
+?>>US</option>
478
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
479
+	print ' selected ';
480
+}
481
+?>>AU</option>
482
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
483
+	print ' selected ';
484
+}
485
+?>>NL</option>
486
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
487
+	print ' selected ';
488
+}
489
+?>>FR</option>
490
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
491
+	print ' selected ';
492
+}
493
+?>>TR</option>
384 494
 				</select>
385 495
 			</p>
386 496
 		</fieldset>
@@ -389,15 +499,24 @@  discard block
 block discarded – undo
389 499
 			<p><i>Only put in DB flights that are inside a circle</i></p>
390 500
 			<p>
391 501
 				<label for="latitude">Center latitude</label>
392
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
502
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
503
+	echo $globalDistanceIgnore['latitude'];
504
+}
505
+?>" />
393 506
 			</p>
394 507
 			<p>
395 508
 				<label for="longitude">Center longitude</label>
396
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
509
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
510
+	echo $globalDistanceIgnore['longitude'];
511
+}
512
+?>" />
397 513
 			</p>
398 514
 			<p>
399 515
 				<label for="Distance">Distance (in km)</label>
400
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
516
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
517
+	echo $globalDistanceIgnore['distance'];
518
+}
519
+?>" />
401 520
 			</p>
402 521
 		</fieldset>
403 522
 		<fieldset id="sourceloc">
@@ -523,22 +642,34 @@  discard block
 block discarded – undo
523 642
 			<div id="flightaware_data">
524 643
 				<p>
525 644
 					<label for="flightawareusername">FlightAware username</label>
526
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
645
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
646
+	print $globalFlightAwareUsername;
647
+}
648
+?>" />
527 649
 				</p>
528 650
 				<p>
529 651
 					<label for="flightawarepassword">FlightAware password/API key</label>
530
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
652
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
653
+	print $globalFlightAwarePassword;
654
+}
655
+?>" />
531 656
 				</p>
532 657
 			</div>
533 658
 -->
534 659
 			<div id="sailaway_data">
535 660
 				<p>
536 661
 					<label for="sailawayemail">Sailaway email</label>
537
-					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) print $globalSailaway['email']; ?>" />
662
+					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) {
663
+	print $globalSailaway['email'];
664
+}
665
+?>" />
538 666
 				</p>
539 667
 				<p>
540 668
 					<label for="sailawaypassword">Sailaway password</label>
541
-					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) print $globalSailaway['password']; ?>" />
669
+					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) {
670
+	print $globalSailaway['password'];
671
+}
672
+?>" />
542 673
 				</p>
543 674
 			</div>
544 675
 
@@ -580,7 +711,10 @@  discard block
 block discarded – undo
580 711
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
581 712
 								?>
582 713
 								<td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td>
583
-								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
714
+								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) {
715
+	print $source['port'];
716
+}
717
+?>" /></td>
584 718
 								<?php
585 719
 								    } else {
586 720
 									$hostport = explode(':',$source['host']);
@@ -599,39 +733,126 @@  discard block
 block discarded – undo
599 733
 								?>
600 734
 								<td>
601 735
 									<select name="format[]">
602
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
603
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
604
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
605
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
606
-										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
607
-										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option>
608
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
609
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
610
-                                        <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') print 'selected'; ?>>Radarcape json</option>
611
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
612
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
613
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
614
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
615
-										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
616
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
617
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
618
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
619
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
620
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
621
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
622
-                                        <option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec</option>
623
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
624
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
625
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
626
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
627
-										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') print 'selected'; ?>>Sailaway</option>
736
+										<option value="auto" <?php if (!isset($source['format'])) {
737
+	print 'selected';
738
+}
739
+?>>Auto</option>
740
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
741
+	print 'selected';
742
+}
743
+?>>SBS</option>
744
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
745
+	print 'selected';
746
+}
747
+?>>TSV</option>
748
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
749
+	print 'selected';
750
+}
751
+?>>Raw</option>
752
+										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') {
753
+	print 'selected';
754
+}
755
+?>>Dump1090 aircraft.json</option>
756
+										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') {
757
+	print 'selected';
758
+}
759
+?>>Planefinder client</option>
760
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
761
+	print 'selected';
762
+}
763
+?>>APRS</option>
764
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
765
+	print 'selected';
766
+}
767
+?>>Radarcape deltadb.txt</option>
768
+                                        <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') {
769
+	print 'selected';
770
+}
771
+?>>Radarcape json</option>
772
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
773
+	print 'selected';
774
+}
775
+?>>Vatsim</option>
776
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
777
+	print 'selected';
778
+}
779
+?>>Virtual Radar Server AircraftList.json</option>
780
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
781
+	print 'selected';
782
+}
783
+?>>Virtual Radar Server TCP</option>
784
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
785
+	print 'selected';
786
+}
787
+?>>phpVMS</option>
788
+										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
789
+	print 'selected';
790
+}
791
+?>>Virtual Airline Operations System (VAOS)</option>
792
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
793
+	print 'selected';
794
+}
795
+?>>Virtual Airlines Manager</option>
796
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
797
+	print 'selected';
798
+}
799
+?>>IVAO</option>
800
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
801
+	print 'selected';
802
+}
803
+?>>FlightGear Multiplayer</option>
804
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
805
+	print 'selected';
806
+}
807
+?>>FlightGear Singleplayer</option>
808
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
809
+	print 'selected';
810
+}
811
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
812
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
813
+	print 'selected';
814
+}
815
+?>>ACARS SBS-3 over TCP</option>
816
+                                        <option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') {
817
+	print 'selected';
818
+}
819
+?>>ACARS from acarsdec json and vdlm2dec</option>
820
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
821
+	print 'selected';
822
+}
823
+?>>NMEA AIS over TCP</option>
824
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
825
+	print 'selected';
826
+}
827
+?>>AirWhere website</option>
828
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
829
+	print 'selected';
830
+}
831
+?>>HidnSeek Callback</option>
832
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
833
+	print 'selected';
834
+}
835
+?>>Blitzortung</option>
836
+										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') {
837
+	print 'selected';
838
+}
839
+?>>Sailaway</option>
628 840
 									</select>
629 841
 								</td>
630 842
 								<td>
631
-									<input type="text" name="name[]" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
843
+									<input type="text" name="name[]" value="<?php if (isset($source['name'])) {
844
+	print $source['name'];
845
+}
846
+?>" />
632 847
 								</td>
633
-								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
634
-								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
848
+								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
849
+	print 'checked';
850
+}
851
+?> /></td>
852
+								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
853
+	print 'checked';
854
+}
855
+?> /></td>
635 856
 								<td>
636 857
 									<select name="timezones[]">
637 858
 								<?php
@@ -641,7 +862,9 @@  discard block
 block discarded – undo
641 862
 											print '<option selected>'.$timezones.'</option>';
642 863
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
643 864
 											print '<option selected>'.$timezones.'</option>';
644
-										} else print '<option>'.$timezones.'</option>';
865
+										} else {
866
+											print '<option>'.$timezones.'</option>';
867
+										}
645 868
 									}
646 869
 								?>
647 870
 									</select>
@@ -697,7 +920,9 @@  discard block
 block discarded – undo
697 920
 									foreach($timezonelist as $timezones){
698 921
 										if ($timezones == 'UTC') {
699 922
 											print '<option selected>'.$timezones.'</option>';
700
-										} else print '<option>'.$timezones.'</option>';
923
+										} else {
924
+											print '<option>'.$timezones.'</option>';
925
+										}
701 926
 									}
702 927
 								?>
703 928
 									</select>
@@ -722,11 +947,17 @@  discard block
 block discarded – undo
722 947
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
723 948
 					<p>
724 949
 						<label for="acarshost">ACARS UDP host</label>
725
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
950
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
951
+	print $globalACARSHost;
952
+}
953
+?>" />
726 954
 					</p>
727 955
 					<p>
728 956
 						<label for="acarsport">ACARS UDP port</label>
729
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
957
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
958
+	print $globalACARSPort;
959
+}
960
+?>" />
730 961
 					</p>
731 962
 					<p class="help-block"><i>daemon-acars.php</i> can only be run as daemon. It's an alternate script for ACARS data, <i>daemon-spotter.php</i> may be better.</p>
732 963
 				</fieldset>
@@ -753,17 +984,38 @@  discard block
 block discarded – undo
753 984
 				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
754 985
 				    <td>
755 986
 					<select name="newslang[]">
756
-					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
757
-					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
987
+					    <option value="en"<?php if ($lng == 'en') {
988
+	print ' selected';
989
+}
990
+?>>English</option>
991
+					    <option value="fr"<?php if ($lng == 'fr') {
992
+	print ' selected';
993
+}
994
+?>>French</option>
758 995
 					</select>
759 996
 				    </td>
760 997
 				    <td>
761 998
 					<select name="newstype[]">
762
-					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
763
-					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
764
-					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
765
-					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
766
-					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
999
+					    <option value="global"<?php if ($type == 'global') {
1000
+	print ' selected';
1001
+}
1002
+?>>Global</option>
1003
+					    <option value="aircraft"<?php if ($type == 'aircraft') {
1004
+	print ' selected';
1005
+}
1006
+?>>Aircraft</option>
1007
+					    <option value="marine"<?php if ($type == 'marine') {
1008
+	print ' selected';
1009
+}
1010
+?>>Marine</option>
1011
+					    <option value="tracker"<?php if ($type == 'tracker') {
1012
+	print ' selected';
1013
+}
1014
+?>>Tracker</option>
1015
+					    <option value="satellite"<?php if ($type == 'Satellite') {
1016
+	print ' selected';
1017
+}
1018
+?>>Satellite</option>
767 1019
 					</select>
768 1020
 				    </td>
769 1021
 				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
@@ -847,7 +1099,10 @@  discard block
 block discarded – undo
847 1099
 			</p>
848 1100
 			<p>
849 1101
 				<label for="corsproxy">CORS proxy</label>
850
-				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) print $globalCORSproxy; else print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
1102
+				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) {
1103
+	print $globalCORSproxy;
1104
+} else {
1105
+	print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
851 1106
 				<p class="help-block">CORS proxy used for some WMS servers</p>
852 1107
 			</p>
853 1108
 <!--
@@ -910,13 +1165,18 @@  discard block
 block discarded – undo
910 1165
 			<div id="schedules_options">
911 1166
 				<p>
912 1167
 					<label for="britishairways">British Airways API Key</label>
913
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
1168
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey;
1169
+}
1170
+?>" />
914 1171
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
915 1172
 				</p>
916 1173
 				<!--
917 1174
 				<p>
918 1175
 					<label for="transavia">Transavia Test API Consumer Key</label>
919
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
1176
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
1177
+	print $globalTransaviaKey;
1178
+}
1179
+?>" />
920 1180
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
921 1181
 				</p>
922 1182
 				-->
@@ -925,10 +1185,16 @@  discard block
 block discarded – undo
925 1185
 						<b>Lufthansa API Key</b>
926 1186
 						<p>
927 1187
 							<label for="lufthansakey">Key</label>
928
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
1188
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
1189
+	print $globalLufthansaKey['key'];
1190
+}
1191
+?>" />
929 1192
 						</p><p>
930 1193
 							<label for="lufthansasecret">Secret</label>
931
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
1194
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
1195
+	print $globalLufthansaKey['secret'];
1196
+}
1197
+?>" />
932 1198
 						</p>
933 1199
 					</div>
934 1200
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -938,11 +1204,17 @@  discard block
 block discarded – undo
938 1204
 						<b>FlightAware API Key</b>
939 1205
 						<p>
940 1206
 							<label for="flightawareusername">Username</label>
941
-							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
1207
+							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
1208
+	print $globalFlightAwareUsername;
1209
+}
1210
+?>" />
942 1211
 						</p>
943 1212
 						<p>
944 1213
 							<label for="flightawarepassword">API key</label>
945
-							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
1214
+							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
1215
+	print $globalFlightAwarePassword;
1216
+}
1217
+?>" />
946 1218
 						</p>
947 1219
 					</div>
948 1220
 					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
@@ -959,10 +1231,22 @@  discard block
 block discarded – undo
959 1231
 				<p>
960 1232
 					<label for="mapmatchingsource">Map Matching source</label>
961 1233
 					<select name="mapmatchingsource" id="mapmatchingsource">
962
-						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
963
-						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
964
-						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option>
965
-						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
1234
+						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) {
1235
+	print 'selected="selected" ';
1236
+}
1237
+?>>FlightAirMap Map Matching</option>
1238
+						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') {
1239
+	print 'selected="selected" ';
1240
+}
1241
+?>>GraphHopper</option>
1242
+						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') {
1243
+	print 'selected="selected" ';
1244
+}
1245
+?>>OSMR</option>
1246
+						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') {
1247
+	print 'selected="selected" ';
1248
+}
1249
+?>>Mapbox</option>
966 1250
 					</select>
967 1251
 					<p class="help-block">Mapbox need the API Key defined in map section.</p>
968 1252
 					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
@@ -970,7 +1254,10 @@  discard block
 block discarded – undo
970 1254
 				<br />
971 1255
 				<p>
972 1256
 					<label for="graphhopper">GraphHopper API Key</label>
973
-					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
1257
+					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) {
1258
+	print $globalGraphHopperKey;
1259
+}
1260
+?>" />
974 1261
 					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
975 1262
 				</p>
976 1263
 			</div>
@@ -988,7 +1275,10 @@  discard block
 block discarded – undo
988 1275
 			</p>
989 1276
 			<p>
990 1277
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
991
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1278
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
1279
+	print $globalNOTAMSource;
1280
+}
1281
+?>" />
992 1282
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
993 1283
 			</p>
994 1284
 			<br />
@@ -1004,14 +1294,20 @@  discard block
 block discarded – undo
1004 1294
 			<div id="metarsrc">
1005 1295
 				<p>
1006 1296
 					<label for="metarsource">URL of your METAR source</label>
1007
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1297
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
1298
+	print $globalMETARurl;
1299
+}
1300
+?>" />
1008 1301
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
1009 1302
 				</p>
1010 1303
 			</div>
1011 1304
 			<br />
1012 1305
 			<p>
1013 1306
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
1014
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1307
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
1308
+	print $globalBitlyAccessToken;
1309
+}
1310
+?>" />
1015 1311
 			</p>
1016 1312
 			<br />
1017 1313
 			<p>
@@ -1027,11 +1323,26 @@  discard block
 block discarded – undo
1027 1323
 			<p>
1028 1324
 				<label for="geoid_source">Geoid Source</label>
1029 1325
 				<select name="geoid_source" id="geoid_source">
1030
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
1031
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
1032
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
1033
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
1034
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1326
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
1327
+	print ' selected="selected"';
1328
+}
1329
+?>>EGM96 15' (2.1MB)</option>
1330
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
1331
+	print ' selected="selected"';
1332
+}
1333
+?>>EGM96 5' (19MB)</option>
1334
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
1335
+	print ' selected="selected"';
1336
+}
1337
+?>>EGM2008 5' (19MB)</option>
1338
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
1339
+	print ' selected="selected"';
1340
+}
1341
+?>>EGM2008 2.5' (75MB)</option>
1342
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
1343
+	print ' selected="selected"';
1344
+}
1345
+?>>EGM2008 1' (470MB)</option>
1035 1346
 				</select>
1036 1347
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
1037 1348
 			</p>
@@ -1053,7 +1364,12 @@  discard block
 block discarded – undo
1053 1364
 			</p>
1054 1365
 			<p>
1055 1366
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
1056
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1367
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1368
+	print $globalArchiveMonths;
1369
+} else {
1370
+	echo '1';
1371
+}
1372
+?>" />
1057 1373
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
1058 1374
 			</p>
1059 1375
 			<p>
@@ -1063,12 +1379,22 @@  discard block
 block discarded – undo
1063 1379
 			</p>
1064 1380
 			<p>
1065 1381
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
1066
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1382
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1383
+	print $globalArchiveKeepMonths;
1384
+} else {
1385
+	echo '1';
1386
+}
1387
+?>" />
1067 1388
 				<p class="help-block">0 to disable</p>
1068 1389
 			</p>
1069 1390
 			<p>
1070 1391
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
1071
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1392
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1393
+	print $globalArchiveKeepTrackMonths;
1394
+} else {
1395
+	echo '1';
1396
+}
1397
+?>" />
1072 1398
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
1073 1399
 			</p>
1074 1400
 			<br />
@@ -1078,7 +1404,12 @@  discard block
 block discarded – undo
1078 1404
 				<p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p>
1079 1405
 				<div id="cronends"> 
1080 1406
 					<label for="cronend">Run script for xx seconds</label>
1081
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1407
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1408
+	print $globalCronEnd;
1409
+} else {
1410
+	print '0';
1411
+}
1412
+?>" />
1082 1413
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
1083 1414
 				</div>
1084 1415
 			</p>
@@ -1137,20 +1468,40 @@  discard block
 block discarded – undo
1137 1468
 			<br />
1138 1469
 			<p>
1139 1470
 				<label for="refresh">Show flights detected since xxx seconds</label>
1140
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1471
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1472
+	echo $globalLiveInterval;
1473
+} else {
1474
+	echo '200';
1475
+}
1476
+?>" />
1141 1477
 			</p>
1142 1478
 			<p>
1143 1479
 				<label for="maprefresh">Live map refresh (in seconds)</label>
1144
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1480
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1481
+	echo $globalMapRefresh;
1482
+} else {
1483
+	echo '30';
1484
+}
1485
+?>" />
1145 1486
 			</p>
1146 1487
 			<p>
1147 1488
 				<label for="mapidle">Map idle timeout (in minutes)</label>
1148
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1489
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1490
+	echo $globalMapIdleTimeout;
1491
+} else {
1492
+	echo '30';
1493
+}
1494
+?>" />
1149 1495
 				<p class="help-block">0 to disable</p>
1150 1496
 			</p>
1151 1497
 			<p>
1152 1498
 				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1153
-				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1499
+				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) {
1500
+	echo $globalMinFetch;
1501
+} else {
1502
+	echo '20';
1503
+}
1504
+?>" />
1154 1505
 			</p>
1155 1506
 			<p>
1156 1507
 				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
@@ -1169,12 +1520,20 @@  discard block
 block discarded – undo
1169 1520
 			<br />
1170 1521
 			<p>
1171 1522
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1172
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1523
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1524
+	echo $globalClosestMinDist;
1525
+} else {
1526
+	echo '50';
1527
+}
1528
+?>" />
1173 1529
 			</p>
1174 1530
 			<br />
1175 1531
 			<p>
1176 1532
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1177
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1533
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1534
+	echo $globalAircraftSize;
1535
+}
1536
+?>" />
1178 1537
 			</p>
1179 1538
 			<br />
1180 1539
 			<p>
@@ -1193,22 +1552,42 @@  discard block
 block discarded – undo
1193 1552
 			<br />
1194 1553
 			<p>
1195 1554
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1196
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1555
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1556
+	echo $globalAircraftIconColor;
1557
+} else {
1558
+	echo '1a3151';
1559
+}
1560
+?>" />
1197 1561
 			</p>
1198 1562
 			<br />
1199 1563
 			<p>
1200 1564
 				<label for="marineiconcolor">Color of marine icon on map</label>
1201
-				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) echo $globalMarineIconColor; else echo '43d1d8'; ?>" />
1565
+				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) {
1566
+	echo $globalMarineIconColor;
1567
+} else {
1568
+	echo '43d1d8';
1569
+}
1570
+?>" />
1202 1571
 			</p>
1203 1572
 			<br />
1204 1573
 			<p>
1205 1574
 				<label for="trackericoncolor">Color of tracker icon on map</label>
1206
-				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) echo $globalTrackerIconColor; else echo '1a3151'; ?>" />
1575
+				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) {
1576
+	echo $globalTrackerIconColor;
1577
+} else {
1578
+	echo '1a3151';
1579
+}
1580
+?>" />
1207 1581
 			</p>
1208 1582
 			<br />
1209 1583
 			<p>
1210 1584
 				<label for="satelliteiconcolor">Color of satellite icon on map</label>
1211
-				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) echo $globalSatelliteIconColor; else echo '1a3151'; ?>" />
1585
+				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) {
1586
+	echo $globalSatelliteIconColor;
1587
+} else {
1588
+	echo '1a3151';
1589
+}
1590
+?>" />
1212 1591
 			</p>
1213 1592
 			<?php
1214 1593
 				if (!is_writable('../cache')) {
@@ -1232,14 +1611,27 @@  discard block
 block discarded – undo
1232 1611
 			<p>
1233 1612
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1234 1613
 				<div class="range">
1235
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1236
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1614
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1615
+	echo $globalAirportZoom;
1616
+} else {
1617
+	echo '7';
1618
+}
1619
+?>" />
1620
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1621
+	echo $globalAirportZoom;
1622
+} else {
1623
+	echo '7';
1624
+}
1625
+?></output>
1237 1626
 				</div>
1238 1627
 			</p>
1239 1628
 			<br />
1240 1629
 			<p>
1241 1630
 				<label for="customcss">Custom CSS web path</label>
1242
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1631
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1632
+	echo $globalCustomCSS;
1633
+}
1634
+?>" />
1243 1635
 			</p>
1244 1636
 		</fieldset>
1245 1637
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -1269,8 +1661,12 @@  discard block
 block discarded – undo
1269 1661
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1270 1662
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1271 1663
 
1272
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1273
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1664
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1665
+		$error .= 'Mysql driver for PDO must be loaded';
1666
+	}
1667
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1668
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1669
+	}
1274 1670
 	
1275 1671
 	$_SESSION['database_root'] = $dbroot;
1276 1672
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1348,15 +1744,23 @@  discard block
 block discarded – undo
1348 1744
 	$source_city = $_POST['source_city'];
1349 1745
 	$source_country = $_POST['source_country'];
1350 1746
 	$source_ref = $_POST['source_ref'];
1351
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1352
-	else $source_id = array();
1747
+	if (isset($source_id)) {
1748
+		$source_id = $_POST['source_id'];
1749
+	} else {
1750
+		$source_id = array();
1751
+	}
1353 1752
 	
1354 1753
 	$sources = array();
1355 1754
 	foreach ($source_name as $keys => $name) {
1356
-	    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]);
1357
-	    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]);
1755
+	    if (isset($source_id[$keys])) {
1756
+	    	$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]);
1757
+	    } else {
1758
+	    	$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]);
1759
+	    }
1760
+	}
1761
+	if (count($sources) > 0) {
1762
+		$_SESSION['sources'] = $sources;
1358 1763
 	}
1359
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1360 1764
 
1361 1765
 	$newsurl = $_POST['newsurl'];
1362 1766
 	$newslng = $_POST['newslang'];
@@ -1369,7 +1773,9 @@  discard block
 block discarded – undo
1369 1773
 		$lng = $newslng[$newskey];
1370 1774
 		if (isset($newsfeeds[$type][$lng])) {
1371 1775
 		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1372
-		} else $newsfeeds[$type][$lng] = array($url);
1776
+		} else {
1777
+			$newsfeeds[$type][$lng] = array($url);
1778
+		}
1373 1779
 	    }
1374 1780
 	}
1375 1781
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
@@ -1394,17 +1800,29 @@  discard block
 block discarded – undo
1394 1800
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1395 1801
 
1396 1802
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1397
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1398
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1803
+	if ($globalaircraft == 'aircraft') {
1804
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1805
+	} else {
1806
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1807
+	}
1399 1808
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1400
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1401
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1809
+	if ($globaltracker == 'tracker') {
1810
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1811
+	} else {
1812
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1813
+	}
1402 1814
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1403
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1404
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1815
+	if ($globalmarine == 'marine') {
1816
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1817
+	} else {
1818
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1819
+	}
1405 1820
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1406
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1407
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1821
+	if ($globalsatellite == 'satellite') {
1822
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1823
+	} else {
1824
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1825
+	}
1408 1826
 
1409 1827
 /*	
1410 1828
 	$globalSBS1Hosts = array();
@@ -1426,23 +1844,37 @@  discard block
 block discarded – undo
1426 1844
 	$name = $_POST['name'];
1427 1845
 	$format = $_POST['format'];
1428 1846
 	$timezones = $_POST['timezones'];
1429
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1430
-	else $sourcestats = array();
1431
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1432
-	else $noarchive = array();
1847
+	if (isset($_POST['sourcestats'])) {
1848
+		$sourcestats = $_POST['sourcestats'];
1849
+	} else {
1850
+		$sourcestats = array();
1851
+	}
1852
+	if (isset($_POST['noarchive'])) {
1853
+		$noarchive = $_POST['noarchive'];
1854
+	} else {
1855
+		$noarchive = array();
1856
+	}
1433 1857
 	$gSources = array();
1434 1858
 	$forcepilots = false;
1435 1859
 	foreach ($host as $key => $h) {
1436
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1437
-		else $cov = 'FALSE';
1438
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1439
-		else $arch = 'FALSE';
1860
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1861
+			$cov = 'TRUE';
1862
+		} else {
1863
+			$cov = 'FALSE';
1864
+		}
1865
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1866
+			$arch = 'TRUE';
1867
+		} else {
1868
+			$arch = 'FALSE';
1869
+		}
1440 1870
 		if (strpos($format[$key],'_callback')) {
1441 1871
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1442 1872
 		} elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) {
1443 1873
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1444 1874
 		}
1445
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1875
+		if ($format[$key] == 'airwhere') {
1876
+			$forcepilots = true;
1877
+		}
1446 1878
 	}
1447 1879
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1448 1880
 
@@ -1473,7 +1905,9 @@  discard block
 block discarded – undo
1473 1905
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1474 1906
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1475 1907
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1476
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1908
+	} else {
1909
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1910
+	}
1477 1911
 
1478 1912
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1479 1913
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1514,7 +1948,9 @@  discard block
 block discarded – undo
1514 1948
 
1515 1949
 	// Create in settings.php keys not yet configurable if not already here
1516 1950
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1517
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1951
+	if (!isset($globalDebug)) {
1952
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1953
+	}
1518 1954
 
1519 1955
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1520 1956
 	if ($resetyearstats == 'resetyearstats') {
@@ -1557,37 +1993,56 @@  discard block
 block discarded – undo
1557 1993
 	}
1558 1994
 */
1559 1995
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1560
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1561
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1562
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1563
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1996
+	if ($globalsbs == 'sbs') {
1997
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1998
+	} else {
1999
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
2000
+	}
2001
+	if ($globalaprs == 'aprs') {
2002
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
2003
+	} else {
2004
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
2005
+	}
1564 2006
 	$va = false;
1565 2007
 	if ($globalivao == 'ivao') {
1566 2008
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1567 2009
 		$va = true;
1568
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2010
+	} else {
2011
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2012
+	}
1569 2013
 	if ($globalvatsim == 'vatsim') {
1570 2014
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1571 2015
 		$va = true;
1572
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2016
+	} else {
2017
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2018
+	}
1573 2019
 	if ($globalphpvms == 'phpvms') {
1574 2020
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1575 2021
 		$va = true;
1576
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2022
+	} else {
2023
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2024
+	}
1577 2025
 	if ($globalvam == 'vam') {
1578 2026
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1579 2027
 		$va = true;
1580
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2028
+	} else {
2029
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2030
+	}
1581 2031
 	if ($va) {
1582 2032
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1583
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2033
+	} else {
2034
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2035
+	}
1584 2036
 	if ($globalva == 'va' || $va) {
1585 2037
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1586 2038
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1587 2039
 	} else {
1588 2040
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1589
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1590
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2041
+		if ($forcepilots) {
2042
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
2043
+		} else {
2044
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2045
+		}
1591 2046
 	}
1592 2047
 	if ($globalvm == 'vm') {
1593 2048
 		$settings = array_merge($settings,array('globalVM' => 'TRUE'));
@@ -1847,7 +2302,9 @@  discard block
 block discarded – undo
1847 2302
 	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1848 2303
 	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1849 2304
 
1850
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2305
+	if (!isset($globalTransaction)) {
2306
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2307
+	}
1851 2308
 
1852 2309
 	// Set some defaults values...
1853 2310
 	if (!isset($globalAircraftImageSources)) {
@@ -1862,15 +2319,23 @@  discard block
 block discarded – undo
1862 2319
 
1863 2320
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1864 2321
 
1865
-	if ($error == '') settings::modify_settings($settings);
1866
-	if ($error == '') settings::comment_settings($settings_comment);
2322
+	if ($error == '') {
2323
+		settings::modify_settings($settings);
2324
+	}
2325
+	if ($error == '') {
2326
+		settings::comment_settings($settings_comment);
2327
+	}
1867 2328
 	if ($error != '') {
1868 2329
 		print '<div class="info column">'.$error.'</div>';
1869 2330
 		require('../footer.php');
1870 2331
 		exit;
1871 2332
 	} else {
1872
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1873
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
2333
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
2334
+			$_SESSION['waypoints'] = 1;
2335
+		}
2336
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
2337
+			$_SESSION['owner'] = 1;
2338
+		}
1874 2339
 		if (isset($_POST['createdb'])) {
1875 2340
 			$_SESSION['install'] = 'database_create';
1876 2341
 		} else {
@@ -1907,10 +2372,18 @@  discard block
 block discarded – undo
1907 2372
 	$popw = false;
1908 2373
 	foreach ($_SESSION['done'] as $done) {
1909 2374
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1910
-	    if ($done == 'Create database') $pop = true;
1911
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1912
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1913
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
2375
+	    if ($done == 'Create database') {
2376
+	    	$pop = true;
2377
+	    }
2378
+	    if ($_SESSION['install'] == 'database_create') {
2379
+	    	$pop = true;
2380
+	    }
2381
+	    if ($_SESSION['install'] == 'database_import') {
2382
+	    	$popi = true;
2383
+	    }
2384
+	    if ($_SESSION['install'] == 'waypoints') {
2385
+	    	$popw = true;
2386
+	    }
1914 2387
 	}
1915 2388
 	if ($pop) {
1916 2389
 	    sleep(5);
@@ -1921,7 +2394,9 @@  discard block
 block discarded – undo
1921 2394
 	} else if ($popw) {
1922 2395
 	    sleep(5);
1923 2396
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1924
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2397
+	} else {
2398
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2399
+	}
1925 2400
 	print '</div></ul>';
1926 2401
 	print '<div id="error"></div>';
1927 2402
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.