Completed
Push — master ( 84e658...75d861 )
by Yannick
09:05
created
flightid-overview.php 2 patches
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_STRING);
2
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_STRING);
3 3
 if ($id == "")
4 4
 {
5 5
 	header('Location: /');
@@ -16,30 +16,30 @@  discard block
 block discarded – undo
16 16
 
17 17
 if (!empty($spotter_array))
18 18
 {
19
-	if(isset($spotter_array[0]['flightaware_id'])) {
19
+	if (isset($spotter_array[0]['flightaware_id'])) {
20 20
 		$flightaware_id = $spotter_array[0]['flightaware_id'];
21 21
 	}
22
-	if(isset($spotter_array[0]['last_latitude']) && $spotter_array[0]['last_latitude'] != '') {
22
+	if (isset($spotter_array[0]['last_latitude']) && $spotter_array[0]['last_latitude'] != '') {
23 23
 		$latitude = $spotter_array[0]['last_latitude'];
24
-	} elseif(isset($spotter_array[0]['latitude'])) {
24
+	} elseif (isset($spotter_array[0]['latitude'])) {
25 25
 		$latitude = $spotter_array[0]['latitude'];
26 26
 	}
27
-	if(isset($spotter_array[0]['last_longitude']) && $spotter_array[0]['last_longitude'] != '') {
27
+	if (isset($spotter_array[0]['last_longitude']) && $spotter_array[0]['last_longitude'] != '') {
28 28
 		$longitude = $spotter_array[0]['last_longitude'];
29
-	} elseif(isset($spotter_array[0]['longitude'])) {
29
+	} elseif (isset($spotter_array[0]['longitude'])) {
30 30
 		$longitude = $spotter_array[0]['longitude'];
31 31
 	}
32 32
 	$title = '';
33
-	if(isset($spotter_array[0]['ident'])) {
33
+	if (isset($spotter_array[0]['ident'])) {
34 34
 		$title .= $spotter_array[0]['ident'];
35 35
 	}
36
-	if(isset($spotter_array[0]['airline_name'])) {
36
+	if (isset($spotter_array[0]['airline_name'])) {
37 37
 		$title .= ' - '.$spotter_array[0]['airline_name'];
38 38
 	}
39
-	if(isset($spotter_array[0]['aircraft_name']) && $spotter_array[0]['aircraft_name'] != 'Not Available') {
39
+	if (isset($spotter_array[0]['aircraft_name']) && $spotter_array[0]['aircraft_name'] != 'Not Available') {
40 40
 		$title .= ' - '.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')';
41 41
 	}
42
-	if(isset($spotter_array[0]['registration']) && $spotter_array[0]['registration'] != 'NA' && $spotter_array[0]['registration'] != 'N/A') {
42
+	if (isset($spotter_array[0]['registration']) && $spotter_array[0]['registration'] != 'NA' && $spotter_array[0]['registration'] != 'N/A') {
43 43
 		$title .= ' - '.$spotter_array[0]['registration'];
44 44
 	}
45 45
 	//$facebook_meta_image = $spotter_array[0]['image'];
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 			$altitude_data = '';
60 60
 			$hour_data = '';
61 61
 			$speed_data = '';
62
-			foreach($all_data as $data)
62
+			foreach ($all_data as $data)
63 63
 			{
64 64
 				$hour_data .= '"'.$data['date'].'",';
65 65
 				if (isset($data['real_altitude']) && $data['real_altitude'] != '') {
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 				$speed_data .= $speed.',';
88 88
 			}
89 89
 			$hour_data = "['x',".substr($hour_data, 0, -1)."]";
90
-			$altitude_data = "['altitude',".substr($altitude_data,0,-1)."]";
91
-			$speed_data = "['speed',".substr($speed_data,0,-1)."]";
90
+			$altitude_data = "['altitude',".substr($altitude_data, 0, -1)."]";
91
+			$speed_data = "['speed',".substr($speed_data, 0, -1)."]";
92 92
 			print 'c3.generate({
93 93
 			    bindto: "#chart",
94 94
 			    data: {
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
 			print '<a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a> ';
135 135
 		}
136 136
 	}
137
-	if(isset($spotter_array[0]['ident'])) {
137
+	if (isset($spotter_array[0]['ident'])) {
138 138
 		print $spotter_array[0]['ident'];
139 139
 	}
140
-	if(isset($spotter_array[0]['airline_name'])) {
140
+	if (isset($spotter_array[0]['airline_name'])) {
141 141
 		print ' - '.$spotter_array[0]['airline_name'];
142 142
 	}
143
-	if(isset($spotter_array[0]['aircraft_name']) && $spotter_array[0]['aircraft_name'] != 'Not Available') {
143
+	if (isset($spotter_array[0]['aircraft_name']) && $spotter_array[0]['aircraft_name'] != 'Not Available') {
144 144
 		print ' - '.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')';
145 145
 	}
146
-	if(isset($spotter_array[0]['registration']) && $spotter_array[0]['registration'] != 'NA') {
146
+	if (isset($spotter_array[0]['registration']) && $spotter_array[0]['registration'] != 'NA') {
147 147
 		print ' - '.$spotter_array[0]['registration'];
148 148
 	}
149 149
 	print '</h1>';
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 print '</div>';
298 298
 */
299 299
 
300
-	foreach($spotter_array as $spotter_item)
300
+	foreach ($spotter_array as $spotter_item)
301 301
 	{
302 302
 		print '<div class="details">';
303 303
 		print '<h3>'._("Flight Information").'</h3>';
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 			if (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != '') {
398 398
 				if ($spotter_item['departure_airport_time'] > 2460) {
399 399
 					print '<div class="time">';
400
-					print 'at '.date('H:m',$spotter_item['departure_airport_time']);
400
+					print 'at '.date('H:m', $spotter_item['departure_airport_time']);
401 401
 					print '</div>';
402 402
 				} else {
403 403
 					print '<div class="time">';
@@ -546,19 +546,19 @@  discard block
 block discarded – undo
546 546
 			$departure_airport_info = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
547 547
 			if (isset($spotter_item['last_latitude']) && $spotter_item['last_latitude'] != '') {
548 548
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
549
-					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'nm').' nm';
549
+					print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'nm').' nm';
550 550
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
551
-					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'mi').' mi';
551
+					print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'mi').' mi';
552 552
 				} else {
553
-					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'km').' km';
553
+					print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'km').' km';
554 554
 				}
555 555
 			} else {
556 556
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
557
-					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'nm').' nm';
557
+					print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'nm').' nm';
558 558
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
559
-					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'mi').' mi';
559
+					print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'mi').' mi';
560 560
 				} else {
561
-					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'km').' km';
561
+					print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $departure_airport_info[0]['latitude'], $departure_airport_info[0]['longitude'], 'km').' km';
562 562
 				}
563 563
 			}
564 564
 			print '</div>';
@@ -572,19 +572,19 @@  discard block
 block discarded – undo
572 572
 			$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
573 573
 			if (isset($spotter_item['last_latitude']) && $spotter_item['last_latitude'] != '') {
574 574
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
575
-					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'nm').' nm';
575
+					print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'nm').' nm';
576 576
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
577
-					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'mi').' mi';
577
+					print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'mi').' mi';
578 578
 				} else {
579
-					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'km').' km';
579
+					print $Common->distance($spotter_item['last_latitude'], $spotter_item['last_longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'km').' km';
580 580
 				}
581 581
 			} else {
582 582
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
583
-					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'nm').' nm';
583
+					print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'nm').' nm';
584 584
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
585
-					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'mi').' mi';
585
+					print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'mi').' mi';
586 586
 				} else {
587
-					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'km').' km';
587
+					print $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $arrival_airport_info[0]['latitude'], $arrival_airport_info[0]['longitude'], 'km').' km';
588 588
 				}
589 589
 			}
590 590
 			print '</div>';
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 		print '<div class="last-flights">';
604 604
 		print '<h3>'._("Last 5 Flights of this Aircraft").' ('.$spotter_array[0]['registration'].')</h3>';
605 605
 		$hide_th_links = true;
606
-		$spotter_array = $Spotter->getSpotterDataByRegistration($spotter_array[0]['registration'],"0,5", "");
606
+		$spotter_array = $Spotter->getSpotterDataByRegistration($spotter_array[0]['registration'], "0,5", "");
607 607
 		include('table-output.php'); 
608 608
 		print '<div class="more">';
609 609
 		print '<a href="'.$globalURL.'/registration/'.$spotter_array[0]['registration'].'" class="btn btn-default btn" role="button">See all Flights&raquo;</a>';
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -48,7 +48,9 @@  discard block
 block discarded – undo
48 48
 		$all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']);
49 49
 		if (isset($globalTimezone)) {
50 50
 			date_default_timezone_set($globalTimezone);
51
-		} else date_default_timezone_set('UTC');
51
+		} else {
52
+			date_default_timezone_set('UTC');
53
+		}
52 54
 		
53 55
 		if (is_array($all_data) && count($all_data) > 1) {
54 56
 			print '<br/>';
@@ -327,9 +329,13 @@  discard block
 block discarded – undo
327 329
 			print '<div>';
328 330
 			if (isset($spotter_item['pilot_id']) && $spotter_item['pilot_id'] != "")
329 331
 			{
330
-				if ($spotter_item['format_source'] == 'whazzup') print '<a href="https://www.ivao.aero/Member.aspx?ID='.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>';
331
-				elseif ($spotter_item['format_source'] == 'vatsimtxt') print '<a href="http://www.vataware.com/pilot/'.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>';
332
-				else print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
332
+				if ($spotter_item['format_source'] == 'whazzup') {
333
+					print '<a href="https://www.ivao.aero/Member.aspx?ID='.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>';
334
+				} elseif ($spotter_item['format_source'] == 'vatsimtxt') {
335
+					print '<a href="http://www.vataware.com/pilot/'.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>';
336
+				} else {
337
+					print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
338
+				}
333 339
 			} else {
334 340
 				if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != "")
335 341
 				{
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 2 patches
Indentation   +651 added lines, -651 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 = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
@@ -152,44 +152,44 @@  discard block
 block discarded – undo
152 152
 	}
153 153
 
154 154
 
155
-        /**
156
-        * Gets all the spotter information based on a particular callsign
157
-        *
158
-        * @return Array the spotter information
159
-        *
160
-        */
161
-        public function getLastArchiveSpotterDataByIdent($ident)
162
-        {
155
+		/**
156
+		 * Gets all the spotter information based on a particular callsign
157
+		 *
158
+		 * @return Array the spotter information
159
+		 *
160
+		 */
161
+		public function getLastArchiveSpotterDataByIdent($ident)
162
+		{
163 163
 		$Spotter = new Spotter($this->db);
164
-                date_default_timezone_set('UTC');
164
+				date_default_timezone_set('UTC');
165 165
 
166
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
167
-                //$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";
168
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
166
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
167
+				//$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";
168
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
169 169
 
170
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
170
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
171 171
 
172
-                return $spotter_array;
173
-        }
172
+				return $spotter_array;
173
+		}
174 174
 
175 175
 
176
-        /**
177
-        * Gets last the spotter information based on a particular id
178
-        *
179
-        * @return Array the spotter information
180
-        *
181
-        */
182
-        public function getLastArchiveSpotterDataById($id)
183
-        {
184
-    		$Spotter = new Spotter($this->db);
185
-                date_default_timezone_set('UTC');
186
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
187
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
188
-                //$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";
189
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
176
+		/**
177
+		 * Gets last the spotter information based on a particular id
178
+		 *
179
+		 * @return Array the spotter information
180
+		 *
181
+		 */
182
+		public function getLastArchiveSpotterDataById($id)
183
+		{
184
+			$Spotter = new Spotter($this->db);
185
+				date_default_timezone_set('UTC');
186
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
187
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
188
+				//$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";
189
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
190 190
 
191 191
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
192
-                  /*
192
+				  /*
193 193
                 try {
194 194
                         $Connection = new Connection();
195 195
                         $sth = Connection->$db->prepare($query);
@@ -199,235 +199,235 @@  discard block
 block discarded – undo
199 199
                 }
200 200
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
201 201
                 */
202
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
203
-
204
-                return $spotter_array;
205
-        }
206
-
207
-        /**
208
-        * Gets all the spotter information based on a particular id
209
-        *
210
-        * @return Array the spotter information
211
-        *
212
-        */
213
-        public function getAllArchiveSpotterDataById($id)
202
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
203
+
204
+				return $spotter_array;
205
+		}
206
+
207
+		/**
208
+		 * Gets all the spotter information based on a particular id
209
+		 *
210
+		 * @return Array the spotter information
211
+		 *
212
+		 */
213
+		public function getAllArchiveSpotterDataById($id)
214 214
 	{
215
-                date_default_timezone_set('UTC');
216
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
217
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
215
+				date_default_timezone_set('UTC');
216
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
217
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
218 218
 
219 219
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
220 220
 
221
-                try {
222
-                        $sth = $this->db->prepare($query);
223
-                        $sth->execute(array(':id' => $id));
224
-                } catch(PDOException $e) {
225
-                        echo $e->getMessage();
226
-                        die;
227
-                }
228
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
229
-
230
-                return $spotter_array;
231
-        }
232
-
233
-        /**
234
-        * Gets coordinate & time spotter information based on a particular id
235
-        *
236
-        * @return Array the spotter information
237
-        *
238
-        */
239
-        public function getCoordArchiveSpotterDataById($id)
240
-        {
241
-                date_default_timezone_set('UTC');
242
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
243
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
221
+				try {
222
+						$sth = $this->db->prepare($query);
223
+						$sth->execute(array(':id' => $id));
224
+				} catch(PDOException $e) {
225
+						echo $e->getMessage();
226
+						die;
227
+				}
228
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
229
+
230
+				return $spotter_array;
231
+		}
232
+
233
+		/**
234
+		 * Gets coordinate & time spotter information based on a particular id
235
+		 *
236
+		 * @return Array the spotter information
237
+		 *
238
+		 */
239
+		public function getCoordArchiveSpotterDataById($id)
240
+		{
241
+				date_default_timezone_set('UTC');
242
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
243
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
244 244
 
245 245
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
246 246
 
247
-                try {
248
-                        $sth = $this->db->prepare($query);
249
-                        $sth->execute(array(':id' => $id));
250
-                } catch(PDOException $e) {
251
-                        echo $e->getMessage();
252
-                        die;
253
-                }
254
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
247
+				try {
248
+						$sth = $this->db->prepare($query);
249
+						$sth->execute(array(':id' => $id));
250
+				} catch(PDOException $e) {
251
+						echo $e->getMessage();
252
+						die;
253
+				}
254
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
255 255
 
256
-                return $spotter_array;
257
-        }
256
+				return $spotter_array;
257
+		}
258 258
 
259 259
 
260
-        /**
261
-        * Gets altitude information based on a particular callsign
262
-        *
263
-        * @return Array the spotter information
264
-        *
265
-        */
266
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
267
-        {
260
+		/**
261
+		 * Gets altitude information based on a particular callsign
262
+		 *
263
+		 * @return Array the spotter information
264
+		 *
265
+		 */
266
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
267
+		{
268 268
 
269
-                date_default_timezone_set('UTC');
269
+				date_default_timezone_set('UTC');
270 270
 
271
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
272
-                $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";
271
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
272
+				$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";
273 273
 
274
-                try {
275
-                        $sth = $this->db->prepare($query);
276
-                        $sth->execute(array(':ident' => $ident));
277
-                } catch(PDOException $e) {
278
-                        echo $e->getMessage();
279
-                        die;
280
-                }
281
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
274
+				try {
275
+						$sth = $this->db->prepare($query);
276
+						$sth->execute(array(':ident' => $ident));
277
+				} catch(PDOException $e) {
278
+						echo $e->getMessage();
279
+						die;
280
+				}
281
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
282 282
 
283
-                return $spotter_array;
284
-        }
283
+				return $spotter_array;
284
+		}
285 285
 
286
-        /**
287
-        * Gets altitude information based on a particular id
288
-        *
289
-        * @return Array the spotter information
290
-        *
291
-        */
292
-        public function getAltitudeArchiveSpotterDataById($id)
293
-        {
286
+		/**
287
+		 * Gets altitude information based on a particular id
288
+		 *
289
+		 * @return Array the spotter information
290
+		 *
291
+		 */
292
+		public function getAltitudeArchiveSpotterDataById($id)
293
+		{
294 294
 
295
-                date_default_timezone_set('UTC');
295
+				date_default_timezone_set('UTC');
296 296
 
297
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
298
-                $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";
297
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
298
+				$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";
299 299
 
300
-                try {
301
-                        $sth = $this->db->prepare($query);
302
-                        $sth->execute(array(':id' => $id));
303
-                } catch(PDOException $e) {
304
-                        echo $e->getMessage();
305
-                        die;
306
-                }
307
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
300
+				try {
301
+						$sth = $this->db->prepare($query);
302
+						$sth->execute(array(':id' => $id));
303
+				} catch(PDOException $e) {
304
+						echo $e->getMessage();
305
+						die;
306
+				}
307
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
308 308
 
309
-                return $spotter_array;
310
-        }
309
+				return $spotter_array;
310
+		}
311 311
 
312
-        /**
313
-        * Gets altitude & speed information based on a particular id
314
-        *
315
-        * @return Array the spotter information
316
-        *
317
-        */
318
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
319
-        {
312
+		/**
313
+		 * Gets altitude & speed information based on a particular id
314
+		 *
315
+		 * @return Array the spotter information
316
+		 *
317
+		 */
318
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
319
+		{
320 320
 
321
-                date_default_timezone_set('UTC');
321
+				date_default_timezone_set('UTC');
322 322
 
323
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
324
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
323
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
324
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
325 325
 
326
-                try {
327
-                        $sth = $this->db->prepare($query);
328
-                        $sth->execute(array(':id' => $id));
329
-                } catch(PDOException $e) {
330
-                        echo $e->getMessage();
331
-                        die;
332
-                }
333
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
326
+				try {
327
+						$sth = $this->db->prepare($query);
328
+						$sth->execute(array(':id' => $id));
329
+				} catch(PDOException $e) {
330
+						echo $e->getMessage();
331
+						die;
332
+				}
333
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
334 334
 
335
-                return $spotter_array;
336
-        }
335
+				return $spotter_array;
336
+		}
337 337
 
338 338
 
339
-        /**
340
-        * Gets altitude information based on a particular callsign
341
-        *
342
-        * @return Array the spotter information
343
-        *
344
-        */
345
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
346
-        {
339
+		/**
340
+		 * Gets altitude information based on a particular callsign
341
+		 *
342
+		 * @return Array the spotter information
343
+		 *
344
+		 */
345
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
346
+		{
347 347
 
348
-                date_default_timezone_set('UTC');
348
+				date_default_timezone_set('UTC');
349 349
 
350
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
351
-                $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";
350
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
351
+				$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";
352 352
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
353 353
 
354
-                try {
355
-                        $sth = $this->db->prepare($query);
356
-                        $sth->execute(array(':ident' => $ident));
357
-                } catch(PDOException $e) {
358
-                        echo $e->getMessage();
359
-                        die;
360
-                }
361
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
354
+				try {
355
+						$sth = $this->db->prepare($query);
356
+						$sth->execute(array(':ident' => $ident));
357
+				} catch(PDOException $e) {
358
+						echo $e->getMessage();
359
+						die;
360
+				}
361
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
362 362
 
363
-                return $spotter_array;
364
-        }
363
+				return $spotter_array;
364
+		}
365 365
 
366 366
 
367 367
 
368
-       /**
369
-        * Gets all the archive spotter information
370
-        *
371
-        * @return Array the spotter information
372
-        *
373
-        */
374
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
375
-        {
376
-    		$Spotter = new Spotter($this->db);
377
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
378
-                $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";
368
+	   /**
369
+	    * Gets all the archive spotter information
370
+	    *
371
+	    * @return Array the spotter information
372
+	    *
373
+	    */
374
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
375
+		{
376
+			$Spotter = new Spotter($this->db);
377
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
378
+				$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";
379 379
 
380
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
380
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
381 381
 
382
-                return $spotter_array;
383
-        }
382
+				return $spotter_array;
383
+		}
384 384
         
385
-        public function deleteSpotterArchiveTrackData()
386
-        {
385
+		public function deleteSpotterArchiveTrackData()
386
+		{
387 387
 		global $globalArchiveKeepTrackMonths, $globalDBdriver;
388 388
 		if ($globalDBdriver == 'mysql') {
389 389
 			$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
390 390
 		} else {
391 391
 			$query = "DELETE FROM spotter_archive WHERE spotter_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH'";
392 392
 		}
393
-                try {
394
-                        $sth = $this->db->prepare($query);
395
-                        $sth->execute();
396
-                } catch(PDOException $e) {
397
-                        echo $e->getMessage();
398
-                        die;
399
-                }
393
+				try {
394
+						$sth = $this->db->prepare($query);
395
+						$sth->execute();
396
+				} catch(PDOException $e) {
397
+						echo $e->getMessage();
398
+						die;
399
+				}
400 400
 	}
401 401
 
402 402
 	/**
403
-        * Gets Minimal Live Spotter data
404
-        *
405
-        * @return Array the spotter information
406
-        *
407
-        */
408
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
409
-        {
410
-                global $globalDBdriver, $globalLiveInterval;
411
-                date_default_timezone_set('UTC');
412
-
413
-                $filter_query = '';
414
-                if (isset($filter['source']) && !empty($filter['source'])) {
415
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
416
-                }
417
-                // Use spotter_output also ?
418
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
419
-                        $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 ";
420
-                }
421
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
422
-                        $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 ";
423
-                }
424
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
425
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
426
-                }
427
-
428
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
429
-                if ($globalDBdriver == 'mysql') {
430
-                        /*
403
+	 * Gets Minimal Live Spotter data
404
+	 *
405
+	 * @return Array the spotter information
406
+	 *
407
+	 */
408
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
409
+		{
410
+				global $globalDBdriver, $globalLiveInterval;
411
+				date_default_timezone_set('UTC');
412
+
413
+				$filter_query = '';
414
+				if (isset($filter['source']) && !empty($filter['source'])) {
415
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
416
+				}
417
+				// Use spotter_output also ?
418
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
419
+						$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 ";
420
+				}
421
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
422
+						$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 ";
423
+				}
424
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
425
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
426
+				}
427
+
428
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
429
+				if ($globalDBdriver == 'mysql') {
430
+						/*
431 431
                         $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 
432 432
                     		    FROM spotter_archive 
433 433
                     		    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';
@@ -446,56 +446,56 @@  discard block
 block discarded – undo
446 446
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
447 447
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
448 448
                         	    '.$filter_query.' ORDER BY flightaware_id';
449
-                } else {
450
-                        //$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';
451
-                        $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 
449
+				} else {
450
+						//$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';
451
+						$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 
452 452
                         	    FROM spotter_archive 
453 453
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
454 454
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
455 455
                         	    '.$filter_query.' ORDER BY flightaware_id';
456
-                }
457
-                //echo $query;
458
-                try {
459
-                        $sth = $this->db->prepare($query);
460
-                        $sth->execute();
461
-                } catch(PDOException $e) {
462
-                        echo $e->getMessage();
463
-                        die;
464
-                }
465
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
466
-
467
-                return $spotter_array;
468
-        }
456
+				}
457
+				//echo $query;
458
+				try {
459
+						$sth = $this->db->prepare($query);
460
+						$sth->execute();
461
+				} catch(PDOException $e) {
462
+						echo $e->getMessage();
463
+						die;
464
+				}
465
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
466
+
467
+				return $spotter_array;
468
+		}
469 469
 
470 470
 	/**
471
-        * Gets Minimal Live Spotter data
472
-        *
473
-        * @return Array the spotter information
474
-        *
475
-        */
476
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
477
-        {
478
-                global $globalDBdriver, $globalLiveInterval;
479
-                date_default_timezone_set('UTC');
480
-
481
-                $filter_query = '';
482
-                if (isset($filter['source']) && !empty($filter['source'])) {
483
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
484
-                }
485
-                // Should use spotter_output also ?
486
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
487
-                        $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 ";
488
-                }
489
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
490
-                        $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 ";
491
-                }
492
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
493
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
494
-                }
495
-
496
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
497
-                if ($globalDBdriver == 'mysql') {
498
-                        /*
471
+	 * Gets Minimal Live Spotter data
472
+	 *
473
+	 * @return Array the spotter information
474
+	 *
475
+	 */
476
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
477
+		{
478
+				global $globalDBdriver, $globalLiveInterval;
479
+				date_default_timezone_set('UTC');
480
+
481
+				$filter_query = '';
482
+				if (isset($filter['source']) && !empty($filter['source'])) {
483
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
484
+				}
485
+				// Should use spotter_output also ?
486
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
487
+						$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 ";
488
+				}
489
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
490
+						$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 ";
491
+				}
492
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
493
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
494
+				}
495
+
496
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
497
+				if ($globalDBdriver == 'mysql') {
498
+						/*
499 499
                         $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 
500 500
                     		    FROM spotter_archive 
501 501
                     		    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';
@@ -506,95 +506,95 @@  discard block
 block discarded – undo
506 506
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
507 507
                         	    '.$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';
508 508
 
509
-                } else {
510
-                        //$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';
511
-                       /*
509
+				} else {
510
+						//$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';
511
+					   /*
512 512
                         $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
513 513
                         	    FROM spotter_archive_output 
514 514
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
515 515
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
516 516
                         	    '.$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';
517 517
                         */
518
-                        $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
518
+						$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
519 519
                         	    FROM spotter_archive_output 
520 520
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
521 521
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
522 522
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
523 523
 //                        	    .' 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';
524 524
                         	    
525
-                }
526
-                //echo $query;
527
-                try {
528
-                        $sth = $this->db->prepare($query);
529
-                        $sth->execute();
530
-                } catch(PDOException $e) {
531
-                        echo $e->getMessage();
532
-                        die;
533
-                }
534
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
535
-
536
-                return $spotter_array;
537
-        }
525
+				}
526
+				//echo $query;
527
+				try {
528
+						$sth = $this->db->prepare($query);
529
+						$sth->execute();
530
+				} catch(PDOException $e) {
531
+						echo $e->getMessage();
532
+						die;
533
+				}
534
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
535
+
536
+				return $spotter_array;
537
+		}
538 538
 
539 539
 	 /**
540
-        * Gets count Live Spotter data
541
-        *
542
-        * @return Array the spotter information
543
-        *
544
-        */
545
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
546
-        {
547
-                global $globalDBdriver, $globalLiveInterval;
548
-                date_default_timezone_set('UTC');
549
-
550
-                $filter_query = '';
551
-                if (isset($filter['source']) && !empty($filter['source'])) {
552
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
553
-                }
554
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
555
-                        $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 ";
556
-                }
557
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
558
-                        $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 ";
559
-                }
560
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
561
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
562
-                }
563
-
564
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
565
-                if ($globalDBdriver == 'mysql') {
540
+	  * Gets count Live Spotter data
541
+	  *
542
+	  * @return Array the spotter information
543
+	  *
544
+	  */
545
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
546
+		{
547
+				global $globalDBdriver, $globalLiveInterval;
548
+				date_default_timezone_set('UTC');
549
+
550
+				$filter_query = '';
551
+				if (isset($filter['source']) && !empty($filter['source'])) {
552
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
553
+				}
554
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
555
+						$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 ";
556
+				}
557
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
558
+						$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 ";
559
+				}
560
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
561
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
562
+				}
563
+
564
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
565
+				if ($globalDBdriver == 'mysql') {
566 566
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
567 567
 			FROM spotter_archive l 
568 568
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
569
-                } else {
569
+				} else {
570 570
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
571
-                }
572
-                //echo $query;
573
-                try {
574
-                        $sth = $this->db->prepare($query);
575
-                        $sth->execute();
576
-                } catch(PDOException $e) {
577
-                        echo $e->getMessage();
578
-                        die;
579
-                }
571
+				}
572
+				//echo $query;
573
+				try {
574
+						$sth = $this->db->prepare($query);
575
+						$sth->execute();
576
+				} catch(PDOException $e) {
577
+						echo $e->getMessage();
578
+						die;
579
+				}
580 580
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
581 581
 		$sth->closeCursor();
582
-                return $result['nb'];
582
+				return $result['nb'];
583 583
 
584
-        }
584
+		}
585 585
 
586 586
 
587 587
 
588 588
 	// Spotter_Archive_output
589 589
 	
590
-    /**
591
-    * Gets all the spotter information
592
-    *
593
-    * @return Array the spotter information
594
-    *
595
-    */
596
-    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())
597
-    {
590
+	/**
591
+	 * Gets all the spotter information
592
+	 *
593
+	 * @return Array the spotter information
594
+	 *
595
+	 */
596
+	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())
597
+	{
598 598
 	global $globalTimezone, $globalDBdriver;
599 599
 	require_once(dirname(__FILE__).'/class.Translation.php');
600 600
 	$Translation = new Translation();
@@ -608,159 +608,159 @@  discard block
 block discarded – undo
608 608
 	$filter_query = $this->getFilter($filters);
609 609
 	if ($q != "")
610 610
 	{
611
-	    if (!is_string($q))
612
-	    {
611
+		if (!is_string($q))
612
+		{
613 613
 		return false;
614
-	    } else {
614
+		} else {
615 615
 	        
616 616
 		$q_array = explode(" ", $q);
617 617
 		
618 618
 		foreach ($q_array as $q_item){
619
-		    $additional_query .= " AND (";
620
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
621
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
622
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
623
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
624
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
625
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
626
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
627
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
628
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
629
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
630
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
631
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
632
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
633
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
634
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
635
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
636
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
637
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
638
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
639
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
640
-		    $translate = $Translation->ident2icao($q_item);
641
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
642
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
643
-		    $additional_query .= ")";
644
-		}
645
-	    }
619
+			$additional_query .= " AND (";
620
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
621
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
622
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
623
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
624
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
625
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
626
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
627
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
628
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
629
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
630
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
631
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
632
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
633
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
634
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
635
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
636
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
637
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
638
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
639
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
640
+			$translate = $Translation->ident2icao($q_item);
641
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
642
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
643
+			$additional_query .= ")";
644
+		}
645
+		}
646 646
 	}
647 647
 	
648 648
 	if ($registration != "")
649 649
 	{
650
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
651
-	    if (!is_string($registration))
652
-	    {
650
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
651
+		if (!is_string($registration))
652
+		{
653 653
 		return false;
654
-	    } else {
654
+		} else {
655 655
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
656
-	    }
656
+		}
657 657
 	}
658 658
 	
659 659
 	if ($aircraft_icao != "")
660 660
 	{
661
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
662
-	    if (!is_string($aircraft_icao))
663
-	    {
661
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
662
+		if (!is_string($aircraft_icao))
663
+		{
664 664
 		return false;
665
-	    } else {
665
+		} else {
666 666
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
667
-	    }
667
+		}
668 668
 	}
669 669
 	
670 670
 	if ($aircraft_manufacturer != "")
671 671
 	{
672
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
673
-	    if (!is_string($aircraft_manufacturer))
674
-	    {
672
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
673
+		if (!is_string($aircraft_manufacturer))
674
+		{
675 675
 		return false;
676
-	    } else {
676
+		} else {
677 677
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
678
-	    }
678
+		}
679 679
 	}
680 680
 	
681 681
 	if ($highlights == "true")
682 682
 	{
683
-	    if (!is_string($highlights))
684
-	    {
683
+		if (!is_string($highlights))
684
+		{
685 685
 		return false;
686
-	    } else {
686
+		} else {
687 687
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
688
-	    }
688
+		}
689 689
 	}
690 690
 	
691 691
 	if ($airline_icao != "")
692 692
 	{
693
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
694
-	    if (!is_string($airline_icao))
695
-	    {
693
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
694
+		if (!is_string($airline_icao))
695
+		{
696 696
 		return false;
697
-	    } else {
697
+		} else {
698 698
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
699
-	    }
699
+		}
700 700
 	}
701 701
 	
702 702
 	if ($airline_country != "")
703 703
 	{
704
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
705
-	    if (!is_string($airline_country))
706
-	    {
704
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
705
+		if (!is_string($airline_country))
706
+		{
707 707
 		return false;
708
-	    } else {
708
+		} else {
709 709
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
710
-	    }
710
+		}
711 711
 	}
712 712
 	
713 713
 	if ($airline_type != "")
714 714
 	{
715
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
716
-	    if (!is_string($airline_type))
717
-	    {
715
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
716
+		if (!is_string($airline_type))
717
+		{
718 718
 		return false;
719
-	    } else {
719
+		} else {
720 720
 		if ($airline_type == "passenger")
721 721
 		{
722
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
722
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
723 723
 		}
724 724
 		if ($airline_type == "cargo")
725 725
 		{
726
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
726
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
727 727
 		}
728 728
 		if ($airline_type == "military")
729 729
 		{
730
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
730
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
731
+		}
731 732
 		}
732
-	    }
733 733
 	}
734 734
 	
735 735
 	if ($airport != "")
736 736
 	{
737
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
738
-	    if (!is_string($airport))
739
-	    {
737
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
738
+		if (!is_string($airport))
739
+		{
740 740
 		return false;
741
-	    } else {
741
+		} else {
742 742
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
743
-	    }
743
+		}
744 744
 	}
745 745
 	
746 746
 	if ($airport_country != "")
747 747
 	{
748
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
749
-	    if (!is_string($airport_country))
750
-	    {
748
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
749
+		if (!is_string($airport_country))
750
+		{
751 751
 		return false;
752
-	    } else {
752
+		} else {
753 753
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
754
-	    }
754
+		}
755 755
 	}
756 756
     
757 757
 	if ($callsign != "")
758 758
 	{
759
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
760
-	    if (!is_string($callsign))
761
-	    {
759
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
760
+		if (!is_string($callsign))
761
+		{
762 762
 		return false;
763
-	    } else {
763
+		} else {
764 764
 		$translate = $Translation->ident2icao($callsign);
765 765
 		if ($translate != $callsign) {
766 766
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -768,99 +768,99 @@  discard block
 block discarded – undo
768 768
 		} else {
769 769
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
770 770
 		}
771
-	    }
771
+		}
772 772
 	}
773 773
 
774 774
 	if ($owner != "")
775 775
 	{
776
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
777
-	    if (!is_string($owner))
778
-	    {
776
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
777
+		if (!is_string($owner))
778
+		{
779 779
 		return false;
780
-	    } else {
780
+		} else {
781 781
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
782
-	    }
782
+		}
783 783
 	}
784 784
 
785 785
 	if ($pilot_name != "")
786 786
 	{
787
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
788
-	    if (!is_string($pilot_name))
789
-	    {
787
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
788
+		if (!is_string($pilot_name))
789
+		{
790 790
 		return false;
791
-	    } else {
791
+		} else {
792 792
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
793
-	    }
793
+		}
794 794
 	}
795 795
 	
796 796
 	if ($pilot_id != "")
797 797
 	{
798
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
799
-	    if (!is_string($pilot_id))
800
-	    {
798
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
799
+		if (!is_string($pilot_id))
800
+		{
801 801
 		return false;
802
-	    } else {
802
+		} else {
803 803
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
804
-	    }
804
+		}
805 805
 	}
806 806
 	
807 807
 	if ($departure_airport_route != "")
808 808
 	{
809
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
810
-	    if (!is_string($departure_airport_route))
811
-	    {
809
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
810
+		if (!is_string($departure_airport_route))
811
+		{
812 812
 		return false;
813
-	    } else {
813
+		} else {
814 814
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
815
-	    }
815
+		}
816 816
 	}
817 817
 	
818 818
 	if ($arrival_airport_route != "")
819 819
 	{
820
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
821
-	    if (!is_string($arrival_airport_route))
822
-	    {
820
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
821
+		if (!is_string($arrival_airport_route))
822
+		{
823 823
 		return false;
824
-	    } else {
824
+		} else {
825 825
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
826
-	    }
826
+		}
827 827
 	}
828 828
 	
829 829
 	if ($altitude != "")
830 830
 	{
831
-	    $altitude_array = explode(",", $altitude);
831
+		$altitude_array = explode(",", $altitude);
832 832
 	    
833
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
834
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
833
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
834
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
835 835
 	    
836 836
 
837
-	    if ($altitude_array[1] != "")
838
-	    {                
837
+		if ($altitude_array[1] != "")
838
+		{                
839 839
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
840 840
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
841 841
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
842
-	    } else {
842
+		} else {
843 843
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
844 844
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
845
-	    }
845
+		}
846 846
 	}
847 847
 	
848 848
 	if ($date_posted != "")
849 849
 	{
850
-	    $date_array = explode(",", $date_posted);
850
+		$date_array = explode(",", $date_posted);
851 851
 	    
852
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
853
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
852
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
853
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
854 854
 	    
855
-	    if ($globalTimezone != '') {
855
+		if ($globalTimezone != '') {
856 856
 		date_default_timezone_set($globalTimezone);
857 857
 		$datetime = new DateTime();
858 858
 		$offset = $datetime->format('P');
859
-	    } else $offset = '+00:00';
859
+		} else $offset = '+00:00';
860 860
 
861 861
 
862
-	    if ($date_array[1] != "")
863
-	    {                
862
+		if ($date_array[1] != "")
863
+		{                
864 864
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
865 865
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
866 866
 		if ($globalDBdriver == 'mysql') {
@@ -868,28 +868,28 @@  discard block
 block discarded – undo
868 868
 		} else {
869 869
 			$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) ";
870 870
 		}
871
-	    } else {
871
+		} else {
872 872
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
873
-                if ($globalDBdriver == 'mysql') {
873
+				if ($globalDBdriver == 'mysql') {
874 874
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
875 875
 		} else {
876 876
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
877 877
 		}
878
-	    }
878
+		}
879 879
 	}
880 880
 	
881 881
 	if ($limit != "")
882 882
 	{
883
-	    $limit_array = explode(",", $limit);
883
+		$limit_array = explode(",", $limit);
884 884
 	    
885
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
886
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
885
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
886
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
887 887
 	    
888
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
889
-	    {
888
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
889
+		{
890 890
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
891 891
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
892
-	    }
892
+		}
893 893
 	}
894 894
 	
895 895
 
@@ -920,33 +920,33 @@  discard block
 block discarded – undo
920 920
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
921 921
 
922 922
 	return $spotter_array;
923
-    }
923
+	}
924 924
 
925
-    public function deleteSpotterArchiveData()
926
-    {
925
+	public function deleteSpotterArchiveData()
926
+	{
927 927
 		global $globalArchiveKeepMonths, $globalDBdriver;
928
-                date_default_timezone_set('UTC');
929
-                if ($globalDBdriver == 'mysql') {
928
+				date_default_timezone_set('UTC');
929
+				if ($globalDBdriver == 'mysql') {
930 930
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
931 931
 		} else {
932 932
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
933 933
 		}
934
-                try {
935
-                        $sth = $this->db->prepare($query);
936
-                        $sth->execute();
937
-                } catch(PDOException $e) {
938
-                        return "error";
939
-                }
934
+				try {
935
+						$sth = $this->db->prepare($query);
936
+						$sth->execute();
937
+				} catch(PDOException $e) {
938
+						return "error";
939
+				}
940 940
 	}
941 941
 
942
-    /**
943
-    * Gets all the spotter information based on the callsign
944
-    *
945
-    * @return Array the spotter information
946
-    *
947
-    */
948
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
949
-    {
942
+	/**
943
+	 * Gets all the spotter information based on the callsign
944
+	 *
945
+	 * @return Array the spotter information
946
+	 *
947
+	 */
948
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
949
+	{
950 950
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
951 951
 	
952 952
 	date_default_timezone_set('UTC');
@@ -958,35 +958,35 @@  discard block
 block discarded – undo
958 958
 	
959 959
 	if ($ident != "")
960 960
 	{
961
-	    if (!is_string($ident))
962
-	    {
961
+		if (!is_string($ident))
962
+		{
963 963
 		return false;
964
-	    } else {
964
+		} else {
965 965
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
966 966
 		$query_values = array(':ident' => $ident);
967
-	    }
967
+		}
968 968
 	}
969 969
 	
970 970
 	if ($limit != "")
971 971
 	{
972
-	    $limit_array = explode(",", $limit);
972
+		$limit_array = explode(",", $limit);
973 973
 	    
974
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
975
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
974
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
975
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
976 976
 	    
977
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
978
-	    {
977
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
978
+		{
979 979
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
980 980
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
981
-	    }
981
+		}
982 982
 	}
983 983
 
984 984
 	if ($sort != "")
985 985
 	{
986
-	    $search_orderby_array = $Spotter->getOrderBy();
987
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
986
+		$search_orderby_array = $Spotter->getOrderBy();
987
+		$orderby_query = $search_orderby_array[$sort]['sql'];
988 988
 	} else {
989
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
989
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
990 990
 	}
991 991
 
992 992
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -994,17 +994,17 @@  discard block
 block discarded – undo
994 994
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
995 995
 
996 996
 	return $spotter_array;
997
-    }
997
+	}
998 998
 
999 999
 
1000
-    /**
1001
-    * Gets all the spotter information based on the owner
1002
-    *
1003
-    * @return Array the spotter information
1004
-    *
1005
-    */
1006
-    public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1007
-    {
1000
+	/**
1001
+	 * Gets all the spotter information based on the owner
1002
+	 *
1003
+	 * @return Array the spotter information
1004
+	 *
1005
+	 */
1006
+	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1007
+	{
1008 1008
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1009 1009
 	
1010 1010
 	date_default_timezone_set('UTC');
@@ -1017,35 +1017,35 @@  discard block
 block discarded – undo
1017 1017
 	
1018 1018
 	if ($owner != "")
1019 1019
 	{
1020
-	    if (!is_string($owner))
1021
-	    {
1020
+		if (!is_string($owner))
1021
+		{
1022 1022
 		return false;
1023
-	    } else {
1023
+		} else {
1024 1024
 		$additional_query = " AND (spotter_archive_output.owner_name = :owner)";
1025 1025
 		$query_values = array(':owner' => $owner);
1026
-	    }
1026
+		}
1027 1027
 	}
1028 1028
 	
1029 1029
 	if ($limit != "")
1030 1030
 	{
1031
-	    $limit_array = explode(",", $limit);
1031
+		$limit_array = explode(",", $limit);
1032 1032
 	    
1033
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1034
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1033
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1034
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1035 1035
 	    
1036
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1037
-	    {
1036
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1037
+		{
1038 1038
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1039 1039
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1040
-	    }
1040
+		}
1041 1041
 	}
1042 1042
 
1043 1043
 	if ($sort != "")
1044 1044
 	{
1045
-	    $search_orderby_array = $Spotter->getOrderBy();
1046
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1045
+		$search_orderby_array = $Spotter->getOrderBy();
1046
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1047 1047
 	} else {
1048
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1048
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1049 1049
 	}
1050 1050
 
1051 1051
 	$query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1053,16 +1053,16 @@  discard block
 block discarded – undo
1053 1053
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1054 1054
 
1055 1055
 	return $spotter_array;
1056
-    }
1057
-
1058
-    /**
1059
-    * Gets all the spotter information based on the pilot
1060
-    *
1061
-    * @return Array the spotter information
1062
-    *
1063
-    */
1064
-    public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1065
-    {
1056
+	}
1057
+
1058
+	/**
1059
+	 * Gets all the spotter information based on the pilot
1060
+	 *
1061
+	 * @return Array the spotter information
1062
+	 *
1063
+	 */
1064
+	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1065
+	{
1066 1066
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1067 1067
 	
1068 1068
 	date_default_timezone_set('UTC');
@@ -1081,24 +1081,24 @@  discard block
 block discarded – undo
1081 1081
 	
1082 1082
 	if ($limit != "")
1083 1083
 	{
1084
-	    $limit_array = explode(",", $limit);
1084
+		$limit_array = explode(",", $limit);
1085 1085
 	    
1086
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1087
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1086
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1087
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1088 1088
 	    
1089
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1090
-	    {
1089
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1090
+		{
1091 1091
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1092 1092
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1093
-	    }
1093
+		}
1094 1094
 	}
1095 1095
 
1096 1096
 	if ($sort != "")
1097 1097
 	{
1098
-	    $search_orderby_array = $Spotter->getOrderBy();
1099
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1098
+		$search_orderby_array = $Spotter->getOrderBy();
1099
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1100 1100
 	} else {
1101
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1101
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1102 1102
 	}
1103 1103
 
1104 1104
 	$query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1106,16 +1106,16 @@  discard block
 block discarded – undo
1106 1106
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1107 1107
 
1108 1108
 	return $spotter_array;
1109
-    }
1110
-
1111
-    /**
1112
-    * Gets all number of flight over countries
1113
-    *
1114
-    * @return Array the airline country list
1115
-    *
1116
-    */
1117
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1118
-    {
1109
+	}
1110
+
1111
+	/**
1112
+	 * Gets all number of flight over countries
1113
+	 *
1114
+	 * @return Array the airline country list
1115
+	 *
1116
+	 */
1117
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1118
+	{
1119 1119
 	global $globalDBdriver;
1120 1120
 	/*
1121 1121
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1125,14 +1125,14 @@  discard block
 block discarded – undo
1125 1125
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1126 1126
 		    FROM countries c, spotter_archive s
1127 1127
 		    WHERE c.iso2 = s.over_country ";
1128
-                if ($olderthanmonths > 0) {
1129
-            		if ($globalDBdriver == 'mysql') {
1128
+				if ($olderthanmonths > 0) {
1129
+					if ($globalDBdriver == 'mysql') {
1130 1130
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1131 1131
 			} else {
1132 1132
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1133 1133
 			}
1134 1134
 		}
1135
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1135
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1136 1136
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1137 1137
 	if ($limit) $query .= " LIMIT 0,10";
1138 1138
       
@@ -1145,23 +1145,23 @@  discard block
 block discarded – undo
1145 1145
         
1146 1146
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1147 1147
 	{
1148
-	    $temp_array['flight_count'] = $row['nb'];
1149
-	    $temp_array['flight_country'] = $row['name'];
1150
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1151
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1152
-	    $flight_array[] = $temp_array;
1148
+		$temp_array['flight_count'] = $row['nb'];
1149
+		$temp_array['flight_country'] = $row['name'];
1150
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1151
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1152
+		$flight_array[] = $temp_array;
1153 1153
 	}
1154 1154
 	return $flight_array;
1155
-    }
1156
-
1157
-    /**
1158
-    * Gets all number of flight over countries
1159
-    *
1160
-    * @return Array the airline country list
1161
-    *
1162
-    */
1163
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1164
-    {
1155
+	}
1156
+
1157
+	/**
1158
+	 * Gets all number of flight over countries
1159
+	 *
1160
+	 * @return Array the airline country list
1161
+	 *
1162
+	 */
1163
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1164
+	{
1165 1165
 	global $globalDBdriver;
1166 1166
 	/*
1167 1167
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1171,14 +1171,14 @@  discard block
 block discarded – undo
1171 1171
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1172 1172
 		    FROM countries c, spotter_archive s, spotter_output o
1173 1173
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id ";
1174
-                if ($olderthanmonths > 0) {
1175
-            		if ($globalDBdriver == 'mysql') {
1174
+				if ($olderthanmonths > 0) {
1175
+					if ($globalDBdriver == 'mysql') {
1176 1176
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1177 1177
 			} else {
1178 1178
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1179 1179
 			}
1180 1180
 		}
1181
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1181
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1182 1182
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1183 1183
 	if ($limit) $query .= " LIMIT 0,10";
1184 1184
       
@@ -1191,24 +1191,24 @@  discard block
 block discarded – undo
1191 1191
         
1192 1192
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1193 1193
 	{
1194
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1195
-	    $temp_array['flight_count'] = $row['nb'];
1196
-	    $temp_array['flight_country'] = $row['name'];
1197
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1198
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1199
-	    $flight_array[] = $temp_array;
1194
+		$temp_array['airline_icao'] = $row['airline_icao'];
1195
+		$temp_array['flight_count'] = $row['nb'];
1196
+		$temp_array['flight_country'] = $row['name'];
1197
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1198
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1199
+		$flight_array[] = $temp_array;
1200 1200
 	}
1201 1201
 	return $flight_array;
1202
-    }
1203
-
1204
-    /**
1205
-    * Gets last spotter information based on a particular callsign
1206
-    *
1207
-    * @return Array the spotter information
1208
-    *
1209
-    */
1210
-    public function getDateArchiveSpotterDataById($id,$date)
1211
-    {
1202
+	}
1203
+
1204
+	/**
1205
+	 * Gets last spotter information based on a particular callsign
1206
+	 *
1207
+	 * @return Array the spotter information
1208
+	 *
1209
+	 */
1210
+	public function getDateArchiveSpotterDataById($id,$date)
1211
+	{
1212 1212
 	$Spotter = new Spotter($this->db);
1213 1213
 	date_default_timezone_set('UTC');
1214 1214
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1216,16 +1216,16 @@  discard block
 block discarded – undo
1216 1216
 	$date = date('c',$date);
1217 1217
 	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1218 1218
 	return $spotter_array;
1219
-    }
1220
-
1221
-    /**
1222
-    * Gets all the spotter information based on a particular callsign
1223
-    *
1224
-    * @return Array the spotter information
1225
-    *
1226
-    */
1227
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1228
-    {
1219
+	}
1220
+
1221
+	/**
1222
+	 * Gets all the spotter information based on a particular callsign
1223
+	 *
1224
+	 * @return Array the spotter information
1225
+	 *
1226
+	 */
1227
+	public function getDateArchiveSpotterDataByIdent($ident,$date)
1228
+	{
1229 1229
 	$Spotter = new Spotter($this->db);
1230 1230
 	date_default_timezone_set('UTC');
1231 1231
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1233,16 +1233,16 @@  discard block
 block discarded – undo
1233 1233
 	$date = date('c',$date);
1234 1234
 	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1235 1235
 	return $spotter_array;
1236
-    }
1237
-
1238
-    /**
1239
-    * Gets all the spotter information based on the airport
1240
-    *
1241
-    * @return Array the spotter information
1242
-    *
1243
-    */
1244
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1245
-    {
1236
+	}
1237
+
1238
+	/**
1239
+	 * Gets all the spotter information based on the airport
1240
+	 *
1241
+	 * @return Array the spotter information
1242
+	 *
1243
+	 */
1244
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1245
+	{
1246 1246
 	global $global_query;
1247 1247
 	$Spotter = new Spotter();
1248 1248
 	date_default_timezone_set('UTC');
@@ -1253,35 +1253,35 @@  discard block
 block discarded – undo
1253 1253
 	
1254 1254
 	if ($airport != "")
1255 1255
 	{
1256
-	    if (!is_string($airport))
1257
-	    {
1256
+		if (!is_string($airport))
1257
+		{
1258 1258
 		return false;
1259
-	    } else {
1259
+		} else {
1260 1260
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))";
1261 1261
 		$query_values = array(':airport' => $airport);
1262
-	    }
1262
+		}
1263 1263
 	}
1264 1264
 	
1265 1265
 	if ($limit != "")
1266 1266
 	{
1267
-	    $limit_array = explode(",", $limit);
1267
+		$limit_array = explode(",", $limit);
1268 1268
 	    
1269
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1270
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1269
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1270
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1271 1271
 	    
1272
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1273
-	    {
1272
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1273
+		{
1274 1274
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1275 1275
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1276
-	    }
1276
+		}
1277 1277
 	}
1278 1278
 	
1279 1279
 	if ($sort != "")
1280 1280
 	{
1281
-	    $search_orderby_array = $Spotter->getOrderBy();
1282
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1281
+		$search_orderby_array = $Spotter->getOrderBy();
1282
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1283 1283
 	} else {
1284
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1284
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1285 1285
 	}
1286 1286
 
1287 1287
 	$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;
@@ -1289,6 +1289,6 @@  discard block
 block discarded – undo
1289 1289
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1290 1290
 
1291 1291
 	return $spotter_array;
1292
-    }
1292
+	}
1293 1293
 }
1294 1294
 ?>
1295 1295
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -13,62 +13,62 @@  discard block
 block discarded – undo
13 13
     * @param Array $filter the filter
14 14
     * @return Array the SQL part
15 15
     */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
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])) {
20 20
 		if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21 21
 			$filters = $globalStatsFilters[$globalFilterName];
22 22
 		} else {
23
-			$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
23
+			$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
24 24
 		}
25 25
 	}
26 26
 	if (isset($filter[0]['source'])) {
27
-		$filters = array_merge($filters,$filter);
27
+		$filters = array_merge($filters, $filter);
28 28
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+	if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32
-	foreach($filters as $flt) {
32
+	foreach ($filters as $flt) {
33 33
 	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
34 34
 		if ($flt['airlines'][0] != '') {
35 35
 		    if (isset($flt['source'])) {
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";
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 37
 		    } else {
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";
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 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 48
 	    }
49 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 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 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 70
 	    if ($filter['airlines'][0] != '') {
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";
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
 	
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 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 85
 	    $filter_query_where .= " AND ident = '".$filter['ident']."'";
86 86
 	}
87 87
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
88
-		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
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 91
 	    $filter_query_date = '';
@@ -111,41 +111,41 @@  discard block
 block discarded – undo
111 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';
118 118
 	if ($filter_query_where != '') {
119
-		$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
119
+		$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
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
-	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 = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
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 = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
127 127
 		require_once(dirname(__FILE__).'/class.Spotter.php');
128 128
 		if ($over_country == '') {
129 129
 			$Spotter = new Spotter($this->db);
130
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
130
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
131 131
 			if (!empty($data_country)) $country = $data_country['iso2'];
132 132
 			else $country = '';
133 133
 		} else $country = $over_country;
134
-		if ($airline_type === NULL) $airline_type ='';
134
+		if ($airline_type === NULL) $airline_type = '';
135 135
 	
136 136
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
137 137
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
138 138
 
139 139
 		// Route is not added in spotter_archive
140
-		$query  = "INSERT INTO spotter_archive (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,over_country,source_name,real_altitude)
140
+		$query = "INSERT INTO spotter_archive (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,over_country,source_name,real_altitude)
141 141
 		        VALUES (: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, :over_country, :source_name,:real_altitude)";
142 142
 
143
-		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name,':real_altitude' => $real_altitude);
143
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name, ':real_altitude' => $real_altitude);
144 144
 		try {
145 145
 			$sth = $this->db->prepare($query);
146 146
 			$sth->execute($query_values);
147 147
 			$sth->closeCursor();
148
-		} catch(PDOException $e) {
148
+		} catch (PDOException $e) {
149 149
 			return "error : ".$e->getMessage();
150 150
 		}
151 151
 		return "success";
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 
166 166
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
167 167
                 //$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";
168
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
168
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
169 169
 
170
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
170
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
171 171
 
172 172
                 return $spotter_array;
173 173
         }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
187 187
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
188 188
                 //$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";
189
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
189
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
190 190
 
191 191
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
192 192
                   /*
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                 }
200 200
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
201 201
                 */
202
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
202
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
203 203
 
204 204
                 return $spotter_array;
205 205
         }
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
 	{
215 215
                 date_default_timezone_set('UTC');
216 216
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
217
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
217
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
218 218
 
219 219
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
220 220
 
221 221
                 try {
222 222
                         $sth = $this->db->prepare($query);
223 223
                         $sth->execute(array(':id' => $id));
224
-                } catch(PDOException $e) {
224
+                } catch (PDOException $e) {
225 225
                         echo $e->getMessage();
226 226
                         die;
227 227
                 }
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
         {
241 241
                 date_default_timezone_set('UTC');
242 242
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
243
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
243
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
244 244
 
245 245
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
246 246
 
247 247
                 try {
248 248
                         $sth = $this->db->prepare($query);
249 249
                         $sth->execute(array(':id' => $id));
250
-                } catch(PDOException $e) {
250
+                } catch (PDOException $e) {
251 251
                         echo $e->getMessage();
252 252
                         die;
253 253
                 }
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
                 date_default_timezone_set('UTC');
270 270
 
271 271
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
272
-                $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
+                $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";
273 273
 
274 274
                 try {
275 275
                         $sth = $this->db->prepare($query);
276 276
                         $sth->execute(array(':ident' => $ident));
277
-                } catch(PDOException $e) {
277
+                } catch (PDOException $e) {
278 278
                         echo $e->getMessage();
279 279
                         die;
280 280
                 }
@@ -295,12 +295,12 @@  discard block
 block discarded – undo
295 295
                 date_default_timezone_set('UTC');
296 296
 
297 297
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
298
-                $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
+                $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";
299 299
 
300 300
                 try {
301 301
                         $sth = $this->db->prepare($query);
302 302
                         $sth->execute(array(':id' => $id));
303
-                } catch(PDOException $e) {
303
+                } catch (PDOException $e) {
304 304
                         echo $e->getMessage();
305 305
                         die;
306 306
                 }
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
                 date_default_timezone_set('UTC');
322 322
 
323 323
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
324
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
324
+                $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
325 325
 
326 326
                 try {
327 327
                         $sth = $this->db->prepare($query);
328 328
                         $sth->execute(array(':id' => $id));
329
-                } catch(PDOException $e) {
329
+                } catch (PDOException $e) {
330 330
                         echo $e->getMessage();
331 331
                         die;
332 332
                 }
@@ -348,13 +348,13 @@  discard block
 block discarded – undo
348 348
                 date_default_timezone_set('UTC');
349 349
 
350 350
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
351
-                $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
+                $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";
352 352
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
353 353
 
354 354
                 try {
355 355
                         $sth = $this->db->prepare($query);
356 356
                         $sth->execute(array(':ident' => $ident));
357
-                } catch(PDOException $e) {
357
+                } catch (PDOException $e) {
358 358
                         echo $e->getMessage();
359 359
                         die;
360 360
                 }
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
         * @return Array the spotter information
372 372
         *
373 373
         */
374
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
374
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
375 375
         {
376 376
     		$Spotter = new Spotter($this->db);
377 377
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
378
-                $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
+                $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";
379 379
 
380
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
380
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
381 381
 
382 382
                 return $spotter_array;
383 383
         }
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
                 try {
394 394
                         $sth = $this->db->prepare($query);
395 395
                         $sth->execute();
396
-                } catch(PDOException $e) {
396
+                } catch (PDOException $e) {
397 397
                         echo $e->getMessage();
398 398
                         die;
399 399
                 }
@@ -405,24 +405,24 @@  discard block
 block discarded – undo
405 405
         * @return Array the spotter information
406 406
         *
407 407
         */
408
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
408
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
409 409
         {
410 410
                 global $globalDBdriver, $globalLiveInterval;
411 411
                 date_default_timezone_set('UTC');
412 412
 
413 413
                 $filter_query = '';
414 414
                 if (isset($filter['source']) && !empty($filter['source'])) {
415
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
415
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
416 416
                 }
417 417
                 // Use spotter_output also ?
418 418
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
419
-                        $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 ";
419
+                        $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 ";
420 420
                 }
421 421
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
422 422
                         $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 ";
423 423
                 }
424 424
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
425
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
425
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
426 426
                 }
427 427
 
428 428
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -441,14 +441,14 @@  discard block
 block discarded – undo
441 441
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
442 442
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
443 443
 */
444
-			$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 
444
+			$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 445
 				    FROM spotter_archive 
446 446
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
447 447
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
448 448
                         	    '.$filter_query.' ORDER BY flightaware_id';
449 449
                 } else {
450 450
                         //$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';
451
-                        $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 
451
+                        $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 
452 452
                         	    FROM spotter_archive 
453 453
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
454 454
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
                 try {
459 459
                         $sth = $this->db->prepare($query);
460 460
                         $sth->execute();
461
-                } catch(PDOException $e) {
461
+                } catch (PDOException $e) {
462 462
                         echo $e->getMessage();
463 463
                         die;
464 464
                 }
@@ -473,24 +473,24 @@  discard block
 block discarded – undo
473 473
         * @return Array the spotter information
474 474
         *
475 475
         */
476
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
476
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
477 477
         {
478 478
                 global $globalDBdriver, $globalLiveInterval;
479 479
                 date_default_timezone_set('UTC');
480 480
 
481 481
                 $filter_query = '';
482 482
                 if (isset($filter['source']) && !empty($filter['source'])) {
483
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
483
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
484 484
                 }
485 485
                 // Should use spotter_output also ?
486 486
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
487
-                        $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 ";
487
+                        $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 ";
488 488
                 }
489 489
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
490 490
                         $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 ";
491 491
                 }
492 492
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
493
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
493
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
494 494
                 }
495 495
 
496 496
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
                     		    FROM spotter_archive 
501 501
                     		    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 502
 			*/
503
-			$query  = 'SELECT a.aircraft_shadow, 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 
503
+			$query = 'SELECT a.aircraft_shadow, 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 
504 504
 				    FROM spotter_archive_output 
505 505
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
506 506
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
516 516
                         	    '.$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';
517 517
                         */
518
-                        $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
518
+                        $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
519 519
                         	    FROM spotter_archive_output 
520 520
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
521 521
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
                 try {
528 528
                         $sth = $this->db->prepare($query);
529 529
                         $sth->execute();
530
-                } catch(PDOException $e) {
530
+                } catch (PDOException $e) {
531 531
                         echo $e->getMessage();
532 532
                         die;
533 533
                 }
@@ -542,23 +542,23 @@  discard block
 block discarded – undo
542 542
         * @return Array the spotter information
543 543
         *
544 544
         */
545
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
545
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
546 546
         {
547 547
                 global $globalDBdriver, $globalLiveInterval;
548 548
                 date_default_timezone_set('UTC');
549 549
 
550 550
                 $filter_query = '';
551 551
                 if (isset($filter['source']) && !empty($filter['source'])) {
552
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
552
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
553 553
                 }
554 554
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
555
-                        $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 ";
555
+                        $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 ";
556 556
                 }
557 557
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
558 558
                         $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 ";
559 559
                 }
560 560
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
561
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
561
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
562 562
                 }
563 563
 
564 564
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
                 try {
574 574
                         $sth = $this->db->prepare($query);
575 575
                         $sth->execute();
576
-                } catch(PDOException $e) {
576
+                } catch (PDOException $e) {
577 577
                         echo $e->getMessage();
578 578
                         die;
579 579
                 }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
     * @return Array the spotter information
594 594
     *
595 595
     */
596
-    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())
596
+    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())
597 597
     {
598 598
 	global $globalTimezone, $globalDBdriver;
599 599
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 	        
616 616
 		$q_array = explode(" ", $q);
617 617
 		
618
-		foreach ($q_array as $q_item){
618
+		foreach ($q_array as $q_item) {
619 619
 		    $additional_query .= " AND (";
620 620
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
621 621
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 	
648 648
 	if ($registration != "")
649 649
 	{
650
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
650
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
651 651
 	    if (!is_string($registration))
652 652
 	    {
653 653
 		return false;
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 	
659 659
 	if ($aircraft_icao != "")
660 660
 	{
661
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
661
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
662 662
 	    if (!is_string($aircraft_icao))
663 663
 	    {
664 664
 		return false;
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 	
670 670
 	if ($aircraft_manufacturer != "")
671 671
 	{
672
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
672
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
673 673
 	    if (!is_string($aircraft_manufacturer))
674 674
 	    {
675 675
 		return false;
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 	
691 691
 	if ($airline_icao != "")
692 692
 	{
693
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
693
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
694 694
 	    if (!is_string($airline_icao))
695 695
 	    {
696 696
 		return false;
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 	
702 702
 	if ($airline_country != "")
703 703
 	{
704
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
704
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
705 705
 	    if (!is_string($airline_country))
706 706
 	    {
707 707
 		return false;
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 	
713 713
 	if ($airline_type != "")
714 714
 	{
715
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
715
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
716 716
 	    if (!is_string($airline_type))
717 717
 	    {
718 718
 		return false;
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 	
735 735
 	if ($airport != "")
736 736
 	{
737
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
737
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
738 738
 	    if (!is_string($airport))
739 739
 	    {
740 740
 		return false;
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 	
746 746
 	if ($airport_country != "")
747 747
 	{
748
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
748
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
749 749
 	    if (!is_string($airport_country))
750 750
 	    {
751 751
 		return false;
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
     
757 757
 	if ($callsign != "")
758 758
 	{
759
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
759
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
760 760
 	    if (!is_string($callsign))
761 761
 	    {
762 762
 		return false;
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 		$translate = $Translation->ident2icao($callsign);
765 765
 		if ($translate != $callsign) {
766 766
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
767
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
767
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
768 768
 		} else {
769 769
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
770 770
 		}
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 
774 774
 	if ($owner != "")
775 775
 	{
776
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
776
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
777 777
 	    if (!is_string($owner))
778 778
 	    {
779 779
 		return false;
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 
785 785
 	if ($pilot_name != "")
786 786
 	{
787
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
787
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
788 788
 	    if (!is_string($pilot_name))
789 789
 	    {
790 790
 		return false;
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 	
796 796
 	if ($pilot_id != "")
797 797
 	{
798
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
798
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
799 799
 	    if (!is_string($pilot_id))
800 800
 	    {
801 801
 		return false;
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 	
807 807
 	if ($departure_airport_route != "")
808 808
 	{
809
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
809
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
810 810
 	    if (!is_string($departure_airport_route))
811 811
 	    {
812 812
 		return false;
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 	
818 818
 	if ($arrival_airport_route != "")
819 819
 	{
820
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
820
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
821 821
 	    if (!is_string($arrival_airport_route))
822 822
 	    {
823 823
 		return false;
@@ -830,8 +830,8 @@  discard block
 block discarded – undo
830 830
 	{
831 831
 	    $altitude_array = explode(",", $altitude);
832 832
 	    
833
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
834
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
833
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
834
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
835 835
 	    
836 836
 
837 837
 	    if ($altitude_array[1] != "")
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	{
850 850
 	    $date_array = explode(",", $date_posted);
851 851
 	    
852
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
853
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
852
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
853
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
854 854
 	    
855 855
 	    if ($globalTimezone != '') {
856 856
 		date_default_timezone_set($globalTimezone);
@@ -882,8 +882,8 @@  discard block
 block discarded – undo
882 882
 	{
883 883
 	    $limit_array = explode(",", $limit);
884 884
 	    
885
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
886
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
885
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
886
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
887 887
 	    
888 888
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
889 889
 	    {
@@ -894,8 +894,8 @@  discard block
 block discarded – undo
894 894
 	
895 895
 
896 896
 	if ($origLat != "" && $origLon != "" && $dist != "") {
897
-		$dist = number_format($dist*0.621371,2,'.','');
898
-		$query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
897
+		$dist = number_format($dist*0.621371, 2, '.', '');
898
+		$query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
899 899
                           FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
900 900
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
901 901
 	} else {
@@ -912,12 +912,12 @@  discard block
 block discarded – undo
912 912
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
913 913
 		}
914 914
 
915
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
915
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
916 916
 		    WHERE spotter_archive_output.ident <> '' 
917 917
 		    ".$additional_query."
918 918
 		    ".$filter_query.$orderby_query;
919 919
 	}
920
-	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
920
+	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
921 921
 
922 922
 	return $spotter_array;
923 923
     }
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
                 try {
935 935
                         $sth = $this->db->prepare($query);
936 936
                         $sth->execute();
937
-                } catch(PDOException $e) {
937
+                } catch (PDOException $e) {
938 938
                         return "error";
939 939
                 }
940 940
 	}
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
 	{
972 972
 	    $limit_array = explode(",", $limit);
973 973
 	    
974
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
975
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
974
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
975
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
976 976
 	    
977 977
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
978 978
 	    {
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
 	$query_values = array();
1014 1014
 	$limit_query = '';
1015 1015
 	$additional_query = '';
1016
-	$filter_query = $this->getFilter($filter,true,true);
1016
+	$filter_query = $this->getFilter($filter, true, true);
1017 1017
 	
1018 1018
 	if ($owner != "")
1019 1019
 	{
@@ -1030,8 +1030,8 @@  discard block
 block discarded – undo
1030 1030
 	{
1031 1031
 	    $limit_array = explode(",", $limit);
1032 1032
 	    
1033
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1034
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1033
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1034
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1035 1035
 	    
1036 1036
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1037 1037
 	    {
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 	$query_values = array();
1072 1072
 	$limit_query = '';
1073 1073
 	$additional_query = '';
1074
-	$filter_query = $this->getFilter($filter,true,true);
1074
+	$filter_query = $this->getFilter($filter, true, true);
1075 1075
 	
1076 1076
 	if ($pilot != "")
1077 1077
 	{
@@ -1083,8 +1083,8 @@  discard block
 block discarded – undo
1083 1083
 	{
1084 1084
 	    $limit_array = explode(",", $limit);
1085 1085
 	    
1086
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1087
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1086
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1087
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1088 1088
 	    
1089 1089
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1090 1090
 	    {
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
     * @return Array the airline country list
1115 1115
     *
1116 1116
     */
1117
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1117
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1118 1118
     {
1119 1119
 	global $globalDBdriver;
1120 1120
 	/*
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 	$flight_array = array();
1144 1144
 	$temp_array = array();
1145 1145
         
1146
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1146
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1147 1147
 	{
1148 1148
 	    $temp_array['flight_count'] = $row['nb'];
1149 1149
 	    $temp_array['flight_country'] = $row['name'];
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
     * @return Array the airline country list
1161 1161
     *
1162 1162
     */
1163
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1163
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1164 1164
     {
1165 1165
 	global $globalDBdriver;
1166 1166
 	/*
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
 	$flight_array = array();
1190 1190
 	$temp_array = array();
1191 1191
         
1192
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1192
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1193 1193
 	{
1194 1194
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1195 1195
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1207,14 +1207,14 @@  discard block
 block discarded – undo
1207 1207
     * @return Array the spotter information
1208 1208
     *
1209 1209
     */
1210
-    public function getDateArchiveSpotterDataById($id,$date)
1210
+    public function getDateArchiveSpotterDataById($id, $date)
1211 1211
     {
1212 1212
 	$Spotter = new Spotter($this->db);
1213 1213
 	date_default_timezone_set('UTC');
1214 1214
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1215
-	$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 AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1216
-	$date = date('c',$date);
1217
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1215
+	$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 AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1216
+	$date = date('c', $date);
1217
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1218 1218
 	return $spotter_array;
1219 1219
     }
1220 1220
 
@@ -1224,14 +1224,14 @@  discard block
 block discarded – undo
1224 1224
     * @return Array the spotter information
1225 1225
     *
1226 1226
     */
1227
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1227
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
1228 1228
     {
1229 1229
 	$Spotter = new Spotter($this->db);
1230 1230
 	date_default_timezone_set('UTC');
1231 1231
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1232
-	$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 AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1233
-	$date = date('c',$date);
1234
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1232
+	$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 AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1233
+	$date = date('c', $date);
1234
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1235 1235
 	return $spotter_array;
1236 1236
     }
1237 1237
 
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
     * @return Array the spotter information
1242 1242
     *
1243 1243
     */
1244
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1244
+    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1245 1245
     {
1246 1246
 	global $global_query;
1247 1247
 	$Spotter = new Spotter();
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 	$query_values = array();
1250 1250
 	$limit_query = '';
1251 1251
 	$additional_query = '';
1252
-	$filter_query = $this->getFilter($filters,true,true);
1252
+	$filter_query = $this->getFilter($filters, true, true);
1253 1253
 	
1254 1254
 	if ($airport != "")
1255 1255
 	{
@@ -1266,8 +1266,8 @@  discard block
 block discarded – undo
1266 1266
 	{
1267 1267
 	    $limit_array = explode(",", $limit);
1268 1268
 	    
1269
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1270
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1269
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1270
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1271 1271
 	    
1272 1272
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1273 1273
 	    {
Please login to merge, or discard this patch.
ident-detailed.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Language.php');
4 4
 require_once('require/class.Translation.php');
5 5
 $type = '';
6
-$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
6
+$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
7 7
 if (isset($_GET['marine'])) {
8 8
 	require_once('require/class.Marine.php');
9 9
 	require_once('require/class.MarineLive.php');
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 	$page_url = $globalURL.'/ident/'.$_GET['ident'];
31 31
 }
32 32
 
33
-if (!isset($_GET['ident'])){
33
+if (!isset($_GET['ident'])) {
34 34
 	header('Location: '.$globalURL.'');
35 35
 } else {
36 36
 	$Translation = new Translation();
37 37
 	//calculuation for the pagination
38
-	if(!isset($_GET['limit']))
38
+	if (!isset($_GET['limit']))
39 39
 	{
40 40
 		$limit_start = 0;
41 41
 		$limit_end = 25;
@@ -54,18 +54,18 @@  discard block
 block discarded – undo
54 54
 	$limit_previous_1 = $limit_start - $absolute_difference;
55 55
 	$limit_previous_2 = $limit_end - $absolute_difference;
56 56
 	
57
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
57
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
58 58
 	if ($type == 'aircraft') {
59 59
 		if ($sort != '') 
60 60
 		{
61
-			$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
61
+			$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
62 62
 			if (empty($spotter_array)) {
63
-				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
63
+				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
64 64
 			}
65 65
 		} else {
66
-			$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
66
+			$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
67 67
 			if (empty($spotter_array)) {
68
-				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
68
+				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
69 69
 			}
70 70
 		}
71 71
 		if (empty($spotter_array)) {
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 				$ident = $new_ident;
75 75
 				if ($sort != '') 
76 76
 				{
77
-					$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
77
+					$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
78 78
 					if (empty($spotter_array)) {
79
-						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
79
+						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
80 80
 					}
81 81
 				} else {
82
-					$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
82
+					$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
83 83
 					if (empty($spotter_array)) {
84
-						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
84
+						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
85 85
 					}
86 86
 				}
87 87
 			}
@@ -89,34 +89,34 @@  discard block
 block discarded – undo
89 89
 	} elseif ($type == 'marine') {
90 90
 		if ($sort != '') 
91 91
 		{
92
-			$spotter_array = $Marine->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
92
+			$spotter_array = $Marine->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
93 93
 			if (empty($spotter_array)) {
94
-				$spotter_array = $MarineArchive->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
94
+				$spotter_array = $MarineArchive->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
95 95
 			}
96 96
 		} else {
97
-			$spotter_array = $Marine->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference);
97
+			$spotter_array = $Marine->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference);
98 98
 			if (empty($spotter_array)) {
99
-				$spotter_array = $MarineArchive->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference);
99
+				$spotter_array = $MarineArchive->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference);
100 100
 			}
101 101
 		}
102 102
 	} elseif ($type == 'tracker') {
103 103
 		if ($sort != '') 
104 104
 		{
105
-			$spotter_array = $Tracker->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
105
+			$spotter_array = $Tracker->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
106 106
 			if (empty($spotter_array)) {
107
-				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
107
+				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
108 108
 			}
109 109
 		} else {
110
-			$spotter_array = $Tracker->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference);
110
+			$spotter_array = $Tracker->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference);
111 111
 			if (empty($spotter_array)) {
112
-				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference);
112
+				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference);
113 113
 			}
114 114
 		}
115 115
 	}
116 116
 
117 117
 	if (!empty($spotter_array))
118 118
 	{
119
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']);
119
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['ident']);
120 120
 		$ident = $spotter_array[0]['ident'];
121 121
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
122 122
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 				$altitude_data = '';
137 137
 				$hour_data = '';
138 138
 				$speed_data = '';
139
-				foreach($all_data as $data)
139
+				foreach ($all_data as $data)
140 140
 				{
141 141
 					$hour_data .= '"'.$data['date'].'",';
142 142
 					if (isset($data['real_altitude']) && $data['real_altitude'] != '') {
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 					$speed_data .= $speed.',';
165 165
 				}
166 166
 				$hour_data = "['x',".substr($hour_data, 0, -1)."]";
167
-				$altitude_data = "['altitude',".substr($altitude_data,0,-1)."]";
168
-				$speed_data = "['speed',".substr($speed_data,0,-1)."]";
167
+				$altitude_data = "['altitude',".substr($altitude_data, 0, -1)."]";
168
+				$speed_data = "['speed',".substr($speed_data, 0, -1)."]";
169 169
 				print 'c3.generate({
170 170
 				    bindto: "#chart",
171 171
 				    data: {
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
 	
210 210
 		if ($type == 'aircraft') include('ident-sub-menu.php');
211 211
 		print '<div class="table column">';
212
-		if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
213
-		elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
214
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
212
+		if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
213
+		elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
214
+		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
215 215
 
216 216
 		include('table-output.php'); 
217 217
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +22 added lines, -8 removed lines patch added patch discarded remove patch
@@ -118,8 +118,12 @@  discard block
 block discarded – undo
118 118
 	{
119 119
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']);
120 120
 		$ident = $spotter_array[0]['ident'];
121
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
122
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
121
+		if (isset($spotter_array[0]['latitude'])) {
122
+			$latitude = $spotter_array[0]['latitude'];
123
+		}
124
+		if (isset($spotter_array[0]['longitude'])) {
125
+			$longitude = $spotter_array[0]['longitude'];
126
+		}
123 127
 		require_once('header.php');
124 128
 		if (isset($globalArchive) && $globalArchive && $type == 'aircraft') {
125 129
 			// Requirement for altitude graph
@@ -127,7 +131,9 @@  discard block
 block discarded – undo
127 131
 			$all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']);
128 132
 			if (isset($globalTimezone)) {
129 133
 				date_default_timezone_set($globalTimezone);
130
-			} else date_default_timezone_set('UTC');
134
+			} else {
135
+				date_default_timezone_set('UTC');
136
+			}
131 137
 			if (is_array($all_data) && count($all_data) > 1) {
132 138
 				print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
133 139
 				print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -204,14 +210,22 @@  discard block
 block discarded – undo
204 210
 		if (isset($spotter_array[0]['airline_icao'])) {
205 211
 			print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>'; 
206 212
 		}
207
-		if ($type == 'aircraft') print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>';
213
+		if ($type == 'aircraft') {
214
+			print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>';
215
+		}
208 216
 		print '</div>';
209 217
 	
210
-		if ($type == 'aircraft') include('ident-sub-menu.php');
218
+		if ($type == 'aircraft') {
219
+			include('ident-sub-menu.php');
220
+		}
211 221
 		print '<div class="table column">';
212
-		if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
213
-		elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
214
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
222
+		if ($type == 'aircraft') {
223
+			print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
224
+		} elseif ($type == 'marine') {
225
+			print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
226
+		} elseif ($type == 'tracker') {
227
+			print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
228
+		}
215 229
 
216 230
 		include('table-output.php'); 
217 231
 		print '<div class="pagination">';
Please login to merge, or discard this patch.