Completed
Push — master ( 6c4f55...213543 )
by Yannick
10:31
created
index.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 <div id="showdetails" class="showdetails"></div>
37 37
 <div id="infobox" class="infobox"><h4><?php echo _("Aircrafts detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div>
38 38
 <?php
39
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
39
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
40 40
 
41 41
 ?>
42 42
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script>
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script>
57 57
 <?php
58 58
 	}
59
-    }
59
+	}
60 60
 ?>
61 61
 <div id="dialog" title="<?php echo _("Session has timed-out"); ?>">
62 62
   <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p>
@@ -70,34 +70,34 @@  discard block
 block discarded – undo
70 70
 	<li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
71 71
 	<li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
72 72
 <?php
73
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
73
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
74 74
 	if (isset($globalArchive) && $globalArchive == TRUE) {
75 75
 ?>
76 76
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
77 77
 <?php
78 78
 	}
79
-    }
79
+	}
80 80
 ?>
81 81
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
82 82
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
83 83
 	<li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li>
84 84
 <?php
85
-    if (isset($globalMap3D) && $globalMap3D) {
85
+	if (isset($globalMap3D) && $globalMap3D) {
86 86
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
87 87
 ?>
88 88
 	<li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
89 89
 <?php
90
-        } else {
91
-    	    if (isset($globalMapSatellites) && $globalMapSatellites) {
90
+		} else {
91
+			if (isset($globalMapSatellites) && $globalMapSatellites) {
92 92
 ?>
93 93
 	<li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li>
94 94
 <?php
95
-	    }
95
+		}
96 96
 ?>
97 97
 	<li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
98 98
 <?php
99 99
 	}
100
-    }
100
+	}
101 101
 ?>
102 102
     </ul>
103 103
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 ?>
172 172
         </div>
173 173
 <?php
174
-    if (isset($globalArchive) && $globalArchive == TRUE) {
174
+	if (isset($globalArchive) && $globalArchive == TRUE) {
175 175
 ?>
176 176
         <div class="sidebar-pane" id="archive">
177 177
 	    <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	    </form>
232 232
 	</div>
233 233
 <?php
234
-    }
234
+	}
235 235
 ?>
236 236
         <div class="sidebar-pane" id="settings">
237 237
 	    <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -242,56 +242,56 @@  discard block
 block discarded – undo
242 242
 			    <?php
243 243
 				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
244 244
 				else $MapType = $_COOKIE['MapType'];
245
-			    ?>
245
+				?>
246 246
 			    <?php
247 247
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
248
-			    ?>
248
+				?>
249 249
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
250 250
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
251 251
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
252 252
 			    <?php
253 253
 				}
254
-			    ?>
254
+				?>
255 255
 			    <?php
256
-			        if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
257
-			    ?>
256
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
257
+				?>
258 258
 			    <?php
259
-				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
260
-			    ?>
259
+					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
260
+				?>
261 261
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
262 262
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
263 263
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
264 264
 			    <?php
265
-				    }
266
-			    ?>
265
+					}
266
+				?>
267 267
 			    <?php
268
-				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
269
-			    ?>
268
+					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
269
+				?>
270 270
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
271 271
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
272 272
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
273 273
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
274 274
 			    <?php
275
-				    }
276
-			    ?>
275
+					}
276
+				?>
277 277
 			    <?php
278
-				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
279
-			    ?>
278
+					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
279
+				?>
280 280
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
281 281
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
282 282
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
283 283
 			    <?php
284
-				    }
285
-			    ?>
284
+					}
285
+				?>
286 286
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
287 287
 			    <?php
288 288
 				}
289
-			    ?>
289
+				?>
290 290
 			    <?php
291
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
291
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
292 292
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
293 293
 					else $MapBoxId = $_COOKIE['MapTypeId'];
294
-			    ?>
294
+				?>
295 295
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
296 296
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
297 297
 			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
306 306
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
307 307
 			    <?php
308
-				    }
309
-			    ?>
308
+					}
309
+				?>
310 310
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
311 311
 			</select>
312 312
 		    </li>
313 313
 <?php
314
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
314
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
315 315
 ?>
316 316
 		    <li><?php echo _("Type of Terrain:"); ?>
317 317
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 			</select>
322 322
 		    </li>
323 323
 <?php
324
-    }
324
+	}
325 325
 ?>
326 326
 <?php
327
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
327
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
328 328
 ?>
329 329
 		    
330 330
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
@@ -332,68 +332,68 @@  discard block
 block discarded – undo
332 332
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
333 333
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
334 334
 <?php
335
-    }
335
+	}
336 336
 ?>
337 337
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
338 338
 <?php
339
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
339
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
340 340
 ?>
341 341
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
342 342
 <?php
343
-    }
344
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
343
+	}
344
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
345 345
 ?>
346 346
 		    <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>
347 347
 <?php
348
-    }
348
+	}
349 349
 ?>
350 350
 
351 351
 		    <?php
352 352
 			if (function_exists('array_column')) {
353
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
354
-		    ?>
353
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
354
+			?>
355 355
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
356 356
 		    <?php
357
-			    }
357
+				}
358 358
 			} elseif (isset($globalSources)) {
359
-			    $dispolar = false;
360
-			    foreach ($globalSources as $testsource) {
361
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
362
-			    }
363
-			    if ($dispolar) {
364
-		    ?>
359
+				$dispolar = false;
360
+				foreach ($globalSources as $testsource) {
361
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
362
+				}
363
+				if ($dispolar) {
364
+			?>
365 365
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
366 366
 		    <?php
367
-			    }
368
-		        }
369
-		    ?>
367
+				}
368
+				}
369
+			?>
370 370
 <?php
371
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
371
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
372 372
 ?>
373 373
 
374 374
 		    <?php
375
-		        if (extension_loaded('gd') && function_exists('gd_info')) {
376
-		    ?>
375
+				if (extension_loaded('gd') && function_exists('gd_info')) {
376
+			?>
377 377
 		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
378 378
 		    <?php 
379 379
 			if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
380
-		    ?>
380
+			?>
381 381
 		    <li><?php echo _("Aircraft icon color:"); ?>
382 382
 			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
383 383
 		    </li>
384 384
 		    <?php
385
-			    }
386
-		        }
387
-		    ?>
385
+				}
386
+				}
387
+			?>
388 388
 		    <?php
389
-		        if (extension_loaded('gd') && function_exists('gd_info')) {
390
-		    ?>
389
+				if (extension_loaded('gd') && function_exists('gd_info')) {
390
+			?>
391 391
 		    <li><?php echo _("Marine icon color:"); ?>
392 392
 			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
393 393
 		    </li>
394 394
 		    <?php
395
-		        }
396
-		    ?>
395
+				}
396
+			?>
397 397
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
398 398
 			<div class="range">
399 399
 			    <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'; ?>">
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 			</div>
402 402
 		    </li>
403 403
 <?php
404
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
404
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
405 405
 ?>
406 406
 		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li>
407 407
 		    <li><?php echo _("Aircraft icon color:"); ?>
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 		    </li>
417 417
 <?php
418 418
 	}
419
-    }
419
+	}
420 420
 ?>
421 421
 		    <li><?php echo _("Distance unit:"); ?>
422 422
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -449,16 +449,16 @@  discard block
 block discarded – undo
449 449
 		    <ul>
450 450
 		    <?php
451 451
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
452
-		    ?>
452
+			?>
453 453
 			<?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 } ?>
454 454
 			<?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 } ?>
455 455
 			<?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 } ?>
456 456
 		    <?php
457 457
 			}
458
-		    ?>
458
+			?>
459 459
 		    <?php
460 460
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
461
-		    ?>
461
+			?>
462 462
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
463 463
 			    <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>
464 464
 			<?php } ?>
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 			<?php } ?>
468 468
 		    <?php
469 469
 			}
470
-		    ?>
470
+			?>
471 471
 		    <li><?php echo _("Display airlines:"); ?>
472 472
 		    <br/>
473 473
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -487,14 +487,14 @@  discard block
 block discarded – undo
487 487
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
488 488
 					}
489 489
 				}
490
-			    ?>
490
+				?>
491 491
 			</select>
492 492
 		    </li>
493 493
 		    <?php
494 494
 			$Spotter = new Spotter();
495 495
 			$allalliancenames = $Spotter->getAllAllianceNames();
496 496
 			if (!empty($allalliancenames)) {
497
-		    ?>
497
+			?>
498 498
 		    <li><?php echo _("Display alliance:"); ?>
499 499
 		    <br/>
500 500
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -508,15 +508,15 @@  discard block
 block discarded – undo
508 508
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
509 509
 					}
510 510
 				}
511
-			    ?>
511
+				?>
512 512
 			</select>
513 513
 		    </li>
514 514
 		    <?php
515 515
 			}
516
-		    ?>
516
+			?>
517 517
 		    <?php
518 518
 			if (isset($globalAPRS) && $globalAPRS) {
519
-		    ?>
519
+			?>
520 520
 		    <li><?php echo _("Display APRS sources name:"); ?>
521 521
 			<select class="selectpicker" multiple onchange="sources(this);">
522 522
 			    <?php
@@ -528,15 +528,15 @@  discard block
 block discarded – undo
528 528
 						echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>';
529 529
 					}
530 530
 				}
531
-			    ?>
531
+				?>
532 532
 			</select>
533 533
 		    </li>
534 534
 		    <?php
535 535
 			}
536
-		    ?>
536
+			?>
537 537
 		    <?php
538 538
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
539
-		    ?>
539
+			?>
540 540
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
541 541
 			<select class="selectpicker" onchange="airlinestype(this);">
542 542
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 		    </li>
548 548
 		    <?php
549 549
 			}
550
-		    ?>
550
+			?>
551 551
 		    <li>
552 552
 			<?php echo _("Display flight with ident:"); ?>
553 553
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 	    </form>
561 561
     	</div>
562 562
 <?php
563
-    if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
563
+	if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
564 564
 ?>
565 565
         <div class="sidebar-pane" id="satellites">
566 566
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -600,14 +600,14 @@  discard block
 block discarded – undo
600 600
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
601 601
 					}
602 602
 				}
603
-			    ?>
603
+				?>
604 604
 			</select>
605 605
 		    </li>
606 606
 		</ul>
607 607
 	    </form>
608 608
 	</div>
609 609
 <?php
610
-    }
610
+	}
611 611
 ?>
612 612
     </div>
613 613
 </div>
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 1 patch
Indentation   +653 added lines, -653 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
 		$this->db = $Connection->db;
9 9
 	}
10 10
 
11
-    /**
12
-    * Get SQL query part for filter used
13
-    * @param Array $filter the filter
14
-    * @return Array the SQL part
15
-    */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
11
+	/**
12
+	 * Get SQL query part for filter used
13
+	 * @param Array $filter the filter
14
+	 * @return Array the SQL part
15
+	 */
16
+	public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 	$filters = array();
19 19
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
@@ -30,88 +30,88 @@  discard block
 block discarded – undo
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32 32
 	foreach($filters as $flt) {
33
-	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
33
+		if (isset($flt['airlines']) && !empty($flt['airlines'])) {
34 34
 		if ($flt['airlines'][0] != '') {
35
-		    if (isset($flt['source'])) {
35
+			if (isset($flt['source'])) {
36 36
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
37
-		    } else {
37
+			} else {
38 38
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
39
-		    }
39
+			}
40
+		}
40 41
 		}
41
-	    }
42
-	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
42
+		if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
43 43
 		if (isset($flt['source'])) {
44
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
44
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
45 45
 		} else {
46
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
46
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
47 47
 		}
48
-	    }
49
-	    if (isset($flt['idents']) && !empty($flt['idents'])) {
48
+		}
49
+		if (isset($flt['idents']) && !empty($flt['idents'])) {
50 50
 		if (isset($flt['source'])) {
51
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
51
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
52 52
 		} else {
53
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
53
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
54
+		}
54 55
 		}
55
-	    }
56
-	    if (isset($flt['registrations']) && !empty($flt['registrations'])) {
56
+		if (isset($flt['registrations']) && !empty($flt['registrations'])) {
57 57
 		if (isset($flt['source'])) {
58
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
58
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
59 59
 		} else {
60
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
60
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
61
+		}
61 62
 		}
62
-	    }
63
-	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
63
+		if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
64 64
 		if (isset($flt['source'])) {
65
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
65
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
66
+		}
66 67
 		}
67
-	    }
68 68
 	}
69 69
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
70
-	    if ($filter['airlines'][0] != '') {
70
+		if ($filter['airlines'][0] != '') {
71 71
 		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
72
-	    }
72
+		}
73 73
 	}
74 74
 	
75 75
 	if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
76
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
76
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
77 77
 	}
78 78
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
79
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
79
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
80 80
 	}
81 81
 	if (isset($filter['source']) && !empty($filter['source'])) {
82
-	    $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
82
+		$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
83 83
 	}
84 84
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
85
-	    $filter_query_where .= " AND ident = '".$filter['ident']."'";
85
+		$filter_query_where .= " AND ident = '".$filter['ident']."'";
86 86
 	}
87 87
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
88 88
 		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
89 89
 	}
90 90
 	if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
91
-	    $filter_query_date = '';
91
+		$filter_query_date = '';
92 92
 	    
93
-	    if (isset($filter['year']) && $filter['year'] != '') {
93
+		if (isset($filter['year']) && $filter['year'] != '') {
94 94
 		if ($globalDBdriver == 'mysql') {
95
-		    $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
95
+			$filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
96 96
 		} else {
97
-		    $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
97
+			$filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
98
+		}
98 99
 		}
99
-	    }
100
-	    if (isset($filter['month']) && $filter['month'] != '') {
100
+		if (isset($filter['month']) && $filter['month'] != '') {
101 101
 		if ($globalDBdriver == 'mysql') {
102
-		    $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
102
+			$filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
103 103
 		} else {
104
-		    $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
104
+			$filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
105 105
 		}
106
-	    }
107
-	    if (isset($filter['day']) && $filter['day'] != '') {
106
+		}
107
+		if (isset($filter['day']) && $filter['day'] != '') {
108 108
 		if ($globalDBdriver == 'mysql') {
109
-		    $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
109
+			$filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
110 110
 		} else {
111
-		    $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
111
+			$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
112
+		}
112 113
 		}
113
-	    }
114
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
114
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
115 115
 	}
116 116
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
117 117
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	}
121 121
 	$filter_query = $filter_query_join.$filter_query_where;
122 122
 	return $filter_query;
123
-    }
123
+	}
124 124
 
125 125
 	// Spotter_archive
126 126
 	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
@@ -151,44 +151,44 @@  discard block
 block discarded – undo
151 151
 	}
152 152
 
153 153
 
154
-        /**
155
-        * Gets all the spotter information based on a particular callsign
156
-        *
157
-        * @return Array the spotter information
158
-        *
159
-        */
160
-        public function getLastArchiveSpotterDataByIdent($ident)
161
-        {
154
+		/**
155
+		 * Gets all the spotter information based on a particular callsign
156
+		 *
157
+		 * @return Array the spotter information
158
+		 *
159
+		 */
160
+		public function getLastArchiveSpotterDataByIdent($ident)
161
+		{
162 162
 		$Spotter = new Spotter($this->db);
163
-                date_default_timezone_set('UTC');
163
+				date_default_timezone_set('UTC');
164 164
 
165
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
166
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
167
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
165
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
166
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
167
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
168 168
 
169
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
169
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
170 170
 
171
-                return $spotter_array;
172
-        }
171
+				return $spotter_array;
172
+		}
173 173
 
174 174
 
175
-        /**
176
-        * Gets last the spotter information based on a particular id
177
-        *
178
-        * @return Array the spotter information
179
-        *
180
-        */
181
-        public function getLastArchiveSpotterDataById($id)
182
-        {
183
-    		$Spotter = new Spotter($this->db);
184
-                date_default_timezone_set('UTC');
185
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
186
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
187
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
188
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
175
+		/**
176
+		 * Gets last the spotter information based on a particular id
177
+		 *
178
+		 * @return Array the spotter information
179
+		 *
180
+		 */
181
+		public function getLastArchiveSpotterDataById($id)
182
+		{
183
+			$Spotter = new Spotter($this->db);
184
+				date_default_timezone_set('UTC');
185
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
186
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
187
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
188
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
189 189
 
190 190
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
191
-                  /*
191
+				  /*
192 192
                 try {
193 193
                         $Connection = new Connection();
194 194
                         $sth = Connection->$db->prepare($query);
@@ -198,232 +198,232 @@  discard block
 block discarded – undo
198 198
                 }
199 199
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
200 200
                 */
201
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
202
-
203
-                return $spotter_array;
204
-        }
205
-
206
-        /**
207
-        * Gets all the spotter information based on a particular id
208
-        *
209
-        * @return Array the spotter information
210
-        *
211
-        */
212
-        public function getAllArchiveSpotterDataById($id)
213
-        {
214
-                date_default_timezone_set('UTC');
215
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
216
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
201
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
202
+
203
+				return $spotter_array;
204
+		}
205
+
206
+		/**
207
+		 * Gets all the spotter information based on a particular id
208
+		 *
209
+		 * @return Array the spotter information
210
+		 *
211
+		 */
212
+		public function getAllArchiveSpotterDataById($id)
213
+		{
214
+				date_default_timezone_set('UTC');
215
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
216
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
217 217
 
218 218
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
219 219
 
220
-                try {
221
-                        $sth = $this->db->prepare($query);
222
-                        $sth->execute(array(':id' => $id));
223
-                } catch(PDOException $e) {
224
-                        echo $e->getMessage();
225
-                        die;
226
-                }
227
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
228
-
229
-                return $spotter_array;
230
-        }
231
-
232
-        /**
233
-        * Gets coordinate & time spotter information based on a particular id
234
-        *
235
-        * @return Array the spotter information
236
-        *
237
-        */
238
-        public function getCoordArchiveSpotterDataById($id)
239
-        {
240
-                date_default_timezone_set('UTC');
241
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
242
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
220
+				try {
221
+						$sth = $this->db->prepare($query);
222
+						$sth->execute(array(':id' => $id));
223
+				} catch(PDOException $e) {
224
+						echo $e->getMessage();
225
+						die;
226
+				}
227
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
228
+
229
+				return $spotter_array;
230
+		}
231
+
232
+		/**
233
+		 * Gets coordinate & time spotter information based on a particular id
234
+		 *
235
+		 * @return Array the spotter information
236
+		 *
237
+		 */
238
+		public function getCoordArchiveSpotterDataById($id)
239
+		{
240
+				date_default_timezone_set('UTC');
241
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
242
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
243 243
 
244 244
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
245 245
 
246
-                try {
247
-                        $sth = $this->db->prepare($query);
248
-                        $sth->execute(array(':id' => $id));
249
-                } catch(PDOException $e) {
250
-                        echo $e->getMessage();
251
-                        die;
252
-                }
253
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
246
+				try {
247
+						$sth = $this->db->prepare($query);
248
+						$sth->execute(array(':id' => $id));
249
+				} catch(PDOException $e) {
250
+						echo $e->getMessage();
251
+						die;
252
+				}
253
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
254 254
 
255
-                return $spotter_array;
256
-        }
255
+				return $spotter_array;
256
+		}
257 257
 
258 258
 
259
-        /**
260
-        * Gets altitude information based on a particular callsign
261
-        *
262
-        * @return Array the spotter information
263
-        *
264
-        */
265
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
266
-        {
259
+		/**
260
+		 * Gets altitude information based on a particular callsign
261
+		 *
262
+		 * @return Array the spotter information
263
+		 *
264
+		 */
265
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
266
+		{
267 267
 
268
-                date_default_timezone_set('UTC');
268
+				date_default_timezone_set('UTC');
269 269
 
270
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
271
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
270
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
271
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
272 272
 
273
-                try {
274
-                        $sth = $this->db->prepare($query);
275
-                        $sth->execute(array(':ident' => $ident));
276
-                } catch(PDOException $e) {
277
-                        echo $e->getMessage();
278
-                        die;
279
-                }
280
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
273
+				try {
274
+						$sth = $this->db->prepare($query);
275
+						$sth->execute(array(':ident' => $ident));
276
+				} catch(PDOException $e) {
277
+						echo $e->getMessage();
278
+						die;
279
+				}
280
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
281 281
 
282
-                return $spotter_array;
283
-        }
282
+				return $spotter_array;
283
+		}
284 284
 
285
-        /**
286
-        * Gets altitude information based on a particular id
287
-        *
288
-        * @return Array the spotter information
289
-        *
290
-        */
291
-        public function getAltitudeArchiveSpotterDataById($id)
292
-        {
285
+		/**
286
+		 * Gets altitude information based on a particular id
287
+		 *
288
+		 * @return Array the spotter information
289
+		 *
290
+		 */
291
+		public function getAltitudeArchiveSpotterDataById($id)
292
+		{
293 293
 
294
-                date_default_timezone_set('UTC');
294
+				date_default_timezone_set('UTC');
295 295
 
296
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
297
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
296
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
297
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
298 298
 
299
-                try {
300
-                        $sth = $this->db->prepare($query);
301
-                        $sth->execute(array(':id' => $id));
302
-                } catch(PDOException $e) {
303
-                        echo $e->getMessage();
304
-                        die;
305
-                }
306
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
299
+				try {
300
+						$sth = $this->db->prepare($query);
301
+						$sth->execute(array(':id' => $id));
302
+				} catch(PDOException $e) {
303
+						echo $e->getMessage();
304
+						die;
305
+				}
306
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
307 307
 
308
-                return $spotter_array;
309
-        }
308
+				return $spotter_array;
309
+		}
310 310
 
311
-        /**
312
-        * Gets altitude & speed information based on a particular id
313
-        *
314
-        * @return Array the spotter information
315
-        *
316
-        */
317
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
318
-        {
311
+		/**
312
+		 * Gets altitude & speed information based on a particular id
313
+		 *
314
+		 * @return Array the spotter information
315
+		 *
316
+		 */
317
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
318
+		{
319 319
 
320
-                date_default_timezone_set('UTC');
320
+				date_default_timezone_set('UTC');
321 321
 
322
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
323
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
322
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
323
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
324 324
 
325
-                try {
326
-                        $sth = $this->db->prepare($query);
327
-                        $sth->execute(array(':id' => $id));
328
-                } catch(PDOException $e) {
329
-                        echo $e->getMessage();
330
-                        die;
331
-                }
332
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
325
+				try {
326
+						$sth = $this->db->prepare($query);
327
+						$sth->execute(array(':id' => $id));
328
+				} catch(PDOException $e) {
329
+						echo $e->getMessage();
330
+						die;
331
+				}
332
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
333 333
 
334
-                return $spotter_array;
335
-        }
334
+				return $spotter_array;
335
+		}
336 336
 
337 337
 
338
-        /**
339
-        * Gets altitude information based on a particular callsign
340
-        *
341
-        * @return Array the spotter information
342
-        *
343
-        */
344
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
345
-        {
338
+		/**
339
+		 * Gets altitude information based on a particular callsign
340
+		 *
341
+		 * @return Array the spotter information
342
+		 *
343
+		 */
344
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
345
+		{
346 346
 
347
-                date_default_timezone_set('UTC');
347
+				date_default_timezone_set('UTC');
348 348
 
349
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
350
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
349
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
350
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
351 351
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
352 352
 
353
-                try {
354
-                        $sth = $this->db->prepare($query);
355
-                        $sth->execute(array(':ident' => $ident));
356
-                } catch(PDOException $e) {
357
-                        echo $e->getMessage();
358
-                        die;
359
-                }
360
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
353
+				try {
354
+						$sth = $this->db->prepare($query);
355
+						$sth->execute(array(':ident' => $ident));
356
+				} catch(PDOException $e) {
357
+						echo $e->getMessage();
358
+						die;
359
+				}
360
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
361 361
 
362
-                return $spotter_array;
363
-        }
362
+				return $spotter_array;
363
+		}
364 364
 
365 365
 
366 366
 
367
-       /**
368
-        * Gets all the archive spotter information
369
-        *
370
-        * @return Array the spotter information
371
-        *
372
-        */
373
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
374
-        {
375
-    		$Spotter = new Spotter($this->db);
376
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
377
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
367
+	   /**
368
+	    * Gets all the archive spotter information
369
+	    *
370
+	    * @return Array the spotter information
371
+	    *
372
+	    */
373
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
374
+		{
375
+			$Spotter = new Spotter($this->db);
376
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
377
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
378 378
 
379
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
379
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
380 380
 
381
-                return $spotter_array;
382
-        }
381
+				return $spotter_array;
382
+		}
383 383
         
384
-        public function deleteSpotterArchiveTrackData()
385
-        {
384
+		public function deleteSpotterArchiveTrackData()
385
+		{
386 386
 		global $globalArchiveKeepTrackMonths;
387
-                date_default_timezone_set('UTC');
387
+				date_default_timezone_set('UTC');
388 388
 		$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
389
-                try {
390
-                        $sth = $this->db->prepare($query);
391
-                        $sth->execute();
392
-                } catch(PDOException $e) {
393
-                        echo $e->getMessage();
394
-                        die;
395
-                }
389
+				try {
390
+						$sth = $this->db->prepare($query);
391
+						$sth->execute();
392
+				} catch(PDOException $e) {
393
+						echo $e->getMessage();
394
+						die;
395
+				}
396 396
 	}
397 397
 
398 398
 	/**
399
-        * Gets Minimal Live Spotter data
400
-        *
401
-        * @return Array the spotter information
402
-        *
403
-        */
404
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
405
-        {
406
-                global $globalDBdriver, $globalLiveInterval;
407
-                date_default_timezone_set('UTC');
408
-
409
-                $filter_query = '';
410
-                if (isset($filter['source']) && !empty($filter['source'])) {
411
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
412
-                }
413
-                // Use spotter_output also ?
414
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
415
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
416
-                }
417
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
418
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
419
-                }
420
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
421
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
422
-                }
423
-
424
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
425
-                if ($globalDBdriver == 'mysql') {
426
-                        /*
399
+	 * Gets Minimal Live Spotter data
400
+	 *
401
+	 * @return Array the spotter information
402
+	 *
403
+	 */
404
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
405
+		{
406
+				global $globalDBdriver, $globalLiveInterval;
407
+				date_default_timezone_set('UTC');
408
+
409
+				$filter_query = '';
410
+				if (isset($filter['source']) && !empty($filter['source'])) {
411
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
412
+				}
413
+				// Use spotter_output also ?
414
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
415
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
416
+				}
417
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
418
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
419
+				}
420
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
421
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
422
+				}
423
+
424
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
425
+				if ($globalDBdriver == 'mysql') {
426
+						/*
427 427
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
428 428
                     		    FROM spotter_archive 
429 429
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -442,56 +442,56 @@  discard block
 block discarded – undo
442 442
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
443 443
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
444 444
                         	    '.$filter_query.' ORDER BY flightaware_id';
445
-                } else {
446
-                        //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
447
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
445
+				} else {
446
+						//$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
447
+						$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
448 448
                         	    FROM spotter_archive 
449 449
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
450 450
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
451 451
                         	    '.$filter_query.' ORDER BY flightaware_id';
452
-                }
453
-                //echo $query;
454
-                try {
455
-                        $sth = $this->db->prepare($query);
456
-                        $sth->execute();
457
-                } catch(PDOException $e) {
458
-                        echo $e->getMessage();
459
-                        die;
460
-                }
461
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
462
-
463
-                return $spotter_array;
464
-        }
452
+				}
453
+				//echo $query;
454
+				try {
455
+						$sth = $this->db->prepare($query);
456
+						$sth->execute();
457
+				} catch(PDOException $e) {
458
+						echo $e->getMessage();
459
+						die;
460
+				}
461
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
462
+
463
+				return $spotter_array;
464
+		}
465 465
 
466 466
 	/**
467
-        * Gets Minimal Live Spotter data
468
-        *
469
-        * @return Array the spotter information
470
-        *
471
-        */
472
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
473
-        {
474
-                global $globalDBdriver, $globalLiveInterval;
475
-                date_default_timezone_set('UTC');
476
-
477
-                $filter_query = '';
478
-                if (isset($filter['source']) && !empty($filter['source'])) {
479
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
480
-                }
481
-                // Should use spotter_output also ?
482
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
483
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
484
-                }
485
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
486
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
487
-                }
488
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
489
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
490
-                }
491
-
492
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
493
-                if ($globalDBdriver == 'mysql') {
494
-                        /*
467
+	 * Gets Minimal Live Spotter data
468
+	 *
469
+	 * @return Array the spotter information
470
+	 *
471
+	 */
472
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
473
+		{
474
+				global $globalDBdriver, $globalLiveInterval;
475
+				date_default_timezone_set('UTC');
476
+
477
+				$filter_query = '';
478
+				if (isset($filter['source']) && !empty($filter['source'])) {
479
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
480
+				}
481
+				// Should use spotter_output also ?
482
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
483
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
484
+				}
485
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
486
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
487
+				}
488
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
489
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
490
+				}
491
+
492
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
493
+				if ($globalDBdriver == 'mysql') {
494
+						/*
495 495
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
496 496
                     		    FROM spotter_archive 
497 497
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -502,95 +502,95 @@  discard block
 block discarded – undo
502 502
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
503 503
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
504 504
 
505
-                } else {
506
-                        //$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
507
-                       /*
505
+				} else {
506
+						//$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
507
+					   /*
508 508
                         $query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
509 509
                         	    FROM spotter_archive_output 
510 510
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
511 511
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
512 512
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
513 513
                         */
514
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
514
+						$query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
515 515
                         	    FROM spotter_archive_output 
516 516
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
517 517
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
518 518
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
519 519
 //                        	    .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
520 520
                         	    
521
-                }
522
-                //echo $query;
523
-                try {
524
-                        $sth = $this->db->prepare($query);
525
-                        $sth->execute();
526
-                } catch(PDOException $e) {
527
-                        echo $e->getMessage();
528
-                        die;
529
-                }
530
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
531
-
532
-                return $spotter_array;
533
-        }
521
+				}
522
+				//echo $query;
523
+				try {
524
+						$sth = $this->db->prepare($query);
525
+						$sth->execute();
526
+				} catch(PDOException $e) {
527
+						echo $e->getMessage();
528
+						die;
529
+				}
530
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
531
+
532
+				return $spotter_array;
533
+		}
534 534
 
535 535
 	 /**
536
-        * Gets count Live Spotter data
537
-        *
538
-        * @return Array the spotter information
539
-        *
540
-        */
541
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
542
-        {
543
-                global $globalDBdriver, $globalLiveInterval;
544
-                date_default_timezone_set('UTC');
545
-
546
-                $filter_query = '';
547
-                if (isset($filter['source']) && !empty($filter['source'])) {
548
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
549
-                }
550
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
551
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
552
-                }
553
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
554
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
555
-                }
556
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
557
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
558
-                }
559
-
560
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
561
-                if ($globalDBdriver == 'mysql') {
536
+	  * Gets count Live Spotter data
537
+	  *
538
+	  * @return Array the spotter information
539
+	  *
540
+	  */
541
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
542
+		{
543
+				global $globalDBdriver, $globalLiveInterval;
544
+				date_default_timezone_set('UTC');
545
+
546
+				$filter_query = '';
547
+				if (isset($filter['source']) && !empty($filter['source'])) {
548
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
549
+				}
550
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
551
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
552
+				}
553
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
554
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
555
+				}
556
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
557
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
558
+				}
559
+
560
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
561
+				if ($globalDBdriver == 'mysql') {
562 562
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
563 563
 			FROM spotter_archive l 
564 564
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
565
-                } else {
565
+				} else {
566 566
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
567
-                }
568
-                //echo $query;
569
-                try {
570
-                        $sth = $this->db->prepare($query);
571
-                        $sth->execute();
572
-                } catch(PDOException $e) {
573
-                        echo $e->getMessage();
574
-                        die;
575
-                }
567
+				}
568
+				//echo $query;
569
+				try {
570
+						$sth = $this->db->prepare($query);
571
+						$sth->execute();
572
+				} catch(PDOException $e) {
573
+						echo $e->getMessage();
574
+						die;
575
+				}
576 576
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
577 577
 		$sth->closeCursor();
578
-                return $result['nb'];
578
+				return $result['nb'];
579 579
 
580
-        }
580
+		}
581 581
 
582 582
 
583 583
 
584 584
 	// Spotter_Archive_output
585 585
 	
586
-    /**
587
-    * Gets all the spotter information
588
-    *
589
-    * @return Array the spotter information
590
-    *
591
-    */
592
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
593
-    {
586
+	/**
587
+	 * Gets all the spotter information
588
+	 *
589
+	 * @return Array the spotter information
590
+	 *
591
+	 */
592
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
593
+	{
594 594
 	global $globalTimezone, $globalDBdriver;
595 595
 	require_once(dirname(__FILE__).'/class.Translation.php');
596 596
 	$Translation = new Translation();
@@ -604,159 +604,159 @@  discard block
 block discarded – undo
604 604
 	$filter_query = $this->getFilter($filters);
605 605
 	if ($q != "")
606 606
 	{
607
-	    if (!is_string($q))
608
-	    {
607
+		if (!is_string($q))
608
+		{
609 609
 		return false;
610
-	    } else {
610
+		} else {
611 611
 	        
612 612
 		$q_array = explode(" ", $q);
613 613
 		
614 614
 		foreach ($q_array as $q_item){
615
-		    $additional_query .= " AND (";
616
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
617
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
618
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
619
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
620
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
621
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
622
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
623
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
624
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
625
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
626
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
627
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
628
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
629
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
630
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
631
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
632
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
633
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
634
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
635
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
636
-		    $translate = $Translation->ident2icao($q_item);
637
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
638
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
639
-		    $additional_query .= ")";
640
-		}
641
-	    }
615
+			$additional_query .= " AND (";
616
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
617
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
618
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
619
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
620
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
621
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
622
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
623
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
624
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
625
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
626
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
627
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
628
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
629
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
630
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
631
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
632
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
633
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
634
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
635
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
636
+			$translate = $Translation->ident2icao($q_item);
637
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
638
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
639
+			$additional_query .= ")";
640
+		}
641
+		}
642 642
 	}
643 643
 	
644 644
 	if ($registration != "")
645 645
 	{
646
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
647
-	    if (!is_string($registration))
648
-	    {
646
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
647
+		if (!is_string($registration))
648
+		{
649 649
 		return false;
650
-	    } else {
650
+		} else {
651 651
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
652
-	    }
652
+		}
653 653
 	}
654 654
 	
655 655
 	if ($aircraft_icao != "")
656 656
 	{
657
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
658
-	    if (!is_string($aircraft_icao))
659
-	    {
657
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
658
+		if (!is_string($aircraft_icao))
659
+		{
660 660
 		return false;
661
-	    } else {
661
+		} else {
662 662
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
663
-	    }
663
+		}
664 664
 	}
665 665
 	
666 666
 	if ($aircraft_manufacturer != "")
667 667
 	{
668
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
669
-	    if (!is_string($aircraft_manufacturer))
670
-	    {
668
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
669
+		if (!is_string($aircraft_manufacturer))
670
+		{
671 671
 		return false;
672
-	    } else {
672
+		} else {
673 673
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
674
-	    }
674
+		}
675 675
 	}
676 676
 	
677 677
 	if ($highlights == "true")
678 678
 	{
679
-	    if (!is_string($highlights))
680
-	    {
679
+		if (!is_string($highlights))
680
+		{
681 681
 		return false;
682
-	    } else {
682
+		} else {
683 683
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
684
-	    }
684
+		}
685 685
 	}
686 686
 	
687 687
 	if ($airline_icao != "")
688 688
 	{
689
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
690
-	    if (!is_string($airline_icao))
691
-	    {
689
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
690
+		if (!is_string($airline_icao))
691
+		{
692 692
 		return false;
693
-	    } else {
693
+		} else {
694 694
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
695
-	    }
695
+		}
696 696
 	}
697 697
 	
698 698
 	if ($airline_country != "")
699 699
 	{
700
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
701
-	    if (!is_string($airline_country))
702
-	    {
700
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
701
+		if (!is_string($airline_country))
702
+		{
703 703
 		return false;
704
-	    } else {
704
+		} else {
705 705
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
706
-	    }
706
+		}
707 707
 	}
708 708
 	
709 709
 	if ($airline_type != "")
710 710
 	{
711
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
712
-	    if (!is_string($airline_type))
713
-	    {
711
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
712
+		if (!is_string($airline_type))
713
+		{
714 714
 		return false;
715
-	    } else {
715
+		} else {
716 716
 		if ($airline_type == "passenger")
717 717
 		{
718
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
718
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
719 719
 		}
720 720
 		if ($airline_type == "cargo")
721 721
 		{
722
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
722
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
723 723
 		}
724 724
 		if ($airline_type == "military")
725 725
 		{
726
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
726
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
727
+		}
727 728
 		}
728
-	    }
729 729
 	}
730 730
 	
731 731
 	if ($airport != "")
732 732
 	{
733
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
734
-	    if (!is_string($airport))
735
-	    {
733
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
734
+		if (!is_string($airport))
735
+		{
736 736
 		return false;
737
-	    } else {
737
+		} else {
738 738
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
739
-	    }
739
+		}
740 740
 	}
741 741
 	
742 742
 	if ($airport_country != "")
743 743
 	{
744
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
745
-	    if (!is_string($airport_country))
746
-	    {
744
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
745
+		if (!is_string($airport_country))
746
+		{
747 747
 		return false;
748
-	    } else {
748
+		} else {
749 749
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
750
-	    }
750
+		}
751 751
 	}
752 752
     
753 753
 	if ($callsign != "")
754 754
 	{
755
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
756
-	    if (!is_string($callsign))
757
-	    {
755
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
756
+		if (!is_string($callsign))
757
+		{
758 758
 		return false;
759
-	    } else {
759
+		} else {
760 760
 		$translate = $Translation->ident2icao($callsign);
761 761
 		if ($translate != $callsign) {
762 762
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -764,99 +764,99 @@  discard block
 block discarded – undo
764 764
 		} else {
765 765
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
766 766
 		}
767
-	    }
767
+		}
768 768
 	}
769 769
 
770 770
 	if ($owner != "")
771 771
 	{
772
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
773
-	    if (!is_string($owner))
774
-	    {
772
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
773
+		if (!is_string($owner))
774
+		{
775 775
 		return false;
776
-	    } else {
776
+		} else {
777 777
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
778
-	    }
778
+		}
779 779
 	}
780 780
 
781 781
 	if ($pilot_name != "")
782 782
 	{
783
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
784
-	    if (!is_string($pilot_name))
785
-	    {
783
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
784
+		if (!is_string($pilot_name))
785
+		{
786 786
 		return false;
787
-	    } else {
787
+		} else {
788 788
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
789
-	    }
789
+		}
790 790
 	}
791 791
 	
792 792
 	if ($pilot_id != "")
793 793
 	{
794
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
795
-	    if (!is_string($pilot_id))
796
-	    {
794
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
795
+		if (!is_string($pilot_id))
796
+		{
797 797
 		return false;
798
-	    } else {
798
+		} else {
799 799
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
800
-	    }
800
+		}
801 801
 	}
802 802
 	
803 803
 	if ($departure_airport_route != "")
804 804
 	{
805
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
806
-	    if (!is_string($departure_airport_route))
807
-	    {
805
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
806
+		if (!is_string($departure_airport_route))
807
+		{
808 808
 		return false;
809
-	    } else {
809
+		} else {
810 810
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
811
-	    }
811
+		}
812 812
 	}
813 813
 	
814 814
 	if ($arrival_airport_route != "")
815 815
 	{
816
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
817
-	    if (!is_string($arrival_airport_route))
818
-	    {
816
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
817
+		if (!is_string($arrival_airport_route))
818
+		{
819 819
 		return false;
820
-	    } else {
820
+		} else {
821 821
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
822
-	    }
822
+		}
823 823
 	}
824 824
 	
825 825
 	if ($altitude != "")
826 826
 	{
827
-	    $altitude_array = explode(",", $altitude);
827
+		$altitude_array = explode(",", $altitude);
828 828
 	    
829
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
830
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
829
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
830
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
831 831
 	    
832 832
 
833
-	    if ($altitude_array[1] != "")
834
-	    {                
833
+		if ($altitude_array[1] != "")
834
+		{                
835 835
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
836 836
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
837 837
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
838
-	    } else {
838
+		} else {
839 839
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
840 840
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
841
-	    }
841
+		}
842 842
 	}
843 843
 	
844 844
 	if ($date_posted != "")
845 845
 	{
846
-	    $date_array = explode(",", $date_posted);
846
+		$date_array = explode(",", $date_posted);
847 847
 	    
848
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
849
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
848
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
849
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
850 850
 	    
851
-	    if ($globalTimezone != '') {
851
+		if ($globalTimezone != '') {
852 852
 		date_default_timezone_set($globalTimezone);
853 853
 		$datetime = new DateTime();
854 854
 		$offset = $datetime->format('P');
855
-	    } else $offset = '+00:00';
855
+		} else $offset = '+00:00';
856 856
 
857 857
 
858
-	    if ($date_array[1] != "")
859
-	    {                
858
+		if ($date_array[1] != "")
859
+		{                
860 860
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
861 861
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
862 862
 		if ($globalDBdriver == 'mysql') {
@@ -864,28 +864,28 @@  discard block
 block discarded – undo
864 864
 		} else {
865 865
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
866 866
 		}
867
-	    } else {
867
+		} else {
868 868
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
869
-                if ($globalDBdriver == 'mysql') {
869
+				if ($globalDBdriver == 'mysql') {
870 870
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
871 871
 		} else {
872 872
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
873 873
 		}
874
-	    }
874
+		}
875 875
 	}
876 876
 	
877 877
 	if ($limit != "")
878 878
 	{
879
-	    $limit_array = explode(",", $limit);
879
+		$limit_array = explode(",", $limit);
880 880
 	    
881
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
882
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
881
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
882
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
883 883
 	    
884
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
885
-	    {
884
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
885
+		{
886 886
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
887 887
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
888
-	    }
888
+		}
889 889
 	}
890 890
 	
891 891
 
@@ -916,33 +916,33 @@  discard block
 block discarded – undo
916 916
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
917 917
 
918 918
 	return $spotter_array;
919
-    }
919
+	}
920 920
 
921
-    public function deleteSpotterArchiveData()
922
-    {
921
+	public function deleteSpotterArchiveData()
922
+	{
923 923
 		global $globalArchiveKeepMonths, $globalDBdriver;
924
-                date_default_timezone_set('UTC');
925
-                if ($globalDBdriver == 'mysql') {
924
+				date_default_timezone_set('UTC');
925
+				if ($globalDBdriver == 'mysql') {
926 926
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
927 927
 		} else {
928 928
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
929 929
 		}
930
-                try {
931
-                        $sth = $this->db->prepare($query);
932
-                        $sth->execute();
933
-                } catch(PDOException $e) {
934
-                        return "error";
935
-                }
930
+				try {
931
+						$sth = $this->db->prepare($query);
932
+						$sth->execute();
933
+				} catch(PDOException $e) {
934
+						return "error";
935
+				}
936 936
 	}
937 937
 
938
-    /**
939
-    * Gets all the spotter information based on the callsign
940
-    *
941
-    * @return Array the spotter information
942
-    *
943
-    */
944
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
945
-    {
938
+	/**
939
+	 * Gets all the spotter information based on the callsign
940
+	 *
941
+	 * @return Array the spotter information
942
+	 *
943
+	 */
944
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
945
+	{
946 946
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
947 947
 	
948 948
 	date_default_timezone_set('UTC');
@@ -954,35 +954,35 @@  discard block
 block discarded – undo
954 954
 	
955 955
 	if ($ident != "")
956 956
 	{
957
-	    if (!is_string($ident))
958
-	    {
957
+		if (!is_string($ident))
958
+		{
959 959
 		return false;
960
-	    } else {
960
+		} else {
961 961
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
962 962
 		$query_values = array(':ident' => $ident);
963
-	    }
963
+		}
964 964
 	}
965 965
 	
966 966
 	if ($limit != "")
967 967
 	{
968
-	    $limit_array = explode(",", $limit);
968
+		$limit_array = explode(",", $limit);
969 969
 	    
970
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
971
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
970
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
971
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
972 972
 	    
973
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
974
-	    {
973
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
974
+		{
975 975
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
976 976
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
977
-	    }
977
+		}
978 978
 	}
979 979
 
980 980
 	if ($sort != "")
981 981
 	{
982
-	    $search_orderby_array = $Spotter->getOrderBy();
983
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
982
+		$search_orderby_array = $Spotter->getOrderBy();
983
+		$orderby_query = $search_orderby_array[$sort]['sql'];
984 984
 	} else {
985
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
985
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
986 986
 	}
987 987
 
988 988
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -990,17 +990,17 @@  discard block
 block discarded – undo
990 990
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
991 991
 
992 992
 	return $spotter_array;
993
-    }
993
+	}
994 994
 
995 995
 
996
-    /**
997
-    * Gets all the spotter information based on the owner
998
-    *
999
-    * @return Array the spotter information
1000
-    *
1001
-    */
1002
-    public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1003
-    {
996
+	/**
997
+	 * Gets all the spotter information based on the owner
998
+	 *
999
+	 * @return Array the spotter information
1000
+	 *
1001
+	 */
1002
+	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1003
+	{
1004 1004
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1005 1005
 	
1006 1006
 	date_default_timezone_set('UTC');
@@ -1013,35 +1013,35 @@  discard block
 block discarded – undo
1013 1013
 	
1014 1014
 	if ($owner != "")
1015 1015
 	{
1016
-	    if (!is_string($owner))
1017
-	    {
1016
+		if (!is_string($owner))
1017
+		{
1018 1018
 		return false;
1019
-	    } else {
1019
+		} else {
1020 1020
 		$additional_query = " AND (spotter_archive_output.owner_name = :owner)";
1021 1021
 		$query_values = array(':owner' => $owner);
1022
-	    }
1022
+		}
1023 1023
 	}
1024 1024
 	
1025 1025
 	if ($limit != "")
1026 1026
 	{
1027
-	    $limit_array = explode(",", $limit);
1027
+		$limit_array = explode(",", $limit);
1028 1028
 	    
1029
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1030
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1029
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1030
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1031 1031
 	    
1032
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1033
-	    {
1032
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1033
+		{
1034 1034
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1035 1035
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1036
-	    }
1036
+		}
1037 1037
 	}
1038 1038
 
1039 1039
 	if ($sort != "")
1040 1040
 	{
1041
-	    $search_orderby_array = $Spotter->getOrderBy();
1042
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1041
+		$search_orderby_array = $Spotter->getOrderBy();
1042
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1043 1043
 	} else {
1044
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1044
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1045 1045
 	}
1046 1046
 
1047 1047
 	$query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1049,16 +1049,16 @@  discard block
 block discarded – undo
1049 1049
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1050 1050
 
1051 1051
 	return $spotter_array;
1052
-    }
1053
-
1054
-    /**
1055
-    * Gets all the spotter information based on the pilot
1056
-    *
1057
-    * @return Array the spotter information
1058
-    *
1059
-    */
1060
-    public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1061
-    {
1052
+	}
1053
+
1054
+	/**
1055
+	 * Gets all the spotter information based on the pilot
1056
+	 *
1057
+	 * @return Array the spotter information
1058
+	 *
1059
+	 */
1060
+	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1061
+	{
1062 1062
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1063 1063
 	
1064 1064
 	date_default_timezone_set('UTC');
@@ -1077,24 +1077,24 @@  discard block
 block discarded – undo
1077 1077
 	
1078 1078
 	if ($limit != "")
1079 1079
 	{
1080
-	    $limit_array = explode(",", $limit);
1080
+		$limit_array = explode(",", $limit);
1081 1081
 	    
1082
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1083
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1082
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1083
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1084 1084
 	    
1085
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1086
-	    {
1085
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1086
+		{
1087 1087
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1088 1088
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1089
-	    }
1089
+		}
1090 1090
 	}
1091 1091
 
1092 1092
 	if ($sort != "")
1093 1093
 	{
1094
-	    $search_orderby_array = $Spotter->getOrderBy();
1095
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1094
+		$search_orderby_array = $Spotter->getOrderBy();
1095
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1096 1096
 	} else {
1097
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1097
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1098 1098
 	}
1099 1099
 
1100 1100
 	$query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1102,16 +1102,16 @@  discard block
 block discarded – undo
1102 1102
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1103 1103
 
1104 1104
 	return $spotter_array;
1105
-    }
1106
-
1107
-    /**
1108
-    * Gets all number of flight over countries
1109
-    *
1110
-    * @return Array the airline country list
1111
-    *
1112
-    */
1113
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1114
-    {
1105
+	}
1106
+
1107
+	/**
1108
+	 * Gets all number of flight over countries
1109
+	 *
1110
+	 * @return Array the airline country list
1111
+	 *
1112
+	 */
1113
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1114
+	{
1115 1115
 	global $globalDBdriver;
1116 1116
 	/*
1117 1117
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1121,14 +1121,14 @@  discard block
 block discarded – undo
1121 1121
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1122 1122
 		    FROM countries c, spotter_archive s
1123 1123
 		    WHERE c.iso2 = s.over_country ";
1124
-                if ($olderthanmonths > 0) {
1125
-            		if ($globalDBdriver == 'mysql') {
1124
+				if ($olderthanmonths > 0) {
1125
+					if ($globalDBdriver == 'mysql') {
1126 1126
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1127 1127
 			} else {
1128 1128
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1129 1129
 			}
1130 1130
 		}
1131
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1131
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1132 1132
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1133 1133
 	if ($limit) $query .= " LIMIT 0,10";
1134 1134
       
@@ -1141,23 +1141,23 @@  discard block
 block discarded – undo
1141 1141
         
1142 1142
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1143 1143
 	{
1144
-	    $temp_array['flight_count'] = $row['nb'];
1145
-	    $temp_array['flight_country'] = $row['name'];
1146
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1147
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1148
-	    $flight_array[] = $temp_array;
1144
+		$temp_array['flight_count'] = $row['nb'];
1145
+		$temp_array['flight_country'] = $row['name'];
1146
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1147
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1148
+		$flight_array[] = $temp_array;
1149 1149
 	}
1150 1150
 	return $flight_array;
1151
-    }
1152
-
1153
-    /**
1154
-    * Gets all number of flight over countries
1155
-    *
1156
-    * @return Array the airline country list
1157
-    *
1158
-    */
1159
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1160
-    {
1151
+	}
1152
+
1153
+	/**
1154
+	 * Gets all number of flight over countries
1155
+	 *
1156
+	 * @return Array the airline country list
1157
+	 *
1158
+	 */
1159
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1160
+	{
1161 1161
 	global $globalDBdriver;
1162 1162
 	/*
1163 1163
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1167,14 +1167,14 @@  discard block
 block discarded – undo
1167 1167
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1168 1168
 		    FROM countries c, spotter_archive s, spotter_output o
1169 1169
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id ";
1170
-                if ($olderthanmonths > 0) {
1171
-            		if ($globalDBdriver == 'mysql') {
1170
+				if ($olderthanmonths > 0) {
1171
+					if ($globalDBdriver == 'mysql') {
1172 1172
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1173 1173
 			} else {
1174 1174
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1175 1175
 			}
1176 1176
 		}
1177
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1177
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1178 1178
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1179 1179
 	if ($limit) $query .= " LIMIT 0,10";
1180 1180
       
@@ -1187,24 +1187,24 @@  discard block
 block discarded – undo
1187 1187
         
1188 1188
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1189 1189
 	{
1190
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1191
-	    $temp_array['flight_count'] = $row['nb'];
1192
-	    $temp_array['flight_country'] = $row['name'];
1193
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1194
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1195
-	    $flight_array[] = $temp_array;
1190
+		$temp_array['airline_icao'] = $row['airline_icao'];
1191
+		$temp_array['flight_count'] = $row['nb'];
1192
+		$temp_array['flight_country'] = $row['name'];
1193
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1194
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1195
+		$flight_array[] = $temp_array;
1196 1196
 	}
1197 1197
 	return $flight_array;
1198
-    }
1199
-
1200
-    /**
1201
-    * Gets last spotter information based on a particular callsign
1202
-    *
1203
-    * @return Array the spotter information
1204
-    *
1205
-    */
1206
-    public function getDateArchiveSpotterDataById($id,$date)
1207
-    {
1198
+	}
1199
+
1200
+	/**
1201
+	 * Gets last spotter information based on a particular callsign
1202
+	 *
1203
+	 * @return Array the spotter information
1204
+	 *
1205
+	 */
1206
+	public function getDateArchiveSpotterDataById($id,$date)
1207
+	{
1208 1208
 	$Spotter = new Spotter($this->db);
1209 1209
 	date_default_timezone_set('UTC');
1210 1210
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1212,16 +1212,16 @@  discard block
 block discarded – undo
1212 1212
 	$date = date('c',$date);
1213 1213
 	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1214 1214
 	return $spotter_array;
1215
-    }
1216
-
1217
-    /**
1218
-    * Gets all the spotter information based on a particular callsign
1219
-    *
1220
-    * @return Array the spotter information
1221
-    *
1222
-    */
1223
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1224
-    {
1215
+	}
1216
+
1217
+	/**
1218
+	 * Gets all the spotter information based on a particular callsign
1219
+	 *
1220
+	 * @return Array the spotter information
1221
+	 *
1222
+	 */
1223
+	public function getDateArchiveSpotterDataByIdent($ident,$date)
1224
+	{
1225 1225
 	$Spotter = new Spotter($this->db);
1226 1226
 	date_default_timezone_set('UTC');
1227 1227
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1229,16 +1229,16 @@  discard block
 block discarded – undo
1229 1229
 	$date = date('c',$date);
1230 1230
 	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1231 1231
 	return $spotter_array;
1232
-    }
1233
-
1234
-    /**
1235
-    * Gets all the spotter information based on the airport
1236
-    *
1237
-    * @return Array the spotter information
1238
-    *
1239
-    */
1240
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1241
-    {
1232
+	}
1233
+
1234
+	/**
1235
+	 * Gets all the spotter information based on the airport
1236
+	 *
1237
+	 * @return Array the spotter information
1238
+	 *
1239
+	 */
1240
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1241
+	{
1242 1242
 	global $global_query;
1243 1243
 	$Spotter = new Spotter();
1244 1244
 	date_default_timezone_set('UTC');
@@ -1249,35 +1249,35 @@  discard block
 block discarded – undo
1249 1249
 	
1250 1250
 	if ($airport != "")
1251 1251
 	{
1252
-	    if (!is_string($airport))
1253
-	    {
1252
+		if (!is_string($airport))
1253
+		{
1254 1254
 		return false;
1255
-	    } else {
1255
+		} else {
1256 1256
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))";
1257 1257
 		$query_values = array(':airport' => $airport);
1258
-	    }
1258
+		}
1259 1259
 	}
1260 1260
 	
1261 1261
 	if ($limit != "")
1262 1262
 	{
1263
-	    $limit_array = explode(",", $limit);
1263
+		$limit_array = explode(",", $limit);
1264 1264
 	    
1265
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1266
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1265
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1266
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1267 1267
 	    
1268
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1269
-	    {
1268
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1269
+		{
1270 1270
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1271 1271
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1272
-	    }
1272
+		}
1273 1273
 	}
1274 1274
 	
1275 1275
 	if ($sort != "")
1276 1276
 	{
1277
-	    $search_orderby_array = $Spotter->getOrderBy();
1278
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1277
+		$search_orderby_array = $Spotter->getOrderBy();
1278
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1279 1279
 	} else {
1280
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1280
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1281 1281
 	}
1282 1282
 
1283 1283
 	$query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1285,6 +1285,6 @@  discard block
 block discarded – undo
1285 1285
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1286 1286
 
1287 1287
 	return $spotter_array;
1288
-    }
1288
+	}
1289 1289
 }
1290 1290
 ?>
1291 1291
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -9,25 +9,25 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Stats.php');
10 10
 require_once(dirname(__FILE__).'/class.Source.php');
11 11
 if (isset($globalServerAPRS) && $globalServerAPRS) {
12
-    require_once(dirname(__FILE__).'/class.APRS.php');
12
+	require_once(dirname(__FILE__).'/class.APRS.php');
13 13
 }
14 14
 
15 15
 class MarineImport {
16
-    private $all_tracked = array();
17
-    private $last_delete_hourly = 0;
18
-    private $last_delete = 0;
19
-    private $stats = array();
20
-    private $tmd = 0;
21
-    private $source_location = array();
22
-    public $db = null;
23
-    public $nb = 0;
16
+	private $all_tracked = array();
17
+	private $last_delete_hourly = 0;
18
+	private $last_delete = 0;
19
+	private $stats = array();
20
+	private $tmd = 0;
21
+	private $source_location = array();
22
+	public $db = null;
23
+	public $nb = 0;
24 24
 
25
-    public function __construct($dbc = null) {
25
+	public function __construct($dbc = null) {
26 26
 	global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB;
27 27
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
28
-	    $Connection = new Connection($dbc);
29
-	    $this->db = $Connection->db();
30
-	    date_default_timezone_set('UTC');
28
+		$Connection = new Connection($dbc);
29
+		$this->db = $Connection->db();
30
+		date_default_timezone_set('UTC');
31 31
 	}
32 32
 	// Get previous source stats
33 33
 	/*
@@ -46,55 +46,55 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 	*/
48 48
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
49
-	    $APRSMarine = new APRSMarine();
50
-	    //$APRSSpotter->connect();
49
+		$APRSMarine = new APRSMarine();
50
+		//$APRSSpotter->connect();
51
+	}
51 52
 	}
52
-    }
53 53
 
54
-    public function checkAll() {
54
+	public function checkAll() {
55 55
 	global $globalDebug;
56 56
 	if ($globalDebug) echo "Update last seen tracked data...\n";
57 57
 	foreach ($this->all_tracked as $key => $flight) {
58
-	    if (isset($this->all_tracked[$key]['id'])) {
58
+		if (isset($this->all_tracked[$key]['id'])) {
59 59
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
60
-    		$Marine = new Marine($this->db);
61
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
62
-            }
60
+			$Marine = new Marine($this->db);
61
+			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
62
+			}
63
+	}
63 64
 	}
64
-    }
65 65
 
66
-    public function del() {
66
+	public function del() {
67 67
 	global $globalDebug, $globalNoDB, $globalNoImport;
68 68
 	// Delete old infos
69 69
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
70 70
 	foreach ($this->all_tracked as $key => $flight) {
71
-    	    if (isset($flight['lastupdate'])) {
72
-        	if ($flight['lastupdate'] < (time()-3000)) {
73
-            	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
74
-            		if (isset($this->all_tracked[$key]['id'])) {
75
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
76
-			    /*
71
+			if (isset($flight['lastupdate'])) {
72
+			if ($flight['lastupdate'] < (time()-3000)) {
73
+					if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
74
+					if (isset($this->all_tracked[$key]['id'])) {
75
+						if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
76
+				/*
77 77
 			    $MarineLive = new MarineLive();
78 78
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
79 79
 			    $MarineLive->db = null;
80 80
 			    */
81
-            		    //$real_arrival = $this->arrival($key);
82
-            		    $Marine = new Marine($this->db);
83
-            		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
81
+						//$real_arrival = $this->arrival($key);
82
+						$Marine = new Marine($this->db);
83
+						if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
84 84
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
85 85
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
86
-			    }
87
-			    // Put in archive
86
+				}
87
+				// Put in archive
88 88
 //				$Marine->db = null;
89 89
 			}
90
-            	    }
91
-            	    unset($this->all_tracked[$key]);
92
-    	        }
93
-	    }
94
-        }
95
-    }
90
+					}
91
+					unset($this->all_tracked[$key]);
92
+				}
93
+		}
94
+		}
95
+	}
96 96
 
97
-    public function add($line) {
97
+	public function add($line) {
98 98
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
99 99
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
100 100
 	date_default_timezone_set('UTC');
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	
104 104
 	// SBS format is CSV format
105 105
 	if(is_array($line) && isset($line['mmsi'])) {
106
-	    //print_r($line);
107
-  	    if (isset($line['mmsi'])) {
106
+		//print_r($line);
107
+  		if (isset($line['mmsi'])) {
108 108
 
109 109
 		/*
110 110
 		// Increment message number
@@ -121,64 +121,64 @@  discard block
 block discarded – undo
121 121
 		
122 122
 		$Common = new Common();
123 123
 		$AIS = new AIS();
124
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
125
-	        else $id = trim($line['id']);
124
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
125
+			else $id = trim($line['id']);
126 126
 		
127 127
 		if (!isset($this->all_tracked[$id])) {
128
-		    $this->all_tracked[$id] = array();
129
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
130
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
131
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
132
-		    if (!isset($line['id'])) {
128
+			$this->all_tracked[$id] = array();
129
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
130
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
131
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
132
+			if (!isset($line['id'])) {
133 133
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
134 134
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
135
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
136
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
135
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
136
+			if ($globalAllTracked !== FALSE) $dataFound = true;
137 137
 		}
138 138
 		
139 139
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
140
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
141
-		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
140
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
141
+			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
142 142
 			$Marine = new Marine($this->db);
143 143
 			$identity = $Marine->getIdentity($line['mmsi']);
144 144
 			if (!empty($identity)) {
145
-			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
146
-			    $this->all_tracked[$id]['type'] = $identity['type'];
145
+				$this->all_tracked[$id]['ident'] = $identity['ship_name'];
146
+				$this->all_tracked[$id]['type'] = $identity['type'];
147 147
 			}
148 148
 			//print_r($identity);
149 149
 			unset($Marine);
150 150
 			//$dataFound = true;
151
-		    }
151
+			}
152 152
 		}
153 153
 		if (isset($line['type_id']) && $line['type_id'] != '') {
154
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
154
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
155 155
 		}
156 156
 		if (isset($line['type']) && $line['type'] != '') {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
157
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
158 158
 		}
159 159
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
160
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
160
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
161 161
 		}
162 162
 		if (isset($line['imo']) && $line['imo'] != '') {
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
163
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
164 164
 		}
165 165
 		if (isset($line['callsign']) && $line['callsign'] != '') {
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
166
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
167 167
 		}
168 168
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
169
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
169
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
170 170
 		}
171 171
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
172
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
173 173
 		}
174 174
 
175 175
 
176 176
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
177 177
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
178
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
179
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
178
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
179
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
180 180
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
181
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
181
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
182 182
 				$timeelapsed = microtime(true);
183 183
 				$Marine = new Marine($this->db);
184 184
 				$fromsource = NULL;
@@ -186,31 +186,31 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
187 187
 				$Marine->db = null;
188 188
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
189
-			    }
189
+				}
190 190
 			}
191
-		    }
192
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
191
+			}
192
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
193 193
 		}
194 194
 
195 195
 		if (isset($line['speed']) && $line['speed'] != '') {
196
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
197
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
196
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
197
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
198 198
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
199
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
200
-		    if ($distance > 1000 && $distance < 10000) {
199
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
200
+			if ($distance > 1000 && $distance < 10000) {
201 201
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
202 202
 			$speed = $speed*3.6;
203 203
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
204 204
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
205
-		    }
205
+			}
206 206
 		}
207 207
 
208
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
209
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
210
-	    	    else unset($timediff);
211
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
208
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
209
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
210
+				else unset($timediff);
211
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
212 212
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
213
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
213
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
214 214
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
215 215
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
216 216
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -218,84 +218,84 @@  discard block
 block discarded – undo
218 218
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
219 219
 				$timeelapsed = microtime(true);
220 220
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
221
-				    $Marine = new Marine($this->db);
222
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
223
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
224
-				    $Marine->db = null;
225
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
221
+					$Marine = new Marine($this->db);
222
+					$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
223
+					if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
224
+					$Marine->db = null;
225
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
226 226
 				}
227 227
 				$this->tmd = 0;
228 228
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
229
-			    }
229
+				}
230 230
 			}
231 231
 
232 232
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
233 233
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
234 234
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
235
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
236
-				    $dataFound = true;
237
-				    $this->all_tracked[$id]['time_last_coord'] = time();
235
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
236
+					$dataFound = true;
237
+					$this->all_tracked[$id]['time_last_coord'] = time();
238 238
 				}
239 239
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
240 240
 			}
241 241
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
242
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
242
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
243 243
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
244 244
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
245
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
246
-				    $dataFound = true;
247
-				    $this->all_tracked[$id]['time_last_coord'] = time();
245
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
246
+					$dataFound = true;
247
+					$this->all_tracked[$id]['time_last_coord'] = time();
248 248
 				}
249 249
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
250 250
 			}
251 251
 
252
-		    } else if ($globalDebug && $timediff > 20) {
252
+			} else if ($globalDebug && $timediff > 20) {
253 253
 			$this->tmd = $this->tmd + 1;
254 254
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
255 255
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
256 256
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
257 257
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
258
-		    }
258
+			}
259 259
 		}
260 260
 		if (isset($line['last_update']) && $line['last_update'] != '') {
261
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
261
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
263 263
 		}
264 264
 		if (isset($line['format_source']) && $line['format_source'] != '') {
265
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
265
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
266 266
 		}
267 267
 		if (isset($line['source_name']) && $line['source_name'] != '') {
268
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
268
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
269 269
 		}
270 270
 		if (isset($line['status']) && $line['status'] != '') {
271
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
271
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
272 272
 		}
273 273
 
274 274
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
275
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
275
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
276 276
 		}
277 277
 		
278 278
 		if (isset($line['heading']) && $line['heading'] != '') {
279
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
280
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
281
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
282
-		    //$dataFound = true;
279
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
280
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
281
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
282
+			//$dataFound = true;
283 283
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
284
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
285
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
286
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
287
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
284
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
285
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
286
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
287
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
288 288
   		}
289 289
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
290 290
 
291 291
 		if (isset($line['datetime'])) {
292
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
292
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
293 293
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
294
-		    } else {
294
+			} else {
295 295
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
296 296
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
297 297
 				return '';
298
-		    }
298
+			}
299 299
 		} else {
300 300
 			date_default_timezone_set('UTC');
301 301
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -303,50 +303,50 @@  discard block
 block discarded – undo
303 303
 
304 304
 
305 305
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
306
-		    $this->all_tracked[$id]['lastupdate'] = time();
307
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
308
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
309
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
306
+			$this->all_tracked[$id]['lastupdate'] = time();
307
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
308
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
309
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
310 310
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
311
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
312
-				    $timeelapsed = microtime(true);
313
-				    $MarineLive = new MarineLive($this->db);
314
-				    if (isset($line['id'])) {
311
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
312
+					$timeelapsed = microtime(true);
313
+					$MarineLive = new MarineLive($this->db);
314
+					if (isset($line['id'])) {
315 315
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
316 316
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
317
-				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
317
+					} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
318 318
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
319 319
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
320
-				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
320
+					} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
321 321
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
322 322
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
323
-				    } else $recent_ident = '';
324
-				    $MarineLive->db=null;
325
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
326
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
323
+					} else $recent_ident = '';
324
+					$MarineLive->db=null;
325
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
326
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
327 327
 				} else $recent_ident = '';
328
-			    } else {
328
+				} else {
329 329
 				$recent_ident = '';
330 330
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
331
-			    }
332
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
333
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
334
-			    {
331
+				}
332
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
333
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
334
+				{
335 335
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
336 336
 				//adds the spotter data for the archive
337
-				    $highlight = '';
338
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
339
-				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
337
+					$highlight = '';
338
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
339
+					if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
340 340
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
341
-					    $timeelapsed = microtime(true);
342
-					    $Marine = new Marine($this->db);
343
-					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
344
-					    $Marine->db = null;
345
-					    if ($globalDebug && isset($result)) echo $result."\n";
346
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
341
+						$timeelapsed = microtime(true);
342
+						$Marine = new Marine($this->db);
343
+						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
344
+						$Marine->db = null;
345
+						if ($globalDebug && isset($result)) echo $result."\n";
346
+						if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
347 347
 					}
348
-				    }
349
-				    /*
348
+					}
349
+					/*
350 350
 				    // Add source stat in DB
351 351
 				    $Stats = new Stats($this->db);
352 352
 				    if (!empty($this->stats)) {
@@ -373,56 +373,56 @@  discard block
 block discarded – undo
373 373
 				    }
374 374
 				    $Stats->db = null;
375 375
 				    */
376
-				    $this->del();
376
+					$this->del();
377 377
 				//$ignoreImport = false;
378 378
 				$this->all_tracked[$id]['addedMarine'] = 1;
379 379
 				//print_r($this->all_tracked[$id]);
380 380
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
381
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
382
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
383
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
381
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
382
+					//MarineLive->deleteLiveMarineDataNotUpdated();
383
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
384 384
 					$MarineLive = new MarineLive($this->db);
385 385
 					$MarineLive->deleteLiveMarineData();
386 386
 					$MarineLive->db=null;
387 387
 					if ($globalDebug) echo " Done\n";
388
-				    }
389
-				    $this->last_delete = time();
388
+					}
389
+					$this->last_delete = time();
390 390
 				}
391
-			    } elseif ($recent_ident != '') {
391
+				} elseif ($recent_ident != '') {
392 392
 				$this->all_tracked[$id]['id'] = $recent_ident;
393 393
 				$this->all_tracked[$id]['addedMarine'] = 1;
394 394
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
395
-				    if (isset($globalDaemon) && !$globalDaemon) {
395
+					if (isset($globalDaemon) && !$globalDaemon) {
396 396
 					$Marine = new Marine($this->db);
397 397
 					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
398 398
 					$Marine->db = null;
399
-				    }
399
+					}
400 400
 				}
401 401
 				
402
-			    }
402
+				}
403 403
 			}
404
-		    }
405
-		    //adds the spotter LIVE data
406
-		    if ($globalDebug) {
404
+			}
405
+			//adds the spotter LIVE data
406
+			if ($globalDebug) {
407 407
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
408
-		    }
409
-		    $ignoreImport = false;
408
+			}
409
+			$ignoreImport = false;
410 410
 
411
-		    if (!$ignoreImport) {
411
+			if (!$ignoreImport) {
412 412
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
413 413
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
414 414
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
415
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
415
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
416 416
 					$timeelapsed = microtime(true);
417 417
 					$MarineLive = new MarineLive($this->db);
418 418
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
419 419
 					$MarineLive->db = null;
420 420
 					if ($globalDebug) echo $result."\n";
421 421
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
422
-				    }
422
+					}
423 423
 				}
424 424
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
425
-				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
425
+					$APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
426 426
 				}
427 427
 				$this->all_tracked[$id]['putinarchive'] = false;
428 428
 
@@ -487,24 +487,24 @@  discard block
 block discarded – undo
487 487
 			
488 488
 			
489 489
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
490
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
490
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
491 491
 				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
492 492
 				$MarineLive = new MarineLive($this->db);
493 493
 				$MarineLive->deleteLiveMarineDataNotUpdated();
494 494
 				$MarineLive->db = null;
495 495
 				//MarineLive->deleteLiveMarineData();
496 496
 				if ($globalDebug) echo " Done\n";
497
-			    }
498
-			    $this->last_delete_hourly = time();
497
+				}
498
+				$this->last_delete_hourly = time();
499 499
 			}
500 500
 			
501
-		    }
502
-		    //$ignoreImport = false;
501
+			}
502
+			//$ignoreImport = false;
503 503
 		}
504 504
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
505 505
 		if ($send) return $this->all_tracked[$id];
506
-	    }
506
+		}
507
+	}
507 508
 	}
508
-    }
509 509
 }
510 510
 ?>
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	/**
89
-	* Gets all the spotter information based on the latest data entry
90
-	*
91
-	* @return Array the spotter information
92
-	*
93
-	*/
89
+	 * Gets all the spotter information based on the latest data entry
90
+	 *
91
+	 * @return Array the spotter information
92
+	 *
93
+	 */
94 94
 	public function getLiveMarineData($limit = '', $sort = '', $filter = array())
95 95
 	{
96 96
 		global $globalDBdriver, $globalLiveInterval;
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	}
133 133
 
134 134
 	/**
135
-	* Gets Minimal Live Spotter data
136
-	*
137
-	* @return Array the spotter information
138
-	*
139
-	*/
135
+	 * Gets Minimal Live Spotter data
136
+	 *
137
+	 * @return Array the spotter information
138
+	 *
139
+	 */
140 140
 	public function getMinLiveMarineData($filter = array())
141 141
 	{
142 142
 		global $globalDBdriver, $globalLiveInterval;
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	/**
169
-	* Gets Minimal Live Spotter data since xx seconds
170
-	*
171
-	* @return Array the spotter information
172
-	*
173
-	*/
169
+	 * Gets Minimal Live Spotter data since xx seconds
170
+	 *
171
+	 * @return Array the spotter information
172
+	 *
173
+	 */
174 174
 	public function getMinLastLiveMarineData($filter = array())
175 175
 	{
176 176
 		global $globalDBdriver, $globalLiveInterval;
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184 184
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
185 185
 			ORDER BY marine_live.fammarine_id, marine_live.date";
186
-                } else {
186
+				} else {
187 187
 			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
188 188
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
189 189
 			ORDER BY marine_live.fammarine_id, marine_live.date";
190 190
 		}
191 191
 
192
-    		try {
192
+			try {
193 193
 			$sth = $this->db->prepare($query);
194 194
 			$sth->execute();
195 195
 		} catch(PDOException $e) {
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	}
202 202
 
203 203
 	/**
204
-	* Gets number of latest data entry
205
-	*
206
-	* @return String number of entry
207
-	*
208
-	*/
204
+	 * Gets number of latest data entry
205
+	 *
206
+	 * @return String number of entry
207
+	 *
208
+	 */
209 209
 	public function getLiveMarineCount($filter = array())
210 210
 	{
211 211
 		global $globalDBdriver, $globalLiveInterval;
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	/**
233
-	* Gets all the spotter information based on the latest data entry and coord
234
-	*
235
-	* @return Array the spotter information
236
-	*
237
-	*/
233
+	 * Gets all the spotter information based on the latest data entry and coord
234
+	 *
235
+	 * @return Array the spotter information
236
+	 *
237
+	 */
238 238
 	public function getLiveMarineDatabyCoord($coord, $filter = array())
239 239
 	{
240 240
 		global $globalDBdriver, $globalLiveInterval;
@@ -258,11 +258,11 @@  discard block
 block discarded – undo
258 258
 	}
259 259
 
260 260
 	/**
261
-	* Gets all the spotter information based on the latest data entry and coord
262
-	*
263
-	* @return Array the spotter information
264
-	*
265
-	*/
261
+	 * Gets all the spotter information based on the latest data entry and coord
262
+	 *
263
+	 * @return Array the spotter information
264
+	 *
265
+	 */
266 266
 	public function getMinLiveMarineDatabyCoord($coord, $filter = array())
267 267
 	{
268 268
 		global $globalDBdriver, $globalLiveInterval;
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 	}
291 291
 
292 292
 	/**
293
-	* Gets all the spotter information based on a user's latitude and longitude
294
-	*
295
-	* @return Array the spotter information
296
-	*
297
-	*/
293
+	 * Gets all the spotter information based on a user's latitude and longitude
294
+	 *
295
+	 * @return Array the spotter information
296
+	 *
297
+	 */
298 298
 	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
299 299
 	{
300 300
 		$Marine = new Marine($this->db);
@@ -307,134 +307,134 @@  discard block
 block discarded – undo
307 307
 		if ($lng != '')
308 308
 		{
309 309
 			if (!is_numeric($lng))
310
-                        {
311
-                                return false;
312
-                        }
313
-                }
314
-
315
-                if ($radius != '')
316
-                {
317
-                        if (!is_numeric($radius))
318
-                        {
319
-                                return false;
320
-                        }
321
-                }
310
+						{
311
+								return false;
312
+						}
313
+				}
314
+
315
+				if ($radius != '')
316
+				{
317
+						if (!is_numeric($radius))
318
+						{
319
+								return false;
320
+						}
321
+				}
322 322
 		$additional_query = '';
323 323
 		if ($interval != '')
324
-                {
325
-                        if (!is_string($interval))
326
-                        {
327
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
328
-			        return false;
329
-                        } else {
330
-                if ($interval == '1m')
331
-                {
332
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
333
-                } else if ($interval == '15m'){
334
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
335
-                } 
336
-            }
337
-                } else {
338
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
339
-        }
340
-
341
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
324
+				{
325
+						if (!is_string($interval))
326
+						{
327
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
328
+					return false;
329
+						} else {
330
+				if ($interval == '1m')
331
+				{
332
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
333
+				} else if ($interval == '15m'){
334
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
335
+				} 
336
+			}
337
+				} else {
338
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
339
+		}
340
+
341
+				$query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
342 342
                    WHERE marine_live.latitude <> '' 
343 343
                                    AND marine_live.longitude <> '' 
344 344
                    ".$additional_query."
345 345
                    HAVING distance < :radius  
346 346
                                    ORDER BY distance";
347 347
 
348
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
348
+				$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
349 349
 
350
-                return $spotter_array;
351
-        }
350
+				return $spotter_array;
351
+		}
352 352
 
353 353
     
354
-        /**
355
-	* Gets all the spotter information based on a particular callsign
356
-	*
357
-	* @return Array the spotter information
358
-	*
359
-	*/
354
+		/**
355
+		 * Gets all the spotter information based on a particular callsign
356
+		 *
357
+		 * @return Array the spotter information
358
+		 *
359
+		 */
360 360
 	public function getLastLiveMarineDataByIdent($ident)
361 361
 	{
362 362
 		$Marine = new Marine($this->db);
363 363
 		date_default_timezone_set('UTC');
364 364
 
365 365
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
366
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
366
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
367 367
 
368 368
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
369 369
 
370 370
 		return $spotter_array;
371 371
 	}
372 372
 
373
-        /**
374
-	* Gets all the spotter information based on a particular callsign
375
-	*
376
-	* @return Array the spotter information
377
-	*
378
-	*/
373
+		/**
374
+		 * Gets all the spotter information based on a particular callsign
375
+		 *
376
+		 * @return Array the spotter information
377
+		 *
378
+		 */
379 379
 	public function getDateLiveMarineDataByIdent($ident,$date)
380 380
 	{
381 381
 		$Marine = new Marine($this->db);
382 382
 		date_default_timezone_set('UTC');
383 383
 
384 384
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
385
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
385
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
386 386
 
387
-                $date = date('c',$date);
387
+				$date = date('c',$date);
388 388
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
389 389
 
390 390
 		return $spotter_array;
391 391
 	}
392 392
 
393
-        /**
394
-	* Gets last spotter information based on a particular callsign
395
-	*
396
-	* @return Array the spotter information
397
-	*
398
-	*/
393
+		/**
394
+		 * Gets last spotter information based on a particular callsign
395
+		 *
396
+		 * @return Array the spotter information
397
+		 *
398
+		 */
399 399
 	public function getLastLiveMarineDataById($id)
400 400
 	{
401 401
 		$Marine = new Marine($this->db);
402 402
 		date_default_timezone_set('UTC');
403 403
 
404 404
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
405
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
405
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
406 406
 
407 407
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
408 408
 
409 409
 		return $spotter_array;
410 410
 	}
411 411
 
412
-        /**
413
-	* Gets last spotter information based on a particular callsign
414
-	*
415
-	* @return Array the spotter information
416
-	*
417
-	*/
412
+		/**
413
+		 * Gets last spotter information based on a particular callsign
414
+		 *
415
+		 * @return Array the spotter information
416
+		 *
417
+		 */
418 418
 	public function getDateLiveMarineDataById($id,$date)
419 419
 	{
420 420
 		$Marine = new Marine($this->db);
421 421
 		date_default_timezone_set('UTC');
422 422
 
423 423
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
424
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
425
-                $date = date('c',$date);
424
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
425
+				$date = date('c',$date);
426 426
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
427 427
 
428 428
 		return $spotter_array;
429 429
 	}
430 430
 
431 431
 
432
-        /**
433
-	* Gets all the spotter information based on a particular id
434
-	*
435
-	* @return Array the spotter information
436
-	*
437
-	*/
432
+		/**
433
+		 * Gets all the spotter information based on a particular id
434
+		 *
435
+		 * @return Array the spotter information
436
+		 *
437
+		 */
438 438
 	public function getAllLiveMarineDataById($id,$liveinterval = false)
439 439
 	{
440 440
 		global $globalDBdriver, $globalLiveInterval;
@@ -462,18 +462,18 @@  discard block
 block discarded – undo
462 462
 		return $spotter_array;
463 463
 	}
464 464
 
465
-        /**
466
-	* Gets all the spotter information based on a particular ident
467
-	*
468
-	* @return Array the spotter information
469
-	*
470
-	*/
465
+		/**
466
+		 * Gets all the spotter information based on a particular ident
467
+		 *
468
+		 * @return Array the spotter information
469
+		 *
470
+		 */
471 471
 	public function getAllLiveMarineDataByIdent($ident)
472 472
 	{
473 473
 		date_default_timezone_set('UTC');
474 474
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
475 475
 		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
476
-    		try {
476
+			try {
477 477
 			
478 478
 			$sth = $this->db->prepare($query);
479 479
 			$sth->execute(array(':ident' => $ident));
@@ -487,23 +487,23 @@  discard block
 block discarded – undo
487 487
 
488 488
 
489 489
 	/**
490
-	* Deletes all info in the table
491
-	*
492
-	* @return String success or false
493
-	*
494
-	*/
490
+	 * Deletes all info in the table
491
+	 *
492
+	 * @return String success or false
493
+	 *
494
+	 */
495 495
 	public function deleteLiveMarineData()
496 496
 	{
497 497
 		global $globalDBdriver;
498 498
 		if ($globalDBdriver == 'mysql') {
499 499
 			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
500 500
 			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';
501
-            		//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
501
+					//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
502 502
 		} else {
503 503
 			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";
504 504
 		}
505 505
         
506
-    		try {
506
+			try {
507 507
 			
508 508
 			$sth = $this->db->prepare($query);
509 509
 			$sth->execute();
@@ -515,18 +515,18 @@  discard block
 block discarded – undo
515 515
 	}
516 516
 
517 517
 	/**
518
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
519
-	*
520
-	* @return String success or false
521
-	*
522
-	*/
518
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
519
+	 *
520
+	 * @return String success or false
521
+	 *
522
+	 */
523 523
 	public function deleteLiveMarineDataNotUpdated()
524 524
 	{
525 525
 		global $globalDBdriver, $globalDebug;
526 526
 		if ($globalDBdriver == 'mysql') {
527 527
 			//$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0';
528
-    			$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
529
-    			try {
528
+				$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
529
+				try {
530 530
 				
531 531
 				$sth = $this->db->prepare($query);
532 532
 				$sth->execute();
@@ -534,8 +534,8 @@  discard block
 block discarded – undo
534 534
 				return "error";
535 535
 			}
536 536
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
537
-                        $i = 0;
538
-                        $j =0;
537
+						$i = 0;
538
+						$j =0;
539 539
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
540 540
 			foreach($all as $row)
541 541
 			{
@@ -543,20 +543,20 @@  discard block
 block discarded – undo
543 543
 				$j++;
544 544
 				if ($j == 30) {
545 545
 					if ($globalDebug) echo ".";
546
-				    	try {
546
+						try {
547 547
 						
548 548
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
549 549
 						$sth->execute();
550 550
 					} catch(PDOException $e) {
551 551
 						return "error";
552 552
 					}
553
-                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
554
-                                	$j = 0;
553
+									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
554
+									$j = 0;
555 555
 				}
556 556
 				$query_delete .= "'".$row['fammarine_id']."',";
557 557
 			}
558 558
 			if ($i > 0) {
559
-    				try {
559
+					try {
560 560
 					
561 561
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
562 562
 					$sth->execute();
@@ -567,9 +567,9 @@  discard block
 block discarded – undo
567 567
 			return "success";
568 568
 		} elseif ($globalDBdriver == 'pgsql') {
569 569
 			//$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0";
570
-    			//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
571
-    			$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
572
-    			try {
570
+				//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
571
+				$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
572
+				try {
573 573
 				
574 574
 				$sth = $this->db->prepare($query);
575 575
 				$sth->execute();
@@ -613,17 +613,17 @@  discard block
 block discarded – undo
613 613
 	}
614 614
 
615 615
 	/**
616
-	* Deletes all info in the table for an ident
617
-	*
618
-	* @return String success or false
619
-	*
620
-	*/
616
+	 * Deletes all info in the table for an ident
617
+	 *
618
+	 * @return String success or false
619
+	 *
620
+	 */
621 621
 	public function deleteLiveMarineDataByIdent($ident)
622 622
 	{
623 623
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
624 624
 		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
625 625
         
626
-    		try {
626
+			try {
627 627
 			
628 628
 			$sth = $this->db->prepare($query);
629 629
 			$sth->execute(array(':ident' => $ident));
@@ -635,17 +635,17 @@  discard block
 block discarded – undo
635 635
 	}
636 636
 
637 637
 	/**
638
-	* Deletes all info in the table for an id
639
-	*
640
-	* @return String success or false
641
-	*
642
-	*/
638
+	 * Deletes all info in the table for an id
639
+	 *
640
+	 * @return String success or false
641
+	 *
642
+	 */
643 643
 	public function deleteLiveMarineDataById($id)
644 644
 	{
645 645
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
646 646
 		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
647 647
         
648
-    		try {
648
+			try {
649 649
 			
650 650
 			$sth = $this->db->prepare($query);
651 651
 			$sth->execute(array(':id' => $id));
@@ -658,11 +658,11 @@  discard block
 block discarded – undo
658 658
 
659 659
 
660 660
 	/**
661
-	* Gets the aircraft ident within the last hour
662
-	*
663
-	* @return String the ident
664
-	*
665
-	*/
661
+	 * Gets the aircraft ident within the last hour
662
+	 *
663
+	 * @return String the ident
664
+	 *
665
+	 */
666 666
 	public function getIdentFromLastHour($ident)
667 667
 	{
668 668
 		global $globalDBdriver, $globalTimezone;
@@ -688,14 +688,14 @@  discard block
 block discarded – undo
688 688
 			$ident_result = $row['ident'];
689 689
 		}
690 690
 		return $ident_result;
691
-        }
691
+		}
692 692
 
693 693
 	/**
694
-	* Check recent aircraft
695
-	*
696
-	* @return String the ident
697
-	*
698
-	*/
694
+	 * Check recent aircraft
695
+	 *
696
+	 * @return String the ident
697
+	 *
698
+	 */
699 699
 	public function checkIdentRecent($ident)
700 700
 	{
701 701
 		global $globalDBdriver, $globalTimezone;
@@ -721,14 +721,14 @@  discard block
 block discarded – undo
721 721
 			$ident_result = $row['fammarine_id'];
722 722
 		}
723 723
 		return $ident_result;
724
-        }
724
+		}
725 725
 
726 726
 	/**
727
-	* Check recent aircraft by id
728
-	*
729
-	* @return String the ident
730
-	*
731
-	*/
727
+	 * Check recent aircraft by id
728
+	 *
729
+	 * @return String the ident
730
+	 *
731
+	 */
732 732
 	public function checkIdRecent($id)
733 733
 	{
734 734
 		global $globalDBdriver, $globalTimezone;
@@ -754,14 +754,14 @@  discard block
 block discarded – undo
754 754
 			$ident_result = $row['fammarine_id'];
755 755
 		}
756 756
 		return $ident_result;
757
-        }
757
+		}
758 758
 
759 759
 	/**
760
-	* Check recent aircraft by mmsi
761
-	*
762
-	* @return String the ident
763
-	*
764
-	*/
760
+	 * Check recent aircraft by mmsi
761
+	 *
762
+	 * @return String the ident
763
+	 *
764
+	 */
765 765
 	public function checkMMSIRecent($mmsi)
766 766
 	{
767 767
 		global $globalDBdriver, $globalTimezone;
@@ -787,19 +787,19 @@  discard block
 block discarded – undo
787 787
 			$ident_result = $row['fammarine_id'];
788 788
 		}
789 789
 		return $ident_result;
790
-        }
790
+		}
791 791
 
792 792
 	/**
793
-	* Adds a new spotter data
794
-	*
795
-	* @param String $fammarine_id the ID from flightaware
796
-	* @param String $ident the flight ident
797
-	* @param String $aircraft_icao the aircraft type
798
-	* @param String $departure_airport_icao the departure airport
799
-	* @param String $arrival_airport_icao the arrival airport
800
-	* @return String success or false
801
-	*
802
-	*/
793
+	 * Adds a new spotter data
794
+	 *
795
+	 * @param String $fammarine_id the ID from flightaware
796
+	 * @param String $ident the flight ident
797
+	 * @param String $aircraft_icao the aircraft type
798
+	 * @param String $departure_airport_icao the departure airport
799
+	 * @param String $arrival_airport_icao the arrival airport
800
+	 * @return String success or false
801
+	 *
802
+	 */
803 803
 	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
804 804
 	{
805 805
 		global $globalURL, $globalArchive, $globalDebug;
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
871 871
 		
872 872
 
873
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
874
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
875
-            	if ($arrival_date == '') $arrival_date = NULL;
873
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
874
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
875
+				if ($arrival_date == '') $arrival_date = NULL;
876 876
 		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
877 877
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
878 878
 
@@ -881,9 +881,9 @@  discard block
 block discarded – undo
881 881
 			
882 882
 			$sth = $this->db->prepare($query);
883 883
 			$sth->execute($query_values);
884
-                } catch(PDOException $e) {
885
-                	return "error : ".$e->getMessage();
886
-                }
884
+				} catch(PDOException $e) {
885
+					return "error : ".$e->getMessage();
886
+				}
887 887
 		/*
888 888
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
889 889
 		    if ($globalDebug) echo '(Add to SBS archive : ';
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	/**
89
-	* Gets all the spotter information based on the latest data entry
90
-	*
91
-	* @return Array the spotter information
92
-	*
93
-	*/
89
+	 * Gets all the spotter information based on the latest data entry
90
+	 *
91
+	 * @return Array the spotter information
92
+	 *
93
+	 */
94 94
 	public function getLiveTrackerData($limit = '', $sort = '', $filter = array())
95 95
 	{
96 96
 		global $globalDBdriver, $globalLiveInterval;
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	}
133 133
 
134 134
 	/**
135
-	* Gets Minimal Live Spotter data
136
-	*
137
-	* @return Array the spotter information
138
-	*
139
-	*/
135
+	 * Gets Minimal Live Spotter data
136
+	 *
137
+	 * @return Array the spotter information
138
+	 *
139
+	 */
140 140
 	public function getMinLiveTrackerData($filter = array())
141 141
 	{
142 142
 		global $globalDBdriver, $globalLiveInterval;
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	/**
173
-	* Gets Minimal Live Spotter data since xx seconds
174
-	*
175
-	* @return Array the spotter information
176
-	*
177
-	*/
173
+	 * Gets Minimal Live Spotter data since xx seconds
174
+	 *
175
+	 * @return Array the spotter information
176
+	 *
177
+	 */
178 178
 	public function getMinLastLiveTrackerData($filter = array())
179 179
 	{
180 180
 		global $globalDBdriver, $globalLiveInterval;
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
188 188
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
189 189
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
190
-                } else {
190
+				} else {
191 191
 			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
192 192
 			FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
193 193
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
194 194
 		}
195 195
 
196
-    		try {
196
+			try {
197 197
 			$sth = $this->db->prepare($query);
198 198
 			$sth->execute();
199 199
 		} catch(PDOException $e) {
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 	}
206 206
 
207 207
 	/**
208
-	* Gets number of latest data entry
209
-	*
210
-	* @return String number of entry
211
-	*
212
-	*/
208
+	 * Gets number of latest data entry
209
+	 *
210
+	 * @return String number of entry
211
+	 *
212
+	 */
213 213
 	public function getLiveTrackerCount($filter = array())
214 214
 	{
215 215
 		global $globalDBdriver, $globalLiveInterval;
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 	}
235 235
 
236 236
 	/**
237
-	* Gets all the spotter information based on the latest data entry and coord
238
-	*
239
-	* @return Array the spotter information
240
-	*
241
-	*/
237
+	 * Gets all the spotter information based on the latest data entry and coord
238
+	 *
239
+	 * @return Array the spotter information
240
+	 *
241
+	 */
242 242
 	public function getLiveTrackerDatabyCoord($coord, $filter = array())
243 243
 	{
244 244
 		global $globalDBdriver, $globalLiveInterval;
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 	}
263 263
 
264 264
 	/**
265
-	* Gets all the spotter information based on the latest data entry and coord
266
-	*
267
-	* @return Array the spotter information
268
-	*
269
-	*/
265
+	 * Gets all the spotter information based on the latest data entry and coord
266
+	 *
267
+	 * @return Array the spotter information
268
+	 *
269
+	 */
270 270
 	public function getMinLiveTrackerDatabyCoord($coord, $filter = array())
271 271
 	{
272 272
 		global $globalDBdriver, $globalLiveInterval;
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
 	}
294 294
 
295 295
 	/**
296
-	* Gets all the spotter information based on a user's latitude and longitude
297
-	*
298
-	* @return Array the spotter information
299
-	*
300
-	*/
296
+	 * Gets all the spotter information based on a user's latitude and longitude
297
+	 *
298
+	 * @return Array the spotter information
299
+	 *
300
+	 */
301 301
 	public function getLatestTrackerForLayar($lat, $lng, $radius, $interval)
302 302
 	{
303 303
 		$Tracker = new Tracker($this->db);
@@ -310,142 +310,142 @@  discard block
 block discarded – undo
310 310
 		if ($lng != '')
311 311
 		{
312 312
 			if (!is_numeric($lng))
313
-                        {
314
-                                return false;
315
-                        }
316
-                }
317
-
318
-                if ($radius != '')
319
-                {
320
-                        if (!is_numeric($radius))
321
-                        {
322
-                                return false;
323
-                        }
324
-                }
313
+						{
314
+								return false;
315
+						}
316
+				}
317
+
318
+				if ($radius != '')
319
+				{
320
+						if (!is_numeric($radius))
321
+						{
322
+								return false;
323
+						}
324
+				}
325 325
 		$additional_query = '';
326 326
 		if ($interval != '')
327
-                {
328
-                        if (!is_string($interval))
329
-                        {
330
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
331
-			        return false;
332
-                        } else {
333
-                if ($interval == '1m')
334
-                {
335
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
336
-                } else if ($interval == '15m'){
337
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
338
-                } 
339
-            }
340
-                } else {
341
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
342
-        }
343
-
344
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
327
+				{
328
+						if (!is_string($interval))
329
+						{
330
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
331
+					return false;
332
+						} else {
333
+				if ($interval == '1m')
334
+				{
335
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
336
+				} else if ($interval == '15m'){
337
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
338
+				} 
339
+			}
340
+				} else {
341
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
342
+		}
343
+
344
+				$query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
345 345
                    WHERE tracker_live.latitude <> '' 
346 346
                                    AND tracker_live.longitude <> '' 
347 347
                    ".$additional_query."
348 348
                    HAVING distance < :radius  
349 349
                                    ORDER BY distance";
350 350
 
351
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
351
+				$spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
352 352
 
353
-                return $spotter_array;
354
-        }
353
+				return $spotter_array;
354
+		}
355 355
 
356 356
     
357
-        /**
358
-	* Gets all the spotter information based on a particular callsign
359
-	*
360
-	* @return Array the spotter information
361
-	*
362
-	*/
357
+		/**
358
+		 * Gets all the spotter information based on a particular callsign
359
+		 *
360
+		 * @return Array the spotter information
361
+		 *
362
+		 */
363 363
 	public function getLastLiveTrackerDataByIdent($ident)
364 364
 	{
365 365
 		$Tracker = new Tracker($this->db);
366 366
 		date_default_timezone_set('UTC');
367 367
 
368 368
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
369
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
369
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
370 370
 
371 371
 		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
372 372
 
373 373
 		return $spotter_array;
374 374
 	}
375 375
 
376
-        /**
377
-	* Gets all the spotter information based on a particular callsign
378
-	*
379
-	* @return Array the spotter information
380
-	*
381
-	*/
376
+		/**
377
+		 * Gets all the spotter information based on a particular callsign
378
+		 *
379
+		 * @return Array the spotter information
380
+		 *
381
+		 */
382 382
 	public function getDateLiveTrackerDataByIdent($ident,$date)
383 383
 	{
384 384
 		$Tracker = new Tracker($this->db);
385 385
 		date_default_timezone_set('UTC');
386 386
 
387 387
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
388
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
388
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
389 389
 
390
-                $date = date('c',$date);
390
+				$date = date('c',$date);
391 391
 		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
392 392
 
393 393
 		return $spotter_array;
394 394
 	}
395 395
 
396
-        /**
397
-	* Gets last spotter information based on a particular callsign
398
-	*
399
-	* @return Array the spotter information
400
-	*
401
-	*/
396
+		/**
397
+		 * Gets last spotter information based on a particular callsign
398
+		 *
399
+		 * @return Array the spotter information
400
+		 *
401
+		 */
402 402
 	public function getLastLiveTrackerDataById($id)
403 403
 	{
404 404
 		$Tracker = new Tracker($this->db);
405 405
 		date_default_timezone_set('UTC');
406 406
 
407 407
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
408
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
408
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
409 409
 
410 410
 		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
411 411
 
412 412
 		return $spotter_array;
413 413
 	}
414 414
 
415
-        /**
416
-	* Gets last spotter information based on a particular callsign
417
-	*
418
-	* @return Array the spotter information
419
-	*
420
-	*/
415
+		/**
416
+		 * Gets last spotter information based on a particular callsign
417
+		 *
418
+		 * @return Array the spotter information
419
+		 *
420
+		 */
421 421
 	public function getDateLiveTrackerDataById($id,$date)
422 422
 	{
423 423
 		$Tracker = new Tracker($this->db);
424 424
 		date_default_timezone_set('UTC');
425 425
 
426 426
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
427
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
428
-                $date = date('c',$date);
427
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
428
+				$date = date('c',$date);
429 429
 		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
430 430
 
431 431
 		return $spotter_array;
432 432
 	}
433 433
 
434
-        /**
435
-	* Gets altitude information based on a particular callsign
436
-	*
437
-	* @return Array the spotter information
438
-	*
439
-	*/
434
+		/**
435
+		 * Gets altitude information based on a particular callsign
436
+		 *
437
+		 * @return Array the spotter information
438
+		 *
439
+		 */
440 440
 	public function getAltitudeLiveTrackerDataByIdent($ident)
441 441
 	{
442 442
 
443 443
 		date_default_timezone_set('UTC');
444 444
 
445 445
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
446
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
446
+				$query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
447 447
 
448
-    		try {
448
+			try {
449 449
 			
450 450
 			$sth = $this->db->prepare($query);
451 451
 			$sth->execute(array(':ident' => $ident));
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 		return $spotter_array;
459 459
 	}
460 460
 
461
-        /**
462
-	* Gets all the spotter information based on a particular id
463
-	*
464
-	* @return Array the spotter information
465
-	*
466
-	*/
461
+		/**
462
+		 * Gets all the spotter information based on a particular id
463
+		 *
464
+		 * @return Array the spotter information
465
+		 *
466
+		 */
467 467
 	public function getAllLiveTrackerDataById($id,$liveinterval = false)
468 468
 	{
469 469
 		global $globalDBdriver, $globalLiveInterval;
@@ -491,18 +491,18 @@  discard block
 block discarded – undo
491 491
 		return $spotter_array;
492 492
 	}
493 493
 
494
-        /**
495
-	* Gets all the spotter information based on a particular ident
496
-	*
497
-	* @return Array the spotter information
498
-	*
499
-	*/
494
+		/**
495
+		 * Gets all the spotter information based on a particular ident
496
+		 *
497
+		 * @return Array the spotter information
498
+		 *
499
+		 */
500 500
 	public function getAllLiveTrackerDataByIdent($ident)
501 501
 	{
502 502
 		date_default_timezone_set('UTC');
503 503
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
504 504
 		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
505
-    		try {
505
+			try {
506 506
 			
507 507
 			$sth = $this->db->prepare($query);
508 508
 			$sth->execute(array(':ident' => $ident));
@@ -516,23 +516,23 @@  discard block
 block discarded – undo
516 516
 
517 517
 
518 518
 	/**
519
-	* Deletes all info in the table
520
-	*
521
-	* @return String success or false
522
-	*
523
-	*/
519
+	 * Deletes all info in the table
520
+	 *
521
+	 * @return String success or false
522
+	 *
523
+	 */
524 524
 	public function deleteLiveTrackerData()
525 525
 	{
526 526
 		global $globalDBdriver;
527 527
 		if ($globalDBdriver == 'mysql') {
528 528
 			//$query  = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date";
529 529
 			$query  = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date';
530
-            		//$query  = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";
530
+					//$query  = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";
531 531
 		} else {
532 532
 			$query  = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date";
533 533
 		}
534 534
         
535
-    		try {
535
+			try {
536 536
 			
537 537
 			$sth = $this->db->prepare($query);
538 538
 			$sth->execute();
@@ -544,18 +544,18 @@  discard block
 block discarded – undo
544 544
 	}
545 545
 
546 546
 	/**
547
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
548
-	*
549
-	* @return String success or false
550
-	*
551
-	*/
547
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
548
+	 *
549
+	 * @return String success or false
550
+	 *
551
+	 */
552 552
 	public function deleteLiveTrackerDataNotUpdated()
553 553
 	{
554 554
 		global $globalDBdriver, $globalDebug;
555 555
 		if ($globalDBdriver == 'mysql') {
556 556
 			//$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0';
557
-    			$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
558
-    			try {
557
+				$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
558
+				try {
559 559
 				
560 560
 				$sth = $this->db->prepare($query);
561 561
 				$sth->execute();
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
 				return "error";
564 564
 			}
565 565
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
566
-                        $i = 0;
567
-                        $j =0;
566
+						$i = 0;
567
+						$j =0;
568 568
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
569 569
 			foreach($all as $row)
570 570
 			{
@@ -572,20 +572,20 @@  discard block
 block discarded – undo
572 572
 				$j++;
573 573
 				if ($j == 30) {
574 574
 					if ($globalDebug) echo ".";
575
-				    	try {
575
+						try {
576 576
 						
577 577
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
578 578
 						$sth->execute();
579 579
 					} catch(PDOException $e) {
580 580
 						return "error";
581 581
 					}
582
-                                	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
583
-                                	$j = 0;
582
+									$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
583
+									$j = 0;
584 584
 				}
585 585
 				$query_delete .= "'".$row['famtrackid']."',";
586 586
 			}
587 587
 			if ($i > 0) {
588
-    				try {
588
+					try {
589 589
 					
590 590
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
591 591
 					$sth->execute();
@@ -596,9 +596,9 @@  discard block
 block discarded – undo
596 596
 			return "success";
597 597
 		} elseif ($globalDBdriver == 'pgsql') {
598 598
 			//$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0";
599
-    			//$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
600
-    			$query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
601
-    			try {
599
+				//$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
600
+				$query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
601
+				try {
602 602
 				
603 603
 				$sth = $this->db->prepare($query);
604 604
 				$sth->execute();
@@ -642,17 +642,17 @@  discard block
 block discarded – undo
642 642
 	}
643 643
 
644 644
 	/**
645
-	* Deletes all info in the table for an ident
646
-	*
647
-	* @return String success or false
648
-	*
649
-	*/
645
+	 * Deletes all info in the table for an ident
646
+	 *
647
+	 * @return String success or false
648
+	 *
649
+	 */
650 650
 	public function deleteLiveTrackerDataByIdent($ident)
651 651
 	{
652 652
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
653 653
 		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
654 654
         
655
-    		try {
655
+			try {
656 656
 			
657 657
 			$sth = $this->db->prepare($query);
658 658
 			$sth->execute(array(':ident' => $ident));
@@ -664,17 +664,17 @@  discard block
 block discarded – undo
664 664
 	}
665 665
 
666 666
 	/**
667
-	* Deletes all info in the table for an id
668
-	*
669
-	* @return String success or false
670
-	*
671
-	*/
667
+	 * Deletes all info in the table for an id
668
+	 *
669
+	 * @return String success or false
670
+	 *
671
+	 */
672 672
 	public function deleteLiveTrackerDataById($id)
673 673
 	{
674 674
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
675 675
 		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
676 676
         
677
-    		try {
677
+			try {
678 678
 			
679 679
 			$sth = $this->db->prepare($query);
680 680
 			$sth->execute(array(':id' => $id));
@@ -687,11 +687,11 @@  discard block
 block discarded – undo
687 687
 
688 688
 
689 689
 	/**
690
-	* Gets the aircraft ident within the last hour
691
-	*
692
-	* @return String the ident
693
-	*
694
-	*/
690
+	 * Gets the aircraft ident within the last hour
691
+	 *
692
+	 * @return String the ident
693
+	 *
694
+	 */
695 695
 	public function getIdentFromLastHour($ident)
696 696
 	{
697 697
 		global $globalDBdriver, $globalTimezone;
@@ -717,14 +717,14 @@  discard block
 block discarded – undo
717 717
 			$ident_result = $row['ident'];
718 718
 		}
719 719
 		return $ident_result;
720
-        }
720
+		}
721 721
 
722 722
 	/**
723
-	* Check recent aircraft
724
-	*
725
-	* @return String the ident
726
-	*
727
-	*/
723
+	 * Check recent aircraft
724
+	 *
725
+	 * @return String the ident
726
+	 *
727
+	 */
728 728
 	public function checkIdentRecent($ident)
729 729
 	{
730 730
 		global $globalDBdriver, $globalTimezone;
@@ -750,14 +750,14 @@  discard block
 block discarded – undo
750 750
 			$ident_result = $row['famtrackid'];
751 751
 		}
752 752
 		return $ident_result;
753
-        }
753
+		}
754 754
 
755 755
 	/**
756
-	* Check recent aircraft by id
757
-	*
758
-	* @return String the ident
759
-	*
760
-	*/
756
+	 * Check recent aircraft by id
757
+	 *
758
+	 * @return String the ident
759
+	 *
760
+	 */
761 761
 	public function checkIdRecent($id)
762 762
 	{
763 763
 		global $globalDBdriver, $globalTimezone;
@@ -783,19 +783,19 @@  discard block
 block discarded – undo
783 783
 			$ident_result = $row['famtrackid'];
784 784
 		}
785 785
 		return $ident_result;
786
-        }
786
+		}
787 787
 
788 788
 	/**
789
-	* Adds a new spotter data
790
-	*
791
-	* @param String $famtrackid the ID from flightaware
792
-	* @param String $ident the flight ident
793
-	* @param String $aircraft_icao the aircraft type
794
-	* @param String $departure_airport_icao the departure airport
795
-	* @param String $arrival_airport_icao the arrival airport
796
-	* @return String success or false
797
-	*
798
-	*/
789
+	 * Adds a new spotter data
790
+	 *
791
+	 * @param String $famtrackid the ID from flightaware
792
+	 * @param String $ident the flight ident
793
+	 * @param String $aircraft_icao the aircraft type
794
+	 * @param String $departure_airport_icao the departure airport
795
+	 * @param String $arrival_airport_icao the arrival airport
796
+	 * @return String success or false
797
+	 *
798
+	 */
799 799
 	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
800 800
 	{
801 801
 		global $globalURL, $globalArchive, $globalDebug;
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
869 869
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
870 870
 
871
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
872
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
871
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
872
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
873 873
             	
874 874
 		$query  = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
875 875
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
@@ -879,9 +879,9 @@  discard block
 block discarded – undo
879 879
 			
880 880
 			$sth = $this->db->prepare($query);
881 881
 			$sth->execute($query_values);
882
-                } catch(PDOException $e) {
883
-                	return "error : ".$e->getMessage();
884
-                }
882
+				} catch(PDOException $e) {
883
+					return "error : ".$e->getMessage();
884
+				}
885 885
 		/*
886 886
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
887 887
 		    if ($globalDebug) echo '(Add to SBS archive : ';
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 
13 13
 	/**
14
-	* Get SQL query part for filter used
15
-	* @param Array $filter the filter
16
-	* @return Array the SQL part
17
-	*/
14
+	 * Get SQL query part for filter used
15
+	 * @param Array $filter the filter
16
+	 * @return Array the SQL part
17
+	 */
18 18
 	
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 	}
79 79
 
80 80
 	/**
81
-	* Executes the SQL statements to get the spotter information
82
-	*
83
-	* @param String $query the SQL query
84
-	* @param Array $params parameter of the query
85
-	* @param String $limitQuery the limit query
86
-	* @return Array the spotter information
87
-	*
88
-	*/
81
+	 * Executes the SQL statements to get the spotter information
82
+	 *
83
+	 * @param String $query the SQL query
84
+	 * @param Array $params parameter of the query
85
+	 * @param String $limitQuery the limit query
86
+	 * @return Array the spotter information
87
+	 *
88
+	 */
89 89
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 	
213 213
 	
214 214
 	/**
215
-	* Gets all the spotter information based on the latest data entry
216
-	*
217
-	* @return Array the spotter information
218
-	*
219
-	*/
215
+	 * Gets all the spotter information based on the latest data entry
216
+	 *
217
+	 * @return Array the spotter information
218
+	 *
219
+	 */
220 220
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
221 221
 	{
222 222
 		global $global_query;
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
 	}
275 275
 
276 276
 	/**
277
-	* Gets all the spotter information based on the callsign
278
-	*
279
-	* @return Array the spotter information
280
-	*
281
-	*/
277
+	 * Gets all the spotter information based on the callsign
278
+	 *
279
+	 * @return Array the spotter information
280
+	 *
281
+	 */
282 282
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
283 283
 	{
284 284
 		global $global_query;
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
 
390 390
 
391 391
 	/**
392
-	* Gets all source name
393
-	*
394
-	* @param String type format of source
395
-	* @return Array list of source name
396
-	*
397
-	*/
392
+	 * Gets all source name
393
+	 *
394
+	 * @param String type format of source
395
+	 * @return Array list of source name
396
+	 *
397
+	 */
398 398
 	public function getAllSourceName($type = '',$filters = array())
399 399
 	{
400 400
 		$filter_query = $this->getFilter($filters,true,true);
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
 
425 425
 
426 426
 	/**
427
-	* Gets a list of all idents/callsigns
428
-	*
429
-	* @return Array list of ident/callsign names
430
-	*
431
-	*/
427
+	 * Gets a list of all idents/callsigns
428
+	 *
429
+	 * @return Array list of ident/callsign names
430
+	 *
431
+	 */
432 432
 	public function getAllIdents($filters = array())
433 433
 	{
434 434
 		$filter_query = $this->getFilter($filters,true,true);
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
 	}
453 453
 
454 454
 	/**
455
-	* Gets all info from a mmsi
456
-	*
457
-	* @return Array list of mmsi info
458
-	*
459
-	*/
455
+	 * Gets all info from a mmsi
456
+	 *
457
+	 * @return Array list of mmsi info
458
+	 *
459
+	 */
460 460
 	public function getIdentity($mmsi)
461 461
 	{
462 462
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -513,18 +513,18 @@  discard block
 block discarded – undo
513 513
 	
514 514
 	
515 515
 	/**
516
-	* Update ident tracker data
517
-	*
518
-	* @param String $fammarine_id the ID
519
-	* @param String $ident the marine ident
520
-	* @return String success or false
521
-	*
522
-	*/	
516
+	 * Update ident tracker data
517
+	 *
518
+	 * @param String $fammarine_id the ID
519
+	 * @param String $ident the marine ident
520
+	 * @return String success or false
521
+	 *
522
+	 */	
523 523
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
524 524
 	{
525 525
 
526 526
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
527
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
527
+				$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
528 528
 
529 529
 		try {
530 530
 			$sth = $this->db->prepare($query);
@@ -537,17 +537,17 @@  discard block
 block discarded – undo
537 537
 
538 538
 	}
539 539
 	/**
540
-	* Update latest marine data
541
-	*
542
-	* @param String $fammarine_id the ID
543
-	* @param String $ident the marine ident
544
-	* @return String success or false
545
-	*
546
-	*/	
540
+	 * Update latest marine data
541
+	 *
542
+	 * @param String $fammarine_id the ID
543
+	 * @param String $ident the marine ident
544
+	 * @return String success or false
545
+	 *
546
+	 */	
547 547
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
548 548
 	{
549 549
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
550
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
550
+				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
551 551
 
552 552
 		try {
553 553
 			$sth = $this->db->prepare($query);
@@ -561,30 +561,30 @@  discard block
 block discarded – undo
561 561
 	}
562 562
 
563 563
 	/**
564
-	* Adds a new spotter data
565
-	*
566
-	* @param String $fammarine_id the ID
567
-	* @param String $ident the marine ident
568
-	* @param String $departure_airport_icao the departure airport
569
-	* @param String $arrival_airport_icao the arrival airport
570
-	* @param String $latitude latitude of flight
571
-	* @param String $longitude latitude of flight
572
-	* @param String $waypoints waypoints of flight
573
-	* @param String $heading heading of flight
574
-	* @param String $groundspeed speed of flight
575
-	* @param String $date date of flight
576
-	* @param String $departure_airport_time departure time of flight
577
-	* @param String $arrival_airport_time arrival time of flight
578
-	* @param String $squawk squawk code of flight
579
-	* @param String $route_stop route stop of flight
580
-	* @param String $highlight highlight or not
581
-	* @param String $ModeS ModesS code of flight
582
-	* @param String $registration registration code of flight
583
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
584
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
585
-	* @param String $verticalrate vertival rate of flight
586
-	* @return String success or false
587
-	*/
564
+	 * Adds a new spotter data
565
+	 *
566
+	 * @param String $fammarine_id the ID
567
+	 * @param String $ident the marine ident
568
+	 * @param String $departure_airport_icao the departure airport
569
+	 * @param String $arrival_airport_icao the arrival airport
570
+	 * @param String $latitude latitude of flight
571
+	 * @param String $longitude latitude of flight
572
+	 * @param String $waypoints waypoints of flight
573
+	 * @param String $heading heading of flight
574
+	 * @param String $groundspeed speed of flight
575
+	 * @param String $date date of flight
576
+	 * @param String $departure_airport_time departure time of flight
577
+	 * @param String $arrival_airport_time arrival time of flight
578
+	 * @param String $squawk squawk code of flight
579
+	 * @param String $route_stop route stop of flight
580
+	 * @param String $highlight highlight or not
581
+	 * @param String $ModeS ModesS code of flight
582
+	 * @param String $registration registration code of flight
583
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
584
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
585
+	 * @param String $verticalrate vertival rate of flight
586
+	 * @return String success or false
587
+	 */
588 588
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '')
589 589
 	{
590 590
 		global $globalURL, $globalMarineImageFetch;
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
 			unset($Image);
682 682
 		}
683 683
 		
684
-                if ($latitude == '' && $longitude == '') {
685
-            		$latitude = 0;
686
-            		$longitude = 0;
687
-            	}
688
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
689
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
690
-                if ($arrival_date == '') $arrival_date = NULL;
684
+				if ($latitude == '' && $longitude == '') {
685
+					$latitude = 0;
686
+					$longitude = 0;
687
+				}
688
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
689
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
690
+				if ($arrival_date == '') $arrival_date = NULL;
691 691
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
692 692
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
693 693
 
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 			$sth->execute($query_values);
699 699
 			$this->db = null;
700 700
 		} catch (PDOException $e) {
701
-		    return "error : ".$e->getMessage();
701
+			return "error : ".$e->getMessage();
702 702
 		}
703 703
 		
704 704
 		return "success";
@@ -707,11 +707,11 @@  discard block
 block discarded – undo
707 707
 	
708 708
   
709 709
 	/**
710
-	* Gets the aircraft ident within the last hour
711
-	*
712
-	* @return String the ident
713
-	*
714
-	*/
710
+	 * Gets the aircraft ident within the last hour
711
+	 *
712
+	 * @return String the ident
713
+	 *
714
+	 */
715 715
 	public function getIdentFromLastHour($ident)
716 716
 	{
717 717
 		global $globalDBdriver, $globalTimezone;
@@ -727,11 +727,11 @@  discard block
 block discarded – undo
727 727
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
728 728
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
729 729
 			$query_data = array(':ident' => $ident);
730
-    		}
730
+			}
731 731
 		
732 732
 		$sth = $this->db->prepare($query);
733 733
 		$sth->execute($query_data);
734
-    		$ident_result='';
734
+			$ident_result='';
735 735
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
736 736
 		{
737 737
 			$ident_result = $row['ident'];
@@ -742,11 +742,11 @@  discard block
 block discarded – undo
742 742
 	
743 743
 	
744 744
 	/**
745
-	* Gets the aircraft data from the last 20 seconds
746
-	*
747
-	* @return Array the spotter data
748
-	*
749
-	*/
745
+	 * Gets the aircraft data from the last 20 seconds
746
+	 *
747
+	 * @return Array the spotter data
748
+	 *
749
+	 */
750 750
 	public function getRealTimeData($q = '')
751 751
 	{
752 752
 		global $globalDBdriver;
@@ -784,11 +784,11 @@  discard block
 block discarded – undo
784 784
 	
785 785
 
786 786
 	/**
787
-	* Gets all number of flight over countries
788
-	*
789
-	* @return Array the airline country list
790
-	*
791
-	*/
787
+	 * Gets all number of flight over countries
788
+	 *
789
+	 * @return Array the airline country list
790
+	 *
791
+	 */
792 792
 /*
793 793
 	public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
794 794
 	{
@@ -839,11 +839,11 @@  discard block
 block discarded – undo
839 839
 	
840 840
 	
841 841
 	/**
842
-	* Gets all callsigns that have flown over
843
-	*
844
-	* @return Array the callsign list
845
-	*
846
-	*/
842
+	 * Gets all callsigns that have flown over
843
+	 *
844
+	 * @return Array the callsign list
845
+	 *
846
+	 */
847 847
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
848 848
 	{
849 849
 		global $globalDBdriver;
@@ -910,11 +910,11 @@  discard block
 block discarded – undo
910 910
 
911 911
 
912 912
 	/**
913
-	* Counts all dates
914
-	*
915
-	* @return Array the date list
916
-	*
917
-	*/
913
+	 * Counts all dates
914
+	 *
915
+	 * @return Array the date list
916
+	 *
917
+	 */
918 918
 	public function countAllDates($filters = array())
919 919
 	{
920 920
 		global $globalTimezone, $globalDBdriver;
@@ -960,11 +960,11 @@  discard block
 block discarded – undo
960 960
 	
961 961
 	
962 962
 	/**
963
-	* Counts all dates during the last 7 days
964
-	*
965
-	* @return Array the date list
966
-	*
967
-	*/
963
+	 * Counts all dates during the last 7 days
964
+	 *
965
+	 * @return Array the date list
966
+	 *
967
+	 */
968 968
 	public function countAllDatesLast7Days($filters = array())
969 969
 	{
970 970
 		global $globalTimezone, $globalDBdriver;
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 			$query .= " GROUP BY date_name 
987 987
 								ORDER BY date_name ASC";
988 988
 			$query_data = array(':offset' => $offset);
989
-    		}
989
+			}
990 990
 		
991 991
 		$sth = $this->db->prepare($query);
992 992
 		$sth->execute($query_data);
@@ -1006,11 +1006,11 @@  discard block
 block discarded – undo
1006 1006
 	}
1007 1007
 
1008 1008
 	/**
1009
-	* Counts all dates during the last month
1010
-	*
1011
-	* @return Array the date list
1012
-	*
1013
-	*/
1009
+	 * Counts all dates during the last month
1010
+	 *
1011
+	 * @return Array the date list
1012
+	 *
1013
+	 */
1014 1014
 	public function countAllDatesLastMonth($filters = array())
1015 1015
 	{
1016 1016
 		global $globalTimezone, $globalDBdriver;
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 			$query .= " GROUP BY date_name 
1033 1033
 								ORDER BY date_name ASC";
1034 1034
 			$query_data = array(':offset' => $offset);
1035
-    		}
1035
+			}
1036 1036
 		
1037 1037
 		$sth = $this->db->prepare($query);
1038 1038
 		$sth->execute($query_data);
@@ -1054,11 +1054,11 @@  discard block
 block discarded – undo
1054 1054
 
1055 1055
 
1056 1056
 	/**
1057
-	* Counts all month
1058
-	*
1059
-	* @return Array the month list
1060
-	*
1061
-	*/
1057
+	 * Counts all month
1058
+	 *
1059
+	 * @return Array the month list
1060
+	 *
1061
+	 */
1062 1062
 	public function countAllMonths($filters = array())
1063 1063
 	{
1064 1064
 		global $globalTimezone, $globalDBdriver;
@@ -1103,11 +1103,11 @@  discard block
 block discarded – undo
1103 1103
 	
1104 1104
 
1105 1105
 	/**
1106
-	* Counts all dates during the last year
1107
-	*
1108
-	* @return Array the date list
1109
-	*
1110
-	*/
1106
+	 * Counts all dates during the last year
1107
+	 *
1108
+	 * @return Array the date list
1109
+	 *
1110
+	 */
1111 1111
 	public function countAllMonthsLastYear($filters)
1112 1112
 	{
1113 1113
 		global $globalTimezone, $globalDBdriver;
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 			$query .= " GROUP BY year_name, month_name
1130 1130
 								ORDER BY year_name, month_name ASC";
1131 1131
 			$query_data = array(':offset' => $offset);
1132
-    		}
1132
+			}
1133 1133
 		
1134 1134
 		$sth = $this->db->prepare($query);
1135 1135
 		$sth->execute($query_data);
@@ -1152,11 +1152,11 @@  discard block
 block discarded – undo
1152 1152
 	
1153 1153
 	
1154 1154
 	/**
1155
-	* Counts all hours
1156
-	*
1157
-	* @return Array the hour list
1158
-	*
1159
-	*/
1155
+	 * Counts all hours
1156
+	 *
1157
+	 * @return Array the hour list
1158
+	 *
1159
+	 */
1160 1160
 	public function countAllHours($orderby,$filters = array())
1161 1161
 	{
1162 1162
 		global $globalTimezone, $globalDBdriver;
@@ -1219,11 +1219,11 @@  discard block
 block discarded – undo
1219 1219
 	
1220 1220
 	
1221 1221
 	/**
1222
-	* Counts all hours by date
1223
-	*
1224
-	* @return Array the hour list
1225
-	*
1226
-	*/
1222
+	 * Counts all hours by date
1223
+	 *
1224
+	 * @return Array the hour list
1225
+	 *
1226
+	 */
1227 1227
 	public function countAllHoursByDate($date, $filters = array())
1228 1228
 	{
1229 1229
 		global $globalTimezone, $globalDBdriver;
@@ -1267,11 +1267,11 @@  discard block
 block discarded – undo
1267 1267
 	
1268 1268
 	
1269 1269
 	/**
1270
-	* Counts all hours by a ident/callsign
1271
-	*
1272
-	* @return Array the hour list
1273
-	*
1274
-	*/
1270
+	 * Counts all hours by a ident/callsign
1271
+	 *
1272
+	 * @return Array the hour list
1273
+	 *
1274
+	 */
1275 1275
 	public function countAllHoursByIdent($ident, $filters = array())
1276 1276
 	{
1277 1277
 		global $globalTimezone, $globalDBdriver;
@@ -1316,11 +1316,11 @@  discard block
 block discarded – undo
1316 1316
 	
1317 1317
 	
1318 1318
 	/**
1319
-	* Counts all flights that have flown over
1320
-	*
1321
-	* @return Integer the number of flights
1322
-	*
1323
-	*/
1319
+	 * Counts all flights that have flown over
1320
+	 *
1321
+	 * @return Integer the number of flights
1322
+	 *
1323
+	 */
1324 1324
 	public function countOverallTracked($filters = array(),$year = '',$month = '')
1325 1325
 	{
1326 1326
 		global $globalDBdriver;
@@ -1355,11 +1355,11 @@  discard block
 block discarded – undo
1355 1355
 	
1356 1356
   
1357 1357
 	/**
1358
-	* Counts all hours of today
1359
-	*
1360
-	* @return Array the hour list
1361
-	*
1362
-	*/
1358
+	 * Counts all hours of today
1359
+	 *
1360
+	 * @return Array the hour list
1361
+	 *
1362
+	 */
1363 1363
 	public function countAllHoursFromToday($filters = array())
1364 1364
 	{
1365 1365
 		global $globalTimezone, $globalDBdriver;
@@ -1399,12 +1399,12 @@  discard block
 block discarded – undo
1399 1399
 	}
1400 1400
     
1401 1401
     
1402
-     /**
1403
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1404
-	*
1405
-	* @return Integer the Barrie Spotter ID
1402
+	 /**
1403
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1404
+	  *
1405
+	  * @return Integer the Barrie Spotter ID
1406 1406
 q	*
1407
-	*/
1407
+	  */
1408 1408
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1409 1409
 	{
1410 1410
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1425,13 +1425,13 @@  discard block
 block discarded – undo
1425 1425
   
1426 1426
  
1427 1427
 	/**
1428
-	* Parses a date string
1429
-	*
1430
-	* @param String $dateString the date string
1431
-	* @param String $timezone the timezone of a user
1432
-	* @return Array the time information
1433
-	*
1434
-	*/
1428
+	 * Parses a date string
1429
+	 *
1430
+	 * @param String $dateString the date string
1431
+	 * @param String $timezone the timezone of a user
1432
+	 * @return Array the time information
1433
+	 *
1434
+	 */
1435 1435
 	public function parseDateString($dateString, $timezone = '')
1436 1436
 	{
1437 1437
 		$time_array = array();
@@ -1464,12 +1464,12 @@  discard block
 block discarded – undo
1464 1464
 	}
1465 1465
 	
1466 1466
 	/**
1467
-	* Parses the direction degrees to working
1468
-	*
1469
-	* @param Float $direction the direction in degrees
1470
-	* @return Array the direction information
1471
-	*
1472
-	*/
1467
+	 * Parses the direction degrees to working
1468
+	 *
1469
+	 * @param Float $direction the direction in degrees
1470
+	 * @return Array the direction information
1471
+	 *
1472
+	 */
1473 1473
 	public function parseDirection($direction = 0)
1474 1474
 	{
1475 1475
 		if ($direction == '') $direction = 0;
@@ -1548,12 +1548,12 @@  discard block
 block discarded – undo
1548 1548
 	
1549 1549
 	
1550 1550
 	/**
1551
-	* Gets Country from latitude/longitude
1552
-	*
1553
-	* @param Float $latitude latitute of the flight
1554
-	* @param Float $longitude longitute of the flight
1555
-	* @return String the countrie
1556
-	*/
1551
+	 * Gets Country from latitude/longitude
1552
+	 *
1553
+	 * @param Float $latitude latitute of the flight
1554
+	 * @param Float $longitude longitute of the flight
1555
+	 * @return String the countrie
1556
+	 */
1557 1557
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1558 1558
 	{
1559 1559
 		global $globalDBdriver, $globalDebug;
@@ -1590,11 +1590,11 @@  discard block
 block discarded – undo
1590 1590
 	}
1591 1591
 
1592 1592
 	/**
1593
-	* Gets Country from iso2
1594
-	*
1595
-	* @param String $iso2 ISO2 country code
1596
-	* @return String the countrie
1597
-	*/
1593
+	 * Gets Country from iso2
1594
+	 *
1595
+	 * @param String $iso2 ISO2 country code
1596
+	 * @return String the countrie
1597
+	 */
1598 1598
 	public function getCountryFromISO2($iso2)
1599 1599
 	{
1600 1600
 		global $globalDBdriver, $globalDebug;
@@ -1623,12 +1623,12 @@  discard block
 block discarded – undo
1623 1623
 
1624 1624
 	
1625 1625
 	/**
1626
-	* Gets the short url from bit.ly
1627
-	*
1628
-	* @param String $url the full url
1629
-	* @return String the bit.ly url
1630
-	*
1631
-	*/
1626
+	 * Gets the short url from bit.ly
1627
+	 *
1628
+	 * @param String $url the full url
1629
+	 * @return String the bit.ly url
1630
+	 *
1631
+	 */
1632 1632
 	public function getBitlyURL($url)
1633 1633
 	{
1634 1634
 		global $globalBitlyAccessToken;
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	/**
15
-	* Gets the images based on the aircraft registration
16
-	*
17
-	* @return Array the images list
18
-	*
19
-	*/
15
+	 * Gets the images based on the aircraft registration
16
+	 *
17
+	 * @return Array the images list
18
+	 *
19
+	 */
20 20
 	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
21 21
 	{
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	/**
40
-	* Gets the images based on the ship name
41
-	*
42
-	* @return Array the images list
43
-	*
44
-	*/
40
+	 * Gets the images based on the ship name
41
+	 *
42
+	 * @return Array the images list
43
+	 *
44
+	 */
45 45
 	public function getMarineImage($mmsi,$imo = '',$name = '')
46 46
 	{
47 47
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 
70 70
 	/**
71
-	* Gets the image copyright based on the Exif data
72
-	*
73
-	* @return String image copyright
74
-	*
75
-	*/
71
+	 * Gets the image copyright based on the Exif data
72
+	 *
73
+	 * @return String image copyright
74
+	 *
75
+	 */
76 76
 	public function getExifCopyright($url) {
77 77
 		$exif = exif_read_data($url);
78 78
 		$copyright = '';
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	}
88 88
 
89 89
 	/**
90
-	* Adds the images based on the aircraft registration
91
-	*
92
-	* @return String either success or error
93
-	*
94
-	*/
90
+	 * Adds the images based on the aircraft registration
91
+	 *
92
+	 * @return String either success or error
93
+	 *
94
+	 */
95 95
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
96 96
 	{
97 97
 		global $globalDebug,$globalAircraftImageFetch;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	}
120 120
 
121 121
 	/**
122
-	* Adds the images based on the marine name
123
-	*
124
-	* @return String either success or error
125
-	*
126
-	*/
122
+	 * Adds the images based on the marine name
123
+	 *
124
+	 * @return String either success or error
125
+	 *
126
+	 */
127 127
 	public function addMarineImage($mmsi,$imo = '',$name = '')
128 128
 	{
129 129
 		global $globalDebug,$globalMarineImageFetch;
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 
162 162
 	/**
163
-	* Gets the aircraft image
164
-	*
165
-	* @param String $aircraft_registration the registration of the aircraft
166
-	* @return Array the aircraft thumbnail, orignal url and copyright
167
-	*
168
-	*/
163
+	 * Gets the aircraft image
164
+	 *
165
+	 * @param String $aircraft_registration the registration of the aircraft
166
+	 * @return Array the aircraft thumbnail, orignal url and copyright
167
+	 *
168
+	 */
169 169
 	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
170 170
 	{
171 171
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO;
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 	}
210 210
 
211 211
 	/**
212
-	* Gets the vessel image
213
-	*
214
-	* @param String $mmsi the vessel mmsi
215
-	* @param String $imo the vessel imo
216
-	* @param String $name the vessel name
217
-	* @return Array the aircraft thumbnail, orignal url and copyright
218
-	*
219
-	*/
212
+	 * Gets the vessel image
213
+	 *
214
+	 * @param String $mmsi the vessel mmsi
215
+	 * @param String $imo the vessel imo
216
+	 * @param String $name the vessel name
217
+	 * @return Array the aircraft thumbnail, orignal url and copyright
218
+	 *
219
+	 */
220 220
 	public function findMarineImage($mmsi,$imo = '',$name = '')
221 221
 	{
222 222
 		global $globalMarineSources;
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 	/**
253
-	* Gets the aircraft image from Planespotters
254
-	*
255
-	* @param String $aircraft_registration the registration of the aircraft
256
-	* @param String $aircraft_name type of the aircraft
257
-	* @return Array the aircraft thumbnail, orignal url and copyright
258
-	*
259
-	*/
253
+	 * Gets the aircraft image from Planespotters
254
+	 *
255
+	 * @param String $aircraft_registration the registration of the aircraft
256
+	 * @param String $aircraft_name type of the aircraft
257
+	 * @return Array the aircraft thumbnail, orignal url and copyright
258
+	 *
259
+	 */
260 260
 	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
261 261
 		$Common = new Common();
262 262
 		// If aircraft registration is only number, also check with aircraft model
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 	/**
286
-	* Gets the aircraft image from Deviantart
287
-	*
288
-	* @param String $registration the registration of the aircraft
289
-	* @param String $name type of the aircraft
290
-	* @return Array the aircraft thumbnail, orignal url and copyright
291
-	*
292
-	*/
286
+	 * Gets the aircraft image from Deviantart
287
+	 *
288
+	 * @param String $registration the registration of the aircraft
289
+	 * @param String $name type of the aircraft
290
+	 * @return Array the aircraft thumbnail, orignal url and copyright
291
+	 *
292
+	 */
293 293
 	public function fromDeviantart($type,$registration, $name='') {
294 294
 		$Common = new Common();
295 295
 		if ($type == 'aircraft') {
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
 	}
322 322
 
323 323
 	/**
324
-	* Gets the aircraft image from JetPhotos
325
-	*
326
-	* @param String $aircraft_registration the registration of the aircraft
327
-	* @param String $aircraft_name type of the aircraft
328
-	* @return Array the aircraft thumbnail, orignal url and copyright
329
-	*
330
-	*/
324
+	 * Gets the aircraft image from JetPhotos
325
+	 *
326
+	 * @param String $aircraft_registration the registration of the aircraft
327
+	 * @param String $aircraft_name type of the aircraft
328
+	 * @return Array the aircraft thumbnail, orignal url and copyright
329
+	 *
330
+	 */
331 331
 	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
332 332
 		$Common = new Common();
333 333
 		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
@@ -363,13 +363,13 @@  discard block
 block discarded – undo
363 363
 	}
364 364
 
365 365
 	/**
366
-	* Gets the aircraft image from PlanePictures
367
-	*
368
-	* @param String $aircraft_registration the registration of the aircraft
369
-	* @param String $aircraft_name type of the aircraft
370
-	* @return Array the aircraft thumbnail, orignal url and copyright
371
-	*
372
-	*/
366
+	 * Gets the aircraft image from PlanePictures
367
+	 *
368
+	 * @param String $aircraft_registration the registration of the aircraft
369
+	 * @param String $aircraft_name type of the aircraft
370
+	 * @return Array the aircraft thumbnail, orignal url and copyright
371
+	 *
372
+	 */
373 373
 	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
374 374
 		$Common = new Common();
375 375
 		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 	}
398 398
 
399 399
 	/**
400
-	* Gets the aircraft image from Flickr
401
-	*
402
-	* @param String $registration the registration of the aircraft
403
-	* @param String $name type of the aircraft
404
-	* @return Array the aircraft thumbnail, orignal url and copyright
405
-	*
406
-	*/
400
+	 * Gets the aircraft image from Flickr
401
+	 *
402
+	 * @param String $registration the registration of the aircraft
403
+	 * @param String $name type of the aircraft
404
+	 * @return Array the aircraft thumbnail, orignal url and copyright
405
+	 *
406
+	 */
407 407
 	public function fromFlickr($type,$registration,$name='') {
408 408
 		$Common = new Common();
409 409
 		if ($type == 'aircraft') {
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
 	}
447 447
 
448 448
 	/**
449
-	* Gets the aircraft image from Bing
450
-	*
451
-	* @param String $aircraft_registration the registration of the aircraft
452
-	* @param String $aircraft_name type of the aircraft
453
-	* @return Array the aircraft thumbnail, orignal url and copyright
454
-	*
455
-	*/
449
+	 * Gets the aircraft image from Bing
450
+	 *
451
+	 * @param String $aircraft_registration the registration of the aircraft
452
+	 * @param String $aircraft_name type of the aircraft
453
+	 * @return Array the aircraft thumbnail, orignal url and copyright
454
+	 *
455
+	 */
456 456
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
457 457
 		global $globalImageBingKey;
458 458
 		$Common = new Common();
@@ -478,13 +478,13 @@  discard block
 block discarded – undo
478 478
 	}
479 479
 
480 480
 	/**
481
-	* Gets the aircraft image from airport-data
482
-	*
483
-	* @param String $aircraft_registration the registration of the aircraft
484
-	* @param String $aircraft_name type of the aircraft
485
-	* @return Array the aircraft thumbnail, orignal url and copyright
486
-	*
487
-	*/
481
+	 * Gets the aircraft image from airport-data
482
+	 *
483
+	 * @param String $aircraft_registration the registration of the aircraft
484
+	 * @param String $aircraft_name type of the aircraft
485
+	 * @return Array the aircraft thumbnail, orignal url and copyright
486
+	 *
487
+	 */
488 488
 	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
489 489
 		$Common = new Common();
490 490
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
 	}
504 504
 
505 505
 	/**
506
-	* Gets image from WikiMedia
507
-	*
508
-	* @param String $registration the registration of the aircraft/mmsi
509
-	* @param String $name name
510
-	* @return Array the aircraft thumbnail, orignal url and copyright
511
-	*
512
-	*/
506
+	 * Gets image from WikiMedia
507
+	 *
508
+	 * @param String $registration the registration of the aircraft/mmsi
509
+	 * @param String $name name
510
+	 * @return Array the aircraft thumbnail, orignal url and copyright
511
+	 *
512
+	 */
513 513
 	public function fromWikimedia($type,$registration,$name='') {
514 514
 		$Common = new Common();
515 515
 		if ($type == 'aircraft') {
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 	}
565 565
 
566 566
 	/**
567
-	* Gets the aircraft image from custom url
568
-	*
569
-	* @param String $aircraft_registration the registration of the aircraft
570
-	* @param String $aircraft_name type of the aircraft
571
-	* @return Array the aircraft thumbnail, orignal url and copyright
572
-	*
573
-	*/
567
+	 * Gets the aircraft image from custom url
568
+	 *
569
+	 * @param String $aircraft_registration the registration of the aircraft
570
+	 * @param String $aircraft_name type of the aircraft
571
+	 * @return Array the aircraft thumbnail, orignal url and copyright
572
+	 *
573
+	 */
574 574
 	public function fromCustomSource($type,$aircraft_registration,$aircraft_name='') {
575 575
 		global $globalAircraftImageCustomSources, $globalDebug;
576 576
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	/**
131
-	* Gets all the spotter information based on the latest data entry
132
-	*
133
-	* @return Array the spotter information
134
-	*
135
-	*/
131
+	 * Gets all the spotter information based on the latest data entry
132
+	 *
133
+	 * @return Array the spotter information
134
+	 *
135
+	 */
136 136
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
137 137
 	{
138 138
 		global $globalDBdriver, $globalLiveInterval;
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	/**
177
-	* Gets Minimal Live Spotter data
178
-	*
179
-	* @return Array the spotter information
180
-	*
181
-	*/
177
+	 * Gets Minimal Live Spotter data
178
+	 *
179
+	 * @return Array the spotter information
180
+	 *
181
+	 */
182 182
 	public function getMinLiveSpotterData($filter = array())
183 183
 	{
184 184
 		global $globalDBdriver, $globalLiveInterval;
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 	}
232 232
 
233 233
 	/**
234
-	* Gets Minimal Live Spotter data since xx seconds
235
-	*
236
-	* @return Array the spotter information
237
-	*
238
-	*/
234
+	 * Gets Minimal Live Spotter data since xx seconds
235
+	 *
236
+	 * @return Array the spotter information
237
+	 *
238
+	 */
239 239
 	public function getMinLastLiveSpotterData($filter = array())
240 240
 	{
241 241
 		global $globalDBdriver, $globalLiveInterval;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
254 254
 			FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
255 255
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
256
-                } else {
256
+				} else {
257 257
 /*
258 258
 			$query  = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
259 259
 			FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 //			echo $query;
266 266
 		}
267 267
 
268
-    		try {
268
+			try {
269 269
 			$sth = $this->db->prepare($query);
270 270
 			$sth->execute();
271 271
 		} catch(PDOException $e) {
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
 	}
278 278
 
279 279
 	/**
280
-	* Gets number of latest data entry
281
-	*
282
-	* @return String number of entry
283
-	*
284
-	*/
280
+	 * Gets number of latest data entry
281
+	 *
282
+	 * @return String number of entry
283
+	 *
284
+	 */
285 285
 	public function getLiveSpotterCount($filter = array())
286 286
 	{
287 287
 		global $globalDBdriver, $globalLiveInterval;
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
 	}
309 309
 
310 310
 	/**
311
-	* Gets all the spotter information based on the latest data entry and coord
312
-	*
313
-	* @return Array the spotter information
314
-	*
315
-	*/
311
+	 * Gets all the spotter information based on the latest data entry and coord
312
+	 *
313
+	 * @return Array the spotter information
314
+	 *
315
+	 */
316 316
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
317 317
 	{
318 318
 		global $globalDBdriver, $globalLiveInterval;
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 	}
338 338
 
339 339
 	/**
340
-	* Gets all the spotter information based on the latest data entry and coord
341
-	*
342
-	* @return Array the spotter information
343
-	*
344
-	*/
340
+	 * Gets all the spotter information based on the latest data entry and coord
341
+	 *
342
+	 * @return Array the spotter information
343
+	 *
344
+	 */
345 345
 	public function getMinLiveSpotterDatabyCoord($coord, $filter = array())
346 346
 	{
347 347
 		global $globalDBdriver, $globalLiveInterval;
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
 	}
390 390
 
391 391
 	/**
392
-	* Gets all the spotter information based on a user's latitude and longitude
393
-	*
394
-	* @return Array the spotter information
395
-	*
396
-	*/
392
+	 * Gets all the spotter information based on a user's latitude and longitude
393
+	 *
394
+	 * @return Array the spotter information
395
+	 *
396
+	 */
397 397
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
398 398
 	{
399 399
 		$Spotter = new Spotter($this->db);
@@ -403,145 +403,145 @@  discard block
 block discarded – undo
403 403
 				return false;
404 404
 			}
405 405
 		}
406
-        if ($lng != '')
407
-                {
408
-                        if (!is_numeric($lng))
409
-                        {
410
-                                return false;
411
-                        }
412
-                }
413
-
414
-                if ($radius != '')
415
-                {
416
-                        if (!is_numeric($radius))
417
-                        {
418
-                                return false;
419
-                        }
420
-                }
406
+		if ($lng != '')
407
+				{
408
+						if (!is_numeric($lng))
409
+						{
410
+								return false;
411
+						}
412
+				}
413
+
414
+				if ($radius != '')
415
+				{
416
+						if (!is_numeric($radius))
417
+						{
418
+								return false;
419
+						}
420
+				}
421 421
 		$additional_query = '';
422
-        if ($interval != '')
423
-                {
424
-                        if (!is_string($interval))
425
-                        {
426
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
427
-			        return false;
428
-                        } else {
429
-                if ($interval == '1m')
430
-                {
431
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
432
-                } else if ($interval == '15m'){
433
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
434
-                } 
435
-            }
436
-                } else {
437
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
438
-        }
439
-
440
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
422
+		if ($interval != '')
423
+				{
424
+						if (!is_string($interval))
425
+						{
426
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
427
+					return false;
428
+						} else {
429
+				if ($interval == '1m')
430
+				{
431
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
432
+				} else if ($interval == '15m'){
433
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
434
+				} 
435
+			}
436
+				} else {
437
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
438
+		}
439
+
440
+				$query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
441 441
                    WHERE spotter_live.latitude <> '' 
442 442
                                    AND spotter_live.longitude <> '' 
443 443
                    ".$additional_query."
444 444
                    HAVING distance < :radius  
445 445
                                    ORDER BY distance";
446 446
 
447
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
447
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
448 448
 
449
-                return $spotter_array;
450
-        }
449
+				return $spotter_array;
450
+		}
451 451
 
452 452
     
453
-        /**
454
-	* Gets all the spotter information based on a particular callsign
455
-	*
456
-	* @return Array the spotter information
457
-	*
458
-	*/
453
+		/**
454
+		 * Gets all the spotter information based on a particular callsign
455
+		 *
456
+		 * @return Array the spotter information
457
+		 *
458
+		 */
459 459
 	public function getLastLiveSpotterDataByIdent($ident)
460 460
 	{
461 461
 		$Spotter = new Spotter($this->db);
462 462
 		date_default_timezone_set('UTC');
463 463
 
464 464
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
465
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
465
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
466 466
 
467 467
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
468 468
 
469 469
 		return $spotter_array;
470 470
 	}
471 471
 
472
-        /**
473
-	* Gets all the spotter information based on a particular callsign
474
-	*
475
-	* @return Array the spotter information
476
-	*
477
-	*/
472
+		/**
473
+		 * Gets all the spotter information based on a particular callsign
474
+		 *
475
+		 * @return Array the spotter information
476
+		 *
477
+		 */
478 478
 	public function getDateLiveSpotterDataByIdent($ident,$date)
479 479
 	{
480 480
 		$Spotter = new Spotter($this->db);
481 481
 		date_default_timezone_set('UTC');
482 482
 
483 483
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
484
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
484
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
485 485
 
486
-                $date = date('c',$date);
486
+				$date = date('c',$date);
487 487
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
488 488
 
489 489
 		return $spotter_array;
490 490
 	}
491 491
 
492
-        /**
493
-	* Gets last spotter information based on a particular callsign
494
-	*
495
-	* @return Array the spotter information
496
-	*
497
-	*/
492
+		/**
493
+		 * Gets last spotter information based on a particular callsign
494
+		 *
495
+		 * @return Array the spotter information
496
+		 *
497
+		 */
498 498
 	public function getLastLiveSpotterDataById($id)
499 499
 	{
500 500
 		$Spotter = new Spotter($this->db);
501 501
 		date_default_timezone_set('UTC');
502 502
 
503 503
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
504
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
504
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
505 505
 
506 506
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
507 507
 
508 508
 		return $spotter_array;
509 509
 	}
510 510
 
511
-        /**
512
-	* Gets last spotter information based on a particular callsign
513
-	*
514
-	* @return Array the spotter information
515
-	*
516
-	*/
511
+		/**
512
+		 * Gets last spotter information based on a particular callsign
513
+		 *
514
+		 * @return Array the spotter information
515
+		 *
516
+		 */
517 517
 	public function getDateLiveSpotterDataById($id,$date)
518 518
 	{
519 519
 		$Spotter = new Spotter($this->db);
520 520
 		date_default_timezone_set('UTC');
521 521
 
522 522
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
523
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
524
-                $date = date('c',$date);
523
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
524
+				$date = date('c',$date);
525 525
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
526 526
 
527 527
 		return $spotter_array;
528 528
 	}
529 529
 
530
-        /**
531
-	* Gets altitude information based on a particular callsign
532
-	*
533
-	* @return Array the spotter information
534
-	*
535
-	*/
530
+		/**
531
+		 * Gets altitude information based on a particular callsign
532
+		 *
533
+		 * @return Array the spotter information
534
+		 *
535
+		 */
536 536
 	public function getAltitudeLiveSpotterDataByIdent($ident)
537 537
 	{
538 538
 
539 539
 		date_default_timezone_set('UTC');
540 540
 
541 541
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
542
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
542
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
543 543
 
544
-    		try {
544
+			try {
545 545
 			
546 546
 			$sth = $this->db->prepare($query);
547 547
 			$sth->execute(array(':ident' => $ident));
@@ -554,12 +554,12 @@  discard block
 block discarded – undo
554 554
 		return $spotter_array;
555 555
 	}
556 556
 
557
-        /**
558
-	* Gets all the spotter information based on a particular id
559
-	*
560
-	* @return Array the spotter information
561
-	*
562
-	*/
557
+		/**
558
+		 * Gets all the spotter information based on a particular id
559
+		 *
560
+		 * @return Array the spotter information
561
+		 *
562
+		 */
563 563
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
564 564
 	{
565 565
 		global $globalDBdriver, $globalLiveInterval;
@@ -587,18 +587,18 @@  discard block
 block discarded – undo
587 587
 		return $spotter_array;
588 588
 	}
589 589
 
590
-        /**
591
-	* Gets all the spotter information based on a particular ident
592
-	*
593
-	* @return Array the spotter information
594
-	*
595
-	*/
590
+		/**
591
+		 * Gets all the spotter information based on a particular ident
592
+		 *
593
+		 * @return Array the spotter information
594
+		 *
595
+		 */
596 596
 	public function getAllLiveSpotterDataByIdent($ident)
597 597
 	{
598 598
 		date_default_timezone_set('UTC');
599 599
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
600 600
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
601
-    		try {
601
+			try {
602 602
 			
603 603
 			$sth = $this->db->prepare($query);
604 604
 			$sth->execute(array(':ident' => $ident));
@@ -612,23 +612,23 @@  discard block
 block discarded – undo
612 612
 
613 613
 
614 614
 	/**
615
-	* Deletes all info in the table
616
-	*
617
-	* @return String success or false
618
-	*
619
-	*/
615
+	 * Deletes all info in the table
616
+	 *
617
+	 * @return String success or false
618
+	 *
619
+	 */
620 620
 	public function deleteLiveSpotterData()
621 621
 	{
622 622
 		global $globalDBdriver;
623 623
 		if ($globalDBdriver == 'mysql') {
624 624
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
625 625
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
626
-            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
626
+					//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
627 627
 		} else {
628 628
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
629 629
 		}
630 630
         
631
-    		try {
631
+			try {
632 632
 			
633 633
 			$sth = $this->db->prepare($query);
634 634
 			$sth->execute();
@@ -640,18 +640,18 @@  discard block
 block discarded – undo
640 640
 	}
641 641
 
642 642
 	/**
643
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
644
-	*
645
-	* @return String success or false
646
-	*
647
-	*/
643
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
644
+	 *
645
+	 * @return String success or false
646
+	 *
647
+	 */
648 648
 	public function deleteLiveSpotterDataNotUpdated()
649 649
 	{
650 650
 		global $globalDBdriver, $globalDebug;
651 651
 		if ($globalDBdriver == 'mysql') {
652 652
 			//$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0';
653
-    			$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
654
-    			try {
653
+				$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
654
+				try {
655 655
 				
656 656
 				$sth = $this->db->prepare($query);
657 657
 				$sth->execute();
@@ -659,8 +659,8 @@  discard block
 block discarded – undo
659 659
 				return "error";
660 660
 			}
661 661
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
662
-                        $i = 0;
663
-                        $j =0;
662
+						$i = 0;
663
+						$j =0;
664 664
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
665 665
 			foreach($all as $row)
666 666
 			{
@@ -668,20 +668,20 @@  discard block
 block discarded – undo
668 668
 				$j++;
669 669
 				if ($j == 30) {
670 670
 					if ($globalDebug) echo ".";
671
-				    	try {
671
+						try {
672 672
 						
673 673
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
674 674
 						$sth->execute();
675 675
 					} catch(PDOException $e) {
676 676
 						return "error";
677 677
 					}
678
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
679
-                                	$j = 0;
678
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
679
+									$j = 0;
680 680
 				}
681 681
 				$query_delete .= "'".$row['flightaware_id']."',";
682 682
 			}
683 683
 			if ($i > 0) {
684
-    				try {
684
+					try {
685 685
 					
686 686
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
687 687
 					$sth->execute();
@@ -692,9 +692,9 @@  discard block
 block discarded – undo
692 692
 			return "success";
693 693
 		} elseif ($globalDBdriver == 'pgsql') {
694 694
 			//$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0";
695
-    			//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
696
-    			$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
697
-    			try {
695
+				//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
696
+				$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
697
+				try {
698 698
 				
699 699
 				$sth = $this->db->prepare($query);
700 700
 				$sth->execute();
@@ -738,17 +738,17 @@  discard block
 block discarded – undo
738 738
 	}
739 739
 
740 740
 	/**
741
-	* Deletes all info in the table for an ident
742
-	*
743
-	* @return String success or false
744
-	*
745
-	*/
741
+	 * Deletes all info in the table for an ident
742
+	 *
743
+	 * @return String success or false
744
+	 *
745
+	 */
746 746
 	public function deleteLiveSpotterDataByIdent($ident)
747 747
 	{
748 748
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
749 749
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
750 750
         
751
-    		try {
751
+			try {
752 752
 			
753 753
 			$sth = $this->db->prepare($query);
754 754
 			$sth->execute(array(':ident' => $ident));
@@ -760,17 +760,17 @@  discard block
 block discarded – undo
760 760
 	}
761 761
 
762 762
 	/**
763
-	* Deletes all info in the table for an id
764
-	*
765
-	* @return String success or false
766
-	*
767
-	*/
763
+	 * Deletes all info in the table for an id
764
+	 *
765
+	 * @return String success or false
766
+	 *
767
+	 */
768 768
 	public function deleteLiveSpotterDataById($id)
769 769
 	{
770 770
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
771 771
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
772 772
         
773
-    		try {
773
+			try {
774 774
 			
775 775
 			$sth = $this->db->prepare($query);
776 776
 			$sth->execute(array(':id' => $id));
@@ -783,11 +783,11 @@  discard block
 block discarded – undo
783 783
 
784 784
 
785 785
 	/**
786
-	* Gets the aircraft ident within the last hour
787
-	*
788
-	* @return String the ident
789
-	*
790
-	*/
786
+	 * Gets the aircraft ident within the last hour
787
+	 *
788
+	 * @return String the ident
789
+	 *
790
+	 */
791 791
 	public function getIdentFromLastHour($ident)
792 792
 	{
793 793
 		global $globalDBdriver, $globalTimezone;
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 			$ident_result = $row['ident'];
814 814
 		}
815 815
 		return $ident_result;
816
-        }
816
+		}
817 817
 
818 818
 	/**
819
-	* Check recent aircraft
820
-	*
821
-	* @return String the ident
822
-	*
823
-	*/
819
+	 * Check recent aircraft
820
+	 *
821
+	 * @return String the ident
822
+	 *
823
+	 */
824 824
 	public function checkIdentRecent($ident)
825 825
 	{
826 826
 		global $globalDBdriver, $globalTimezone;
@@ -846,14 +846,14 @@  discard block
 block discarded – undo
846 846
 			$ident_result = $row['flightaware_id'];
847 847
 		}
848 848
 		return $ident_result;
849
-        }
849
+		}
850 850
 
851 851
 	/**
852
-	* Check recent aircraft by id
853
-	*
854
-	* @return String the ident
855
-	*
856
-	*/
852
+	 * Check recent aircraft by id
853
+	 *
854
+	 * @return String the ident
855
+	 *
856
+	 */
857 857
 	public function checkIdRecent($id)
858 858
 	{
859 859
 		global $globalDBdriver, $globalTimezone;
@@ -879,14 +879,14 @@  discard block
 block discarded – undo
879 879
 			$ident_result = $row['flightaware_id'];
880 880
 		}
881 881
 		return $ident_result;
882
-        }
882
+		}
883 883
 
884 884
 	/**
885
-	* Check recent aircraft by ModeS
886
-	*
887
-	* @return String the ModeS
888
-	*
889
-	*/
885
+	 * Check recent aircraft by ModeS
886
+	 *
887
+	 * @return String the ModeS
888
+	 *
889
+	 */
890 890
 	public function checkModeSRecent($modes)
891 891
 	{
892 892
 		global $globalDBdriver, $globalTimezone;
@@ -913,19 +913,19 @@  discard block
 block discarded – undo
913 913
 			$ident_result = $row['flightaware_id'];
914 914
 		}
915 915
 		return $ident_result;
916
-        }
916
+		}
917 917
 
918 918
 	/**
919
-	* Adds a new spotter data
920
-	*
921
-	* @param String $flightaware_id the ID from flightaware
922
-	* @param String $ident the flight ident
923
-	* @param String $aircraft_icao the aircraft type
924
-	* @param String $departure_airport_icao the departure airport
925
-	* @param String $arrival_airport_icao the arrival airport
926
-	* @return String success or false
927
-	*
928
-	*/
919
+	 * Adds a new spotter data
920
+	 *
921
+	 * @param String $flightaware_id the ID from flightaware
922
+	 * @param String $ident the flight ident
923
+	 * @param String $aircraft_icao the aircraft type
924
+	 * @param String $departure_airport_icao the departure airport
925
+	 * @param String $arrival_airport_icao the arrival airport
926
+	 * @return String success or false
927
+	 *
928
+	 */
929 929
 	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
930 930
 	{
931 931
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1060,10 +1060,10 @@  discard block
 block discarded – undo
1060 1060
 		$arrival_airport_country = '';
1061 1061
 		
1062 1062
             	
1063
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1064
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1065
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1066
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1063
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1064
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1065
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1066
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1067 1067
 		
1068 1068
 		$query = '';
1069 1069
 		if ($globalArchive) {
@@ -1083,10 +1083,10 @@  discard block
 block discarded – undo
1083 1083
 			return "error : ".$e->getMessage();
1084 1084
 		}
1085 1085
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1086
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1087
-		    $SpotterArchive = new SpotterArchive($this->db);
1088
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1089
-		    if ($globalDebug) echo $result.')';
1086
+			if ($globalDebug) echo '(Add to SBS archive : ';
1087
+			$SpotterArchive = new SpotterArchive($this->db);
1088
+			$result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1089
+			if ($globalDebug) echo $result.')';
1090 1090
 		}
1091 1091
 		return "success";
1092 1092
 
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 = 38;
8 8
 	
9 9
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10
-	    global $globalDBdriver, $globalNoDB;
11
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
10
+		global $globalDBdriver, $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
 	{
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			return false;
158 158
 		}
159 159
 		if($results->rowCount()>0) {
160
-		    return true; 
160
+			return true; 
161 161
 		}
162 162
 		else return false;
163 163
 	}
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 				$sum = $sum->fetchColumn(0);
175 175
 			} else $sum = 0;
176 176
 			if (intval($sum) !== 2) {
177
-			     return false;
177
+				 return false;
178 178
 			}
179 179
 			
180 180
 		} catch(PDOException $e) {
181 181
 			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182
-            			throw $e;
183
-	                }
184
-	                //echo 'error ! '.$e->getMessage();
182
+						throw $e;
183
+					}
184
+					//echo 'error ! '.$e->getMessage();
185 185
 			return false;
186 186
 		}
187 187
 		return true; 
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 		$version = 0;
286 286
 		if ($this->tableExists('aircraft')) {
287 287
 			if (!$this->tableExists('config')) {
288
-	    			$version = '1';
289
-	    			return $version;
288
+					$version = '1';
289
+					return $version;
290 290
 			} else {
291 291
 				$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
292 292
 				try {
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	* @return Boolean if latest version or not
308 308
 	*/
309 309
 	public function latest() {
310
-	    global $globalNoDB;
311
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
312
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
313
-	    else return false;
310
+		global $globalNoDB;
311
+		if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
312
+		if ($this->check_schema_version() == $this->latest_schema) return true;
313
+		else return false;
314 314
 	}
315 315
 
316 316
 }
Please login to merge, or discard this patch.