Completed
Push — master ( 4b9f50...005bcb )
by Yannick
28:37
created
index.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     <?php }; if (isset($globalSatellite) && $globalSatellite) { ?><td><div id="ibxsatellite"><h4><?php echo _("Satellites Displayed"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?>
47 47
 </tr></table></div>
48 48
 <?php
49
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
49
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
50 50
 ?>
51 51
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script>
52 52
 <?php
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script>
71 71
 <?php
72 72
 	}
73
-    }
73
+	}
74 74
 ?>
75 75
 
76 76
 <div id="sidebar" class="sidebar collapsed">
@@ -81,34 +81,34 @@  discard block
 block discarded – undo
81 81
 	<li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
82 82
 	<li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
83 83
 <?php
84
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
84
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
85 85
 	if (isset($globalArchive) && $globalArchive == TRUE) {
86 86
 ?>
87 87
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
88 88
 <?php
89 89
 	}
90
-    }
90
+	}
91 91
 ?>
92 92
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
93 93
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
94 94
 	<li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li>
95 95
 <?php
96
-    if (isset($globalMap3D) && $globalMap3D) {
96
+	if (isset($globalMap3D) && $globalMap3D) {
97 97
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
98 98
 ?>
99 99
 	<li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
100 100
 <?php
101
-        } else {
102
-    	    if (isset($globalSatellite) && $globalSatellite) {
101
+		} else {
102
+			if (isset($globalSatellite) && $globalSatellite) {
103 103
 ?>
104 104
 	<li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li>
105 105
 <?php
106
-	    }
106
+		}
107 107
 ?>
108 108
 	<li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
109 109
 <?php
110 110
 	}
111
-    }
111
+	}
112 112
 ?>
113 113
     </ul>
114 114
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 ?>
184 184
         </div>
185 185
 <?php
186
-    if (isset($globalArchive) && $globalArchive == TRUE) {
186
+	if (isset($globalArchive) && $globalArchive == TRUE) {
187 187
 ?>
188 188
         <div class="sidebar-pane" id="archive">
189 189
 	    <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	    </form>
244 244
 	</div>
245 245
 <?php
246
-    }
246
+	}
247 247
 ?>
248 248
         <div class="sidebar-pane" id="settings">
249 249
 	    <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -254,56 +254,56 @@  discard block
 block discarded – undo
254 254
 			    <?php
255 255
 				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
256 256
 				else $MapType = $_COOKIE['MapType'];
257
-			    ?>
257
+				?>
258 258
 			    <?php
259 259
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
260
-			    ?>
260
+				?>
261 261
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
262 262
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
263 263
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
264 264
 			    <?php
265 265
 				}
266
-			    ?>
266
+				?>
267 267
 			    <?php
268
-			        if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
269
-			    ?>
268
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
269
+				?>
270 270
 			    <?php
271
-				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
272
-			    ?>
271
+					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
272
+				?>
273 273
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
274 274
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
275 275
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
276 276
 			    <?php
277
-				    }
278
-			    ?>
277
+					}
278
+				?>
279 279
 			    <?php
280
-				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
281
-			    ?>
280
+					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
281
+				?>
282 282
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
283 283
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
284 284
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
285 285
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
286 286
 			    <?php
287
-				    }
288
-			    ?>
287
+					}
288
+				?>
289 289
 			    <?php
290
-				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
291
-			    ?>
290
+					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
291
+				?>
292 292
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
293 293
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
294 294
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
295 295
 			    <?php
296
-				    }
297
-			    ?>
296
+					}
297
+				?>
298 298
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
299 299
 			    <?php
300 300
 				}
301
-			    ?>
301
+				?>
302 302
 			    <?php
303
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
303
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
304 304
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
305 305
 					else $MapBoxId = $_COOKIE['MapTypeId'];
306
-			    ?>
306
+				?>
307 307
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
308 308
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
309 309
 			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
@@ -317,13 +317,13 @@  discard block
 block discarded – undo
317 317
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
318 318
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
319 319
 			    <?php
320
-				    }
321
-			    ?>
320
+					}
321
+				?>
322 322
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
323 323
 			</select>
324 324
 		    </li>
325 325
 <?php
326
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
326
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
327 327
 ?>
328 328
 		    <li><?php echo _("Type of Terrain:"); ?>
329 329
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 			</select>
335 335
 		    </li>
336 336
 <?php
337
-    }
337
+	}
338 338
 ?>
339 339
 <?php
340
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
340
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
341 341
 ?>
342 342
 		    
343 343
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
@@ -346,89 +346,89 @@  discard block
 block discarded – undo
346 346
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || !isset($_COOKIE['MapRemainingRoute']) || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) print 'checked'; ?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
347 347
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
348 348
 <?php
349
-    }
349
+	}
350 350
 ?>
351 351
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
352 352
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li>
353 353
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayweatherstation" value="1" onclick="clickDisplayWeatherStation(this)" <?php if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) print 'checked'; ?> ><?php echo _("Display weather station on map"); ?></label></div></li>
354 354
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaylightning" value="1" onclick="clickDisplayLightning(this)" <?php if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) print 'checked'; ?> ><?php echo _("Display lightning on map"); ?></label></div></li>
355 355
 <?php
356
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
356
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
357 357
 ?>
358 358
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
359 359
 <?php
360
-    }
361
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
360
+	}
361
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
362 362
 ?>
363 363
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li>
364 364
 <?php
365
-    }
365
+	}
366 366
 ?>
367 367
 
368 368
 		    <?php
369 369
 			if (function_exists('array_column')) {
370
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
371
-		    ?>
370
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
371
+			?>
372 372
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
373 373
 		    <?php
374
-			    }
374
+				}
375 375
 			} elseif (isset($globalSources)) {
376
-			    $dispolar = false;
377
-			    foreach ($globalSources as $testsource) {
378
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
379
-			    }
380
-			    if ($dispolar) {
381
-		    ?>
376
+				$dispolar = false;
377
+				foreach ($globalSources as $testsource) {
378
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
379
+				}
380
+				if ($dispolar) {
381
+			?>
382 382
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
383 383
 		    <?php
384
-			    }
385
-		        }
386
-		    ?>
384
+				}
385
+				}
386
+			?>
387 387
 <?php
388
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
388
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
389 389
 ?>
390 390
 
391 391
 		    <?php
392 392
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
393
-		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
394
-		    ?>
393
+					if (extension_loaded('gd') && function_exists('gd_info')) {
394
+			?>
395 395
 		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
396 396
 		    <?php 
397 397
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
398
-		    ?>
398
+			?>
399 399
 		    <li><?php echo _("Aircraft icon color:"); ?>
400 400
 			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
401 401
 		    </li>
402 402
 		    <?php
403 403
 				}
404
-			    }
405
-		        }
406
-		    ?>
404
+				}
405
+				}
406
+			?>
407 407
 		    <?php
408 408
 			if (isset($globalMarine) && $globalMarine === TRUE) {
409
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
410
-		    ?>
409
+				if (extension_loaded('gd') && function_exists('gd_info')) {
410
+			?>
411 411
 		    <li><?php echo _("Marine icon color:"); ?>
412 412
 			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
413 413
 		    </li>
414 414
 		    <?php
415
-			    }
416
-		        }
417
-		    ?>
415
+				}
416
+				}
417
+			?>
418 418
 		    <?php
419 419
 			if (isset($globalTracker) && $globalTracker === TRUE) {
420
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
421
-		    ?>
420
+				if (extension_loaded('gd') && function_exists('gd_info')) {
421
+			?>
422 422
 		    <li><?php echo _("Tracker icon color:"); ?>
423 423
 			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>">
424 424
 		    </li>
425 425
 		    <?php
426
-			    }
427
-		        }
428
-		    ?>
426
+				}
427
+				}
428
+			?>
429 429
 		    <?php
430 430
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
431
-		    ?>
431
+			?>
432 432
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
433 433
 			<div class="range">
434 434
 			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 		    </li>
438 438
 		    <?php
439 439
 			}
440
-		    ?>
440
+			?>
441 441
 <?php
442
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
442
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
443 443
 ?>
444 444
 <?php
445 445
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 		    </li>
471 471
 <?php
472 472
 	}
473
-    }
473
+	}
474 474
 ?>
475 475
 		    <li><?php echo _("Distance unit:"); ?>
476 476
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -503,19 +503,19 @@  discard block
 block discarded – undo
503 503
 		    <ul>
504 504
 		    <?php
505 505
 			if (!isset($globalAircraft) || $globalAircraft) {
506
-		    ?>
506
+			?>
507 507
 		    <?php
508 508
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
509
-		    ?>
509
+			?>
510 510
 			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
511 511
 			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
512 512
 			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
513 513
 		    <?php
514 514
 			}
515
-		    ?>
515
+			?>
516 516
 		    <?php
517 517
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
518
-		    ?>
518
+			?>
519 519
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
520 520
 			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
521 521
 			<?php } ?>
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 			<?php } ?>
525 525
 		    <?php
526 526
 			}
527
-		    ?>
527
+			?>
528 528
 		    <li><?php echo _("Display airlines:"); ?>
529 529
 		    <br/>
530 530
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -544,14 +544,14 @@  discard block
 block discarded – undo
544 544
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
545 545
 					}
546 546
 				}
547
-			    ?>
547
+				?>
548 548
 			</select>
549 549
 		    </li>
550 550
 		    <?php
551 551
 			$Spotter = new Spotter();
552 552
 			$allalliancenames = $Spotter->getAllAllianceNames();
553 553
 			if (!empty($allalliancenames)) {
554
-		    ?>
554
+			?>
555 555
 		    <li><?php echo _("Display alliance:"); ?>
556 556
 		    <br/>
557 557
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -565,18 +565,18 @@  discard block
 block discarded – undo
565 565
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
566 566
 					}
567 567
 				}
568
-			    ?>
568
+				?>
569 569
 			</select>
570 570
 		    </li>
571 571
 		    <?php
572 572
 			}
573
-		    ?>
573
+			?>
574 574
 		    <?php
575 575
 			}
576
-		    ?>
576
+			?>
577 577
 		    <?php
578 578
 			if (isset($globalAPRS) && $globalAPRS) {
579
-		    ?>
579
+			?>
580 580
 		    <li><?php echo _("Display APRS sources name:"); ?>
581 581
 			<select class="selectpicker" multiple onchange="sources(this);">
582 582
 			    <?php
@@ -588,18 +588,18 @@  discard block
 block discarded – undo
588 588
 						echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>';
589 589
 					}
590 590
 				}
591
-			    ?>
591
+				?>
592 592
 			</select>
593 593
 		    </li>
594 594
 		    <?php
595 595
 			}
596
-		    ?>
596
+			?>
597 597
 		    <?php
598 598
 			if (!isset($globalAircraft) && $globalAircraft) {
599
-		    ?>
599
+			?>
600 600
 		    <?php
601 601
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
602
-		    ?>
602
+			?>
603 603
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
604 604
 			<select class="selectpicker" onchange="airlinestype(this);">
605 605
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -610,14 +610,14 @@  discard block
 block discarded – undo
610 610
 		    </li>
611 611
 		    <?php
612 612
 			}
613
-		    ?>
613
+			?>
614 614
 		    <li>
615 615
 			<?php echo _("Display flight with ident:"); ?>
616 616
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
617 617
 		    </li>
618 618
 		    <?php
619 619
 			}
620
-		    ?>
620
+			?>
621 621
 		</ul>
622 622
 	    </form>
623 623
 	    <form method="post">
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 	    </form>
627 627
     	</div>
628 628
 <?php
629
-    if (isset($globalSatellite) && $globalSatellite && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
629
+	if (isset($globalSatellite) && $globalSatellite && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
630 630
 ?>
631 631
         <div class="sidebar-pane" id="satellites">
632 632
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -666,14 +666,14 @@  discard block
 block discarded – undo
666 666
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
667 667
 					}
668 668
 				}
669
-			    ?>
669
+				?>
670 670
 			</select>
671 671
 		    </li>
672 672
 		</ul>
673 673
 	    </form>
674 674
 	</div>
675 675
 <?php
676
-    }
676
+	}
677 677
 ?>
678 678
     </div>
679 679
 </div>
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
7 7
 	public $latest_schema = 46;
8 8
 	
9 9
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10
-	    global $globalNoDB;
11
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
10
+		global $globalNoDB;
11
+		if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 		$this->db = null;
13
-	    } else {
13
+		} else {
14 14
 		if ($dbc === null) {
15
-		    if ($this->db === null && $dbname === null) {
15
+			if ($this->db === null && $dbname === null) {
16 16
 			if ($user === null && $pass === null) {
17
-			    $this->createDBConnection();
17
+				$this->createDBConnection();
18 18
 			} else {
19
-			    $this->createDBConnection(null,$user,$pass);
19
+				$this->createDBConnection(null,$user,$pass);
20 20
 			}
21
-		    } else {
21
+			} else {
22 22
 			$this->createDBConnection($dbname);
23
-		    }
23
+			}
24 24
 		} elseif ($dbname === null || $dbname === 'default') {
25
-	    	    $this->db = $dbc;
26
-	    	    if ($this->connectionExists() === false) {
25
+				$this->db = $dbc;
26
+				if ($this->connectionExists() === false) {
27 27
 			/*
28 28
 			echo 'Restart Connection !!!'."\n";
29 29
 			$e = new \Exception;
30 30
 			var_dump($e->getTraceAsString());
31 31
 			*/
32 32
 			$this->createDBConnection();
33
-		    }
33
+			}
34 34
 		} else {
35
-		    //$this->connectionExists();
36
-		    $this->dbs[$dbname] = $dbc;
35
+			//$this->connectionExists();
36
+			$this->dbs[$dbname] = $dbc;
37
+		}
37 38
 		}
38
-	    }
39 39
 	}
40 40
 
41 41
 	public function db() {
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 	}
57 57
 
58 58
 	/**
59
-	* Creates the database connection
60
-	*
61
-	* @return Boolean of the database connection
62
-	*
63
-	*/
59
+	 * Creates the database connection
60
+	 *
61
+	 * @return Boolean of the database connection
62
+	 *
63
+	 */
64 64
 
65 65
 	public function createDBConnection($DBname = null, $user = null, $pass = null)
66 66
 	{
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			return false;
159 159
 		}
160 160
 		if($results->rowCount()>0) {
161
-		    return true; 
161
+			return true; 
162 162
 		}
163 163
 		else return false;
164 164
 	}
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 				$sum = $sum->fetchColumn(0);
177 177
 			} else $sum = 0;
178 178
 			if (intval($sum) !== 2) {
179
-			     return false;
179
+				 return false;
180 180
 			}
181 181
 			
182 182
 		} catch(PDOException $e) {
183 183
 			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
184
-            			throw $e;
185
-	                }
186
-	                //echo 'error ! '.$e->getMessage();
184
+						throw $e;
185
+					}
186
+					//echo 'error ! '.$e->getMessage();
187 187
 			return false;
188 188
 		}
189 189
 		return true; 
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
 		$version = 0;
288 288
 		if ($this->tableExists('aircraft')) {
289 289
 			if (!$this->tableExists('config')) {
290
-	    			$version = '1';
291
-	    			return $version;
290
+					$version = '1';
291
+					return $version;
292 292
 			} else {
293 293
 				$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
294 294
 				try {
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
 	* @return Boolean if latest version or not
310 310
 	*/
311 311
 	public function latest() {
312
-	    global $globalNoDB;
313
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
314
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
315
-	    else return false;
312
+		global $globalNoDB;
313
+		if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
314
+		if ($this->check_schema_version() == $this->latest_schema) return true;
315
+		else return false;
316 316
 	}
317 317
 
318 318
 }
Please login to merge, or discard this patch.
require/class.Satellite.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 	}
125 125
 
126 126
 	/**
127
-	* Gets all launch site
128
-	*
129
-	* @return Array the launch site list
130
-	*
131
-	*/
127
+	 * Gets all launch site
128
+	 *
129
+	 * @return Array the launch site list
130
+	 *
131
+	 */
132 132
 	public function countAllLaunchSite($limit = true, $filters = array())
133 133
 	{
134 134
 		global $globalDBdriver;
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 	}
154 154
 
155 155
 	/**
156
-	* Gets all owners
157
-	*
158
-	* @return Array the owners list
159
-	*
160
-	*/
156
+	 * Gets all owners
157
+	 *
158
+	 * @return Array the owners list
159
+	 *
160
+	 */
161 161
 	public function countAllOwners($limit = true, $filters = array())
162 162
 	{
163 163
 		global $globalDBdriver;
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	/**
185
-	* Gets all countries owners
186
-	*
187
-	* @return Array the countries list
188
-	*
189
-	*/
185
+	 * Gets all countries owners
186
+	 *
187
+	 * @return Array the countries list
188
+	 *
189
+	 */
190 190
 	public function countAllCountriesOwners($limit = true, $filters = array())
191 191
 	{
192 192
 		global $globalDBdriver;
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 	}
212 212
 
213 213
 	/**
214
-	* Counts all launch dates during the last year
215
-	*
216
-	* @return Array the launch date list
217
-	*
218
-	*/
214
+	 * Counts all launch dates during the last year
215
+	 *
216
+	 * @return Array the launch date list
217
+	 *
218
+	 */
219 219
 	public function countAllMonthsLastYear($filters = array(), $sincedate = '')
220 220
 	{
221 221
 		global $globalTimezone, $globalDBdriver;
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 	}
257 257
 
258 258
 	/**
259
-	* Counts all dates during the last 10 years
260
-	*
261
-	* @return Array the date list
262
-	*
263
-	*/
259
+	 * Counts all dates during the last 10 years
260
+	 *
261
+	 * @return Array the date list
262
+	 *
263
+	 */
264 264
 	public function countAllYears($filters = array(), $sincedate = '')
265 265
 	{
266 266
 		global $globalTimezone, $globalDBdriver;
Please login to merge, or discard this patch.
header.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30 30
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
31
+		return strpos($key,'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 ?>
162 162
 <?php 
163
-    if (isset($_POST['archive'])) {
163
+	if (isset($_POST['archive'])) {
164 164
 ?>
165 165
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
166 166
 <?php 
167
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
167
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
168 168
 ?>
169 169
 
170 170
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script>
171 171
 <?php    
172
-	    }
173
-    } else {
172
+		}
173
+	} else {
174 174
 ?>
175 175
 <?php
176 176
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 */
183 183
 ?>
184 184
 <?php 
185
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
185
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
186 186
 ?>
187 187
 <?php
188 188
 //		if (isset($globalBeta) && $globalBeta) {
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
 <script src="<?php print $globalURL; ?>/js/map-marine.2d.js.php?<?php print time(); ?>"></script>
209 209
 <?php
210 210
 		}
211
-	    }
211
+		}
212 212
 ?>
213 213
 <?php
214 214
 //	}
215 215
 ?>
216 216
 <?php
217
-    }
217
+	}
218 218
 }
219 219
 ?>
220 220
 <?php
@@ -388,61 +388,61 @@  discard block
 block discarded – undo
388 388
       <ul class="nav navbar-nav">
389 389
 
390 390
 <?php 
391
-    $sub = false;
392
-    if (
391
+	$sub = false;
392
+	if (
393 393
 	(
394
-	    (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
394
+		(!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
395 395
 	) || 
396 396
 	(
397
-	    isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
397
+		isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
398 398
 	) || 
399 399
 	(
400
-	    isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
400
+		isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
401 401
 	) || 
402 402
 	(
403
-	    isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
403
+		isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
404 404
 	)
405
-    ) {
405
+	) {
406 406
 	$sub = true;
407
-    }
407
+	}
408 408
 ?>
409 409
 <?php
410
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
410
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
411 411
 ?>
412 412
     <li class="dropdown">
413 413
 <?php
414
-    if ($sub) {
414
+	if ($sub) {
415 415
 ?>
416 416
       	<li class="dropdown">
417 417
           <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Aircrafts"); ?> <b class="caret"></b></a>
418 418
 	<ul class="dropdown-menu multi-level">
419 419
       	<li class="dropdown-submenu">
420 420
 <?php
421
-    }
421
+	}
422 422
 ?>
423 423
           <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
424 424
           <ul class="dropdown-menu">
425 425
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li>
426 426
 <?php
427
-    if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
427
+	if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
428 428
 ?>
429 429
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
430 430
 <?php
431
-    }
431
+	}
432 432
 ?>
433 433
 			<li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li>
434 434
 <?php
435
-    if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
435
+	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
436 436
 ?>
437 437
 			<li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li>
438 438
 <?php
439
-    } 
440
-    if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
439
+	} 
440
+	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
441 441
 
442 442
 ?>
443 443
 			<li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li>
444 444
 <?php
445
-    }
445
+	}
446 446
 ?>
447 447
 			<li><hr /></li>
448 448
             <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li>
@@ -450,43 +450,43 @@  discard block
 block discarded – undo
450 450
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
451 451
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
452 452
             <?php
453
-        	if ($globalACARS) {
454
-        	    if (isset($globalDemo) && $globalDemo) {
455
-    	    ?>
453
+			if ($globalACARS) {
454
+				if (isset($globalDemo) && $globalDemo) {
455
+			?>
456 456
             <li><hr /></li>
457 457
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
458 458
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
459 459
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
460 460
             <?php
461
-        	    } else {
462
-    	    ?>
461
+				} else {
462
+			?>
463 463
             <li><hr /></li>
464 464
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
465 465
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
466 466
             <?php
467
-        	    }
468
-        	}
469
-    	    ?>
467
+				}
468
+			}
469
+			?>
470 470
     	    <?php
471
-    	        if (isset($globalAccidents) && $globalAccidents) {
472
-    	    ?>
471
+				if (isset($globalAccidents) && $globalAccidents) {
472
+			?>
473 473
             <li><hr /></li>
474 474
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li>
475 475
             <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li>
476 476
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li>
477 477
             <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li>
478 478
             <?php
479
-        	}
480
-    	    ?>
479
+			}
480
+			?>
481 481
             <li><hr /></li>
482 482
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
483 483
             <?php
484 484
 		if (!isset($globalNoUpcoming) || $globalNoUpcoming === FALSE) {
485
-	    ?>
485
+		?>
486 486
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
487 487
 	    <?php
488 488
 		}
489
-	    ?>
489
+		?>
490 490
           </ul>
491 491
         </li>
492 492
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
@@ -513,14 +513,14 @@  discard block
 block discarded – undo
513 513
     </ul>
514 514
 <?php
515 515
 	}
516
-    }
516
+	}
517 517
 ?>
518 518
 <?php
519
-    if (isset($globalMarine) && $globalMarine) {
519
+	if (isset($globalMarine) && $globalMarine) {
520 520
 ?>
521 521
     <li class="dropdown">
522 522
 <?php
523
-        if ($sub) {
523
+		if ($sub) {
524 524
 ?>
525 525
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Vessels"); ?> <b class="caret"></b></a>
526 526
 	<ul class="dropdown-menu multi-level">
@@ -545,14 +545,14 @@  discard block
 block discarded – undo
545 545
 	}
546 546
 ?>
547 547
 <?php
548
-    }
548
+	}
549 549
 ?>
550 550
 <?php
551
-    if (isset($globalTracker) && $globalTracker) {
551
+	if (isset($globalTracker) && $globalTracker) {
552 552
 ?>
553 553
     <li class="dropdown">
554 554
 <?php
555
-        if ($sub) {
555
+		if ($sub) {
556 556
 ?>
557 557
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Trackers"); ?> <b class="caret"></b></a>
558 558
 	<ul class="dropdown-menu multi-level">
@@ -577,14 +577,14 @@  discard block
 block discarded – undo
577 577
 	}
578 578
 ?>
579 579
 <?php
580
-    }
580
+	}
581 581
 ?>
582 582
 <?php
583
-    if (isset($globalSatellite) && $globalSatellite) {
583
+	if (isset($globalSatellite) && $globalSatellite) {
584 584
 ?>
585 585
     <li class="dropdown">
586 586
 <?php
587
-        if ($sub) {
587
+		if ($sub) {
588 588
 ?>
589 589
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Satellite"); ?> <b class="caret"></b></a>
590 590
 	<ul class="dropdown-menu multi-level">
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	}
612 612
 ?>
613 613
 <?php
614
-    }
614
+	}
615 615
 ?>
616 616
 
617 617
         <li class="dropdown">
@@ -620,12 +620,12 @@  discard block
 block discarded – undo
620 620
           	<li><a href="<?php print $globalURL; ?>/about"><?php echo _("About The Project"); ?></a></li>
621 621
           	<li><a href="<?php print $globalURL; ?>/about/export"><?php echo _("Exporting Data"); ?></a></li>
622 622
 <?php
623
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
623
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
624 624
 ?>
625 625
 		<li><hr /></li>
626 626
 		<li><a href="<?php print $globalURL; ?>/about/tv"><?php echo _("Spotter TV"); ?></a></li>
627 627
 <?php
628
-    }
628
+	}
629 629
 ?>
630 630
 	    <?php if (isset($globalContribute) && $globalContribute) { ?>
631 631
                 <li><hr /></li>
@@ -646,14 +646,14 @@  discard block
 block discarded – undo
646 646
   	    <form>
647 647
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
648 648
   		    <?php
649
-  		        $Language = new Language();
650
-  		        $alllang = $Language->getLanguages();
651
-  		        foreach ($alllang as $key => $lang) {
652
-  		            print '<option value="'.$key.'"';
653
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
654
-  		            print '>'.$lang[0].'</option>';
655
-  		        }
656
-  		    ?>
649
+  				$Language = new Language();
650
+  				$alllang = $Language->getLanguages();
651
+  				foreach ($alllang as $key => $lang) {
652
+  					print '<option value="'.$key.'"';
653
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
654
+  					print '>'.$lang[0].'</option>';
655
+  				}
656
+  			?>
657 657
   		</select>
658 658
   	    </form>
659 659
   	</div>
@@ -684,18 +684,18 @@  discard block
 block discarded – undo
684 684
 ?>
685 685
     <div class="top-header clear" role="main">
686 686
 <?php
687
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
687
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
688 688
 ?>
689 689
     <div id="archive-map"></div>
690 690
 <?php
691
-    }
691
+	}
692 692
 ?>
693 693
     </div>
694 694
 <?php
695 695
 }
696 696
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
697 697
 {
698
-    ?>
698
+	?>
699 699
     <div class="top-header clear" role="main">
700 700
         <div id="map"></div>
701 701
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -706,15 +706,15 @@  discard block
 block discarded – undo
706 706
         var zoom = 13;
707 707
 //create the map
708 708
 <?php
709
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
709
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
710 710
 ?>
711 711
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
712 712
 <?php
713
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
713
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
714 714
 ?>
715 715
   map = L.map('map', { zoomControl:true });
716 716
 <?php
717
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
717
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
718 718
 ?>
719 719
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
720 720
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -722,22 +722,22 @@  discard block
 block discarded – undo
722 722
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
723 723
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
724 724
 <?php
725
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
725
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
726 726
 ?>
727 727
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
728 728
 <?php
729
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
729
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
730 730
 ?>
731 731
   map = L.map('map', { zoomControl:true });
732 732
 <?php
733
-    }
733
+	}
734 734
 ?>
735 735
   //initialize the layer group for the aircrft markers
736 736
   var layer_data = L.layerGroup();
737 737
 
738 738
   //a few title layers
739 739
 <?php
740
-    if ($globalMapProvider == 'Mapbox') {
740
+	if ($globalMapProvider == 'Mapbox') {
741 741
 ?>
742 742
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
743 743
     maxZoom: 18,
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
     token : '<?php print $globalMapboxToken; ?>'
749 749
   }).addTo(map);
750 750
 <?php
751
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
751
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
752 752
 ?>
753 753
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
754 754
     maxZoom: 18,
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
758 758
   }).addTo(map);
759 759
 <?php
760
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
760
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
761 761
 ?>
762 762
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
763 763
     maxZoom: 18,
@@ -766,27 +766,27 @@  discard block
 block discarded – undo
766 766
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
767 767
   }).addTo(map);
768 768
 <?php
769
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
769
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
770 770
 ?>
771 771
     var googleLayer = new L.Google('ROADMAP');
772 772
     map.addLayer(googleLayer);
773 773
 <?php
774
-    } elseif ($globalMapProvider == 'Google-Satellite') {
774
+	} elseif ($globalMapProvider == 'Google-Satellite') {
775 775
 ?>
776 776
     var googleLayer = new L.Google('SATELLITE');
777 777
     map.addLayer(googleLayer);
778 778
 <?php
779
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
779
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
780 780
 ?>
781 781
     var googleLayer = new L.Google('HYBRID');
782 782
     map.addLayer(googleLayer);
783 783
 <?php
784
-    } elseif ($globalMapProvider == 'Google-Terrain') {
784
+	} elseif ($globalMapProvider == 'Google-Terrain') {
785 785
 ?>
786 786
     var googleLayer = new L.Google('Terrain');
787 787
     map.addLayer(googleLayer);
788 788
 <?php
789
-    } elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
789
+	} elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
790 790
 	$customid = $globalMapProvider;
791 791
 ?>
792 792
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
@@ -796,8 +796,8 @@  discard block
 block discarded – undo
796 796
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
797 797
     }).addTo(map);
798 798
 <?php
799
-    //} elseif ($globalMapProvider == 'OpenStreetMap') {
800
-    } else {
799
+	//} elseif ($globalMapProvider == 'OpenStreetMap') {
800
+	} else {
801 801
 ?>
802 802
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
803 803
     maxZoom: 18,
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
   }).addTo(map);
807 807
 
808 808
 <?php
809
-    }
809
+	}
810 810
 ?>
811 811
         </script>
812 812
     </div>
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Indentation   +954 added lines, -954 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 if (isset($options['idsource'])) $id_source = $options['idsource'];
80 80
 else $id_source = 1;
81 81
 if (isset($globalServer) && $globalServer) {
82
-    if ($globalDebug) echo "Using Server Mode\n";
83
-    $SI=new SpotterServer();
82
+	if ($globalDebug) echo "Using Server Mode\n";
83
+	$SI=new SpotterServer();
84 84
 /*
85 85
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
86 86
     $SI = new adsb2aprs();
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 } else $SI=new SpotterImport($Connection->db);
90 90
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
91 91
 if (isset($globalMarine) && $globalMarine) {
92
-    $AIS = new AIS();
93
-    $MI = new MarineImport($Connection->db);
92
+	$AIS = new AIS();
93
+	$MI = new MarineImport($Connection->db);
94 94
 }
95 95
 //$APRS=new APRS($Connection->db);
96 96
 $SBS=new SBS();
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 //$servertz = system('date +%Z');
102 102
 // signal handler - playing nice with sockets and dump1090
103 103
 if (function_exists('pcntl_fork')) {
104
-    pcntl_signal(SIGINT,  function() {
105
-        global $sockets;
106
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
107
-        die("Bye!\n");
108
-    });
109
-    pcntl_signal_dispatch();
104
+	pcntl_signal(SIGINT,  function() {
105
+		global $sockets;
106
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
107
+		die("Bye!\n");
108
+	});
109
+	pcntl_signal_dispatch();
110 110
 }
111 111
 
112 112
 // let's try and connect
@@ -116,36 +116,36 @@  discard block
 block discarded – undo
116 116
 $reset = 0;
117 117
 
118 118
 function connect_all($hosts) {
119
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
120
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
121
-    $reset++;
122
-    if ($globalDebug) echo 'Connect to all...'."\n";
123
-    foreach ($hosts as $id => $value) {
119
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
120
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
121
+	$reset++;
122
+	if ($globalDebug) echo 'Connect to all...'."\n";
123
+	foreach ($hosts as $id => $value) {
124 124
 	$host = $value['host'];
125 125
 	$globalSources[$id]['last_exec'] = 0;
126 126
 	// Here we check type of source(s)
127 127
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
128
-            if (preg_match('/deltadb.txt$/i',$host)) {
129
-        	//$formats[$id] = 'deltadbtxt';
130
-        	$globalSources[$id]['format'] = 'deltadbtxt';
131
-        	//$last_exec['deltadbtxt'] = 0;
132
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
133
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
134
-        	//$formats[$id] = 'vatsimtxt';
135
-        	$globalSources[$id]['format'] = 'vatsimtxt';
136
-        	//$last_exec['vatsimtxt'] = 0;
137
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
138
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
139
-        	//$formats[$id] = 'aircraftlistjson';
140
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
141
-        	//$last_exec['aircraftlistjson'] = 0;
142
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
143
-    	    } else if (preg_match('/opensky/i',$host)) {
144
-        	//$formats[$id] = 'aircraftlistjson';
145
-        	$globalSources[$id]['format'] = 'opensky';
146
-        	//$last_exec['aircraftlistjson'] = 0;
147
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
148
-    	    /*
128
+			if (preg_match('/deltadb.txt$/i',$host)) {
129
+			//$formats[$id] = 'deltadbtxt';
130
+			$globalSources[$id]['format'] = 'deltadbtxt';
131
+			//$last_exec['deltadbtxt'] = 0;
132
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
133
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
134
+			//$formats[$id] = 'vatsimtxt';
135
+			$globalSources[$id]['format'] = 'vatsimtxt';
136
+			//$last_exec['vatsimtxt'] = 0;
137
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
138
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
139
+			//$formats[$id] = 'aircraftlistjson';
140
+			$globalSources[$id]['format'] = 'aircraftlistjson';
141
+			//$last_exec['aircraftlistjson'] = 0;
142
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
143
+			} else if (preg_match('/opensky/i',$host)) {
144
+			//$formats[$id] = 'aircraftlistjson';
145
+			$globalSources[$id]['format'] = 'opensky';
146
+			//$last_exec['aircraftlistjson'] = 0;
147
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
148
+			/*
149 149
     	    // Disabled for now, site change source format
150 150
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
151 151
         	//$formats[$id] = 'radarvirtueljson';
@@ -157,121 +157,121 @@  discard block
 block discarded – undo
157 157
         	    exit(0);
158 158
         	}
159 159
     	    */
160
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
161
-        	//$formats[$id] = 'planeupdatefaa';
162
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
163
-        	//$last_exec['planeupdatefaa'] = 0;
164
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
165
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
166
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
167
-        	    exit(0);
168
-        	}
169
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
170
-        	//$formats[$id] = 'phpvmacars';
171
-        	$globalSources[$id]['format'] = 'phpvmacars';
172
-        	//$last_exec['phpvmacars'] = 0;
173
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
174
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
175
-        	//$formats[$id] = 'phpvmacars';
176
-        	$globalSources[$id]['format'] = 'vam';
177
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
178
-            } else if (preg_match('/whazzup/i',$host)) {
179
-        	//$formats[$id] = 'whazzup';
180
-        	$globalSources[$id]['format'] = 'whazzup';
181
-        	//$last_exec['whazzup'] = 0;
182
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
183
-            } else if (preg_match('/blitzortung/i',$host)) {
184
-        	$globalSources[$id]['format'] = 'blitzortung';
185
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
186
-            } else if (preg_match('/airwhere/i',$host)) {
187
-        	$globalSources[$id]['format'] = 'airwhere';
188
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
189
-            } else if (preg_match('/recentpireps/i',$host)) {
190
-        	//$formats[$id] = 'pirepsjson';
191
-        	$globalSources[$id]['format'] = 'pirepsjson';
192
-        	//$last_exec['pirepsjson'] = 0;
193
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
194
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
195
-        	//$formats[$id] = 'fr24json';
196
-        	$globalSources[$id]['format'] = 'fr24json';
197
-        	//$last_exec['fr24json'] = 0;
198
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
199
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
200
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
201
-        	    exit(0);
202
-        	}
203
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
204
-        	//$formats[$id] = 'fr24json';
205
-        	$globalSources[$id]['format'] = 'myshiptracking';
206
-        	//$last_exec['fr24json'] = 0;
207
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
208
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
-        	    exit(0);
211
-        	}
212
-            //} else if (preg_match('/10001/',$host)) {
213
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
214
-        	//$formats[$id] = 'tsv';
215
-        	$globalSources[$id]['format'] = 'tsv';
216
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
217
-            }
218
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
219
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
220
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
221
-    		    if ($idf !== false) {
222
-    			$httpfeeds[$id] = $idf;
223
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
224
-    		    }
225
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
226
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
227
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
228
-	    $hostport = explode(':',$host);
229
-	    if (isset($hostport[1])) {
160
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
161
+			//$formats[$id] = 'planeupdatefaa';
162
+			$globalSources[$id]['format'] = 'planeupdatefaa';
163
+			//$last_exec['planeupdatefaa'] = 0;
164
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
165
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
166
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
167
+				exit(0);
168
+			}
169
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
170
+			//$formats[$id] = 'phpvmacars';
171
+			$globalSources[$id]['format'] = 'phpvmacars';
172
+			//$last_exec['phpvmacars'] = 0;
173
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
174
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
175
+			//$formats[$id] = 'phpvmacars';
176
+			$globalSources[$id]['format'] = 'vam';
177
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
178
+			} else if (preg_match('/whazzup/i',$host)) {
179
+			//$formats[$id] = 'whazzup';
180
+			$globalSources[$id]['format'] = 'whazzup';
181
+			//$last_exec['whazzup'] = 0;
182
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
183
+			} else if (preg_match('/blitzortung/i',$host)) {
184
+			$globalSources[$id]['format'] = 'blitzortung';
185
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
186
+			} else if (preg_match('/airwhere/i',$host)) {
187
+			$globalSources[$id]['format'] = 'airwhere';
188
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
189
+			} else if (preg_match('/recentpireps/i',$host)) {
190
+			//$formats[$id] = 'pirepsjson';
191
+			$globalSources[$id]['format'] = 'pirepsjson';
192
+			//$last_exec['pirepsjson'] = 0;
193
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
194
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
195
+			//$formats[$id] = 'fr24json';
196
+			$globalSources[$id]['format'] = 'fr24json';
197
+			//$last_exec['fr24json'] = 0;
198
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
199
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
200
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
201
+				exit(0);
202
+			}
203
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
204
+			//$formats[$id] = 'fr24json';
205
+			$globalSources[$id]['format'] = 'myshiptracking';
206
+			//$last_exec['fr24json'] = 0;
207
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
208
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
+				exit(0);
211
+			}
212
+			//} else if (preg_match('/10001/',$host)) {
213
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
214
+			//$formats[$id] = 'tsv';
215
+			$globalSources[$id]['format'] = 'tsv';
216
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
217
+			}
218
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
219
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
220
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
221
+				if ($idf !== false) {
222
+				$httpfeeds[$id] = $idf;
223
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
224
+				}
225
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
226
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
227
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
228
+		$hostport = explode(':',$host);
229
+		if (isset($hostport[1])) {
230 230
 		$port = $hostport[1];
231 231
 		$hostn = $hostport[0];
232
-	    } else {
232
+		} else {
233 233
 		$port = $globalSources[$id]['port'];
234 234
 		$hostn = $globalSources[$id]['host'];
235
-	    }
236
-	    $Common = new Common();
237
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
238
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
239
-    	    } else {
240
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
241
-	    }
242
-	    if ($s) {
243
-    	        $sockets[$id] = $s;
244
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
245
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
235
+		}
236
+		$Common = new Common();
237
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
238
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
239
+			} else {
240
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
241
+		}
242
+		if ($s) {
243
+				$sockets[$id] = $s;
244
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
245
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
246 246
 			//$formats[$id] = 'aprs';
247 247
 			$globalSources[$id]['format'] = 'aprs';
248 248
 			//$aprs_connect = 0;
249 249
 			//$use_aprs = true;
250
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
250
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
251 251
 			$globalSources[$id]['format'] = 'vrstcp';
252
-    		    } elseif ($port == '10001') {
253
-        		//$formats[$id] = 'tsv';
254
-        		$globalSources[$id]['format'] = 'tsv';
255
-		    } elseif ($port == '30002') {
256
-        		//$formats[$id] = 'raw';
257
-        		$globalSources[$id]['format'] = 'raw';
258
-		    } elseif ($port == '5001') {
259
-        		//$formats[$id] = 'raw';
260
-        		$globalSources[$id]['format'] = 'flightgearmp';
261
-		    } elseif ($port == '30005') {
252
+				} elseif ($port == '10001') {
253
+				//$formats[$id] = 'tsv';
254
+				$globalSources[$id]['format'] = 'tsv';
255
+			} elseif ($port == '30002') {
256
+				//$formats[$id] = 'raw';
257
+				$globalSources[$id]['format'] = 'raw';
258
+			} elseif ($port == '5001') {
259
+				//$formats[$id] = 'raw';
260
+				$globalSources[$id]['format'] = 'flightgearmp';
261
+			} elseif ($port == '30005') {
262 262
 			// Not yet supported
263
-        		//$formats[$id] = 'beast';
264
-        		$globalSources[$id]['format'] = 'beast';
265
-		    //} else $formats[$id] = 'sbs';
266
-		    } else $globalSources[$id]['format'] = 'sbs';
267
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
263
+				//$formats[$id] = 'beast';
264
+				$globalSources[$id]['format'] = 'beast';
265
+			//} else $formats[$id] = 'sbs';
266
+			} else $globalSources[$id]['format'] = 'sbs';
267
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
268 268
 		}
269 269
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
270
-            } else {
270
+			} else {
271 271
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
272
-    	    }
273
-        }
274
-    }
272
+			}
273
+		}
274
+	}
275 275
 }
276 276
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
277 277
 
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 //connect_all($globalSources);
295 295
 
296 296
 if (isset($globalProxy) && $globalProxy) {
297
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
297
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
298 298
 } else {
299
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
299
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
300 300
 }
301 301
 
302 302
 // APRS Configuration
@@ -305,21 +305,21 @@  discard block
 block discarded – undo
305 305
 	die;
306 306
 }
307 307
 foreach ($globalSources as $key => $source) {
308
-    if (!isset($source['format'])) {
309
-        $globalSources[$key]['format'] = 'auto';
310
-    }
311
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
312
-        unset($globalSources[$key]);
313
-    }
308
+	if (!isset($source['format'])) {
309
+		$globalSources[$key]['format'] = 'auto';
310
+	}
311
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
312
+		unset($globalSources[$key]);
313
+	}
314 314
 }
315 315
 connect_all($globalSources);
316 316
 foreach ($globalSources as $key => $source) {
317
-    if (isset($source['format']) && $source['format'] == 'aprs') {
317
+	if (isset($source['format']) && $source['format'] == 'aprs') {
318 318
 	$aprs_connect = 0;
319 319
 	$use_aprs = true;
320 320
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
321 321
 	break;
322
-    }
322
+	}
323 323
 }
324 324
 
325 325
 if ($use_aprs) {
@@ -360,126 +360,126 @@  discard block
 block discarded – undo
360 360
 
361 361
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
362 362
 while ($i > 0) {
363
-    if (!$globalDaemon) $i = $endtime-time();
364
-    // Delete old ATC
365
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
363
+	if (!$globalDaemon) $i = $endtime-time();
364
+	// Delete old ATC
365
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
366 366
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
367
-        $ATC->deleteOldATC();
368
-    }
367
+		$ATC->deleteOldATC();
368
+	}
369 369
     
370
-    if (count($last_exec) == count($globalSources)) {
370
+	if (count($last_exec) == count($globalSources)) {
371 371
 	$max = $globalMinFetch;
372 372
 	foreach ($last_exec as $last) {
373
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
373
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
374 374
 	}
375 375
 	if ($max != $globalMinFetch) {
376
-	    if ($globalDebug) echo 'Sleeping...'."\n";
377
-	    sleep($globalMinFetch-$max+2);
376
+		if ($globalDebug) echo 'Sleeping...'."\n";
377
+		sleep($globalMinFetch-$max+2);
378
+	}
378 379
 	}
379
-    }
380 380
 
381 381
     
382
-    //foreach ($formats as $id => $value) {
383
-    foreach ($globalSources as $id => $value) {
382
+	//foreach ($formats as $id => $value) {
383
+	foreach ($globalSources as $id => $value) {
384 384
 	date_default_timezone_set('UTC');
385 385
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
386 386
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
387 387
 	if ($value['format'] == 'deltadbtxt' && 
388
-	    (
388
+		(
389 389
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
390 390
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
391
-	    )
391
+		)
392 392
 	) {
393
-	    //$buffer = $Common->getData($hosts[$id]);
394
-	    $buffer = $Common->getData($value['host']);
395
-	    if ($buffer != '') $reset = 0;
396
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
397
-	    $buffer = explode('\n',$buffer);
398
-	    foreach ($buffer as $line) {
399
-    		if ($line != '' && count($line) > 7) {
400
-    		    $line = explode(',', $line);
401
-	            $data = array();
402
-	            $data['hex'] = $line[1]; // hex
403
-	            $data['ident'] = $line[2]; // ident
404
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
405
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
406
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
407
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
408
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
409
-	            $data['verticalrate'] = ''; // vertical rate
410
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
411
-	            $data['emergency'] = ''; // emergency
412
-		    $data['datetime'] = date('Y-m-d H:i:s');
413
-		    $data['format_source'] = 'deltadbtxt';
414
-    		    $data['id_source'] = $id_source;
415
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
417
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
418
-    		    $SI->add($data);
419
-		    unset($data);
420
-    		}
421
-    	    }
422
-    	    $last_exec[$id]['last'] = time();
393
+		//$buffer = $Common->getData($hosts[$id]);
394
+		$buffer = $Common->getData($value['host']);
395
+		if ($buffer != '') $reset = 0;
396
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
397
+		$buffer = explode('\n',$buffer);
398
+		foreach ($buffer as $line) {
399
+			if ($line != '' && count($line) > 7) {
400
+				$line = explode(',', $line);
401
+				$data = array();
402
+				$data['hex'] = $line[1]; // hex
403
+				$data['ident'] = $line[2]; // ident
404
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
405
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
406
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
407
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
408
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
409
+				$data['verticalrate'] = ''; // vertical rate
410
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
411
+				$data['emergency'] = ''; // emergency
412
+			$data['datetime'] = date('Y-m-d H:i:s');
413
+			$data['format_source'] = 'deltadbtxt';
414
+				$data['id_source'] = $id_source;
415
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
417
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
418
+				$SI->add($data);
419
+			unset($data);
420
+			}
421
+			}
422
+			$last_exec[$id]['last'] = time();
423 423
 	} elseif ($value['format'] == 'aisnmeatxt' && 
424
-	    (
424
+		(
425 425
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
426 426
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
427
-	    )
427
+		)
428 428
 	) {
429
-	    date_default_timezone_set('CET');
430
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
431
-	    date_default_timezone_set('UTC');
432
-	    if ($buffer != '') $reset = 0;
433
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
-	    $buffer = explode('\n',$buffer);
435
-	    foreach ($buffer as $line) {
429
+		date_default_timezone_set('CET');
430
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
431
+		date_default_timezone_set('UTC');
432
+		if ($buffer != '') $reset = 0;
433
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
+		$buffer = explode('\n',$buffer);
435
+		foreach ($buffer as $line) {
436 436
 		if ($line != '') {
437
-		    //echo "'".$line."'\n";
438
-		    $add = false;
439
-		    $ais_data = $AIS->parse_line(trim($line));
440
-		    $data = array();
441
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
442
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
443
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
444
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
445
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
446
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
447
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
448
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
449
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
450
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
451
-		    if (isset($ais_data['timestamp'])) {
437
+			//echo "'".$line."'\n";
438
+			$add = false;
439
+			$ais_data = $AIS->parse_line(trim($line));
440
+			$data = array();
441
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
442
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
443
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
444
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
445
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
446
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
447
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
448
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
449
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
450
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
451
+			if (isset($ais_data['timestamp'])) {
452 452
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
453 453
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
454
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
455
-			    $add = true;
454
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
455
+				$add = true;
456 456
 			}
457
-		    } else {
457
+			} else {
458 458
 			$data['datetime'] = date('Y-m-d H:i:s');
459 459
 			$add = true;
460
-		    }
461
-		    $data['format_source'] = 'aisnmeatxt';
462
-    		    $data['id_source'] = $id_source;
463
-		    //print_r($data);
464
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
465
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
466
-		    unset($data);
460
+			}
461
+			$data['format_source'] = 'aisnmeatxt';
462
+				$data['id_source'] = $id_source;
463
+			//print_r($data);
464
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
465
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
466
+			unset($data);
467 467
 		}
468
-    	    }
469
-    	    $last_exec[$id]['last'] = time();
468
+			}
469
+			$last_exec[$id]['last'] = time();
470 470
 	} elseif ($value['format'] == 'aisnmeahttp') {
471
-	    $arr = $httpfeeds;
472
-	    $w = $e = null;
471
+		$arr = $httpfeeds;
472
+		$w = $e = null;
473 473
 	    
474
-	    if (isset($arr[$id])) {
474
+		if (isset($arr[$id])) {
475 475
 		$nn = stream_select($arr,$w,$e,$timeout);
476 476
 		if ($nn > 0) {
477
-		    foreach ($httpfeeds as $feed) {
477
+			foreach ($httpfeeds as $feed) {
478 478
 			$buffer = stream_get_line($feed,2000,"\n");
479 479
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
480 480
 			$buffer = explode('\n',$buffer);
481 481
 			foreach ($buffer as $line) {
482
-			    if ($line != '') {
482
+				if ($line != '') {
483 483
 				$ais_data = $AIS->parse_line(trim($line));
484 484
 				$data = array();
485 485
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -497,111 +497,111 @@  discard block
 block discarded – undo
497 497
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
498 498
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
499 499
 				if (isset($ais_data['timestamp'])) {
500
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
500
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
501 501
 				} else {
502
-				    $data['datetime'] = date('Y-m-d H:i:s');
502
+					$data['datetime'] = date('Y-m-d H:i:s');
503 503
 				}
504 504
 				$data['format_source'] = 'aisnmeahttp';
505 505
 				$data['id_source'] = $id_source;
506 506
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
507 507
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
508 508
 				unset($data);
509
-			    }
509
+				}
510
+			}
510 511
 			}
511
-		    }
512 512
 		} else {
513
-		    $format = $value['format'];
514
-		    if (isset($tt[$format])) $tt[$format]++;
515
-		    else $tt[$format] = 0;
516
-		    if ($tt[$format] > 30) {
513
+			$format = $value['format'];
514
+			if (isset($tt[$format])) $tt[$format]++;
515
+			else $tt[$format] = 0;
516
+			if ($tt[$format] > 30) {
517 517
 			if ($globalDebug) echo 'Reconnect...'."\n";
518 518
 			sleep(2);
519 519
 			$sourceeen[] = $value;
520 520
 			connect_all($sourceeen);
521 521
 			$sourceeen = array();
522
-		    }
522
+			}
523
+		}
523 524
 		}
524
-	    }
525 525
 	} elseif ($value['format'] == 'myshiptracking' && 
526
-	    (
526
+		(
527 527
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
528 528
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
529
-	    )
529
+		)
530 530
 	) {
531
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
532
-	    if ($buffer != '') {
531
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
532
+		if ($buffer != '') {
533 533
 		//echo $buffer;
534 534
 		$all_data = json_decode($buffer,true);
535 535
 		//print_r($all_data);
536 536
 		if (isset($all_data[0]['DATA'])) {
537
-		    foreach ($all_data[0]['DATA'] as $line) {
537
+			foreach ($all_data[0]['DATA'] as $line) {
538 538
 			if ($line != '') {
539
-			    $data = array();
540
-			    $data['ident'] = $line['NAME'];
541
-			    $data['mmsi'] = $line['MMSI'];
542
-			    $data['speed'] = $line['SOG'];
543
-			    $data['heading'] = $line['COG'];
544
-			    $data['latitude'] = $line['LAT'];
545
-			    $data['longitude'] = $line['LNG'];
546
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
547
-			    $data['imo'] = $line['IMO'];
548
-			    //$data['arrival_code'] = $ais_data['destination'];
549
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
550
-			    $data['format_source'] = 'myshiptracking';
551
-			    $data['id_source'] = $id_source;
552
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
553
-			    $MI->add($data);
554
-			    unset($data);
539
+				$data = array();
540
+				$data['ident'] = $line['NAME'];
541
+				$data['mmsi'] = $line['MMSI'];
542
+				$data['speed'] = $line['SOG'];
543
+				$data['heading'] = $line['COG'];
544
+				$data['latitude'] = $line['LAT'];
545
+				$data['longitude'] = $line['LNG'];
546
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
547
+				$data['imo'] = $line['IMO'];
548
+				//$data['arrival_code'] = $ais_data['destination'];
549
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
550
+				$data['format_source'] = 'myshiptracking';
551
+				$data['id_source'] = $id_source;
552
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
553
+				$MI->add($data);
554
+				unset($data);
555
+			}
555 556
 			}
556
-		    }
557 557
 		}
558
-	    }
559
-	    $last_exec[$id]['last'] = time();
558
+		}
559
+		$last_exec[$id]['last'] = time();
560 560
 	} elseif ($value['format'] == 'boatbeaconapp' && 
561
-	    (
561
+		(
562 562
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
563 563
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
564
-	    )
564
+		)
565 565
 	) {
566
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
567
-	    if ($buffer != '') {
566
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
567
+		if ($buffer != '') {
568 568
 		$all_data = json_decode($buffer,true);
569 569
 		if (isset($all_data[0]['mmsi'])) {
570
-		    foreach ($all_data as $line) {
570
+			foreach ($all_data as $line) {
571 571
 			if ($line != '') {
572
-			    $data = array();
573
-			    $data['ident'] = $line['shipname'];
574
-			    $data['callsign'] = $line['callsign'];
575
-			    $data['mmsi'] = $line['mmsi'];
576
-			    $data['speed'] = $line['sog'];
577
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
578
-			    $data['latitude'] = $line['latitude'];
579
-			    $data['longitude'] = $line['longitude'];
580
-			    $data['type_id'] = $line['shiptype'];
581
-			    $data['arrival_code'] = $line['destination'];
582
-			    $data['datetime'] = $line['time'];
583
-			    $data['format_source'] = 'boatbeaconapp';
584
-			    $data['id_source'] = $id_source;
585
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
586
-			    $MI->add($data);
587
-			    unset($data);
572
+				$data = array();
573
+				$data['ident'] = $line['shipname'];
574
+				$data['callsign'] = $line['callsign'];
575
+				$data['mmsi'] = $line['mmsi'];
576
+				$data['speed'] = $line['sog'];
577
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
578
+				$data['latitude'] = $line['latitude'];
579
+				$data['longitude'] = $line['longitude'];
580
+				$data['type_id'] = $line['shiptype'];
581
+				$data['arrival_code'] = $line['destination'];
582
+				$data['datetime'] = $line['time'];
583
+				$data['format_source'] = 'boatbeaconapp';
584
+				$data['id_source'] = $id_source;
585
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
586
+				$MI->add($data);
587
+				unset($data);
588
+			}
588 589
 			}
589
-		    }
590 590
 		}
591 591
 		
592
-	    }
593
-    	    $last_exec[$id]['last'] = time();
592
+		}
593
+			$last_exec[$id]['last'] = time();
594 594
 	} elseif ($value['format'] == 'boatnerd' && 
595
-	    (
595
+		(
596 596
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
597 597
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
598
-	    )
598
+		)
599 599
 	) {
600
-	    $buffer = $Common->getData($value['host']);
601
-	    if ($buffer != '') {
600
+		$buffer = $Common->getData($value['host']);
601
+		if ($buffer != '') {
602 602
 		$all_data = json_decode($buffer,true);
603 603
 		if (isset($all_data['features'][0]['id'])) {
604
-		    foreach ($all_data['features'] as $line) {
604
+			foreach ($all_data['features'] as $line) {
605 605
 			$data = array();
606 606
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
607 607
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -620,78 +620,78 @@  discard block
 block discarded – undo
620 620
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
621 621
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
622 622
 			unset($data);
623
-		    }
623
+			}
624 624
 		}
625 625
 		
626
-	    }
627
-    	    $last_exec[$id]['last'] = time();
626
+		}
627
+			$last_exec[$id]['last'] = time();
628 628
 	} elseif ($value['format'] == 'shipplotter' && 
629
-	    (
629
+		(
630 630
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
631 631
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
632
-	    )
632
+		)
633 633
 	) {
634
-	    echo 'download...';
635
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
636
-	    echo 'done !'."\n";
637
-	    if ($buffer != '') $reset = 0;
638
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
639
-	    $buffer = explode('\n',$buffer);
640
-	    foreach ($buffer as $line) {
634
+		echo 'download...';
635
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
636
+		echo 'done !'."\n";
637
+		if ($buffer != '') $reset = 0;
638
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
639
+		$buffer = explode('\n',$buffer);
640
+		foreach ($buffer as $line) {
641 641
 		if ($line != '') {
642
-		    $data = array();
643
-		    $data['mmsi'] = (int)substr($line,0,9);
644
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
645
-		    //$data['status'] = substr($line,21,2);
646
-		    //$data['type'] = substr($line,24,3);
647
-		    $data['latitude'] = substr($line,29,9);
648
-		    $data['longitude'] = substr($line,41,9);
649
-		    $data['speed'] = round(substr($line,51,5));
650
-		    //$data['course'] = substr($line,57,5);
651
-		    $data['heading'] = round(substr($line,63,3));
652
-		    //$data['draft'] = substr($line,67,4);
653
-		    //$data['length'] = substr($line,72,3);
654
-		    //$data['beam'] = substr($line,76,2);
655
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
656
-		    //$data['callsign'] = trim(substr($line,100,7);
657
-		    //$data['dest'] = substr($line,108,20);
658
-		    //$data['etaDate'] = substr($line,129,5);
659
-		    //$data['etaTime'] = substr($line,135,5);
660
-		    $data['format_source'] = 'shipplotter';
661
-    		    $data['id_source'] = $id_source;
662
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
663
-		    //print_r($data);
664
-		    echo 'Add...'."\n";
665
-		    $MI->add($data);
666
-		    unset($data);
642
+			$data = array();
643
+			$data['mmsi'] = (int)substr($line,0,9);
644
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
645
+			//$data['status'] = substr($line,21,2);
646
+			//$data['type'] = substr($line,24,3);
647
+			$data['latitude'] = substr($line,29,9);
648
+			$data['longitude'] = substr($line,41,9);
649
+			$data['speed'] = round(substr($line,51,5));
650
+			//$data['course'] = substr($line,57,5);
651
+			$data['heading'] = round(substr($line,63,3));
652
+			//$data['draft'] = substr($line,67,4);
653
+			//$data['length'] = substr($line,72,3);
654
+			//$data['beam'] = substr($line,76,2);
655
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
656
+			//$data['callsign'] = trim(substr($line,100,7);
657
+			//$data['dest'] = substr($line,108,20);
658
+			//$data['etaDate'] = substr($line,129,5);
659
+			//$data['etaTime'] = substr($line,135,5);
660
+			$data['format_source'] = 'shipplotter';
661
+				$data['id_source'] = $id_source;
662
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
663
+			//print_r($data);
664
+			echo 'Add...'."\n";
665
+			$MI->add($data);
666
+			unset($data);
667 667
 		}
668
-    	    }
669
-    	    $last_exec[$id]['last'] = time();
668
+			}
669
+			$last_exec[$id]['last'] = time();
670 670
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
671 671
 	} elseif (
672
-	    (
672
+		(
673 673
 		$value['format'] == 'whazzup' && 
674 674
 		(
675
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
676
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
675
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
676
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
677 677
 		)
678
-	    ) || (
678
+		) || (
679 679
 		$value['format'] == 'vatsimtxt' && 
680 680
 		(
681
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
682
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
681
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
682
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
683
+		)
683 684
 		)
684
-	    )
685 685
 	) {
686
-	    //$buffer = $Common->getData($hosts[$id]);
687
-	    $buffer = $Common->getData($value['host']);
688
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
689
-	    $buffer = explode('\n',$buffer);
690
-	    $reset = 0;
691
-	    foreach ($buffer as $line) {
692
-    		if ($line != '') {
693
-    		    $line = explode(':', $line);
694
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
686
+		//$buffer = $Common->getData($hosts[$id]);
687
+		$buffer = $Common->getData($value['host']);
688
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
689
+		$buffer = explode('\n',$buffer);
690
+		$reset = 0;
691
+		foreach ($buffer as $line) {
692
+			if ($line != '') {
693
+				$line = explode(':', $line);
694
+				if (count($line) > 30 && $line[0] != 'callsign') {
695 695
 			$data = array();
696 696
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
697 697
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -704,37 +704,37 @@  discard block
 block discarded – undo
704 704
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
705 705
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
706 706
 			$data['latitude'] = $line[5]; // lat
707
-	        	$data['longitude'] = $line[6]; // long
708
-	        	$data['verticalrate'] = ''; // vertical rate
709
-	        	$data['squawk'] = ''; // squawk
710
-	        	$data['emergency'] = ''; // emergency
711
-	        	$data['waypoints'] = $line[30];
707
+				$data['longitude'] = $line[6]; // long
708
+				$data['verticalrate'] = ''; // vertical rate
709
+				$data['squawk'] = ''; // squawk
710
+				$data['emergency'] = ''; // emergency
711
+				$data['waypoints'] = $line[30];
712 712
 			$data['datetime'] = date('Y-m-d H:i:s');
713 713
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
714 714
 			//if (isset($line[37])) $data['last_update'] = $line[37];
715
-		        $data['departure_airport_icao'] = $line[11];
716
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
717
-		        $data['arrival_airport_icao'] = $line[13];
715
+				$data['departure_airport_icao'] = $line[11];
716
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
717
+				$data['arrival_airport_icao'] = $line[13];
718 718
 			$data['frequency'] = $line[4];
719 719
 			$data['type'] = $line[18];
720 720
 			$data['range'] = $line[19];
721 721
 			if (isset($line[35])) $data['info'] = $line[35];
722
-    			$data['id_source'] = $id_source;
723
-	    		//$data['arrival_airport_time'] = ;
724
-	    		if ($line[9] != '') {
725
-	    		    $aircraft_data = explode('/',$line[9]);
726
-	    		    if (isset($aircraft_data[1])) {
727
-	    			$data['aircraft_icao'] = $aircraft_data[1];
728
-	    		    }
729
-        		}
730
-	    		/*
722
+				$data['id_source'] = $id_source;
723
+				//$data['arrival_airport_time'] = ;
724
+				if ($line[9] != '') {
725
+					$aircraft_data = explode('/',$line[9]);
726
+					if (isset($aircraft_data[1])) {
727
+					$data['aircraft_icao'] = $aircraft_data[1];
728
+					}
729
+				}
730
+				/*
731 731
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
732 732
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
733 733
 	    		*/
734
-	    		$data['format_source'] = $value['format'];
734
+				$data['format_source'] = $value['format'];
735 735
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
736 736
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
737
-    			if ($line[3] == 'PILOT') $SI->add($data);
737
+				if ($line[3] == 'PILOT') $SI->add($data);
738 738
 			elseif ($line[3] == 'ATC') {
739 739
 				//print_r($data);
740 740
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -755,21 +755,21 @@  discard block
 block discarded – undo
755 755
 					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
756 756
 				}
757 757
 			}
758
-    			unset($data);
759
-    		    }
760
-    		}
761
-    	    }
762
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
763
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
764
-    	    $last_exec[$id]['last'] = time();
765
-    	} elseif ($value['format'] == 'airwhere' && 
766
-    	    (
767
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
768
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
769
-    	    )
770
-    	) {
771
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
772
-	    if ($buffer != '') {
758
+				unset($data);
759
+				}
760
+			}
761
+			}
762
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
763
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
764
+			$last_exec[$id]['last'] = time();
765
+		} elseif ($value['format'] == 'airwhere' && 
766
+			(
767
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
768
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
769
+			)
770
+		) {
771
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
772
+		if ($buffer != '') {
773 773
 		$all_data = simplexml_load_string($buffer);
774 774
 		foreach($all_data->children() as $childdata) {
775 775
 			$data = array();
@@ -791,10 +791,10 @@  discard block
 block discarded – undo
791 791
 			$SI->add($data);
792 792
 			unset($data);
793 793
 		}
794
-	    }
795
-	    $Source->deleteOldLocationByType('gs');
796
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
797
-	    if ($buffer != '') {
794
+		}
795
+		$Source->deleteOldLocationByType('gs');
796
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
797
+		if ($buffer != '') {
798 798
 		$all_data = simplexml_load_string($buffer);
799 799
 		foreach($all_data->children() as $childdata) {
800 800
 			$data = array();
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 			}
813 813
 			unset($data);
814 814
 		}
815
-	    }
816
-	    $last_exec[$id]['last'] = time();
815
+		}
816
+		$last_exec[$id]['last'] = time();
817 817
 	/*
818 818
 	} if ($value['format'] == 'aircraftlistjson') {
819 819
 	    print_r($globalSources);
@@ -821,17 +821,17 @@  discard block
 block discarded – undo
821 821
 	    echo $globalMinFetch;
822 822
 	*/
823 823
 	} elseif ($value['format'] == 'aircraftlistjson' && 
824
-	    (
824
+		(
825 825
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
826 826
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
827
-	    )
827
+		)
828 828
 	) {
829
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
830
-	    if ($buffer != '') {
831
-	        $all_data = json_decode($buffer,true);
829
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
830
+		if ($buffer != '') {
831
+			$all_data = json_decode($buffer,true);
832 832
 		if (isset($all_data['acList'])) {
833
-		    $reset = 0;
834
-		    foreach ($all_data['acList'] as $line) {
833
+			$reset = 0;
834
+			foreach ($all_data['acList'] as $line) {
835 835
 			$data = array();
836 836
 			$data['hex'] = $line['Icao']; // hex
837 837
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -854,10 +854,10 @@  discard block
 block discarded – undo
854 854
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
855 855
 			if (isset($data['latitude'])) $SI->add($data);
856 856
 			unset($data);
857
-		    }
857
+			}
858 858
 		} elseif (is_array($all_data)) {
859
-		    $reset = 0;
860
-		    foreach ($all_data as $line) {
859
+			$reset = 0;
860
+			foreach ($all_data as $line) {
861 861
 			$data = array();
862 862
 			$data['hex'] = $line['hex']; // hex
863 863
 			$data['ident'] = $line['flight']; // ident
@@ -877,218 +877,218 @@  discard block
 block discarded – undo
877 877
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
878 878
 			$SI->add($data);
879 879
 			unset($data);
880
-		    }
880
+			}
881 881
 		}
882
-	    } elseif ($globalDebug) echo 'No data'."\n";
883
-    	    //$last_exec['aircraftlistjson'] = time();
884
-    	    $last_exec[$id]['last'] = time();
885
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
886
-    	} elseif ($value['format'] == 'planeupdatefaa' && 
887
-    	    (
888
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
889
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
890
-    	    )
891
-    	) {
892
-	    $buffer = $Common->getData($value['host']);
893
-	    $all_data = json_decode($buffer,true);
894
-	    if (isset($all_data['planes'])) {
882
+		} elseif ($globalDebug) echo 'No data'."\n";
883
+			//$last_exec['aircraftlistjson'] = time();
884
+			$last_exec[$id]['last'] = time();
885
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
886
+		} elseif ($value['format'] == 'planeupdatefaa' && 
887
+			(
888
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
889
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
890
+			)
891
+		) {
892
+		$buffer = $Common->getData($value['host']);
893
+		$all_data = json_decode($buffer,true);
894
+		if (isset($all_data['planes'])) {
895 895
 		$reset = 0;
896 896
 		foreach ($all_data['planes'] as $key => $line) {
897
-		    $data = array();
898
-		    $data['hex'] = $key; // hex
899
-		    $data['ident'] = $line[3]; // ident
900
-		    $data['altitude'] = $line[6]; // altitude
901
-		    $data['speed'] = $line[8]; // speed
902
-		    $data['heading'] = $line[7]; // heading
903
-		    $data['latitude'] = $line[4]; // lat
904
-		    $data['longitude'] = $line[5]; // long
905
-		    //$data['verticalrate'] = $line[]; // verticale rate
906
-		    $data['squawk'] = $line[10]; // squawk
907
-		    $data['emergency'] = ''; // emergency
908
-		    $data['registration'] = $line[2];
909
-		    $data['aircraft_icao'] = $line[0];
910
-		    $deparr = explode('-',$line[1]);
911
-		    if (count($deparr) == 2) {
897
+			$data = array();
898
+			$data['hex'] = $key; // hex
899
+			$data['ident'] = $line[3]; // ident
900
+			$data['altitude'] = $line[6]; // altitude
901
+			$data['speed'] = $line[8]; // speed
902
+			$data['heading'] = $line[7]; // heading
903
+			$data['latitude'] = $line[4]; // lat
904
+			$data['longitude'] = $line[5]; // long
905
+			//$data['verticalrate'] = $line[]; // verticale rate
906
+			$data['squawk'] = $line[10]; // squawk
907
+			$data['emergency'] = ''; // emergency
908
+			$data['registration'] = $line[2];
909
+			$data['aircraft_icao'] = $line[0];
910
+			$deparr = explode('-',$line[1]);
911
+			if (count($deparr) == 2) {
912 912
 			$data['departure_airport_icao'] = $deparr[0];
913 913
 			$data['arrival_airport_icao'] = $deparr[1];
914
-		    }
915
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
916
-	    	    $data['format_source'] = 'planeupdatefaa';
917
-    		    $data['id_source'] = $id_source;
918
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
919
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
920
-		    $SI->add($data);
921
-		    unset($data);
914
+			}
915
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
916
+				$data['format_source'] = 'planeupdatefaa';
917
+				$data['id_source'] = $id_source;
918
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
919
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
920
+			$SI->add($data);
921
+			unset($data);
922
+		}
922 923
 		}
923
-	    }
924
-	    //$last_exec['planeupdatefaa'] = time();
925
-	    $last_exec[$id]['last'] = time();
924
+		//$last_exec['planeupdatefaa'] = time();
925
+		$last_exec[$id]['last'] = time();
926 926
 	} elseif ($value['format'] == 'opensky' && 
927
-	    (
927
+		(
928 928
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
929 929
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
930
-	    )
930
+		)
931 931
 	) {
932
-	    $buffer = $Common->getData($value['host']);
933
-	    $all_data = json_decode($buffer,true);
934
-	    if (isset($all_data['states'])) {
932
+		$buffer = $Common->getData($value['host']);
933
+		$all_data = json_decode($buffer,true);
934
+		if (isset($all_data['states'])) {
935 935
 		$reset = 0;
936 936
 		foreach ($all_data['states'] as $key => $line) {
937
-		    $data = array();
938
-		    $data['hex'] = $line[0]; // hex
939
-		    $data['ident'] = trim($line[1]); // ident
940
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
941
-		    $data['speed'] = round($line[9]*1.94384); // speed
942
-		    $data['heading'] = round($line[10]); // heading
943
-		    $data['latitude'] = $line[6]; // lat
944
-		    $data['longitude'] = $line[5]; // long
945
-		    $data['verticalrate'] = $line[11]; // verticale rate
946
-		    //$data['squawk'] = $line[10]; // squawk
947
-		    //$data['emergency'] = ''; // emergency
948
-		    //$data['registration'] = $line[2];
949
-		    //$data['aircraft_icao'] = $line[0];
950
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
951
-		    $data['format_source'] = 'opensky';
952
-		    $data['id_source'] = $id_source;
953
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
954
-		    $SI->add($data);
955
-		    unset($data);
937
+			$data = array();
938
+			$data['hex'] = $line[0]; // hex
939
+			$data['ident'] = trim($line[1]); // ident
940
+			$data['altitude'] = round($line[7]*3.28084); // altitude
941
+			$data['speed'] = round($line[9]*1.94384); // speed
942
+			$data['heading'] = round($line[10]); // heading
943
+			$data['latitude'] = $line[6]; // lat
944
+			$data['longitude'] = $line[5]; // long
945
+			$data['verticalrate'] = $line[11]; // verticale rate
946
+			//$data['squawk'] = $line[10]; // squawk
947
+			//$data['emergency'] = ''; // emergency
948
+			//$data['registration'] = $line[2];
949
+			//$data['aircraft_icao'] = $line[0];
950
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
951
+			$data['format_source'] = 'opensky';
952
+			$data['id_source'] = $id_source;
953
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
954
+			$SI->add($data);
955
+			unset($data);
956 956
 		}
957
-	    }
958
-	    //$last_exec['planeupdatefaa'] = time();
959
-	    $last_exec[$id]['last'] = time();
957
+		}
958
+		//$last_exec['planeupdatefaa'] = time();
959
+		$last_exec[$id]['last'] = time();
960 960
 	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
961 961
 	} elseif ($value['format'] == 'fr24json' && 
962
-	    (
962
+		(
963 963
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
964 964
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
965
-	    )
965
+		)
966 966
 	) {
967
-	    //$buffer = $Common->getData($hosts[$id]);
968
-	    $buffer = $Common->getData($value['host']);
969
-	    $all_data = json_decode($buffer,true);
970
-	    if (!empty($all_data)) $reset = 0;
971
-	    foreach ($all_data as $key => $line) {
967
+		//$buffer = $Common->getData($hosts[$id]);
968
+		$buffer = $Common->getData($value['host']);
969
+		$all_data = json_decode($buffer,true);
970
+		if (!empty($all_data)) $reset = 0;
971
+		foreach ($all_data as $key => $line) {
972 972
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
973
-		    $data = array();
974
-		    $data['hex'] = $line[0];
975
-		    $data['ident'] = $line[16]; //$line[13]
976
-	    	    $data['altitude'] = $line[4]; // altitude
977
-	    	    $data['speed'] = $line[5]; // speed
978
-	    	    $data['heading'] = $line[3]; // heading
979
-	    	    $data['latitude'] = $line[1]; // lat
980
-	    	    $data['longitude'] = $line[2]; // long
981
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
982
-	    	    $data['squawk'] = $line[6]; // squawk
983
-	    	    $data['aircraft_icao'] = $line[8];
984
-	    	    $data['registration'] = $line[9];
985
-		    $data['departure_airport_iata'] = $line[11];
986
-		    $data['arrival_airport_iata'] = $line[12];
987
-	    	    $data['emergency'] = ''; // emergency
988
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
989
-	    	    $data['format_source'] = 'fr24json';
990
-    		    $data['id_source'] = $id_source;
991
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
992
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
993
-		    $SI->add($data);
994
-		    unset($data);
973
+			$data = array();
974
+			$data['hex'] = $line[0];
975
+			$data['ident'] = $line[16]; //$line[13]
976
+				$data['altitude'] = $line[4]; // altitude
977
+				$data['speed'] = $line[5]; // speed
978
+				$data['heading'] = $line[3]; // heading
979
+				$data['latitude'] = $line[1]; // lat
980
+				$data['longitude'] = $line[2]; // long
981
+				$data['verticalrate'] = $line[15]; // verticale rate
982
+				$data['squawk'] = $line[6]; // squawk
983
+				$data['aircraft_icao'] = $line[8];
984
+				$data['registration'] = $line[9];
985
+			$data['departure_airport_iata'] = $line[11];
986
+			$data['arrival_airport_iata'] = $line[12];
987
+				$data['emergency'] = ''; // emergency
988
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
989
+				$data['format_source'] = 'fr24json';
990
+				$data['id_source'] = $id_source;
991
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
992
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
993
+			$SI->add($data);
994
+			unset($data);
995 995
 		}
996
-	    }
997
-	    //$last_exec['fr24json'] = time();
998
-	    $last_exec[$id]['last'] = time();
996
+		}
997
+		//$last_exec['fr24json'] = time();
998
+		$last_exec[$id]['last'] = time();
999 999
 	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1000 1000
 	} elseif ($value['format'] == 'radarvirtueljson' && 
1001
-	    (
1001
+		(
1002 1002
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1003 1003
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1004
-	    )
1004
+		)
1005 1005
 	) {
1006
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1007
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1008
-	    //echo $buffer;
1009
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1010
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1011
-	    $all_data = json_decode($buffer,true);
1012
-	    if (json_last_error() != JSON_ERROR_NONE) {
1006
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1007
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1008
+		//echo $buffer;
1009
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1010
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1011
+		$all_data = json_decode($buffer,true);
1012
+		if (json_last_error() != JSON_ERROR_NONE) {
1013 1013
 		die(json_last_error_msg());
1014
-	    }
1015
-	    if (isset($all_data['mrkrs'])) {
1014
+		}
1015
+		if (isset($all_data['mrkrs'])) {
1016 1016
 		$reset = 0;
1017 1017
 		foreach ($all_data['mrkrs'] as $key => $line) {
1018
-		    if (isset($line['inf'])) {
1018
+			if (isset($line['inf'])) {
1019 1019
 			$data = array();
1020 1020
 			$data['hex'] = $line['inf']['ia'];
1021 1021
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1022
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1023
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1024
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1025
-	    		$data['latitude'] = $line['pt'][0]; // lat
1026
-	    		$data['longitude'] = $line['pt'][1]; // long
1027
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1028
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1029
-	    		//$data['aircraft_icao'] = $line[8];
1030
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1022
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1023
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1024
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1025
+				$data['latitude'] = $line['pt'][0]; // lat
1026
+				$data['longitude'] = $line['pt'][1]; // long
1027
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1028
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1029
+				//$data['aircraft_icao'] = $line[8];
1030
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1031 1031
 			//$data['departure_airport_iata'] = $line[11];
1032 1032
 			//$data['arrival_airport_iata'] = $line[12];
1033
-	    		//$data['emergency'] = ''; // emergency
1033
+				//$data['emergency'] = ''; // emergency
1034 1034
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1035
-	    		$data['format_source'] = 'radarvirtueljson';
1036
-    			$data['id_source'] = $id_source;
1035
+				$data['format_source'] = 'radarvirtueljson';
1036
+				$data['id_source'] = $id_source;
1037 1037
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1038 1038
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1039 1039
 			$SI->add($data);
1040 1040
 			unset($data);
1041
-		    }
1041
+			}
1042
+		}
1042 1043
 		}
1043
-	    }
1044
-	    //$last_exec['radarvirtueljson'] = time();
1045
-	    $last_exec[$id]['last'] = time();
1044
+		//$last_exec['radarvirtueljson'] = time();
1045
+		$last_exec[$id]['last'] = time();
1046 1046
 	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1047 1047
 	} elseif ($value['format'] == 'pirepsjson' && 
1048
-	    (
1048
+		(
1049 1049
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1050 1050
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1051
-	    )
1051
+		)
1052 1052
 	) {
1053
-	    //$buffer = $Common->getData($hosts[$id]);
1054
-	    $buffer = $Common->getData($value['host'].'?'.time());
1055
-	    $all_data = json_decode(utf8_encode($buffer),true);
1053
+		//$buffer = $Common->getData($hosts[$id]);
1054
+		$buffer = $Common->getData($value['host'].'?'.time());
1055
+		$all_data = json_decode(utf8_encode($buffer),true);
1056 1056
 	    
1057
-	    if (isset($all_data['pireps'])) {
1057
+		if (isset($all_data['pireps'])) {
1058 1058
 		$reset = 0;
1059
-	        foreach ($all_data['pireps'] as $line) {
1060
-		    $data = array();
1061
-		    $data['id'] = $line['id'];
1062
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1063
-		    $data['ident'] = $line['callsign']; // ident
1064
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1065
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1066
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1067
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1068
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1069
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1070
-		    $data['latitude'] = $line['lat']; // lat
1071
-		    $data['longitude'] = $line['lon']; // long
1072
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1073
-		    //$data['squawk'] = $line['squawk']; // squawk
1074
-		    //$data['emergency'] = ''; // emergency
1075
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1076
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1077
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1078
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1079
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1080
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1081
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1082
-		    else $data['info'] = '';
1083
-		    $data['format_source'] = 'pireps';
1084
-    		    $data['id_source'] = $id_source;
1085
-		    $data['datetime'] = date('Y-m-d H:i:s');
1086
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1087
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1088
-		    if ($line['icon'] == 'plane') {
1059
+			foreach ($all_data['pireps'] as $line) {
1060
+			$data = array();
1061
+			$data['id'] = $line['id'];
1062
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1063
+			$data['ident'] = $line['callsign']; // ident
1064
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1065
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1066
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1067
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1068
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1069
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1070
+			$data['latitude'] = $line['lat']; // lat
1071
+			$data['longitude'] = $line['lon']; // long
1072
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1073
+			//$data['squawk'] = $line['squawk']; // squawk
1074
+			//$data['emergency'] = ''; // emergency
1075
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1076
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1077
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1078
+			//$data['arrival_airport_time'] = $line['arrtime'];
1079
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1080
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1081
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1082
+			else $data['info'] = '';
1083
+			$data['format_source'] = 'pireps';
1084
+				$data['id_source'] = $id_source;
1085
+			$data['datetime'] = date('Y-m-d H:i:s');
1086
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1087
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1088
+			if ($line['icon'] == 'plane') {
1089 1089
 			$SI->add($data);
1090
-		    //    print_r($data);
1091
-    		    } elseif ($line['icon'] == 'ct') {
1090
+			//    print_r($data);
1091
+				} elseif ($line['icon'] == 'ct') {
1092 1092
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1093 1093
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1094 1094
 			$typec = substr($data['ident'],-3);
@@ -1103,148 +1103,148 @@  discard block
 block discarded – undo
1103 1103
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1104 1104
 			else $data['type'] = 'Observer';
1105 1105
 			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']);
1106
-		    }
1107
-		    unset($data);
1106
+			}
1107
+			unset($data);
1108
+		}
1108 1109
 		}
1109
-	    }
1110
-	    //$last_exec['pirepsjson'] = time();
1111
-	    $last_exec[$id]['last'] = time();
1110
+		//$last_exec['pirepsjson'] = time();
1111
+		$last_exec[$id]['last'] = time();
1112 1112
 	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1113 1113
 	} elseif ($value['format'] == 'phpvmacars' && 
1114
-	    (
1114
+		(
1115 1115
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1116 1116
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1117
-	    )
1117
+		)
1118 1118
 	) {
1119
-	    //$buffer = $Common->getData($hosts[$id]);
1120
-	    if ($globalDebug) echo 'Get Data...'."\n";
1121
-	    $buffer = $Common->getData($value['host']);
1122
-	    $all_data = json_decode($buffer,true);
1123
-	    if ($buffer != '' && is_array($all_data)) {
1119
+		//$buffer = $Common->getData($hosts[$id]);
1120
+		if ($globalDebug) echo 'Get Data...'."\n";
1121
+		$buffer = $Common->getData($value['host']);
1122
+		$all_data = json_decode($buffer,true);
1123
+		if ($buffer != '' && is_array($all_data)) {
1124 1124
 		$reset = 0;
1125 1125
 		foreach ($all_data as $line) {
1126
-	    	    $data = array();
1127
-	    	    //$data['id'] = $line['id']; // id not usable
1128
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1129
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1130
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1131
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1132
-	    	    $data['ident'] = $line['flightnum']; // ident
1133
-	    	    $data['altitude'] = $line['alt']; // altitude
1134
-	    	    $data['speed'] = $line['gs']; // speed
1135
-	    	    $data['heading'] = $line['heading']; // heading
1136
-	    	    $data['latitude'] = $line['lat']; // lat
1137
-	    	    $data['longitude'] = $line['lng']; // long
1138
-	    	    $data['verticalrate'] = ''; // verticale rate
1139
-	    	    $data['squawk'] = ''; // squawk
1140
-	    	    $data['emergency'] = ''; // emergency
1141
-	    	    //$data['datetime'] = $line['lastupdate'];
1142
-	    	    //$data['last_update'] = $line['lastupdate'];
1143
-	    	    if (isset($value['timezone'])) {
1144
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1145
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1146
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1147
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1148
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1149
-	    	    $data['departure_airport_time'] = $line['deptime'];
1150
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1151
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1152
-    		    $data['registration'] = $line['aircraft'];
1153
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1154
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1155
-		    if (isset($line['aircraftname'])) {
1126
+				$data = array();
1127
+				//$data['id'] = $line['id']; // id not usable
1128
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1129
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1130
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1131
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1132
+				$data['ident'] = $line['flightnum']; // ident
1133
+				$data['altitude'] = $line['alt']; // altitude
1134
+				$data['speed'] = $line['gs']; // speed
1135
+				$data['heading'] = $line['heading']; // heading
1136
+				$data['latitude'] = $line['lat']; // lat
1137
+				$data['longitude'] = $line['lng']; // long
1138
+				$data['verticalrate'] = ''; // verticale rate
1139
+				$data['squawk'] = ''; // squawk
1140
+				$data['emergency'] = ''; // emergency
1141
+				//$data['datetime'] = $line['lastupdate'];
1142
+				//$data['last_update'] = $line['lastupdate'];
1143
+				if (isset($value['timezone'])) {
1144
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1145
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1146
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1147
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1148
+				$data['departure_airport_icao'] = $line['depicao'];
1149
+				$data['departure_airport_time'] = $line['deptime'];
1150
+				$data['arrival_airport_icao'] = $line['arricao'];
1151
+				$data['arrival_airport_time'] = $line['arrtime'];
1152
+				$data['registration'] = $line['aircraft'];
1153
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1154
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1155
+			if (isset($line['aircraftname'])) {
1156 1156
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1157 1157
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1158
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1159
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1160
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1161
-	    		else {
1162
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1163
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1164
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1165
-	    		}
1166
-	    	    }
1167
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1168
-    		    $data['id_source'] = $id_source;
1169
-	    	    $data['format_source'] = 'phpvmacars';
1170
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1171
-		    $SI->add($data);
1172
-		    unset($data);
1158
+				$aircraft_data = explode('-',$line['aircraftname']);
1159
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1160
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1161
+				else {
1162
+					$aircraft_data = explode(' ',$line['aircraftname']);
1163
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1164
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1165
+				}
1166
+				}
1167
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1168
+				$data['id_source'] = $id_source;
1169
+				$data['format_source'] = 'phpvmacars';
1170
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1171
+			$SI->add($data);
1172
+			unset($data);
1173 1173
 		}
1174 1174
 		if ($globalDebug) echo 'No more data...'."\n";
1175 1175
 		unset($buffer);
1176 1176
 		unset($all_data);
1177
-	    }
1178
-	    //$last_exec['phpvmacars'] = time();
1179
-	    $last_exec[$id]['last'] = time();
1177
+		}
1178
+		//$last_exec['phpvmacars'] = time();
1179
+		$last_exec[$id]['last'] = time();
1180 1180
 	} elseif ($value['format'] == 'vam' && 
1181
-	    (
1181
+		(
1182 1182
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1183 1183
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1184
-	    )
1184
+		)
1185 1185
 	) {
1186
-	    //$buffer = $Common->getData($hosts[$id]);
1187
-	    if ($globalDebug) echo 'Get Data...'."\n";
1188
-	    $buffer = $Common->getData($value['host']);
1189
-	    $all_data = json_decode($buffer,true);
1190
-	    if ($buffer != '' && is_array($all_data)) {
1186
+		//$buffer = $Common->getData($hosts[$id]);
1187
+		if ($globalDebug) echo 'Get Data...'."\n";
1188
+		$buffer = $Common->getData($value['host']);
1189
+		$all_data = json_decode($buffer,true);
1190
+		if ($buffer != '' && is_array($all_data)) {
1191 1191
 		$reset = 0;
1192 1192
 		foreach ($all_data as $line) {
1193
-	    	    $data = array();
1194
-	    	    //$data['id'] = $line['id']; // id not usable
1195
-	    	    $data['id'] = trim($line['flight_id']);
1196
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1197
-	    	    $data['pilot_name'] = $line['pilot_name'];
1198
-	    	    $data['pilot_id'] = $line['pilot_id'];
1199
-	    	    $data['ident'] = trim($line['callsign']); // ident
1200
-	    	    $data['altitude'] = $line['altitude']; // altitude
1201
-	    	    $data['speed'] = $line['gs']; // speed
1202
-	    	    $data['heading'] = $line['heading']; // heading
1203
-	    	    $data['latitude'] = $line['latitude']; // lat
1204
-	    	    $data['longitude'] = $line['longitude']; // long
1205
-	    	    $data['verticalrate'] = ''; // verticale rate
1206
-	    	    $data['squawk'] = ''; // squawk
1207
-	    	    $data['emergency'] = ''; // emergency
1208
-	    	    //$data['datetime'] = $line['lastupdate'];
1209
-	    	    $data['last_update'] = $line['last_update'];
1210
-		    $data['datetime'] = date('Y-m-d H:i:s');
1211
-	    	    $data['departure_airport_icao'] = $line['departure'];
1212
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1213
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1214
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1215
-    		    //$data['registration'] = $line['aircraft'];
1216
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1217
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1218
-    		    $data['id_source'] = $id_source;
1219
-	    	    $data['format_source'] = 'vam';
1220
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1221
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1222
-		    $SI->add($data);
1223
-		    unset($data);
1193
+				$data = array();
1194
+				//$data['id'] = $line['id']; // id not usable
1195
+				$data['id'] = trim($line['flight_id']);
1196
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1197
+				$data['pilot_name'] = $line['pilot_name'];
1198
+				$data['pilot_id'] = $line['pilot_id'];
1199
+				$data['ident'] = trim($line['callsign']); // ident
1200
+				$data['altitude'] = $line['altitude']; // altitude
1201
+				$data['speed'] = $line['gs']; // speed
1202
+				$data['heading'] = $line['heading']; // heading
1203
+				$data['latitude'] = $line['latitude']; // lat
1204
+				$data['longitude'] = $line['longitude']; // long
1205
+				$data['verticalrate'] = ''; // verticale rate
1206
+				$data['squawk'] = ''; // squawk
1207
+				$data['emergency'] = ''; // emergency
1208
+				//$data['datetime'] = $line['lastupdate'];
1209
+				$data['last_update'] = $line['last_update'];
1210
+			$data['datetime'] = date('Y-m-d H:i:s');
1211
+				$data['departure_airport_icao'] = $line['departure'];
1212
+				//$data['departure_airport_time'] = $line['departure_time'];
1213
+				$data['arrival_airport_icao'] = $line['arrival'];
1214
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1215
+				//$data['registration'] = $line['aircraft'];
1216
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1217
+				$data['aircraft_icao'] = $line['plane_type'];
1218
+				$data['id_source'] = $id_source;
1219
+				$data['format_source'] = 'vam';
1220
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1221
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1222
+			$SI->add($data);
1223
+			unset($data);
1224 1224
 		}
1225 1225
 		if ($globalDebug) echo 'No more data...'."\n";
1226 1226
 		unset($buffer);
1227 1227
 		unset($all_data);
1228
-	    }
1229
-	    //$last_exec['phpvmacars'] = time();
1230
-	    $last_exec[$id]['last'] = time();
1228
+		}
1229
+		//$last_exec['phpvmacars'] = time();
1230
+		$last_exec[$id]['last'] = time();
1231 1231
 	} elseif ($value['format'] == 'blitzortung' && 
1232
-	    (
1232
+		(
1233 1233
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1234 1234
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1235
-	    )
1235
+		)
1236 1236
 	) {
1237
-	    //$buffer = $Common->getData($hosts[$id]);
1238
-	    if ($globalDebug) echo 'Get Data...'."\n";
1239
-	    $buffer = $Common->getData($value['host']);
1240
-	    $all_data = json_decode($buffer,true);
1241
-	    if ($buffer != '') {
1237
+		//$buffer = $Common->getData($hosts[$id]);
1238
+		if ($globalDebug) echo 'Get Data...'."\n";
1239
+		$buffer = $Common->getData($value['host']);
1240
+		$all_data = json_decode($buffer,true);
1241
+		if ($buffer != '') {
1242 1242
 		$Source->deleteLocationBySource('blitzortung');
1243 1243
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1244 1244
 		$buffer = explode('\n',$buffer);
1245 1245
 		foreach ($buffer as $buffer_line) {
1246
-		    $line = json_decode($buffer_line,true);
1247
-		    if (isset($line['time'])) {
1246
+			$line = json_decode($buffer_line,true);
1247
+			if (isset($line['time'])) {
1248 1248
 			$data = array();
1249 1249
 			$data['altitude'] = $line['alt']; // altitude
1250 1250
 			$data['latitude'] = $line['lat']; // lat
@@ -1256,94 +1256,94 @@  discard block
 block discarded – undo
1256 1256
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1257 1257
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1258 1258
 			unset($data);
1259
-		    }
1259
+			}
1260 1260
 		}
1261 1261
 		if ($globalDebug) echo 'No more data...'."\n";
1262 1262
 		unset($buffer);
1263
-	    }
1264
-	    $last_exec[$id]['last'] = time();
1263
+		}
1264
+		$last_exec[$id]['last'] = time();
1265 1265
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1266 1266
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1267
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1268
-    	    //$last_exec[$id]['last'] = time();
1267
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1268
+			//$last_exec[$id]['last'] = time();
1269 1269
 
1270
-	    //$read = array( $sockets[$id] );
1271
-	    $read = $sockets;
1272
-	    $write = NULL;
1273
-	    $e = NULL;
1274
-	    $n = socket_select($read, $write, $e, $timeout);
1275
-	    if ($e != NULL) var_dump($e);
1276
-	    if ($n > 0) {
1270
+		//$read = array( $sockets[$id] );
1271
+		$read = $sockets;
1272
+		$write = NULL;
1273
+		$e = NULL;
1274
+		$n = socket_select($read, $write, $e, $timeout);
1275
+		if ($e != NULL) var_dump($e);
1276
+		if ($n > 0) {
1277 1277
 		$reset = 0;
1278 1278
 		foreach ($read as $nb => $r) {
1279
-		    //$value = $formats[$nb];
1280
-		    $format = $globalSources[$nb]['format'];
1281
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1279
+			//$value = $formats[$nb];
1280
+			$format = $globalSources[$nb]['format'];
1281
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1282 1282
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1283
-		    } elseif ($format == 'vrstcp') {
1283
+			} elseif ($format == 'vrstcp') {
1284 1284
 			$buffer = @socket_read($r, 6000);
1285
-		    } else {
1285
+			} else {
1286 1286
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1287
-		    }
1288
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1289
-		    //echo $buffer."\n";
1290
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1291
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1292
-		    $error = false;
1293
-		    //$SI::del();
1294
-		    if ($format == 'vrstcp') {
1287
+			}
1288
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1289
+			//echo $buffer."\n";
1290
+			// lets play nice and handle signals such as ctrl-c/kill properly
1291
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1292
+			$error = false;
1293
+			//$SI::del();
1294
+			if ($format == 'vrstcp') {
1295 1295
 			$buffer = explode('},{',$buffer);
1296
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1297
-		    // SBS format is CSV format
1298
-		    if ($buffer !== FALSE && $buffer != '') {
1296
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1297
+			// SBS format is CSV format
1298
+			if ($buffer !== FALSE && $buffer != '') {
1299 1299
 			$tt[$format] = 0;
1300 1300
 			if ($format == 'acarssbs3') {
1301
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1302
-			    $ACARS->add(trim($buffer));
1303
-			    $ACARS->deleteLiveAcarsData();
1301
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1302
+				$ACARS->add(trim($buffer));
1303
+				$ACARS->deleteLiveAcarsData();
1304 1304
 			} elseif ($format == 'raw') {
1305
-			    // AVR format
1306
-			    $data = $SBS->parse($buffer);
1307
-			    if (is_array($data)) {
1305
+				// AVR format
1306
+				$data = $SBS->parse($buffer);
1307
+				if (is_array($data)) {
1308 1308
 				$data['datetime'] = date('Y-m-d H:i:s');
1309 1309
 				$data['format_source'] = 'raw';
1310 1310
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1311 1311
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1312 1312
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1313 1313
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1314
-			    }
1314
+				}
1315 1315
 			} elseif ($format == 'ais') {
1316
-			    $ais_data = $AIS->parse_line(trim($buffer));
1317
-			    $data = array();
1318
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1319
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1320
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1321
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1322
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1323
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1324
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1325
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1326
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1327
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1328
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1329
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1330
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1331
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1332
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1333
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1316
+				$ais_data = $AIS->parse_line(trim($buffer));
1317
+				$data = array();
1318
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1319
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1320
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1321
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1322
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1323
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1324
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1325
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1326
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1327
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1328
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1329
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1330
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1331
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1332
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1333
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1334 1334
 
1335
-			    if (isset($ais_data['timestamp'])) {
1335
+				if (isset($ais_data['timestamp'])) {
1336 1336
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1337
-			    } else {
1337
+				} else {
1338 1338
 				$data['datetime'] = date('Y-m-d H:i:s');
1339
-			    }
1340
-			    $data['format_source'] = 'aisnmea';
1341
-    			    $data['id_source'] = $id_source;
1342
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1343
-			    unset($data);
1344
-                        } elseif ($format == 'flightgearsp') {
1345
-                    	    //echo $buffer."\n";
1346
-                    	    if (strlen($buffer) > 5) {
1339
+				}
1340
+				$data['format_source'] = 'aisnmea';
1341
+					$data['id_source'] = $id_source;
1342
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1343
+				unset($data);
1344
+						} elseif ($format == 'flightgearsp') {
1345
+							//echo $buffer."\n";
1346
+							if (strlen($buffer) > 5) {
1347 1347
 				$line = explode(',',$buffer);
1348 1348
 				$data = array();
1349 1349
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1360,38 +1360,38 @@  discard block
 block discarded – undo
1360 1360
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1361 1361
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1362 1362
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1363
-			    }
1364
-                        } elseif ($format == 'acars') {
1365
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1366
-			    $ACARS->add(trim($buffer));
1367
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1368
-			    $ACARS->deleteLiveAcarsData();
1363
+				}
1364
+						} elseif ($format == 'acars') {
1365
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1366
+				$ACARS->add(trim($buffer));
1367
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1368
+				$ACARS->deleteLiveAcarsData();
1369 1369
 			} elseif ($format == 'flightgearmp') {
1370
-			    if (substr($buffer,0,1) != '#') {
1370
+				if (substr($buffer,0,1) != '#') {
1371 1371
 				$data = array();
1372 1372
 				//echo $buffer."\n";
1373 1373
 				$line = explode(' ',$buffer);
1374 1374
 				if (count($line) == 11) {
1375
-				    $userserver = explode('@',$line[0]);
1376
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1377
-				    $data['ident'] = $userserver[0];
1378
-				    $data['registration'] = $userserver[0];
1379
-				    $data['latitude'] = $line[4];
1380
-				    $data['longitude'] = $line[5];
1381
-				    $data['altitude'] = $line[6];
1382
-				    $data['datetime'] = date('Y-m-d H:i:s');
1383
-				    $aircraft_type = $line[10];
1384
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1385
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1386
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1387
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1375
+					$userserver = explode('@',$line[0]);
1376
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1377
+					$data['ident'] = $userserver[0];
1378
+					$data['registration'] = $userserver[0];
1379
+					$data['latitude'] = $line[4];
1380
+					$data['longitude'] = $line[5];
1381
+					$data['altitude'] = $line[6];
1382
+					$data['datetime'] = date('Y-m-d H:i:s');
1383
+					$aircraft_type = $line[10];
1384
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1385
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1386
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1387
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1388
+				}
1388 1389
 				}
1389
-			    }
1390 1390
 			} elseif ($format == 'beast') {
1391
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1392
-			    die;
1391
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1392
+				die;
1393 1393
 			} elseif ($format == 'vrstcp') {
1394
-			    foreach($buffer as $all_data) {
1394
+				foreach($buffer as $all_data) {
1395 1395
 				$line = json_decode('{'.$all_data.'}',true);
1396 1396
 				$data = array();
1397 1397
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1411,148 +1411,148 @@  discard block
 block discarded – undo
1411 1411
 				*/
1412 1412
 				$data['datetime'] = date('Y-m-d H:i:s');
1413 1413
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1414
-		    		$data['format_source'] = 'vrstcp';
1414
+					$data['format_source'] = 'vrstcp';
1415 1415
 				$data['id_source'] = $id_source;
1416 1416
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1417 1417
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1418 1418
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1419 1419
 				unset($data);
1420
-			    }
1420
+				}
1421 1421
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1422
-			    $line = explode("\t", $buffer);
1423
-			    for($k = 0; $k < count($line); $k=$k+2) {
1422
+				$line = explode("\t", $buffer);
1423
+				for($k = 0; $k < count($line); $k=$k+2) {
1424 1424
 				$key = $line[$k];
1425
-			        $lined[$key] = $line[$k+1];
1426
-			    }
1427
-    			    if (count($lined) > 3) {
1428
-    				$data['hex'] = $lined['hexid'];
1429
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1430
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1431
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1432
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1433
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1434
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1435
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1436
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1437
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1438
-    				$data['id_source'] = $id_source;
1439
-    				$data['format_source'] = 'tsv';
1440
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1441
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1425
+					$lined[$key] = $line[$k+1];
1426
+				}
1427
+					if (count($lined) > 3) {
1428
+					$data['hex'] = $lined['hexid'];
1429
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1430
+					$data['datetime'] = date('Y-m-d H:i:s');;
1431
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1432
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1433
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1434
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1435
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1436
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1437
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1438
+					$data['id_source'] = $id_source;
1439
+					$data['format_source'] = 'tsv';
1440
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1441
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1442 1442
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1443
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1444
-    				unset($lined);
1445
-    				unset($data);
1446
-    			    } else $error = true;
1443
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1444
+					unset($lined);
1445
+					unset($data);
1446
+					} else $error = true;
1447 1447
 			} elseif ($format == 'aprs' && $use_aprs) {
1448
-			    if ($aprs_connect == 0) {
1448
+				if ($aprs_connect == 0) {
1449 1449
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1450 1450
 				$aprs_connect = 1;
1451
-			    }
1451
+				}
1452 1452
 			    
1453
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1453
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1454 1454
 				$aprs_last_tx = time();
1455 1455
 				$data_aprs = "# Keep alive";
1456 1456
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1457
-			    }
1457
+				}
1458 1458
 			    
1459
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1460
-			    //echo 'APRS data : '.$buffer."\n";
1461
-			    $buffer = str_replace('APRS <- ','',$buffer);
1462
-			    $buffer = str_replace('APRS -> ','',$buffer);
1463
-			    //echo $buffer."\n";
1464
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1459
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1460
+				//echo 'APRS data : '.$buffer."\n";
1461
+				$buffer = str_replace('APRS <- ','',$buffer);
1462
+				$buffer = str_replace('APRS -> ','',$buffer);
1463
+				//echo $buffer."\n";
1464
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1465 1465
 				$line = $APRS->parse($buffer);
1466 1466
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1467 1467
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1468
-				    $aprs_last_tx = time();
1469
-				    $data = array();
1470
-				    //print_r($line);
1471
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1472
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1473
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1474
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1475
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1476
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1477
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1478
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1479
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1480
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1481
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1482
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1483
-				    $data['latitude'] = $line['latitude'];
1484
-				    $data['longitude'] = $line['longitude'];
1485
-				    //$data['verticalrate'] = $line[16];
1486
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1487
-				    //else $data['speed'] = 0;
1488
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1489
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1490
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1491
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1492
-				    //else $data['heading'] = 0;
1493
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1494
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1495
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1496
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1497
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1498
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1499
-    				    $data['id_source'] = $id_source;
1500
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1501
-				    else $data['format_source'] = 'aprs';
1502
-				    $data['source_name'] = $line['source'];
1503
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1504
-				    else $data['source_type'] = 'flarm';
1505
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1506
-				    $currentdate = date('Y-m-d H:i:s');
1507
-				    $aprsdate = strtotime($data['datetime']);
1508
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1509
-				    // Accept data if time <= system time + 20s
1510
-				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1511
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1468
+					$aprs_last_tx = time();
1469
+					$data = array();
1470
+					//print_r($line);
1471
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1472
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1473
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1474
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1475
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1476
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1477
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1478
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1479
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1480
+					else $data['datetime'] = date('Y-m-d H:i:s');
1481
+					//$data['datetime'] = date('Y-m-d H:i:s');
1482
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1483
+					$data['latitude'] = $line['latitude'];
1484
+					$data['longitude'] = $line['longitude'];
1485
+					//$data['verticalrate'] = $line[16];
1486
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1487
+					//else $data['speed'] = 0;
1488
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1489
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1490
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1491
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1492
+					//else $data['heading'] = 0;
1493
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1494
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1495
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1496
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1497
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1498
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1499
+						$data['id_source'] = $id_source;
1500
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1501
+					else $data['format_source'] = 'aprs';
1502
+					$data['source_name'] = $line['source'];
1503
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1504
+					else $data['source_type'] = 'flarm';
1505
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1506
+					$currentdate = date('Y-m-d H:i:s');
1507
+					$aprsdate = strtotime($data['datetime']);
1508
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1509
+					// Accept data if time <= system time + 20s
1510
+					//if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1511
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1512 1512
 					$send = $SI->add($data);
1513
-				    } elseif ($data['source_type'] == 'ais') {
1513
+					} elseif ($data['source_type'] == 'ais') {
1514 1514
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1515
-				    } elseif (isset($line['stealth'])) {
1515
+					} elseif (isset($line['stealth'])) {
1516 1516
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1517 1517
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1518
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1519
-					    //$line['symbol'] == 'Balloon' ||
1520
-					    $line['symbol'] == 'Glider' || 
1521
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1522
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1523
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1524
-					    $send = $SI->add($data);
1525
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1526
-					    $line['symbol'] == 'Yacht (Sail)' || 
1527
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1528
-					    $send = $MI->add($data);
1529
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1530
-					    $line['symbol'] == 'Car' || 
1531
-					    $line['symbol'] == 'Ambulance' || 
1532
-					    $line['symbol'] == 'Van' || 
1533
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1534
-					    $line['symbol'] == 'Motorcycle' || 
1535
-					    $line['symbol'] == 'Tractor' || 
1536
-					    $line['symbol'] == 'Police' || 
1537
-					    $line['symbol'] == 'Bike' || 
1538
-					    $line['symbol'] == 'Jogger' || 
1539
-					    $line['symbol'] == 'Horse' || 
1540
-					    $line['symbol'] == 'Bus' || 
1541
-					    $line['symbol'] == 'Jeep' || 
1542
-					    $line['symbol'] == 'Recreational Vehicle' || 
1543
-					    $line['symbol'] == 'Yacht (Sail)' || 
1544
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1545
-					    $line['symbol'] == 'Firetruck' || 
1546
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1547
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1548
-					    $line['symbol'] == 'SUV' ||
1549
-					    $line['symbol'] == 'Snowmobile' ||
1550
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1551
-				    //} 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') {
1518
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1519
+						//$line['symbol'] == 'Balloon' ||
1520
+						$line['symbol'] == 'Glider' || 
1521
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1522
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1523
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1524
+						$send = $SI->add($data);
1525
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1526
+						$line['symbol'] == 'Yacht (Sail)' || 
1527
+						$line['symbol'] == 'Ship (Power Boat)')) {
1528
+						$send = $MI->add($data);
1529
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1530
+						$line['symbol'] == 'Car' || 
1531
+						$line['symbol'] == 'Ambulance' || 
1532
+						$line['symbol'] == 'Van' || 
1533
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1534
+						$line['symbol'] == 'Motorcycle' || 
1535
+						$line['symbol'] == 'Tractor' || 
1536
+						$line['symbol'] == 'Police' || 
1537
+						$line['symbol'] == 'Bike' || 
1538
+						$line['symbol'] == 'Jogger' || 
1539
+						$line['symbol'] == 'Horse' || 
1540
+						$line['symbol'] == 'Bus' || 
1541
+						$line['symbol'] == 'Jeep' || 
1542
+						$line['symbol'] == 'Recreational Vehicle' || 
1543
+						$line['symbol'] == 'Yacht (Sail)' || 
1544
+						$line['symbol'] == 'Ship (Power Boat)' || 
1545
+						$line['symbol'] == 'Firetruck' || 
1546
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1547
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1548
+						$line['symbol'] == 'SUV' ||
1549
+						$line['symbol'] == 'Snowmobile' ||
1550
+						$line['symbol'] == 'Mobile Satellite Station')) {
1551
+					//} 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') {
1552 1552
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1553 1553
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1554 1554
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1555
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1555
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1556 1556
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1557 1557
 					$Source->deleteOldLocationByType('gs');
1558 1558
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
 					} else {
1561 1561
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1562 1562
 					}
1563
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1563
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1564 1564
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1565 1565
 					if ($globalDebug) echo '# Weather Station added'."\n";
1566 1566
 					$Source->deleteOldLocationByType('wx');
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
 					} else {
1571 1571
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1572 1572
 					}
1573
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1573
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1574 1574
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1575 1575
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1576 1576
 					$Source->deleteOldLocationByType('lightning');
@@ -1579,11 +1579,11 @@  discard block
 block discarded – undo
1579 1579
 					} else {
1580 1580
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1581 1581
 					}
1582
-				    } elseif ($globalDebug) {
1583
-				    	echo '/!\ Not added: '.$buffer."\n";
1584
-				    	print_r($line);
1585
-				    }
1586
-				    unset($data);
1582
+					} elseif ($globalDebug) {
1583
+						echo '/!\ Not added: '.$buffer."\n";
1584
+						print_r($line);
1585
+					}
1586
+					unset($data);
1587 1587
 				}
1588 1588
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1589 1589
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1602,12 +1602,12 @@  discard block
 block discarded – undo
1602 1602
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1603 1603
 					$globalSources[$nb]['last_weather_clean'] = time();
1604 1604
 				}
1605
-			    }
1605
+				}
1606 1606
 			} else {
1607
-			    $line = explode(',', $buffer);
1608
-    			    if (count($line) > 20) {
1609
-    			    	$data['hex'] = $line[4];
1610
-    				/*
1607
+				$line = explode(',', $buffer);
1608
+					if (count($line) > 20) {
1609
+						$data['hex'] = $line[4];
1610
+					/*
1611 1611
     				$data['datetime'] = $line[6].' '.$line[7];
1612 1612
     					date_default_timezone_set($globalTimezone);
1613 1613
     					$datetime = new DateTime($data['datetime']);
@@ -1615,30 +1615,30 @@  discard block
 block discarded – undo
1615 1615
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1616 1616
     					date_default_timezone_set('UTC');
1617 1617
     				*/
1618
-    				// Force datetime to current UTC datetime
1619
-    				date_default_timezone_set('UTC');
1620
-    				$data['datetime'] = date('Y-m-d H:i:s');
1621
-    				$data['ident'] = trim($line[10]);
1622
-    				$data['latitude'] = $line[14];
1623
-    				$data['longitude'] = $line[15];
1624
-    				$data['verticalrate'] = $line[16];
1625
-    				$data['emergency'] = $line[20];
1626
-    				$data['speed'] = $line[12];
1627
-    				$data['squawk'] = $line[17];
1628
-    				$data['altitude'] = $line[11];
1629
-    				$data['heading'] = $line[13];
1630
-    				$data['ground'] = $line[21];
1631
-    				$data['emergency'] = $line[19];
1632
-    				$data['format_source'] = 'sbs';
1618
+					// Force datetime to current UTC datetime
1619
+					date_default_timezone_set('UTC');
1620
+					$data['datetime'] = date('Y-m-d H:i:s');
1621
+					$data['ident'] = trim($line[10]);
1622
+					$data['latitude'] = $line[14];
1623
+					$data['longitude'] = $line[15];
1624
+					$data['verticalrate'] = $line[16];
1625
+					$data['emergency'] = $line[20];
1626
+					$data['speed'] = $line[12];
1627
+					$data['squawk'] = $line[17];
1628
+					$data['altitude'] = $line[11];
1629
+					$data['heading'] = $line[13];
1630
+					$data['ground'] = $line[21];
1631
+					$data['emergency'] = $line[19];
1632
+					$data['format_source'] = 'sbs';
1633 1633
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1634
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1634
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1635 1635
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1636
-    				$data['id_source'] = $id_source;
1637
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1638
-    				else $error = true;
1639
-    				unset($data);
1640
-    			    } else $error = true;
1641
-			    if ($error) {
1636
+					$data['id_source'] = $id_source;
1637
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1638
+					else $error = true;
1639
+					unset($data);
1640
+					} else $error = true;
1641
+				if ($error) {
1642 1642
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1643 1643
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1644 1644
 				} else {
@@ -1654,13 +1654,13 @@  discard block
 block discarded – undo
1654 1654
 					connect_all($sourceer);
1655 1655
 					$sourceer = array();
1656 1656
 				}
1657
-			    }
1657
+				}
1658 1658
 			}
1659 1659
 			// Sleep for xxx microseconds
1660 1660
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1661
-		    } else {
1661
+			} else {
1662 1662
 			if ($format == 'flightgearmp') {
1663
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1663
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1664 1664
 				//@socket_close($r);
1665 1665
 				sleep($globalMinFetch);
1666 1666
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1669,9 +1669,9 @@  discard block
 block discarded – undo
1669 1669
 				break;
1670 1670
 				
1671 1671
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1672
-			    if (isset($tt[$format])) $tt[$format]++;
1673
-			    else $tt[$format] = 0;
1674
-			    if ($tt[$format] > 30) {
1672
+				if (isset($tt[$format])) $tt[$format]++;
1673
+				else $tt[$format] = 0;
1674
+				if ($tt[$format] > 30) {
1675 1675
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1676 1676
 				//@socket_close($r);
1677 1677
 				sleep(2);
@@ -1682,23 +1682,23 @@  discard block
 block discarded – undo
1682 1682
 				//connect_all($globalSources);
1683 1683
 				$tt[$format]=0;
1684 1684
 				break;
1685
-			    }
1685
+				}
1686
+			}
1686 1687
 			}
1687
-		    }
1688 1688
 		}
1689
-	    } else {
1689
+		} else {
1690 1690
 		$error = socket_strerror(socket_last_error());
1691 1691
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1692 1692
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1693 1693
 			if (isset($globalDebug)) echo "Restarting...\n";
1694 1694
 			// Restart the script if possible
1695 1695
 			if (is_array($sockets)) {
1696
-			    if ($globalDebug) echo "Shutdown all sockets...";
1696
+				if ($globalDebug) echo "Shutdown all sockets...";
1697 1697
 			    
1698
-			    foreach ($sockets as $sock) {
1698
+				foreach ($sockets as $sock) {
1699 1699
 				@socket_shutdown($sock,2);
1700 1700
 				@socket_close($sock);
1701
-			    }
1701
+				}
1702 1702
 			    
1703 1703
 			}
1704 1704
 			if ($globalDebug) echo "Waiting...";
@@ -1713,15 +1713,15 @@  discard block
 block discarded – undo
1713 1713
 			if ($globalDebug) echo "Restart all connections...";
1714 1714
 			connect_all($globalSources);
1715 1715
 		}
1716
-	    }
1716
+		}
1717 1717
 	}
1718 1718
 	if ($globalDaemon === false) {
1719
-	    if ($globalDebug) echo 'Check all...'."\n";
1720
-	    if (isset($SI)) $SI->checkAll();
1721
-	    if (isset($TI)) $TI->checkAll();
1722
-	    if (isset($MI)) $MI->checkAll();
1719
+		if ($globalDebug) echo 'Check all...'."\n";
1720
+		if (isset($SI)) $SI->checkAll();
1721
+		if (isset($TI)) $TI->checkAll();
1722
+		if (isset($MI)) $MI->checkAll();
1723
+	}
1723 1724
 	}
1724
-    }
1725 1725
 }
1726 1726
 
1727 1727
 ?>
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Indentation   +647 added lines, -647 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
15
+				$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+			} catch(PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19
-    	    }
20
-    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
-    	    }
19
+			}
20
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
+			$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
183
+					$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+				} catch(PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
+				$query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
251
+					$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+				} catch(PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
277
+			$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
289
-			$sth->execute();
290
-    		    } catch(PDOException $e) {
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289
+			$sth->execute();
290
+				} catch(PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
381
-    		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
381
+			$Connection = new Connection();
382
+			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412
-    		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
431
-			$sth->execute();
432
-    		    } catch(PDOException $e) {
412
+			$Connection = new Connection();
413
+			$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
416
+			$sth->execute();
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431
+			$sth->execute();
432
+				} catch(PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443
-            	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
-            	    }
446
-                } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
443
+					} else {
444
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
+					}
446
+				} else {
447
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
497
-    		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
497
+			$Connection = new Connection();
498
+			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
+				$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+				} catch(PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505
-    			}
505
+				}
506 506
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
-    			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
+				$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
664
+				$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
674
+				$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 682
 		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
684
+				$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
694
+				$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 			} catch(PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179
-                }
1179
+				}
1180 1180
 		if (!$Connection->checkColumnName('aircraft','mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 			} catch(PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253
-                }
1253
+				}
1254 1254
 		if (!$Connection->indexExists('accidents','registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 			} catch(PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263
-                }
1263
+				}
1264 1264
 		if (!$Connection->indexExists('accidents','rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			} catch(PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273
-                }
1273
+				}
1274 1274
 
1275 1275
 		$query = "UPDATE config SET value = '31' WHERE name = 'schema_version'";
1276 1276
 		try {
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 			} catch(PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565
-                }
1565
+				}
1566 1566
 		$query = "UPDATE config SET value = '36' WHERE name = 'schema_version'";
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
 			} catch(PDOException $e) {
1724 1724
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1725 1725
 			}
1726
-                }
1726
+				}
1727 1727
 		$query = "UPDATE config SET value = '38' WHERE name = 'schema_version'";
1728 1728
 		try {
1729 1729
 			$sth = $Connection->db->prepare($query);
@@ -2152,210 +2152,210 @@  discard block
 block discarded – undo
2152 2152
 
2153 2153
 
2154 2154
 
2155
-    	public static function check_version($update = false) {
2156
-    	    global $globalDBname;
2157
-    	    $version = 0;
2158
-    	    $Connection = new Connection();
2159
-    	    if ($Connection->tableExists('aircraft')) {
2160
-    		if (!$Connection->tableExists('config')) {
2161
-    		    $version = '1';
2162
-    		    if ($update) return self::update_from_1();
2163
-    		    else return $version;
2155
+		public static function check_version($update = false) {
2156
+			global $globalDBname;
2157
+			$version = 0;
2158
+			$Connection = new Connection();
2159
+			if ($Connection->tableExists('aircraft')) {
2160
+			if (!$Connection->tableExists('config')) {
2161
+				$version = '1';
2162
+				if ($update) return self::update_from_1();
2163
+				else return $version;
2164 2164
 		} else {
2165
-    		    $Connection = new Connection();
2166
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2167
-		    try {
2168
-            		$sth = $Connection->db->prepare($query);
2169
-		        $sth->execute();
2170
-		    } catch(PDOException $e) {
2165
+				$Connection = new Connection();
2166
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2167
+			try {
2168
+					$sth = $Connection->db->prepare($query);
2169
+				$sth->execute();
2170
+			} catch(PDOException $e) {
2171 2171
 			return "error : ".$e->getMessage()."\n";
2172
-    		    }
2173
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
2174
-    		    if ($update) {
2175
-    			if ($result['value'] == '2') {
2176
-    			    $error = self::update_from_2();
2177
-    			    if ($error != '') return $error;
2178
-    			    else return self::check_version(true);
2179
-    			} elseif ($result['value'] == '3') {
2180
-    			    $error = self::update_from_3();
2181
-    			    if ($error != '') return $error;
2182
-    			    else return self::check_version(true);
2183
-    			} elseif ($result['value'] == '4') {
2184
-    			    $error = self::update_from_4();
2185
-    			    if ($error != '') return $error;
2186
-    			    else return self::check_version(true);
2187
-    			} elseif ($result['value'] == '5') {
2188
-    			    $error = self::update_from_5();
2189
-    			    if ($error != '') return $error;
2190
-    			    else return self::check_version(true);
2191
-    			} elseif ($result['value'] == '6') {
2192
-    			    $error = self::update_from_6();
2193
-    			    if ($error != '') return $error;
2194
-    			    else return self::check_version(true);
2195
-    			} elseif ($result['value'] == '7') {
2196
-    			    $error = self::update_from_7();
2197
-    			    if ($error != '') return $error;
2198
-    			    else return self::check_version(true);
2199
-    			} elseif ($result['value'] == '8') {
2200
-    			    $error = self::update_from_8();
2201
-    			    if ($error != '') return $error;
2202
-    			    else return self::check_version(true);
2203
-    			} elseif ($result['value'] == '9') {
2204
-    			    $error = self::update_from_9();
2205
-    			    if ($error != '') return $error;
2206
-    			    else return self::check_version(true);
2207
-    			} elseif ($result['value'] == '10') {
2208
-    			    $error = self::update_from_10();
2209
-    			    if ($error != '') return $error;
2210
-    			    else return self::check_version(true);
2211
-    			} elseif ($result['value'] == '11') {
2212
-    			    $error = self::update_from_11();
2213
-    			    if ($error != '') return $error;
2214
-    			    else return self::check_version(true);
2215
-    			} elseif ($result['value'] == '12') {
2216
-    			    $error = self::update_from_12();
2217
-    			    if ($error != '') return $error;
2218
-    			    else return self::check_version(true);
2219
-    			} elseif ($result['value'] == '13') {
2220
-    			    $error = self::update_from_13();
2221
-    			    if ($error != '') return $error;
2222
-    			    else return self::check_version(true);
2223
-    			} elseif ($result['value'] == '14') {
2224
-    			    $error = self::update_from_14();
2225
-    			    if ($error != '') return $error;
2226
-    			    else return self::check_version(true);
2227
-    			} elseif ($result['value'] == '15') {
2228
-    			    $error = self::update_from_15();
2229
-    			    if ($error != '') return $error;
2230
-    			    else return self::check_version(true);
2231
-    			} elseif ($result['value'] == '16') {
2232
-    			    $error = self::update_from_16();
2233
-    			    if ($error != '') return $error;
2234
-    			    else return self::check_version(true);
2235
-    			} elseif ($result['value'] == '17') {
2236
-    			    $error = self::update_from_17();
2237
-    			    if ($error != '') return $error;
2238
-    			    else return self::check_version(true);
2239
-    			} elseif ($result['value'] == '18') {
2240
-    			    $error = self::update_from_18();
2241
-    			    if ($error != '') return $error;
2242
-    			    else return self::check_version(true);
2243
-    			} elseif ($result['value'] == '19') {
2244
-    			    $error = self::update_from_19();
2245
-    			    if ($error != '') return $error;
2246
-    			    else return self::check_version(true);
2247
-    			} elseif ($result['value'] == '20') {
2248
-    			    $error = self::update_from_20();
2249
-    			    if ($error != '') return $error;
2250
-    			    else return self::check_version(true);
2251
-    			} elseif ($result['value'] == '21') {
2252
-    			    $error = self::update_from_21();
2253
-    			    if ($error != '') return $error;
2254
-    			    else return self::check_version(true);
2255
-    			} elseif ($result['value'] == '22') {
2256
-    			    $error = self::update_from_22();
2257
-    			    if ($error != '') return $error;
2258
-    			    else return self::check_version(true);
2259
-    			} elseif ($result['value'] == '23') {
2260
-    			    $error = self::update_from_23();
2261
-    			    if ($error != '') return $error;
2262
-    			    else return self::check_version(true);
2263
-    			} elseif ($result['value'] == '24') {
2264
-    			    $error = self::update_from_24();
2265
-    			    if ($error != '') return $error;
2266
-    			    else return self::check_version(true);
2267
-    			} elseif ($result['value'] == '25') {
2268
-    			    $error = self::update_from_25();
2269
-    			    if ($error != '') return $error;
2270
-    			    else return self::check_version(true);
2271
-    			} elseif ($result['value'] == '26') {
2272
-    			    $error = self::update_from_26();
2273
-    			    if ($error != '') return $error;
2274
-    			    else return self::check_version(true);
2275
-    			} elseif ($result['value'] == '27') {
2276
-    			    $error = self::update_from_27();
2277
-    			    if ($error != '') return $error;
2278
-    			    else return self::check_version(true);
2279
-    			} elseif ($result['value'] == '28') {
2280
-    			    $error = self::update_from_28();
2281
-    			    if ($error != '') return $error;
2282
-    			    else return self::check_version(true);
2283
-    			} elseif ($result['value'] == '29') {
2284
-    			    $error = self::update_from_29();
2285
-    			    if ($error != '') return $error;
2286
-    			    else return self::check_version(true);
2287
-    			} elseif ($result['value'] == '30') {
2288
-    			    $error = self::update_from_30();
2289
-    			    if ($error != '') return $error;
2290
-    			    else return self::check_version(true);
2291
-    			} elseif ($result['value'] == '31') {
2292
-    			    $error = self::update_from_31();
2293
-    			    if ($error != '') return $error;
2294
-    			    else return self::check_version(true);
2295
-    			} elseif ($result['value'] == '32') {
2296
-    			    $error = self::update_from_32();
2297
-    			    if ($error != '') return $error;
2298
-    			    else return self::check_version(true);
2299
-    			} elseif ($result['value'] == '33') {
2300
-    			    $error = self::update_from_33();
2301
-    			    if ($error != '') return $error;
2302
-    			    else return self::check_version(true);
2303
-    			} elseif ($result['value'] == '34') {
2304
-    			    $error = self::update_from_34();
2305
-    			    if ($error != '') return $error;
2306
-    			    else return self::check_version(true);
2307
-    			} elseif ($result['value'] == '35') {
2308
-    			    $error = self::update_from_35();
2309
-    			    if ($error != '') return $error;
2310
-    			    else return self::check_version(true);
2311
-    			} elseif ($result['value'] == '36') {
2312
-    			    $error = self::update_from_36();
2313
-    			    if ($error != '') return $error;
2314
-    			    else return self::check_version(true);
2315
-    			} elseif ($result['value'] == '37') {
2316
-    			    $error = self::update_from_37();
2317
-    			    if ($error != '') return $error;
2318
-    			    else return self::check_version(true);
2319
-    			} elseif ($result['value'] == '38') {
2320
-    			    $error = self::update_from_38();
2321
-    			    if ($error != '') return $error;
2322
-    			    else return self::check_version(true);
2323
-    			} elseif ($result['value'] == '39') {
2324
-    			    $error = self::update_from_39();
2325
-    			    if ($error != '') return $error;
2326
-    			    else return self::check_version(true);
2327
-    			} elseif ($result['value'] == '40') {
2328
-    			    $error = self::update_from_40();
2329
-    			    if ($error != '') return $error;
2330
-    			    else return self::check_version(true);
2331
-    			} elseif ($result['value'] == '41') {
2332
-    			    $error = self::update_from_41();
2333
-    			    if ($error != '') return $error;
2334
-    			    else return self::check_version(true);
2335
-    			} elseif ($result['value'] == '42') {
2336
-    			    $error = self::update_from_42();
2337
-    			    if ($error != '') return $error;
2338
-    			    else return self::check_version(true);
2339
-    			} elseif ($result['value'] == '43') {
2340
-    			    $error = self::update_from_43();
2341
-    			    if ($error != '') return $error;
2342
-    			    else return self::check_version(true);
2343
-    			} elseif ($result['value'] == '44') {
2344
-    			    $error = self::update_from_44();
2345
-    			    if ($error != '') return $error;
2346
-    			    else return self::check_version(true);
2347
-    			} elseif ($result['value'] == '45') {
2348
-    			    $error = self::update_from_45();
2349
-    			    if ($error != '') return $error;
2350
-    			    else return self::check_version(true);
2351
-    			} else return '';
2352
-    		    } else {
2353
-    			if (isset($result['value']) && $result['value'] != '') return $result['value'];
2354
-    			else return 0;
2172
+				}
2173
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
2174
+				if ($update) {
2175
+				if ($result['value'] == '2') {
2176
+					$error = self::update_from_2();
2177
+					if ($error != '') return $error;
2178
+					else return self::check_version(true);
2179
+				} elseif ($result['value'] == '3') {
2180
+					$error = self::update_from_3();
2181
+					if ($error != '') return $error;
2182
+					else return self::check_version(true);
2183
+				} elseif ($result['value'] == '4') {
2184
+					$error = self::update_from_4();
2185
+					if ($error != '') return $error;
2186
+					else return self::check_version(true);
2187
+				} elseif ($result['value'] == '5') {
2188
+					$error = self::update_from_5();
2189
+					if ($error != '') return $error;
2190
+					else return self::check_version(true);
2191
+				} elseif ($result['value'] == '6') {
2192
+					$error = self::update_from_6();
2193
+					if ($error != '') return $error;
2194
+					else return self::check_version(true);
2195
+				} elseif ($result['value'] == '7') {
2196
+					$error = self::update_from_7();
2197
+					if ($error != '') return $error;
2198
+					else return self::check_version(true);
2199
+				} elseif ($result['value'] == '8') {
2200
+					$error = self::update_from_8();
2201
+					if ($error != '') return $error;
2202
+					else return self::check_version(true);
2203
+				} elseif ($result['value'] == '9') {
2204
+					$error = self::update_from_9();
2205
+					if ($error != '') return $error;
2206
+					else return self::check_version(true);
2207
+				} elseif ($result['value'] == '10') {
2208
+					$error = self::update_from_10();
2209
+					if ($error != '') return $error;
2210
+					else return self::check_version(true);
2211
+				} elseif ($result['value'] == '11') {
2212
+					$error = self::update_from_11();
2213
+					if ($error != '') return $error;
2214
+					else return self::check_version(true);
2215
+				} elseif ($result['value'] == '12') {
2216
+					$error = self::update_from_12();
2217
+					if ($error != '') return $error;
2218
+					else return self::check_version(true);
2219
+				} elseif ($result['value'] == '13') {
2220
+					$error = self::update_from_13();
2221
+					if ($error != '') return $error;
2222
+					else return self::check_version(true);
2223
+				} elseif ($result['value'] == '14') {
2224
+					$error = self::update_from_14();
2225
+					if ($error != '') return $error;
2226
+					else return self::check_version(true);
2227
+				} elseif ($result['value'] == '15') {
2228
+					$error = self::update_from_15();
2229
+					if ($error != '') return $error;
2230
+					else return self::check_version(true);
2231
+				} elseif ($result['value'] == '16') {
2232
+					$error = self::update_from_16();
2233
+					if ($error != '') return $error;
2234
+					else return self::check_version(true);
2235
+				} elseif ($result['value'] == '17') {
2236
+					$error = self::update_from_17();
2237
+					if ($error != '') return $error;
2238
+					else return self::check_version(true);
2239
+				} elseif ($result['value'] == '18') {
2240
+					$error = self::update_from_18();
2241
+					if ($error != '') return $error;
2242
+					else return self::check_version(true);
2243
+				} elseif ($result['value'] == '19') {
2244
+					$error = self::update_from_19();
2245
+					if ($error != '') return $error;
2246
+					else return self::check_version(true);
2247
+				} elseif ($result['value'] == '20') {
2248
+					$error = self::update_from_20();
2249
+					if ($error != '') return $error;
2250
+					else return self::check_version(true);
2251
+				} elseif ($result['value'] == '21') {
2252
+					$error = self::update_from_21();
2253
+					if ($error != '') return $error;
2254
+					else return self::check_version(true);
2255
+				} elseif ($result['value'] == '22') {
2256
+					$error = self::update_from_22();
2257
+					if ($error != '') return $error;
2258
+					else return self::check_version(true);
2259
+				} elseif ($result['value'] == '23') {
2260
+					$error = self::update_from_23();
2261
+					if ($error != '') return $error;
2262
+					else return self::check_version(true);
2263
+				} elseif ($result['value'] == '24') {
2264
+					$error = self::update_from_24();
2265
+					if ($error != '') return $error;
2266
+					else return self::check_version(true);
2267
+				} elseif ($result['value'] == '25') {
2268
+					$error = self::update_from_25();
2269
+					if ($error != '') return $error;
2270
+					else return self::check_version(true);
2271
+				} elseif ($result['value'] == '26') {
2272
+					$error = self::update_from_26();
2273
+					if ($error != '') return $error;
2274
+					else return self::check_version(true);
2275
+				} elseif ($result['value'] == '27') {
2276
+					$error = self::update_from_27();
2277
+					if ($error != '') return $error;
2278
+					else return self::check_version(true);
2279
+				} elseif ($result['value'] == '28') {
2280
+					$error = self::update_from_28();
2281
+					if ($error != '') return $error;
2282
+					else return self::check_version(true);
2283
+				} elseif ($result['value'] == '29') {
2284
+					$error = self::update_from_29();
2285
+					if ($error != '') return $error;
2286
+					else return self::check_version(true);
2287
+				} elseif ($result['value'] == '30') {
2288
+					$error = self::update_from_30();
2289
+					if ($error != '') return $error;
2290
+					else return self::check_version(true);
2291
+				} elseif ($result['value'] == '31') {
2292
+					$error = self::update_from_31();
2293
+					if ($error != '') return $error;
2294
+					else return self::check_version(true);
2295
+				} elseif ($result['value'] == '32') {
2296
+					$error = self::update_from_32();
2297
+					if ($error != '') return $error;
2298
+					else return self::check_version(true);
2299
+				} elseif ($result['value'] == '33') {
2300
+					$error = self::update_from_33();
2301
+					if ($error != '') return $error;
2302
+					else return self::check_version(true);
2303
+				} elseif ($result['value'] == '34') {
2304
+					$error = self::update_from_34();
2305
+					if ($error != '') return $error;
2306
+					else return self::check_version(true);
2307
+				} elseif ($result['value'] == '35') {
2308
+					$error = self::update_from_35();
2309
+					if ($error != '') return $error;
2310
+					else return self::check_version(true);
2311
+				} elseif ($result['value'] == '36') {
2312
+					$error = self::update_from_36();
2313
+					if ($error != '') return $error;
2314
+					else return self::check_version(true);
2315
+				} elseif ($result['value'] == '37') {
2316
+					$error = self::update_from_37();
2317
+					if ($error != '') return $error;
2318
+					else return self::check_version(true);
2319
+				} elseif ($result['value'] == '38') {
2320
+					$error = self::update_from_38();
2321
+					if ($error != '') return $error;
2322
+					else return self::check_version(true);
2323
+				} elseif ($result['value'] == '39') {
2324
+					$error = self::update_from_39();
2325
+					if ($error != '') return $error;
2326
+					else return self::check_version(true);
2327
+				} elseif ($result['value'] == '40') {
2328
+					$error = self::update_from_40();
2329
+					if ($error != '') return $error;
2330
+					else return self::check_version(true);
2331
+				} elseif ($result['value'] == '41') {
2332
+					$error = self::update_from_41();
2333
+					if ($error != '') return $error;
2334
+					else return self::check_version(true);
2335
+				} elseif ($result['value'] == '42') {
2336
+					$error = self::update_from_42();
2337
+					if ($error != '') return $error;
2338
+					else return self::check_version(true);
2339
+				} elseif ($result['value'] == '43') {
2340
+					$error = self::update_from_43();
2341
+					if ($error != '') return $error;
2342
+					else return self::check_version(true);
2343
+				} elseif ($result['value'] == '44') {
2344
+					$error = self::update_from_44();
2345
+					if ($error != '') return $error;
2346
+					else return self::check_version(true);
2347
+				} elseif ($result['value'] == '45') {
2348
+					$error = self::update_from_45();
2349
+					if ($error != '') return $error;
2350
+					else return self::check_version(true);
2351
+				} else return '';
2352
+				} else {
2353
+				if (isset($result['value']) && $result['value'] != '') return $result['value'];
2354
+				else return 0;
2355 2355
 		}
2356 2356
 		
2357
-	    } else return $version;
2358
-    	}
2357
+		} else return $version;
2358
+		}
2359 2359
     	
2360 2360
 }
2361 2361
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Indentation   +387 added lines, -387 removed lines patch added patch discarded remove patch
@@ -76,38 +76,38 @@  discard block
 block discarded – undo
76 76
 		try {
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79
-                        $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
81
-                        return "error : ".$e->getMessage();
82
-                }
79
+						$sth->execute(array(':source' => $database_file));
80
+				} catch(PDOException $e) {
81
+						return "error : ".$e->getMessage();
82
+				}
83 83
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
85
-    		update_db::connect_sqlite($database_file);
84
+			if ($globalDebug) echo " - Add routes to DB -";
85
+			update_db::connect_sqlite($database_file);
86 86
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
87 87
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
88 88
 		try {
89
-                        $sth = update_db::$db_sqlite->prepare($query);
90
-                        $sth->execute();
91
-                } catch(PDOException $e) {
92
-                        return "error : ".$e->getMessage();
93
-                }
89
+						$sth = update_db::$db_sqlite->prepare($query);
90
+						$sth->execute();
91
+				} catch(PDOException $e) {
92
+						return "error : ".$e->getMessage();
93
+				}
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
96 96
 		$Connection = new Connection();
97 97
 		$sth_dest = $Connection->db->prepare($query_dest);
98 98
 		try {
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 102
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104
-            		}
104
+					}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106 106
 		} catch(PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
110
-                return '';
110
+				return '';
111 111
 	}
112 112
 	public static function retrieve_route_oneworld($database_file) {
113 113
 		global $globalDebug, $globalTransaction;
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 		try {
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121
-                        $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
123
-                        return "error : ".$e->getMessage();
124
-                }
121
+						$sth->execute(array(':source' => 'oneworld'));
122
+				} catch(PDOException $e) {
123
+						return "error : ".$e->getMessage();
124
+				}
125 125
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
126
+			if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129 129
 		if ($fh = fopen($database_file,"r")) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			}
148 148
 			if ($globalTransaction) $Connection->db->commit();
149 149
 		}
150
-                return '';
150
+				return '';
151 151
 	}
152 152
 	
153 153
 	public static function retrieve_route_skyteam($database_file) {
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 		try {
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162
-                        $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
164
-                        return "error : ".$e->getMessage();
165
-                }
162
+						$sth->execute(array(':source' => 'skyteam'));
163
+				} catch(PDOException $e) {
164
+						return "error : ".$e->getMessage();
165
+				}
166 166
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
167
+			if ($globalDebug) echo " - Add routes to DB -";
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
192 192
 		}
193
-                return '';
193
+				return '';
194 194
 	}
195 195
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
196 196
 		global $globalTransaction;
@@ -199,27 +199,27 @@  discard block
 block discarded – undo
199 199
 		try {
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202
-                        $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
204
-                        return "error : ".$e->getMessage();
205
-                }
202
+						$sth->execute(array(':source' => $database_file));
203
+				} catch(PDOException $e) {
204
+						return "error : ".$e->getMessage();
205
+				}
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
207 207
 		try {
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210
-                        $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
212
-                        return "error : ".$e->getMessage();
213
-                }
210
+						$sth->execute(array(':source' => $database_file));
211
+				} catch(PDOException $e) {
212
+						return "error : ".$e->getMessage();
213
+				}
214 214
 
215
-    		update_db::connect_sqlite($database_file);
215
+			update_db::connect_sqlite($database_file);
216 216
 		$query = 'select * from Aircraft';
217 217
 		try {
218
-                        $sth = update_db::$db_sqlite->prepare($query);
219
-                        $sth->execute();
220
-                } catch(PDOException $e) {
221
-                        return "error : ".$e->getMessage();
222
-                }
218
+						$sth = update_db::$db_sqlite->prepare($query);
219
+						$sth->execute();
220
+				} catch(PDOException $e) {
221
+						return "error : ".$e->getMessage();
222
+				}
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
224 224
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
225 225
 		
@@ -230,17 +230,17 @@  discard block
 block discarded – undo
230 230
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 231
 		try {
232 232
 			if ($globalTransaction) $Connection->db->beginTransaction();
233
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237 237
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
-				    $sth_dest_owner->execute($query_dest_owner_values);
240
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
+					$sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243
-            		}
243
+					}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245 245
 		} catch(PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 		try {
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254
-                        $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
256
-                        return "error : ".$e->getMessage();
257
-                }
254
+						$sth->execute(array(':source' => $database_file));
255
+				} catch(PDOException $e) {
256
+						return "error : ".$e->getMessage();
257
+				}
258 258
 		return '';
259 259
 	}
260 260
 
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 		try {
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269
-                        $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
271
-                        return "error : ".$e->getMessage();
272
-                }
269
+						$sth->execute(array(':source' => $database_file));
270
+				} catch(PDOException $e) {
271
+						return "error : ".$e->getMessage();
272
+				}
273 273
 		
274 274
 		if ($fh = fopen($database_file,"r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -279,26 +279,26 @@  discard block
 block discarded – undo
279 279
 			$sth_dest = $Connection->db->prepare($query_dest);
280 280
 			try {
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282
-            			while (!feof($fh)) {
283
-            				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
282
+						while (!feof($fh)) {
283
+							$values = array();
284
+							$line = $Common->hex2str(fgets($fh,9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
289
-            				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
291
-            				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
-            				$sth_search = $Connection->db->prepare($query_search);
286
+							$values['ModeS'] = substr($line,0,6);
287
+							$values['Registration'] = trim(substr($line,69,6));
288
+							$aircraft_name = trim(substr($line,48,6));
289
+							// Check if we can find ICAO, else set it to GLID
290
+							$aircraft_name_split = explode(' ',$aircraft_name);
291
+							$search_more = '';
292
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
+							$sth_search = $Connection->db->prepare($query_search);
295 295
 					try {
296
-                                    		$sth_search->execute();
297
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
-	            				//if (count($result) > 0) {
299
-	            				if (isset($result['icao']) && $result['icao'] != '') {
300
-	            				    $values['ICAOTypeCode'] = $result['icao'];
301
-	            				} 
296
+											$sth_search->execute();
297
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
+								//if (count($result) > 0) {
299
+								if (isset($result['icao']) && $result['icao'] != '') {
300
+									$values['ICAOTypeCode'] = $result['icao'];
301
+								} 
302 302
 					} catch(PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 		try {
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324
-                        $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
326
-                        return "error : ".$e->getMessage();
327
-                }
324
+						$sth->execute(array(':source' => $database_file));
325
+				} catch(PDOException $e) {
326
+						return "error : ".$e->getMessage();
327
+				}
328 328
 		return '';
329 329
 	}
330 330
 
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 		try {
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338
-                        $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
340
-                        return "error : ".$e->getMessage();
341
-                }
338
+						$sth->execute(array(':source' => $database_file));
339
+				} catch(PDOException $e) {
340
+						return "error : ".$e->getMessage();
341
+				}
342 342
 		
343 343
 		if ($fh = fopen($database_file,"r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -349,25 +349,25 @@  discard block
 block discarded – undo
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351 351
 				$tmp = fgetcsv($fh,9999,',',"'");
352
-            			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
352
+						while (!feof($fh)) {
353
+							$line = fgetcsv($fh,9999,',',"'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
357
-            				$values['ModeS'] = $line[1];
358
-            				$values['Registration'] = $line[3];
359
-            				$values['ICAOTypeCode'] = '';
360
-            				$aircraft_name = $line[2];
361
-            				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
363
-            				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
-            				$sth_search = $Connection->db->prepare($query_search);
357
+							$values['ModeS'] = $line[1];
358
+							$values['Registration'] = $line[3];
359
+							$values['ICAOTypeCode'] = '';
360
+							$aircraft_name = $line[2];
361
+							// Check if we can find ICAO, else set it to GLID
362
+							$aircraft_name_split = explode(' ',$aircraft_name);
363
+							$search_more = '';
364
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
+							$sth_search = $Connection->db->prepare($query_search);
367 367
 					try {
368
-                                    		$sth_search->execute();
369
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
368
+											$sth_search->execute();
369
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371 371
 					} catch(PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
 		try {
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393
-                        $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
395
-                        return "error : ".$e->getMessage();
396
-                }
393
+						$sth->execute(array(':source' => $database_file));
394
+				} catch(PDOException $e) {
395
+						return "error : ".$e->getMessage();
396
+				}
397 397
 		return '';
398 398
 	}
399 399
 
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
 		try {
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407
-                        $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
409
-                        return "error : ".$e->getMessage();
410
-                }
407
+						$sth->execute(array(':source' => $database_file));
408
+				} catch(PDOException $e) {
409
+						return "error : ".$e->getMessage();
410
+				}
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413 413
 		if ($fh = fopen($database_file,"r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
416
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
417 417
 		        
418 418
 			$Connection = new Connection();
419 419
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -421,126 +421,126 @@  discard block
 block discarded – undo
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423 423
 				$tmp = fgetcsv($fh,9999,',','"');
424
-            			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
426
-            				$values = array();
427
-            				//print_r($line);
428
-            				if ($country == 'F') {
429
-            				    $values['registration'] = $line[0];
430
-            				    $values['base'] = $line[4];
431
-            				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
-					    $values['cancel'] = $line[7];
424
+						while (!feof($fh)) {
425
+							$line = fgetcsv($fh,9999,',','"');
426
+							$values = array();
427
+							//print_r($line);
428
+							if ($country == 'F') {
429
+								$values['registration'] = $line[0];
430
+								$values['base'] = $line[4];
431
+								$values['owner'] = $line[5];
432
+								if ($line[6] == '') $values['date_first_reg'] = null;
433
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
+						$values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436
-					    // TODO : add modeS & reg to aircraft_modes
437
-            				    $values['registration'] = $line[0];
438
-            				    $values['base'] = $line[3];
439
-            				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
-					    $values['cancel'] = '';
443
-					    $values['modes'] = $line[7];
444
-					    $values['icao'] = $line[8];
436
+						// TODO : add modeS & reg to aircraft_modes
437
+								$values['registration'] = $line[0];
438
+								$values['base'] = $line[3];
439
+								$values['owner'] = $line[2];
440
+								if ($line[1] == '') $values['date_first_reg'] = null;
441
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
+						$values['cancel'] = '';
443
+						$values['modes'] = $line[7];
444
+						$values['icao'] = $line[8];
445 445
 					    
446 446
 					} elseif ($country == 'HB') {
447
-					    // TODO : add modeS & reg to aircraft_modes
448
-            				    $values['registration'] = $line[0];
449
-            				    $values['base'] = null;
450
-            				    $values['owner'] = $line[5];
451
-            				    $values['date_first_reg'] = null;
452
-					    $values['cancel'] = '';
453
-					    $values['modes'] = $line[4];
454
-					    $values['icao'] = $line[7];
447
+						// TODO : add modeS & reg to aircraft_modes
448
+								$values['registration'] = $line[0];
449
+								$values['base'] = null;
450
+								$values['owner'] = $line[5];
451
+								$values['date_first_reg'] = null;
452
+						$values['cancel'] = '';
453
+						$values['modes'] = $line[4];
454
+						$values['icao'] = $line[7];
455 455
 					} elseif ($country == 'OK') {
456
-					    // TODO : add modeS & reg to aircraft_modes
457
-            				    $values['registration'] = $line[3];
458
-            				    $values['base'] = null;
459
-            				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
-					    $values['cancel'] = '';
456
+						// TODO : add modeS & reg to aircraft_modes
457
+								$values['registration'] = $line[3];
458
+								$values['base'] = null;
459
+								$values['owner'] = $line[5];
460
+								if ($line[18] == '') $values['date_first_reg'] = null;
461
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
+						$values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464
-					    // TODO : add modeS & reg to aircraft_modes
465
-            				    $values['registration'] = $line[0];
466
-            				    $values['base'] = null;
467
-            				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
-
471
-					    $values['cancel'] = $line[39];
464
+						// TODO : add modeS & reg to aircraft_modes
465
+								$values['registration'] = $line[0];
466
+								$values['base'] = null;
467
+								$values['owner'] = $line[12];
468
+								if ($line[28] == '') $values['date_first_reg'] = null;
469
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
+
471
+						$values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
473
-            				    $values['registration'] = $line[0];
474
-            				    $values['base'] = null;
475
-            				    $values['owner'] = $line[4];
476
-            				    $values['date_first_reg'] = null;
477
-					    $values['cancel'] = '';
473
+								$values['registration'] = $line[0];
474
+								$values['base'] = null;
475
+								$values['owner'] = $line[4];
476
+								$values['date_first_reg'] = null;
477
+						$values['cancel'] = '';
478 478
 					} elseif ($country == 'CC') {
479
-            				    $values['registration'] = $line[0];
480
-            				    $values['base'] = null;
481
-            				    $values['owner'] = $line[6];
482
-            				    $values['date_first_reg'] = null;
483
-					    $values['cancel'] = '';
479
+								$values['registration'] = $line[0];
480
+								$values['base'] = null;
481
+								$values['owner'] = $line[6];
482
+								$values['date_first_reg'] = null;
483
+						$values['cancel'] = '';
484 484
 					} elseif ($country == 'HJ') {
485
-            				    $values['registration'] = $line[0];
486
-            				    $values['base'] = null;
487
-            				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
-					    $values['cancel'] = '';
485
+								$values['registration'] = $line[0];
486
+								$values['base'] = null;
487
+								$values['owner'] = $line[8];
488
+								if ($line[7] == '') $values['date_first_reg'] = null;
489
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
+						$values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492
-            				    $values['registration'] = $line[0];
493
-            				    $values['base'] = null;
494
-            				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
-					    $values['cancel'] = $line[7];
492
+								$values['registration'] = $line[0];
493
+								$values['base'] = null;
494
+								$values['owner'] = $line[4];
495
+								if ($line[6] == '') $values['date_first_reg'] = null;
496
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+						$values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499
-            				    $values['registration'] = $line[0];
500
-            				    $values['base'] = null;
501
-            				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
-					    $values['cancel'] = '';
499
+								$values['registration'] = $line[0];
500
+								$values['base'] = null;
501
+								$values['owner'] = $line[4];
502
+								if ($line[5] == '') $values['date_first_reg'] = null;
503
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
+						$values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506
-            				    $values['registration'] = $line[0];
507
-            				    $values['base'] = null;
508
-            				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
-					    $values['cancel'] = '';
506
+								$values['registration'] = $line[0];
507
+								$values['base'] = null;
508
+								$values['owner'] = $line[3];
509
+								if ($line[7] == '') $values['date_first_reg'] = null;
510
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
+						$values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513
-            				    $values['registration'] = $line[0];
514
-            				    $values['base'] = null;
515
-            				    $values['owner'] = $line[3];
516
-            				    $values['date_first_reg'] = null;
517
-					    $values['cancel'] = '';
518
-					    $values['modes'] = $line[5];
519
-					    $values['icao'] = $line[9];
513
+								$values['registration'] = $line[0];
514
+								$values['base'] = null;
515
+								$values['owner'] = $line[3];
516
+								$values['date_first_reg'] = null;
517
+						$values['cancel'] = '';
518
+						$values['modes'] = $line[5];
519
+						$values['icao'] = $line[9];
520 520
 					} elseif ($country == 'M') {
521
-            				    $values['registration'] = $line[0];
522
-            				    $values['base'] = null;
523
-            				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
-					    $values['modes'] = $line[4];
527
-					    $values['icao'] = $line[10];
521
+								$values['registration'] = $line[0];
522
+								$values['base'] = null;
523
+								$values['owner'] = $line[6];
524
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
+						$values['modes'] = $line[4];
527
+						$values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529
-            				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
-					    $values['modes'] = $line[5];
532
-					    $values['icao'] = $line[6];
529
+								$values['registration'] = $line[0];
530
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
+						$values['modes'] = $line[5];
532
+						$values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534
-            				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
-					    $values['modes'] = $line[4];
537
-					    $values['icao'] = $line[5];
534
+								$values['registration'] = $line[0];
535
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
+						$values['modes'] = $line[4];
537
+						$values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
539
-            				    $values['registration'] = $line[0];
540
-            				    $values['base'] = null;
541
-            				    $values['owner'] = $line[3];
542
-            				    $values['date_first_reg'] = null;
543
-					    $values['cancel'] = '';
539
+								$values['registration'] = $line[0];
540
+								$values['base'] = null;
541
+								$values['owner'] = $line[3];
542
+								$values['date_first_reg'] = null;
543
+						$values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546 546
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
                         return "error : ".$e->getMessage();
674 674
                 }
675 675
                 */
676
-                /*
676
+				/*
677 677
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
678 678
 		try {
679 679
 			$Connection = new Connection();
@@ -918,10 +918,10 @@  discard block
 block discarded – undo
918 918
 		try {
919 919
 			$Connection = new Connection();
920 920
 			$sth = $Connection->db->prepare($query);
921
-                        $sth->execute(array(':source' => 'translation.csv'));
922
-                } catch(PDOException $e) {
923
-                        return "error : ".$e->getMessage();
924
-                }
921
+						$sth->execute(array(':source' => 'translation.csv'));
922
+				} catch(PDOException $e) {
923
+						return "error : ".$e->getMessage();
924
+				}
925 925
 
926 926
 		
927 927
 		//update_db::unzip($out_file);
@@ -940,21 +940,21 @@  discard block
 block discarded – undo
940 940
 					$data = $row;
941 941
 					$operator = $data[2];
942 942
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
943
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
944
-                                                //echo substr($operator, 0, 2)."\n";;
945
-                                                if (count($airline_array) > 0) {
943
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
944
+												//echo substr($operator, 0, 2)."\n";;
945
+												if (count($airline_array) > 0) {
946 946
 							//print_r($airline_array);
947 947
 							$operator = $airline_array[0]['icao'].substr($operator,2);
948
-                                                }
949
-                                        }
948
+												}
949
+										}
950 950
 					
951 951
 					$operator_correct = $data[3];
952 952
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
953
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954
-                                                if (count($airline_array) > 0) {
955
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
956
-                                            	}
957
-                                        }
953
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954
+												if (count($airline_array) > 0) {
955
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
956
+												}
957
+										}
958 958
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
959 959
 					try {
960 960
 						$sth = $Connection->db->prepare($query);
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 			//$Connection->db->commit();
969 969
 		}
970 970
 		return '';
971
-        }
971
+		}
972 972
 	
973 973
 	public static function translation_fam() {
974 974
 		global $tmp_dir, $globalTransaction;
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 			//$Connection->db->commit();
1007 1007
 		}
1008 1008
 		return '';
1009
-        }
1009
+		}
1010 1010
 
1011 1011
 	/*
1012 1012
 	* This function use FAA public data.
@@ -1018,19 +1018,19 @@  discard block
 block discarded – undo
1018 1018
 		try {
1019 1019
 			$Connection = new Connection();
1020 1020
 			$sth = $Connection->db->prepare($query);
1021
-                        $sth->execute(array(':source' => 'website_faa'));
1022
-                } catch(PDOException $e) {
1023
-                        return "error : ".$e->getMessage();
1024
-                }
1021
+						$sth->execute(array(':source' => 'website_faa'));
1022
+				} catch(PDOException $e) {
1023
+						return "error : ".$e->getMessage();
1024
+				}
1025 1025
 
1026 1026
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1027 1027
 		try {
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030
-                        $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1032
-                        return "error : ".$e->getMessage();
1033
-                }
1030
+						$sth->execute(array(':source' => 'website_faa'));
1031
+				} catch(PDOException $e) {
1032
+						return "error : ".$e->getMessage();
1033
+				}
1034 1034
 
1035 1035
 		$delimiter = ",";
1036 1036
 		$mfr = array();
@@ -1106,17 +1106,17 @@  discard block
 block discarded – undo
1106 1106
 		}
1107 1107
 		//print_r($mfr);
1108 1108
 		return '';
1109
-        }
1109
+		}
1110 1110
 	public static function modes_fam() {
1111 1111
 		global $tmp_dir, $globalTransaction;
1112 1112
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1113 1113
 		try {
1114 1114
 			$Connection = new Connection();
1115 1115
 			$sth = $Connection->db->prepare($query);
1116
-                        $sth->execute(array(':source' => 'website_fam'));
1117
-                } catch(PDOException $e) {
1118
-                        return "error : ".$e->getMessage();
1119
-                }
1116
+						$sth->execute(array(':source' => 'website_fam'));
1117
+				} catch(PDOException $e) {
1118
+						return "error : ".$e->getMessage();
1119
+				}
1120 1120
 
1121 1121
 		
1122 1122
 		//update_db::unzip($out_file);
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 			if ($globalTransaction) $Connection->db->commit();
1147 1147
 		}
1148 1148
 		return '';
1149
-        }
1149
+		}
1150 1150
         
1151 1151
 	public static function owner_fam() {
1152 1152
 		global $tmp_dir, $globalTransaction;
@@ -1154,10 +1154,10 @@  discard block
 block discarded – undo
1154 1154
 		try {
1155 1155
 			$Connection = new Connection();
1156 1156
 			$sth = $Connection->db->prepare($query);
1157
-                        $sth->execute(array(':source' => 'website_fam'));
1158
-                } catch(PDOException $e) {
1159
-                        return "error : ".$e->getMessage();
1160
-                }
1157
+						$sth->execute(array(':source' => 'website_fam'));
1158
+				} catch(PDOException $e) {
1159
+						return "error : ".$e->getMessage();
1160
+				}
1161 1161
 
1162 1162
 		$delimiter = "\t";
1163 1163
 		$Connection = new Connection();
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 			if ($globalTransaction) $Connection->db->commit();
1184 1184
 		}
1185 1185
 		return '';
1186
-        }
1186
+		}
1187 1187
 
1188 1188
 	public static function routes_fam() {
1189 1189
 		global $tmp_dir, $globalTransaction, $globalDebug;
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 			if ($globalTransaction) $Connection->db->commit();
1219 1219
 		}
1220 1220
 		return '';
1221
-        }
1221
+		}
1222 1222
 
1223 1223
 	public static function marine_identity_fam() {
1224 1224
 		global $tmp_dir, $globalTransaction;
@@ -1226,10 +1226,10 @@  discard block
 block discarded – undo
1226 1226
 		try {
1227 1227
 			$Connection = new Connection();
1228 1228
 			$sth = $Connection->db->prepare($query);
1229
-                        $sth->execute();
1230
-                } catch(PDOException $e) {
1231
-                        return "error : ".$e->getMessage();
1232
-                }
1229
+						$sth->execute();
1230
+				} catch(PDOException $e) {
1231
+						return "error : ".$e->getMessage();
1232
+				}
1233 1233
 
1234 1234
 		
1235 1235
 		//update_db::unzip($out_file);
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 			if ($globalTransaction) $Connection->db->commit();
1260 1260
 		}
1261 1261
 		return '';
1262
-        }
1262
+		}
1263 1263
 
1264 1264
 	public static function satellite_fam() {
1265 1265
 		global $tmp_dir, $globalTransaction;
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
 			if ($globalTransaction) $Connection->db->commit();
1331 1331
 		}
1332 1332
 		return '';
1333
-        }
1333
+		}
1334 1334
 
1335 1335
 	public static function tle($filename,$tletype) {
1336 1336
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1341,10 +1341,10 @@  discard block
 block discarded – undo
1341 1341
 		try {
1342 1342
 			$Connection = new Connection();
1343 1343
 			$sth = $Connection->db->prepare($query);
1344
-                        $sth->execute(array(':source' => $filename));
1345
-                } catch(PDOException $e) {
1346
-                        return "error : ".$e->getMessage();
1347
-                }
1344
+						$sth->execute(array(':source' => $filename));
1345
+				} catch(PDOException $e) {
1346
+						return "error : ".$e->getMessage();
1347
+				}
1348 1348
 		
1349 1349
 		$Connection = new Connection();
1350 1350
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
 			//$Connection->db->commit();
1380 1380
 		}
1381 1381
 		return '';
1382
-        }
1382
+		}
1383 1383
 
1384 1384
 	public static function satellite_ucsdb($filename) {
1385 1385
 		global $tmp_dir, $globalTransaction;
@@ -1628,11 +1628,11 @@  discard block
 block discarded – undo
1628 1628
 						try {
1629 1629
 							$sth = $Connection->db->prepare($query);
1630 1630
 							$sth->execute(array(
1631
-							    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1632
-							    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1633
-							    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1634
-							    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1635
-							    )
1631
+								':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1632
+								':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1633
+								':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1634
+								':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1635
+								)
1636 1636
 							);
1637 1637
 						} catch(PDOException $e) {
1638 1638
 							return "error : ".$e->getMessage();
@@ -1655,13 +1655,13 @@  discard block
 block discarded – undo
1655 1655
 			//$Connection->db->commit();
1656 1656
 		}
1657 1657
 		return '';
1658
-        }
1658
+		}
1659 1659
 
1660 1660
 	/**
1661
-        * Convert a HTML table to an array
1662
-        * @param String $data HTML page
1663
-        * @return Array array of the tables in HTML page
1664
-        */
1661
+	 * Convert a HTML table to an array
1662
+	 * @param String $data HTML page
1663
+	 * @return Array array of the tables in HTML page
1664
+	 */
1665 1665
 /*
1666 1666
         private static function table2array($data) {
1667 1667
                 $html = str_get_html($data);
@@ -1691,11 +1691,11 @@  discard block
 block discarded – undo
1691 1691
                 return(array_filter($tabledata));
1692 1692
         }
1693 1693
 */
1694
-       /**
1695
-        * Get data from form result
1696
-        * @param String $url form URL
1697
-        * @return String the result
1698
-        */
1694
+	   /**
1695
+	    * Get data from form result
1696
+	    * @param String $url form URL
1697
+	    * @return String the result
1698
+	    */
1699 1699
 /*
1700 1700
         private static function getData($url) {
1701 1701
                 $ch = curl_init();
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
 			if ($globalTransaction) $Connection->db->commit();
1789 1789
 		}
1790 1790
 		return '';
1791
-        }
1791
+		}
1792 1792
 
1793 1793
 	public static function ivao_airlines($filename) {
1794 1794
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1798,10 +1798,10 @@  discard block
 block discarded – undo
1798 1798
 		try {
1799 1799
 			$Connection = new Connection();
1800 1800
 			$sth = $Connection->db->prepare($query);
1801
-                        $sth->execute();
1802
-                } catch(PDOException $e) {
1803
-                        return "error : ".$e->getMessage();
1804
-                }
1801
+						$sth->execute();
1802
+				} catch(PDOException $e) {
1803
+						return "error : ".$e->getMessage();
1804
+				}
1805 1805
 
1806 1806
 		$header = NULL;
1807 1807
 		$delimiter = ':';
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
 			if ($globalTransaction) $Connection->db->commit();
1826 1826
 		}
1827 1827
 		return '';
1828
-        }
1828
+		}
1829 1829
 	
1830 1830
 	public static function update_airspace() {
1831 1831
 		global $tmp_dir, $globalDBdriver;
@@ -1835,11 +1835,11 @@  discard block
 block discarded – undo
1835 1835
 			$query = 'DROP TABLE airspace';
1836 1836
 			try {
1837 1837
 				$sth = $Connection->db->prepare($query);
1838
-                    		$sth->execute();
1839
-	                } catch(PDOException $e) {
1838
+							$sth->execute();
1839
+					} catch(PDOException $e) {
1840 1840
 				return "error : ".$e->getMessage();
1841
-	                }
1842
-	        }
1841
+					}
1842
+			}
1843 1843
 
1844 1844
 
1845 1845
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1894,10 +1894,10 @@  discard block
 block discarded – undo
1894 1894
 			$query = 'DROP TABLE countries';
1895 1895
 			try {
1896 1896
 				$sth = $Connection->db->prepare($query);
1897
-            	        	$sth->execute();
1898
-	                } catch(PDOException $e) {
1899
-    	                	echo "error : ".$e->getMessage();
1900
-	                }
1897
+							$sth->execute();
1898
+					} catch(PDOException $e) {
1899
+							echo "error : ".$e->getMessage();
1900
+					}
1901 1901
 		}
1902 1902
 		if ($globalDBdriver == 'mysql') {
1903 1903
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2452,11 +2452,11 @@  discard block
 block discarded – undo
2452 2452
 						$query = 'DROP TABLE airspace';
2453 2453
 						try {
2454 2454
 							$sth = $Connection->db->prepare($query);
2455
-    	    	    					$sth->execute();
2456
-			            		} catch(PDOException $e) {
2455
+										$sth->execute();
2456
+								} catch(PDOException $e) {
2457 2457
 							return "error : ".$e->getMessage();
2458
-		            			}
2459
-		    			}
2458
+								}
2459
+						}
2460 2460
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2461 2461
 					update_db::insert_airspace_version($airspace_md5);
2462 2462
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -2666,12 +2666,12 @@  discard block
 block discarded – undo
2666 2666
 		echo $data;
2667 2667
 		*/
2668 2668
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2669
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2670
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2671
-		    $result = fread($fh,100000000);
2672
-		    //echo $result;
2673
-		    //var_dump(str_get_html($result));
2674
-		    //print_r(self::table2array($result));
2669
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2670
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2671
+			$result = fread($fh,100000000);
2672
+			//echo $result;
2673
+			//var_dump(str_get_html($result));
2674
+			//print_r(self::table2array($result));
2675 2675
 		}
2676 2676
 
2677 2677
 	}
@@ -2685,10 +2685,10 @@  discard block
 block discarded – undo
2685 2685
 		try {
2686 2686
 			$Connection = new Connection();
2687 2687
 			$sth = $Connection->db->prepare($query);
2688
-                        $sth->execute();
2689
-                } catch(PDOException $e) {
2690
-                        return "error : ".$e->getMessage();
2691
-                }
2688
+						$sth->execute();
2689
+				} catch(PDOException $e) {
2690
+						return "error : ".$e->getMessage();
2691
+				}
2692 2692
 
2693 2693
 		$error = '';
2694 2694
 		if ($globalDebug) echo "Notam : Download...";
@@ -2744,8 +2744,8 @@  discard block
 block discarded – undo
2744 2744
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2745 2745
 					$data['permanent'] = 0;
2746 2746
 				} else {
2747
-				    $data['date_end'] = NULL;
2748
-				    $data['permanent'] = 1;
2747
+					$data['date_end'] = NULL;
2748
+					$data['permanent'] = 1;
2749 2749
 				}
2750 2750
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2751 2751
 				$NOTAM = new NOTAM();
@@ -2819,13 +2819,13 @@  discard block
 block discarded – undo
2819 2819
 		try {
2820 2820
 			$Connection = new Connection();
2821 2821
 			$sth = $Connection->db->prepare($query);
2822
-                        $sth->execute();
2823
-                } catch(PDOException $e) {
2824
-                        return "error : ".$e->getMessage();
2825
-                }
2826
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2827
-                if ($row['nb'] > 0) return false;
2828
-                else return true;
2822
+						$sth->execute();
2823
+				} catch(PDOException $e) {
2824
+						return "error : ".$e->getMessage();
2825
+				}
2826
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2827
+				if ($row['nb'] > 0) return false;
2828
+				else return true;
2829 2829
 	}
2830 2830
 
2831 2831
 	public static function insert_last_update() {
@@ -2834,10 +2834,10 @@  discard block
 block discarded – undo
2834 2834
 		try {
2835 2835
 			$Connection = new Connection();
2836 2836
 			$sth = $Connection->db->prepare($query);
2837
-                        $sth->execute();
2838
-                } catch(PDOException $e) {
2839
-                        return "error : ".$e->getMessage();
2840
-                }
2837
+						$sth->execute();
2838
+				} catch(PDOException $e) {
2839
+						return "error : ".$e->getMessage();
2840
+				}
2841 2841
 	}
2842 2842
 
2843 2843
 	public static function check_airspace_version($version) {
@@ -2845,13 +2845,13 @@  discard block
 block discarded – undo
2845 2845
 		try {
2846 2846
 			$Connection = new Connection();
2847 2847
 			$sth = $Connection->db->prepare($query);
2848
-                        $sth->execute(array(':version' => $version));
2849
-                } catch(PDOException $e) {
2850
-                        return "error : ".$e->getMessage();
2851
-                }
2852
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2853
-                if ($row['nb'] > 0) return true;
2854
-                else return false;
2848
+						$sth->execute(array(':version' => $version));
2849
+				} catch(PDOException $e) {
2850
+						return "error : ".$e->getMessage();
2851
+				}
2852
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2853
+				if ($row['nb'] > 0) return true;
2854
+				else return false;
2855 2855
 	}
2856 2856
 
2857 2857
 	public static function check_geoid_version($version) {
@@ -2859,13 +2859,13 @@  discard block
 block discarded – undo
2859 2859
 		try {
2860 2860
 			$Connection = new Connection();
2861 2861
 			$sth = $Connection->db->prepare($query);
2862
-                        $sth->execute(array(':version' => $version));
2863
-                } catch(PDOException $e) {
2864
-                        return "error : ".$e->getMessage();
2865
-                }
2866
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2867
-                if ($row['nb'] > 0) return true;
2868
-                else return false;
2862
+						$sth->execute(array(':version' => $version));
2863
+				} catch(PDOException $e) {
2864
+						return "error : ".$e->getMessage();
2865
+				}
2866
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2867
+				if ($row['nb'] > 0) return true;
2868
+				else return false;
2869 2869
 	}
2870 2870
 
2871 2871
 	public static function check_marine_identity_version($version) {
@@ -2915,10 +2915,10 @@  discard block
 block discarded – undo
2915 2915
 		try {
2916 2916
 			$Connection = new Connection();
2917 2917
 			$sth = $Connection->db->prepare($query);
2918
-                        $sth->execute(array(':version' => $version));
2919
-                } catch(PDOException $e) {
2920
-                        return "error : ".$e->getMessage();
2921
-                }
2918
+						$sth->execute(array(':version' => $version));
2919
+				} catch(PDOException $e) {
2920
+						return "error : ".$e->getMessage();
2921
+				}
2922 2922
 	}
2923 2923
 
2924 2924
 	public static function insert_marine_identity_version($version) {
@@ -2955,13 +2955,13 @@  discard block
 block discarded – undo
2955 2955
 		try {
2956 2956
 			$Connection = new Connection();
2957 2957
 			$sth = $Connection->db->prepare($query);
2958
-                        $sth->execute();
2959
-                } catch(PDOException $e) {
2960
-                        return "error : ".$e->getMessage();
2961
-                }
2962
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2963
-                if ($row['nb'] > 0) return false;
2964
-                else return true;
2958
+						$sth->execute();
2959
+				} catch(PDOException $e) {
2960
+						return "error : ".$e->getMessage();
2961
+				}
2962
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2963
+				if ($row['nb'] > 0) return false;
2964
+				else return true;
2965 2965
 	}
2966 2966
 
2967 2967
 	public static function insert_last_notam_update() {
@@ -2970,10 +2970,10 @@  discard block
 block discarded – undo
2970 2970
 		try {
2971 2971
 			$Connection = new Connection();
2972 2972
 			$sth = $Connection->db->prepare($query);
2973
-                        $sth->execute();
2974
-                } catch(PDOException $e) {
2975
-                        return "error : ".$e->getMessage();
2976
-                }
2973
+						$sth->execute();
2974
+				} catch(PDOException $e) {
2975
+						return "error : ".$e->getMessage();
2976
+				}
2977 2977
 	}
2978 2978
 
2979 2979
 	public static function check_last_airspace_update() {
@@ -2986,13 +2986,13 @@  discard block
 block discarded – undo
2986 2986
 		try {
2987 2987
 			$Connection = new Connection();
2988 2988
 			$sth = $Connection->db->prepare($query);
2989
-                        $sth->execute();
2990
-                } catch(PDOException $e) {
2991
-                        return "error : ".$e->getMessage();
2992
-                }
2993
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2994
-                if ($row['nb'] > 0) return false;
2995
-                else return true;
2989
+						$sth->execute();
2990
+				} catch(PDOException $e) {
2991
+						return "error : ".$e->getMessage();
2992
+				}
2993
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2994
+				if ($row['nb'] > 0) return false;
2995
+				else return true;
2996 2996
 	}
2997 2997
 
2998 2998
 	public static function insert_last_airspace_update() {
@@ -3001,10 +3001,10 @@  discard block
 block discarded – undo
3001 3001
 		try {
3002 3002
 			$Connection = new Connection();
3003 3003
 			$sth = $Connection->db->prepare($query);
3004
-                        $sth->execute();
3005
-                } catch(PDOException $e) {
3006
-                        return "error : ".$e->getMessage();
3007
-                }
3004
+						$sth->execute();
3005
+				} catch(PDOException $e) {
3006
+						return "error : ".$e->getMessage();
3007
+				}
3008 3008
 	}
3009 3009
 
3010 3010
 	public static function check_last_geoid_update() {
@@ -3017,13 +3017,13 @@  discard block
 block discarded – undo
3017 3017
 		try {
3018 3018
 			$Connection = new Connection();
3019 3019
 			$sth = $Connection->db->prepare($query);
3020
-                        $sth->execute();
3021
-                } catch(PDOException $e) {
3022
-                        return "error : ".$e->getMessage();
3023
-                }
3024
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3025
-                if ($row['nb'] > 0) return false;
3026
-                else return true;
3020
+						$sth->execute();
3021
+				} catch(PDOException $e) {
3022
+						return "error : ".$e->getMessage();
3023
+				}
3024
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3025
+				if ($row['nb'] > 0) return false;
3026
+				else return true;
3027 3027
 	}
3028 3028
 
3029 3029
 	public static function insert_last_geoid_update() {
@@ -3032,10 +3032,10 @@  discard block
 block discarded – undo
3032 3032
 		try {
3033 3033
 			$Connection = new Connection();
3034 3034
 			$sth = $Connection->db->prepare($query);
3035
-                        $sth->execute();
3036
-                } catch(PDOException $e) {
3037
-                        return "error : ".$e->getMessage();
3038
-                }
3035
+						$sth->execute();
3036
+				} catch(PDOException $e) {
3037
+						return "error : ".$e->getMessage();
3038
+				}
3039 3039
 	}
3040 3040
 
3041 3041
 	public static function check_last_owner_update() {
@@ -3048,13 +3048,13 @@  discard block
 block discarded – undo
3048 3048
 		try {
3049 3049
 			$Connection = new Connection();
3050 3050
 			$sth = $Connection->db->prepare($query);
3051
-                        $sth->execute();
3052
-                } catch(PDOException $e) {
3053
-                        return "error : ".$e->getMessage();
3054
-                }
3055
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3056
-                if ($row['nb'] > 0) return false;
3057
-                else return true;
3051
+						$sth->execute();
3052
+				} catch(PDOException $e) {
3053
+						return "error : ".$e->getMessage();
3054
+				}
3055
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3056
+				if ($row['nb'] > 0) return false;
3057
+				else return true;
3058 3058
 	}
3059 3059
 
3060 3060
 	public static function insert_last_owner_update() {
@@ -3063,10 +3063,10 @@  discard block
 block discarded – undo
3063 3063
 		try {
3064 3064
 			$Connection = new Connection();
3065 3065
 			$sth = $Connection->db->prepare($query);
3066
-                        $sth->execute();
3067
-                } catch(PDOException $e) {
3068
-                        return "error : ".$e->getMessage();
3069
-                }
3066
+						$sth->execute();
3067
+				} catch(PDOException $e) {
3068
+						return "error : ".$e->getMessage();
3069
+				}
3070 3070
 	}
3071 3071
 	public static function check_last_schedules_update() {
3072 3072
 		global $globalDBdriver;
@@ -3078,13 +3078,13 @@  discard block
 block discarded – undo
3078 3078
 		try {
3079 3079
 			$Connection = new Connection();
3080 3080
 			$sth = $Connection->db->prepare($query);
3081
-                        $sth->execute();
3082
-                } catch(PDOException $e) {
3083
-                        return "error : ".$e->getMessage();
3084
-                }
3085
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3086
-                if ($row['nb'] > 0) return false;
3087
-                else return true;
3081
+						$sth->execute();
3082
+				} catch(PDOException $e) {
3083
+						return "error : ".$e->getMessage();
3084
+				}
3085
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3086
+				if ($row['nb'] > 0) return false;
3087
+				else return true;
3088 3088
 	}
3089 3089
 
3090 3090
 	public static function insert_last_schedules_update() {
@@ -3264,10 +3264,10 @@  discard block
 block discarded – undo
3264 3264
 		try {
3265 3265
 			$Connection = new Connection();
3266 3266
 			$sth = $Connection->db->prepare($query);
3267
-                        $sth->execute();
3268
-                } catch(PDOException $e) {
3269
-                        return "error : ".$e->getMessage();
3270
-                }
3267
+						$sth->execute();
3268
+				} catch(PDOException $e) {
3269
+						return "error : ".$e->getMessage();
3270
+				}
3271 3271
 	}
3272 3272
 	public static function delete_duplicateowner() {
3273 3273
 		global $globalDBdriver;
@@ -3279,10 +3279,10 @@  discard block
 block discarded – undo
3279 3279
 		try {
3280 3280
 			$Connection = new Connection();
3281 3281
 			$sth = $Connection->db->prepare($query);
3282
-                        $sth->execute();
3283
-                } catch(PDOException $e) {
3284
-                        return "error : ".$e->getMessage();
3285
-                }
3282
+						$sth->execute();
3283
+				} catch(PDOException $e) {
3284
+						return "error : ".$e->getMessage();
3285
+				}
3286 3286
 	}
3287 3287
 	
3288 3288
 	public static function update_all() {
Please login to merge, or discard this patch.