Completed
Push — master ( cc50d0...0f8c33 )
by Yannick
09:46
created
live-geojson.php 1 patch
Braces   +270 added lines, -106 removed lines patch added patch discarded remove patch
@@ -47,27 +47,52 @@  discard block
 block discarded – undo
47 47
 }
48 48
 header('Content-Type: text/javascript');
49 49
 
50
-if (!isset($globalJsonCompress)) $compress = true;
51
-else $compress = $globalJsonCompress;
50
+if (!isset($globalJsonCompress)) {
51
+	$compress = true;
52
+} else {
53
+	$compress = $globalJsonCompress;
54
+}
52 55
 
53 56
 $from_archive = false;
54 57
 $min = true;
55 58
 $allhistory = false;
56 59
 $filter['source'] = array();
57
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
60
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
62
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
63
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
60
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
61
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
62
+}
63
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
64
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
65
+}
66
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
67
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
68
+}
69
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
70
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
71
+}
72
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
73
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
74
+}
75
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
76
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
77
+}
78
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
79
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
80
+}
81
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
82
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
83
+}
84
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
85
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
86
+}
87
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
88
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
89
+}
67 90
 
68 91
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
69 92
 	$min = true;
70
-} else $min = false;
93
+} else {
94
+	$min = false;
95
+}
71 96
 
72 97
 if (isset($_GET['ident'])) {
73 98
 	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
@@ -149,20 +174,30 @@  discard block
 block discarded – undo
149 174
 	}
150 175
 */
151 176
 	$flightcnt = count($spotter_array);
152
-	if ($flightcnt == '') $flightcnt = 0;
153
-} else $flightcnt = 0;
177
+	if ($flightcnt == '') {
178
+		$flightcnt = 0;
179
+	}
180
+	} else {
181
+	$flightcnt = 0;
182
+}
154 183
 
155 184
 $sqltime = round(microtime(true)-$begintime,2);
156 185
 
157
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
158
-else $usenextlatlon = true;
186
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
187
+	$usenextlatlon = false;
188
+} else {
189
+	$usenextlatlon = true;
190
+}
159 191
 $j = 0;
160 192
 $prev_flightaware_id = '';
161 193
 $aircrafts_shadow = array();
162 194
 $output = '{';
163 195
 	$output .= '"type": "FeatureCollection",';
164
-		if ($min) $output .= '"minimal": "true",';
165
-		else $output .= '"minimal": "false",';
196
+		if ($min) {
197
+			$output .= '"minimal": "true",';
198
+		} else {
199
+			$output .= '"minimal": "false",';
200
+		}
166 201
 		$output .= '"fc": "'.$flightcnt.'",';
167 202
 		$output .= '"sqt": "'.$sqltime.'",';
168 203
 
@@ -206,18 +241,29 @@  discard block
 block discarded – undo
206 241
 						}
207 242
 						$output .= '"properties": {';
208 243
 						if (isset($spotter_item['flightaware_id'])) {
209
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
210
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
244
+							if ($compress) {
245
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
246
+							} else {
247
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
248
+							}
211 249
 						} elseif (isset($spotter_item['famtrackid'])) {
212
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
213
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
250
+							if ($compress) {
251
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
252
+							} else {
253
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
254
+							}
214 255
 						} elseif (isset($spotter_item['fammarine_id'])) {
215
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
216
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
256
+							if ($compress) {
257
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
258
+							} else {
259
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
260
+							}
217 261
 						}
218 262
 							$output .= '"fc": "'.$flightcnt.'",';
219 263
 							$output .= '"sqt": "'.$sqltime.'",';
220
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
264
+							if (isset($begindate)) {
265
+								$output .= '"archive_date": "'.$begindate.'",';
266
+							}
221 267
 
222 268
 /*
223 269
 							if ($min) $output .= '"minimal": "true",';
@@ -225,13 +271,21 @@  discard block
 block discarded – undo
225 271
 */
226 272
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
227 273
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
228
-							if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",';
229
-							else $output .= '"callsign": "'.$spotter_item['ident'].'",';
274
+							if ($compress) {
275
+								$output .= '"c": "'.$spotter_item['ident'].'",';
276
+							} else {
277
+								$output .= '"callsign": "'.$spotter_item['ident'].'",';
278
+							}
230 279
 						} else {
231
-							if ($compress) $output .= '"c": "NA",';
232
-							else $output .= '"callsign": "NA",';
280
+							if ($compress) {
281
+								$output .= '"c": "NA",';
282
+							} else {
283
+								$output .= '"callsign": "NA",';
284
+							}
285
+						}
286
+						if (isset($spotter_item['registration'])) {
287
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
233 288
 						}
234
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
235 289
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
236 290
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
237 291
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -244,15 +298,21 @@  discard block
 block discarded – undo
244 298
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
245 299
 						}
246 300
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
247
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
248
-							else {
301
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
302
+								$spotter_item['aircraft_shadow'] = '';
303
+							} else {
249 304
 								$aircraft_icao = $spotter_item['aircraft_icao'];
250
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
251
-								else {
305
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
306
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
307
+								} else {
252 308
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
253
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
254
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
255
-									else $spotter_item['aircraft_shadow'] = '';
309
+									if (count($aircraft_info) > 0) {
310
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
311
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
312
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
313
+									} else {
314
+										$spotter_item['aircraft_shadow'] = '';
315
+									}
256 316
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
257 317
 								}
258 318
 							}
@@ -260,73 +320,139 @@  discard block
 block discarded – undo
260 320
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
261 321
 							if ($tracker) {
262 322
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
263
-									if ($compress) $output .= '"as": "ambulance.png",';
264
-									else $output .= '"aircraft_shadow": "ambulance.png",';
323
+									if ($compress) {
324
+										$output .= '"as": "ambulance.png",';
325
+									} else {
326
+										$output .= '"aircraft_shadow": "ambulance.png",';
327
+									}
265 328
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
266
-									if ($compress) $output .= '"as": "police.png",';
267
-									else $output .= '"aircraft_shadow": "police.png",';
329
+									if ($compress) {
330
+										$output .= '"as": "police.png",';
331
+									} else {
332
+										$output .= '"aircraft_shadow": "police.png",';
333
+									}
268 334
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
269
-									if ($compress) $output .= '"as": "ship.png",';
270
-									else $output .= '"aircraft_shadow": "ship.png",';
335
+									if ($compress) {
336
+										$output .= '"as": "ship.png",';
337
+									} else {
338
+										$output .= '"aircraft_shadow": "ship.png",';
339
+									}
271 340
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
272
-									if ($compress) $output .= '"as": "ship.png",';
273
-									else $output .= '"aircraft_shadow": "ship.png",';
341
+									if ($compress) {
342
+										$output .= '"as": "ship.png",';
343
+									} else {
344
+										$output .= '"aircraft_shadow": "ship.png",';
345
+									}
274 346
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
275
-									if ($compress) $output .= '"as": "ship.png",';
276
-									else $output .= '"aircraft_shadow": "ship.png",';
347
+									if ($compress) {
348
+										$output .= '"as": "ship.png",';
349
+									} else {
350
+										$output .= '"aircraft_shadow": "ship.png",';
351
+									}
277 352
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
278
-									if ($compress) $output .= '"as": "truck.png",';
279
-									else $output .= '"aircraft_shadow": "truck.png",';
353
+									if ($compress) {
354
+										$output .= '"as": "truck.png",';
355
+									} else {
356
+										$output .= '"aircraft_shadow": "truck.png",';
357
+									}
280 358
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
281
-									if ($compress) $output .= '"as": "truck.png",';
282
-									else $output .= '"aircraft_shadow": "truck.png",';
359
+									if ($compress) {
360
+										$output .= '"as": "truck.png",';
361
+									} else {
362
+										$output .= '"aircraft_shadow": "truck.png",';
363
+									}
283 364
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
284
-									if ($compress) $output .= '"as": "aircraft.png",';
285
-									else $output .= '"aircraft_shadow": "aircraft.png",';
365
+									if ($compress) {
366
+										$output .= '"as": "aircraft.png",';
367
+									} else {
368
+										$output .= '"aircraft_shadow": "aircraft.png",';
369
+									}
286 370
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
287
-									if ($compress) $output .= '"as": "aircraft.png",';
288
-									else $output .= '"aircraft_shadow": "aircraft.png",';
371
+									if ($compress) {
372
+										$output .= '"as": "aircraft.png",';
373
+									} else {
374
+										$output .= '"aircraft_shadow": "aircraft.png",';
375
+									}
289 376
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
290
-									if ($compress) $output .= '"as": "helico.png",';
291
-									else $output .= '"aircraft_shadow": "helico.png",';
377
+									if ($compress) {
378
+										$output .= '"as": "helico.png",';
379
+									} else {
380
+										$output .= '"aircraft_shadow": "helico.png",';
381
+									}
292 382
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
293
-									if ($compress) $output .= '"as": "rail.png",';
294
-									else $output .= '"aircraft_shadow": "rail.png",';
383
+									if ($compress) {
384
+										$output .= '"as": "rail.png",';
385
+									} else {
386
+										$output .= '"aircraft_shadow": "rail.png",';
387
+									}
295 388
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
296
-									if ($compress) $output .= '"as": "firetruck.png",';
297
-									else $output .= '"aircraft_shadow": "firetruck.png",';
389
+									if ($compress) {
390
+										$output .= '"as": "firetruck.png",';
391
+									} else {
392
+										$output .= '"aircraft_shadow": "firetruck.png",';
393
+									}
298 394
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
299
-									if ($compress) $output .= '"as": "bus.png",';
300
-									else $output .= '"aircraft_shadow": "bus.png",';
395
+									if ($compress) {
396
+										$output .= '"as": "bus.png",';
397
+									} else {
398
+										$output .= '"aircraft_shadow": "bus.png",';
399
+									}
301 400
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
302
-									if ($compress) $output .= '"as": "phone.png",';
303
-									else $output .= '"aircraft_shadow": "phone.png",';
401
+									if ($compress) {
402
+										$output .= '"as": "phone.png",';
403
+									} else {
404
+										$output .= '"aircraft_shadow": "phone.png",';
405
+									}
304 406
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
305
-									if ($compress) $output .= '"as": "jogger.png",';
306
-									else $output .= '"aircraft_shadow": "jogger.png",';
407
+									if ($compress) {
408
+										$output .= '"as": "jogger.png",';
409
+									} else {
410
+										$output .= '"aircraft_shadow": "jogger.png",';
411
+									}
307 412
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
308
-									if ($compress) $output .= '"as": "bike.png",';
309
-									else $output .= '"aircraft_shadow": "bike.png",';
413
+									if ($compress) {
414
+										$output .= '"as": "bike.png",';
415
+									} else {
416
+										$output .= '"aircraft_shadow": "bike.png",';
417
+									}
310 418
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
311
-									if ($compress) $output .= '"as": "motorcycle.png",';
312
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
419
+									if ($compress) {
420
+										$output .= '"as": "motorcycle.png",';
421
+									} else {
422
+										$output .= '"aircraft_shadow": "motorcycle.png",';
423
+									}
313 424
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
314
-									if ($compress) $output .= '"as": "balloon.png",';
315
-									else $output .= '"aircraft_shadow": "balloon.png",';
425
+									if ($compress) {
426
+										$output .= '"as": "balloon.png",';
427
+									} else {
428
+										$output .= '"aircraft_shadow": "balloon.png",';
429
+									}
316 430
 								} else {
317
-									if ($compress) $output .= '"as": "car.png",';
318
-									else $output .= '"aircraft_shadow": "car.png",';
431
+									if ($compress) {
432
+										$output .= '"as": "car.png",';
433
+									} else {
434
+										$output .= '"aircraft_shadow": "car.png",';
435
+									}
319 436
 								}
320 437
 							} elseif ($marine) {
321
-								if ($compress) $output .= '"as": "ship.png",';
322
-								else $output .= '"aircraft_shadow": "ship.png",';
438
+								if ($compress) {
439
+									$output .= '"as": "ship.png",';
440
+								} else {
441
+									$output .= '"aircraft_shadow": "ship.png",';
442
+								}
323 443
 							} else {
324
-								if ($compress) $output .= '"as": "default.png",';
325
-								else $output .= '"aircraft_shadow": "default.png",';
444
+								if ($compress) {
445
+									$output .= '"as": "default.png",';
446
+								} else {
447
+									$output .= '"aircraft_shadow": "default.png",';
448
+								}
326 449
 							}
327 450
 						} else {
328
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
329
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
451
+							if ($compress) {
452
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
453
+							} else {
454
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
455
+							}
330 456
 						}
331 457
 						if (isset($spotter_item['airline_name'])) {
332 458
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -334,8 +460,11 @@  discard block
 block discarded – undo
334 460
 							$output .= '"airline_name": "NA",';
335 461
 						}
336 462
 						if (isset($spotter_item['departure_airport'])) {
337
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
338
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
463
+							if ($compress) {
464
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
465
+							} else {
466
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
467
+							}
339 468
 						}
340 469
 						if (isset($spotter_item['departure_airport_city'])) {
341 470
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -347,8 +476,11 @@  discard block
 block discarded – undo
347 476
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
348 477
 						}
349 478
 						if (isset($spotter_item['arrival_airport'])) {
350
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
351
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
479
+							if ($compress) {
480
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
481
+							} else {
482
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
483
+							}
352 484
 						}
353 485
 						if (isset($spotter_item['arrival_airport_city'])) {
354 486
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -367,11 +499,17 @@  discard block
 block discarded – undo
367 499
 						}
368 500
 						
369 501
 						if (isset($spotter_item['altitude'])) {
370
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
371
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
502
+							if ($compress) {
503
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
504
+							} else {
505
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
506
+							}
507
+						}
508
+						if ($compress) {
509
+							$output .= '"h": "'.$spotter_item['heading'].'",';
510
+						} else {
511
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
372 512
 						}
373
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
374
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
375 513
 						
376 514
 						if (isset($archivespeed)) {
377 515
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -381,7 +519,9 @@  discard block
 block discarded – undo
381 519
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
382 520
 						}
383 521
 
384
-						if (!$min) $output .= '"image": "'.$image.'",';
522
+						if (!$min) {
523
+							$output .= '"image": "'.$image.'",';
524
+						}
385 525
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
386 526
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
387 527
 						}
@@ -389,8 +529,11 @@  discard block
 block discarded – undo
389 529
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
390 530
 						}
391 531
 						if (isset($spotter_item['squawk'])) {
392
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
393
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
532
+							if ($compress) {
533
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
534
+							} else {
535
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
536
+							}
394 537
 						}
395 538
 						if (isset($spotter_item['squawk_usage'])) {
396 539
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -409,14 +552,23 @@  discard block
 block discarded – undo
409 552
 						}
410 553
 						// type when not aircraft ?
411 554
 						if (isset($spotter_item['type'])) {
412
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
413
-							else $output .= '"type": "'.$spotter_item['type'].'"';
555
+							if ($compress) {
556
+								$output .= '"t": "'.$spotter_item['type'].'"';
557
+							} else {
558
+								$output .= '"type": "'.$spotter_item['type'].'"';
559
+							}
414 560
 						} elseif ($marine) {
415
-							if ($compress) $output .= '"t": "ship"';
416
-							else $output .= '"type": "ship"';
561
+							if ($compress) {
562
+								$output .= '"t": "ship"';
563
+							} else {
564
+								$output .= '"type": "ship"';
565
+							}
417 566
 						} else {
418
-							if ($compress) $output .= '"t": "aircraft"';
419
-							else $output .= '"type": "aircraft"';
567
+							if ($compress) {
568
+								$output .= '"t": "aircraft"';
569
+							} else {
570
+								$output .= '"type": "aircraft"';
571
+							}
420 572
 						}
421 573
 						$output .= '},';
422 574
 						$output .= '"geometry": {';
@@ -484,7 +636,9 @@  discard block
 block discarded – undo
484 636
 			}
485 637
 */
486 638
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
487
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
639
+				if ($history == '' && isset($_COOKIE['history'])) {
640
+					$history = $_COOKIE['history'];
641
+				}
488 642
 				
489 643
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
490 644
 				|| (!isset($_COOKIE['flightpath']) 
@@ -513,8 +667,11 @@  discard block
 block discarded – undo
513 667
 							$output_history .= ']}},';
514 668
 							$output .= $output_history;
515 669
 						    }
516
-						    if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
517
-						    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
670
+						    if ($compress) {
671
+						    	$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
672
+						    } else {
673
+						    	$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
674
+						    }
518 675
 						}
519 676
 						$output_history .= '[';
520 677
 						$output_history .=  $spotter_history['longitude'].', ';
@@ -524,9 +681,14 @@  discard block
 block discarded – undo
524 681
 						$prev_alt = $alt;
525 682
 					} else {
526 683
 						if ($d == false) {
527
-							if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
528
-							else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
529
-						} else $d = true;
684
+							if ($compress) {
685
+								$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
686
+							} else {
687
+								$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
688
+							}
689
+						} else {
690
+							$d = true;
691
+						}
530 692
 						$output_history .= '[';
531 693
 						$output_history .=  $spotter_history['longitude'].', ';
532 694
 						$output_history .=  $spotter_history['latitude'];
@@ -570,7 +732,9 @@  discard block
 block discarded – undo
570 732
 			$output .= ']';
571 733
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
572 734
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
573
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
735
+			if (isset($begindate)) {
736
+				$output .= '"archive_date": "'.$begindate.'",';
737
+			}
574 738
 			$output .= '"fc": "'.$j.'"';
575 739
 		} else {
576 740
 			$output .= '"features": ';
Please login to merge, or discard this patch.
aircraft-data.php 1 patch
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
 {
56 56
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
57 57
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
58
-	} else $image = $spotter_item['image_thumbnail'];
58
+	} else {
59
+		$image = $spotter_item['image_thumbnail'];
60
+	}
59 61
 
60 62
 }
61 63
 /* else {
@@ -67,7 +69,9 @@  discard block
 block discarded – undo
67 69
 	print '<div class="left"><img src="'.$image.'" alt="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].'" title="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' Image &copy; '.$spotter_item['image_copyright'].'"/><br />Image &copy; '.$spotter_item['image_copyright'].'</div>';
68 70
 }
69 71
 print '<div class="right"><div class="callsign-details"><div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
70
-if (isset($spotter_item['airline_name'])) print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
72
+if (isset($spotter_item['airline_name'])) {
73
+	print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
74
+}
71 75
 print '</div>';
72 76
 print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
73 77
 if (isset($spotter_item['departure_airport_time'])) {
@@ -95,9 +99,14 @@  discard block
 block discarded – undo
95 99
 print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
96 100
 print '</div></div><div>';
97 101
 print '<span>'._("Aircraft").'</span>';
98
-if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
99
-if (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
100
-else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
102
+if (isset($spotter_item['aircraft_wiki'])) {
103
+	print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
104
+}
105
+if (isset($spotter_item['aircraft_type'])) {
106
+	print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
107
+} else {
108
+	print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
109
+}
101 110
 print '</div>';
102 111
 print '<div><span>'._("Altitude").'</span>';
103 112
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
@@ -106,7 +115,9 @@  discard block
 block discarded – undo
106 115
 	print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
107 116
 }
108 117
 print '</div>';
109
-if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
118
+if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') {
119
+	print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
120
+}
110 121
 print '<div><span>'._("Speed").'</span>';
111 122
 if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
112 123
 	print round($spotter_item['ground_speed']*1.15078).' mph';
@@ -120,8 +131,11 @@  discard block
 block discarded – undo
120 131
 print '<div><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>';
121 132
 if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') {
122 133
 	print '<div><span>'._("Pilot").'</span>';
123
-	if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
124
-	else print $spotter_item['pilot_name'];
134
+	if (isset($spotter_item['pilot_id'])) {
135
+		print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
136
+	} else {
137
+		print $spotter_item['pilot_name'];
138
+	}
125 139
 	print '</div>';
126 140
 }
127 141
 
@@ -147,10 +161,18 @@  discard block
 block discarded – undo
147 161
 }
148 162
 print '</div>';
149 163
 
150
-if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
151
-if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
152
-if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
153
-if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
164
+if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') {
165
+	print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
166
+}
167
+if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') {
168
+	print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
169
+}
170
+if (isset($spotter_item['acars']['message'])) {
171
+	print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
172
+}
173
+if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) {
174
+	print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
175
+}
154 176
 print '</div>';
155 177
 ?>
156 178
 </div>
157 179
\ No newline at end of file
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +651 added lines, -225 removed lines patch added patch discarded remove patch
@@ -13,13 +13,17 @@  discard block
 block discarded – undo
13 13
 require_once(dirname(__FILE__).'/../require/class.SBS.php');
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
16
+if (isset($globalTracker) && $globalTracker) {
17
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+}
17 19
 if (isset($globalMarine) && $globalMarine) {
18 20
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
19 21
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 22
 }
21 23
 
22
-if (!isset($globalDebug)) $globalDebug = FALSE;
24
+if (!isset($globalDebug)) {
25
+	$globalDebug = FALSE;
26
+}
23 27
 
24 28
 // Check if schema is at latest version
25 29
 $Connection = new Connection();
@@ -59,14 +63,25 @@  discard block
 block discarded – undo
59 63
     $globalSources = array();
60 64
     $globalSources[] = array('host' => $options['source']);
61 65
 }
62
-if (isset($options['server'])) $globalServer = TRUE;
63
-if (isset($options['idsource'])) $id_source = $options['idsource'];
64
-else $id_source = 1;
66
+if (isset($options['server'])) {
67
+	$globalServer = TRUE;
68
+}
69
+if (isset($options['idsource'])) {
70
+	$id_source = $options['idsource'];
71
+} else {
72
+	$id_source = 1;
73
+}
65 74
 if (isset($globalServer) && $globalServer) {
66
-    if ($globalDebug) echo "Using Server Mode\n";
75
+    if ($globalDebug) {
76
+    	echo "Using Server Mode\n";
77
+    }
67 78
     $SI=new SpotterServer();
68
-} else $SI=new SpotterImport($Connection->db);
69
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
79
+} else {
80
+	$SI=new SpotterImport($Connection->db);
81
+}
82
+if (isset($globalTracker) && $globalTracker) {
83
+	$TI = new TrackerImport($Connection->db);
84
+}
70 85
 if (isset($globalMarine) && $globalMarine) {
71 86
     $AIS = new AIS();
72 87
     $MI = new MarineImport($Connection->db);
@@ -88,7 +103,9 @@  discard block
 block discarded – undo
88 103
 }
89 104
 
90 105
 // let's try and connect
91
-if ($globalDebug) echo "Connecting...\n";
106
+if ($globalDebug) {
107
+	echo "Connecting...\n";
108
+}
92 109
 $use_aprs = false;
93 110
 $aprs_full = false;
94 111
 $reset = 0;
@@ -97,7 +114,9 @@  discard block
 block discarded – undo
97 114
     $ip = gethostbyname($host);
98 115
     $s = socket_create(AF_INET, SOCK_STREAM, 0);
99 116
     $r = @socket_connect($s, $ip, $port);
100
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
117
+    if (!socket_set_nonblock($s)) {
118
+    	echo "Unable to set nonblock on socket\n";
119
+    }
101 120
     if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
102 121
         return $s;
103 122
     }
@@ -125,7 +144,9 @@  discard block
 block discarded – undo
125 144
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
126 145
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
127 146
     $reset++;
128
-    if ($globalDebug) echo 'Connect to all...'."\n";
147
+    if ($globalDebug) {
148
+    	echo 'Connect to all...'."\n";
149
+    }
129 150
     foreach ($hosts as $id => $value) {
130 151
 	$host = $value['host'];
131 152
 	$globalSources[$id]['last_exec'] = 0;
@@ -135,27 +156,37 @@  discard block
 block discarded – undo
135 156
         	//$formats[$id] = 'deltadbtxt';
136 157
         	$globalSources[$id]['format'] = 'deltadbtxt';
137 158
         	//$last_exec['deltadbtxt'] = 0;
138
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
159
+        	if ($globalDebug) {
160
+        		echo "Connect to deltadb source (".$host.")...\n";
161
+        	}
139 162
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
140 163
         	//$formats[$id] = 'vatsimtxt';
141 164
         	$globalSources[$id]['format'] = 'vatsimtxt';
142 165
         	//$last_exec['vatsimtxt'] = 0;
143
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
166
+        	if ($globalDebug) {
167
+        		echo "Connect to vatsim source (".$host.")...\n";
168
+        	}
144 169
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
145 170
         	//$formats[$id] = 'aircraftlistjson';
146 171
         	$globalSources[$id]['format'] = 'aircraftlistjson';
147 172
         	//$last_exec['aircraftlistjson'] = 0;
148
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
173
+        	if ($globalDebug) {
174
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
175
+        	}
149 176
     	    } else if (preg_match('/opensky/i',$host)) {
150 177
         	//$formats[$id] = 'aircraftlistjson';
151 178
         	$globalSources[$id]['format'] = 'opensky';
152 179
         	//$last_exec['aircraftlistjson'] = 0;
153
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
180
+        	if ($globalDebug) {
181
+        		echo "Connect to opensky source (".$host.")...\n";
182
+        	}
154 183
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
155 184
         	//$formats[$id] = 'radarvirtueljson';
156 185
         	$globalSources[$id]['format'] = 'radarvirtueljson';
157 186
         	//$last_exec['radarvirtueljson'] = 0;
158
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
187
+        	if ($globalDebug) {
188
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
189
+        	}
159 190
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
160 191
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161 192
         	    exit(0);
@@ -164,7 +195,9 @@  discard block
 block discarded – undo
164 195
         	//$formats[$id] = 'planeupdatefaa';
165 196
         	$globalSources[$id]['format'] = 'planeupdatefaa';
166 197
         	//$last_exec['planeupdatefaa'] = 0;
167
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
198
+        	if ($globalDebug) {
199
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
200
+        	}
168 201
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
169 202
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
170 203
         	    exit(0);
@@ -173,26 +206,36 @@  discard block
 block discarded – undo
173 206
         	//$formats[$id] = 'phpvmacars';
174 207
         	$globalSources[$id]['format'] = 'phpvmacars';
175 208
         	//$last_exec['phpvmacars'] = 0;
176
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
209
+        	if ($globalDebug) {
210
+        		echo "Connect to phpvmacars source (".$host.")...\n";
211
+        	}
177 212
             } else if (preg_match('/VAM-json.php$/i',$host)) {
178 213
         	//$formats[$id] = 'phpvmacars';
179 214
         	$globalSources[$id]['format'] = 'vam';
180
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
215
+        	if ($globalDebug) {
216
+        		echo "Connect to Vam source (".$host.")...\n";
217
+        	}
181 218
             } else if (preg_match('/whazzup/i',$host)) {
182 219
         	//$formats[$id] = 'whazzup';
183 220
         	$globalSources[$id]['format'] = 'whazzup';
184 221
         	//$last_exec['whazzup'] = 0;
185
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to whazzup source (".$host.")...\n";
224
+        	}
186 225
             } else if (preg_match('/recentpireps/i',$host)) {
187 226
         	//$formats[$id] = 'pirepsjson';
188 227
         	$globalSources[$id]['format'] = 'pirepsjson';
189 228
         	//$last_exec['pirepsjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
229
+        	if ($globalDebug) {
230
+        		echo "Connect to pirepsjson source (".$host.")...\n";
231
+        	}
191 232
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
192 233
         	//$formats[$id] = 'fr24json';
193 234
         	$globalSources[$id]['format'] = 'fr24json';
194 235
         	//$last_exec['fr24json'] = 0;
195
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
236
+        	if ($globalDebug) {
237
+        		echo "Connect to fr24 source (".$host.")...\n";
238
+        	}
196 239
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
197 240
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
198 241
         	    exit(0);
@@ -201,17 +244,24 @@  discard block
 block discarded – undo
201 244
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202 245
         	//$formats[$id] = 'tsv';
203 246
         	$globalSources[$id]['format'] = 'tsv';
204
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
247
+        	if ($globalDebug) {
248
+        		echo "Connect to tsv source (".$host.")...\n";
249
+        	}
205 250
             }
206 251
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
207 252
     		if ($globalSources[$id]['format'] == 'nmeahttp') {
208 253
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
209 254
     		    if ($idf !== false) {
210 255
     			$httpfeeds[$id] = $idf;
211
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
256
+        		if ($globalDebug) {
257
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
258
+        		}
259
+    		    } elseif ($globalDebug) {
260
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
212 261
     		    }
213
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
262
+    		} elseif ($globalDebug) {
263
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
264
+    		}
215 265
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216 266
 	    $hostport = explode(':',$host);
217 267
 	    if (isset($hostport[1])) {
@@ -248,17 +298,25 @@  discard block
 block discarded – undo
248 298
         		//$formats[$id] = 'beast';
249 299
         		$globalSources[$id]['format'] = 'beast';
250 300
 		    //} else $formats[$id] = 'sbs';
251
-		    } else $globalSources[$id]['format'] = 'sbs';
301
+		    } else {
302
+		    	$globalSources[$id]['format'] = 'sbs';
303
+		    }
252 304
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
253 305
 		}
254
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
306
+		if ($globalDebug) {
307
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
308
+		}
255 309
             } else {
256
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
310
+		if ($globalDebug) {
311
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
312
+		}
257 313
     	    }
258 314
         }
259 315
     }
260 316
 }
261
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
317
+if (!isset($globalMinFetch)) {
318
+	$globalMinFetch = 15;
319
+}
262 320
 
263 321
 // Initialize all
264 322
 $status = array();
@@ -267,13 +325,19 @@  discard block
 block discarded – undo
267 325
 $formats = array();
268 326
 $last_exec = array();
269 327
 $time = time();
270
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
271
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
272
-else $timeout = 20;
328
+if (isset($globalSourcesTimeout)) {
329
+	$timeout = $globalSourcesTimeOut;
330
+} else if (isset($globalSBS1TimeOut)) {
331
+	$timeout = $globalSBS1TimeOut;
332
+} else {
333
+	$timeout = 20;
334
+}
273 335
 $errno = '';
274 336
 $errstr='';
275 337
 
276
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
338
+if (!isset($globalDaemon)) {
339
+	$globalDaemon = TRUE;
340
+}
277 341
 /* Initiate connections to all the hosts simultaneously */
278 342
 //connect_all($hosts);
279 343
 //connect_all($globalSources);
@@ -299,7 +363,9 @@  discard block
 block discarded – undo
299 363
     if (isset($source['format']) && $source['format'] == 'aprs') {
300 364
 	$aprs_connect = 0;
301 365
 	$use_aprs = true;
302
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
366
+	if (isset($source['port']) && $source['port'] == '10152') {
367
+		$aprs_full = true;
368
+	}
303 369
 	break;
304 370
     }
305 371
 }
@@ -310,23 +376,43 @@  discard block
 block discarded – undo
310 376
 	$aprs_connect = 0;
311 377
 	$aprs_keep = 120;
312 378
 	$aprs_last_tx = time();
313
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
314
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
315
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
316
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
317
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
318
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
319
-	if ($aprs_full) $aprs_filter = '';
379
+	if (isset($globalAPRSversion)) {
380
+		$aprs_version = $globalAPRSversion;
381
+	} else {
382
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
383
+	}
384
+	if (isset($globalAPRSssid)) {
385
+		$aprs_ssid = $globalAPRSssid;
386
+	} else {
387
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
388
+	}
389
+	if (isset($globalAPRSfilter)) {
390
+		$aprs_filter = $globalAPRSfilter;
391
+	} else {
392
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
393
+	}
394
+	if ($aprs_full) {
395
+		$aprs_filter = '';
396
+	}
320 397
 
321
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
322
-	else $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n";
323
-}
398
+	if ($aprs_filter != '') {
399
+		$aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
400
+	} else {
401
+		$aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n";
402
+	}
403
+	}
324 404
 
325 405
 // connected - lets do some work
326
-if ($globalDebug) echo "Connected!\n";
406
+if ($globalDebug) {
407
+	echo "Connected!\n";
408
+}
327 409
 sleep(1);
328
-if ($globalDebug) echo "SCAN MODE \n\n";
329
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
410
+if ($globalDebug) {
411
+	echo "SCAN MODE \n\n";
412
+}
413
+if (!isset($globalCronEnd)) {
414
+	$globalCronEnd = 60;
415
+}
330 416
 $endtime = time()+$globalCronEnd;
331 417
 $i = 1;
332 418
 $tt = array();
@@ -340,10 +426,14 @@  discard block
 block discarded – undo
340 426
 
341 427
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
342 428
 while ($i > 0) {
343
-    if (!$globalDaemon) $i = $endtime-time();
429
+    if (!$globalDaemon) {
430
+    	$i = $endtime-time();
431
+    }
344 432
     // Delete old ATC
345 433
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
346
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
434
+	if ($globalDebug) {
435
+		echo 'Delete old ATC...'."\n";
436
+	}
347 437
         $ATC->deleteOldATC();
348 438
     }
349 439
     
@@ -351,10 +441,14 @@  discard block
 block discarded – undo
351 441
     if (count($last_exec) == count($globalSources)) {
352 442
 	$max = $globalMinFetch;
353 443
 	foreach ($last_exec as $last) {
354
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
444
+	    if ((time() - $last['last']) < $max) {
445
+	    	$max = time() - $last['last'];
446
+	    }
355 447
 	}
356 448
 	if ($max != $globalMinFetch) {
357
-	    if ($globalDebug) echo 'Sleeping...'."\n";
449
+	    if ($globalDebug) {
450
+	    	echo 'Sleeping...'."\n";
451
+	    }
358 452
 	    sleep($globalMinFetch-$max+2);
359 453
 	}
360 454
     }
@@ -363,11 +457,15 @@  discard block
 block discarded – undo
363 457
     //foreach ($formats as $id => $value) {
364 458
     foreach ($globalSources as $id => $value) {
365 459
 	date_default_timezone_set('UTC');
366
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
460
+	if (!isset($last_exec[$id]['last'])) {
461
+		$last_exec[$id]['last'] = 0;
462
+	}
367 463
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
368 464
 	    //$buffer = $Common->getData($hosts[$id]);
369 465
 	    $buffer = $Common->getData($value['host']);
370
-	    if ($buffer != '') $reset = 0;
466
+	    if ($buffer != '') {
467
+	    	$reset = 0;
468
+	    }
371 469
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
372 470
 	    $buffer = explode('\n',$buffer);
373 471
 	    foreach ($buffer as $line) {
@@ -376,19 +474,38 @@  discard block
 block discarded – undo
376 474
 	            $data = array();
377 475
 	            $data['hex'] = $line[1]; // hex
378 476
 	            $data['ident'] = $line[2]; // ident
379
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
380
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
381
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
382
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
383
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
477
+	            if (isset($line[3])) {
478
+	            	$data['altitude'] = $line[3];
479
+	            }
480
+	            // altitude
481
+	            if (isset($line[4])) {
482
+	            	$data['speed'] = $line[4];
483
+	            }
484
+	            // speed
485
+	            if (isset($line[5])) {
486
+	            	$data['heading'] = $line[5];
487
+	            }
488
+	            // heading
489
+	            if (isset($line[6])) {
490
+	            	$data['latitude'] = $line[6];
491
+	            }
492
+	            // lat
493
+	            if (isset($line[7])) {
494
+	            	$data['longitude'] = $line[7];
495
+	            }
496
+	            // long
384 497
 	            $data['verticalrate'] = ''; // vertical rate
385 498
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
386 499
 	            $data['emergency'] = ''; // emergency
387 500
 		    $data['datetime'] = date('Y-m-d H:i:s');
388 501
 		    $data['format_source'] = 'deltadbtxt';
389 502
     		    $data['id_source'] = $id_source;
390
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
391
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
503
+		    if (isset($value['name']) && $value['name'] != '') {
504
+		    	$data['source_name'] = $value['name'];
505
+		    }
506
+		    if (isset($value['sourcestats'])) {
507
+		    	$data['sourcestats'] = $value['sourcestats'];
508
+		    }
392 509
     		    $SI->add($data);
393 510
 		    unset($data);
394 511
     		}
@@ -398,7 +515,9 @@  discard block
 block discarded – undo
398 515
 	    date_default_timezone_set('CET');
399 516
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
400 517
 	    date_default_timezone_set('UTC');
401
-	    if ($buffer != '') $reset = 0;
518
+	    if ($buffer != '') {
519
+	    	$reset = 0;
520
+	    }
402 521
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
403 522
 	    $buffer = explode('\n',$buffer);
404 523
 	    foreach ($buffer as $line) {
@@ -407,13 +526,27 @@  discard block
 block discarded – undo
407 526
 		    $add = false;
408 527
 		    $ais_data = $AIS->parse_line(trim($line));
409 528
 		    $data = array();
410
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
411
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
412
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
413
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
414
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
415
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
416
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
529
+		    if (isset($ais_data['ident'])) {
530
+		    	$data['ident'] = $ais_data['ident'];
531
+		    }
532
+		    if (isset($ais_data['mmsi'])) {
533
+		    	$data['mmsi'] = $ais_data['mmsi'];
534
+		    }
535
+		    if (isset($ais_data['speed'])) {
536
+		    	$data['speed'] = $ais_data['speed'];
537
+		    }
538
+		    if (isset($ais_data['heading'])) {
539
+		    	$data['heading'] = $ais_data['heading'];
540
+		    }
541
+		    if (isset($ais_data['latitude'])) {
542
+		    	$data['latitude'] = $ais_data['latitude'];
543
+		    }
544
+		    if (isset($ais_data['longitude'])) {
545
+		    	$data['longitude'] = $ais_data['longitude'];
546
+		    }
547
+		    if (isset($ais_data['status'])) {
548
+		    	$data['status'] = $ais_data['status'];
549
+		    }
417 550
 		    if (isset($ais_data['timestamp'])) {
418 551
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
419 552
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -428,7 +561,9 @@  discard block
 block discarded – undo
428 561
     		    $data['id_source'] = $id_source;
429 562
 		    print_r($data);
430 563
 		    echo 'Add...'."\n";
431
-		    if ($add) $MI->add($data);
564
+		    if ($add) {
565
+		    	$MI->add($data);
566
+		    }
432 567
 		    unset($data);
433 568
 		}
434 569
     	    }
@@ -446,13 +581,27 @@  discard block
 block discarded – undo
446 581
 			if ($line != '') {
447 582
 			    $ais_data = $AIS->parse_line(trim($line));
448 583
 			    $data = array();
449
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
450
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
451
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
452
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
453
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
454
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
455
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
584
+			    if (isset($ais_data['ident'])) {
585
+			    	$data['ident'] = $ais_data['ident'];
586
+			    }
587
+			    if (isset($ais_data['mmsi'])) {
588
+			    	$data['mmsi'] = $ais_data['mmsi'];
589
+			    }
590
+			    if (isset($ais_data['speed'])) {
591
+			    	$data['speed'] = $ais_data['speed'];
592
+			    }
593
+			    if (isset($ais_data['heading'])) {
594
+			    	$data['heading'] = $ais_data['heading'];
595
+			    }
596
+			    if (isset($ais_data['latitude'])) {
597
+			    	$data['latitude'] = $ais_data['latitude'];
598
+			    }
599
+			    if (isset($ais_data['longitude'])) {
600
+			    	$data['longitude'] = $ais_data['longitude'];
601
+			    }
602
+			    if (isset($ais_data['status'])) {
603
+			    	$data['status'] = $ais_data['status'];
604
+			    }
456 605
 			    if (isset($ais_data['timestamp'])) {
457 606
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
458 607
 			    } else {
@@ -470,7 +619,9 @@  discard block
 block discarded – undo
470 619
 	    echo 'download...';
471 620
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
472 621
 	    echo 'done !'."\n";
473
-	    if ($buffer != '') $reset = 0;
622
+	    if ($buffer != '') {
623
+	    	$reset = 0;
624
+	    }
474 625
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
475 626
 	    $buffer = explode('\n',$buffer);
476 627
 	    foreach ($buffer as $line) {
@@ -514,16 +665,28 @@  discard block
 block discarded – undo
514 665
     		    $line = explode(':', $line);
515 666
     		    if (count($line) > 30 && $line[0] != 'callsign') {
516 667
 			$data = array();
517
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
518
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
668
+			if (isset($line[37]) && $line[37] != '') {
669
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
670
+			} else {
671
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
672
+			}
519 673
 			$data['pilot_id'] = $line[1];
520 674
 			$data['pilot_name'] = $line[2];
521 675
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
522 676
 			$data['ident'] = $line[0]; // ident
523
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
677
+			if ($line[7] != '' && $line[7] != 0) {
678
+				$data['altitude'] = $line[7];
679
+			}
680
+			// altitude
524 681
 			$data['speed'] = $line[8]; // speed
525
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
526
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
682
+			if (isset($line[45])) {
683
+				$data['heading'] = $line[45];
684
+			}
685
+			// heading
686
+			elseif (isset($line[38])) {
687
+				$data['heading'] = $line[38];
688
+			}
689
+			// heading
527 690
 			$data['latitude'] = $line[5]; // lat
528 691
 	        	$data['longitude'] = $line[6]; // long
529 692
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -539,7 +702,9 @@  discard block
 block discarded – undo
539 702
 			$data['frequency'] = $line[4];
540 703
 			$data['type'] = $line[18];
541 704
 			$data['range'] = $line[19];
542
-			if (isset($line[35])) $data['info'] = $line[35];
705
+			if (isset($line[35])) {
706
+				$data['info'] = $line[35];
707
+			}
543 708
     			$data['id_source'] = $id_source;
544 709
 	    		//$data['arrival_airport_time'] = ;
545 710
 	    		if ($line[9] != '') {
@@ -553,24 +718,41 @@  discard block
 block discarded – undo
553 718
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
554 719
 	    		*/
555 720
 	    		$data['format_source'] = $value['format'];
556
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
557
-    			if ($line[3] == 'PILOT') $SI->add($data);
558
-			elseif ($line[3] == 'ATC') {
721
+			if (isset($value['name']) && $value['name'] != '') {
722
+				$data['source_name'] = $value['name'];
723
+			}
724
+    			if ($line[3] == 'PILOT') {
725
+    				$SI->add($data);
726
+    			} elseif ($line[3] == 'ATC') {
559 727
 				//print_r($data);
560 728
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
561 729
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
562 730
 				$typec = substr($data['ident'],-3);
563
-				if ($typec == 'APP') $data['type'] = 'Approach';
564
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
565
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
566
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
567
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
568
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
569
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
570
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
571
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
572
-				if (!isset($data['source_name'])) $data['source_name'] = '';
573
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
731
+				if ($typec == 'APP') {
732
+					$data['type'] = 'Approach';
733
+				} elseif ($typec == 'TWR') {
734
+					$data['type'] = 'Tower';
735
+				} elseif ($typec == 'OBS') {
736
+					$data['type'] = 'Observer';
737
+				} elseif ($typec == 'GND') {
738
+					$data['type'] = 'Ground';
739
+				} elseif ($typec == 'DEL') {
740
+					$data['type'] = 'Delivery';
741
+				} elseif ($typec == 'DEP') {
742
+					$data['type'] = 'Departure';
743
+				} elseif ($typec == 'FSS') {
744
+					$data['type'] = 'Flight Service Station';
745
+				} elseif ($typec == 'CTR') {
746
+					$data['type'] = 'Control Radar or Centre';
747
+				} elseif ($data['type'] == '') {
748
+					$data['type'] = 'Observer';
749
+				}
750
+				if (!isset($data['source_name'])) {
751
+					$data['source_name'] = '';
752
+				}
753
+				if (isset($ATC)) {
754
+					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']);
755
+				}
574 756
 			}
575 757
     			unset($data);
576 758
     		    }
@@ -589,26 +771,55 @@  discard block
 block discarded – undo
589 771
 		foreach ($all_data['acList'] as $line) {
590 772
 		    $data = array();
591 773
 		    $data['hex'] = $line['Icao']; // hex
592
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
593
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
594
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
595
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
596
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
597
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
774
+		    if (isset($line['Call'])) {
775
+		    	$data['ident'] = $line['Call'];
776
+		    }
777
+		    // ident
778
+		    if (isset($line['Alt'])) {
779
+		    	$data['altitude'] = $line['Alt'];
780
+		    }
781
+		    // altitude
782
+		    if (isset($line['Spd'])) {
783
+		    	$data['speed'] = $line['Spd'];
784
+		    }
785
+		    // speed
786
+		    if (isset($line['Trak'])) {
787
+		    	$data['heading'] = $line['Trak'];
788
+		    }
789
+		    // heading
790
+		    if (isset($line['Lat'])) {
791
+		    	$data['latitude'] = $line['Lat'];
792
+		    }
793
+		    // lat
794
+		    if (isset($line['Long'])) {
795
+		    	$data['longitude'] = $line['Long'];
796
+		    }
797
+		    // long
598 798
 		    //$data['verticalrate'] = $line['']; // verticale rate
599
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
799
+		    if (isset($line['Sqk'])) {
800
+		    	$data['squawk'] = $line['Sqk'];
801
+		    }
802
+		    // squawk
600 803
 		    $data['emergency'] = ''; // emergency
601
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
804
+		    if (isset($line['Reg'])) {
805
+		    	$data['registration'] = $line['Reg'];
806
+		    }
602 807
 		    /*
603 808
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
604 809
 		    else $data['datetime'] = date('Y-m-d H:i:s');
605 810
 		    */
606 811
 		    $data['datetime'] = date('Y-m-d H:i:s');
607
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
812
+		    if (isset($line['Type'])) {
813
+		    	$data['aircraft_icao'] = $line['Type'];
814
+		    }
608 815
 	    	    $data['format_source'] = 'aircraftlistjson';
609 816
 		    $data['id_source'] = $id_source;
610
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
611
-		    if (isset($data['datetime'])) $SI->add($data);
817
+		    if (isset($value['name']) && $value['name'] != '') {
818
+		    	$data['source_name'] = $value['name'];
819
+		    }
820
+		    if (isset($data['datetime'])) {
821
+		    	$SI->add($data);
822
+		    }
612 823
 		    unset($data);
613 824
 		}
614 825
 	    } else {
@@ -628,7 +839,9 @@  discard block
 block discarded – undo
628 839
 		    $data['datetime'] = date('Y-m-d H:i:s');
629 840
 	    	    $data['format_source'] = 'aircraftlistjson';
630 841
     		    $data['id_source'] = $id_source;
631
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
842
+		    if (isset($value['name']) && $value['name'] != '') {
843
+		    	$data['source_name'] = $value['name'];
844
+		    }
632 845
 		    $SI->add($data);
633 846
 		    unset($data);
634 847
 		}
@@ -664,7 +877,9 @@  discard block
 block discarded – undo
664 877
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
665 878
 	    	    $data['format_source'] = 'planeupdatefaa';
666 879
     		    $data['id_source'] = $id_source;
667
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
880
+		    if (isset($value['name']) && $value['name'] != '') {
881
+		    	$data['source_name'] = $value['name'];
882
+		    }
668 883
 		    $SI->add($data);
669 884
 		    unset($data);
670 885
 		}
@@ -704,7 +919,9 @@  discard block
 block discarded – undo
704 919
 	    //$buffer = $Common->getData($hosts[$id]);
705 920
 	    $buffer = $Common->getData($value['host']);
706 921
 	    $all_data = json_decode($buffer,true);
707
-	    if (!empty($all_data)) $reset = 0;
922
+	    if (!empty($all_data)) {
923
+	    	$reset = 0;
924
+	    }
708 925
 	    foreach ($all_data as $key => $line) {
709 926
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
710 927
 		    $data = array();
@@ -725,7 +942,9 @@  discard block
 block discarded – undo
725 942
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
726 943
 	    	    $data['format_source'] = 'fr24json';
727 944
     		    $data['id_source'] = $id_source;
728
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
945
+		    if (isset($value['name']) && $value['name'] != '') {
946
+		    	$data['source_name'] = $value['name'];
947
+		    }
729 948
 		    $SI->add($data);
730 949
 		    unset($data);
731 950
 		}
@@ -749,23 +968,39 @@  discard block
 block discarded – undo
749 968
 		    if (isset($line['inf'])) {
750 969
 			$data = array();
751 970
 			$data['hex'] = $line['inf']['ia'];
752
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
971
+			if (isset($line['inf']['cs'])) {
972
+				$data['ident'] = $line['inf']['cs'];
973
+			}
974
+			//$line[13]
753 975
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
754
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
755
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
976
+	    		if (isset($line['inf']['gs'])) {
977
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
978
+	    		}
979
+	    		// speed
980
+	    		if (isset($line['inf']['tr'])) {
981
+	    			$data['heading'] = $line['inf']['tr'];
982
+	    		}
983
+	    		// heading
756 984
 	    		$data['latitude'] = $line['pt'][0]; // lat
757 985
 	    		$data['longitude'] = $line['pt'][1]; // long
758 986
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
759
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
987
+	    		if (isset($line['inf']['sq'])) {
988
+	    			$data['squawk'] = $line['inf']['sq'];
989
+	    		}
990
+	    		// squawk
760 991
 	    		//$data['aircraft_icao'] = $line[8];
761
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
992
+	    		if (isset($line['inf']['rc'])) {
993
+	    			$data['registration'] = $line['inf']['rc'];
994
+	    		}
762 995
 			//$data['departure_airport_iata'] = $line[11];
763 996
 			//$data['arrival_airport_iata'] = $line[12];
764 997
 	    		//$data['emergency'] = ''; // emergency
765 998
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
766 999
 	    		$data['format_source'] = 'radarvirtueljson';
767 1000
     			$data['id_source'] = $id_source;
768
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1001
+			if (isset($value['name']) && $value['name'] != '') {
1002
+				$data['source_name'] = $value['name'];
1003
+			}
769 1004
 			$SI->add($data);
770 1005
 			unset($data);
771 1006
 		    }
@@ -786,29 +1021,62 @@  discard block
 block discarded – undo
786 1021
 		    $data['id'] = $line['id'];
787 1022
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
788 1023
 		    $data['ident'] = $line['callsign']; // ident
789
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
790
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
791
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
792
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
793
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
794
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1024
+		    if (isset($line['pilotid'])) {
1025
+		    	$data['pilot_id'] = $line['pilotid'];
1026
+		    }
1027
+		    // pilot id
1028
+		    if (isset($line['name'])) {
1029
+		    	$data['pilot_name'] = $line['name'];
1030
+		    }
1031
+		    // pilot name
1032
+		    if (isset($line['alt'])) {
1033
+		    	$data['altitude'] = $line['alt'];
1034
+		    }
1035
+		    // altitude
1036
+		    if (isset($line['gs'])) {
1037
+		    	$data['speed'] = $line['gs'];
1038
+		    }
1039
+		    // speed
1040
+		    if (isset($line['heading'])) {
1041
+		    	$data['heading'] = $line['heading'];
1042
+		    }
1043
+		    // heading
1044
+		    if (isset($line['route'])) {
1045
+		    	$data['waypoints'] = $line['route'];
1046
+		    }
1047
+		    // route
795 1048
 		    $data['latitude'] = $line['lat']; // lat
796 1049
 		    $data['longitude'] = $line['lon']; // long
797 1050
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
798 1051
 		    //$data['squawk'] = $line['squawk']; // squawk
799 1052
 		    //$data['emergency'] = ''; // emergency
800
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
801
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
802
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1053
+		    if (isset($line['depicao'])) {
1054
+		    	$data['departure_airport_icao'] = $line['depicao'];
1055
+		    }
1056
+		    if (isset($line['deptime'])) {
1057
+		    	$data['departure_airport_time'] = $line['deptime'];
1058
+		    }
1059
+		    if (isset($line['arricao'])) {
1060
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1061
+		    }
803 1062
 		    //$data['arrival_airport_time'] = $line['arrtime'];
804
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
805
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
806
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
807
-		    else $data['info'] = '';
1063
+		    if (isset($line['aircraft'])) {
1064
+		    	$data['aircraft_icao'] = $line['aircraft'];
1065
+		    }
1066
+		    if (isset($line['transponder'])) {
1067
+		    	$data['squawk'] = $line['transponder'];
1068
+		    }
1069
+		    if (isset($line['atis'])) {
1070
+		    	$data['info'] = $line['atis'];
1071
+		    } else {
1072
+		    	$data['info'] = '';
1073
+		    }
808 1074
 		    $data['format_source'] = 'pireps';
809 1075
     		    $data['id_source'] = $id_source;
810 1076
 		    $data['datetime'] = date('Y-m-d H:i:s');
811
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1077
+		    if (isset($value['name']) && $value['name'] != '') {
1078
+		    	$data['source_name'] = $value['name'];
1079
+		    }
812 1080
 		    if ($line['icon'] == 'plane') {
813 1081
 			$SI->add($data);
814 1082
 		    //    print_r($data);
@@ -817,16 +1085,28 @@  discard block
 block discarded – undo
817 1085
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
818 1086
 			$typec = substr($data['ident'],-3);
819 1087
 			$data['type'] = '';
820
-			if ($typec == 'APP') $data['type'] = 'Approach';
821
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
822
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
823
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
824
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
825
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
826
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
827
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
828
-			else $data['type'] = 'Observer';
829
-			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']);
1088
+			if ($typec == 'APP') {
1089
+				$data['type'] = 'Approach';
1090
+			} elseif ($typec == 'TWR') {
1091
+				$data['type'] = 'Tower';
1092
+			} elseif ($typec == 'OBS') {
1093
+				$data['type'] = 'Observer';
1094
+			} elseif ($typec == 'GND') {
1095
+				$data['type'] = 'Ground';
1096
+			} elseif ($typec == 'DEL') {
1097
+				$data['type'] = 'Delivery';
1098
+			} elseif ($typec == 'DEP') {
1099
+				$data['type'] = 'Departure';
1100
+			} elseif ($typec == 'FSS') {
1101
+				$data['type'] = 'Flight Service Station';
1102
+			} elseif ($typec == 'CTR') {
1103
+				$data['type'] = 'Control Radar or Centre';
1104
+			} else {
1105
+				$data['type'] = 'Observer';
1106
+			}
1107
+			if (isset($ATC)) {
1108
+				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']);
1109
+			}
830 1110
 		    }
831 1111
 		    unset($data);
832 1112
 		}
@@ -836,7 +1116,9 @@  discard block
 block discarded – undo
836 1116
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
837 1117
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
838 1118
 	    //$buffer = $Common->getData($hosts[$id]);
839
-	    if ($globalDebug) echo 'Get Data...'."\n";
1119
+	    if ($globalDebug) {
1120
+	    	echo 'Get Data...'."\n";
1121
+	    }
840 1122
 	    $buffer = $Common->getData($value['host']);
841 1123
 	    $all_data = json_decode($buffer,true);
842 1124
 	    if ($buffer != '' && is_array($all_data)) {
@@ -844,10 +1126,16 @@  discard block
 block discarded – undo
844 1126
 		foreach ($all_data as $line) {
845 1127
 	    	    $data = array();
846 1128
 	    	    //$data['id'] = $line['id']; // id not usable
847
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1129
+	    	    if (isset($line['pilotid'])) {
1130
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1131
+	    	    }
848 1132
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
849
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
850
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1133
+	    	    if (isset($line['pilotname'])) {
1134
+	    	    	$data['pilot_name'] = $line['pilotname'];
1135
+	    	    }
1136
+	    	    if (isset($line['pilotid'])) {
1137
+	    	    	$data['pilot_id'] = $line['pilotid'];
1138
+	    	    }
851 1139
 	    	    $data['ident'] = $line['flightnum']; // ident
852 1140
 	    	    $data['altitude'] = $line['alt']; // altitude
853 1141
 	    	    $data['speed'] = $line['gs']; // speed
@@ -865,27 +1153,41 @@  discard block
 block discarded – undo
865 1153
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
866 1154
     		    $data['arrival_airport_time'] = $line['arrtime'];
867 1155
     		    $data['registration'] = $line['aircraft'];
868
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1156
+		    if (isset($line['route'])) {
1157
+		    	$data['waypoints'] = $line['route'];
1158
+		    }
1159
+		    // route
869 1160
 		    if (isset($line['aircraftname'])) {
870 1161
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
871 1162
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
872 1163
 	    		$aircraft_data = explode('-',$line['aircraftname']);
873
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
874
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
875
-	    		else {
1164
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
1165
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1166
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
1167
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1168
+	    		} else {
876 1169
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
877
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
878
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
1170
+	    		    if (isset($aircraft_data[1])) {
1171
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
1172
+	    		    } else {
1173
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
1174
+	    		    }
879 1175
 	    		}
880 1176
 	    	    }
881
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1177
+    		    if (isset($line['route'])) {
1178
+    		    	$data['waypoints'] = $line['route'];
1179
+    		    }
882 1180
     		    $data['id_source'] = $id_source;
883 1181
 	    	    $data['format_source'] = 'phpvmacars';
884
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1182
+		    if (isset($value['name']) && $value['name'] != '') {
1183
+		    	$data['source_name'] = $value['name'];
1184
+		    }
885 1185
 		    $SI->add($data);
886 1186
 		    unset($data);
887 1187
 		}
888
-		if ($globalDebug) echo 'No more data...'."\n";
1188
+		if ($globalDebug) {
1189
+			echo 'No more data...'."\n";
1190
+		}
889 1191
 		unset($buffer);
890 1192
 		unset($all_data);
891 1193
 	    }
@@ -893,7 +1195,9 @@  discard block
 block discarded – undo
893 1195
     	    $last_exec[$id]['last'] = time();
894 1196
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
895 1197
 	    //$buffer = $Common->getData($hosts[$id]);
896
-	    if ($globalDebug) echo 'Get Data...'."\n";
1198
+	    if ($globalDebug) {
1199
+	    	echo 'Get Data...'."\n";
1200
+	    }
897 1201
 	    $buffer = $Common->getData($value['host']);
898 1202
 	    $all_data = json_decode($buffer,true);
899 1203
 	    if ($buffer != '' && is_array($all_data)) {
@@ -922,15 +1226,22 @@  discard block
 block discarded – undo
922 1226
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
923 1227
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
924 1228
     		    //$data['registration'] = $line['aircraft'];
925
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1229
+		    if (isset($line['route'])) {
1230
+		    	$data['waypoints'] = $line['route'];
1231
+		    }
1232
+		    // route
926 1233
 	    	    $data['aircraft_icao'] = $line['plane_type'];
927 1234
     		    $data['id_source'] = $id_source;
928 1235
 	    	    $data['format_source'] = 'vam';
929
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1236
+		    if (isset($value['name']) && $value['name'] != '') {
1237
+		    	$data['source_name'] = $value['name'];
1238
+		    }
930 1239
 		    $SI->add($data);
931 1240
 		    unset($data);
932 1241
 		}
933
-		if ($globalDebug) echo 'No more data...'."\n";
1242
+		if ($globalDebug) {
1243
+			echo 'No more data...'."\n";
1244
+		}
934 1245
 		unset($buffer);
935 1246
 		unset($all_data);
936 1247
 	    }
@@ -938,7 +1249,9 @@  discard block
 block discarded – undo
938 1249
     	    $last_exec[$id]['last'] = time();
939 1250
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
940 1251
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais') {
941
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1252
+	    if (function_exists('pcntl_fork')) {
1253
+	    	pcntl_signal_dispatch();
1254
+	    }
942 1255
     	    //$last_exec[$id]['last'] = time();
943 1256
 
944 1257
 	    //$read = array( $sockets[$id] );
@@ -946,7 +1259,9 @@  discard block
 block discarded – undo
946 1259
 	    $write = NULL;
947 1260
 	    $e = NULL;
948 1261
 	    $n = socket_select($read, $write, $e, $timeout);
949
-	    if ($e != NULL) var_dump($e);
1262
+	    if ($e != NULL) {
1263
+	    	var_dump($e);
1264
+	    }
950 1265
 	    if ($n > 0) {
951 1266
 		$reset = 0;
952 1267
 		foreach ($read as $nb => $r) {
@@ -968,7 +1283,9 @@  discard block
 block discarded – undo
968 1283
 		    if ($buffer != '') {
969 1284
 			$tt[$format] = 0;
970 1285
 			if ($format == 'acarssbs3') {
971
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1286
+                    	    if ($globalDebug) {
1287
+                    	    	echo 'ACARS : '.$buffer."\n";
1288
+                    	    }
972 1289
 			    $ACARS->add(trim($buffer));
973 1290
 			    $ACARS->deleteLiveAcarsData();
974 1291
 			} elseif ($format == 'raw') {
@@ -977,19 +1294,37 @@  discard block
 block discarded – undo
977 1294
 			    if (is_array($data)) {
978 1295
 				$data['datetime'] = date('Y-m-d H:i:s');
979 1296
 				$data['format_source'] = 'raw';
980
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
981
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
982
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1297
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1298
+					$data['source_name'] = $globalSources[$nb]['name'];
1299
+				}
1300
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1301
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1302
+    				}
1303
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1304
+                                	$SI->add($data);
1305
+                                }
983 1306
                             }
984 1307
                         } elseif ($format == 'ais') {
985 1308
 			    $ais_data = $AIS->parse_line(trim($buffer));
986 1309
 			    $data = array();
987
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
988
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
989
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
990
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
991
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
992
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1310
+			    if (isset($ais_data['ident'])) {
1311
+			    	$data['ident'] = $ais_data['ident'];
1312
+			    }
1313
+			    if (isset($ais_data['mmsi'])) {
1314
+			    	$data['mmsi'] = $ais_data['mmsi'];
1315
+			    }
1316
+			    if (isset($ais_data['speed'])) {
1317
+			    	$data['speed'] = $ais_data['speed'];
1318
+			    }
1319
+			    if (isset($ais_data['heading'])) {
1320
+			    	$data['heading'] = $ais_data['heading'];
1321
+			    }
1322
+			    if (isset($ais_data['latitude'])) {
1323
+			    	$data['latitude'] = $ais_data['latitude'];
1324
+			    }
1325
+			    if (isset($ais_data['longitude'])) {
1326
+			    	$data['longitude'] = $ais_data['longitude'];
1327
+			    }
993 1328
 			    if (isset($ais_data['timestamp'])) {
994 1329
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
995 1330
 			    } else {
@@ -1015,11 +1350,15 @@  discard block
 block discarded – undo
1015 1350
 				$data['speed'] = round($line[5]*1.94384);
1016 1351
 				$data['datetime'] = date('Y-m-d H:i:s');
1017 1352
 				$data['format_source'] = 'flightgearsp';
1018
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1353
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1354
+					$SI->add($data);
1355
+				}
1019 1356
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1020 1357
 			    }
1021 1358
                         } elseif ($format == 'acars') {
1022
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1359
+                    	    if ($globalDebug) {
1360
+                    	    	echo 'ACARS : '.$buffer."\n";
1361
+                    	    }
1023 1362
 			    $ACARS->add(trim($buffer));
1024 1363
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1025 1364
 			    $ACARS->deleteLiveAcarsData();
@@ -1040,7 +1379,9 @@  discard block
 block discarded – undo
1040 1379
 				    $aircraft_type = $line[10];
1041 1380
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1042 1381
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1043
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1382
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1383
+				    	$SI->add($data);
1384
+				    }
1044 1385
 				}
1045 1386
 			    }
1046 1387
 			} elseif ($format == 'beast') {
@@ -1056,21 +1397,43 @@  discard block
 block discarded – undo
1056 1397
     				$data['hex'] = $lined['hexid'];
1057 1398
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1058 1399
     				$data['datetime'] = date('Y-m-d H:i:s');;
1059
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1060
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1061
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1062
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1063
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1064
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1065
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1400
+    				if (isset($lined['ident'])) {
1401
+    					$data['ident'] = $lined['ident'];
1402
+    				}
1403
+    				if (isset($lined['lat'])) {
1404
+    					$data['latitude'] = $lined['lat'];
1405
+    				}
1406
+    				if (isset($lined['lon'])) {
1407
+    					$data['longitude'] = $lined['lon'];
1408
+    				}
1409
+    				if (isset($lined['speed'])) {
1410
+    					$data['speed'] = $lined['speed'];
1411
+    				}
1412
+    				if (isset($lined['squawk'])) {
1413
+    					$data['squawk'] = $lined['squawk'];
1414
+    				}
1415
+    				if (isset($lined['alt'])) {
1416
+    					$data['altitude'] = $lined['alt'];
1417
+    				}
1418
+    				if (isset($lined['heading'])) {
1419
+    					$data['heading'] = $lined['heading'];
1420
+    				}
1066 1421
     				$data['id_source'] = $id_source;
1067 1422
     				$data['format_source'] = 'tsv';
1068
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1069
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1070
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1423
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1424
+    					$data['source_name'] = $globalSources[$nb]['name'];
1425
+    				}
1426
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1427
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1428
+    				}
1429
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1430
+    					$SI->add($data);
1431
+    				}
1071 1432
     				unset($lined);
1072 1433
     				unset($data);
1073
-    			    } else $error = true;
1434
+    			    } else {
1435
+    			    	$error = true;
1436
+    			    }
1074 1437
 			} elseif ($format == 'aprs' && $use_aprs) {
1075 1438
 			    if ($aprs_connect == 0) {
1076 1439
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1095,47 +1458,72 @@  discard block
 block discarded – undo
1095 1458
 				    $aprs_last_tx = time();
1096 1459
 				    $data = array();
1097 1460
 				    //print_r($line);
1098
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1099
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1100
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1461
+				    if (isset($line['address'])) {
1462
+				    	$data['hex'] = $line['address'];
1463
+				    }
1464
+				    if (isset($line['timestamp'])) {
1465
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1466
+				    } else {
1467
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1468
+				    }
1101 1469
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1102 1470
 				    $data['ident'] = $line['ident'];
1103 1471
 				    $data['latitude'] = $line['latitude'];
1104 1472
 				    $data['longitude'] = $line['longitude'];
1105 1473
 				    //$data['verticalrate'] = $line[16];
1106
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1107
-				    else $data['speed'] = 0;
1108
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1109
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1110
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1111
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1474
+				    if (isset($line['speed'])) {
1475
+				    	$data['speed'] = $line['speed'];
1476
+				    } else {
1477
+				    	$data['speed'] = 0;
1478
+				    }
1479
+				    if (isset($line['altitude'])) {
1480
+				    	$data['altitude'] = $line['altitude'];
1481
+				    }
1482
+				    if (isset($line['comment'])) {
1483
+				    	$data['comment'] = $line['comment'];
1484
+				    }
1485
+				    if (isset($line['symbol'])) {
1486
+				    	$data['type'] = $line['symbol'];
1487
+				    }
1488
+				    if (isset($line['heading'])) {
1489
+				    	$data['heading'] = $line['heading'];
1490
+				    }
1112 1491
 				    //else $data['heading'] = 0;
1113
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1114
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1492
+				    if (isset($line['stealth'])) {
1493
+				    	$data['aircraft_type'] = $line['stealth'];
1494
+				    }
1495
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1496
+				    	$data['noarchive'] = true;
1497
+				    }
1115 1498
     				    $data['id_source'] = $id_source;
1116 1499
 				    $data['format_source'] = 'aprs';
1117 1500
 				    $data['source_name'] = $line['source'];
1118 1501
 				    $data['source_type'] = 'flarm';
1119
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1502
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1503
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1504
+    				    }
1120 1505
 				    $currentdate = date('Y-m-d H:i:s');
1121 1506
 				    $aprsdate = strtotime($data['datetime']);
1122 1507
 				    // Accept data if time <= system time + 20s
1123 1508
 				    if (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'])))) {
1124 1509
 					$send = $SI->add($data);
1125 1510
 				    } elseif (isset($line['stealth'])) {
1126
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1127
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1511
+					if ($line['stealth'] != 0) {
1512
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1513
+					} else {
1514
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1515
+					}
1128 1516
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1129 1517
 				    } 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') {
1130 1518
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1131
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1519
+					if (isset($globalTracker) && $globalTracker) {
1520
+						$send = $TI->add($data);
1521
+					}
1132 1522
 				    }
1133 1523
 				    unset($data);
1134
-				} 
1135
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1524
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1136 1525
 					echo '!! Weather Station not yet supported'."\n";
1137
-				}
1138
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1526
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1139 1527
 					echo '!! Car & Trucks not yet supported'."\n";
1140 1528
 				}
1141 1529
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1168,25 +1556,42 @@  discard block
 block discarded – undo
1168 1556
     				$data['ground'] = $line[21];
1169 1557
     				$data['emergency'] = $line[19];
1170 1558
     				$data['format_source'] = 'sbs';
1171
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1172
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1559
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1560
+					$data['source_name'] = $globalSources[$nb]['name'];
1561
+				}
1562
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1563
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1564
+    				}
1173 1565
     				$data['id_source'] = $id_source;
1174
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1175
-    				else $error = true;
1566
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1567
+    					$send = $SI->add($data);
1568
+    				} else {
1569
+    					$error = true;
1570
+    				}
1176 1571
     				unset($data);
1177
-    			    } else $error = true;
1572
+    			    } else {
1573
+    			    	$error = true;
1574
+    			    }
1178 1575
 			    if ($error) {
1179 1576
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1180
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1577
+					if ($globalDebug) {
1578
+						echo "Not a message. Ignoring... \n";
1579
+					}
1181 1580
 				} else {
1182
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1581
+					if ($globalDebug) {
1582
+						echo "Wrong line format. Ignoring... \n";
1583
+					}
1183 1584
 					if ($globalDebug) {
1184 1585
 						echo $buffer;
1185 1586
 						print_r($line);
1186 1587
 					}
1187 1588
 					//socket_close($r);
1188
-					if ($globalDebug) echo "Reconnect after an error...\n";
1189
-					if ($format == 'aprs') $aprs_connect = 0;
1589
+					if ($globalDebug) {
1590
+						echo "Reconnect after an error...\n";
1591
+					}
1592
+					if ($format == 'aprs') {
1593
+						$aprs_connect = 0;
1594
+					}
1190 1595
 					$sourceer[$nb] = $globalSources[$nb];
1191 1596
 					connect_all($sourceer);
1192 1597
 					$sourceer = array();
@@ -1194,10 +1599,14 @@  discard block
 block discarded – undo
1194 1599
 			    }
1195 1600
 			}
1196 1601
 			// Sleep for xxx microseconds
1197
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1602
+			if (isset($globalSBSSleep)) {
1603
+				usleep($globalSBSSleep);
1604
+			}
1198 1605
 		    } else {
1199 1606
 			if ($format == 'flightgearmp') {
1200
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1607
+			    	if ($globalDebug) {
1608
+			    		echo "Reconnect FlightGear MP...";
1609
+			    	}
1201 1610
 				//@socket_close($r);
1202 1611
 				sleep($globalMinFetch);
1203 1612
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1206,10 +1615,15 @@  discard block
 block discarded – undo
1206 1615
 				break;
1207 1616
 				
1208 1617
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1209
-			    if (isset($tt[$format])) $tt[$format]++;
1210
-			    else $tt[$format] = 0;
1618
+			    if (isset($tt[$format])) {
1619
+			    	$tt[$format]++;
1620
+			    } else {
1621
+			    	$tt[$format] = 0;
1622
+			    }
1211 1623
 			    if ($tt[$format] > 30) {
1212
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1624
+				if ($globalDebug) {
1625
+					echo "ERROR : Reconnect ".$format."...";
1626
+				}
1213 1627
 				//@socket_close($r);
1214 1628
 				sleep(2);
1215 1629
 				$aprs_connect = 0;
@@ -1226,11 +1640,17 @@  discard block
 block discarded – undo
1226 1640
 	    } else {
1227 1641
 		$error = socket_strerror(socket_last_error());
1228 1642
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1229
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1230
-			if (isset($globalDebug)) echo "Restarting...\n";
1643
+			if ($globalDebug) {
1644
+				echo "ERROR : socket_select give this error ".$error . "\n";
1645
+			}
1646
+			if (isset($globalDebug)) {
1647
+				echo "Restarting...\n";
1648
+			}
1231 1649
 			// Restart the script if possible
1232 1650
 			if (is_array($sockets)) {
1233
-			    if ($globalDebug) echo "Shutdown all sockets...";
1651
+			    if ($globalDebug) {
1652
+			    	echo "Shutdown all sockets...";
1653
+			    }
1234 1654
 			    
1235 1655
 			    foreach ($sockets as $sock) {
1236 1656
 				@socket_shutdown($sock,2);
@@ -1238,18 +1658,24 @@  discard block
 block discarded – undo
1238 1658
 			    }
1239 1659
 			    
1240 1660
 			}
1241
-			if ($globalDebug) echo "Restart all connections...";
1661
+			if ($globalDebug) {
1662
+				echo "Restart all connections...";
1663
+			}
1242 1664
 			sleep(2);
1243 1665
 			$time = time();
1244 1666
 			//connect_all($hosts);
1245 1667
 			$aprs_connect = 0;
1246
-			if ($reset > 40) exit('Too many attempts...');
1668
+			if ($reset > 40) {
1669
+				exit('Too many attempts...');
1670
+			}
1247 1671
 			connect_all($globalSources);
1248 1672
 		}
1249 1673
 	    }
1250 1674
 	}
1251 1675
 	if ($globalDaemon === false) {
1252
-	    if ($globalDebug) echo 'Check all...'."\n";
1676
+	    if ($globalDebug) {
1677
+	    	echo 'Check all...'."\n";
1678
+	    }
1253 1679
 	    $SI->checkAll();
1254 1680
 	}
1255 1681
     }
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +428 added lines, -113 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
236 284
 			</div>
@@ -239,42 +287,86 @@  discard block
 block discarded – undo
239 287
 			<legend>Coverage area</legend>
240 288
 			<p>
241 289
 				<label for="latitudemax">The maximum latitude (north)</label>
242
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
290
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
291
+	print $globalLatitudeMax;
292
+}
293
+?>" />
243 294
 			</p>
244 295
 			<p>
245 296
 				<label for="latitudemin">The minimum latitude (south)</label>
246
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
297
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
298
+	print $globalLatitudeMin;
299
+}
300
+?>" />
247 301
 			</p>
248 302
 			<p>
249 303
 				<label for="longitudemax">The maximum longitude (west)</label>
250
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
304
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
305
+	print $globalLongitudeMax;
306
+}
307
+?>" />
251 308
 			</p>
252 309
 			<p>
253 310
 				<label for="longitudemin">The minimum longitude (east)</label>
254
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
311
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
312
+	print $globalLongitudeMin;
313
+}
314
+?>" />
255 315
 			</p>
256 316
 			<p>
257 317
 				<label for="latitudecenter">The latitude center</label>
258
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
318
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
319
+	print $globalCenterLatitude;
320
+}
321
+?>" />
259 322
 			</p>
260 323
 			<p>
261 324
 				<label for="longitudecenter">The longitude center</label>
262
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
325
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
326
+	print $globalCenterLongitude;
327
+}
328
+?>" />
263 329
 			</p>
264 330
 			<p>
265 331
 				<label for="livezoom">Default Zoom on live map</label>
266
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
332
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
333
+	print $globalLiveZoom;
334
+} else {
335
+	print '9';
336
+}
337
+?>" />
267 338
 			</p>
268 339
 			<p>
269 340
 				<label for="squawk_country">Country for squawk usage</label>
270 341
 				<select name="squawk_country" id="squawk_country">
271
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
272
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
273
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
274
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
275
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
276
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
277
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
342
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
343
+	print ' selected ';
344
+}
345
+?>>UK</option>
346
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
347
+	print ' selected ';
348
+}
349
+?>>NZ</option>
350
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
351
+	print ' selected ';
352
+}
353
+?>>US</option>
354
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
355
+	print ' selected ';
356
+}
357
+?>>AU</option>
358
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
359
+	print ' selected ';
360
+}
361
+?>>NL</option>
362
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
363
+	print ' selected ';
364
+}
365
+?>>FR</option>
366
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
367
+	print ' selected ';
368
+}
369
+?>>TR</option>
278 370
 				</select>
279 371
 			</p>
280 372
 		</fieldset>
@@ -283,15 +375,24 @@  discard block
 block discarded – undo
283 375
 			<p><i>Only put in DB flights that are inside a circle</i></p>
284 376
 			<p>
285 377
 				<label for="latitude">Center latitude</label>
286
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
378
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
379
+	echo $globalDistanceIgnore['latitude'];
380
+}
381
+?>" />
287 382
 			</p>
288 383
 			<p>
289 384
 				<label for="longitude">Center longitude</label>
290
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
385
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
386
+	echo $globalDistanceIgnore['longitude'];
387
+}
388
+?>" />
291 389
 			</p>
292 390
 			<p>
293 391
 				<label for="Distance">Distance (in km)</label>
294
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
392
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
393
+	echo $globalDistanceIgnore['distance'];
394
+}
395
+?>" />
295 396
 			</p>
296 397
 		</fieldset>
297 398
 		<fieldset id="sourceloc">
@@ -397,11 +498,17 @@  discard block
 block discarded – undo
397 498
 			<div id="flightaware_data">
398 499
 				<p>
399 500
 					<label for="flightawareusername">FlightAware username</label>
400
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
501
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
502
+	print $globalFlightAwareUsername;
503
+}
504
+?>" />
401 505
 				</p>
402 506
 				<p>
403 507
 					<label for="flightawarepassword">FlightAware password/API key</label>
404
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
508
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
509
+	print $globalFlightAwarePassword;
510
+}
511
+?>" />
405 512
 				</p>
406 513
 			</div>
407 514
 -->
@@ -460,26 +567,80 @@  discard block
 block discarded – undo
460 567
 								?>
461 568
 								<td>
462 569
 									<select name="format[]" id="format">
463
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
464
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
465
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
466
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
467
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
468
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
469
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
470
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server</option>
471
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
472
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
473
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
474
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
475
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
476
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
477
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
478
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
570
+										<option value="auto" <?php if (!isset($source['format'])) {
571
+	print 'selected';
572
+}
573
+?>>Auto</option>
574
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
575
+	print 'selected';
576
+}
577
+?>>SBS</option>
578
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
579
+	print 'selected';
580
+}
581
+?>>TSV</option>
582
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
583
+	print 'selected';
584
+}
585
+?>>Raw</option>
586
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
587
+	print 'selected';
588
+}
589
+?>>APRS</option>
590
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
591
+	print 'selected';
592
+}
593
+?>>Radarcape deltadb.txt</option>
594
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
595
+	print 'selected';
596
+}
597
+?>>Vatsim</option>
598
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
599
+	print 'selected';
600
+}
601
+?>>Virtual Radar Server</option>
602
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
603
+	print 'selected';
604
+}
605
+?>>phpVMS</option>
606
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
607
+	print 'selected';
608
+}
609
+?>>Virtual Airlines Manager</option>
610
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
611
+	print 'selected';
612
+}
613
+?>>IVAO</option>
614
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
615
+	print 'selected';
616
+}
617
+?>>FlightGear Multiplayer</option>
618
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
619
+	print 'selected';
620
+}
621
+?>>FlightGear Singleplayer</option>
622
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
623
+	print 'selected';
624
+}
625
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
626
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
627
+	print 'selected';
628
+}
629
+?>>ACARS SBS-3 over TCP</option>
630
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
631
+	print 'selected';
632
+}
633
+?>>NMEA AIS over TCP</option>
479 634
 									</select>
480 635
 								</td>
481
-								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td>
482
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
636
+								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
637
+	print $source['name'];
638
+}
639
+?>" /></td>
640
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
641
+	print 'checked';
642
+}
643
+?> /></td>
483 644
 								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
484 645
 							</tr>
485 646
 <?php
@@ -526,11 +687,17 @@  discard block
 block discarded – undo
526 687
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
527 688
 					<p>
528 689
 						<label for="acarshost">ACARS UDP host</label>
529
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
690
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
691
+	print $globalACARSHost;
692
+}
693
+?>" />
530 694
 					</p>
531 695
 					<p>
532 696
 						<label for="acarsport">ACARS UDP port</label>
533
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
697
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
698
+	print $globalACARSPort;
699
+}
700
+?>" />
534 701
 					</p>
535 702
 				</fieldset>
536 703
 			</div>
@@ -610,13 +777,19 @@  discard block
 block discarded – undo
610 777
 			<div id="schedules_options">
611 778
 				<p>
612 779
 					<label for="britishairways">British Airways API Key</label>
613
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
780
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
781
+	print $globalBritishAirwaysKey;
782
+}
783
+?>" />
614 784
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
615 785
 				</p>
616 786
 				<!--
617 787
 				<p>
618 788
 					<label for="transavia">Transavia Test API Consumer Key</label>
619
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
789
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
790
+	print $globalTransaviaKey;
791
+}
792
+?>" />
620 793
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
621 794
 				</p>
622 795
 				-->
@@ -625,10 +798,16 @@  discard block
 block discarded – undo
625 798
 						<b>Lufthansa API Key</b>
626 799
 						<p>
627 800
 							<label for="lufthansakey">Key</label>
628
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
801
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
802
+	print $globalLufthansaKey['key'];
803
+}
804
+?>" />
629 805
 						</p><p>
630 806
 							<label for="lufthansasecret">Secret</label>
631
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
807
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
808
+	print $globalLufthansaKey['secret'];
809
+}
810
+?>" />
632 811
 						</p>
633 812
 					</div>
634 813
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -648,7 +827,10 @@  discard block
 block discarded – undo
648 827
 			</p>
649 828
 			<p>
650 829
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
651
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
830
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
831
+	print $globalNOTAMSource;
832
+}
833
+?>" />
652 834
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
653 835
 			</p>
654 836
 			<br />
@@ -664,14 +846,20 @@  discard block
 block discarded – undo
664 846
 			<div id="metarsrc">
665 847
 				<p>
666 848
 					<label for="metarsource">URL of your METAR source</label>
667
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
849
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
850
+	print $globalMETARurl;
851
+}
852
+?>" />
668 853
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
669 854
 				</p>
670 855
 			</div>
671 856
 			<br />
672 857
 			<p>
673 858
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
674
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
859
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
860
+	print $globalBitlyAccessToken;
861
+}
862
+?>" />
675 863
 			</p>
676 864
 			<br />
677 865
 			<p>
@@ -691,7 +879,12 @@  discard block
 block discarded – undo
691 879
 			</p>
692 880
 			<p>
693 881
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
694
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
882
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
883
+	print $globalArchiveMonths;
884
+} else {
885
+	echo '0';
886
+}
887
+?>" />
695 888
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
696 889
 			</p>
697 890
 			<p>
@@ -701,12 +894,22 @@  discard block
 block discarded – undo
701 894
 			</p>
702 895
 			<p>
703 896
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
704
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
897
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
898
+	print $globalArchiveKeepMonths;
899
+} else {
900
+	echo '0';
901
+}
902
+?>" />
705 903
 				<p class="help-block">0 to disable</p>
706 904
 			</p>
707 905
 			<p>
708 906
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
709
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
907
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
908
+	print $globalArchiveKeepTrackMonths;
909
+} else {
910
+	echo '0';
911
+}
912
+?>" />
710 913
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
711 914
 			</p>
712 915
 			<br />
@@ -716,7 +919,12 @@  discard block
 block discarded – undo
716 919
 				<p class="help-block">Uncheck if the script is running as cron job</p>
717 920
 				<div id="cronends"> 
718 921
 					<label for="cronend">Run script for xx seconds</label>
719
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
922
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
923
+	print $globalCronEnd;
924
+} else {
925
+	print '0';
926
+}
927
+?>" />
720 928
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
721 929
 				</div>
722 930
 			</p>
@@ -761,26 +969,49 @@  discard block
 block discarded – undo
761 969
 			<br />
762 970
 			<p>
763 971
 				<label for="refresh">Show flights detected since xxx seconds</label>
764
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
972
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
973
+	echo $globalLiveInterval;
974
+} else {
975
+	echo '200';
976
+}
977
+?>" />
765 978
 			</p>
766 979
 			<p>
767 980
 				<label for="maprefresh">Live map refresh (in seconds)</label>
768
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
981
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
982
+	echo $globalMapRefresh;
983
+} else {
984
+	echo '30';
985
+}
986
+?>" />
769 987
 			</p>
770 988
 			<p>
771 989
 				<label for="mapidle">Map idle timeout (in minutes)</label>
772
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
990
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
991
+	echo $globalMapIdleTimeout;
992
+} else {
993
+	echo '30';
994
+}
995
+?>" />
773 996
 				<p class="help-block">0 to disable</p>
774 997
 			</p>
775 998
 			<br />
776 999
 			<p>
777 1000
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
778
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1001
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1002
+	echo $globalClosestMinDist;
1003
+} else {
1004
+	echo '50';
1005
+}
1006
+?>" />
779 1007
 			</p>
780 1008
 			<br />
781 1009
 			<p>
782 1010
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
783
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1011
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1012
+	echo $globalAircraftSize;
1013
+}
1014
+?>" />
784 1015
 			</p>
785 1016
 			<br />
786 1017
 			<p>
@@ -788,7 +1019,12 @@  discard block
 block discarded – undo
788 1019
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
789 1020
 			?>
790 1021
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
791
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1022
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1023
+	echo $globalAircraftIconColor;
1024
+} else {
1025
+	echo '1a3151';
1026
+}
1027
+?>" />
792 1028
 			<?php
793 1029
 				if (!is_writable('../cache')) {
794 1030
 			?>
@@ -806,8 +1042,18 @@  discard block
 block discarded – undo
806 1042
 			<p>
807 1043
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
808 1044
 				<div class="range">
809
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
810
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1045
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1046
+	echo $globalAirportZoom;
1047
+} else {
1048
+	echo '7';
1049
+}
1050
+?>" />
1051
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1052
+	echo $globalAirportZoom;
1053
+} else {
1054
+	echo '7';
1055
+}
1056
+?></output>
811 1057
 				</div>
812 1058
 			</p>
813 1059
 		</fieldset>
@@ -835,8 +1081,12 @@  discard block
 block discarded – undo
835 1081
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
836 1082
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
837 1083
 
838
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
839
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1084
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1085
+		$error .= 'Mysql driver for PDO must be loaded';
1086
+	}
1087
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1088
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1089
+	}
840 1090
 	
841 1091
 	$_SESSION['database_root'] = $dbroot;
842 1092
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -903,15 +1153,23 @@  discard block
 block discarded – undo
903 1153
 	$source_city = $_POST['source_city'];
904 1154
 	$source_country = $_POST['source_country'];
905 1155
 	$source_ref = $_POST['source_ref'];
906
-	if (isset($source_id)) $source_id = $_POST['source_id'];
907
-	else $source_id = array();
1156
+	if (isset($source_id)) {
1157
+		$source_id = $_POST['source_id'];
1158
+	} else {
1159
+		$source_id = array();
1160
+	}
908 1161
 	
909 1162
 	$sources = array();
910 1163
 	foreach ($source_name as $keys => $name) {
911
-	    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]);
912
-	    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]);
1164
+	    if (isset($source_id[$keys])) {
1165
+	    	$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]);
1166
+	    } else {
1167
+	    	$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]);
1168
+	    }
1169
+	}
1170
+	if (count($sources) > 0) {
1171
+		$_SESSION['sources'] = $sources;
913 1172
 	}
914
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
915 1173
 
916 1174
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
917 1175
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -931,14 +1189,23 @@  discard block
 block discarded – undo
931 1189
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
932 1190
 
933 1191
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
934
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
935
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1192
+	if ($globalaircraft == 'aircraft') {
1193
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1194
+	} else {
1195
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1196
+	}
936 1197
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
937
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
938
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1198
+	if ($globaltracker == 'tracker') {
1199
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1200
+	} else {
1201
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1202
+	}
939 1203
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
940
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
941
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1204
+	if ($globalmarine == 'marine') {
1205
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1206
+	} else {
1207
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1208
+	}
942 1209
 
943 1210
 /*	
944 1211
 	$globalSBS1Hosts = array();
@@ -959,13 +1226,21 @@  discard block
 block discarded – undo
959 1226
 	$port = $_POST['port'];
960 1227
 	$name = $_POST['name'];
961 1228
 	$format = $_POST['format'];
962
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
963
-	else $sourcestats = array();
1229
+	if (isset($_POST['sourcestats'])) {
1230
+		$sourcestats = $_POST['sourcestats'];
1231
+	} else {
1232
+		$sourcestats = array();
1233
+	}
964 1234
 	$gSources = array();
965 1235
 	foreach ($host as $key => $h) {
966
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
967
-		else $cov = 'FALSE';
968
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1236
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1237
+			$cov = 'TRUE';
1238
+		} else {
1239
+			$cov = 'FALSE';
1240
+		}
1241
+		if ($h != '') {
1242
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1243
+		}
969 1244
 	}
970 1245
 	$settings = array_merge($settings,array('globalSources' => $gSources));
971 1246
 
@@ -990,7 +1265,9 @@  discard block
 block discarded – undo
990 1265
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
991 1266
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
992 1267
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
993
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1268
+	} else {
1269
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1270
+	}
994 1271
 
995 1272
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
996 1273
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1029,7 +1306,9 @@  discard block
 block discarded – undo
1029 1306
 
1030 1307
 	// Create in settings.php keys not yet configurable if not already here
1031 1308
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1032
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1309
+	if (!isset($globalDebug)) {
1310
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1311
+	}
1033 1312
 
1034 1313
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1035 1314
 	if ($resetyearstats == 'resetyearstats') {
@@ -1066,27 +1345,43 @@  discard block
 block discarded – undo
1066 1345
 	}
1067 1346
 */
1068 1347
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1069
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1070
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1071
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1072
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1348
+	if ($globalsbs == 'sbs') {
1349
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1350
+	} else {
1351
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1352
+	}
1353
+	if ($globalaprs == 'aprs') {
1354
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1355
+	} else {
1356
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1357
+	}
1073 1358
 	if ($globalivao == 'ivao') {
1074 1359
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1075 1360
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1076
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1361
+	} else {
1362
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1363
+	}
1077 1364
 	if ($globalvatsim == 'vatsim') {
1078 1365
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1079 1366
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1080
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1367
+	} else {
1368
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1369
+	}
1081 1370
 	if ($globalphpvms == 'phpvms') {
1082 1371
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1083
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1372
+	} else {
1373
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1374
+	}
1084 1375
 	if ($globalvam == 'vam') {
1085 1376
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1086
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1377
+	} else {
1378
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1379
+	}
1087 1380
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1088 1381
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1089
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1382
+	} else {
1383
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1384
+	}
1090 1385
 	
1091 1386
 
1092 1387
 
@@ -1222,7 +1517,9 @@  discard block
 block discarded – undo
1222 1517
 		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1223 1518
 	}
1224 1519
 
1225
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1520
+	if (!isset($globalTransaction)) {
1521
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1522
+	}
1226 1523
 
1227 1524
 	// Set some defaults values...
1228 1525
 	if (!isset($globalAircraftImageSources)) {
@@ -1237,15 +1534,23 @@  discard block
 block discarded – undo
1237 1534
 
1238 1535
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1239 1536
 
1240
-	if ($error == '') settings::modify_settings($settings);
1241
-	if ($error == '') settings::comment_settings($settings_comment);
1537
+	if ($error == '') {
1538
+		settings::modify_settings($settings);
1539
+	}
1540
+	if ($error == '') {
1541
+		settings::comment_settings($settings_comment);
1542
+	}
1242 1543
 	if ($error != '') {
1243 1544
 		print '<div class="info column">'.$error.'</div>';
1244 1545
 		require('../footer.php');
1245 1546
 		exit;
1246 1547
 	} else {
1247
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1248
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1548
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1549
+			$_SESSION['waypoints'] = 1;
1550
+		}
1551
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1552
+			$_SESSION['owner'] = 1;
1553
+		}
1249 1554
 		if (isset($_POST['createdb'])) {
1250 1555
 			$_SESSION['install'] = 'database_create';
1251 1556
 		} else {
@@ -1286,10 +1591,18 @@  discard block
 block discarded – undo
1286 1591
 	$popw = false;
1287 1592
 	foreach ($_SESSION['done'] as $done) {
1288 1593
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1289
-	    if ($done == 'Create database') $pop = true;
1290
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1291
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1292
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1594
+	    if ($done == 'Create database') {
1595
+	    	$pop = true;
1596
+	    }
1597
+	    if ($_SESSION['install'] == 'database_create') {
1598
+	    	$pop = true;
1599
+	    }
1600
+	    if ($_SESSION['install'] == 'database_import') {
1601
+	    	$popi = true;
1602
+	    }
1603
+	    if ($_SESSION['install'] == 'waypoints') {
1604
+	    	$popw = true;
1605
+	    }
1293 1606
 	}
1294 1607
 	if ($pop) {
1295 1608
 	    sleep(5);
@@ -1300,7 +1613,9 @@  discard block
 block discarded – undo
1300 1613
 	} else if ($popw) {
1301 1614
 	    sleep(5);
1302 1615
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1303
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1616
+	} else {
1617
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1618
+	}
1304 1619
 	print '</div></ul>';
1305 1620
 	print '<div id="error"></div>';
1306 1621
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +323 added lines, -120 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1605,30 +1671,54 @@  discard block
 block discarded – undo
1605 1671
 		}
1606 1672
 		if ($globalDBdriver == 'mysql') {
1607 1673
 			$error .= create_db::import_file('../db/tracker_output.sql');
1608
-			if ($error != '') return $error;
1674
+			if ($error != '') {
1675
+				return $error;
1676
+			}
1609 1677
 			$error .= create_db::import_file('../db/tracker_live.sql');
1610
-			if ($error != '') return $error;
1678
+			if ($error != '') {
1679
+				return $error;
1680
+			}
1611 1681
 			$error .= create_db::import_file('../db/marine_output.sql');
1612
-			if ($error != '') return $error;
1682
+			if ($error != '') {
1683
+				return $error;
1684
+			}
1613 1685
 			$error .= create_db::import_file('../db/marine_live.sql');
1614
-			if ($error != '') return $error;
1686
+			if ($error != '') {
1687
+				return $error;
1688
+			}
1615 1689
 			$error .= create_db::import_file('../db/marine_identity.sql');
1616
-			if ($error != '') return $error;
1690
+			if ($error != '') {
1691
+				return $error;
1692
+			}
1617 1693
 			$error .= create_db::import_file('../db/marine_mid.sql');
1618
-			if ($error != '') return $error;
1694
+			if ($error != '') {
1695
+				return $error;
1696
+			}
1619 1697
 		} else {
1620 1698
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1621
-			if ($error != '') return $error;
1699
+			if ($error != '') {
1700
+				return $error;
1701
+			}
1622 1702
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1623
-			if ($error != '') return $error;
1703
+			if ($error != '') {
1704
+				return $error;
1705
+			}
1624 1706
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1625
-			if ($error != '') return $error;
1707
+			if ($error != '') {
1708
+				return $error;
1709
+			}
1626 1710
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1627
-			if ($error != '') return $error;
1711
+			if ($error != '') {
1712
+				return $error;
1713
+			}
1628 1714
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1629
-			if ($error != '') return $error;
1715
+			if ($error != '') {
1716
+				return $error;
1717
+			}
1630 1718
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1631
-			if ($error != '') return $error;
1719
+			if ($error != '') {
1720
+				return $error;
1721
+			}
1632 1722
 		}
1633 1723
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1634 1724
 		try {
@@ -1648,8 +1738,11 @@  discard block
 block discarded – undo
1648 1738
     	    if ($Connection->tableExists('aircraft')) {
1649 1739
     		if (!$Connection->tableExists('config')) {
1650 1740
     		    $version = '1';
1651
-    		    if ($update) return self::update_from_1();
1652
-    		    else return $version;
1741
+    		    if ($update) {
1742
+    		    	return self::update_from_1();
1743
+    		    } else {
1744
+    		    	return $version;
1745
+    		    }
1653 1746
 		} else {
1654 1747
     		    $Connection = new Connection();
1655 1748
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1663,150 +1756,260 @@  discard block
 block discarded – undo
1663 1756
     		    if ($update) {
1664 1757
     			if ($result['value'] == '2') {
1665 1758
     			    $error = self::update_from_2();
1666
-    			    if ($error != '') return $error;
1667
-    			    else return self::check_version(true);
1759
+    			    if ($error != '') {
1760
+    			    	return $error;
1761
+    			    } else {
1762
+    			    	return self::check_version(true);
1763
+    			    }
1668 1764
     			} elseif ($result['value'] == '3') {
1669 1765
     			    $error = self::update_from_3();
1670
-    			    if ($error != '') return $error;
1671
-    			    else return self::check_version(true);
1766
+    			    if ($error != '') {
1767
+    			    	return $error;
1768
+    			    } else {
1769
+    			    	return self::check_version(true);
1770
+    			    }
1672 1771
     			} elseif ($result['value'] == '4') {
1673 1772
     			    $error = self::update_from_4();
1674
-    			    if ($error != '') return $error;
1675
-    			    else return self::check_version(true);
1773
+    			    if ($error != '') {
1774
+    			    	return $error;
1775
+    			    } else {
1776
+    			    	return self::check_version(true);
1777
+    			    }
1676 1778
     			} elseif ($result['value'] == '5') {
1677 1779
     			    $error = self::update_from_5();
1678
-    			    if ($error != '') return $error;
1679
-    			    else return self::check_version(true);
1780
+    			    if ($error != '') {
1781
+    			    	return $error;
1782
+    			    } else {
1783
+    			    	return self::check_version(true);
1784
+    			    }
1680 1785
     			} elseif ($result['value'] == '6') {
1681 1786
     			    $error = self::update_from_6();
1682
-    			    if ($error != '') return $error;
1683
-    			    else return self::check_version(true);
1787
+    			    if ($error != '') {
1788
+    			    	return $error;
1789
+    			    } else {
1790
+    			    	return self::check_version(true);
1791
+    			    }
1684 1792
     			} elseif ($result['value'] == '7') {
1685 1793
     			    $error = self::update_from_7();
1686
-    			    if ($error != '') return $error;
1687
-    			    else return self::check_version(true);
1794
+    			    if ($error != '') {
1795
+    			    	return $error;
1796
+    			    } else {
1797
+    			    	return self::check_version(true);
1798
+    			    }
1688 1799
     			} elseif ($result['value'] == '8') {
1689 1800
     			    $error = self::update_from_8();
1690
-    			    if ($error != '') return $error;
1691
-    			    else return self::check_version(true);
1801
+    			    if ($error != '') {
1802
+    			    	return $error;
1803
+    			    } else {
1804
+    			    	return self::check_version(true);
1805
+    			    }
1692 1806
     			} elseif ($result['value'] == '9') {
1693 1807
     			    $error = self::update_from_9();
1694
-    			    if ($error != '') return $error;
1695
-    			    else return self::check_version(true);
1808
+    			    if ($error != '') {
1809
+    			    	return $error;
1810
+    			    } else {
1811
+    			    	return self::check_version(true);
1812
+    			    }
1696 1813
     			} elseif ($result['value'] == '10') {
1697 1814
     			    $error = self::update_from_10();
1698
-    			    if ($error != '') return $error;
1699
-    			    else return self::check_version(true);
1815
+    			    if ($error != '') {
1816
+    			    	return $error;
1817
+    			    } else {
1818
+    			    	return self::check_version(true);
1819
+    			    }
1700 1820
     			} elseif ($result['value'] == '11') {
1701 1821
     			    $error = self::update_from_11();
1702
-    			    if ($error != '') return $error;
1703
-    			    else return self::check_version(true);
1822
+    			    if ($error != '') {
1823
+    			    	return $error;
1824
+    			    } else {
1825
+    			    	return self::check_version(true);
1826
+    			    }
1704 1827
     			} elseif ($result['value'] == '12') {
1705 1828
     			    $error = self::update_from_12();
1706
-    			    if ($error != '') return $error;
1707
-    			    else return self::check_version(true);
1829
+    			    if ($error != '') {
1830
+    			    	return $error;
1831
+    			    } else {
1832
+    			    	return self::check_version(true);
1833
+    			    }
1708 1834
     			} elseif ($result['value'] == '13') {
1709 1835
     			    $error = self::update_from_13();
1710
-    			    if ($error != '') return $error;
1711
-    			    else return self::check_version(true);
1836
+    			    if ($error != '') {
1837
+    			    	return $error;
1838
+    			    } else {
1839
+    			    	return self::check_version(true);
1840
+    			    }
1712 1841
     			} elseif ($result['value'] == '14') {
1713 1842
     			    $error = self::update_from_14();
1714
-    			    if ($error != '') return $error;
1715
-    			    else return self::check_version(true);
1843
+    			    if ($error != '') {
1844
+    			    	return $error;
1845
+    			    } else {
1846
+    			    	return self::check_version(true);
1847
+    			    }
1716 1848
     			} elseif ($result['value'] == '15') {
1717 1849
     			    $error = self::update_from_15();
1718
-    			    if ($error != '') return $error;
1719
-    			    else return self::check_version(true);
1850
+    			    if ($error != '') {
1851
+    			    	return $error;
1852
+    			    } else {
1853
+    			    	return self::check_version(true);
1854
+    			    }
1720 1855
     			} elseif ($result['value'] == '16') {
1721 1856
     			    $error = self::update_from_16();
1722
-    			    if ($error != '') return $error;
1723
-    			    else return self::check_version(true);
1857
+    			    if ($error != '') {
1858
+    			    	return $error;
1859
+    			    } else {
1860
+    			    	return self::check_version(true);
1861
+    			    }
1724 1862
     			} elseif ($result['value'] == '17') {
1725 1863
     			    $error = self::update_from_17();
1726
-    			    if ($error != '') return $error;
1727
-    			    else return self::check_version(true);
1864
+    			    if ($error != '') {
1865
+    			    	return $error;
1866
+    			    } else {
1867
+    			    	return self::check_version(true);
1868
+    			    }
1728 1869
     			} elseif ($result['value'] == '18') {
1729 1870
     			    $error = self::update_from_18();
1730
-    			    if ($error != '') return $error;
1731
-    			    else return self::check_version(true);
1871
+    			    if ($error != '') {
1872
+    			    	return $error;
1873
+    			    } else {
1874
+    			    	return self::check_version(true);
1875
+    			    }
1732 1876
     			} elseif ($result['value'] == '19') {
1733 1877
     			    $error = self::update_from_19();
1734
-    			    if ($error != '') return $error;
1735
-    			    else return self::check_version(true);
1878
+    			    if ($error != '') {
1879
+    			    	return $error;
1880
+    			    } else {
1881
+    			    	return self::check_version(true);
1882
+    			    }
1736 1883
     			} elseif ($result['value'] == '20') {
1737 1884
     			    $error = self::update_from_20();
1738
-    			    if ($error != '') return $error;
1739
-    			    else return self::check_version(true);
1885
+    			    if ($error != '') {
1886
+    			    	return $error;
1887
+    			    } else {
1888
+    			    	return self::check_version(true);
1889
+    			    }
1740 1890
     			} elseif ($result['value'] == '21') {
1741 1891
     			    $error = self::update_from_21();
1742
-    			    if ($error != '') return $error;
1743
-    			    else return self::check_version(true);
1892
+    			    if ($error != '') {
1893
+    			    	return $error;
1894
+    			    } else {
1895
+    			    	return self::check_version(true);
1896
+    			    }
1744 1897
     			} elseif ($result['value'] == '22') {
1745 1898
     			    $error = self::update_from_22();
1746
-    			    if ($error != '') return $error;
1747
-    			    else return self::check_version(true);
1899
+    			    if ($error != '') {
1900
+    			    	return $error;
1901
+    			    } else {
1902
+    			    	return self::check_version(true);
1903
+    			    }
1748 1904
     			} elseif ($result['value'] == '23') {
1749 1905
     			    $error = self::update_from_23();
1750
-    			    if ($error != '') return $error;
1751
-    			    else return self::check_version(true);
1906
+    			    if ($error != '') {
1907
+    			    	return $error;
1908
+    			    } else {
1909
+    			    	return self::check_version(true);
1910
+    			    }
1752 1911
     			} elseif ($result['value'] == '24') {
1753 1912
     			    $error = self::update_from_24();
1754
-    			    if ($error != '') return $error;
1755
-    			    else return self::check_version(true);
1913
+    			    if ($error != '') {
1914
+    			    	return $error;
1915
+    			    } else {
1916
+    			    	return self::check_version(true);
1917
+    			    }
1756 1918
     			} elseif ($result['value'] == '25') {
1757 1919
     			    $error = self::update_from_25();
1758
-    			    if ($error != '') return $error;
1759
-    			    else return self::check_version(true);
1920
+    			    if ($error != '') {
1921
+    			    	return $error;
1922
+    			    } else {
1923
+    			    	return self::check_version(true);
1924
+    			    }
1760 1925
     			} elseif ($result['value'] == '26') {
1761 1926
     			    $error = self::update_from_26();
1762
-    			    if ($error != '') return $error;
1763
-    			    else return self::check_version(true);
1927
+    			    if ($error != '') {
1928
+    			    	return $error;
1929
+    			    } else {
1930
+    			    	return self::check_version(true);
1931
+    			    }
1764 1932
     			} elseif ($result['value'] == '27') {
1765 1933
     			    $error = self::update_from_27();
1766
-    			    if ($error != '') return $error;
1767
-    			    else return self::check_version(true);
1934
+    			    if ($error != '') {
1935
+    			    	return $error;
1936
+    			    } else {
1937
+    			    	return self::check_version(true);
1938
+    			    }
1768 1939
     			} elseif ($result['value'] == '28') {
1769 1940
     			    $error = self::update_from_28();
1770
-    			    if ($error != '') return $error;
1771
-    			    else return self::check_version(true);
1941
+    			    if ($error != '') {
1942
+    			    	return $error;
1943
+    			    } else {
1944
+    			    	return self::check_version(true);
1945
+    			    }
1772 1946
     			} elseif ($result['value'] == '29') {
1773 1947
     			    $error = self::update_from_29();
1774
-    			    if ($error != '') return $error;
1775
-    			    else return self::check_version(true);
1948
+    			    if ($error != '') {
1949
+    			    	return $error;
1950
+    			    } else {
1951
+    			    	return self::check_version(true);
1952
+    			    }
1776 1953
     			} elseif ($result['value'] == '30') {
1777 1954
     			    $error = self::update_from_30();
1778
-    			    if ($error != '') return $error;
1779
-    			    else return self::check_version(true);
1955
+    			    if ($error != '') {
1956
+    			    	return $error;
1957
+    			    } else {
1958
+    			    	return self::check_version(true);
1959
+    			    }
1780 1960
     			} elseif ($result['value'] == '31') {
1781 1961
     			    $error = self::update_from_31();
1782
-    			    if ($error != '') return $error;
1783
-    			    else return self::check_version(true);
1962
+    			    if ($error != '') {
1963
+    			    	return $error;
1964
+    			    } else {
1965
+    			    	return self::check_version(true);
1966
+    			    }
1784 1967
     			} elseif ($result['value'] == '32') {
1785 1968
     			    $error = self::update_from_32();
1786
-    			    if ($error != '') return $error;
1787
-    			    else return self::check_version(true);
1969
+    			    if ($error != '') {
1970
+    			    	return $error;
1971
+    			    } else {
1972
+    			    	return self::check_version(true);
1973
+    			    }
1788 1974
     			} elseif ($result['value'] == '33') {
1789 1975
     			    $error = self::update_from_33();
1790
-    			    if ($error != '') return $error;
1791
-    			    else return self::check_version(true);
1976
+    			    if ($error != '') {
1977
+    			    	return $error;
1978
+    			    } else {
1979
+    			    	return self::check_version(true);
1980
+    			    }
1792 1981
     			} elseif ($result['value'] == '34') {
1793 1982
     			    $error = self::update_from_34();
1794
-    			    if ($error != '') return $error;
1795
-    			    else return self::check_version(true);
1983
+    			    if ($error != '') {
1984
+    			    	return $error;
1985
+    			    } else {
1986
+    			    	return self::check_version(true);
1987
+    			    }
1796 1988
     			} elseif ($result['value'] == '35') {
1797 1989
     			    $error = self::update_from_35();
1798
-    			    if ($error != '') return $error;
1799
-    			    else return self::check_version(true);
1990
+    			    if ($error != '') {
1991
+    			    	return $error;
1992
+    			    } else {
1993
+    			    	return self::check_version(true);
1994
+    			    }
1800 1995
     			} elseif ($result['value'] == '36') {
1801 1996
     			    $error = self::update_from_36();
1802
-    			    if ($error != '') return $error;
1803
-    			    else return self::check_version(true);
1804
-    			} else return '';
1997
+    			    if ($error != '') {
1998
+    			    	return $error;
1999
+    			    } else {
2000
+    			    	return self::check_version(true);
2001
+    			    }
2002
+    			} else {
2003
+    				return '';
2004
+    			}
2005
+    		    } else {
2006
+    		    	return $result['value'];
1805 2007
     		    }
1806
-    		    else return $result['value'];
1807 2008
 		}
1808 2009
 		
1809
-	    } else return $version;
2010
+	    } else {
2011
+	    	return $version;
2012
+	    }
1810 2013
     	}
1811 2014
     	
1812 2015
 }
Please login to merge, or discard this patch.
marine-data.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@
 block discarded – undo
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65 65
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
66
-	} else $image = $spotter_item['image_thumbnail'];
66
+	} else {
67
+		$image = $spotter_item['image_thumbnail'];
68
+	}
67 69
 
68 70
 }
69 71
 /* else {
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Braces   +98 added lines, -39 removed lines patch added patch discarded remove patch
@@ -102,26 +102,36 @@  discard block
 block discarded – undo
102 102
 	
103 103
 	/* Check that end was found and body has at least one byte. */
104 104
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
105
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
105
+	    if ($globalDebug) {
106
+	    	echo '!!! APRS invalid : '.$input."\n";
107
+	    }
106 108
 	    return false;
107 109
 	}
108 110
 	
109
-	if ($debug) echo 'input : '.$input."\n";
111
+	if ($debug) {
112
+		echo 'input : '.$input."\n";
113
+	}
110 114
 	/* Save header and body. */
111 115
 	$body = substr($input,$splitpos+1,$input_len);
112 116
 	$body_len = strlen($body);
113 117
 	$header = substr($input,0,$splitpos);
114 118
 	//$header_len = strlen($header);
115
-	if ($debug) echo 'header : '.$header."\n";
119
+	if ($debug) {
120
+		echo 'header : '.$header."\n";
121
+	}
116 122
 	
117 123
 	/* Parse source, target and path. */
118 124
 	//FLRDF0A52>APRS,qAS,LSTB
119 125
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
120 126
 	    $ident = $matches[1];
121 127
 	    $all_elements = $matches[2];
122
-	    if ($debug) echo 'ident : '.$ident."\n";
128
+	    if ($debug) {
129
+	    	echo 'ident : '.$ident."\n";
130
+	    }
123 131
 	    $result['ident'] = $ident;
124
-	} else return false;
132
+	} else {
133
+		return false;
134
+	}
125 135
 	$elements = explode(',',$all_elements);
126 136
 	$source = end($elements);
127 137
 	$result['source'] = $source;
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
 	        //echo "ok";
131 141
 	        //if ($element == 'TCPIP*') return false;
132 142
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
133
-		if ($debug) echo 'element : '.$element."\n";
143
+		if ($debug) {
144
+			echo 'element : '.$element."\n";
145
+		}
134 146
 		return false;
135 147
 	    }
136 148
 	    /*
@@ -143,7 +155,9 @@  discard block
 block discarded – undo
143 155
 	}
144 156
 	
145 157
 	$type = substr($body,0,1);
146
-	if ($debug) echo 'type : '.$type."\n";
158
+	if ($debug) {
159
+		echo 'type : '.$type."\n";
160
+	}
147 161
 	if ($type == ';') {
148 162
 		$result['ident'] = trim(substr($body,1,9));
149 163
 	} elseif ($type == ',') {
@@ -213,7 +227,9 @@  discard block
 block discarded – undo
213 227
 		//$symbol_table = $matches[4];
214 228
 		$lat = intval($lat_deg);
215 229
 		$lon = intval($lon_deg);
216
-		if ($lat > 89 || $lon > 179) return false;
230
+		if ($lat > 89 || $lon > 179) {
231
+			return false;
232
+		}
217 233
 	    
218 234
 	    /*
219 235
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -223,8 +239,12 @@  discard block
 block discarded – undo
223 239
 	    */
224 240
 		$latitude = $lat + floatval($lat_min)/60;
225 241
 		$longitude = $lon + floatval($lon_min)/60;
226
-		if ($sind == 'S') $latitude = 0-$latitude;
227
-		if ($wind == 'W') $longitude = 0-$longitude;
242
+		if ($sind == 'S') {
243
+			$latitude = 0-$latitude;
244
+		}
245
+		if ($wind == 'W') {
246
+			$longitude = 0-$longitude;
247
+		}
228 248
 		$result['latitude'] = $latitude;
229 249
 		$result['longitude'] = $longitude;
230 250
 		$body_parse = substr($body_parse,18);
@@ -257,7 +277,9 @@  discard block
 block discarded – undo
257 277
 			$body_parse = substr($body_parse,1);
258 278
 			$body_parse_len = strlen($body_parse);
259 279
 			$result['symbol_code'] = $symbol_code;
260
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
280
+			if (isset($this->symbols[$symbol_code])) {
281
+				$result['symbol'] = $this->symbols[$symbol_code];
282
+			}
261 283
 			if ($symbol_code != '_') {
262 284
 			}
263 285
 		    //$body_parse = substr($body_parse,1);
@@ -268,7 +290,9 @@  discard block
 block discarded – undo
268 290
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
269 291
 		    	    $course = substr($body_parse,0,3);
270 292
 		    	    $tmp_s = intval($course);
271
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
293
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
294
+		    	    	$result['heading'] = intval($course);
295
+		    	    }
272 296
 		    	    $speed = substr($body_parse,4,3);
273 297
 		    	    if ($speed != '...') {
274 298
 		    		    $result['speed'] = round($speed*1.852);
@@ -306,10 +330,16 @@  discard block
 block discarded – undo
306 330
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
307 331
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
308 332
 			    
309
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
310
-				else $result['latitude'] += $lat_off;
311
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
312
-				else $result['longitude'] += $lon_off;
333
+				if ($result['latitude'] < 0) {
334
+					$result['latitude'] -= $lat_off;
335
+				} else {
336
+					$result['latitude'] += $lat_off;
337
+				}
338
+				if ($result['longitude'] < 0) {
339
+					$result['longitude'] -= $lon_off;
340
+				} else {
341
+					$result['longitude'] += $lon_off;
342
+				}
313 343
 			    }
314 344
 		            $body_parse = substr($body_parse,6);
315 345
 		    }
@@ -323,27 +353,48 @@  discard block
 block discarded – undo
323 353
 			$address = substr($id,2);
324 354
 			//print_r($matches);
325 355
 			$addressType = (intval(substr($id,0,2),16))&3;
326
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
327
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
328
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
329
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
356
+			if ($addressType == 0) {
357
+				$result['addresstype'] = "RANDOM";
358
+			} elseif ($addressType == 1) {
359
+				$result['addresstype'] = "ICAO";
360
+			} elseif ($addressType == 2) {
361
+				$result['addresstype'] = "FLARM";
362
+			} elseif ($addressType == 3) {
363
+				$result['addresstype'] = "OGN";
364
+			}
330 365
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
331 366
 			$result['aircrafttype_code'] = $aircraftType;
332
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
333
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
334
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
335
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
336
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
337
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
338
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
339
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
340
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
341
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
342
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
343
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
344
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
345
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
346
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
367
+			if ($aircraftType == 0) {
368
+				$result['aircrafttype'] = "UNKNOWN";
369
+			} elseif ($aircraftType == 1) {
370
+				$result['aircrafttype'] = "GLIDER";
371
+			} elseif ($aircraftType == 2) {
372
+				$result['aircrafttype'] = "TOW_PLANE";
373
+			} elseif ($aircraftType == 3) {
374
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
375
+			} elseif ($aircraftType == 4) {
376
+				$result['aircrafttype'] = "PARACHUTE";
377
+			} elseif ($aircraftType == 5) {
378
+				$result['aircrafttype'] = "DROP_PLANE";
379
+			} elseif ($aircraftType == 6) {
380
+				$result['aircrafttype'] = "HANG_GLIDER";
381
+			} elseif ($aircraftType == 7) {
382
+				$result['aircrafttype'] = "PARA_GLIDER";
383
+			} elseif ($aircraftType == 8) {
384
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
385
+			} elseif ($aircraftType == 9) {
386
+				$result['aircrafttype'] = "JET_AIRCRAFT";
387
+			} elseif ($aircraftType == 10) {
388
+				$result['aircrafttype'] = "UFO";
389
+			} elseif ($aircraftType == 11) {
390
+				$result['aircrafttype'] = "BALLOON";
391
+			} elseif ($aircraftType == 12) {
392
+				$result['aircrafttype'] = "AIRSHIP";
393
+			} elseif ($aircraftType == 13) {
394
+				$result['aircrafttype'] = "UAV";
395
+			} elseif ($aircraftType == 15) {
396
+				$result['aircrafttype'] = "STATIC_OBJECT";
397
+			}
347 398
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
348 399
 			$result['stealth'] = $stealth;
349 400
 			$result['address'] = $address;
@@ -383,13 +434,21 @@  discard block
 block discarded – undo
383 434
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
384 435
 		    }
385 436
 		}
386
-		} else $result['comment'] = trim($body_parse);
437
+		} else {
438
+			$result['comment'] = trim($body_parse);
439
+		}
387 440
 
388 441
 	    }
389 442
 	//}
390
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
391
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
392
-	if ($debug) print_r($result);
443
+	if (isset($result['latitude'])) {
444
+		$result['latitude'] = round($result['latitude'],4);
445
+	}
446
+	if (isset($result['longitude'])) {
447
+		$result['longitude'] = round($result['longitude'],4);
448
+	}
449
+	if ($debug) {
450
+		print_r($result);
451
+	}
393 452
 	return $result;
394 453
     }
395 454
 }
Please login to merge, or discard this patch.
require/class.Spotter.php 1 patch
Braces   +735 added lines, -257 removed lines patch added patch discarded remove patch
@@ -72,7 +72,9 @@  discard block
 block discarded – undo
72 72
 		if (isset($filter[0]['source'])) {
73 73
 			$filters = array_merge($filters,$filter);
74 74
 		}
75
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
75
+		if (is_array($globalFilter)) {
76
+			$filter = array_merge($filter,$globalFilter);
77
+		}
76 78
 		$filter_query_join = '';
77 79
 		$filter_query_where = '';
78 80
 		foreach($filters as $flt) {
@@ -156,8 +158,11 @@  discard block
 block discarded – undo
156 158
 				$filter_query_where .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
157 159
 			}
158 160
 		}
159
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
160
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
161
+		if ($filter_query_where == '' && $where) {
162
+			$filter_query_where = ' WHERE';
163
+		} elseif ($filter_query_where != '' && $and) {
164
+			$filter_query_where .= ' AND';
165
+		}
161 166
 		if ($filter_query_where != '') {
162 167
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
163 168
 		}
@@ -180,10 +185,18 @@  discard block
 block discarded – undo
180 185
 		$Image = new Image($this->db);
181 186
 		$Schedule = new Schedule($this->db);
182 187
 		$ACARS = new ACARS($this->db);
183
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
184
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
185
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
186
-		if (!isset($globalVAM)) $globalVAM = FALSE;
188
+		if (!isset($globalIVAO)) {
189
+			$globalIVAO = FALSE;
190
+		}
191
+		if (!isset($globalVATSIM)) {
192
+			$globalVATSIM = FALSE;
193
+		}
194
+		if (!isset($globalphpVMS)) {
195
+			$globalphpVMS = FALSE;
196
+		}
197
+		if (!isset($globalVAM)) {
198
+			$globalVAM = FALSE;
199
+		}
187 200
 		date_default_timezone_set('UTC');
188 201
 		
189 202
 		if (!is_string($query))
@@ -230,21 +243,35 @@  discard block
 block discarded – undo
230 243
 			} else {
231 244
 				$temp_array['spotter_id'] = '';
232 245
 			}
233
-			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id'];
234
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
246
+			if (isset($row['flightaware_id'])) {
247
+				$temp_array['flightaware_id'] = $row['flightaware_id'];
248
+			}
249
+			if (isset($row['modes'])) {
250
+				$temp_array['modes'] = $row['modes'];
251
+			}
235 252
 			$temp_array['ident'] = $row['ident'];
236 253
 			if (isset($row['registration']) && $row['registration'] != '') {
237 254
 				$temp_array['registration'] = $row['registration'];
238 255
 			} elseif (isset($temp_array['modes'])) {
239 256
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
240
-			} else $temp_array['registration'] = '';
241
-			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao'];
257
+			} else {
258
+				$temp_array['registration'] = '';
259
+			}
260
+			if (isset($row['aircraft_icao'])) {
261
+				$temp_array['aircraft_type'] = $row['aircraft_icao'];
262
+			}
242 263
 			
243 264
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
244 265
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
245
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
246
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
247
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
266
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
267
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
268
+			}
269
+			if (isset($row['latitude'])) {
270
+				$temp_array['latitude'] = $row['latitude'];
271
+			}
272
+			if (isset($row['longitude'])) {
273
+				$temp_array['longitude'] = $row['longitude'];
274
+			}
248 275
 			/*
249 276
 			if (Connection->tableExists('countries')) {
250 277
 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
@@ -254,8 +281,12 @@  discard block
 block discarded – undo
254 281
 				}
255 282
 			}
256 283
 			*/
257
-			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints'];
258
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
284
+			if (isset($row['waypoints'])) {
285
+				$temp_array['waypoints'] = $row['waypoints'];
286
+			}
287
+			if (isset($row['format_source'])) {
288
+				$temp_array['format_source'] = $row['format_source'];
289
+			}
259 290
 			if (isset($row['route_stop']) && $row['route_stop'] != '') {
260 291
 				$temp_array['route_stop'] = $row['route_stop'];
261 292
 				$allroute = explode(' ',$row['route_stop']);
@@ -271,13 +302,19 @@  discard block
 block discarded – undo
271 302
 					}
272 303
 				}
273 304
 			}
274
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
305
+			if (isset($row['altitude'])) {
306
+				$temp_array['altitude'] = $row['altitude'];
307
+			}
275 308
 			if (isset($row['heading'])) {
276 309
 				$temp_array['heading'] = $row['heading'];
277 310
 				$heading_direction = $this->parseDirection($row['heading']);
278
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
311
+				if (isset($heading_direction[0]['direction_fullname'])) {
312
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
313
+				}
314
+			}
315
+			if (isset($row['ground_speed'])) {
316
+				$temp_array['ground_speed'] = $row['ground_speed'];
279 317
 			}
280
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
281 318
 			$temp_array['image'] = "";
282 319
 			$temp_array['image_thumbnail'] = "";
283 320
 			$temp_array['image_source'] = "";
@@ -285,7 +322,9 @@  discard block
 block discarded – undo
285 322
  
286 323
 			if (isset($row['highlight'])) {
287 324
 				$temp_array['highlight'] = $row['highlight'];
288
-			} else $temp_array['highlight'] = '';
325
+			} else {
326
+				$temp_array['highlight'] = '';
327
+			}
289 328
 			
290 329
 			if (isset($row['date'])) {
291 330
 				$dateArray = $this->parseDateString($row['date']);
@@ -341,7 +380,9 @@  discard block
 block discarded – undo
341 380
 				
342 381
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
343 382
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
344
-					} else $temp_array['aircraft_shadow'] = 'default.png';
383
+					} else {
384
+						$temp_array['aircraft_shadow'] = 'default.png';
385
+					}
345 386
                                 } else {
346 387
                             		$temp_array['aircraft_shadow'] = 'default.png';
347 388
 					$temp_array['aircraft_name'] = 'N/A';
@@ -349,11 +390,17 @@  discard block
 block discarded – undo
349 390
                             	}
350 391
 			}
351 392
 			$fromsource = NULL;
352
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
353
-			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
354
-			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
355
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
356
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
393
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
394
+				$fromsource = $globalAirlinesSource;
395
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
396
+				$fromsource = 'vatsim';
397
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
398
+				$fromsource = 'ivao';
399
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
400
+				$fromsource = 'vatsim';
401
+			} elseif (isset($globalIVAO) && $globalIVAO) {
402
+				$fromsource = 'ivao';
403
+			}
357 404
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
358 405
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
359 406
 					if (is_numeric(substr($row['ident'], 2, 1))) {
@@ -376,12 +423,18 @@  discard block
 block discarded – undo
376 423
 				}
377 424
 			} else {
378 425
 				$temp_array['airline_icao'] = $row['airline_icao'];
379
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
380
-				else $temp_array['airline_iata'] = 'N/A';
426
+				if (isset($row['airline_iata'])) {
427
+					$temp_array['airline_iata'] = $row['airline_iata'];
428
+				} else {
429
+					$temp_array['airline_iata'] = 'N/A';
430
+				}
381 431
 				$temp_array['airline_name'] = $row['airline_name'];
382 432
 				$temp_array['airline_country'] = $row['airline_country'];
383
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
384
-				else $temp_array['airline_callsign'] = 'N/A';
433
+				if (isset($row['airline_callsign'])) {
434
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
435
+				} else {
436
+					$temp_array['airline_callsign'] = 'N/A';
437
+				}
385 438
 				$temp_array['airline_type'] = $row['airline_type'];
386 439
 				if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') {
387 440
 					$airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']);
@@ -408,7 +461,9 @@  discard block
 block discarded – undo
408 461
 			}
409 462
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) {
410 463
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
411
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
464
+				if ($owner_info['owner'] != '') {
465
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
466
+				}
412 467
 				$temp_array['aircraft_base'] = $owner_info['base'];
413 468
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
414 469
 			}
@@ -416,9 +471,14 @@  discard block
 block discarded – undo
416 471
 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
417 472
 			{
418 473
 				if ($globalIVAO) {
419
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
420
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
421
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
474
+					if (isset($temp_array['airline_icao'])) {
475
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
476
+					} else {
477
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
478
+					}
479
+				} else {
480
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
481
+				}
422 482
 				if (count($image_array) > 0) {
423 483
 					$temp_array['image'] = $image_array[0]['image'];
424 484
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -470,7 +530,9 @@  discard block
 block discarded – undo
470 530
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
471 531
 			if ($row['departure_airport_icao'] != '') {
472 532
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
473
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
533
+				if (!isset($departure_airport_array[0]['name'])) {
534
+					$departure_airport_array = $this->getAllAirportInfo('NA');
535
+				}
474 536
 			/*
475 537
 			} elseif ($row['departure_airport_name'] != '') {
476 538
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -478,7 +540,9 @@  discard block
 block discarded – undo
478 540
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
479 541
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
480 542
 			*/
481
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
543
+			} else {
544
+				$departure_airport_array = $this->getAllAirportInfo('NA');
545
+			}
482 546
 			if (isset($departure_airport_array[0]['name'])) {
483 547
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
484 548
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -498,8 +562,12 @@  discard block
 block discarded – undo
498 562
 			
499 563
 			if ($row['arrival_airport_icao'] != '') {
500 564
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
501
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
502
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
565
+				if (count($arrival_airport_array) == 0) {
566
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
567
+				}
568
+			} else {
569
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
570
+			}
503 571
 			if (isset($arrival_airport_array[0]['name'])) {
504 572
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
505 573
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -515,27 +583,45 @@  discard block
 block discarded – undo
515 583
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
516 584
 			}
517 585
 			*/
518
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
519
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
520
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
521
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
522
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
586
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
587
+				$temp_array['pilot_id'] = $row['pilot_id'];
588
+			}
589
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
590
+				$temp_array['pilot_name'] = $row['pilot_name'];
591
+			}
592
+			if (isset($row['source_name']) && $row['source_name'] != '') {
593
+				$temp_array['source_name'] = $row['source_name'];
594
+			}
595
+			if (isset($row['over_country']) && $row['over_country'] != '') {
596
+				$temp_array['over_country'] = $row['over_country'];
597
+			}
598
+			if (isset($row['distance']) && $row['distance'] != '') {
599
+				$temp_array['distance'] = $row['distance'];
600
+			}
523 601
 			if (isset($row['squawk'])) {
524 602
 				$temp_array['squawk'] = $row['squawk'];
525 603
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
526 604
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
527
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
605
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
606
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
607
+					}
528 608
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
529 609
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
530
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
531
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
610
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
611
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
612
+					}
613
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
614
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
615
+				}
532 616
 			}
533 617
     			
534 618
 			$temp_array['query_number_rows'] = $num_rows;
535 619
 			
536 620
 			$spotter_array[] = $temp_array;
537 621
 		}
538
-		if ($num_rows == 0) return array();
622
+		if ($num_rows == 0) {
623
+			return array();
624
+		}
539 625
 		$spotter_array[0]['query_number_rows'] = $num_rows;
540 626
 		return $spotter_array;
541 627
 	}	
@@ -568,7 +654,9 @@  discard block
 block discarded – undo
568 654
 				foreach ($q_array as $q_item){
569 655
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
570 656
 					$additional_query .= " AND (";
571
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
657
+					if (is_int($q_item)) {
658
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
659
+					}
572 660
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
573 661
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
574 662
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -589,7 +677,9 @@  discard block
 block discarded – undo
589 677
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
590 678
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
591 679
 					$translate = $Translation->ident2icao($q_item);
592
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
680
+					if ($translate != $q_item) {
681
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
682
+					}
593 683
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
594 684
 					$additional_query .= ")";
595 685
 				}
@@ -816,7 +906,9 @@  discard block
 block discarded – undo
816 906
 				date_default_timezone_set($globalTimezone);
817 907
 				$datetime = new DateTime();
818 908
 				$offset = $datetime->format('P');
819
-			} else $offset = '+00:00';
909
+			} else {
910
+				$offset = '+00:00';
911
+			}
820 912
 
821 913
 			if ($date_array[1] != "")
822 914
 			{
@@ -848,8 +940,12 @@  discard block
 block discarded – undo
848 940
 			{
849 941
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
850 942
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
851
-			} else $limit_query = "";
852
-		} else $limit_query = "";
943
+			} else {
944
+				$limit_query = "";
945
+			}
946
+		} else {
947
+			$limit_query = "";
948
+		}
853 949
 
854 950
 
855 951
 		if ($sort != "")
@@ -917,8 +1013,12 @@  discard block
 block discarded – undo
917 1013
 			{
918 1014
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
919 1015
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
920
-			} else $limit_query = "";
921
-		} else $limit_query = "";
1016
+			} else {
1017
+				$limit_query = "";
1018
+			}
1019
+		} else {
1020
+			$limit_query = "";
1021
+		}
922 1022
 		
923 1023
 		if ($sort != "")
924 1024
 		{
@@ -1242,7 +1342,9 @@  discard block
 block discarded – undo
1242 1342
 		global $global_query;
1243 1343
 		
1244 1344
 		date_default_timezone_set('UTC');
1245
-		if ($id == '') return array();
1345
+		if ($id == '') {
1346
+			return array();
1347
+		}
1246 1348
 		$additional_query = "spotter_output.spotter_id = :id";
1247 1349
 		$query_values = array(':id' => $id);
1248 1350
 
@@ -1357,8 +1459,11 @@  discard block
 block discarded – undo
1357 1459
 		if ($sort != "")
1358 1460
 		{
1359 1461
 			$search_orderby_array = $this->getOrderBy();
1360
-			if (isset($search_orderby_array[$sort]['sql'])) $orderby_query = $search_orderby_array[$sort]['sql'];
1361
-			else $orderby_query = " ORDER BY spotter_output.date DESC";
1462
+			if (isset($search_orderby_array[$sort]['sql'])) {
1463
+				$orderby_query = $search_orderby_array[$sort]['sql'];
1464
+			} else {
1465
+				$orderby_query = " ORDER BY spotter_output.date DESC";
1466
+			}
1362 1467
 		} else {
1363 1468
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1364 1469
 		}
@@ -1983,7 +2088,9 @@  discard block
 block discarded – undo
1983 2088
 		{
1984 2089
 			$highlight = $row['highlight'];
1985 2090
 		}
1986
-		if (isset($highlight)) return $highlight;
2091
+		if (isset($highlight)) {
2092
+			return $highlight;
2093
+		}
1987 2094
 	}
1988 2095
 
1989 2096
 	
@@ -2011,7 +2118,9 @@  discard block
 block discarded – undo
2011 2118
 		$sth->closeCursor();
2012 2119
 		if (count($row) > 0) {
2013 2120
 			return $row['usage'];
2014
-		} else return '';
2121
+		} else {
2122
+			return '';
2123
+		}
2015 2124
 	}
2016 2125
 
2017 2126
 	/**
@@ -2036,7 +2145,9 @@  discard block
 block discarded – undo
2036 2145
 		$sth->closeCursor();
2037 2146
 		if (count($row) > 0) {
2038 2147
 			return $row['icao'];
2039
-		} else return '';
2148
+		} else {
2149
+			return '';
2150
+		}
2040 2151
 	}
2041 2152
 
2042 2153
 	/**
@@ -2064,7 +2175,9 @@  discard block
 block discarded – undo
2064 2175
 			$airport_longitude = $row['longitude'];
2065 2176
 			$Common = new Common();
2066 2177
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
2067
-		} else return '';
2178
+		} else {
2179
+			return '';
2180
+		}
2068 2181
 	}
2069 2182
 	
2070 2183
 	/**
@@ -2176,7 +2289,9 @@  discard block
 block discarded – undo
2176 2289
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2177 2290
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2178 2291
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2179
-		} else return array();
2292
+		} else {
2293
+			return array();
2294
+		}
2180 2295
 		if ($globalDBdriver == 'mysql') {
2181 2296
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
2182 2297
 		} else {
@@ -2211,7 +2326,9 @@  discard block
 block discarded – undo
2211 2326
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2212 2327
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2213 2328
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2214
-		} else return array();
2329
+		} else {
2330
+			return array();
2331
+		}
2215 2332
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2216 2333
 		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2217 2334
 		//$query  = "SELECT waypoints.* FROM waypoints";
@@ -2246,7 +2363,9 @@  discard block
 block discarded – undo
2246 2363
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2247 2364
 	{
2248 2365
 		global $globalUseRealAirlines;
2249
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2366
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2367
+			$fromsource = NULL;
2368
+		}
2250 2369
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2251 2370
 		if ($airline_icao == 'NA') {
2252 2371
 			$airline_array = array();
@@ -2315,7 +2434,9 @@  discard block
 block discarded – undo
2315 2434
 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL)
2316 2435
 	{
2317 2436
 		global $globalUseRealAirlines;
2318
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2437
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2438
+			$fromsource = NULL;
2439
+		}
2319 2440
 		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING));
2320 2441
 		$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2321 2442
 		$sth = $this->db->prepare($query);
@@ -2331,7 +2452,9 @@  discard block
 block discarded – undo
2331 2452
 			$sth->execute(array(':fromsource' => $fromsource));
2332 2453
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
2333 2454
 			$sth->closeCursor();
2334
-			if ($row['nb'] == 0) $result = $this->getAllAirlineInfoByName($airline_name);
2455
+			if ($row['nb'] == 0) {
2456
+				$result = $this->getAllAirlineInfoByName($airline_name);
2457
+			}
2335 2458
 		}
2336 2459
 		return $result;
2337 2460
 	}
@@ -2394,15 +2517,20 @@  discard block
 block discarded – undo
2394 2517
 				'A320-211' => 'A320',
2395 2518
 				'747-8i' => 'B748',
2396 2519
 				'A380' => 'A388');
2397
-		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2520
+		if (isset($all_aircraft[$aircraft_type])) {
2521
+			return $all_aircraft[$aircraft_type];
2522
+		}
2398 2523
 
2399 2524
 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2400 2525
 		$aircraft_type = strtoupper($aircraft_type);
2401 2526
 		$sth = $this->db->prepare($query);
2402 2527
 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2403 2528
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2404
-		if (isset($result[0]['icao'])) return $result[0]['icao'];
2405
-		else return '';
2529
+		if (isset($result[0]['icao'])) {
2530
+			return $result[0]['icao'];
2531
+		} else {
2532
+			return '';
2533
+		}
2406 2534
 	}
2407 2535
 	
2408 2536
 	/**
@@ -2430,11 +2558,15 @@  discard block
 block discarded – undo
2430 2558
 		$sth->closeCursor();
2431 2559
 		if (isset($row['icaotypecode'])) {
2432 2560
 			$icao = $row['icaotypecode'];
2433
-			if (isset($this->aircraft_correct_icaotype[$icao])) $icao = $this->aircraft_correct_icaotype[$icao];
2561
+			if (isset($this->aircraft_correct_icaotype[$icao])) {
2562
+				$icao = $this->aircraft_correct_icaotype[$icao];
2563
+			}
2434 2564
 			return $icao;
2435 2565
 		} elseif ($source_type == 'flarm') {
2436 2566
 			return $this->getAllAircraftType($aircraft_modes);
2437
-		} else  return '';
2567
+		} else {
2568
+			return '';
2569
+		}
2438 2570
 	}
2439 2571
 
2440 2572
 	/**
@@ -2457,7 +2589,9 @@  discard block
 block discarded – undo
2457 2589
 		$sth->closeCursor();
2458 2590
 		if (isset($row['icaotypecode'])) {
2459 2591
 			return $row['icaotypecode'];
2460
-		} else return '';
2592
+		} else {
2593
+			return '';
2594
+		}
2461 2595
 	}
2462 2596
 
2463 2597
 	/**
@@ -2503,7 +2637,9 @@  discard block
 block discarded – undo
2503 2637
 		$sth->closeCursor();
2504 2638
 		if (isset($row['operator_correct'])) {
2505 2639
 			return $row['operator_correct'];
2506
-		} else return $operator;
2640
+		} else {
2641
+			return $operator;
2642
+		}
2507 2643
 	}
2508 2644
 
2509 2645
 	/**
@@ -2516,7 +2652,9 @@  discard block
 block discarded – undo
2516 2652
 	public function getRouteInfo($callsign)
2517 2653
 	{
2518 2654
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2519
-                if ($callsign == '') return array();
2655
+                if ($callsign == '') {
2656
+                	return array();
2657
+                }
2520 2658
 		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2521 2659
 		
2522 2660
 		$sth = $this->db->prepare($query);
@@ -2526,7 +2664,9 @@  discard block
 block discarded – undo
2526 2664
 		$sth->closeCursor();
2527 2665
 		if (count($row) > 0) {
2528 2666
 			return $row;
2529
-		} else return array();
2667
+		} else {
2668
+			return array();
2669
+		}
2530 2670
 	}
2531 2671
 	
2532 2672
 	/**
@@ -2579,7 +2719,9 @@  discard block
 block discarded – undo
2579 2719
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
2580 2720
 			$sth->closeCursor();
2581 2721
 			return $result;
2582
-		} else return array();
2722
+		} else {
2723
+			return array();
2724
+		}
2583 2725
 	}
2584 2726
 	
2585 2727
   
@@ -2738,8 +2880,11 @@  discard block
 block discarded – undo
2738 2880
 		$query .= " ORDER BY spotter_output.source_name ASC";
2739 2881
 
2740 2882
 		$sth = $this->db->prepare($query);
2741
-		if (!empty($query_values)) $sth->execute($query_values);
2742
-		else $sth->execute();
2883
+		if (!empty($query_values)) {
2884
+			$sth->execute($query_values);
2885
+		} else {
2886
+			$sth->execute();
2887
+		}
2743 2888
 
2744 2889
 		$source_array = array();
2745 2890
 		$temp_array = array();
@@ -2772,9 +2917,13 @@  discard block
 block discarded – undo
2772 2917
 								WHERE spotter_output.airline_icao <> '' 
2773 2918
 								ORDER BY spotter_output.airline_name ASC";
2774 2919
 			*/
2775
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2776
-			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2777
-			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2920
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2921
+				$forsource = $globalAirlinesSource;
2922
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
2923
+				$forsource = 'vatsim';
2924
+			} elseif (isset($globalIVAO) && $globalIVAO) {
2925
+				$forsource = 'ivao';
2926
+			}
2778 2927
 			if ($forsource === NULL) {
2779 2928
 				$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC";
2780 2929
 				$query_data = array();
@@ -2817,9 +2966,13 @@  discard block
 block discarded – undo
2817 2966
 	{
2818 2967
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2819 2968
 		$filter_query = $this->getFilter($filters,true,true);
2820
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2821
-		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2822
-		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2969
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2970
+			$forsource = $globalAirlinesSource;
2971
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
2972
+			$forsource = 'vatsim';
2973
+		} elseif (isset($globalIVAO) && $globalIVAO) {
2974
+			$forsource = 'ivao';
2975
+		}
2823 2976
 		if ($forsource === NULL) {
2824 2977
 			$query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource IS NULL ORDER BY alliance ASC";
2825 2978
 			$query_data = array();
@@ -3130,7 +3283,9 @@  discard block
 block discarded – undo
3130 3283
 			date_default_timezone_set($globalTimezone);
3131 3284
 			$datetime = new DateTime();
3132 3285
 			$offset = $datetime->format('P');
3133
-		} else $offset = '+00:00';
3286
+		} else {
3287
+			$offset = '+00:00';
3288
+		}
3134 3289
 		if ($airport_icao == '') {
3135 3290
 			if ($globalDBdriver == 'mysql') {
3136 3291
 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -3162,7 +3317,9 @@  discard block
 block discarded – undo
3162 3317
 			date_default_timezone_set($globalTimezone);
3163 3318
 			$datetime = new DateTime();
3164 3319
 			$offset = $datetime->format('P');
3165
-		} else $offset = '+00:00';
3320
+		} else {
3321
+			$offset = '+00:00';
3322
+		}
3166 3323
 		if ($airport_icao == '') {
3167 3324
 			if ($globalDBdriver == 'mysql') {
3168 3325
 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -3195,7 +3352,9 @@  discard block
 block discarded – undo
3195 3352
 			date_default_timezone_set($globalTimezone);
3196 3353
 			$datetime = new DateTime();
3197 3354
 			$offset = $datetime->format('P');
3198
-		} else $offset = '+00:00';
3355
+		} else {
3356
+			$offset = '+00:00';
3357
+		}
3199 3358
 		if ($airport_icao == '') {
3200 3359
 			if ($globalDBdriver == 'mysql') {
3201 3360
 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3234,7 +3393,9 @@  discard block
 block discarded – undo
3234 3393
 			date_default_timezone_set($globalTimezone);
3235 3394
 			$datetime = new DateTime();
3236 3395
 			$offset = $datetime->format('P');
3237
-		} else $offset = '+00:00';
3396
+		} else {
3397
+			$offset = '+00:00';
3398
+		}
3238 3399
 		if ($airport_icao == '') {
3239 3400
 			if ($globalDBdriver == 'mysql') {
3240 3401
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3279,7 +3440,9 @@  discard block
 block discarded – undo
3279 3440
 			date_default_timezone_set($globalTimezone);
3280 3441
 			$datetime = new DateTime();
3281 3442
 			$offset = $datetime->format('P');
3282
-		} else $offset = '+00:00';
3443
+		} else {
3444
+			$offset = '+00:00';
3445
+		}
3283 3446
 		if ($airport_icao == '') {
3284 3447
 			if ($globalDBdriver == 'mysql') {
3285 3448
 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3314,7 +3477,9 @@  discard block
 block discarded – undo
3314 3477
 			date_default_timezone_set($globalTimezone);
3315 3478
 			$datetime = new DateTime();
3316 3479
 			$offset = $datetime->format('P');
3317
-		} else $offset = '+00:00';
3480
+		} else {
3481
+			$offset = '+00:00';
3482
+		}
3318 3483
 		if ($airport_icao == '') {
3319 3484
 			if ($globalDBdriver == 'mysql') {
3320 3485
 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3356,7 +3521,9 @@  discard block
 block discarded – undo
3356 3521
 			date_default_timezone_set($globalTimezone);
3357 3522
 			$datetime = new DateTime();
3358 3523
 			$offset = $datetime->format('P');
3359
-		} else $offset = '+00:00';
3524
+		} else {
3525
+			$offset = '+00:00';
3526
+		}
3360 3527
 		if ($airport_icao == '') {
3361 3528
 			if ($globalDBdriver == 'mysql') {
3362 3529
 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3390,7 +3557,9 @@  discard block
 block discarded – undo
3390 3557
 			date_default_timezone_set($globalTimezone);
3391 3558
 			$datetime = new DateTime();
3392 3559
 			$offset = $datetime->format('P');
3393
-		} else $offset = '+00:00';
3560
+		} else {
3561
+			$offset = '+00:00';
3562
+		}
3394 3563
 		if ($airport_icao == '') {
3395 3564
 			if ($globalDBdriver == 'mysql') {
3396 3565
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3438,7 +3607,9 @@  discard block
 block discarded – undo
3438 3607
 			date_default_timezone_set($globalTimezone);
3439 3608
 			$datetime = new DateTime();
3440 3609
 			$offset = $datetime->format('P');
3441
-		} else $offset = '+00:00';
3610
+		} else {
3611
+			$offset = '+00:00';
3612
+		}
3442 3613
 
3443 3614
 		if ($globalDBdriver == 'mysql') {
3444 3615
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -3558,7 +3729,9 @@  discard block
 block discarded – undo
3558 3729
 	*/	
3559 3730
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3560 3731
 	{
3561
-		if ($groundspeed == '') $groundspeed = NULL;
3732
+		if ($groundspeed == '') {
3733
+			$groundspeed = NULL;
3734
+		}
3562 3735
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
3563 3736
                 $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3564 3737
 
@@ -3608,10 +3781,18 @@  discard block
 block discarded – undo
3608 3781
 		$Image = new Image($this->db);
3609 3782
 		$Common = new Common();
3610 3783
 		
3611
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
3612
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
3613
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3614
-		if (!isset($globalVAM)) $globalVAM = FALSE;
3784
+		if (!isset($globalIVAO)) {
3785
+			$globalIVAO = FALSE;
3786
+		}
3787
+		if (!isset($globalVATSIM)) {
3788
+			$globalVATSIM = FALSE;
3789
+		}
3790
+		if (!isset($globalphpVMS)) {
3791
+			$globalphpVMS = FALSE;
3792
+		}
3793
+		if (!isset($globalVAM)) {
3794
+			$globalVAM = FALSE;
3795
+		}
3615 3796
 		date_default_timezone_set('UTC');
3616 3797
 		
3617 3798
 		//getting the registration
@@ -3624,23 +3805,33 @@  discard block
 block discarded – undo
3624 3805
 				if ($ModeS != '') {
3625 3806
 					$timeelapsed = microtime(true);
3626 3807
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS,$source_type);
3627
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3808
+					if ($globalDebugTimeElapsed) {
3809
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3810
+					}
3628 3811
 				} else {
3629 3812
 					$myhex = explode('-',$flightaware_id);
3630 3813
 					if (count($myhex) > 0) {
3631 3814
 						$timeelapsed = microtime(true);
3632 3815
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0],$source_type);
3633
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3816
+						if ($globalDebugTimeElapsed) {
3817
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3818
+						}
3634 3819
 					}
3635 3820
 				}
3636 3821
 			}
3637 3822
 		}
3638 3823
 		$fromsource = NULL;
3639
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
3640
-		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim';
3641
-		elseif ($format_source == 'whazzup') $fromsource = 'ivao';
3642
-		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
3643
-		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
3824
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
3825
+			$fromsource = $globalAirlinesSource;
3826
+		} elseif ($format_source == 'vatsimtxt') {
3827
+			$fromsource = 'vatsim';
3828
+		} elseif ($format_source == 'whazzup') {
3829
+			$fromsource = 'ivao';
3830
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
3831
+			$fromsource = 'vatsim';
3832
+		} elseif (isset($globalIVAO) && $globalIVAO) {
3833
+			$fromsource = 'ivao';
3834
+		}
3644 3835
 		//getting the airline information
3645 3836
 		if ($ident != "")
3646 3837
 		{
@@ -3664,15 +3855,21 @@  discard block
 block discarded – undo
3664 3855
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3665 3856
 						$airline_array = $this->getAllAirlineInfo("NA");
3666 3857
 					}
3667
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3858
+					if ($globalDebugTimeElapsed) {
3859
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3860
+					}
3668 3861
 
3669 3862
 				} else {
3670 3863
 					$timeelapsed = microtime(true);
3671 3864
 					$airline_array = $this->getAllAirlineInfo("NA");
3672
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3865
+					if ($globalDebugTimeElapsed) {
3866
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3867
+					}
3673 3868
 				}
3674 3869
 			}
3675
-		} else $airline_array = array();
3870
+		} else {
3871
+			$airline_array = array();
3872
+		}
3676 3873
 		
3677 3874
 		//getting the aircraft information
3678 3875
 		$aircraft_array = array();
@@ -3686,27 +3883,37 @@  discard block
 block discarded – undo
3686 3883
 				{
3687 3884
 					$timeelapsed = microtime(true);
3688 3885
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3689
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3886
+					if ($globalDebugTimeElapsed) {
3887
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3888
+					}
3690 3889
 				} else {
3691 3890
 					$timeelapsed = microtime(true);
3692 3891
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3693
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3892
+					if ($globalDebugTimeElapsed) {
3893
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3894
+					}
3694 3895
 				}
3695 3896
 			}
3696 3897
 		} else {
3697 3898
 			if ($ModeS != '') {
3698 3899
 				$timeelapsed = microtime(true);
3699 3900
 				$aircraft_icao = $this->getAllAircraftType($ModeS,$source_type);
3700
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3901
+				if ($globalDebugTimeElapsed) {
3902
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3903
+				}
3701 3904
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3702 3905
 				{
3703 3906
 					$timeelapsed = microtime(true);
3704 3907
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3705
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3908
+					if ($globalDebugTimeElapsed) {
3909
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3910
+					}
3706 3911
 				} else {
3707 3912
 					$timeelapsed = microtime(true);
3708 3913
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3709
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3914
+					if ($globalDebugTimeElapsed) {
3915
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3916
+					}
3710 3917
 				}
3711 3918
 			}
3712 3919
 		}
@@ -3722,7 +3929,9 @@  discard block
 block discarded – undo
3722 3929
 			} else {
3723 3930
 				$timeelapsed = microtime(true);
3724 3931
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3725
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3932
+				if ($globalDebugTimeElapsed) {
3933
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3934
+				}
3726 3935
 			}
3727 3936
 		}
3728 3937
 		
@@ -3737,7 +3946,9 @@  discard block
 block discarded – undo
3737 3946
 			} else {
3738 3947
 				$timeelapsed = microtime(true);
3739 3948
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3740
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3949
+				if ($globalDebugTimeElapsed) {
3950
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3951
+				}
3741 3952
 			}
3742 3953
 		}
3743 3954
 
@@ -3771,7 +3982,9 @@  discard block
 block discarded – undo
3771 3982
 			{
3772 3983
 				return false;
3773 3984
 			}
3774
-		} else $altitude = 0;
3985
+		} else {
3986
+			$altitude = 0;
3987
+		}
3775 3988
 		
3776 3989
 		if ($heading != "")
3777 3990
 		{
@@ -3800,7 +4013,9 @@  discard block
 block discarded – undo
3800 4013
 		{
3801 4014
 			$timeelapsed = microtime(true);
3802 4015
 			$image_array = $Image->getSpotterImage($registration);
3803
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4016
+			if ($globalDebugTimeElapsed) {
4017
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4018
+			}
3804 4019
 			if (!isset($image_array[0]['registration']))
3805 4020
 			{
3806 4021
 				//echo "Add image !!!! \n";
@@ -3808,14 +4023,21 @@  discard block
 block discarded – undo
3808 4023
 			}
3809 4024
 			$timeelapsed = microtime(true);
3810 4025
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3811
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3812
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
4026
+			if ($globalDebugTimeElapsed) {
4027
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4028
+			}
4029
+			if ($owner_info['owner'] != '') {
4030
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
4031
+			}
3813 4032
 		}
3814 4033
     
3815 4034
 		if ($globalIVAO && $aircraft_icao != '')
3816 4035
 		{
3817
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818
-            		else $airline_icao = '';
4036
+            		if (isset($airline_array[0]['icao'])) {
4037
+            			$airline_icao = $airline_array[0]['icao'];
4038
+            		} else {
4039
+            			$airline_icao = '';
4040
+            		}
3819 4041
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3820 4042
 			if (!isset($image_array[0]['registration']))
3821 4043
 			{
@@ -3860,16 +4082,28 @@  discard block
 block discarded – undo
3860 4082
                 {
3861 4083
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3862 4084
                 }
3863
-                if ($registration == '') $registration = 'NA';
4085
+                if ($registration == '') {
4086
+                	$registration = 'NA';
4087
+                }
3864 4088
                 if ($latitude == '' && $longitude == '') {
3865 4089
             		$latitude = 0;
3866 4090
             		$longitude = 0;
3867 4091
             	}
3868
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3869
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3870
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
4092
+                if ($squawk == '' || $Common->isInteger($squawk) === false) {
4093
+                	$squawk = NULL;
4094
+                }
4095
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) {
4096
+                	$verticalrate = NULL;
4097
+                }
4098
+                if ($heading == '' || $Common->isInteger($heading) === false) {
4099
+                	$heading = 0;
4100
+                }
4101
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
4102
+                	$groundspeed = 0;
4103
+                }
4104
+                if (!isset($aircraft_owner)) {
4105
+                	$aircraft_owner = NULL;
4106
+                }
3873 4107
                 $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3874 4108
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3875 4109
 
@@ -3880,9 +4114,13 @@  discard block
 block discarded – undo
3880 4114
 		if ($airline_type == '') {
3881 4115
 			$timeelapsed = microtime(true);
3882 4116
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3883
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4117
+			if ($globalDebugTimeElapsed) {
4118
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4119
+			}
4120
+		}
4121
+		if ($airline_type == null) {
4122
+			$airline_type = '';
3884 4123
 		}
3885
-		if ($airline_type == null) $airline_type = '';
3886 4124
                 $aircraft_type = $aircraft_array[0]['type'];
3887 4125
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3888 4126
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -4046,7 +4284,9 @@  discard block
 block discarded – undo
4046 4284
 			}
4047 4285
 		}
4048 4286
 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
4049
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4287
+		if ($limit) {
4288
+			$query .= " LIMIT 10 OFFSET 0";
4289
+		}
4050 4290
 
4051 4291
 		$sth = $this->db->prepare($query);
4052 4292
 		$sth->execute($query_values);
@@ -4119,7 +4359,9 @@  discard block
 block discarded – undo
4119 4359
 		}
4120 4360
 		
4121 4361
 		$query .= " GROUP BY spotter_output.pilot_id,s.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4122
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4362
+		if ($limit) {
4363
+			$query .= " LIMIT 10 OFFSET 0";
4364
+		}
4123 4365
       
4124 4366
 		
4125 4367
 		$sth = $this->db->prepare($query);
@@ -4163,7 +4405,9 @@  discard block
 block discarded – undo
4163 4405
 			}
4164 4406
 		}
4165 4407
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4166
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4408
+		if ($limit) {
4409
+			$query .= " LIMIT 10 OFFSET 0";
4410
+		}
4167 4411
       
4168 4412
 		
4169 4413
 		$sth = $this->db->prepare($query);
@@ -4239,7 +4483,9 @@  discard block
 block discarded – undo
4239 4483
 			}
4240 4484
 		}
4241 4485
 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
4242
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4486
+		if ($limit) {
4487
+			$query .= " LIMIT 10 OFFSET 0";
4488
+		}
4243 4489
 		
4244 4490
 		$sth = $this->db->prepare($query);
4245 4491
 		$sth->execute($query_values);
@@ -4281,7 +4527,9 @@  discard block
 block discarded – undo
4281 4527
 			}
4282 4528
 		}
4283 4529
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC";
4284
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4530
+		if ($limit) {
4531
+			$query .= " LIMIT 10 OFFSET 0";
4532
+		}
4285 4533
       
4286 4534
 		
4287 4535
 		$sth = $this->db->prepare($query);
@@ -4524,7 +4772,9 @@  discard block
 block discarded – undo
4524 4772
 			date_default_timezone_set($globalTimezone);
4525 4773
 			$datetime = new DateTime($date);
4526 4774
 			$offset = $datetime->format('P');
4527
-		} else $offset = '+00:00';
4775
+		} else {
4776
+			$offset = '+00:00';
4777
+		}
4528 4778
 
4529 4779
 		if ($globalDBdriver == 'mysql') {
4530 4780
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -4572,7 +4822,9 @@  discard block
 block discarded – undo
4572 4822
 			date_default_timezone_set($globalTimezone);
4573 4823
 			$datetime = new DateTime($date);
4574 4824
 			$offset = $datetime->format('P');
4575
-		} else $offset = '+00:00';
4825
+		} else {
4826
+			$offset = '+00:00';
4827
+		}
4576 4828
 		
4577 4829
 		if ($globalDBdriver == 'mysql') {
4578 4830
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4692,9 +4944,13 @@  discard block
 block discarded – undo
4692 4944
 		$sth = $this->db->prepare($query);
4693 4945
 		$sth->execute($query_values);
4694 4946
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4695
-		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4696
-		elseif ($result[0]['duration'] == '') return 0;
4697
-		else return $result[0]['duration'];
4947
+		if (is_numeric($result[0]['duration'])) {
4948
+			return gmdate('H:i:s',$result[0]['duration']);
4949
+		} elseif ($result[0]['duration'] == '') {
4950
+			return 0;
4951
+		} else {
4952
+			return $result[0]['duration'];
4953
+		}
4698 4954
 	}
4699 4955
 
4700 4956
 	/**
@@ -4783,8 +5039,11 @@  discard block
 block discarded – undo
4783 5039
 		$sth = $this->db->prepare($query);
4784 5040
 		$sth->execute($query_values);
4785 5041
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4786
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4787
-		else return $result[0]['duration'];
5042
+		if (is_int($result[0]['duration'])) {
5043
+			return gmdate('H:i:s',$result[0]['duration']);
5044
+		} else {
5045
+			return $result[0]['duration'];
5046
+		}
4788 5047
 	}
4789 5048
 
4790 5049
 	/**
@@ -4989,7 +5248,9 @@  discard block
 block discarded – undo
4989 5248
 		}
4990 5249
 		$query .= " GROUP BY spotter_output.airline_country
4991 5250
 					ORDER BY airline_country_count DESC";
4992
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5251
+		if ($limit) {
5252
+			$query .= " LIMIT 10 OFFSET 0";
5253
+		}
4993 5254
       
4994 5255
 		$sth = $this->db->prepare($query);
4995 5256
 		$sth->execute($query_values);
@@ -5017,7 +5278,9 @@  discard block
 block discarded – undo
5017 5278
 		global $globalDBdriver;
5018 5279
 		//$filter_query = $this->getFilter($filters,true,true);
5019 5280
 		$Connection= new Connection($this->db);
5020
-		if (!$Connection->tableExists('countries')) return array();
5281
+		if (!$Connection->tableExists('countries')) {
5282
+			return array();
5283
+		}
5021 5284
 		/*
5022 5285
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
5023 5286
 					FROM countries c, spotter_output s
@@ -5049,7 +5312,9 @@  discard block
 block discarded – undo
5049 5312
 		}
5050 5313
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spotter_live".$filter_query.") l ON c.iso2 = l.over_country ";
5051 5314
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
5052
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5315
+		if ($limit) {
5316
+			$query .= " LIMIT 10 OFFSET 0";
5317
+		}
5053 5318
       
5054 5319
 		
5055 5320
 		$sth = $this->db->prepare($query);
@@ -5126,7 +5391,9 @@  discard block
 block discarded – undo
5126 5391
 		}
5127 5392
 
5128 5393
 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5129
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5394
+		if ($limit) {
5395
+			$query .= " LIMIT 10 OFFSET 0";
5396
+		}
5130 5397
  
5131 5398
 		$sth = $this->db->prepare($query);
5132 5399
 		$sth->execute($query_values);
@@ -5200,7 +5467,9 @@  discard block
 block discarded – undo
5200 5467
 		}
5201 5468
 
5202 5469
 		$query .= " GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5203
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5470
+		if ($limit) {
5471
+			$query .= " LIMIT 10 OFFSET 0";
5472
+		}
5204 5473
  
5205 5474
 		$sth = $this->db->prepare($query);
5206 5475
 		$sth->execute($query_values);
@@ -5247,7 +5516,9 @@  discard block
 block discarded – undo
5247 5516
 		}
5248 5517
 
5249 5518
 		$query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5250
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5519
+		if ($limit) {
5520
+			$query .= " LIMIT 10 OFFSET 0";
5521
+		}
5251 5522
  
5252 5523
 		$sth = $this->db->prepare($query);
5253 5524
 		$sth->execute();
@@ -5300,7 +5571,9 @@  discard block
 block discarded – undo
5300 5571
 			if($row['registration'] != "")
5301 5572
 			{
5302 5573
 				$image_array = $Image->getSpotterImage($row['registration']);
5303
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5574
+				if (isset($image_array[0]['image_thumbnail'])) {
5575
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5576
+				}
5304 5577
 			}
5305 5578
 			$temp_array['registration_count'] = $row['registration_count'];
5306 5579
 
@@ -5375,7 +5648,9 @@  discard block
 block discarded – undo
5375 5648
 			if($row['registration'] != "")
5376 5649
 			{
5377 5650
 				$image_array = $Image->getSpotterImage($row['registration']);
5378
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5651
+				if (isset($image_array[0]['image_thumbnail'])) {
5652
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5653
+				}
5379 5654
 			}
5380 5655
 			$temp_array['registration_count'] = $row['registration_count'];
5381 5656
 
@@ -5482,7 +5757,9 @@  discard block
 block discarded – undo
5482 5757
 			if($row['registration'] != "")
5483 5758
 			{
5484 5759
 				$image_array = $Image->getSpotterImage($row['registration']);
5485
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5760
+				if (isset($image_array[0]['image_thumbnail'])) {
5761
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5762
+				}
5486 5763
 			}
5487 5764
 			$temp_array['registration_count'] = $row['registration_count'];
5488 5765
 			$aircraft_array[] = $temp_array;
@@ -5607,7 +5884,9 @@  discard block
 block discarded – undo
5607 5884
 			date_default_timezone_set($globalTimezone);
5608 5885
 			$datetime = new DateTime($date);
5609 5886
 			$offset = $datetime->format('P');
5610
-		} else $offset = '+00:00';
5887
+		} else {
5888
+			$offset = '+00:00';
5889
+		}
5611 5890
 
5612 5891
 		if ($globalDBdriver == 'mysql') {
5613 5892
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -5654,7 +5933,9 @@  discard block
 block discarded – undo
5654 5933
 			date_default_timezone_set($globalTimezone);
5655 5934
 			$datetime = new DateTime($date);
5656 5935
 			$offset = $datetime->format('P');
5657
-		} else $offset = '+00:00';
5936
+		} else {
5937
+			$offset = '+00:00';
5938
+		}
5658 5939
 
5659 5940
 		if ($globalDBdriver == 'mysql') {
5660 5941
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
@@ -5683,7 +5964,9 @@  discard block
 block discarded – undo
5683 5964
 			if($row['registration'] != "")
5684 5965
 			{
5685 5966
 				$image_array = $Image->getSpotterImage($row['registration']);
5686
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5967
+				if (isset($image_array[0]['image_thumbnail'])) {
5968
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5969
+				}
5687 5970
 			}
5688 5971
 			$temp_array['registration_count'] = $row['registration_count'];
5689 5972
  
@@ -5708,7 +5991,9 @@  discard block
 block discarded – undo
5708 5991
 			date_default_timezone_set($globalTimezone);
5709 5992
 			$datetime = new DateTime($date);
5710 5993
 			$offset = $datetime->format('P');
5711
-		} else $offset = '+00:00';
5994
+		} else {
5995
+			$offset = '+00:00';
5996
+		}
5712 5997
 
5713 5998
 		if ($globalDBdriver == 'mysql') {
5714 5999
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -5904,8 +6189,11 @@  discard block
 block discarded – undo
5904 6189
 			if($row['registration'] != "")
5905 6190
 			{
5906 6191
 				$image_array = $Image->getSpotterImage($row['registration']);
5907
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5908
-				else $temp_array['image_thumbnail'] = '';
6192
+				if (isset($image_array[0]['image_thumbnail'])) {
6193
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6194
+				} else {
6195
+					$temp_array['image_thumbnail'] = '';
6196
+				}
5909 6197
 			}
5910 6198
 			$temp_array['registration_count'] = $row['registration_count'];
5911 6199
 			$aircraft_array[] = $temp_array;
@@ -5979,8 +6267,11 @@  discard block
 block discarded – undo
5979 6267
 			if($row['registration'] != "")
5980 6268
 			{
5981 6269
 				$image_array = $Image->getSpotterImage($row['registration']);
5982
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5983
-				else $temp_array['image_thumbnail'] = '';
6270
+				if (isset($image_array[0]['image_thumbnail'])) {
6271
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6272
+				} else {
6273
+					$temp_array['image_thumbnail'] = '';
6274
+				}
5984 6275
 			}
5985 6276
 			$temp_array['registration_count'] = $row['registration_count'];
5986 6277
 			$aircraft_array[] = $temp_array;
@@ -6054,8 +6345,11 @@  discard block
 block discarded – undo
6054 6345
 			if($row['registration'] != "")
6055 6346
 			{
6056 6347
 				$image_array = $Image->getSpotterImage($row['registration']);
6057
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6058
-				else $temp_array['image_thumbnail'] = '';
6348
+				if (isset($image_array[0]['image_thumbnail'])) {
6349
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6350
+				} else {
6351
+					$temp_array['image_thumbnail'] = '';
6352
+				}
6059 6353
 			}
6060 6354
 			$temp_array['registration_count'] = $row['registration_count'];
6061 6355
 			$aircraft_array[] = $temp_array;
@@ -6266,7 +6560,9 @@  discard block
 block discarded – undo
6266 6560
 			if($row['registration'] != "")
6267 6561
 			{
6268 6562
 				$image_array = $Image->getSpotterImage($row['registration']);
6269
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6563
+				if (isset($image_array[0]['image_thumbnail'])) {
6564
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6565
+				}
6270 6566
 			}
6271 6567
 			$temp_array['registration_count'] = $row['registration_count'];
6272 6568
           
@@ -6383,7 +6679,9 @@  discard block
 block discarded – undo
6383 6679
 			if($row['registration'] != "")
6384 6680
 			{
6385 6681
 				$image_array = $Image->getSpotterImage($row['registration']);
6386
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6682
+				if (isset($image_array[0]['image_thumbnail'])) {
6683
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6684
+				}
6387 6685
 			}
6388 6686
 			$temp_array['registration_count'] = $row['registration_count'];
6389 6687
           
@@ -6549,7 +6847,9 @@  discard block
 block discarded – undo
6549 6847
 			}
6550 6848
 		}
6551 6849
 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6552
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6850
+		if ($limit) {
6851
+			$query .= " LIMIT 10 OFFSET 0";
6852
+		}
6553 6853
 		
6554 6854
 		$sth = $this->db->prepare($query);
6555 6855
 		$sth->execute($query_values);
@@ -6568,7 +6868,9 @@  discard block
 block discarded – undo
6568 6868
 			if($row['registration'] != "")
6569 6869
 			{
6570 6870
 				$image_array = $Image->getSpotterImage($row['registration']);
6571
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6871
+				if (isset($image_array[0]['image_thumbnail'])) {
6872
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6873
+				}
6572 6874
 			}
6573 6875
           
6574 6876
 			$aircraft_array[] = $temp_array;
@@ -6609,7 +6911,9 @@  discard block
 block discarded – undo
6609 6911
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6610 6912
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6611 6913
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6612
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6914
+		if ($limit) {
6915
+			$query .= " LIMIT 10 OFFSET 0";
6916
+		}
6613 6917
 		
6614 6918
 		$sth = $this->db->prepare($query);
6615 6919
 		$sth->execute();
@@ -6629,7 +6933,9 @@  discard block
 block discarded – undo
6629 6933
 			if($row['registration'] != "")
6630 6934
 			{
6631 6935
 				$image_array = $Image->getSpotterImage($row['registration']);
6632
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6936
+				if (isset($image_array[0]['image_thumbnail'])) {
6937
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6938
+				}
6633 6939
 			}
6634 6940
           
6635 6941
 			$aircraft_array[] = $temp_array;
@@ -6695,7 +7001,9 @@  discard block
 block discarded – undo
6695 7001
 		}
6696 7002
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6697 7003
 				ORDER BY airport_departure_icao_count DESC";
6698
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7004
+		if ($limit) {
7005
+			$query .= " LIMIT 10 OFFSET 0";
7006
+		}
6699 7007
 
6700 7008
 		$sth = $this->db->prepare($query);
6701 7009
 		$sth->execute($query_values);
@@ -6746,7 +7054,9 @@  discard block
 block discarded – undo
6746 7054
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6747 7055
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6748 7056
 				ORDER BY airport_departure_icao_count DESC";
6749
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7057
+		if ($limit) {
7058
+			$query .= " LIMIT 10 OFFSET 0";
7059
+		}
6750 7060
       
6751 7061
 		$sth = $this->db->prepare($query);
6752 7062
 		$sth->execute();
@@ -6824,7 +7134,9 @@  discard block
 block discarded – undo
6824 7134
 		}
6825 7135
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6826 7136
 				ORDER BY airport_departure_icao_count DESC";
6827
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7137
+		if ($limit) {
7138
+			$query .= " LIMIT 10 OFFSET 0";
7139
+		}
6828 7140
     		//echo $query;
6829 7141
 		$sth = $this->db->prepare($query);
6830 7142
 		$sth->execute($query_values);
@@ -6876,7 +7188,9 @@  discard block
 block discarded – undo
6876 7188
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6877 7189
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6878 7190
 				ORDER BY airport_departure_icao_count DESC";
6879
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7191
+		if ($limit) {
7192
+			$query .= " LIMIT 10 OFFSET 0";
7193
+		}
6880 7194
       
6881 7195
 		$sth = $this->db->prepare($query);
6882 7196
 		$sth->execute();
@@ -7271,7 +7585,9 @@  discard block
 block discarded – undo
7271 7585
 			date_default_timezone_set($globalTimezone);
7272 7586
 			$datetime = new DateTime($date);
7273 7587
 			$offset = $datetime->format('P');
7274
-		} else $offset = '+00:00';
7588
+		} else {
7589
+			$offset = '+00:00';
7590
+		}
7275 7591
 
7276 7592
 		if ($globalDBdriver == 'mysql') {
7277 7593
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
@@ -7321,7 +7637,9 @@  discard block
 block discarded – undo
7321 7637
 			date_default_timezone_set($globalTimezone);
7322 7638
 			$datetime = new DateTime($date);
7323 7639
 			$offset = $datetime->format('P');
7324
-		} else $offset = '+00:00';
7640
+		} else {
7641
+			$offset = '+00:00';
7642
+		}
7325 7643
 
7326 7644
 		if ($globalDBdriver == 'mysql') {
7327 7645
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -7670,7 +7988,9 @@  discard block
 block discarded – undo
7670 7988
 		}
7671 7989
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7672 7990
 					ORDER BY airport_arrival_icao_count DESC";
7673
-		if ($limit) $query .= " LIMIT 10";
7991
+		if ($limit) {
7992
+			$query .= " LIMIT 10";
7993
+		}
7674 7994
       
7675 7995
 		
7676 7996
 		$sth = $this->db->prepare($query);
@@ -7690,7 +8010,9 @@  discard block
 block discarded – undo
7690 8010
 			if ($icaoaskey) {
7691 8011
 				$icao = $row['arrival_airport_icao'];
7692 8012
 				$airport_array[$icao] = $temp_array;
7693
-			} else $airport_array[] = $temp_array;
8013
+			} else {
8014
+				$airport_array[] = $temp_array;
8015
+			}
7694 8016
 		}
7695 8017
 
7696 8018
 		return $airport_array;
@@ -7727,7 +8049,9 @@  discard block
 block discarded – undo
7727 8049
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7728 8050
                 $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7729 8051
 					ORDER BY airport_arrival_icao_count DESC";
7730
-		if ($limit) $query .= " LIMIT 10";
8052
+		if ($limit) {
8053
+			$query .= " LIMIT 10";
8054
+		}
7731 8055
       
7732 8056
 		
7733 8057
 		$sth = $this->db->prepare($query);
@@ -7748,7 +8072,9 @@  discard block
 block discarded – undo
7748 8072
 			if ($icaoaskey) {
7749 8073
 				$icao = $row['arrival_airport_icao'];
7750 8074
 				$airport_array[$icao] = $temp_array;
7751
-			} else $airport_array[] = $temp_array;
8075
+			} else {
8076
+				$airport_array[] = $temp_array;
8077
+			}
7752 8078
 		}
7753 8079
 
7754 8080
 		return $airport_array;
@@ -7811,7 +8137,9 @@  discard block
 block discarded – undo
7811 8137
 		}
7812 8138
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7813 8139
 					ORDER BY airport_arrival_icao_count DESC";
7814
-		if ($limit) $query .= " LIMIT 10";
8140
+		if ($limit) {
8141
+			$query .= " LIMIT 10";
8142
+		}
7815 8143
       
7816 8144
 		
7817 8145
 		$sth = $this->db->prepare($query);
@@ -7830,7 +8158,9 @@  discard block
 block discarded – undo
7830 8158
 			if ($icaoaskey) {
7831 8159
 				$icao = $row['arrival_airport_icao'];
7832 8160
 				$airport_array[$icao] = $temp_array;
7833
-			} else $airport_array[] = $temp_array;
8161
+			} else {
8162
+				$airport_array[] = $temp_array;
8163
+			}
7834 8164
 		}
7835 8165
 
7836 8166
 		return $airport_array;
@@ -7867,7 +8197,9 @@  discard block
 block discarded – undo
7867 8197
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7868 8198
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7869 8199
 					ORDER BY airport_arrival_icao_count DESC";
7870
-		if ($limit) $query .= " LIMIT 10";
8200
+		if ($limit) {
8201
+			$query .= " LIMIT 10";
8202
+		}
7871 8203
       
7872 8204
 		
7873 8205
 		$sth = $this->db->prepare($query);
@@ -7888,7 +8220,9 @@  discard block
 block discarded – undo
7888 8220
 			if ($icaoaskey) {
7889 8221
 				$icao = $row['arrival_airport_icao'];
7890 8222
 				$airport_array[$icao] = $temp_array;
7891
-			} else $airport_array[] = $temp_array;
8223
+			} else {
8224
+				$airport_array[] = $temp_array;
8225
+			}
7892 8226
 		}
7893 8227
 
7894 8228
 		return $airport_array;
@@ -8269,7 +8603,9 @@  discard block
 block discarded – undo
8269 8603
 			date_default_timezone_set($globalTimezone);
8270 8604
 			$datetime = new DateTime($date);
8271 8605
 			$offset = $datetime->format('P');
8272
-		} else $offset = '+00:00';
8606
+		} else {
8607
+			$offset = '+00:00';
8608
+		}
8273 8609
 
8274 8610
 		if ($globalDBdriver == 'mysql') {
8275 8611
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
@@ -8319,7 +8655,9 @@  discard block
 block discarded – undo
8319 8655
 			date_default_timezone_set($globalTimezone);
8320 8656
 			$datetime = new DateTime($date);
8321 8657
 			$offset = $datetime->format('P');
8322
-		} else $offset = '+00:00';
8658
+		} else {
8659
+			$offset = '+00:00';
8660
+		}
8323 8661
 
8324 8662
 		if ($globalDBdriver == 'mysql') {
8325 8663
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -8710,7 +9048,9 @@  discard block
 block discarded – undo
8710 9048
 		}
8711 9049
 		$query .= " GROUP BY spotter_output.arrival_airport_country
8712 9050
 					ORDER BY airport_arrival_country_count DESC";
8713
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9051
+		if ($limit) {
9052
+			$query .= " LIMIT 10 OFFSET 0";
9053
+		}
8714 9054
       
8715 9055
 		
8716 9056
 		$sth = $this->db->prepare($query);
@@ -8997,7 +9337,9 @@  discard block
 block discarded – undo
8997 9337
 			date_default_timezone_set($globalTimezone);
8998 9338
 			$datetime = new DateTime($date);
8999 9339
 			$offset = $datetime->format('P');
9000
-		} else $offset = '+00:00';
9340
+		} else {
9341
+			$offset = '+00:00';
9342
+		}
9001 9343
 		
9002 9344
 		if ($globalDBdriver == 'mysql') {
9003 9345
 			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
@@ -9253,12 +9595,18 @@  discard block
 block discarded – undo
9253 9595
 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9254 9596
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9255 9597
 		 if ($olderthanmonths > 0) {
9256
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9257
-			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9598
+			if ($globalDBdriver == 'mysql') {
9599
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9600
+			} else {
9601
+				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9602
+			}
9258 9603
 		}
9259 9604
 		if ($sincedate != '') {
9260
-			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'";
9261
-			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9605
+			if ($globalDBdriver == 'mysql') {
9606
+				$query .= " AND spotter_output.date > '".$sincedate."'";
9607
+			} else {
9608
+				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9609
+			}
9262 9610
 		}
9263 9611
 		$query_values = array();
9264 9612
 		if ($year != '') {
@@ -9289,7 +9637,9 @@  discard block
 block discarded – undo
9289 9637
 			}
9290 9638
 		}
9291 9639
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
9292
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9640
+		if ($limit) {
9641
+			$query .= " LIMIT 10 OFFSET 0";
9642
+		}
9293 9643
       		
9294 9644
 		$sth = $this->db->prepare($query);
9295 9645
 		$sth->execute($query_values);
@@ -9323,15 +9673,23 @@  discard block
 block discarded – undo
9323 9673
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9324 9674
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
9325 9675
 		 if ($olderthanmonths > 0) {
9326
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9327
-			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9676
+			if ($globalDBdriver == 'mysql') {
9677
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9678
+			} else {
9679
+				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9680
+			}
9328 9681
 		}
9329 9682
 		if ($sincedate != '') {
9330
-			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' ";
9331
-			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9683
+			if ($globalDBdriver == 'mysql') {
9684
+				$query .= "AND spotter_output.date > '".$sincedate."' ";
9685
+			} else {
9686
+				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9687
+			}
9332 9688
 		}
9333 9689
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
9334
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9690
+		if ($limit) {
9691
+			$query .= " LIMIT 10 OFFSET 0";
9692
+		}
9335 9693
       		
9336 9694
 		$sth = $this->db->prepare($query);
9337 9695
 		$sth->execute();
@@ -9368,7 +9726,9 @@  discard block
 block discarded – undo
9368 9726
 			date_default_timezone_set($globalTimezone);
9369 9727
 			$datetime = new DateTime();
9370 9728
 			$offset = $datetime->format('P');
9371
-		} else $offset = '+00:00';
9729
+		} else {
9730
+			$offset = '+00:00';
9731
+		}
9372 9732
 
9373 9733
 		if ($globalDBdriver == 'mysql') {
9374 9734
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9417,7 +9777,9 @@  discard block
 block discarded – undo
9417 9777
 			date_default_timezone_set($globalTimezone);
9418 9778
 			$datetime = new DateTime();
9419 9779
 			$offset = $datetime->format('P');
9420
-		} else $offset = '+00:00';
9780
+		} else {
9781
+			$offset = '+00:00';
9782
+		}
9421 9783
 		$filter_query = $this->getFilter($filters,true,true);
9422 9784
 		if ($globalDBdriver == 'mysql') {
9423 9785
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9466,7 +9828,9 @@  discard block
 block discarded – undo
9466 9828
 			date_default_timezone_set($globalTimezone);
9467 9829
 			$datetime = new DateTime();
9468 9830
 			$offset = $datetime->format('P');
9469
-		} else $offset = '+00:00';
9831
+		} else {
9832
+			$offset = '+00:00';
9833
+		}
9470 9834
 		$filter_query = $this->getFilter($filters,true,true);
9471 9835
 		if ($globalDBdriver == 'mysql') {
9472 9836
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9512,7 +9876,9 @@  discard block
 block discarded – undo
9512 9876
 			date_default_timezone_set($globalTimezone);
9513 9877
 			$datetime = new DateTime();
9514 9878
 			$offset = $datetime->format('P');
9515
-		} else $offset = '+00:00';
9879
+		} else {
9880
+			$offset = '+00:00';
9881
+		}
9516 9882
 		$filter_query = $this->getFilter($filters,true,true);
9517 9883
 		if ($globalDBdriver == 'mysql') {
9518 9884
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9560,7 +9926,9 @@  discard block
 block discarded – undo
9560 9926
 			date_default_timezone_set($globalTimezone);
9561 9927
 			$datetime = new DateTime();
9562 9928
 			$offset = $datetime->format('P');
9563
-		} else $offset = '+00:00';
9929
+		} else {
9930
+			$offset = '+00:00';
9931
+		}
9564 9932
 		
9565 9933
 		if ($globalDBdriver == 'mysql') {
9566 9934
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9608,7 +9976,9 @@  discard block
 block discarded – undo
9608 9976
 			date_default_timezone_set($globalTimezone);
9609 9977
 			$datetime = new DateTime();
9610 9978
 			$offset = $datetime->format('P');
9611
-		} else $offset = '+00:00';
9979
+		} else {
9980
+			$offset = '+00:00';
9981
+		}
9612 9982
 
9613 9983
 		if ($globalDBdriver == 'mysql') {
9614 9984
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9655,7 +10025,9 @@  discard block
 block discarded – undo
9655 10025
 			date_default_timezone_set($globalTimezone);
9656 10026
 			$datetime = new DateTime();
9657 10027
 			$offset = $datetime->format('P');
9658
-		} else $offset = '+00:00';
10028
+		} else {
10029
+			$offset = '+00:00';
10030
+		}
9659 10031
 
9660 10032
 		if ($globalDBdriver == 'mysql') {
9661 10033
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9703,7 +10075,9 @@  discard block
 block discarded – undo
9703 10075
 			date_default_timezone_set($globalTimezone);
9704 10076
 			$datetime = new DateTime();
9705 10077
 			$offset = $datetime->format('P');
9706
-		} else $offset = '+00:00';
10078
+		} else {
10079
+			$offset = '+00:00';
10080
+		}
9707 10081
 		$filter_query = $this->getFilter($filters,true,true);
9708 10082
 		if ($globalDBdriver == 'mysql') {
9709 10083
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9748,7 +10122,9 @@  discard block
 block discarded – undo
9748 10122
 			date_default_timezone_set($globalTimezone);
9749 10123
 			$datetime = new DateTime();
9750 10124
 			$offset = $datetime->format('P');
9751
-		} else $offset = '+00:00';
10125
+		} else {
10126
+			$offset = '+00:00';
10127
+		}
9752 10128
 		$filter_query = $this->getFilter($filters,true,true);
9753 10129
 
9754 10130
 		if ($globalDBdriver == 'mysql') {
@@ -9795,7 +10171,9 @@  discard block
 block discarded – undo
9795 10171
 			date_default_timezone_set($globalTimezone);
9796 10172
 			$datetime = new DateTime();
9797 10173
 			$offset = $datetime->format('P');
9798
-		} else $offset = '+00:00';
10174
+		} else {
10175
+			$offset = '+00:00';
10176
+		}
9799 10177
 
9800 10178
 		if ($globalDBdriver == 'mysql') {
9801 10179
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
@@ -9841,7 +10219,9 @@  discard block
 block discarded – undo
9841 10219
 			date_default_timezone_set($globalTimezone);
9842 10220
 			$datetime = new DateTime();
9843 10221
 			$offset = $datetime->format('P');
9844
-		} else $offset = '+00:00';
10222
+		} else {
10223
+			$offset = '+00:00';
10224
+		}
9845 10225
 		$filter_query = $this->getFilter($filters,true,true);
9846 10226
 
9847 10227
 		if ($globalDBdriver == 'mysql') {
@@ -9888,7 +10268,9 @@  discard block
 block discarded – undo
9888 10268
 			date_default_timezone_set($globalTimezone);
9889 10269
 			$datetime = new DateTime();
9890 10270
 			$offset = $datetime->format('P');
9891
-		} else $offset = '+00:00';
10271
+		} else {
10272
+			$offset = '+00:00';
10273
+		}
9892 10274
 
9893 10275
 		if ($globalDBdriver == 'mysql') {
9894 10276
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
@@ -9935,7 +10317,9 @@  discard block
 block discarded – undo
9935 10317
 			date_default_timezone_set($globalTimezone);
9936 10318
 			$datetime = new DateTime();
9937 10319
 			$offset = $datetime->format('P');
9938
-		} else $offset = '+00:00';
10320
+		} else {
10321
+			$offset = '+00:00';
10322
+		}
9939 10323
 
9940 10324
 		if ($globalDBdriver == 'mysql') {
9941 10325
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
@@ -9980,7 +10364,9 @@  discard block
 block discarded – undo
9980 10364
 			date_default_timezone_set($globalTimezone);
9981 10365
 			$datetime = new DateTime();
9982 10366
 			$offset = $datetime->format('P');
9983
-		} else $offset = '+00:00';
10367
+		} else {
10368
+			$offset = '+00:00';
10369
+		}
9984 10370
 		$filter_query = $this->getFilter($filters,true,true);
9985 10371
 
9986 10372
 		if ($globalDBdriver == 'mysql') {
@@ -10028,7 +10414,9 @@  discard block
 block discarded – undo
10028 10414
 			date_default_timezone_set($globalTimezone);
10029 10415
 			$datetime = new DateTime();
10030 10416
 			$offset = $datetime->format('P');
10031
-		} else $offset = '+00:00';
10417
+		} else {
10418
+			$offset = '+00:00';
10419
+		}
10032 10420
 
10033 10421
 		if ($globalDBdriver == 'mysql') {
10034 10422
 			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
@@ -10074,7 +10462,9 @@  discard block
 block discarded – undo
10074 10462
 			date_default_timezone_set($globalTimezone);
10075 10463
 			$datetime = new DateTime();
10076 10464
 			$offset = $datetime->format('P');
10077
-		} else $offset = '+00:00';
10465
+		} else {
10466
+			$offset = '+00:00';
10467
+		}
10078 10468
 		$filter_query = $this->getFilter($filters,true,true);
10079 10469
 
10080 10470
 		if ($globalDBdriver == 'mysql') {
@@ -10122,7 +10512,9 @@  discard block
 block discarded – undo
10122 10512
 			date_default_timezone_set($globalTimezone);
10123 10513
 			$datetime = new DateTime();
10124 10514
 			$offset = $datetime->format('P');
10125
-		} else $offset = '+00:00';
10515
+		} else {
10516
+			$offset = '+00:00';
10517
+		}
10126 10518
 
10127 10519
 		if ($globalDBdriver == 'mysql') {
10128 10520
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
@@ -10169,7 +10561,9 @@  discard block
 block discarded – undo
10169 10561
 			date_default_timezone_set($globalTimezone);
10170 10562
 			$datetime = new DateTime();
10171 10563
 			$offset = $datetime->format('P');
10172
-		} else $offset = '+00:00';
10564
+		} else {
10565
+			$offset = '+00:00';
10566
+		}
10173 10567
 		$filter_query = $this->getFilter($filters,true,true);
10174 10568
 		if ($globalDBdriver == 'mysql') {
10175 10569
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -10218,7 +10612,9 @@  discard block
 block discarded – undo
10218 10612
 			date_default_timezone_set($globalTimezone);
10219 10613
 			$datetime = new DateTime();
10220 10614
 			$offset = $datetime->format('P');
10221
-		} else $offset = '+00:00';
10615
+		} else {
10616
+			$offset = '+00:00';
10617
+		}
10222 10618
 
10223 10619
 		$orderby_sql = '';
10224 10620
 		if ($orderby == "hour")
@@ -10284,7 +10680,9 @@  discard block
 block discarded – undo
10284 10680
 			date_default_timezone_set($globalTimezone);
10285 10681
 			$datetime = new DateTime();
10286 10682
 			$offset = $datetime->format('P');
10287
-		} else $offset = '+00:00';
10683
+		} else {
10684
+			$offset = '+00:00';
10685
+		}
10288 10686
 
10289 10687
 		$orderby_sql = '';
10290 10688
 		if ($orderby == "hour")
@@ -10351,7 +10749,9 @@  discard block
 block discarded – undo
10351 10749
 			date_default_timezone_set($globalTimezone);
10352 10750
 			$datetime = new DateTime();
10353 10751
 			$offset = $datetime->format('P');
10354
-		} else $offset = '+00:00';
10752
+		} else {
10753
+			$offset = '+00:00';
10754
+		}
10355 10755
 
10356 10756
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
10357 10757
 
@@ -10402,7 +10802,9 @@  discard block
 block discarded – undo
10402 10802
 			date_default_timezone_set($globalTimezone);
10403 10803
 			$datetime = new DateTime();
10404 10804
 			$offset = $datetime->format('P');
10405
-		} else $offset = '+00:00';
10805
+		} else {
10806
+			$offset = '+00:00';
10807
+		}
10406 10808
 
10407 10809
 		if ($globalDBdriver == 'mysql') {
10408 10810
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10449,7 +10851,9 @@  discard block
 block discarded – undo
10449 10851
 			date_default_timezone_set($globalTimezone);
10450 10852
 			$datetime = new DateTime();
10451 10853
 			$offset = $datetime->format('P');
10452
-		} else $offset = '+00:00';
10854
+		} else {
10855
+			$offset = '+00:00';
10856
+		}
10453 10857
 
10454 10858
 		if ($globalDBdriver == 'mysql') {
10455 10859
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10496,7 +10900,9 @@  discard block
 block discarded – undo
10496 10900
 			date_default_timezone_set($globalTimezone);
10497 10901
 			$datetime = new DateTime();
10498 10902
 			$offset = $datetime->format('P');
10499
-		} else $offset = '+00:00';
10903
+		} else {
10904
+			$offset = '+00:00';
10905
+		}
10500 10906
 
10501 10907
 		if ($globalDBdriver == 'mysql') {
10502 10908
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10544,7 +10950,9 @@  discard block
 block discarded – undo
10544 10950
 			date_default_timezone_set($globalTimezone);
10545 10951
 			$datetime = new DateTime();
10546 10952
 			$offset = $datetime->format('P');
10547
-		} else $offset = '+00:00';
10953
+		} else {
10954
+			$offset = '+00:00';
10955
+		}
10548 10956
 
10549 10957
 		if ($globalDBdriver == 'mysql') {
10550 10958
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10592,7 +11000,9 @@  discard block
 block discarded – undo
10592 11000
 			date_default_timezone_set($globalTimezone);
10593 11001
 			$datetime = new DateTime($date);
10594 11002
 			$offset = $datetime->format('P');
10595
-		} else $offset = '+00:00';
11003
+		} else {
11004
+			$offset = '+00:00';
11005
+		}
10596 11006
 
10597 11007
 		if ($globalDBdriver == 'mysql') {
10598 11008
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10640,7 +11050,9 @@  discard block
 block discarded – undo
10640 11050
 			date_default_timezone_set($globalTimezone);
10641 11051
 			$datetime = new DateTime();
10642 11052
 			$offset = $datetime->format('P');
10643
-		} else $offset = '+00:00';
11053
+		} else {
11054
+			$offset = '+00:00';
11055
+		}
10644 11056
 
10645 11057
 		if ($globalDBdriver == 'mysql') {
10646 11058
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10687,7 +11099,9 @@  discard block
 block discarded – undo
10687 11099
 			date_default_timezone_set($globalTimezone);
10688 11100
 			$datetime = new DateTime();
10689 11101
 			$offset = $datetime->format('P');
10690
-		} else $offset = '+00:00';
11102
+		} else {
11103
+			$offset = '+00:00';
11104
+		}
10691 11105
 
10692 11106
 		if ($globalDBdriver == 'mysql') {
10693 11107
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10734,7 +11148,9 @@  discard block
 block discarded – undo
10734 11148
 			date_default_timezone_set($globalTimezone);
10735 11149
 			$datetime = new DateTime();
10736 11150
 			$offset = $datetime->format('P');
10737
-		} else $offset = '+00:00';
11151
+		} else {
11152
+			$offset = '+00:00';
11153
+		}
10738 11154
 
10739 11155
 		if ($globalDBdriver == 'mysql') {
10740 11156
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10784,7 +11200,9 @@  discard block
 block discarded – undo
10784 11200
 			date_default_timezone_set($globalTimezone);
10785 11201
 			$datetime = new DateTime();
10786 11202
 			$offset = $datetime->format('P');
10787
-		} else $offset = '+00:00';
11203
+		} else {
11204
+			$offset = '+00:00';
11205
+		}
10788 11206
 
10789 11207
 		if ($globalDBdriver == 'mysql') {
10790 11208
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10831,7 +11249,9 @@  discard block
 block discarded – undo
10831 11249
 			date_default_timezone_set($globalTimezone);
10832 11250
 			$datetime = new DateTime();
10833 11251
 			$offset = $datetime->format('P');
10834
-		} else $offset = '+00:00';
11252
+		} else {
11253
+			$offset = '+00:00';
11254
+		}
10835 11255
 
10836 11256
 		if ($globalDBdriver == 'mysql') {
10837 11257
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -11042,8 +11462,11 @@  discard block
 block discarded – undo
11042 11462
 				$query_values = array_merge($query_values,array(':month' => $month));
11043 11463
 			}
11044 11464
 		}
11045
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
11046
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11465
+		if (empty($query_values)) {
11466
+			$queryi .= $this->getFilter($filters);
11467
+		} else {
11468
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11469
+		}
11047 11470
 		
11048 11471
 		$sth = $this->db->prepare($queryi);
11049 11472
 		$sth->execute($query_values);
@@ -11121,8 +11544,11 @@  discard block
 block discarded – undo
11121 11544
 				$query_values = array_merge($query_values,array(':month' => $month));
11122 11545
 			}
11123 11546
 		}
11124
-                if ($query == '') $queryi .= $this->getFilter($filters);
11125
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11547
+                if ($query == '') {
11548
+                	$queryi .= $this->getFilter($filters);
11549
+                } else {
11550
+                	$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11551
+                }
11126 11552
 
11127 11553
 
11128 11554
 		$sth = $this->db->prepare($queryi);
@@ -11145,7 +11571,9 @@  discard block
 block discarded – undo
11145 11571
 			date_default_timezone_set($globalTimezone);
11146 11572
 			$datetime = new DateTime();
11147 11573
 			$offset = $datetime->format('P');
11148
-		} else $offset = '+00:00';
11574
+		} else {
11575
+			$offset = '+00:00';
11576
+		}
11149 11577
 
11150 11578
 		if ($globalDBdriver == 'mysql') {
11151 11579
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -11331,7 +11759,9 @@  discard block
 block discarded – undo
11331 11759
 	*/
11332 11760
 	public function parseDirection($direction = 0)
11333 11761
 	{
11334
-		if ($direction == '') $direction = 0;
11762
+		if ($direction == '') {
11763
+			$direction = 0;
11764
+		}
11335 11765
 		$direction_array = array();
11336 11766
 		$temp_array = array();
11337 11767
 
@@ -11432,7 +11862,9 @@  discard block
 block discarded – undo
11432 11862
 		if (isset($result->AirlineFlightInfoResult))
11433 11863
 		{
11434 11864
 			$registration = $result->AirlineFlightInfoResult->tailnumber;
11435
-		} else return '';
11865
+		} else {
11866
+			return '';
11867
+		}
11436 11868
 		
11437 11869
 		$registration = $this->convertAircraftRegistration($registration);
11438 11870
 		
@@ -11466,7 +11898,9 @@  discard block
 block discarded – undo
11466 11898
 		    return $row['registration'];
11467 11899
 		} elseif ($source_type == 'flarm') {
11468 11900
 			return $this->getAircraftRegistrationBymodeS($aircraft_modes);
11469
-		} else return '';
11901
+		} else {
11902
+			return '';
11903
+		}
11470 11904
 	
11471 11905
 	}
11472 11906
 
@@ -11493,11 +11927,16 @@  discard block
 block discarded – undo
11493 11927
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11494 11928
 		$sth->closeCursor();
11495 11929
 		if (count($row) > 0) {
11496
-			if ($row['type_flight'] == null) return '';
11497
-			else return $row['type_flight'];
11930
+			if ($row['type_flight'] == null) {
11931
+				return '';
11932
+			} else {
11933
+				return $row['type_flight'];
11934
+			}
11498 11935
 		} elseif ($source_type == 'flarm') {
11499 11936
 			return $this->getAircraftTypeBymodeS($aircraft_modes);
11500
-		} else return '';
11937
+		} else {
11938
+			return '';
11939
+		}
11501 11940
 	
11502 11941
 	}
11503 11942
 
@@ -11515,7 +11954,9 @@  discard block
 block discarded – undo
11515 11954
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11516 11955
 	
11517 11956
 		$Connection = new Connection($this->db);
11518
-		if (!$Connection->tableExists('countries')) return '';
11957
+		if (!$Connection->tableExists('countries')) {
11958
+			return '';
11959
+		}
11519 11960
 	
11520 11961
 		try {
11521 11962
 			/*
@@ -11535,9 +11976,13 @@  discard block
 block discarded – undo
11535 11976
 			$sth->closeCursor();
11536 11977
 			if (count($row) > 0) {
11537 11978
 				return $row;
11538
-			} else return '';
11979
+			} else {
11980
+				return '';
11981
+			}
11539 11982
 		} catch (PDOException $e) {
11540
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
11983
+			if (isset($globalDebug) && $globalDebug) {
11984
+				echo 'Error : '.$e->getMessage()."\n";
11985
+			}
11541 11986
 			return '';
11542 11987
 		}
11543 11988
 	
@@ -11555,7 +12000,9 @@  discard block
 block discarded – undo
11555 12000
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
11556 12001
 	
11557 12002
 		$Connection = new Connection($this->db);
11558
-		if (!$Connection->tableExists('countries')) return '';
12003
+		if (!$Connection->tableExists('countries')) {
12004
+			return '';
12005
+		}
11559 12006
 	
11560 12007
 		try {
11561 12008
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -11567,9 +12014,13 @@  discard block
 block discarded – undo
11567 12014
 			$sth->closeCursor();
11568 12015
 			if (count($row) > 0) {
11569 12016
 				return $row;
11570
-			} else return '';
12017
+			} else {
12018
+				return '';
12019
+			}
11571 12020
 		} catch (PDOException $e) {
11572
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
12021
+			if (isset($globalDebug) && $globalDebug) {
12022
+				echo 'Error : '.$e->getMessage()."\n";
12023
+			}
11573 12024
 			return '';
11574 12025
 		}
11575 12026
 	
@@ -11819,7 +12270,9 @@  discard block
 block discarded – undo
11819 12270
 	{
11820 12271
 		global $globalBitlyAccessToken;
11821 12272
 		
11822
-		if ($globalBitlyAccessToken == '') return $url;
12273
+		if ($globalBitlyAccessToken == '') {
12274
+			return $url;
12275
+		}
11823 12276
         
11824 12277
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
11825 12278
 		
@@ -11968,7 +12421,9 @@  discard block
 block discarded – undo
11968 12421
 		
11969 12422
 
11970 12423
 		// routes
11971
-		if ($globalDebug) print "Routes...\n";
12424
+		if ($globalDebug) {
12425
+			print "Routes...\n";
12426
+		}
11972 12427
 		if ($globalDBdriver == 'mysql') {
11973 12428
 			$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
11974 12429
 		} else {
@@ -11987,7 +12442,9 @@  discard block
 block discarded – undo
11987 12442
 			}
11988 12443
 		}
11989 12444
 		
11990
-		if ($globalDebug) print "Airlines...\n";
12445
+		if ($globalDebug) {
12446
+			print "Airlines...\n";
12447
+		}
11991 12448
 		//airlines
11992 12449
 		if ($globalDBdriver == 'mysql') {
11993 12450
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
@@ -12001,10 +12458,15 @@  discard block
 block discarded – undo
12001 12458
 			if (is_numeric(substr($row['ident'], -1, 1)))
12002 12459
 			{
12003 12460
 				$fromsource = NULL;
12004
-				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
12005
-				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
12006
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
12007
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
12461
+				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
12462
+					$fromsource = 'vatsim';
12463
+				} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
12464
+					$fromsource = 'ivao';
12465
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
12466
+					$fromsource = 'vatsim';
12467
+				} elseif (isset($globalIVAO) && $globalIVAO) {
12468
+					$fromsource = 'ivao';
12469
+				}
12008 12470
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
12009 12471
 				if (isset($airline_array[0]['name'])) {
12010 12472
 					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
@@ -12014,13 +12476,17 @@  discard block
 block discarded – undo
12014 12476
 			}
12015 12477
 		}
12016 12478
 
12017
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
12479
+		if ($globalDebug) {
12480
+			print "Remove Duplicate in aircraft_modes...\n";
12481
+		}
12018 12482
 		//duplicate modes
12019 12483
 		$query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL";
12020 12484
 		$sth = $this->db->prepare($query);
12021 12485
 		$sth->execute();
12022 12486
 		
12023
-		if ($globalDebug) print "Aircraft...\n";
12487
+		if ($globalDebug) {
12488
+			print "Aircraft...\n";
12489
+		}
12024 12490
 		//aircraft
12025 12491
 		if ($globalDBdriver == 'mysql') {
12026 12492
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -12063,26 +12529,38 @@  discard block
 block discarded – undo
12063 12529
 				 if (isset($closestAirports[0])) {
12064 12530
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
12065 12531
 						$airport_icao = $closestAirports[0]['icao'];
12066
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12532
+						if ($globalDebug) {
12533
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12534
+						}
12067 12535
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
12068 12536
 						foreach ($closestAirports as $airport) {
12069 12537
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
12070 12538
 								$airport_icao = $airport['icao'];
12071
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12539
+								if ($globalDebug) {
12540
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12541
+								}
12072 12542
 								break;
12073 12543
 							}
12074 12544
 						}
12075 12545
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
12076 12546
 						$airport_icao = $closestAirports[0]['icao'];
12077
-						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12547
+						if ($globalDebug) {
12548
+							echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12549
+						}
12078 12550
 					} else {
12079
-						if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12551
+						if ($globalDebug) {
12552
+							echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12553
+						}
12080 12554
 					}
12081 12555
 				} else {
12082
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12556
+					if ($globalDebug) {
12557
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12558
+					}
12083 12559
 				}
12084 12560
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
12085
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
12561
+					if ($globalDebug) {
12562
+						echo "Updating airport to ".$airport_icao."...\n";
12563
+					}
12086 12564
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12087 12565
 					$sthu = $this->db->prepare($update_query);
12088 12566
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.
require/class.AIS.php 1 patch
Braces   +109 added lines, -39 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
 			$temp += 1;
36 36
 			$flat = (float)($temp / (60.0 * 10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else {
39
+			$flat = (float)($temp / (60.0 * 10000.0));
40
+		}
39 41
 		return $flat; // float
40 42
 	}
41 43
 
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
 			$temp += 1;
48 50
 			$flon = (float)($temp / (60.0 * 10000.0));
49 51
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
52
+		} else {
53
+			$flon = (float)($temp / (60.0 * 10000.0));
54
+		}
51 55
 		return $flon;
52 56
 	}
53 57
 
@@ -70,10 +74,8 @@  discard block
 block discarded – undo
70 74
     */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73
-		if ($ascii < 48) { }
74
-		else {
75
-			if($ascii>119) { }
76
-			else {
77
+		if ($ascii < 48) { } else {
78
+			if($ascii>119) { } else {
77 79
 				if ($ascii>87 && $ascii<96) ;
78 80
 				else {
79 81
 					$ascii=$ascii+40;
@@ -236,19 +238,34 @@  discard block
 block discarded – undo
236 238
 		// assume 1st ! is valid
237 239
 		// find * ensure that it is at correct position
238 240
 		$end = strrpos ( $rawdata , '*' );
239
-		if ($end === FALSE) return -1; // check for NULLS!!!
241
+		if ($end === FALSE) {
242
+			return -1;
243
+		}
244
+		// check for NULLS!!!
240 245
 		$cs = substr( $rawdata, $end + 1 );
241
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
246
+		if ( strlen($cs) != 2 ) {
247
+			return -1;
248
+		}
249
+		// correct cs length
242 250
 		$dcs = (int)hexdec( $cs );
243
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
251
+		for ( $alias=1; $alias<$end; $alias++) {
252
+			$chksum ^= ord( $rawdata[$alias] );
253
+		}
254
+		// perform XOR for NMEA checksum
244 255
 		if ( $chksum == $dcs ) { // NMEA checksum pass
245 256
 			$pcs = explode(',', $rawdata);
246 257
 			// !AI??? identifier
247 258
 			$num_seq = (int)$pcs[1]; // number of sequences
248 259
 			$seq = (int)$pcs[2]; // get sequence
249 260
 			// get msg sequence id
250
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
251
-			else $msg_sid = (int)$pcs[3]; // multipart message
261
+			if ($pcs[3] == '') {
262
+				$msg_sid = -1;
263
+			}
264
+			// non-multipart message, set to -1
265
+			else {
266
+				$msg_sid = (int)$pcs[3];
267
+			}
268
+			// multipart message
252 269
 			$ais_ch = $pcs[4]; // get AIS channel
253 270
 			// message sequence checking
254 271
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -309,10 +326,18 @@  discard block
 block discarded – undo
309 326
 				//DEBUG echo "[$start $end $tst]\n";
310 327
 				$result = $this->process_ais_raw( $tst, "" );
311 328
 				$last_pos = $end + 1;
312
-			} else break;
329
+			} else {
330
+				break;
331
+			}
332
+		}
333
+		if ($last_pos > 0) {
334
+			$cbuf = substr($cbuf, $last_pos);
313 335
 		}
314
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
315
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
336
+		// move...
337
+		if (strlen($cbuf) > 1024) {
338
+			$cbuf = "";
339
+		}
340
+		// prevent overflow simple mode...
316 341
 		return $result;
317 342
 	}
318 343
 
@@ -332,7 +357,9 @@  discard block
 block discarded – undo
332 357
 		if ($lat<0.0) {
333 358
 			$lat = -$lat;
334 359
 			$neg=true;
335
-		} else $neg=false;
360
+		} else {
361
+			$neg=false;
362
+		}
336 363
 		$latd = 0x00000000;
337 364
 		$latd = intval ($lat * 600000.0);
338 365
 		if ($neg==true) {
@@ -348,7 +375,9 @@  discard block
 block discarded – undo
348 375
 		if ($lon<0.0) {
349 376
 			$lon = -$lon;
350 377
 			$neg=true;
351
-		} else $neg=false;
378
+		} else {
379
+			$neg=false;
380
+		}
352 381
 		$lond = 0x00000000;
353 382
 		$lond = intval ($lon * 600000.0);
354 383
 		if ($neg==true) {
@@ -361,9 +390,14 @@  discard block
 block discarded – undo
361 390
 
362 391
 	private function char2bin($name, $max_len) {
363 392
 		$len = strlen($name);
364
-		if ($len > $max_len) $name = substr($name,0,$max_len);
365
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
366
-		else $pad = '';
393
+		if ($len > $max_len) {
394
+			$name = substr($name,0,$max_len);
395
+		}
396
+		if ($len < $max_len) {
397
+			$pad = str_repeat('0', ($max_len - $len) * 6);
398
+		} else {
399
+			$pad = '';
400
+		}
367 401
 		$rv = '';
368 402
 		$ais_chars = array(
369 403
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -375,9 +409,12 @@  discard block
 block discarded – undo
375 409
 		    '<'=>60, '='=>61, '>'=>62, '?'=>63
376 410
 		);
377 411
 		$_a = str_split($name);
378
-		if ($_a) foreach ($_a as $_1) {
412
+		if ($_a) {
413
+			foreach ($_a as $_1) {
379 414
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
380
-			else $dec = 0;
415
+		} else {
416
+				$dec = 0;
417
+			}
381 418
 			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
382 419
 			$rv .= $bin;
383 420
 			//echo "$_1 $dec ($bin)<br/>";
@@ -389,7 +426,9 @@  discard block
 block discarded – undo
389 426
 		$len_bit = strlen($_enc);
390 427
 		$rem6 = $len_bit % 6;
391 428
 		$pad6_len = 0;
392
-		if ($rem6) $pad6_len = 6 - $rem6;
429
+		if ($rem6) {
430
+			$pad6_len = 6 - $rem6;
431
+		}
393 432
 		//echo  $pad6_len.'<br>';
394 433
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
395 434
 		$len_enc = strlen($_enc) / 6;
@@ -398,8 +437,11 @@  discard block
 block discarded – undo
398 437
 		for ($i=0; $i<$len_enc; $i++) {
399 438
 			$offset = $i * 6;
400 439
 			$dec = bindec(substr($_enc,$offset,6));
401
-			if ($dec < 40) $dec += 48;
402
-			else $dec += 56;
440
+			if ($dec < 40) {
441
+				$dec += 48;
442
+			} else {
443
+				$dec += 56;
444
+			}
403 445
 			//echo chr($dec)." $dec<br/>";
404 446
 			$itu .= chr($dec);
405 447
 		}
@@ -412,25 +454,41 @@  discard block
 block discarded – undo
412 454
 		}
413 455
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
414 456
 		$lsb = $chksum & 0x0F;
415
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
416
-		else $lsbc = '0';
457
+		if ($lsb >=0 && $lsb <= 15 ) {
458
+			$lsbc = $hex_arr[$lsb];
459
+		} else {
460
+			$lsbc = '0';
461
+		}
417 462
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
418
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
419
-		else $msbc = '0';
463
+		if ($msb >=0 && $msb <= 15 ) {
464
+			$msbc = $hex_arr[$msb];
465
+		} else {
466
+			$msbc = '0';
467
+		}
420 468
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
421 469
 		return $itu;
422 470
 	}
423 471
 
424 472
 	public function parse($buffer) {
425 473
 		$data = $this->process_ais_buf($buffer);
426
-		if (!is_object($data)) return array();
427
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
428
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
474
+		if (!is_object($data)) {
475
+			return array();
476
+		}
477
+		if ($data->lon != 0) {
478
+			$result['longitude'] = $data->lon;
479
+		}
480
+		if ($data->lat != 0) {
481
+			$result['latitude'] = $data->lat;
482
+		}
429 483
 		$result['ident'] = trim($data->name);
430 484
 		$result['timestamp'] = $data->ts;
431 485
 		$result['mmsi'] = $data->mmsi;
432
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
433
-		if ($data->cog != 0) $result['heading'] = $data->cog;
486
+		if ($data->sog != -1.0) {
487
+			$result['speed'] = $data->sog;
488
+		}
489
+		if ($data->cog != 0) {
490
+			$result['heading'] = $data->cog;
491
+		}
434 492
 		/*
435 493
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
436 494
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -444,15 +502,27 @@  discard block
 block discarded – undo
444 502
 		$start = strpos($buffer,"VDM");
445 503
 		$tst = substr($buffer, $start - 3);
446 504
 		$data = $this->process_ais_raw( $tst, "" );
447
-		if (!is_object($data)) return array();
448
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
449
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
505
+		if (!is_object($data)) {
506
+			return array();
507
+		}
508
+		if ($data->lon != 0) {
509
+			$result['longitude'] = $data->lon;
510
+		}
511
+		if ($data->lat != 0) {
512
+			$result['latitude'] = $data->lat;
513
+		}
450 514
 		$result['ident'] = trim(str_replace('@','',$data->name));
451 515
 		$result['timestamp'] = $data->ts;
452 516
 		$result['mmsi'] = $data->mmsi;
453
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
454
-		if ($data->cog != 0) $result['heading'] = $data->cog;
455
-		if ($data->status != '') $result['status'] = $data->status;
517
+		if ($data->sog != -1.0) {
518
+			$result['speed'] = $data->sog;
519
+		}
520
+		if ($data->cog != 0) {
521
+			$result['heading'] = $data->cog;
522
+		}
523
+		if ($data->status != '') {
524
+			$result['status'] = $data->status;
525
+		}
456 526
 		$result['all'] = (array) $data;
457 527
 		/*
458 528
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
Please login to merge, or discard this patch.