Completed
Push — master ( caebd9...55f541 )
by Yannick
09:39
created
owner-statistics-airline.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -9,22 +9,22 @@  discard block
 block discarded – undo
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
12
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13
-$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING));
14
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
12
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
13
+$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING));
14
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
15
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') $filter = array_merge($filter, array('year' => $year));
18
+if ($month != '') $filter = array_merge($filter, array('month' => $month));
19 19
 $archive = false;
20
-$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
20
+$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
21 21
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
22 22
 	$archive = true;
23
-	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
23
+	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
24 24
 }
25 25
 if (!empty($spotter_array))
26 26
 {
27
-	$title = sprintf(_("Most Common Airlines of %s"),$spotter_array[0]['aircraft_owner']);
27
+	$title = sprintf(_("Most Common Airlines of %s"), $spotter_array[0]['aircraft_owner']);
28 28
 	require_once('header.php');
29 29
 	print '<div class="info column">';
30 30
 	print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 	include('owner-sub-menu.php');
36 36
 	print '<div class="column">';
37 37
 	print '<h2>'._("Most Common Airlines").'</h2>';
38
-	print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
38
+	print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights owned by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
39 39
 
40 40
 	if ($archive === false) {
41
-		$airline_array = $Spotter->countAllAirlinesByOwner($owner,$filter);
41
+		$airline_array = $Spotter->countAllAirlinesByOwner($owner, $filter);
42 42
 	} else {
43
-		$airline_array = $SpotterArchive->countAllAirlinesByOwner($owner,$filter);
43
+		$airline_array = $SpotterArchive->countAllAirlinesByOwner($owner, $filter);
44 44
 	}
45 45
 	if (!empty($airline_array))
46 46
 	{
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		print '</thead>';
57 57
 		print '<tbody>';
58 58
 		$i = 1;
59
-		foreach($airline_array as $airline_item)
59
+		foreach ($airline_array as $airline_item)
60 60
 		{
61 61
 			print '<tr>';
62 62
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
weather-json.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
 	header('Content-disposition: attachment; filename="weather.json"');
10 10
 }
11 11
 header('Content-Type: text/javascript');
12
-$latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
13
-$longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
12
+$latitude = filter_input(INPUT_GET, 'latitude', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
13
+$longitude = filter_input(INPUT_GET, 'longitude', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
14 14
 if ($latitude == '' || $longitude == '') return '';
15 15
 //echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
16
-$airports = $Spotter->closestAirports($latitude,$longitude,300);
16
+$airports = $Spotter->closestAirports($latitude, $longitude, 300);
17 17
 //print_r($airports);
18 18
 $METAR = new METAR();
19 19
 $Weather = new Weather();
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 $ew = true;
22 22
 $dtf = false;
23 23
 if (empty($airports)) $ew = false;
24
-while($ew) {
24
+while ($ew) {
25 25
 	$met = $METAR->getMETAR($airports[$i]['icao']);
26 26
 	//print_r($met);
27 27
 	if (!empty($met)) {
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 		//print_r($parsed);
30 30
 		$rain = array();
31 31
 		if (isset($parsed['temperature'])) {
32
-			$rain = array_merge($rain,array('temp' => $parsed['temperature']));
32
+			$rain = array_merge($rain, array('temp' => $parsed['temperature']));
33 33
 		}
34 34
 		if (isset($parsed['rh'])) {
35
-			$rain = array_merge($rain,array('rh' => $parsed['rh']));
35
+			$rain = array_merge($rain, array('rh' => $parsed['rh']));
36 36
 		}
37 37
 		if (isset($parsed['weather']) && $parsed['weather'] == 'CAVOK') {
38
-			echo json_encode(array('clouds' => array(),'rain' => array()));
38
+			echo json_encode(array('clouds' => array(), 'rain' => array()));
39 39
 			$ew  = false;
40 40
 			$dtf = true;
41 41
 		} elseif (isset($parsed['cloud'])) {
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 			if (!empty($result)) {
44 44
 				//print_r($met);
45 45
 				//print_r($parsed);
46
-				echo json_encode(array('clouds' => $result,'rain' => $rain));
46
+				echo json_encode(array('clouds' => $result, 'rain' => $rain));
47 47
 				$ew = false;
48 48
 				$dtf = true;
49 49
 			}
@@ -52,6 +52,6 @@  discard block
 block discarded – undo
52 52
 	$i++;
53 53
 	if ($i >= count($airports)) $ew = false;
54 54
 }
55
-if ($dtf === false) echo json_encode($Weather->openweathermap($latitude,$longitude));
55
+if ($dtf === false) echo json_encode($Weather->openweathermap($latitude, $longitude));
56 56
 
57 57
 ?>
58 58
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 1 patch
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -16,75 +16,75 @@  discard block
 block discarded – undo
16 16
      * @param bool $and
17 17
      * @return string the SQL part
18 18
      */
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
37 37
 				if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') {
38 38
 					if (isset($flt['source'])) {
39
-						$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";
39
+						$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";
40 40
 					} else {
41
-						$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";
41
+						$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";
42 42
 					}
43 43
 				}
44 44
 			}
45 45
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
46 46
 				if (isset($flt['source'])) {
47
-					$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";
47
+					$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";
48 48
 				} else {
49
-					$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";
49
+					$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";
50 50
 				}
51 51
 			}
52 52
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
53 53
 				if (isset($flt['source'])) {
54
-					$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";
54
+					$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";
55 55
 				} else {
56
-					$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";
56
+					$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";
57 57
 				}
58 58
 			}
59 59
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
60 60
 				if (isset($flt['source'])) {
61
-					$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";
61
+					$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";
62 62
 				} else {
63
-					$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";
63
+					$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";
64 64
 				}
65 65
 			}
66 66
 			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']))) {
67 67
 				if (isset($flt['source'])) {
68
-					$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";
68
+					$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";
69 69
 				}
70 70
 			}
71 71
 		}
72 72
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
73 73
 			if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') {
74
-				$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";
74
+				$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";
75 75
 			}
76 76
 		}
77 77
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
78 78
 			$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 ";
79 79
 		}
80 80
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
81
-			$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";
81
+			$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";
82 82
 		}
83 83
 		if (isset($filter['source']) && !empty($filter['source'])) {
84 84
 			if (count($filter['source']) == 1) {
85 85
 				$filter_query_where .= " AND format_source = '".$filter['source'][0]."'";
86 86
 			} else {
87
-				$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
87
+				$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
88 88
 			}
89 89
 		}
90 90
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 			$filter_query_where .= " AND flightaware_id = '".$filter['id']."'";
95 95
 		}
96 96
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
97
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
97
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
98 98
 		}
99 99
 		if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
100 100
 			$filter_query_date = '';
@@ -119,41 +119,41 @@  discard block
 block discarded – undo
119 119
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
120 120
 				}
121 121
 			}
122
-			$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";
122
+			$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";
123 123
 		}
124 124
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
125 125
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
126 126
 		if ($filter_query_where != '') {
127
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
127
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
128 128
 		}
129 129
 		$filter_query = $filter_query_join.$filter_query_where;
130 130
 		return $filter_query;
131 131
 	}
132 132
 
133 133
 	// Spotter_archive
134
-	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 = '') {
134
+	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 = '') {
135 135
 		require_once(dirname(__FILE__).'/class.Spotter.php');
136 136
 		if ($over_country == '') {
137 137
 			$Spotter = new Spotter($this->db);
138
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
138
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
139 139
 			if (!empty($data_country)) $country = $data_country['iso2'];
140 140
 			else $country = '';
141 141
 		} else $country = $over_country;
142
-		if ($airline_type === NULL) $airline_type ='';
142
+		if ($airline_type === NULL) $airline_type = '';
143 143
 
144 144
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
145 145
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
146 146
 
147 147
 		// Route is not added in spotter_archive
148
-		$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)
148
+		$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)
149 149
 		          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)";
150 150
 
151
-		$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);
151
+		$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);
152 152
 		try {
153 153
 			$sth = $this->db->prepare($query);
154 154
 			$sth->execute($query_values);
155 155
 			$sth->closeCursor();
156
-		} catch(PDOException $e) {
156
+		} catch (PDOException $e) {
157 157
 			return "error : ".$e->getMessage();
158 158
 		}
159 159
 		return "success";
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 
173 173
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
174 174
 		//$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";
175
-		$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
175
+		$query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
176 176
 
177
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
177
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
178 178
 
179 179
 		return $spotter_array;
180 180
 	}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
193 193
 		//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
194 194
 		//$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";
195
-		$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
195
+		$query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
196 196
 
197 197
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
198 198
 		/*
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 		}
206 206
 		$spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
207 207
 		*/
208
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
208
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
209 209
 
210 210
 		return $spotter_array;
211 211
 	}
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
 	public function getAllArchiveSpotterDataById($id) {
220 220
 		date_default_timezone_set('UTC');
221 221
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
222
-		$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
222
+		$query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
223 223
 
224 224
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
225 225
 
226 226
 		try {
227 227
 			$sth = $this->db->prepare($query);
228 228
 			$sth->execute(array(':id' => $id));
229
-		} catch(PDOException $e) {
229
+		} catch (PDOException $e) {
230 230
 			echo $e->getMessage();
231 231
 			die;
232 232
 		}
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 	public function getCoordArchiveSpotterDataById($id) {
245 245
 		date_default_timezone_set('UTC');
246 246
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
247
-		$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC";
247
+		$query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC";
248 248
 		try {
249 249
 			$sth = $this->db->prepare($query);
250 250
 			$sth->execute(array(':id' => $id));
251
-		} catch(PDOException $e) {
251
+		} catch (PDOException $e) {
252 252
 			echo $e->getMessage();
253 253
 			die;
254 254
 		}
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
      * @param $enddate
265 265
      * @return array the spotter information
266 266
      */
267
-	public function getCoordArchiveSpotterDataByIdDate($id,$begindate,$enddate) {
267
+	public function getCoordArchiveSpotterDataByIdDate($id, $begindate, $enddate) {
268 268
 		date_default_timezone_set('UTC');
269 269
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
270
-		$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.date BETWEEN :begindate AND :enddate ORDER by spotter_archive.date ASC";
270
+		$query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.date BETWEEN :begindate AND :enddate ORDER by spotter_archive.date ASC";
271 271
 		try {
272 272
 			$sth = $this->db->prepare($query);
273
-			$sth->execute(array(':id' => $id,':begindate' => $begindate,':enddate' => $enddate));
274
-		} catch(PDOException $e) {
273
+			$sth->execute(array(':id' => $id, ':begindate' => $begindate, ':enddate' => $enddate));
274
+		} catch (PDOException $e) {
275 275
 			echo $e->getMessage();
276 276
 			die;
277 277
 		}
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 		date_default_timezone_set('UTC');
292 292
 
293 293
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
294
-		$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";
294
+		$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";
295 295
 
296 296
 		try {
297 297
 			$sth = $this->db->prepare($query);
298 298
 			$sth->execute(array(':ident' => $ident));
299
-		} catch(PDOException $e) {
299
+		} catch (PDOException $e) {
300 300
 			echo $e->getMessage();
301 301
 			die;
302 302
 		}
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
 		date_default_timezone_set('UTC');
317 317
 
318 318
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
319
-		$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";
319
+		$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";
320 320
 
321 321
 		try {
322 322
 			$sth = $this->db->prepare($query);
323 323
 			$sth->execute(array(':id' => $id));
324
-		} catch(PDOException $e) {
324
+		} catch (PDOException $e) {
325 325
 			echo $e->getMessage();
326 326
 			die;
327 327
 		}
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 	public function getAltitudeSpeedArchiveSpotterDataById($id) {
340 340
 		date_default_timezone_set('UTC');
341 341
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
342
-		$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";
342
+		$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";
343 343
 		try {
344 344
 			$sth = $this->db->prepare($query);
345 345
 			$sth->execute(array(':id' => $id));
346
-		} catch(PDOException $e) {
346
+		} catch (PDOException $e) {
347 347
 			echo $e->getMessage();
348 348
 			die;
349 349
 		}
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
 	public function getLastAltitudeArchiveSpotterDataByIdent($ident) {
361 361
 		date_default_timezone_set('UTC');
362 362
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
363
-		$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";
363
+		$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";
364 364
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
365 365
 		try {
366 366
 			$sth = $this->db->prepare($query);
367 367
 			$sth->execute(array(':ident' => $ident));
368
-		} catch(PDOException $e) {
368
+		} catch (PDOException $e) {
369 369
 			echo $e->getMessage();
370 370
 			die;
371 371
 		}
@@ -382,11 +382,11 @@  discard block
 block discarded – undo
382 382
      * @param $date
383 383
      * @return array the spotter information
384 384
      */
385
-	public function getSpotterArchiveData($ident,$flightaware_id,$date) {
385
+	public function getSpotterArchiveData($ident, $flightaware_id, $date) {
386 386
 		$Spotter = new Spotter($this->db);
387 387
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
388
-		$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";
389
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
388
+		$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";
389
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
390 390
 		return $spotter_array;
391 391
 	}
392 392
 
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 		try {
401 401
 			$sth = $this->db->prepare($query);
402 402
 			$sth->execute();
403
-		} catch(PDOException $e) {
403
+		} catch (PDOException $e) {
404 404
 			echo $e->getMessage();
405 405
 			die;
406 406
 		}
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 		try {
417 417
 			$sth = $this->db->prepare($query);
418 418
 			$sth->execute(array(':id' => $id));
419
-		} catch(PDOException $e) {
419
+		} catch (PDOException $e) {
420 420
 			echo $e->getMessage();
421 421
 			die;
422 422
 		}
@@ -431,39 +431,39 @@  discard block
 block discarded – undo
431 431
      * @param int $part
432 432
      * @return array the spotter information
433 433
      */
434
-	public function getMinLiveSpotterData($begindate,$enddate,$filter = array(),$part = 0) {
434
+	public function getMinLiveSpotterData($begindate, $enddate, $filter = array(), $part = 0) {
435 435
 		global $globalDBdriver;
436 436
 		date_default_timezone_set('UTC');
437 437
 		//$filter_query = $this->getFilter($filter,true,true);
438 438
 
439 439
 		$filter_query = '';
440 440
 		if (isset($filter['source']) && !empty($filter['source'])) {
441
-			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
441
+			$filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
442 442
 		}
443 443
 		// Use spotter_output also ?
444 444
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
445
-			$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 ";
445
+			$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 ";
446 446
 		}
447 447
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
448 448
 			$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 ";
449 449
 		}
450 450
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
451
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
451
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
452 452
 		}
453 453
 
454 454
 		$limit = '';
455 455
 		if ($part != 0) {
456
-			$limit = ' LIMIT 100 OFFSET '.($part-1)*100;
456
+			$limit = ' LIMIT 100 OFFSET '.($part - 1)*100;
457 457
 		}
458 458
 		if ($globalDBdriver == 'mysql') {
459
-			$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
459
+			$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
460 460
 			          FROM spotter_archive
461 461
 			          INNER JOIN aircraft a on spotter_archive.aircraft_icao = a.icao
462 462
 			          WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".'
463 463
 			          '.$filter_query.' ORDER BY flightaware_id'.$limit;
464 464
 		} else {
465 465
 			
466
-			$query  = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, 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
466
+			$query = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, 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
467 467
 			          FROM spotter_archive
468 468
 			          INNER JOIN aircraft a on spotter_archive.aircraft_icao = a.icao
469 469
 			          WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".'
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 		try {
474 474
 			$sth = $this->db->prepare($query);
475 475
 			$sth->execute();
476
-		} catch(PDOException $e) {
476
+		} catch (PDOException $e) {
477 477
 			echo $e->getMessage();
478 478
 			die;
479 479
 		}
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
      * @param array $filter
490 490
      * @return array the spotter information
491 491
      */
492
-	public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) {
492
+	public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) {
493 493
 		global $globalDBdriver;
494 494
 		date_default_timezone_set('UTC');
495 495
 
@@ -497,17 +497,17 @@  discard block
 block discarded – undo
497 497
 
498 498
 		$filter_query = '';
499 499
 		if (isset($filter['source']) && !empty($filter['source'])) {
500
-			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
500
+			$filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
501 501
 		}
502 502
 		// Use spotter_output also ?
503 503
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
504
-			$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 ";
504
+			$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 ";
505 505
 		}
506 506
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
507 507
 			$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 ";
508 508
 		}
509 509
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
510
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
510
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
511 511
 		}
512 512
 
513 513
 
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 				    FROM spotter_archive
519 519
 				    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';
520 520
 			*/
521
-			$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
521
+			$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
522 522
 			          FROM spotter_archive_output
523 523
 			          LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao
524 524
 			          WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".')
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 			 	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
534 534
 			 	    '.$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';
535 535
 			 */
536
-			$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
536
+			$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
537 537
 			          FROM spotter_archive_output
538 538
 			          INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
539 539
 			          WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 		try {
546 546
 			$sth = $this->db->prepare($query);
547 547
 			$sth->execute();
548
-		} catch(PDOException $e) {
548
+		} catch (PDOException $e) {
549 549
 			echo $e->getMessage();
550 550
 			die;
551 551
 		}
@@ -562,22 +562,22 @@  discard block
 block discarded – undo
562 562
      * @param array $filter
563 563
      * @return array the spotter information
564 564
      */
565
-	public function getLiveSpotterCount($begindate,$enddate,$filter = array()) {
565
+	public function getLiveSpotterCount($begindate, $enddate, $filter = array()) {
566 566
 		global $globalDBdriver, $globalLiveInterval;
567 567
 		date_default_timezone_set('UTC');
568 568
 
569 569
 		$filter_query = '';
570 570
 		if (isset($filter['source']) && !empty($filter['source'])) {
571
-			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
571
+			$filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
572 572
 		}
573 573
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
574
-			$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 ";
574
+			$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 ";
575 575
 		}
576 576
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
577 577
 			$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 ";
578 578
 		}
579 579
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
580
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
580
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
581 581
 		}
582 582
 
583 583
 		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 		try {
593 593
 			$sth = $this->db->prepare($query);
594 594
 			$sth->execute();
595
-		} catch(PDOException $e) {
595
+		} catch (PDOException $e) {
596 596
 			echo $e->getMessage();
597 597
 			die;
598 598
 		}
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
      * @param array $filters
637 637
      * @return array the spotter information
638 638
      */
639
-	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()) {
639
+	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()) {
640 640
 		global $globalTimezone, $globalDBdriver;
641 641
 		require_once(dirname(__FILE__).'/class.Translation.php');
642 642
 		$Translation = new Translation($this->db);
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 		}
687 687
 
688 688
 		if ($registration != "") {
689
-			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
689
+			$registration = filter_var($registration, FILTER_SANITIZE_STRING);
690 690
 			if (!is_string($registration)) {
691 691
 				return array();
692 692
 			} else {
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 		}
696 696
 
697 697
 		if ($aircraft_icao != "") {
698
-			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
698
+			$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
699 699
 			if (!is_string($aircraft_icao)) {
700 700
 				return array();
701 701
 			} else {
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		}
705 705
 
706 706
 		if ($aircraft_manufacturer != "") {
707
-			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
707
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
708 708
 			if (!is_string($aircraft_manufacturer)) {
709 709
 				return array();
710 710
 			} else {
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 		}
722 722
 
723 723
 		if ($airline_icao != "") {
724
-			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
724
+			$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
725 725
 			if (!is_string($airline_icao)) {
726 726
 				return array();
727 727
 			} else {
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 		}
731 731
 
732 732
 		if ($airline_country != "") {
733
-			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
733
+			$airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
734 734
 			if (!is_string($airline_country)) {
735 735
 				return array();
736 736
 			} else {
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 		}
740 740
 
741 741
 		if ($airline_type != "") {
742
-			$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
742
+			$airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
743 743
 			if (!is_string($airline_type)) {
744 744
 				return array();
745 745
 			} else {
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 		}
757 757
 
758 758
 		if ($airport != "") {
759
-			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
759
+			$airport = filter_var($airport, FILTER_SANITIZE_STRING);
760 760
 			if (!is_string($airport)) {
761 761
 				return array();
762 762
 			} else {
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 		}
766 766
 
767 767
 		if ($airport_country != "") {
768
-			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
768
+			$airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
769 769
 			if (!is_string($airport_country)) {
770 770
 				return array();
771 771
 			} else {
@@ -774,14 +774,14 @@  discard block
 block discarded – undo
774 774
 		}
775 775
 
776 776
 		if ($callsign != "") {
777
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
777
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
778 778
 			if (!is_string($callsign)) {
779 779
 				return array();
780 780
 			} else {
781 781
 				$translate = $Translation->ident2icao($callsign);
782 782
 				if ($translate != $callsign) {
783 783
 					$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
784
-					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
784
+					$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
785 785
 				} else {
786 786
 					$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
787 787
 				}
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 		}
790 790
 
791 791
 		if ($owner != "") {
792
-			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
792
+			$owner = filter_var($owner, FILTER_SANITIZE_STRING);
793 793
 			if (!is_string($owner)) {
794 794
 				return array();
795 795
 			} else {
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 		}
799 799
 
800 800
 		if ($pilot_name != "") {
801
-			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
801
+			$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
802 802
 			if (!is_string($pilot_name)) {
803 803
 				return array();
804 804
 			} else {
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 		}
808 808
 
809 809
 		if ($pilot_id != "") {
810
-			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
810
+			$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
811 811
 			if (!is_string($pilot_id)) {
812 812
 				return array();
813 813
 			} else {
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 		}
817 817
 
818 818
 		if ($departure_airport_route != "") {
819
-			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
819
+			$departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
820 820
 			if (!is_string($departure_airport_route)) {
821 821
 				return array();
822 822
 			} else {
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 		}
826 826
 
827 827
 		if ($arrival_airport_route != "") {
828
-			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
828
+			$arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
829 829
 			if (!is_string($arrival_airport_route)) {
830 830
 				return array();
831 831
 			} else {
@@ -836,8 +836,8 @@  discard block
 block discarded – undo
836 836
 		if ($altitude != "") {
837 837
 			$altitude_array = explode(",", $altitude);
838 838
 
839
-			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
840
-			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
839
+			$altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
840
+			$altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
841 841
 
842 842
 
843 843
 			if ($altitude_array[1] != "") {
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
 
853 853
 		if ($date_posted != "") {
854 854
 			$date_array = explode(",", $date_posted);
855
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
856
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
855
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
856
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
857 857
 			if ($globalTimezone != '') {
858 858
 				date_default_timezone_set($globalTimezone);
859 859
 				$datetime = new DateTime();
@@ -878,16 +878,16 @@  discard block
 block discarded – undo
878 878
 		}
879 879
 		if ($limit != "") {
880 880
 			$limit_array = explode(",", $limit);
881
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
882
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
881
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
882
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
883 883
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) {
884 884
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
885 885
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
886 886
 			}
887 887
 		}
888 888
 		if ($origLat != "" && $origLon != "" && $dist != "") {
889
-			$dist = number_format($dist*0.621371,2,'.','');
890
-			$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
889
+			$dist = number_format($dist*0.621371, 2, '.', '');
890
+			$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
891 891
 			       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))
892 892
 			       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";
893 893
 		} else {
@@ -901,12 +901,12 @@  discard block
 block discarded – undo
901 901
 				$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
902 902
 			}
903 903
 
904
-			$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output
904
+			$query = "SELECT spotter_archive_output.* FROM spotter_archive_output
905 905
 			          WHERE spotter_archive_output.ident <> ''
906 906
 			          ".$additional_query."
907 907
 			          ".$filter_query.$orderby_query;
908 908
 		}
909
-		$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
909
+		$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
910 910
 		return $spotter_array;
911 911
 	}
912 912
 
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
 			$sth = $this->db->prepare($query);
923 923
 			$sth->execute();
924 924
 			return '';
925
-		} catch(PDOException $e) {
925
+		} catch (PDOException $e) {
926 926
 			return "error";
927 927
 		}
928 928
 	}
@@ -957,8 +957,8 @@  discard block
 block discarded – undo
957 957
 		if ($limit != "") {
958 958
 			$limit_array = explode(",", $limit);
959 959
 
960
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
961
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
960
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
961
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
962 962
 
963 963
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) {
964 964
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
 		$query_values = array();
1000 1000
 		$limit_query = '';
1001 1001
 		$additional_query = '';
1002
-		$filter_query = $this->getFilter($filter,true,true);
1002
+		$filter_query = $this->getFilter($filter, true, true);
1003 1003
 
1004 1004
 		if ($owner != "") {
1005 1005
 			if (!is_string($owner)) {
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
 		if ($limit != "") {
1014 1014
 			$limit_array = explode(",", $limit);
1015 1015
 
1016
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1017
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1016
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1017
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1018 1018
 
1019 1019
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0 && $limit_array[0] != '' && $limit_array[1] != '') {
1020 1020
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
 		$query_values = array();
1055 1055
 		$limit_query = '';
1056 1056
 		$additional_query = '';
1057
-		$filter_query = $this->getFilter($filter,true,true);
1057
+		$filter_query = $this->getFilter($filter, true, true);
1058 1058
 
1059 1059
 		if ($pilot != "") {
1060 1060
 			$additional_query = " AND (spotter_archive_output.pilot_id = :pilot OR spotter_archive_output.pilot_name = :pilot)";
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
 		if ($limit != "") {
1065 1065
 			$limit_array = explode(",", $limit);
1066 1066
 
1067
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1068
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1067
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1068
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1069 1069
 
1070 1070
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) {
1071 1071
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
      * @param string $sincedate
1096 1096
      * @return array the airline country list
1097 1097
      */
1098
-	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') {
1098
+	public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') {
1099 1099
 		global $globalDBdriver;
1100 1100
 		/*
1101 1101
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 		$flight_array = array();
1124 1124
 		$temp_array = array();
1125 1125
 
1126
-		while($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1126
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1127 1127
 			$temp_array['flight_count'] = $row['nb'];
1128 1128
 			$temp_array['flight_country'] = $row['name'];
1129 1129
 			$temp_array['flight_country_iso3'] = $row['iso3'];
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
      * @param string $sincedate
1142 1142
      * @return array the airline country list
1143 1143
      */
1144
-	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') {
1144
+	public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') {
1145 1145
 		global $globalDBdriver;
1146 1146
 		/*
1147 1147
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 		$flight_array = array();
1170 1170
 		$temp_array = array();
1171 1171
 
1172
-		while($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1172
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1173 1173
 			$temp_array['airline_icao'] = $row['airline_icao'];
1174 1174
 			$temp_array['flight_count'] = $row['nb'];
1175 1175
 			$temp_array['flight_country'] = $row['name'];
@@ -1187,16 +1187,16 @@  discard block
 block discarded – undo
1187 1187
      * @param array $filters
1188 1188
      * @return array the aircraft list
1189 1189
      */
1190
-	public function countAllAircraftTypesByOwner($owner,$filters = array())
1190
+	public function countAllAircraftTypesByOwner($owner, $filters = array())
1191 1191
 	{
1192
-		$filter_query = $this->getFilter($filters,true,true);
1193
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
1192
+		$filter_query = $this->getFilter($filters, true, true);
1193
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
1194 1194
 		$query  = "SELECT DISTINCT spotter_archive_output.aircraft_icao, COUNT(spotter_archive_output.aircraft_icao) AS aircraft_icao_count, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer 
1195 1195
 		    FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner";
1196 1196
 		$query_values = array();
1197 1197
 		$query .= " GROUP BY spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.aircraft_icao
1198 1198
 		    ORDER BY aircraft_icao_count DESC";
1199
-		$query_values = array_merge($query_values,array(':owner' => $owner));
1199
+		$query_values = array_merge($query_values, array(':owner' => $owner));
1200 1200
 		$sth = $this->db->prepare($query);
1201 1201
 		$sth->execute($query_values);
1202 1202
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1209,11 +1209,11 @@  discard block
 block discarded – undo
1209 1209
      * @param array $filters
1210 1210
      * @return array the airline list
1211 1211
      */
1212
-	public function countAllAirlinesByOwner($owner,$filters = array())
1212
+	public function countAllAirlinesByOwner($owner, $filters = array())
1213 1213
 	{
1214
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
1215
-		$filter_query = $this->getFilter($filters,true,true);
1216
-		$query  = "SELECT DISTINCT spotter_archive_output.airline_name, spotter_archive_output.airline_icao, spotter_archive_output.airline_country, COUNT(spotter_archive_output.airline_name) AS airline_count
1214
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
1215
+		$filter_query = $this->getFilter($filters, true, true);
1216
+		$query = "SELECT DISTINCT spotter_archive_output.airline_name, spotter_archive_output.airline_icao, spotter_archive_output.airline_country, COUNT(spotter_archive_output.airline_name) AS airline_count
1217 1217
 		    FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner  
1218 1218
 		    GROUP BY spotter_archive_output.airline_icao, spotter_archive_output.airline_name, spotter_archive_output.airline_country
1219 1219
 		    ORDER BY airline_count DESC";
@@ -1232,9 +1232,9 @@  discard block
 block discarded – undo
1232 1232
      */
1233 1233
 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array())
1234 1234
 	{
1235
-		$filter_query = $this->getFilter($filters,true,true);
1236
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
1237
-		$query  = "SELECT DISTINCT spotter_archive_output.arrival_airport_country, COUNT(spotter_archive_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 
1235
+		$filter_query = $this->getFilter($filters, true, true);
1236
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
1237
+		$query = "SELECT DISTINCT spotter_archive_output.arrival_airport_country, COUNT(spotter_archive_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 
1238 1238
 		    FROM countries, spotter_archive_output".$filter_query." spotter_archive_output.arrival_airport_country <> '' AND spotter_archive_output.owner_name = :owner AND countries.name = spotter_archive_output.arrival_airport_country 
1239 1239
 		    GROUP BY spotter_archive_output.arrival_airport_country, countries.iso3
1240 1240
 		    ORDER BY airport_arrival_country_count DESC";
@@ -1250,11 +1250,11 @@  discard block
 block discarded – undo
1250 1250
      * @param array $filters
1251 1251
      * @return array the airport list
1252 1252
      */
1253
-	public function countAllArrivalAirportsByOwner($owner,$filters = array())
1253
+	public function countAllArrivalAirportsByOwner($owner, $filters = array())
1254 1254
 	{
1255
-		$filter_query = $this->getFilter($filters,true,true);
1256
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
1257
-		$query  = "SELECT DISTINCT spotter_archive_output.arrival_airport_icao, COUNT(spotter_archive_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country 
1255
+		$filter_query = $this->getFilter($filters, true, true);
1256
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
1257
+		$query = "SELECT DISTINCT spotter_archive_output.arrival_airport_icao, COUNT(spotter_archive_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country 
1258 1258
 		    FROM spotter_archive_output".$filter_query." spotter_archive_output.arrival_airport_name <> '' AND spotter_archive_output.arrival_airport_icao <> 'NA' AND spotter_archive_output.arrival_airport_icao <> '' AND spotter_archive_output.owner_name = :owner 
1259 1259
 		    GROUP BY spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country
1260 1260
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 		$sth->execute(array(':owner' => $owner));
1263 1263
 		$airport_array = array();
1264 1264
 		$temp_array = array();
1265
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1265
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1266 1266
 		{
1267 1267
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
1268 1268
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -1281,11 +1281,11 @@  discard block
 block discarded – undo
1281 1281
      * @param array $filters
1282 1282
      * @return array the airport list
1283 1283
      */
1284
-	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array())
1284
+	public function countAllDepartureAirportCountriesByOwner($owner, $filters = array())
1285 1285
 	{
1286
-		$filter_query = $this->getFilter($filters,true,true);
1287
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
1288
-		$query  = "SELECT DISTINCT spotter_archive_output.departure_airport_country, COUNT(spotter_archive_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS airport_departure_country_iso3
1286
+		$filter_query = $this->getFilter($filters, true, true);
1287
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
1288
+		$query = "SELECT DISTINCT spotter_archive_output.departure_airport_country, COUNT(spotter_archive_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS airport_departure_country_iso3
1289 1289
 		    FROM spotter_archive_output,countries".$filter_query." spotter_archive_output.departure_airport_country <> '' AND spotter_archive_output.owner_name = :owner  AND countries.name = spotter_archive_output.departure_airport_country 
1290 1290
 		    GROUP BY spotter_archive_output.departure_airport_country, countries.iso3
1291 1291
 		    ORDER BY airport_departure_country_count DESC";
@@ -1301,11 +1301,11 @@  discard block
 block discarded – undo
1301 1301
      * @param array $filters
1302 1302
      * @return array the airport list
1303 1303
      */
1304
-	public function countAllDepartureAirportsByOwner($owner,$filters = array())
1304
+	public function countAllDepartureAirportsByOwner($owner, $filters = array())
1305 1305
 	{
1306
-		$filter_query = $this->getFilter($filters,true,true);
1307
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
1308
-		$query  = "SELECT DISTINCT spotter_archive_output.departure_airport_icao, COUNT(spotter_archive_output.departure_airport_icao) AS airport_departure_icao_count, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, airport.latitude, airport.longitude 
1306
+		$filter_query = $this->getFilter($filters, true, true);
1307
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
1308
+		$query = "SELECT DISTINCT spotter_archive_output.departure_airport_icao, COUNT(spotter_archive_output.departure_airport_icao) AS airport_departure_icao_count, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, airport.latitude, airport.longitude 
1309 1309
 		    FROM spotter_archive_output,airport".$filter_query." spotter_archive_output.departure_airport_name <> '' AND spotter_archive_output.departure_airport_icao <> 'NA' AND spotter_archive_output.departure_airport_icao <> '' AND spotter_archive_output.owner_name = :owner AND airport.icao = spotter_archive_output.departure_airport_icao 
1310 1310
 		    GROUP BY spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, airport.latitude, airport.longitude
1311 1311
 		    ORDER BY airport_departure_icao_count DESC";
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
 		$sth->execute(array(':owner' => $owner));
1314 1314
 		$airport_array = array();
1315 1315
 		$temp_array = array();
1316
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1316
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1317 1317
 		{
1318 1318
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
1319 1319
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -1334,14 +1334,14 @@  discard block
 block discarded – undo
1334 1334
      * @param array $filters
1335 1335
      * @return array the aircraft manufacturer list
1336 1336
      */
1337
-	public function countAllAircraftManufacturerByOwner($owner,$filters = array())
1337
+	public function countAllAircraftManufacturerByOwner($owner, $filters = array())
1338 1338
 	{
1339
-		$filter_query = $this->getFilter($filters,true,true);
1340
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
1341
-		$query  = "SELECT DISTINCT spotter_archive_output.aircraft_manufacturer, COUNT(spotter_archive_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
1339
+		$filter_query = $this->getFilter($filters, true, true);
1340
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
1341
+		$query = "SELECT DISTINCT spotter_archive_output.aircraft_manufacturer, COUNT(spotter_archive_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
1342 1342
 		    FROM spotter_archive_output".$filter_query." spotter_archive_output.aircraft_manufacturer <> '' AND spotter_archive_output.owner_name = :owner";
1343 1343
 		$query_values = array();
1344
-		$query_values = array_merge($query_values,array(':owner' => $owner));
1344
+		$query_values = array_merge($query_values, array(':owner' => $owner));
1345 1345
 		$query .= " GROUP BY spotter_archive_output.aircraft_manufacturer 
1346 1346
 		    ORDER BY aircraft_manufacturer_count DESC";
1347 1347
 		$sth = $this->db->prepare($query);
@@ -1356,22 +1356,22 @@  discard block
 block discarded – undo
1356 1356
      * @param array $filters
1357 1357
      * @return array the aircraft list
1358 1358
      */
1359
-	public function countAllAircraftRegistrationByOwner($owner,$filters = array())
1359
+	public function countAllAircraftRegistrationByOwner($owner, $filters = array())
1360 1360
 	{
1361
-		$filter_query = $this->getFilter($filters,true,true);
1361
+		$filter_query = $this->getFilter($filters, true, true);
1362 1362
 		$Image = new Image($this->db);
1363
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
1364
-		$query  = "SELECT DISTINCT spotter_archive_output.aircraft_icao, COUNT(spotter_archive_output.registration) AS registration_count, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.registration, spotter_archive_output.airline_name  
1363
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
1364
+		$query = "SELECT DISTINCT spotter_archive_output.aircraft_icao, COUNT(spotter_archive_output.registration) AS registration_count, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.registration, spotter_archive_output.airline_name  
1365 1365
 		    FROM spotter_archive_output".$filter_query." spotter_archive_output.registration <> '' AND spotter_archive_output.owner_name = :owner";
1366 1366
 		$query_values = array();
1367
-		$query_values = array_merge($query_values,array(':owner' => $owner));
1367
+		$query_values = array_merge($query_values, array(':owner' => $owner));
1368 1368
 		$query .= " GROUP BY spotter_archive_output.registration,spotter_archive_output.aircraft_icao, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.airline_name
1369 1369
 		    ORDER BY registration_count DESC";
1370 1370
 		$sth = $this->db->prepare($query);
1371 1371
 		$sth->execute($query_values);
1372 1372
 		$aircraft_array = array();
1373 1373
 		$temp_array = array();
1374
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1374
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1375 1375
 		{
1376 1376
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
1377 1377
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
 			$temp_array['registration'] = $row['registration'];
1380 1380
 			$temp_array['airline_name'] = $row['airline_name'];
1381 1381
 			$temp_array['image_thumbnail'] = "";
1382
-			if($row['registration'] != "")
1382
+			if ($row['registration'] != "")
1383 1383
 			{
1384 1384
 				$image_array = $Image->getSpotterImage($row['registration']);
1385 1385
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -1398,11 +1398,11 @@  discard block
 block discarded – undo
1398 1398
      * @param array $filters
1399 1399
      * @return array the route list
1400 1400
      */
1401
-	public function countAllRoutesByOwner($owner,$filters = array())
1401
+	public function countAllRoutesByOwner($owner, $filters = array())
1402 1402
 	{
1403
-		$filter_query = $this->getFilter($filters,true,true);
1404
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
1405
-		$query  = "SELECT DISTINCT concat(spotter_archive_output.departure_airport_icao, ' - ',  spotter_archive_output.arrival_airport_icao) AS route, count(concat(spotter_archive_output.departure_airport_icao, ' - ', spotter_archive_output.arrival_airport_icao)) AS route_count, spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name AS airport_departure_name, spotter_archive_output.departure_airport_city AS airport_departure_city, spotter_archive_output.departure_airport_country AS airport_departure_country, spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name AS airport_arrival_name, spotter_archive_output.arrival_airport_city AS airport_arrival_city, spotter_archive_output.arrival_airport_country AS airport_arrival_country
1403
+		$filter_query = $this->getFilter($filters, true, true);
1404
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
1405
+		$query = "SELECT DISTINCT concat(spotter_archive_output.departure_airport_icao, ' - ',  spotter_archive_output.arrival_airport_icao) AS route, count(concat(spotter_archive_output.departure_airport_icao, ' - ', spotter_archive_output.arrival_airport_icao)) AS route_count, spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name AS airport_departure_name, spotter_archive_output.departure_airport_city AS airport_departure_city, spotter_archive_output.departure_airport_country AS airport_departure_country, spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name AS airport_arrival_name, spotter_archive_output.arrival_airport_city AS airport_arrival_city, spotter_archive_output.arrival_airport_country AS airport_arrival_country
1406 1406
 		    FROM spotter_archive_output".$filter_query." spotter_archive_output.ident <> '' AND spotter_archive_output.owner_name = :owner 
1407 1407
 		    GROUP BY route, spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country
1408 1408
 		    ORDER BY route_count DESC";
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 		$sth->execute(array(':owner' => $owner));
1411 1411
 		$routes_array = array();
1412 1412
 		$temp_array = array();
1413
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1413
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1414 1414
 		{
1415 1415
 			$temp_array['route_count'] = $row['route_count'];
1416 1416
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -1436,8 +1436,8 @@  discard block
 block discarded – undo
1436 1436
 	public function countAllHoursByOwner($owner, $filters = array())
1437 1437
 	{
1438 1438
 		global $globalTimezone, $globalDBdriver;
1439
-		$filter_query = $this->getFilter($filters,true,true);
1440
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
1439
+		$filter_query = $this->getFilter($filters, true, true);
1440
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
1441 1441
 		if ($globalTimezone != '') {
1442 1442
 			date_default_timezone_set($globalTimezone);
1443 1443
 			$datetime = new DateTime();
@@ -1449,16 +1449,16 @@  discard block
 block discarded – undo
1449 1449
 			    GROUP BY hour_name 
1450 1450
 			    ORDER BY hour_name ASC";
1451 1451
 		} else {
1452
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_archive_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1452
+			$query = "SELECT EXTRACT(HOUR FROM spotter_archive_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1453 1453
 			    FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner 
1454 1454
 			    GROUP BY hour_name 
1455 1455
 			    ORDER BY hour_name ASC";
1456 1456
 		}
1457 1457
 		$sth = $this->db->prepare($query);
1458
-		$sth->execute(array(':owner' => $owner,':offset' => $offset));
1458
+		$sth->execute(array(':owner' => $owner, ':offset' => $offset));
1459 1459
 		$hour_array = array();
1460 1460
 		$temp_array = array();
1461
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1461
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1462 1462
 		{
1463 1463
 			$temp_array['hour_name'] = $row['hour_name'];
1464 1464
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1474,13 +1474,13 @@  discard block
 block discarded – undo
1474 1474
      * @param $date
1475 1475
      * @return array the spotter information
1476 1476
      */
1477
-	public function getDateArchiveSpotterDataById($id,$date) {
1477
+	public function getDateArchiveSpotterDataById($id, $date) {
1478 1478
 		$Spotter = new Spotter($this->db);
1479 1479
 		date_default_timezone_set('UTC');
1480 1480
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
1481
-		$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';
1482
-		$date = date('c',$date);
1483
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1481
+		$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';
1482
+		$date = date('c', $date);
1483
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1484 1484
 		return $spotter_array;
1485 1485
 	}
1486 1486
 
@@ -1491,13 +1491,13 @@  discard block
 block discarded – undo
1491 1491
      * @param $date
1492 1492
      * @return array the spotter information
1493 1493
      */
1494
-	public function getDateArchiveSpotterDataByIdent($ident,$date) {
1494
+	public function getDateArchiveSpotterDataByIdent($ident, $date) {
1495 1495
 		$Spotter = new Spotter($this->db);
1496 1496
 		date_default_timezone_set('UTC');
1497 1497
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1498
-		$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';
1499
-		$date = date('c',$date);
1500
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1498
+		$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';
1499
+		$date = date('c', $date);
1500
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1501 1501
 		return $spotter_array;
1502 1502
 	}
1503 1503
 
@@ -1510,14 +1510,14 @@  discard block
 block discarded – undo
1510 1510
      * @param array $filters
1511 1511
      * @return array the spotter information
1512 1512
      */
1513
-	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) {
1513
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) {
1514 1514
 		global $global_query;
1515 1515
 		$Spotter = new Spotter($this->db);
1516 1516
 		date_default_timezone_set('UTC');
1517 1517
 		$query_values = array();
1518 1518
 		$limit_query = '';
1519 1519
 		$additional_query = '';
1520
-		$filter_query = $this->getFilter($filters,true,true);
1520
+		$filter_query = $this->getFilter($filters, true, true);
1521 1521
 
1522 1522
 		if ($airport != "") {
1523 1523
 			if (!is_string($airport)) {
@@ -1531,8 +1531,8 @@  discard block
 block discarded – undo
1531 1531
 		if ($limit != "") {
1532 1532
 			$limit_array = explode(",", $limit);
1533 1533
 
1534
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1535
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1534
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1535
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1536 1536
 
1537 1537
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) {
1538 1538
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Spacing   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -30,22 +30,22 @@  discard block
 block discarded – undo
30 30
      * @param string $airline_icao
31 31
      * @return array the images list
32 32
      */
33
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
33
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
34 34
 	{
35
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
36
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
37
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
35
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
36
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
37
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
38 38
 		$reg = $registration;
39 39
 		if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
40 40
 		$reg = trim($reg);
41
-		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
41
+		$query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
42 42
 			FROM spotter_image 
43 43
 			WHERE spotter_image.registration = :registration LIMIT 1";
44 44
 		$sth = $this->db->prepare($query);
45 45
 		$sth->execute(array(':registration' => $reg));
46 46
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
47 47
 		if (!empty($result)) return $result;
48
-		elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
48
+		elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('', $aircraft_icao, $airline_icao);
49 49
 		else return array();
50 50
 	}
51 51
 
@@ -58,34 +58,34 @@  discard block
 block discarded – undo
58 58
      * @param string $type_name
59 59
      * @return array the images list
60 60
      */
61
-	public function getMarineImage($mmsi,$imo = '',$name = '',$type_name = '')
61
+	public function getMarineImage($mmsi, $imo = '', $name = '', $type_name = '')
62 62
 	{
63 63
 		global $globalMarineImagePics;
64
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
65
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
66
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
67
-		$type_name = str_replace('&#39;',"'",filter_var($type_name,FILTER_SANITIZE_STRING));
64
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
65
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
66
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
67
+		$type_name = str_replace('&#39;', "'", filter_var($type_name, FILTER_SANITIZE_STRING));
68 68
 		if (isset($globalMarineImagePics) && !empty($globalMarineImagePics)) {
69 69
 			if ($type_name != '' && isset($globalMarineImagePics['type'][$type_name])) {
70 70
 				if (!isset($globalMarineImagePics['type'][$type_name]['image_thumbnail'])) {
71 71
 					$globalMarineImagePics['type'][$type_name]['image_thumbnail'] = $globalMarineImagePics['type'][$type_name]['image'];
72 72
 				}
73
-				return array($globalMarineImagePics['type'][$type_name]+array('image_thumbnail' => '','image' => '', 'image_copyright' => '','image_source' => '','image_source_website' => ''));
73
+				return array($globalMarineImagePics['type'][$type_name] + array('image_thumbnail' => '', 'image' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
74 74
 			}
75 75
 		}
76 76
 		$name = trim($name);
77 77
 		if ($mmsi == '' && $imo == '' && $name == '') return array();
78
-		$query  = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
78
+		$query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
79 79
 			FROM marine_image 
80 80
 			WHERE marine_image.mmsi = :mmsi";
81 81
 		$query_data = array(':mmsi' => $mmsi);
82 82
 		if ($imo != '') {
83 83
 			$query .= " AND marine_image.imo = :imo";
84
-			$query_data = array_merge($query_data,array(':imo' => $imo));
84
+			$query_data = array_merge($query_data, array(':imo' => $imo));
85 85
 		}
86 86
 		if ($name != '') {
87 87
 			$query .= " AND marine_image.name = :name";
88
-			$query_data = array_merge($query_data,array(':name' => $name));
88
+			$query_data = array_merge($query_data, array(':name' => $name));
89 89
 		}
90 90
 		$query .= " LIMIT 1";
91 91
 		$sth = $this->db->prepare($query);
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
107 107
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
108 108
 		if ($copyright != '') {
109
-			$copyright = str_replace('Copyright ','',$copyright);
110
-			$copyright = str_replace('© ','',$copyright);
111
-			$copyright = str_replace('(c) ','',$copyright);
109
+			$copyright = str_replace('Copyright ', '', $copyright);
110
+			$copyright = str_replace('© ', '', $copyright);
111
+			$copyright = str_replace('(c) ', '', $copyright);
112 112
 		}
113 113
 		return $copyright;
114 114
 	}
@@ -121,25 +121,25 @@  discard block
 block discarded – undo
121 121
      * @param string $airline_icao
122 122
      * @return String either success or error
123 123
      */
124
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
124
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
125 125
 	{
126
-		global $globalDebug,$globalAircraftImageFetch, $globalOffline;
126
+		global $globalDebug, $globalAircraftImageFetch, $globalOffline;
127 127
 		if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
128
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
128
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
129 129
 		$registration = trim($registration);
130 130
 		//getting the aircraft image
131 131
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
132 132
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
133 133
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
134
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
134
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
135 135
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
136 136
 		if ($image_url['original'] != '') {
137 137
 			if ($globalDebug) echo 'Found !'."\n";
138
-			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
138
+			$query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
139 139
 			try {
140 140
 				$sth = $this->db->prepare($query);
141
-				$sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
142
-			} catch(PDOException $e) {
141
+				$sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
142
+			} catch (PDOException $e) {
143 143
 				echo $e->getMessage()."\n";
144 144
 				return "error";
145 145
 			}
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
      * @param string $name
156 156
      * @return String either success or error
157 157
      */
158
-	public function addMarineImage($mmsi,$imo = '',$name = '')
158
+	public function addMarineImage($mmsi, $imo = '', $name = '')
159 159
 	{
160
-		global $globalDebug,$globalMarineImageFetch, $globalOffline;
160
+		global $globalDebug, $globalMarineImageFetch, $globalOffline;
161 161
 		if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
162
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
163
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
164
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
162
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
163
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
164
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
165 165
 		$name = trim($name);
166 166
 		$Marine = new Marine($this->db);
167 167
 		if ($imo == '' || $name == '') {
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
 
176 176
 		//getting the aircraft image
177 177
 		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
178
-		$image_url = $this->findMarineImage($mmsi,$imo,$name);
178
+		$image_url = $this->findMarineImage($mmsi, $imo, $name);
179 179
 		if ($image_url['original'] != '') {
180 180
 			if ($globalDebug) echo 'Found !'."\n";
181
-			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
181
+			$query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
182 182
 			try {
183 183
 				$sth = $this->db->prepare($query);
184
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
185
-			} catch(PDOException $e) {
184
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
185
+			} catch (PDOException $e) {
186 186
 				echo $e->getMessage()."\n";
187 187
 				return "error";
188 188
 			}
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
204 204
 		$Spotter = new Spotter($this->db);
205 205
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
206
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
206
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
207 207
 		if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) {
208
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
208
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
209 209
 			$aircraft_registration = urlencode(trim($aircraft_registration));
210 210
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
211 211
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -219,25 +219,25 @@  discard block
 block discarded – undo
219 219
 			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
220 220
 			else $aircraft_name = '';
221 221
 			$aircraft_registration = $aircraft_icao;
222
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
222
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
223 223
 		unset($Spotter);
224
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
224
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
225 225
 		foreach ($globalAircraftImageSources as $source) {
226 226
 			$source = strtolower($source);
227
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
228
-			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
229
-			if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
230
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
231
-			if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
232
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
233
-			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
234
-			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
235
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
236
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
227
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao);
228
+			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name);
229
+			if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name);
230
+			if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name);
231
+			if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name);
232
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name);
233
+			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name);
234
+			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name);
235
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name);
236
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name);
237 237
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
238 238
 		}
239 239
 		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
240
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
240
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
241 241
 	}
242 242
 
243 243
 	/**
@@ -249,14 +249,14 @@  discard block
 block discarded – undo
249 249
 	* @return array the aircraft thumbnail, orignal url and copyright
250 250
 	*
251 251
 	*/
252
-	public function findMarineImage($mmsi,$imo = '',$name = '')
252
+	public function findMarineImage($mmsi, $imo = '', $name = '')
253 253
 	{
254 254
 		global $globalMarineImageSources;
255
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
255
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
256 256
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
257
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
257
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
258 258
 		$name = trim($name);
259
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
259
+		if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
260 260
 		/*
261 261
 		$Marine = new Marine($this->db);
262 262
 		if ($imo == '' || $name == '') {
@@ -268,17 +268,17 @@  discard block
 block discarded – undo
268 268
 		}
269 269
 		unset($Marine);
270 270
 		*/
271
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
271
+		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing');
272 272
 		foreach ($globalMarineImageSources as $source) {
273 273
 			$source = strtolower($source);
274
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
275
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
276
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
277
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
278
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
274
+			if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name);
275
+			if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name);
276
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name);
277
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name);
278
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name);
279 279
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
280 280
 		}
281
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
281
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
282 282
 	}
283 283
 
284 284
 	/**
@@ -289,30 +289,30 @@  discard block
 block discarded – undo
289 289
 	* @return array the aircraft thumbnail, orignal url and copyright
290 290
 	*
291 291
 	*/
292
-	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
292
+	public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') {
293 293
 		$Common = new Common();
294 294
 		// If aircraft registration is only number, also check with aircraft model
295
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
296
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
295
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
296
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
297 297
 		} else {
298 298
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
299
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
299
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
300 300
 		}
301 301
 		$data = $Common->getData($url);
302
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
302
+		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
303 303
 		if ($xml = simplexml_load_string($data)) {
304 304
 			if (isset($xml->channel->item)) {
305 305
 				$image_url = array();
306
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
306
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
307 307
 				$image_url['thumbnail'] = $thumbnail_url;
308
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
309
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
310
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
308
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
309
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
310
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
311 311
 				$image_url['source'] = 'planespotters';
312 312
 				return $image_url;
313 313
 			}
314 314
 		} 
315
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
315
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
316 316
 	}
317 317
 
318 318
     /**
@@ -323,36 +323,36 @@  discard block
 block discarded – undo
323 323
      * @param String $name type of the aircraft
324 324
      * @return array the aircraft thumbnail, orignal url and copyright
325 325
      */
326
-	public function fromDeviantart($type,$registration, $name='') {
326
+	public function fromDeviantart($type, $registration, $name = '') {
327 327
 		$Common = new Common();
328 328
 		if ($type == 'aircraft') {
329 329
 			// If aircraft registration is only number, also check with aircraft model
330
-			if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') {
331
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
330
+			if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') {
331
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
332 332
 			} else {
333
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
333
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
334 334
 			}
335 335
 		} elseif ($type == 'marine') {
336
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
336
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
337 337
 		} else {
338
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
338
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
339 339
 		}
340 340
 		$data = $Common->getData($url);
341
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
341
+		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
342 342
 		if ($xml = simplexml_load_string($data)) {
343 343
 			if (isset($xml->channel->item->link)) {
344 344
 				$image_url = array();
345
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
345
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
346 346
 				$image_url['thumbnail'] = $thumbnail_url;
347
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
347
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
348 348
 				$image_url['original'] = $original_url;
349
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
350
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
349
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
350
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
351 351
 				$image_url['source'] = 'deviantart';
352 352
 				return $image_url;
353 353
 			}
354 354
 		} 
355
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
355
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
356 356
 	}
357 357
 
358 358
 	/**
@@ -363,38 +363,38 @@  discard block
 block discarded – undo
363 363
 	* @return array the aircraft thumbnail, orignal url and copyright
364 364
 	*
365 365
 	*/
366
-	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
366
+	public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') {
367 367
 		$Common = new Common();
368
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
368
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
369 369
 		$data = $Common->getData($url);
370 370
 		$dom = new DOMDocument();
371 371
 		@$dom->loadHTML($data);
372 372
 		$all_pics = array();
373
-		foreach($dom->getElementsByTagName('img') as $image) {
373
+		foreach ($dom->getElementsByTagName('img') as $image) {
374 374
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
375 375
 				$all_pics[] = $image->getAttribute('src');
376 376
 			}
377 377
 		}
378 378
 		$all_authors = array();
379
-		foreach($dom->getElementsByTagName('meta') as $author) {
379
+		foreach ($dom->getElementsByTagName('meta') as $author) {
380 380
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
381 381
 				$all_authors[] = $author->getAttribute('content');
382 382
 			}
383 383
 		}
384 384
 		$all_ref = array();
385
-		foreach($dom->getElementsByTagName('a') as $link) {
385
+		foreach ($dom->getElementsByTagName('a') as $link) {
386 386
 			$all_ref[] = $link->getAttribute('href');
387 387
 		}
388 388
 		if (isset($all_pics[0])) {
389 389
 			$image_url = array();
390 390
 			$image_url['thumbnail'] = $all_pics[0];
391
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
391
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
392 392
 			$image_url['copyright'] = $all_authors[0];
393 393
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
394 394
 			$image_url['source'] = 'JetPhotos';
395 395
 			return $image_url;
396 396
 		}
397
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
397
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
398 398
 	}
399 399
 
400 400
 	/**
@@ -405,30 +405,30 @@  discard block
 block discarded – undo
405 405
 	* @return array the aircraft thumbnail, orignal url and copyright
406 406
 	*
407 407
 	*/
408
-	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
408
+	public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') {
409 409
 		$Common = new Common();
410
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
410
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
411 411
 		$data = $Common->getData($url);
412 412
 		$dom = new DOMDocument();
413 413
 		@$dom->loadHTML($data);
414 414
 		$all_pics = array();
415
-		foreach($dom->getElementsByTagName('img') as $image) {
415
+		foreach ($dom->getElementsByTagName('img') as $image) {
416 416
 			$all_pics[] = $image->getAttribute('src');
417 417
 		}
418 418
 		$all_links = array();
419
-		foreach($dom->getElementsByTagName('a') as $link) {
420
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
419
+		foreach ($dom->getElementsByTagName('a') as $link) {
420
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
421 421
 		}
422
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) {
422
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) {
423 423
 			$image_url = array();
424 424
 			$image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1];
425
-			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]);
425
+			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]);
426 426
 			$image_url['copyright'] = $all_links[6]['text'];
427 427
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
428 428
 			$image_url['source'] = 'PlanePictures';
429 429
 			return $image_url;
430 430
 		}
431
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
431
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
432 432
 	}
433 433
 
434 434
 	/**
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	* @return array the aircraft thumbnail, orignal url and copyright
440 440
 	*
441 441
 	*/
442
-	public function fromFlickr($type,$registration,$name='') {
442
+	public function fromFlickr($type, $registration, $name = '') {
443 443
 		$Common = new Common();
444 444
 		if ($type == 'aircraft') {
445 445
 			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
@@ -449,20 +449,20 @@  discard block
 block discarded – undo
449 449
 			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
450 450
 		}
451 451
 		$data = $Common->getData($url);
452
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
452
+		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
453 453
 		if ($xml = simplexml_load_string($data)) {
454 454
 			if (isset($xml->channel->item)) {
455
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
455
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
456 456
 				$image_url = array();
457 457
 				$image_url['thumbnail'] = $original_url;
458 458
 				$image_url['original'] = $original_url;
459
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
460
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
459
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
460
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
461 461
 				$image_url['source'] = 'flickr';
462 462
 				return $image_url;
463 463
 			}
464 464
 		} 
465
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
465
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
466 466
 	}
467 467
 
468 468
     /**
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 			$image_url['source'] = 'ivao.aero';
484 484
 			return $image_url;
485 485
 		} else {
486
-			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
486
+			return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
487 487
 		}
488 488
 	}
489 489
 
@@ -495,10 +495,10 @@  discard block
 block discarded – undo
495 495
      * @param String $aircraft_name type of the aircraft
496 496
      * @return array the aircraft thumbnail, orignal url and copyright
497 497
      */
498
-	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
498
+	public function fromBing($type, $aircraft_registration, $aircraft_name = '') {
499 499
 		global $globalImageBingKey;
500 500
 		$Common = new Common();
501
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
501
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
502 502
 		if ($type == 'aircraft') {
503 503
 			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
504 504
 			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
507 507
 			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
508 508
 		}
509
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
510
-		$data = $Common->getData($url,'get','',$headers);
509
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
510
+		$data = $Common->getData($url, 'get', '', $headers);
511 511
 		$result = json_decode($data);
512 512
 		if (isset($result->d->results[0]->MediaUrl)) {
513 513
 			$image_url = array();
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 			$image_url['source'] = 'bing';
522 522
 			return $image_url;
523 523
 		}
524
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
524
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
525 525
 	}
526 526
 
527 527
 	/**
@@ -532,21 +532,21 @@  discard block
 block discarded – undo
532 532
 	* @return array the aircraft thumbnail, orignal url and copyright
533 533
 	*
534 534
 	*/
535
-	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
535
+	public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') {
536 536
 		$Common = new Common();
537 537
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
538 538
 		$data = $Common->getData($url);
539 539
 		$result = json_decode($data);
540 540
 		if (isset($result->count) && $result->count > 0) {
541 541
 			$image_url = array();
542
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
542
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
543 543
 			$image_url['source_website'] = $result->data[0]->link;
544 544
 			$image_url['thumbnail'] = $result->data[0]->image;
545 545
 			$image_url['copyright'] = $result->data[0]->photographer;
546 546
 			$image_url['source'] = 'AirportData';
547 547
 			return $image_url;
548 548
 		}
549
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
549
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
550 550
 	}
551 551
 
552 552
 	/**
@@ -557,20 +557,20 @@  discard block
 block discarded – undo
557 557
 	* @return array the aircraft thumbnail, orignal url and copyright
558 558
 	*
559 559
 	*/
560
-	public function fromWikimedia($type,$registration,$name='') {
560
+	public function fromWikimedia($type, $registration, $name = '') {
561 561
 		$Common = new Common();
562 562
 		if ($type == 'aircraft') {
563 563
 			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
564 564
 			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
565 565
 		} elseif ($type == 'marine') {
566 566
 			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
567
-			else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
567
+			else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
568 568
 		}
569 569
 		$data = $Common->getData($url);
570 570
 		$result = json_decode($data);
571 571
 		if (isset($result->query->search[0]->title)) {
572 572
 			$fileo = $result->query->search[0]->title;
573
-			if (substr($fileo,-3) == 'pdf') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
573
+			if (substr($fileo, -3) == 'pdf') return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
574 574
 			$file = urlencode($fileo);
575 575
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
576 576
 			$data2 = $Common->getData($url2);
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
 				if (isset($result2->query->pages)) {
596 596
 					foreach ($result2->query->pages as $page) {
597 597
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
598
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
598
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
599 599
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
600 600
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
601 601
 							}
602
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
602
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
603 603
 							return $image_url;
604 604
 						}
605 605
 					}
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 				return $image_url;
608 608
 			}
609 609
 		}
610
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
610
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
611 611
 	}
612 612
 
613 613
 	/**
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	* @return array the aircraft thumbnail, orignal url and copyright
619 619
 	*
620 620
 	*/
621
-	public function fromCustomSource($type,$registration,$name='') {
621
+	public function fromCustomSource($type, $registration, $name = '') {
622 622
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
623 623
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
624 624
 		if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') {
@@ -635,15 +635,15 @@  discard block
 block discarded – undo
635 635
 					print_r($source);
636 636
 					print_r($customsources);
637 637
 				}
638
-				$url = str_replace('{registration}',$registration,$source['original']);
639
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
638
+				$url = str_replace('{registration}', $registration, $source['original']);
639
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
640 640
 				if ($Common->urlexist($url)) {
641 641
 					$image_url = array();
642 642
 					$image_url['thumbnail'] = $url_thumbnail;
643 643
 					$image_url['original'] = $url;
644 644
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
645 645
 					else $exifCopyright = '';
646
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
646
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
647 647
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
648 648
 					else $image_url['copyright'] = $source['source_website'];
649 649
 					$image_url['source_website'] = $source['source_website'];
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
 					return $image_url;
652 652
 				}
653 653
 			}
654
-			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
655
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
654
+			return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
655
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
656 656
 
657 657
 		if (!empty($globalMarineImageCustomSources) && $type == 'marine') {
658 658
 			$customsources = array();
@@ -668,19 +668,19 @@  discard block
 block discarded – undo
668 668
 					print_r($source);
669 669
 					print_r($customsources);
670 670
 				}
671
-				$url = str_replace('{registration}',$registration,$source['original']);
672
-				$url = str_replace('{mmsi}',$registration,$url);
673
-				$url = str_replace('{name}',$name,$url);
674
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
675
-				$url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail);
676
-				$url_thumbnail = str_replace('{name}',$name,$url_thumbnail);
671
+				$url = str_replace('{registration}', $registration, $source['original']);
672
+				$url = str_replace('{mmsi}', $registration, $url);
673
+				$url = str_replace('{name}', $name, $url);
674
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
675
+				$url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail);
676
+				$url_thumbnail = str_replace('{name}', $name, $url_thumbnail);
677 677
 				if ($Common->urlexist($url)) {
678 678
 					$image_url = array();
679 679
 					$image_url['thumbnail'] = $url_thumbnail;
680 680
 					$image_url['original'] = $url;
681 681
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
682 682
 					else $exifCopyright = '';
683
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
683
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
684 684
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
685 685
 					else $image_url['copyright'] = $source['source_website'];
686 686
 					$image_url['source_website'] = $source['source_website'];
Please login to merge, or discard this patch.
require/class.Source.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		try {
28 28
 			$sth = $this->db->prepare($query);
29 29
 			$sth->execute($query_values);
30
-		} catch(PDOException $e) {
30
+		} catch (PDOException $e) {
31 31
 			return "error : ".$e->getMessage();
32 32
 		}
33 33
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -40,20 +40,20 @@  discard block
 block discarded – undo
40 40
 		try {
41 41
 			$sth = $this->db->prepare($query);
42 42
 			$sth->execute($query_values);
43
-		} catch(PDOException $e) {
43
+		} catch (PDOException $e) {
44 44
 			return "error : ".$e->getMessage();
45 45
 		}
46 46
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
47 47
 		return $all;
48 48
 	}
49 49
 
50
-	public function getLocationInfobyNameType($name,$type) {
50
+	public function getLocationInfobyNameType($name, $type) {
51 51
 		$query = "SELECT * FROM source_location WHERE name = :name AND type = :type";
52
-		$query_values = array(':name' => $name,':type' => $type);
52
+		$query_values = array(':name' => $name, ':type' => $type);
53 53
 		try {
54 54
 			$sth = $this->db->prepare($query);
55 55
 			$sth->execute($query_values);
56
-		} catch(PDOException $e) {
56
+		} catch (PDOException $e) {
57 57
 			return "error : ".$e->getMessage();
58 58
 		}
59 59
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		try {
71 71
 			$sth = $this->db->prepare($query);
72 72
 			$sth->execute($query_values);
73
-		} catch(PDOException $e) {
73
+		} catch (PDOException $e) {
74 74
 			echo "error : ".$e->getMessage();
75 75
 			return array();
76 76
 		}
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 	public function getLocationInfoByType($type, $coord = array(), $limit = false) {
82 82
 		$query = "SELECT * FROM source_location WHERE type = :type";
83 83
 		if (is_array($coord) && !empty($coord) && count($coord) == 4) {
84
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
85
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
86
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
87
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
84
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
85
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
86
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
87
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
88 88
 			$query .= " AND source_location.latitude BETWEEN ".$minlat." AND ".$maxlat." AND source_location.longitude BETWEEN ".$minlong." AND ".$maxlong." AND source_location.latitude <> 0 AND source_location.longitude <> 0";
89 89
 		}
90 90
 		$query .= " ORDER BY last_seen DESC";
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		try {
94 94
 			$sth = $this->db->prepare($query);
95 95
 			$sth->execute($query_values);
96
-		} catch(PDOException $e) {
96
+		} catch (PDOException $e) {
97 97
 			return "error : ".$e->getMessage();
98 98
 		}
99 99
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		try {
107 107
 			$sth = $this->db->prepare($query);
108 108
 			$sth->execute($query_values);
109
-		} catch(PDOException $e) {
109
+		} catch (PDOException $e) {
110 110
 			return "error : ".$e->getMessage();
111 111
 		}
112 112
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -119,58 +119,58 @@  discard block
 block discarded – undo
119 119
 		try {
120 120
 			$sth = $this->db->prepare($query);
121 121
 			$sth->execute($query_values);
122
-		} catch(PDOException $e) {
122
+		} catch (PDOException $e) {
123 123
 			return "error : ".$e->getMessage();
124 124
 		}
125 125
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
126 126
 		return $all;
127 127
 	}
128 128
 
129
-	public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') {
129
+	public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') {
130 130
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
131 131
 		$query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)";
132
-		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
132
+		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
133 133
 		try {
134 134
 			$sth = $this->db->prepare($query);
135 135
 			$sth->execute($query_values);
136
-		} catch(PDOException $e) {
136
+		} catch (PDOException $e) {
137 137
 			echo "error : ".$e->getMessage();
138 138
 		}
139 139
 	}
140 140
 
141
-	public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') {
141
+	public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') {
142 142
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
143 143
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source";
144
-		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
144
+		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
145 145
 		try {
146 146
 			$sth = $this->db->prepare($query);
147 147
 			$sth->execute($query_values);
148
-		} catch(PDOException $e) {
148
+		} catch (PDOException $e) {
149 149
 			return "error : ".$e->getMessage();
150 150
 		}
151 151
 		return '';
152 152
 	}
153 153
 
154
-	public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') {
154
+	public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') {
155 155
 		$query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source";
156
-		$query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description);
156
+		$query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description);
157 157
 		try {
158 158
 			$sth = $this->db->prepare($query);
159 159
 			$sth->execute($query_values);
160
-		} catch(PDOException $e) {
160
+		} catch (PDOException $e) {
161 161
 			return "error : ".$e->getMessage();
162 162
 		}
163 163
 		return '';
164 164
 	}
165 165
 
166
-	public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') {
166
+	public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') {
167 167
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
168 168
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id";
169
-		$query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
169
+		$query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
170 170
 		try {
171 171
 			$sth = $this->db->prepare($query);
172 172
 			$sth->execute($query_values);
173
-		} catch(PDOException $e) {
173
+		} catch (PDOException $e) {
174 174
 			echo "error : ".$e->getMessage();
175 175
 		}
176 176
 	}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		try {
182 182
 			$sth = $this->db->prepare($query);
183 183
 			$sth->execute($query_values);
184
-		} catch(PDOException $e) {
184
+		} catch (PDOException $e) {
185 185
 			return "error : ".$e->getMessage();
186 186
 		}
187 187
 		return '';
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		try {
194 194
 			$sth = $this->db->prepare($query);
195 195
 			$sth->execute($query_values);
196
-		} catch(PDOException $e) {
196
+		} catch (PDOException $e) {
197 197
 			return "error : ".$e->getMessage();
198 198
 		}
199 199
 		return '';
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 		try {
206 206
 			$sth = $this->db->prepare($query);
207 207
 			$sth->execute($query_values);
208
-		} catch(PDOException $e) {
208
+		} catch (PDOException $e) {
209 209
 			return "error : ".$e->getMessage();
210 210
 		}
211 211
 		return '';
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		try {
217 217
 			$sth = $this->db->prepare($query);
218 218
 			$sth->execute();
219
-		} catch(PDOException $e) {
219
+		} catch (PDOException $e) {
220 220
 			return "error : ".$e->getMessage();
221 221
 		}
222 222
 		return '';
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 		try {
247 247
 			$sth = $this->db->prepare($query);
248 248
 			$sth->execute(array(':type' => $type));
249
-		} catch(PDOException $e) {
249
+		} catch (PDOException $e) {
250 250
 			return "error";
251 251
 		}
252 252
 		return "success";
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Spacing   +643 added lines, -643 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 		if ($this->db === null) die('Error: No DB connection. (Stats)');
29 29
 	}
30 30
 
31
-	public function addLastStatsUpdate($type,$stats_date) {
31
+	public function addLastStatsUpdate($type, $stats_date) {
32 32
 		$query = "DELETE FROM config WHERE name = :type;
33 33
 			    INSERT INTO config (name,value) VALUES (:type,:stats_date);";
34
-		$query_values = array('type' => $type,':stats_date' => $stats_date);
34
+		$query_values = array('type' => $type, ':stats_date' => $stats_date);
35 35
 		try {
36 36
 			$sth = $this->db->prepare($query);
37 37
 			$sth->execute($query_values);
38
-		} catch(PDOException $e) {
38
+		} catch (PDOException $e) {
39 39
 			return "error : ".$e->getMessage();
40 40
 		}
41 41
 		return '';
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		try {
47 47
 			$sth = $this->db->prepare($query);
48 48
 			$sth->execute(array(':type' => $type));
49
-		} catch(PDOException $e) {
49
+		} catch (PDOException $e) {
50 50
 			echo "error : ".$e->getMessage();
51 51
 			return array();
52 52
 		}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		try {
69 69
 			$sth = $this->db->prepare($query);
70 70
 			$sth->execute(array(':filter_name' => $filter_name));
71
-		} catch(PDOException $e) {
71
+		} catch (PDOException $e) {
72 72
 			return "error : ".$e->getMessage();
73 73
 		}
74 74
 	}
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 		try {
82 82
 			$sth = $this->db->prepare($query);
83 83
 			$sth->execute();
84
-		} catch(PDOException $e) {
84
+		} catch (PDOException $e) {
85 85
 			return "error : ".$e->getMessage();
86 86
 		}
87 87
 		$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
88 88
 		try {
89 89
 			$sth = $this->db->prepare($query);
90 90
 			$sth->execute(array(':filter_name' => $filter_name));
91
-		} catch(PDOException $e) {
91
+		} catch (PDOException $e) {
92 92
 			return "error : ".$e->getMessage();
93 93
 		}
94 94
 	}
@@ -100,77 +100,77 @@  discard block
 block discarded – undo
100 100
 		 try {
101 101
 			$sth = $this->db->prepare($query);
102 102
 			$sth->execute(array(':filter_name' => $filter_name));
103
-		} catch(PDOException $e) {
103
+		} catch (PDOException $e) {
104 104
 			echo "error : ".$e->getMessage();
105 105
 		}
106 106
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
107 107
 		if (empty($all)) {
108 108
 			$filters = array();
109 109
 			if ($filter_name != '') {
110
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
110
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
111 111
 			}
112 112
 			$Spotter = new Spotter($this->db);
113
-			$all = $Spotter->getAllAirlineNames('',NULL,$filters);
113
+			$all = $Spotter->getAllAirlineNames('', NULL, $filters);
114 114
 		}
115 115
 		return $all;
116 116
 	}
117
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
117
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
118 118
 		if ($filter_name == '') $filter_name = $this->filter_name;
119 119
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
120 120
 		try {
121 121
 			$sth = $this->db->prepare($query);
122
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
123
-		} catch(PDOException $e) {
122
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
123
+		} catch (PDOException $e) {
124 124
 			echo "error : ".$e->getMessage();
125 125
 		}
126 126
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
127 127
 		return $all;
128 128
 	}
129
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
129
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
130 130
 		if ($filter_name == '') $filter_name = $this->filter_name;
131 131
 		$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
132 132
 		try {
133 133
 			$sth = $this->db->prepare($query);
134
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
135
-		} catch(PDOException $e) {
134
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
135
+		} catch (PDOException $e) {
136 136
 			echo "error : ".$e->getMessage();
137 137
 		}
138 138
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
139 139
 		return $all;
140 140
 	}
141
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
141
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143 143
 		$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
144 144
 		try {
145 145
 			$sth = $this->db->prepare($query);
146
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-		} catch(PDOException $e) {
146
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
147
+		} catch (PDOException $e) {
148 148
 			echo "error : ".$e->getMessage();
149 149
 		}
150 150
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
151 151
 		return $all;
152 152
 	}
153 153
 
154
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
154
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
155 155
 		if ($filter_name == '') $filter_name = $this->filter_name;
156 156
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
157 157
 		try {
158 158
 			$sth = $this->db->prepare($query);
159
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
160
-		} catch(PDOException $e) {
159
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
160
+		} catch (PDOException $e) {
161 161
 			echo "error : ".$e->getMessage();
162 162
 		}
163 163
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
164 164
 		return $all;
165 165
 	}
166 166
 
167
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
167
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
168 168
 		if ($filter_name == '') $filter_name = $this->filter_name;
169 169
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
170 170
 		try {
171 171
 			$sth = $this->db->prepare($query);
172
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
173
-		} catch(PDOException $e) {
172
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
173
+		} catch (PDOException $e) {
174 174
 			echo "error : ".$e->getMessage();
175 175
 		}
176 176
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -178,23 +178,23 @@  discard block
 block discarded – undo
178 178
 	}
179 179
 
180 180
 
181
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
181
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
182 182
 		global $globalStatsFilters;
183 183
 		if ($filter_name == '') $filter_name = $this->filter_name;
184
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
184
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
185 185
 			$Spotter = new Spotter($this->db);
186
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
186
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
187 187
 			$alliance_airlines = array();
188 188
 			foreach ($airlines as $airline) {
189
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
189
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
190 190
 			}
191 191
 			if ($year == '' && $month == '') {
192
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
193
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
192
+				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
193
+				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
194 194
 				try {
195 195
 					$sth = $this->db->prepare($query);
196 196
 					$sth->execute(array(':filter_name' => $filter_name));
197
-				} catch(PDOException $e) {
197
+				} catch (PDOException $e) {
198 198
 					echo "error : ".$e->getMessage();
199 199
 				}
200 200
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -205,29 +205,29 @@  discard block
 block discarded – undo
205 205
 				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
206 206
 				try {
207 207
 					$sth = $this->db->prepare($query);
208
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
209
-				} catch(PDOException $e) {
208
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
209
+				} catch (PDOException $e) {
210 210
 					echo "error : ".$e->getMessage();
211 211
 				}
212 212
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
213 213
 			} else $all = array();
214 214
 		}
215 215
 		if (empty($all)) {
216
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
217
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
216
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
217
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
218 218
 			} else {
219
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
219
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
220 220
 			}
221 221
 			if ($filter_name != '') {
222
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
222
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
223 223
 			}
224 224
 			$Spotter = new Spotter($this->db);
225 225
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
226
-			$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
226
+			$all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
227 227
 		}
228 228
 		return $all;
229 229
 	}
230
-	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
230
+	public function countAllMarineTypes($limit = true, $filter_name = '', $year = '', $month = '') {
231 231
 		global $globalStatsFilters, $globalVM;
232 232
 		if ($filter_name == '') $filter_name = $this->filter_name;
233 233
 		if ($year == '' && $month == '' && (!isset($globalVM) || $globalVM === FALSE)) {
@@ -236,23 +236,23 @@  discard block
 block discarded – undo
236 236
 			try {
237 237
 				$sth = $this->db->prepare($query);
238 238
 				$sth->execute(array(':filter_name' => $filter_name));
239
-			} catch(PDOException $e) {
239
+			} catch (PDOException $e) {
240 240
 				echo "error : ".$e->getMessage();
241 241
 			}
242 242
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
243 243
 		} else $all = array();
244 244
 		if (empty($all)) {
245
-			$filters = array('year' => $year,'month' => $month);
245
+			$filters = array('year' => $year, 'month' => $month);
246 246
 			if ($filter_name != '') {
247
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
247
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
248 248
 			}
249 249
 			$Marine = new Marine($this->db);
250 250
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
251
-			$all = $Marine->countAllMarineTypes($limit,0,'',$filters);
251
+			$all = $Marine->countAllMarineTypes($limit, 0, '', $filters);
252 252
 		}
253 253
 		return $all;
254 254
 	}
255
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
255
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
256 256
 		global $globalStatsFilters;
257 257
 		if ($filter_name == '') $filter_name = $this->filter_name;
258 258
 		if ($year == '' && $month == '') {
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			try {
262 262
 				$sth = $this->db->prepare($query);
263 263
 				$sth->execute(array(':filter_name' => $filter_name));
264
-			} catch(PDOException $e) {
264
+			} catch (PDOException $e) {
265 265
 				echo "error : ".$e->getMessage();
266 266
 			}
267 267
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -269,32 +269,32 @@  discard block
 block discarded – undo
269 269
 		if (empty($all)) {
270 270
 			$Spotter = new Spotter($this->db);
271 271
 			$filters = array();
272
-			$filters = array('year' => $year,'month' => $month);
272
+			$filters = array('year' => $year, 'month' => $month);
273 273
 			if ($filter_name != '') {
274
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
274
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
275 275
 			}
276 276
 			//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
277
-			$all = $Spotter->countAllAirlineCountries($limit,$filters);
277
+			$all = $Spotter->countAllAirlineCountries($limit, $filters);
278 278
 		}
279 279
 		return $all;
280 280
 	}
281
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
281
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
282 282
 		global $globalStatsFilters;
283 283
 		if ($filter_name == '') $filter_name = $this->filter_name;
284
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
284
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
285 285
 			$Spotter = new Spotter($this->db);
286
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
286
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
287 287
 			$alliance_airlines = array();
288 288
 			foreach ($airlines as $airline) {
289
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
289
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
290 290
 			}
291 291
 			if ($year == '' && $month == '') {
292
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
293
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
292
+				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
293
+				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
294 294
 				try {
295 295
 					$sth = $this->db->prepare($query);
296 296
 					$sth->execute(array(':filter_name' => $filter_name));
297
-				} catch(PDOException $e) {
297
+				} catch (PDOException $e) {
298 298
 					echo "error : ".$e->getMessage();
299 299
 				}
300 300
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -305,21 +305,21 @@  discard block
 block discarded – undo
305 305
 				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
306 306
 				try {
307 307
 					$sth = $this->db->prepare($query);
308
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
309
-				} catch(PDOException $e) {
308
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
309
+				} catch (PDOException $e) {
310 310
 					echo "error : ".$e->getMessage();
311 311
 				}
312 312
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313 313
 			} else $all = array();
314 314
 		}
315 315
 		if (empty($all)) {
316
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
317
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
316
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
317
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
318 318
 			} else {
319
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
319
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
320 320
 			}
321 321
 			if ($filter_name != '') {
322
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
322
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
323 323
 			}
324 324
 			$Spotter = new Spotter($this->db);
325 325
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -328,23 +328,23 @@  discard block
 block discarded – undo
328 328
 		return $all;
329 329
 	}
330 330
 
331
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
331
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
332 332
 		global $globalStatsFilters;
333 333
 		if ($filter_name == '') $filter_name = $this->filter_name;
334
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
334
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
335 335
 			$Spotter = new Spotter($this->db);
336
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
336
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
337 337
 			$alliance_airlines = array();
338 338
 			foreach ($airlines as $airline) {
339
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
339
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
340 340
 			}
341 341
 			if ($year == '' && $month == '') {
342
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
343
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
342
+				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
343
+				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
344 344
 				try {
345 345
 					$sth = $this->db->prepare($query);
346 346
 					$sth->execute(array(':filter_name' => $filter_name));
347
-				} catch(PDOException $e) {
347
+				} catch (PDOException $e) {
348 348
 					echo "error : ".$e->getMessage();
349 349
 				}
350 350
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -355,61 +355,61 @@  discard block
 block discarded – undo
355 355
 				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
356 356
 				try {
357 357
 					$sth = $this->db->prepare($query);
358
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
359
-				} catch(PDOException $e) {
358
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
359
+				} catch (PDOException $e) {
360 360
 					echo "error : ".$e->getMessage();
361 361
 				}
362 362
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
363 363
 			} else $all = array();
364 364
 		}
365 365
 		if (empty($all)) {
366
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
367
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
366
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
367
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
368 368
 			} else {
369
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
369
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
370 370
 			}
371 371
 			if ($filter_name != '') {
372
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
372
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
373 373
 			}
374 374
 			$Spotter = new Spotter($this->db);
375 375
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
376
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
376
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
377 377
 		}
378 378
 		return $all;
379 379
 	}
380 380
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
381 381
 		global $globalStatsFilters;
382 382
 		if ($filter_name == '') $filter_name = $this->filter_name;
383
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
383
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
384 384
 			$Spotter = new Spotter($this->db);
385
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
385
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
386 386
 			$alliance_airlines = array();
387 387
 			foreach ($airlines as $airline) {
388
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
388
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
389 389
 			}
390
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
391
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
390
+			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
391
+			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
392 392
 			$query_values = array(':filter_name' => $filter_name);
393 393
 		} else {
394 394
 			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
395 395
 			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
396
-			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
396
+			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
397 397
 		}
398 398
 		try {
399 399
 			$sth = $this->db->prepare($query);
400 400
 			$sth->execute($query_values);
401
-		} catch(PDOException $e) {
401
+		} catch (PDOException $e) {
402 402
 			echo "error : ".$e->getMessage();
403 403
 		}
404 404
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
405 405
 		if (empty($all)) {
406
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
407
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
406
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
407
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
408 408
 			} else {
409
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
409
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
410 410
 			}
411 411
 			if ($filter_name != '') {
412
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
412
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
413 413
 			}
414 414
 			$Spotter = new Spotter($this->db);
415 415
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 		return $all;
419 419
 	}
420 420
 
421
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
421
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
422 422
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
423 423
 		if ($filter_name == '') $filter_name = $this->filter_name;
424 424
 		if ($year == '' && $month == '') {
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 			if (isset($forsource)) {
428 428
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
429 429
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
430
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
430
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
431 431
 			} else {
432 432
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
433 433
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 			try {
437 437
 				$sth = $this->db->prepare($query);
438 438
 				$sth->execute($query_values);
439
-			} catch(PDOException $e) {
439
+			} catch (PDOException $e) {
440 440
 				echo "error : ".$e->getMessage();
441 441
 			}
442 442
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -444,32 +444,32 @@  discard block
 block discarded – undo
444 444
                 if (empty($all)) {
445 445
 	                $Spotter = new Spotter($this->db);
446 446
             		$filters = array();
447
-			$filters = array('year' => $year,'month' => $month);
447
+			$filters = array('year' => $year, 'month' => $month);
448 448
             		if ($filter_name != '') {
449
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
449
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
450 450
 			}
451 451
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
452
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
452
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
453 453
                 }
454 454
                 return $all;
455 455
 	}
456
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
456
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
457 457
 		global $globalStatsFilters;
458 458
 		if ($filter_name == '') $filter_name = $this->filter_name;
459
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
459
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
460 460
 			$Spotter = new Spotter($this->db);
461
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
461
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
462 462
 			$alliance_airlines = array();
463 463
 			foreach ($airlines as $airline) {
464
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
464
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
465 465
 			}
466 466
 			if ($year == '' && $month == '') {
467
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
468
-				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
467
+				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
468
+				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
469 469
 				try {
470 470
 					$sth = $this->db->prepare($query);
471 471
 					$sth->execute(array(':filter_name' => $filter_name));
472
-				} catch(PDOException $e) {
472
+				} catch (PDOException $e) {
473 473
 					echo "error : ".$e->getMessage();
474 474
 				}
475 475
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -480,45 +480,45 @@  discard block
 block discarded – undo
480 480
 				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
481 481
 				try {
482 482
 					$sth = $this->db->prepare($query);
483
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
484
-				} catch(PDOException $e) {
483
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
484
+				} catch (PDOException $e) {
485 485
 					echo "error : ".$e->getMessage();
486 486
 				}
487 487
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
488 488
 			} else $all = array();
489 489
 		}
490 490
 		if (empty($all)) {
491
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
492
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
491
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
492
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
493 493
 			} else {
494
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
494
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
495 495
 			}
496 496
 			if ($filter_name != '') {
497
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
497
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
498 498
 			}
499 499
 			$Spotter = new Spotter($this->db);
500 500
 			//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
501
-			$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
501
+			$all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
502 502
 		}
503 503
 		return $all;
504 504
 	}
505
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
505
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
506 506
 		global $globalStatsFilters;
507 507
 		if ($filter_name == '') $filter_name = $this->filter_name;
508
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
508
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
509 509
 			$Spotter = new Spotter($this->db);
510
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
510
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
511 511
 			$alliance_airlines = array();
512 512
 			foreach ($airlines as $airline) {
513
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
513
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
514 514
 			}
515 515
 			if ($year == '' && $month == '') {
516
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
517
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
516
+				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
517
+				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
518 518
 				 try {
519 519
 					$sth = $this->db->prepare($query);
520 520
 					$sth->execute(array(':filter_name' => $filter_name));
521
-				} catch(PDOException $e) {
521
+				} catch (PDOException $e) {
522 522
 					echo "error : ".$e->getMessage();
523 523
 				}
524 524
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -529,46 +529,46 @@  discard block
 block discarded – undo
529 529
 				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
530 530
 				 try {
531 531
 					$sth = $this->db->prepare($query);
532
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
533
-				} catch(PDOException $e) {
532
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
533
+				} catch (PDOException $e) {
534 534
 					echo "error : ".$e->getMessage();
535 535
 				}
536 536
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
537 537
 			} else $all = array();
538 538
 		}
539 539
 		if (empty($all)) {
540
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
541
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
540
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
541
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
542 542
 			} else {
543
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
543
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
544 544
 			}
545 545
 			if ($filter_name != '') {
546
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
546
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
547 547
 			}
548 548
 			$Spotter = new Spotter($this->db);
549 549
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
550
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
550
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
551 551
 		}
552 552
 		return $all;
553 553
 	}
554
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
554
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
555 555
 		$Connection = new Connection($this->db);
556 556
 		if ($filter_name == '') $filter_name = $this->filter_name;
557 557
 		if ($Connection->tableExists('countries')) {
558
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
558
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
559 559
 				$Spotter = new Spotter($this->db);
560
-				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
560
+				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
561 561
 				if ($year == '' && $month == '') {
562 562
 					$alliance_airlines = array();
563 563
 					foreach ($airlines as $airline) {
564
-						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
564
+						$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
565 565
 					}
566
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
567
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
566
+					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
567
+					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
568 568
 					 try {
569 569
 						$sth = $this->db->prepare($query);
570 570
 						$sth->execute(array(':filter_name' => $filter_name));
571
-					} catch(PDOException $e) {
571
+					} catch (PDOException $e) {
572 572
 						echo "error : ".$e->getMessage();
573 573
 					}
574 574
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
581 581
 					 try {
582 582
 						$sth = $this->db->prepare($query);
583
-						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
584
-					} catch(PDOException $e) {
583
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
584
+					} catch (PDOException $e) {
585 585
 						echo "error : ".$e->getMessage();
586 586
 					}
587 587
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 			return $Spotter->countAllFlightOverCountries($limit);
593 593
 		} else return array();
594 594
 	}
595
-	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
595
+	public function countAllMarineOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
596 596
 		$Connection = new Connection($this->db);
597 597
 		if ($filter_name == '') $filter_name = $this->filter_name;
598 598
 		if ($Connection->tableExists('countries')) {
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 				 try {
604 604
 					$sth = $this->db->prepare($query);
605 605
 					$sth->execute(array(':filter_name' => $filter_name));
606
-				} catch(PDOException $e) {
606
+				} catch (PDOException $e) {
607 607
 					echo "error : ".$e->getMessage();
608 608
 				}
609 609
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -611,15 +611,15 @@  discard block
 block discarded – undo
611 611
 			if (empty($all)) {
612 612
 				$filters = array();
613 613
 				if ($filter_name != '') {
614
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
614
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
615 615
 				}
616 616
 				$Marine = new Marine($this->db);
617
-				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
617
+				$all = $Marine->countAllMarineOverCountries($limit, 0, '', $filters);
618 618
 			}
619 619
 			return $all;
620 620
 		} else return array();
621 621
 	}
622
-	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
622
+	public function countAllTrackerOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
623 623
 		global $globalStatsFilters;
624 624
 		$Connection = new Connection($this->db);
625 625
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 				 try {
632 632
 					$sth = $this->db->prepare($query);
633 633
 					$sth->execute(array(':filter_name' => $filter_name));
634
-				} catch(PDOException $e) {
634
+				} catch (PDOException $e) {
635 635
 					echo "error : ".$e->getMessage();
636 636
 				}
637 637
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -640,15 +640,15 @@  discard block
 block discarded – undo
640 640
 			if (empty($all)) {
641 641
 				$filters = array();
642 642
 				if ($filter_name != '') {
643
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
643
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
644 644
 				}
645 645
 				$Tracker = new Tracker($this->db);
646
-				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
646
+				$all = $Tracker->countAllTrackerOverCountries($limit, 0, '', $filters);
647 647
 			}
648 648
 			return $all;
649 649
 		} else return array();
650 650
 	}
651
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
651
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
652 652
 		global $globalStatsFilters;
653 653
 		if ($filter_name == '') $filter_name = $this->filter_name;
654 654
 		if ($year == '' && $month == '') {
@@ -656,41 +656,41 @@  discard block
 block discarded – undo
656 656
 			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
657 657
 			try {
658 658
 				$sth = $this->db->prepare($query);
659
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
660
-			} catch(PDOException $e) {
659
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
660
+			} catch (PDOException $e) {
661 661
 				echo "error : ".$e->getMessage();
662 662
 			}
663 663
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
664 664
 		} else $all = array();
665 665
 		if (empty($all)) {
666
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
666
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
667 667
 			if ($filter_name != '') {
668
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
668
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
669 669
 			}
670 670
 			$Spotter = new Spotter($this->db);
671 671
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
672
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
672
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
673 673
 		}
674 674
 		return $all;
675 675
 	}
676 676
 
677
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
677
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
678 678
 		global $globalStatsFilters;
679 679
 		if ($filter_name == '') $filter_name = $this->filter_name;
680
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
680
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
681 681
 			$Spotter = new Spotter($this->db);
682
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
682
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
683 683
 			if ($year == '' && $month == '') {
684 684
 				$alliance_airlines = array();
685 685
 				foreach ($airlines as $airline) {
686
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
686
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
687 687
 				}
688
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
689
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
688
+				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
689
+				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
690 690
 				try {
691 691
 					$sth = $this->db->prepare($query);
692 692
 					$sth->execute(array(':filter_name' => $filter_name));
693
-				} catch(PDOException $e) {
693
+				} catch (PDOException $e) {
694 694
 					echo "error : ".$e->getMessage();
695 695
 				}
696 696
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -701,45 +701,45 @@  discard block
 block discarded – undo
701 701
 				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
702 702
 				try {
703 703
 					$sth = $this->db->prepare($query);
704
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
705
-				} catch(PDOException $e) {
704
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
705
+				} catch (PDOException $e) {
706 706
 					echo "error : ".$e->getMessage();
707 707
 				}
708 708
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
709 709
 			} else $all = array();
710 710
 		}
711 711
 		if (empty($all)) {
712
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
713
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
712
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
713
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
714 714
 			} else {
715
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
715
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
716 716
 			}
717 717
 			if ($filter_name != '') {
718
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
718
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
719 719
 			}
720 720
 			$Spotter = new Spotter($this->db);
721 721
 			//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
722
-			$all = $Spotter->countAllOwners($limit,0,'',$filters);
722
+			$all = $Spotter->countAllOwners($limit, 0, '', $filters);
723 723
 		}
724 724
 		return $all;
725 725
 	}
726
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
726
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
727 727
 		global $globalStatsFilters;
728 728
 		if ($filter_name == '') $filter_name = $this->filter_name;
729
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
729
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
730 730
 			$Spotter = new Spotter($this->db);
731
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
731
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
732 732
 			if ($year == '' && $month == '') {
733 733
 				$alliance_airlines = array();
734 734
 				foreach ($airlines as $airline) {
735
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
735
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
736 736
 				}
737
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
738
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
737
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
738
+				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
739 739
 				try {
740 740
 					$sth = $this->db->prepare($query);
741 741
 					$sth->execute(array(':filter_name' => $filter_name));
742
-				} catch(PDOException $e) {
742
+				} catch (PDOException $e) {
743 743
 					echo "error : ".$e->getMessage();
744 744
 				}
745 745
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -750,27 +750,27 @@  discard block
 block discarded – undo
750 750
 				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
751 751
 				try {
752 752
 					$sth = $this->db->prepare($query);
753
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
754
-				} catch(PDOException $e) {
753
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
754
+				} catch (PDOException $e) {
755 755
 					echo "error : ".$e->getMessage();
756 756
 				}
757 757
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
758 758
 			} else $all = array();
759 759
 		}
760 760
 		if (empty($all)) {
761
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
762
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
761
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
762
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
763 763
 			} else {
764
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
764
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
765 765
 			}
766 766
 			if ($filter_name != '') {
767
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
767
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
768 768
 			}
769 769
 			$Spotter = new Spotter($this->db);
770 770
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
771 771
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
772
-			$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
773
-			$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
772
+			$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
773
+			$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
774 774
 			$all = array();
775 775
 			foreach ($pall as $value) {
776 776
 				$icao = $value['airport_departure_icao'];
@@ -786,27 +786,27 @@  discard block
 block discarded – undo
786 786
 			foreach ($all as $key => $row) {
787 787
 				$count[$key] = $row['airport_departure_icao_count'];
788 788
 			}
789
-			array_multisort($count,SORT_DESC,$all);
789
+			array_multisort($count, SORT_DESC, $all);
790 790
 		}
791 791
 		return $all;
792 792
 	}
793
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
793
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
794 794
 		global $globalStatsFilters;
795 795
 		if ($filter_name == '') $filter_name = $this->filter_name;
796
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
796
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
797 797
 			$Spotter = new Spotter($this->db);
798
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
798
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
799 799
 			if ($year == '' && $month == '') {
800 800
 				$alliance_airlines = array();
801 801
 				foreach ($airlines as $airline) {
802
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
802
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
803 803
 				}
804
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
805
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
804
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
805
+				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
806 806
 				try {
807 807
 					$sth = $this->db->prepare($query);
808 808
 					$sth->execute(array(':filter_name' => $filter_name));
809
-				} catch(PDOException $e) {
809
+				} catch (PDOException $e) {
810 810
 					echo "error : ".$e->getMessage();
811 811
 				}
812 812
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -817,27 +817,27 @@  discard block
 block discarded – undo
817 817
 				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
818 818
 				try {
819 819
 					$sth = $this->db->prepare($query);
820
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
821
-				} catch(PDOException $e) {
820
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
821
+				} catch (PDOException $e) {
822 822
 					echo "error : ".$e->getMessage();
823 823
 				}
824 824
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
825 825
 			} else $all = array();
826 826
 		}
827 827
 		if (empty($all)) {
828
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
829
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
828
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
829
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
830 830
 			} else {
831
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
831
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
832 832
 			}
833 833
 			if ($filter_name != '') {
834
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
834
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
835 835
 			}
836 836
 			$Spotter = new Spotter($this->db);
837 837
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
838 838
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
839
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
840
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
839
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
840
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
841 841
 			$all = array();
842 842
 			foreach ($pall as $value) {
843 843
 				$icao = $value['airport_arrival_icao'];
@@ -853,26 +853,26 @@  discard block
 block discarded – undo
853 853
 			foreach ($all as $key => $row) {
854 854
 				$count[$key] = $row['airport_arrival_icao_count'];
855 855
 			}
856
-			array_multisort($count,SORT_DESC,$all);
856
+			array_multisort($count, SORT_DESC, $all);
857 857
 		}
858 858
 		return $all;
859 859
 	}
860
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
860
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
861 861
 		global $globalDBdriver, $globalStatsFilters;
862 862
 		if ($filter_name == '') $filter_name = $this->filter_name;
863
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
863
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
864 864
 			$Spotter = new Spotter($this->db);
865
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
865
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
866 866
 			$alliance_airlines = array();
867 867
 			foreach ($airlines as $airline) {
868
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
868
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
869 869
 			}
870 870
 			if ($globalDBdriver == 'mysql') {
871
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
872
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
871
+				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
872
+				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
873 873
 			} else {
874
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
875
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
874
+				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
875
+				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
876 876
 			}
877 877
 			$query_data = array(':filter_name' => $filter_name);
878 878
 		} else {
@@ -883,23 +883,23 @@  discard block
 block discarded – undo
883 883
 				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
884 884
 				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
885 885
 			}
886
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
886
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
887 887
 		}
888 888
 		try {
889 889
 			$sth = $this->db->prepare($query);
890 890
 			$sth->execute($query_data);
891
-		} catch(PDOException $e) {
891
+		} catch (PDOException $e) {
892 892
 			echo "error : ".$e->getMessage();
893 893
 		}
894 894
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
895 895
 		if (empty($all)) {
896
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
897
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
896
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
897
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
898 898
 			} else {
899 899
 				$filters = array('airlines' => array($stats_airline));
900 900
 			}
901 901
 			if ($filter_name != '') {
902
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
902
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
903 903
 			}
904 904
 			$Spotter = new Spotter($this->db);
905 905
 			$all = $Spotter->countAllMonthsLastYear($filters);
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 		return $all;
908 908
 	}
909 909
 
910
-	public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') {
910
+	public function countAllMarineMonthsLastYear($limit = true, $filter_name = '') {
911 911
 		global $globalDBdriver, $globalStatsFilters;
912 912
 		if ($filter_name == '') $filter_name = $this->filter_name;
913 913
 		if ($globalDBdriver == 'mysql') {
@@ -921,14 +921,14 @@  discard block
 block discarded – undo
921 921
 		try {
922 922
 			$sth = $this->db->prepare($query);
923 923
 			$sth->execute($query_data);
924
-		} catch(PDOException $e) {
924
+		} catch (PDOException $e) {
925 925
 			echo "error : ".$e->getMessage();
926 926
 		}
927 927
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
928 928
 		if (empty($all)) {
929 929
 			$filters = array();
930 930
 			if ($filter_name != '') {
931
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
931
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
932 932
 			}
933 933
 			$Marine = new Marine($this->db);
934 934
 			$all = $Marine->countAllMonthsLastYear($filters);
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 		return $all;
937 937
 	}
938 938
 
939
-	public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') {
939
+	public function countAllTrackerMonthsLastYear($limit = true, $filter_name = '') {
940 940
 		global $globalDBdriver, $globalStatsFilters;
941 941
 		if ($filter_name == '') $filter_name = $this->filter_name;
942 942
 		if ($globalDBdriver == 'mysql') {
@@ -950,14 +950,14 @@  discard block
 block discarded – undo
950 950
 		try {
951 951
 			$sth = $this->db->prepare($query);
952 952
 			$sth->execute($query_data);
953
-		} catch(PDOException $e) {
953
+		} catch (PDOException $e) {
954 954
 			echo "error : ".$e->getMessage();
955 955
 		}
956 956
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
957 957
 		if (empty($all)) {
958 958
 			$filters = array();
959 959
 			if ($filter_name != '') {
960
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
960
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
961 961
 			}
962 962
 			$Tracker = new Tracker($this->db);
963 963
 			$all = $Tracker->countAllMonthsLastYear($filters);
@@ -965,37 +965,37 @@  discard block
 block discarded – undo
965 965
 		return $all;
966 966
 	}
967 967
 	
968
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
968
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
969 969
 		global $globalStatsFilters;
970 970
 		if ($filter_name == '') $filter_name = $this->filter_name;
971
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
971
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
972 972
 			$Spotter = new Spotter($this->db);
973
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
973
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
974 974
 			$alliance_airlines = array();
975 975
 			foreach ($airlines as $airline) {
976
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
976
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
977 977
 			}
978
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
978
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
979 979
 			$query_data = array(':filter_name' => $filter_name);
980 980
 		} else {
981 981
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
982
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
982
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
983 983
 		}
984 984
 		try {
985 985
 			$sth = $this->db->prepare($query);
986 986
 			$sth->execute($query_data);
987
-		} catch(PDOException $e) {
987
+		} catch (PDOException $e) {
988 988
 			echo "error : ".$e->getMessage();
989 989
 		}
990 990
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
991 991
 		if (empty($all)) {
992
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
993
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
992
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
993
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
994 994
 			} else {
995 995
 				$filters = array('airlines' => array($stats_airline));
996 996
 			}
997 997
 			if ($filter_name != '') {
998
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
998
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
999 999
 			}
1000 1000
 			$Spotter = new Spotter($this->db);
1001 1001
 			$all = $Spotter->countAllDatesLastMonth($filters);
@@ -1010,14 +1010,14 @@  discard block
 block discarded – undo
1010 1010
 		try {
1011 1011
 			$sth = $this->db->prepare($query);
1012 1012
 			$sth->execute($query_data);
1013
-		} catch(PDOException $e) {
1013
+		} catch (PDOException $e) {
1014 1014
 			echo "error : ".$e->getMessage();
1015 1015
 		}
1016 1016
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1017 1017
 		if (empty($all)) {
1018 1018
 			$filters = array();
1019 1019
 			if ($filter_name != '') {
1020
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1020
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1021 1021
 			}
1022 1022
 			$Marine = new Marine($this->db);
1023 1023
 			$all = $Marine->countAllDatesLastMonth($filters);
@@ -1032,34 +1032,34 @@  discard block
 block discarded – undo
1032 1032
 		try {
1033 1033
 			$sth = $this->db->prepare($query);
1034 1034
 			$sth->execute($query_data);
1035
-		} catch(PDOException $e) {
1035
+		} catch (PDOException $e) {
1036 1036
 			echo "error : ".$e->getMessage();
1037 1037
 		}
1038 1038
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1039 1039
 		if (empty($all)) {
1040 1040
 			$filters = array();
1041 1041
 			if ($filter_name != '') {
1042
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1042
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1043 1043
 			}
1044 1044
 			$Tracker = new Tracker($this->db);
1045 1045
 			$all = $Tracker->countAllDatesLastMonth($filters);
1046 1046
 		}
1047 1047
 		return $all;
1048 1048
 	}
1049
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
1049
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
1050 1050
 		global $globalDBdriver, $globalStatsFilters;
1051 1051
 		if ($filter_name == '') $filter_name = $this->filter_name;
1052
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1052
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1053 1053
 			$Spotter = new Spotter($this->db);
1054
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1054
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1055 1055
 			$alliance_airlines = array();
1056 1056
 			foreach ($airlines as $airline) {
1057
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1057
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1058 1058
 			}
1059 1059
 			if ($globalDBdriver == 'mysql') {
1060
-				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1060
+				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1061 1061
 			} else {
1062
-				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1062
+				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1063 1063
 			}
1064 1064
 			$query_data = array(':filter_name' => $filter_name);
1065 1065
 		} else {
@@ -1068,23 +1068,23 @@  discard block
 block discarded – undo
1068 1068
 			} else {
1069 1069
 				$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1070 1070
 			}
1071
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1071
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1072 1072
 		}
1073 1073
 		try {
1074 1074
 			$sth = $this->db->prepare($query);
1075 1075
 			$sth->execute($query_data);
1076
-		} catch(PDOException $e) {
1076
+		} catch (PDOException $e) {
1077 1077
 			echo "error : ".$e->getMessage();
1078 1078
 		}
1079 1079
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1080 1080
 		if (empty($all)) {
1081
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1082
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1081
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1082
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1083 1083
 			} else {
1084 1084
 				$filters = array('airlines' => array($stats_airline));
1085 1085
 			}
1086 1086
 			if ($filter_name != '') {
1087
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1087
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1088 1088
 			}
1089 1089
 			$Spotter = new Spotter($this->db);
1090 1090
 			$all = $Spotter->countAllDatesLast7Days($filters);
@@ -1103,14 +1103,14 @@  discard block
 block discarded – undo
1103 1103
 		try {
1104 1104
 			$sth = $this->db->prepare($query);
1105 1105
 			$sth->execute($query_data);
1106
-		} catch(PDOException $e) {
1106
+		} catch (PDOException $e) {
1107 1107
 			echo "error : ".$e->getMessage();
1108 1108
 		}
1109 1109
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1110 1110
 		if (empty($all)) {
1111 1111
 			$filters = array();
1112 1112
 			if ($filter_name != '') {
1113
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1113
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1114 1114
 			}
1115 1115
 			$Marine = new Marine($this->db);
1116 1116
 			$all = $Marine->countAllDatesLast7Days($filters);
@@ -1129,51 +1129,51 @@  discard block
 block discarded – undo
1129 1129
 		try {
1130 1130
 			$sth = $this->db->prepare($query);
1131 1131
 			$sth->execute($query_data);
1132
-		} catch(PDOException $e) {
1132
+		} catch (PDOException $e) {
1133 1133
 			echo "error : ".$e->getMessage();
1134 1134
 		}
1135 1135
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1136 1136
 		if (empty($all)) {
1137 1137
 			$filters = array();
1138 1138
 			if ($filter_name != '') {
1139
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1139
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1140 1140
 			}
1141 1141
 			$Tracker = new Tracker($this->db);
1142 1142
 			$all = $Tracker->countAllDatesLast7Days($filters);
1143 1143
 		}
1144 1144
 		return $all;
1145 1145
 	}
1146
-	public function countAllDates($stats_airline = '',$filter_name = '') {
1146
+	public function countAllDates($stats_airline = '', $filter_name = '') {
1147 1147
 		global $globalStatsFilters;
1148 1148
 		if ($filter_name == '') $filter_name = $this->filter_name;
1149
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1149
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1150 1150
 			$Spotter = new Spotter($this->db);
1151
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1151
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1152 1152
 			$alliance_airlines = array();
1153 1153
 			foreach ($airlines as $airline) {
1154
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1154
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1155 1155
 			}
1156
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
1156
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
1157 1157
 			$query_data = array(':filter_name' => $filter_name);
1158 1158
 		} else {
1159 1159
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC";
1160
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1160
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1161 1161
 		}
1162 1162
 		try {
1163 1163
 			$sth = $this->db->prepare($query);
1164 1164
 			$sth->execute($query_data);
1165
-		} catch(PDOException $e) {
1165
+		} catch (PDOException $e) {
1166 1166
 			echo "error : ".$e->getMessage();
1167 1167
 		}
1168 1168
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1169 1169
 		if (empty($all)) {
1170
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1171
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1170
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1171
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1172 1172
 			} else {
1173 1173
 				$filters = array('airlines' => array($stats_airline));
1174 1174
 			}
1175 1175
 			if ($filter_name != '') {
1176
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1176
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1177 1177
 			}
1178 1178
 			$Spotter = new Spotter($this->db);
1179 1179
 			$all = $Spotter->countAllDates($filters);
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 		try {
1189 1189
 			$sth = $this->db->prepare($query);
1190 1190
 			$sth->execute($query_data);
1191
-		} catch(PDOException $e) {
1191
+		} catch (PDOException $e) {
1192 1192
 			echo "error : ".$e->getMessage();
1193 1193
 		}
1194 1194
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1210,7 +1210,7 @@  discard block
 block discarded – undo
1210 1210
 		try {
1211 1211
 			$sth = $this->db->prepare($query);
1212 1212
 			$sth->execute($query_data);
1213
-		} catch(PDOException $e) {
1213
+		} catch (PDOException $e) {
1214 1214
 			echo "error : ".$e->getMessage();
1215 1215
 		}
1216 1216
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1232,34 +1232,34 @@  discard block
 block discarded – undo
1232 1232
 		try {
1233 1233
 			$sth = $this->db->prepare($query);
1234 1234
 			$sth->execute($query_data);
1235
-		} catch(PDOException $e) {
1235
+		} catch (PDOException $e) {
1236 1236
 			echo "error : ".$e->getMessage();
1237 1237
 		}
1238 1238
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1239 1239
 		if (empty($all)) {
1240 1240
 			$filters = array();
1241 1241
 			if ($filter_name != '') {
1242
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1242
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1243 1243
 			}
1244 1244
 			$Spotter = new Spotter($this->db);
1245 1245
 			$all = $Spotter->countAllDatesByAirlines($filters);
1246 1246
 		}
1247 1247
 		return $all;
1248 1248
 	}
1249
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
1249
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
1250 1250
 		global $globalStatsFilters, $globalDBdriver;
1251 1251
 		if ($filter_name == '') $filter_name = $this->filter_name;
1252
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1252
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1253 1253
 			$Spotter = new Spotter($this->db);
1254
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1254
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1255 1255
 			$alliance_airlines = array();
1256 1256
 			foreach ($airlines as $airline) {
1257
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1257
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1258 1258
 			}
1259 1259
 			if ($globalDBdriver == 'mysql') {
1260
-				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1260
+				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1261 1261
 			} else {
1262
-				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1262
+				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1263 1263
 			}
1264 1264
 			$query_data = array(':filter_name' => $filter_name);
1265 1265
 		} else {
@@ -1273,18 +1273,18 @@  discard block
 block discarded – undo
1273 1273
 		try {
1274 1274
 			$sth = $this->db->prepare($query);
1275 1275
 			$sth->execute($query_data);
1276
-		} catch(PDOException $e) {
1276
+		} catch (PDOException $e) {
1277 1277
 			echo "error : ".$e->getMessage();
1278 1278
 		}
1279 1279
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1280 1280
 		if (empty($all)) {
1281
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1282
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1281
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1282
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1283 1283
 			} else {
1284 1284
 				$filters = array('airlines' => array($stats_airline));
1285 1285
 			}
1286 1286
 			if ($filter_name != '') {
1287
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1287
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1288 1288
 			}
1289 1289
 			$Spotter = new Spotter($this->db);
1290 1290
 			$all = $Spotter->countAllMonths($filters);
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 		try {
1302 1302
 			$sth = $this->db->prepare($query);
1303 1303
 			$sth->execute();
1304
-		} catch(PDOException $e) {
1304
+		} catch (PDOException $e) {
1305 1305
 			echo "error : ".$e->getMessage();
1306 1306
 		}
1307 1307
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 		try {
1322 1322
 			$sth = $this->db->prepare($query);
1323 1323
 			$sth->execute();
1324
-		} catch(PDOException $e) {
1324
+		} catch (PDOException $e) {
1325 1325
 			echo "error : ".$e->getMessage();
1326 1326
 		}
1327 1327
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1338,32 +1338,32 @@  discard block
 block discarded – undo
1338 1338
 		try {
1339 1339
 			$sth = $this->db->prepare($query);
1340 1340
 			$sth->execute(array(':filter_name' => $filter_name));
1341
-		} catch(PDOException $e) {
1341
+		} catch (PDOException $e) {
1342 1342
 			echo "error : ".$e->getMessage();
1343 1343
 		}
1344 1344
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1345 1345
 		if (empty($all)) {
1346 1346
 			$filters = array();
1347 1347
 			if ($filter_name != '') {
1348
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1348
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1349 1349
 			}
1350 1350
 			$Spotter = new Spotter($this->db);
1351 1351
 			$all = $Spotter->countAllMilitaryMonths($filters);
1352 1352
 		}
1353 1353
 		return $all;
1354 1354
 	}
1355
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1355
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
1356 1356
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1357 1357
 		if ($filter_name == '') $filter_name = $this->filter_name;
1358
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1358
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1359 1359
 			$Spotter = new Spotter($this->db);
1360
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1360
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1361 1361
 			$alliance_airlines = array();
1362 1362
 			foreach ($airlines as $airline) {
1363
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1363
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1364 1364
 			}
1365
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1366
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1365
+			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1366
+			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1367 1367
 			$query_data = array(':filter_name' => $filter_name);
1368 1368
 		} else {
1369 1369
 			if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1381,25 +1381,25 @@  discard block
 block discarded – undo
1381 1381
 		try {
1382 1382
 			$sth = $this->db->prepare($query);
1383 1383
 			$sth->execute($query_data);
1384
-		} catch(PDOException $e) {
1384
+		} catch (PDOException $e) {
1385 1385
 			echo "error : ".$e->getMessage();
1386 1386
 		}
1387 1387
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1388 1388
 		if (empty($all)) {
1389
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1390
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1389
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1390
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1391 1391
 			} else {
1392 1392
 				$filters = array('airlines' => array($stats_airline));
1393 1393
 			}
1394 1394
 			if ($filter_name != '') {
1395
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1395
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1396 1396
 			}
1397 1397
 			$Spotter = new Spotter($this->db);
1398
-			$all = $Spotter->countAllHours($orderby,$filters);
1398
+			$all = $Spotter->countAllHours($orderby, $filters);
1399 1399
 		}
1400 1400
 		return $all;
1401 1401
 	}
1402
-	public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') {
1402
+	public function countAllMarineHours($orderby = 'hour', $limit = true, $filter_name = '') {
1403 1403
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1404 1404
 		if ($filter_name == '') $filter_name = $this->filter_name;
1405 1405
 		if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
@@ -1416,21 +1416,21 @@  discard block
 block discarded – undo
1416 1416
 		try {
1417 1417
 			$sth = $this->db->prepare($query);
1418 1418
 			$sth->execute($query_data);
1419
-		} catch(PDOException $e) {
1419
+		} catch (PDOException $e) {
1420 1420
 			echo "error : ".$e->getMessage();
1421 1421
 		}
1422 1422
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1423 1423
 		if (empty($all)) {
1424 1424
 			$filters = array();
1425 1425
 			if ($filter_name != '') {
1426
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1426
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1427 1427
 			}
1428 1428
 			$Marine = new Marine($this->db);
1429
-			$all = $Marine->countAllHours($orderby,$filters);
1429
+			$all = $Marine->countAllHours($orderby, $filters);
1430 1430
 		}
1431 1431
 		return $all;
1432 1432
 	}
1433
-	public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') {
1433
+	public function countAllTrackerHours($orderby = 'hour', $limit = true, $filter_name = '') {
1434 1434
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1435 1435
 		if ($filter_name == '') $filter_name = $this->filter_name;
1436 1436
 		if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
@@ -1447,33 +1447,33 @@  discard block
 block discarded – undo
1447 1447
 		try {
1448 1448
 			$sth = $this->db->prepare($query);
1449 1449
 			$sth->execute($query_data);
1450
-		} catch(PDOException $e) {
1450
+		} catch (PDOException $e) {
1451 1451
 			echo "error : ".$e->getMessage();
1452 1452
 		}
1453 1453
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1454 1454
 		if (empty($all)) {
1455 1455
 			$filters = array();
1456 1456
 			if ($filter_name != '') {
1457
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1457
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1458 1458
 			}
1459 1459
 			$Tracker = new Tracker($this->db);
1460
-			$all = $Tracker->countAllHours($orderby,$filters);
1460
+			$all = $Tracker->countAllHours($orderby, $filters);
1461 1461
 		}
1462 1462
 		return $all;
1463 1463
 	}
1464
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1464
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1465 1465
 		global $globalStatsFilters;
1466 1466
 		if ($filter_name == '') $filter_name = $this->filter_name;
1467 1467
 		if ($year == '') $year = date('Y');
1468
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1468
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
1469 1469
 		if (empty($all)) {
1470
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1471
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1470
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1471
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1472 1472
 			} else {
1473
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1473
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1474 1474
 			}
1475 1475
 			if ($filter_name != '') {
1476
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1476
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1477 1477
 			}
1478 1478
 			$Spotter = new Spotter($this->db);
1479 1479
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1481,15 +1481,15 @@  discard block
 block discarded – undo
1481 1481
 		}
1482 1482
 		return $all;
1483 1483
 	}
1484
-	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1484
+	public function countOverallMarine($filter_name = '', $year = '', $month = '') {
1485 1485
 		global $globalStatsFilters;
1486 1486
 		if ($filter_name == '') $filter_name = $this->filter_name;
1487 1487
 		if ($year == '') $year = date('Y');
1488
-		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1488
+		$all = $this->getSumStats('marine_bymonth', $year, '', $filter_name, $month);
1489 1489
 		if (empty($all)) {
1490
-			$filters = array('year' => $year,'month' => $month);
1490
+			$filters = array('year' => $year, 'month' => $month);
1491 1491
 			if ($filter_name != '') {
1492
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1492
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1493 1493
 			}
1494 1494
 			$Marine = new Marine($this->db);
1495 1495
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1497,15 +1497,15 @@  discard block
 block discarded – undo
1497 1497
 		}
1498 1498
 		return $all;
1499 1499
 	}
1500
-	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1500
+	public function countOverallTracker($filter_name = '', $year = '', $month = '') {
1501 1501
 		global $globalStatsFilters;
1502 1502
 		if ($filter_name == '') $filter_name = $this->filter_name;
1503 1503
 		if ($year == '') $year = date('Y');
1504
-		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1504
+		$all = $this->getSumStats('tracker_bymonth', $year, '', $filter_name, $month);
1505 1505
 		if (empty($all)) {
1506
-			$filters = array('year' => $year,'month' => $month);
1506
+			$filters = array('year' => $year, 'month' => $month);
1507 1507
 			if ($filter_name != '') {
1508
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1508
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1509 1509
 			}
1510 1510
 			$Tracker = new Tracker($this->db);
1511 1511
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1513,16 +1513,16 @@  discard block
 block discarded – undo
1513 1513
 		}
1514 1514
 		return $all;
1515 1515
 	}
1516
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1516
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
1517 1517
 		global $globalStatsFilters;
1518 1518
 		if ($filter_name == '') $filter_name = $this->filter_name;
1519 1519
 		if ($year == '') $year = date('Y');
1520
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1520
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
1521 1521
 		if (empty($all)) {
1522 1522
 			$filters = array();
1523
-			$filters = array('year' => $year,'month' => $month);
1523
+			$filters = array('year' => $year, 'month' => $month);
1524 1524
 			if ($filter_name != '') {
1525
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1525
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1526 1526
 			}
1527 1527
 			$Spotter = new Spotter($this->db);
1528 1528
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -1530,19 +1530,19 @@  discard block
 block discarded – undo
1530 1530
 		}
1531 1531
 		return $all;
1532 1532
 	}
1533
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1533
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1534 1534
 		global $globalStatsFilters;
1535 1535
 		if ($filter_name == '') $filter_name = $this->filter_name;
1536 1536
 		if ($year == '') $year = date('Y');
1537
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1537
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
1538 1538
 		if (empty($all)) {
1539
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1540
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1539
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1540
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1541 1541
 			} else {
1542
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1542
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1543 1543
 			}
1544 1544
 			if ($filter_name != '') {
1545
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1545
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1546 1546
 			}
1547 1547
 			$Spotter = new Spotter($this->db);
1548 1548
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -1550,48 +1550,48 @@  discard block
 block discarded – undo
1550 1550
 		}
1551 1551
 		return $all;
1552 1552
 	}
1553
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1553
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1554 1554
 		global $globalStatsFilters;
1555 1555
 		if ($filter_name == '') $filter_name = $this->filter_name;
1556
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1556
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1557 1557
 			$Spotter = new Spotter($this->db);
1558
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1558
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1559 1559
 			if ($year == '' && $month == '') {
1560 1560
 				$alliance_airlines = array();
1561 1561
 				foreach ($airlines as $airline) {
1562
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1562
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1563 1563
 				}
1564
-				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1564
+				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1565 1565
 				try {
1566 1566
 					$sth = $this->db->prepare($query);
1567 1567
 					$sth->execute(array(':filter_name' => $filter_name));
1568
-				} catch(PDOException $e) {
1568
+				} catch (PDOException $e) {
1569 1569
 					echo "error : ".$e->getMessage();
1570 1570
 				}
1571 1571
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1572 1572
 				$all = $result[0]['nb'];
1573
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1573
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1574 1574
 		} else {
1575 1575
 			if ($year == '' && $month == '') {
1576 1576
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1577 1577
 				try {
1578 1578
 					$sth = $this->db->prepare($query);
1579
-					$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
1580
-				} catch(PDOException $e) {
1579
+					$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
1580
+				} catch (PDOException $e) {
1581 1581
 					echo "error : ".$e->getMessage();
1582 1582
 				}
1583 1583
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1584 1584
 				$all = $result[0]['nb'];
1585
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1585
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1586 1586
 		}
1587 1587
 		if (empty($all)) {
1588
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1589
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1588
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1589
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1590 1590
 			} else {
1591
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1591
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1592 1592
 			}
1593 1593
 			if ($filter_name != '') {
1594
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1594
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1595 1595
 			}
1596 1596
 			$Spotter = new Spotter($this->db);
1597 1597
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -1599,7 +1599,7 @@  discard block
 block discarded – undo
1599 1599
 		}
1600 1600
 		return $all;
1601 1601
 	}
1602
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1602
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
1603 1603
 		global $globalStatsFilters;
1604 1604
 		if ($filter_name == '') $filter_name = $this->filter_name;
1605 1605
 		if ($year == '' && $month == '') {
@@ -1607,17 +1607,17 @@  discard block
 block discarded – undo
1607 1607
 			try {
1608 1608
 				$sth = $this->db->prepare($query);
1609 1609
 				$sth->execute(array(':filter_name' => $filter_name));
1610
-			} catch(PDOException $e) {
1610
+			} catch (PDOException $e) {
1611 1611
 				echo "error : ".$e->getMessage();
1612 1612
 			}
1613 1613
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1614 1614
 			$all = $result[0]['nb_airline'];
1615
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1615
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
1616 1616
 		if (empty($all)) {
1617 1617
 			$filters = array();
1618
-			$filters = array('year' => $year,'month' => $month);
1618
+			$filters = array('year' => $year, 'month' => $month);
1619 1619
 			if ($filter_name != '') {
1620
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1620
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1621 1621
 			}
1622 1622
 			$Spotter = new Spotter($this->db);
1623 1623
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 		}
1626 1626
 		return $all;
1627 1627
 	}
1628
-	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1628
+	public function countOverallMarineTypes($filter_name = '', $year = '', $month = '') {
1629 1629
 		global $globalStatsFilters;
1630 1630
 		if ($filter_name == '') $filter_name = $this->filter_name;
1631 1631
 		$all = array();
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 			try {
1635 1635
 				$sth = $this->db->prepare($query);
1636 1636
 				$sth->execute(array(':filter_name' => $filter_name));
1637
-			} catch(PDOException $e) {
1637
+			} catch (PDOException $e) {
1638 1638
 				echo "error : ".$e->getMessage();
1639 1639
 			}
1640 1640
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1642,9 +1642,9 @@  discard block
 block discarded – undo
1642 1642
 		}
1643 1643
 		if (empty($all)) {
1644 1644
 			$filters = array();
1645
-			$filters = array('year' => $year,'month' => $month);
1645
+			$filters = array('year' => $year, 'month' => $month);
1646 1646
 			if ($filter_name != '') {
1647
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1647
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1648 1648
 			}
1649 1649
 			$Marine = new Marine($this->db);
1650 1650
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1652,29 +1652,29 @@  discard block
 block discarded – undo
1652 1652
 		}
1653 1653
 		return $all;
1654 1654
 	}
1655
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1655
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1656 1656
 		global $globalStatsFilters;
1657 1657
 		if ($filter_name == '') $filter_name = $this->filter_name;
1658
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1658
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1659 1659
 			$Spotter = new Spotter($this->db);
1660
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1660
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1661 1661
 			if ($year == '' && $month == '') {
1662 1662
 				$alliance_airlines = array();
1663 1663
 				foreach ($airlines as $airline) {
1664
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1664
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1665 1665
 				}
1666
-				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1666
+				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1667 1667
 				$query_values = array(':filter_name' => $filter_name);
1668 1668
 				try {
1669 1669
 					$sth = $this->db->prepare($query);
1670 1670
 					$sth->execute($query_values);
1671
-				} catch(PDOException $e) {
1671
+				} catch (PDOException $e) {
1672 1672
 					echo "error : ".$e->getMessage();
1673 1673
 				}
1674 1674
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1675 1675
 				$all = $result[0]['nb'];
1676 1676
 			} else {
1677
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1677
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1678 1678
 			}
1679 1679
 		} else {
1680 1680
 			if ($year == '' && $month == '') {
@@ -1683,23 +1683,23 @@  discard block
 block discarded – undo
1683 1683
 				try {
1684 1684
 					$sth = $this->db->prepare($query);
1685 1685
 					$sth->execute($query_values);
1686
-				} catch(PDOException $e) {
1686
+				} catch (PDOException $e) {
1687 1687
 					echo "error : ".$e->getMessage();
1688 1688
 				}
1689 1689
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1690 1690
 				$all = $result[0]['nb'];
1691 1691
 			} else {
1692
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1692
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1693 1693
 			}
1694 1694
 		}
1695 1695
 		if (empty($all)) {
1696
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1697
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1696
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1697
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1698 1698
 			} else {
1699
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1699
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1700 1700
 			}
1701 1701
 			if ($filter_name != '') {
1702
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1702
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1703 1703
 			}
1704 1704
 			$Spotter = new Spotter($this->db);
1705 1705
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
 		}
1708 1708
 		return $all;
1709 1709
 	}
1710
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1710
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1711 1711
 		global $globalStatsFilters;
1712 1712
 		if ($filter_name == '') $filter_name = $this->filter_name;
1713 1713
 		//if ($year == '') $year = date('Y');
@@ -1717,18 +1717,18 @@  discard block
 block discarded – undo
1717 1717
 			try {
1718 1718
 				$sth = $this->db->prepare($query);
1719 1719
 				$sth->execute($query_values);
1720
-			} catch(PDOException $e) {
1720
+			} catch (PDOException $e) {
1721 1721
 				echo "error : ".$e->getMessage();
1722 1722
 			}
1723 1723
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1724 1724
 			$all = $result[0]['nb'];
1725 1725
 		} else {
1726
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
1726
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
1727 1727
 		}
1728 1728
 		if (empty($all)) {
1729
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1729
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1730 1730
 			if ($filter_name != '') {
1731
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1731
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1732 1732
 			}
1733 1733
 			$Spotter = new Spotter($this->db);
1734 1734
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -1737,104 +1737,104 @@  discard block
 block discarded – undo
1737 1737
 		return $all;
1738 1738
 	}
1739 1739
 
1740
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1740
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
1741 1741
 		if ($filter_name == '') $filter_name = $this->filter_name;
1742
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1742
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1743 1743
 			$Spotter = new Spotter($this->db);
1744
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1744
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1745 1745
 			$alliance_airlines = array();
1746 1746
 			foreach ($airlines as $airline) {
1747
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1747
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1748 1748
 			}
1749
-			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1750
-			$query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name);
1749
+			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1750
+			$query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name);
1751 1751
 		} else {
1752 1752
 			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
1753
-			$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1753
+			$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1754 1754
 		}
1755 1755
 		try {
1756 1756
 			$sth = $this->db->prepare($query);
1757 1757
 			$sth->execute($query_values);
1758
-		} catch(PDOException $e) {
1758
+		} catch (PDOException $e) {
1759 1759
 			echo "error : ".$e->getMessage();
1760 1760
 		}
1761 1761
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1762 1762
 		return $all;
1763 1763
 	}
1764
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
1764
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
1765 1765
 		if ($filter_name == '') $filter_name = $this->filter_name;
1766 1766
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1767
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1767
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1768 1768
 		try {
1769 1769
 			$sth = $this->db->prepare($query);
1770 1770
 			$sth->execute($query_values);
1771
-		} catch(PDOException $e) {
1771
+		} catch (PDOException $e) {
1772 1772
 			echo "error : ".$e->getMessage();
1773 1773
 		}
1774 1774
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1775 1775
 		return $all;
1776 1776
 	}
1777
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1777
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
1778 1778
 		if ($filter_name == '') $filter_name = $this->filter_name;
1779 1779
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1780
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1780
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1781 1781
 		try {
1782 1782
 			$sth = $this->db->prepare($query);
1783 1783
 			$sth->execute($query_values);
1784
-		} catch(PDOException $e) {
1784
+		} catch (PDOException $e) {
1785 1785
 			echo "error : ".$e->getMessage();
1786 1786
 		}
1787 1787
 	}
1788
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1788
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
1789 1789
 		if ($filter_name == '') $filter_name = $this->filter_name;
1790 1790
 		global $globalArchiveMonths, $globalDBdriver;
1791
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1791
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1792 1792
 			$Spotter = new Spotter($this->db);
1793
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1793
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1794 1794
 			$alliance_airlines = array();
1795 1795
 			foreach ($airlines as $airline) {
1796
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1796
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1797 1797
 			}
1798 1798
 			if ($globalDBdriver == 'mysql') {
1799 1799
 				if ($month == '') {
1800
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1800
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1801 1801
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1802 1802
 				} else {
1803
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1804
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1803
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1804
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1805 1805
 				}
1806 1806
 			} else {
1807 1807
 				if ($month == '') {
1808
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1808
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1809 1809
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1810 1810
 				} else {
1811
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1812
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1811
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1812
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1813 1813
 				}
1814 1814
 			}
1815 1815
 		} else {
1816 1816
 			if ($globalDBdriver == 'mysql') {
1817 1817
 				if ($month == '') {
1818 1818
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
1819
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1819
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1820 1820
 				} else {
1821 1821
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
1822
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1822
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1823 1823
 				}
1824 1824
 			} else {
1825 1825
 				if ($month == '') {
1826 1826
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
1827
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1827
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1828 1828
 				} else {
1829 1829
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
1830
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1830
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1831 1831
 				}
1832 1832
 			}
1833 1833
 		}
1834 1834
 		try {
1835 1835
 			$sth = $this->db->prepare($query);
1836 1836
 			$sth->execute($query_values);
1837
-		} catch(PDOException $e) {
1837
+		} catch (PDOException $e) {
1838 1838
 			echo "error : ".$e->getMessage();
1839 1839
 		}
1840 1840
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1843,17 +1843,17 @@  discard block
 block discarded – undo
1843 1843
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1844 1844
 		global $globalArchiveMonths, $globalDBdriver;
1845 1845
 		if ($filter_name == '') $filter_name = $this->filter_name;
1846
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1846
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1847 1847
 			$Spotter = new Spotter($this->db);
1848
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1848
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1849 1849
 			$alliance_airlines = array();
1850 1850
 			foreach ($airlines as $airline) {
1851
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1851
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1852 1852
 			}
1853 1853
 			if ($globalDBdriver == 'mysql') {
1854
-				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1854
+				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1855 1855
 			} else {
1856
-				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1856
+				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1857 1857
 			}
1858 1858
 			$query_values = array(':type' => $type, ':filter_name' => $filter_name);
1859 1859
 		} else {
@@ -1867,7 +1867,7 @@  discard block
 block discarded – undo
1867 1867
 		try {
1868 1868
 			$sth = $this->db->prepare($query);
1869 1869
 			$sth->execute($query_values);
1870
-		} catch(PDOException $e) {
1870
+		} catch (PDOException $e) {
1871 1871
 			echo "error : ".$e->getMessage();
1872 1872
 		}
1873 1873
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1876,17 +1876,17 @@  discard block
 block discarded – undo
1876 1876
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1877 1877
 		global $globalArchiveMonths, $globalDBdriver;
1878 1878
 		if ($filter_name == '') $filter_name = $this->filter_name;
1879
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1879
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1880 1880
 			$Spotter = new Spotter($this->db);
1881
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1881
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1882 1882
 			$alliance_airlines = array();
1883 1883
 			foreach ($airlines as $airline) {
1884
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1884
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1885 1885
 			}
1886 1886
 			if ($globalDBdriver == 'mysql') {
1887
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1887
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1888 1888
 			} else {
1889
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1889
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1890 1890
 			}
1891 1891
 		} else {
1892 1892
 			if ($globalDBdriver == 'mysql') {
@@ -1898,7 +1898,7 @@  discard block
 block discarded – undo
1898 1898
 		try {
1899 1899
 			$sth = $this->db->prepare($query);
1900 1900
 			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1901
-		} catch(PDOException $e) {
1901
+		} catch (PDOException $e) {
1902 1902
 			echo "error : ".$e->getMessage();
1903 1903
 		}
1904 1904
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
 		try {
1916 1916
 			$sth = $this->db->prepare($query);
1917 1917
 			$sth->execute(array(':filter_name' => $filter_name));
1918
-		} catch(PDOException $e) {
1918
+		} catch (PDOException $e) {
1919 1919
 			echo "error : ".$e->getMessage();
1920 1920
 		}
1921 1921
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1932,20 +1932,20 @@  discard block
 block discarded – undo
1932 1932
 		try {
1933 1933
 			$sth = $this->db->prepare($query);
1934 1934
 			$sth->execute(array(':filter_name' => $filter_name));
1935
-		} catch(PDOException $e) {
1935
+		} catch (PDOException $e) {
1936 1936
 			echo "error : ".$e->getMessage();
1937 1937
 		}
1938 1938
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1939 1939
 		return $all[0]['total'];
1940 1940
 	}
1941
-	public function getStatsOwner($owner_name,$filter_name = '') {
1941
+	public function getStatsOwner($owner_name, $filter_name = '') {
1942 1942
 		global $globalArchiveMonths, $globalDBdriver;
1943 1943
 		if ($filter_name == '') $filter_name = $this->filter_name;
1944 1944
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1945 1945
 		try {
1946 1946
 			$sth = $this->db->prepare($query);
1947
-			$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1948
-		} catch(PDOException $e) {
1947
+			$sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1948
+		} catch (PDOException $e) {
1949 1949
 			echo "error : ".$e->getMessage();
1950 1950
 		}
1951 1951
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1963,20 +1963,20 @@  discard block
 block discarded – undo
1963 1963
 		try {
1964 1964
 			$sth = $this->db->prepare($query);
1965 1965
 			$sth->execute(array(':filter_name' => $filter_name));
1966
-		} catch(PDOException $e) {
1966
+		} catch (PDOException $e) {
1967 1967
 			echo "error : ".$e->getMessage();
1968 1968
 		}
1969 1969
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1970 1970
 		return $all[0]['total'];
1971 1971
 	}
1972
-	public function getStatsPilot($pilot,$filter_name = '') {
1972
+	public function getStatsPilot($pilot, $filter_name = '') {
1973 1973
 		global $globalArchiveMonths, $globalDBdriver;
1974 1974
 		if ($filter_name == '') $filter_name = $this->filter_name;
1975 1975
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1976 1976
 		try {
1977 1977
 			$sth = $this->db->prepare($query);
1978
-			$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1979
-		} catch(PDOException $e) {
1978
+			$sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1979
+		} catch (PDOException $e) {
1980 1980
 			echo "error : ".$e->getMessage();
1981 1981
 		}
1982 1982
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
 		else return 0;
1985 1985
 	}
1986 1986
 
1987
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1987
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1988 1988
 		global $globalDBdriver;
1989 1989
 		if ($filter_name == '') $filter_name = $this->filter_name;
1990 1990
 		if ($globalDBdriver == 'mysql') {
@@ -1992,15 +1992,15 @@  discard block
 block discarded – undo
1992 1992
 		} else {
1993 1993
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1994 1994
 		}
1995
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1995
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1996 1996
 		try {
1997 1997
 			$sth = $this->db->prepare($query);
1998 1998
 			$sth->execute($query_values);
1999
-		} catch(PDOException $e) {
1999
+		} catch (PDOException $e) {
2000 2000
 			return "error : ".$e->getMessage();
2001 2001
 		}
2002 2002
 	}
2003
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
2003
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
2004 2004
 		global $globalDBdriver;
2005 2005
 		if ($filter_name == '') $filter_name = $this->filter_name;
2006 2006
 		if ($globalDBdriver == 'mysql') {
@@ -2009,11 +2009,11 @@  discard block
 block discarded – undo
2009 2009
 			//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
2010 2010
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2011 2011
 		}
2012
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2012
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2013 2013
 		try {
2014 2014
 			$sth = $this->db->prepare($query);
2015 2015
 			$sth->execute($query_values);
2016
-		} catch(PDOException $e) {
2016
+		} catch (PDOException $e) {
2017 2017
 			return "error : ".$e->getMessage();
2018 2018
 		}
2019 2019
 	}
@@ -2037,95 +2037,95 @@  discard block
 block discarded – undo
2037 2037
         }
2038 2038
         */
2039 2039
 
2040
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
2040
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
2041 2041
 		global $globalDBdriver;
2042 2042
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
2043 2043
 		$query_values = array();
2044 2044
 		if ($globalDBdriver == 'mysql') {
2045 2045
 			if ($year != '') {
2046 2046
 				$query .= ' AND YEAR(stats_date) = :year';
2047
-				$query_values = array_merge($query_values,array(':year' => $year));
2047
+				$query_values = array_merge($query_values, array(':year' => $year));
2048 2048
 			}
2049 2049
 			if ($month != '') {
2050 2050
 				$query .= ' AND MONTH(stats_date) = :month';
2051
-				$query_values = array_merge($query_values,array(':month' => $month));
2051
+				$query_values = array_merge($query_values, array(':month' => $month));
2052 2052
 			}
2053 2053
 			if ($day != '') {
2054 2054
 				$query .= ' AND DAY(stats_date) = :day';
2055
-				$query_values = array_merge($query_values,array(':day' => $day));
2055
+				$query_values = array_merge($query_values, array(':day' => $day));
2056 2056
 			}
2057 2057
 		} else {
2058 2058
 			if ($year != '') {
2059 2059
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
2060
-				$query_values = array_merge($query_values,array(':year' => $year));
2060
+				$query_values = array_merge($query_values, array(':year' => $year));
2061 2061
 			}
2062 2062
 			if ($month != '') {
2063 2063
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
2064
-				$query_values = array_merge($query_values,array(':month' => $month));
2064
+				$query_values = array_merge($query_values, array(':month' => $month));
2065 2065
 			}
2066 2066
 			if ($day != '') {
2067 2067
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
2068
-				$query_values = array_merge($query_values,array(':day' => $day));
2068
+				$query_values = array_merge($query_values, array(':day' => $day));
2069 2069
 			}
2070 2070
 		}
2071 2071
 		$query .= " ORDER BY source_name";
2072
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
2072
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
2073 2073
 		try {
2074 2074
 			$sth = $this->db->prepare($query);
2075 2075
 			$sth->execute($query_values);
2076
-		} catch(PDOException $e) {
2076
+		} catch (PDOException $e) {
2077 2077
 			echo "error : ".$e->getMessage();
2078 2078
 		}
2079 2079
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
2080 2080
 		return $all;
2081 2081
 	}
2082 2082
 
2083
-	public function addStatSource($data,$source_name,$stats_type,$date) {
2083
+	public function addStatSource($data, $source_name, $stats_type, $date) {
2084 2084
 		global $globalDBdriver;
2085 2085
 		if ($globalDBdriver == 'mysql') {
2086 2086
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
2087 2087
 		} else {
2088 2088
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
2089 2089
 		}
2090
-		$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
2090
+		$query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
2091 2091
 		try {
2092 2092
 			$sth = $this->db->prepare($query);
2093 2093
 			$sth->execute($query_values);
2094
-		} catch(PDOException $e) {
2094
+		} catch (PDOException $e) {
2095 2095
 			return "error : ".$e->getMessage();
2096 2096
 		}
2097 2097
 	}
2098
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
2098
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
2099 2099
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
2100
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2100
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2101 2101
 		try {
2102 2102
 			$sth = $this->db->prepare($query);
2103 2103
 			$sth->execute($query_values);
2104
-		} catch(PDOException $e) {
2104
+		} catch (PDOException $e) {
2105 2105
 			return "error : ".$e->getMessage();
2106 2106
 		}
2107 2107
 	}
2108
-	public function addStatMarine($type,$date_name,$cnt,$filter_name = '') {
2108
+	public function addStatMarine($type, $date_name, $cnt, $filter_name = '') {
2109 2109
 		$query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
2110
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
2110
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2111 2111
 		try {
2112 2112
 			$sth = $this->db->prepare($query);
2113 2113
 			$sth->execute($query_values);
2114
-		} catch(PDOException $e) {
2114
+		} catch (PDOException $e) {
2115 2115
 			return "error : ".$e->getMessage();
2116 2116
 		}
2117 2117
 	}
2118
-	public function addStatTracker($type,$date_name,$cnt,$filter_name = '') {
2118
+	public function addStatTracker($type, $date_name, $cnt, $filter_name = '') {
2119 2119
 		$query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
2120
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
2120
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2121 2121
 		try {
2122 2122
 			$sth = $this->db->prepare($query);
2123 2123
 			$sth->execute($query_values);
2124
-		} catch(PDOException $e) {
2124
+		} catch (PDOException $e) {
2125 2125
 			return "error : ".$e->getMessage();
2126 2126
 		}
2127 2127
 	}
2128
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
2128
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
2129 2129
 		global $globalDBdriver;
2130 2130
 		if ($globalDBdriver == 'mysql') {
2131 2131
 			if ($reset) {
@@ -2140,15 +2140,15 @@  discard block
 block discarded – undo
2140 2140
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2141 2141
 			}
2142 2142
 		}
2143
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2143
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2144 2144
 		try {
2145 2145
 			$sth = $this->db->prepare($query);
2146 2146
 			$sth->execute($query_values);
2147
-		} catch(PDOException $e) {
2147
+		} catch (PDOException $e) {
2148 2148
 			return "error : ".$e->getMessage();
2149 2149
 		}
2150 2150
 	}
2151
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
2151
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
2152 2152
 		global $globalDBdriver;
2153 2153
 		if ($globalDBdriver == 'mysql') {
2154 2154
 			if ($reset) {
@@ -2163,15 +2163,15 @@  discard block
 block discarded – undo
2163 2163
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
2164 2164
 			}
2165 2165
 		}
2166
-		$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
2166
+		$query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
2167 2167
 		try {
2168 2168
 			$sth = $this->db->prepare($query);
2169 2169
 			$sth->execute($query_values);
2170
-		} catch(PDOException $e) {
2170
+		} catch (PDOException $e) {
2171 2171
 			return "error : ".$e->getMessage();
2172 2172
 		}
2173 2173
 	}
2174
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
2174
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
2175 2175
 		global $globalDBdriver;
2176 2176
 		if ($globalDBdriver == 'mysql') {
2177 2177
 			if ($reset) {
@@ -2186,15 +2186,15 @@  discard block
 block discarded – undo
2186 2186
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
2187 2187
 			}
2188 2188
 		}
2189
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
2189
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
2190 2190
 		try {
2191 2191
 			$sth = $this->db->prepare($query);
2192 2192
 			$sth->execute($query_values);
2193
-		} catch(PDOException $e) {
2193
+		} catch (PDOException $e) {
2194 2194
 			return "error : ".$e->getMessage();
2195 2195
 		}
2196 2196
 	}
2197
-	public function addStatCountryMarine($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
2197
+	public function addStatCountryMarine($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
2198 2198
 		global $globalDBdriver;
2199 2199
 		if ($globalDBdriver == 'mysql') {
2200 2200
 			if ($reset) {
@@ -2209,15 +2209,15 @@  discard block
 block discarded – undo
2209 2209
 				$query = "UPDATE stats_marine_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_marine_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2210 2210
 			}
2211 2211
 		}
2212
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2212
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2213 2213
 		try {
2214 2214
 			$sth = $this->db->prepare($query);
2215 2215
 			$sth->execute($query_values);
2216
-		} catch(PDOException $e) {
2216
+		} catch (PDOException $e) {
2217 2217
 			return "error : ".$e->getMessage();
2218 2218
 		}
2219 2219
 	}
2220
-	public function addStatCountryTracker($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
2220
+	public function addStatCountryTracker($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
2221 2221
 		global $globalDBdriver;
2222 2222
 		if ($globalDBdriver == 'mysql') {
2223 2223
 			if ($reset) {
@@ -2232,15 +2232,15 @@  discard block
 block discarded – undo
2232 2232
 				$query = "UPDATE stats_tracker_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_tracker_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2233 2233
 			}
2234 2234
 		}
2235
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2235
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2236 2236
 		try {
2237 2237
 			$sth = $this->db->prepare($query);
2238 2238
 			$sth->execute($query_values);
2239
-		} catch(PDOException $e) {
2239
+		} catch (PDOException $e) {
2240 2240
 			return "error : ".$e->getMessage();
2241 2241
 		}
2242 2242
 	}
2243
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2243
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2244 2244
 		global $globalDBdriver;
2245 2245
 		if ($globalDBdriver == 'mysql') {
2246 2246
 			if ($reset) {
@@ -2255,15 +2255,15 @@  discard block
 block discarded – undo
2255 2255
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2256 2256
 			}
2257 2257
 		}
2258
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2258
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2259 2259
 		try {
2260 2260
 			$sth = $this->db->prepare($query);
2261 2261
 			$sth->execute($query_values);
2262
-		} catch(PDOException $e) {
2262
+		} catch (PDOException $e) {
2263 2263
 			return "error : ".$e->getMessage();
2264 2264
 		}
2265 2265
 	}
2266
-	public function addStatMarineType($type,$type_id,$cnt, $filter_name = '', $reset = false) {
2266
+	public function addStatMarineType($type, $type_id, $cnt, $filter_name = '', $reset = false) {
2267 2267
 		global $globalDBdriver;
2268 2268
 		if ($globalDBdriver == 'mysql') {
2269 2269
 			if ($reset) {
@@ -2278,15 +2278,15 @@  discard block
 block discarded – undo
2278 2278
 				$query = "UPDATE stats_marine_type SET cnt = cnt+:cnt, type = :type, filter_name = :filter_name WHERE type_id = :type_id AND filter_name = :filter_name; INSERT INTO stats_marine_type (type,type_id,cnt,filter_name) SELECT :type,:type_id,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_type WHERE type = :type AND filter_name = :filter_name);"; 
2279 2279
 			}
2280 2280
 		}
2281
-		$query_values = array(':type' => $type,':type_id' => $type_id,':cnt' => $cnt, ':filter_name' => $filter_name);
2281
+		$query_values = array(':type' => $type, ':type_id' => $type_id, ':cnt' => $cnt, ':filter_name' => $filter_name);
2282 2282
 		try {
2283 2283
 			$sth = $this->db->prepare($query);
2284 2284
 			$sth->execute($query_values);
2285
-		} catch(PDOException $e) {
2285
+		} catch (PDOException $e) {
2286 2286
 			return "error : ".$e->getMessage();
2287 2287
 		}
2288 2288
 	}
2289
-	public function addStatTrackerType($type,$cnt, $filter_name = '', $reset = false) {
2289
+	public function addStatTrackerType($type, $cnt, $filter_name = '', $reset = false) {
2290 2290
 		global $globalDBdriver;
2291 2291
 		if ($globalDBdriver == 'mysql') {
2292 2292
 			if ($reset) {
@@ -2301,15 +2301,15 @@  discard block
 block discarded – undo
2301 2301
 				$query = "UPDATE stats_tracker_type SET cnt = cnt+:cnt WHERE type = :type AND filter_name = :filter_name; INSERT INTO stats_tracker_type (type,cnt,filter_name) SELECT :type,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_type WHERE type = :type AND filter_name = :filter_name);"; 
2302 2302
 			}
2303 2303
 		}
2304
-		$query_values = array(':type' => $type,':cnt' => $cnt, ':filter_name' => $filter_name);
2304
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':filter_name' => $filter_name);
2305 2305
 		try {
2306 2306
 			$sth = $this->db->prepare($query);
2307 2307
 			$sth->execute($query_values);
2308
-		} catch(PDOException $e) {
2308
+		} catch (PDOException $e) {
2309 2309
 			return "error : ".$e->getMessage();
2310 2310
 		}
2311 2311
 	}
2312
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
2312
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
2313 2313
 		global $globalDBdriver;
2314 2314
 		if ($globalDBdriver == 'mysql') {
2315 2315
 			if ($reset) {
@@ -2324,15 +2324,15 @@  discard block
 block discarded – undo
2324 2324
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
2325 2325
 			}
2326 2326
 		}
2327
-		$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
2327
+		$query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2328 2328
 		try {
2329 2329
 			$sth = $this->db->prepare($query);
2330 2330
 			$sth->execute($query_values);
2331
-		} catch(PDOException $e) {
2331
+		} catch (PDOException $e) {
2332 2332
 			return "error : ".$e->getMessage();
2333 2333
 		}
2334 2334
 	}
2335
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
2335
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
2336 2336
 		global $globalDBdriver;
2337 2337
 		if ($globalDBdriver == 'mysql') {
2338 2338
 			if ($reset) {
@@ -2347,15 +2347,15 @@  discard block
 block discarded – undo
2347 2347
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2348 2348
 			}
2349 2349
 		}
2350
-		$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2350
+		$query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2351 2351
 		try {
2352 2352
 			$sth = $this->db->prepare($query);
2353 2353
 			$sth->execute($query_values);
2354
-		} catch(PDOException $e) {
2354
+		} catch (PDOException $e) {
2355 2355
 			return "error : ".$e->getMessage();
2356 2356
 		}
2357 2357
 	}
2358
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
2358
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
2359 2359
 		global $globalDBdriver;
2360 2360
 		if ($globalDBdriver == 'mysql') {
2361 2361
 			if ($reset) {
@@ -2370,15 +2370,15 @@  discard block
 block discarded – undo
2370 2370
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
2371 2371
 			}
2372 2372
 		}
2373
-		$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
2373
+		$query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
2374 2374
 		try {
2375 2375
 			$sth = $this->db->prepare($query);
2376 2376
 			$sth->execute($query_values);
2377
-		} catch(PDOException $e) {
2377
+		} catch (PDOException $e) {
2378 2378
 			return "error : ".$e->getMessage();
2379 2379
 		}
2380 2380
 	}
2381
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
2381
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
2382 2382
 		global $globalDBdriver;
2383 2383
 		if ($airport_icao != '') {
2384 2384
 			if ($globalDBdriver == 'mysql') {
@@ -2394,16 +2394,16 @@  discard block
 block discarded – undo
2394 2394
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
2395 2395
 				}
2396 2396
 			}
2397
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2397
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2398 2398
 			try {
2399 2399
 				$sth = $this->db->prepare($query);
2400 2400
 				$sth->execute($query_values);
2401
-			} catch(PDOException $e) {
2401
+			} catch (PDOException $e) {
2402 2402
 				return "error : ".$e->getMessage();
2403 2403
 			}
2404 2404
 		}
2405 2405
 	}
2406
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
2406
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
2407 2407
 		global $globalDBdriver;
2408 2408
 		if ($airport_icao != '') {
2409 2409
 			if ($globalDBdriver == 'mysql') {
@@ -2411,16 +2411,16 @@  discard block
 block discarded – undo
2411 2411
 			} else {
2412 2412
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2413 2413
 			}
2414
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2414
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2415 2415
 			 try {
2416 2416
 				$sth = $this->db->prepare($query);
2417 2417
 				$sth->execute($query_values);
2418
-			} catch(PDOException $e) {
2418
+			} catch (PDOException $e) {
2419 2419
 				return "error : ".$e->getMessage();
2420 2420
 			}
2421 2421
 		}
2422 2422
 	}
2423
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
2423
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
2424 2424
 		global $globalDBdriver;
2425 2425
 		if ($airport_icao != '') {
2426 2426
 			if ($globalDBdriver == 'mysql') {
@@ -2436,16 +2436,16 @@  discard block
 block discarded – undo
2436 2436
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
2437 2437
 				}
2438 2438
 			}
2439
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2439
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2440 2440
 			try {
2441 2441
 				$sth = $this->db->prepare($query);
2442 2442
 				$sth->execute($query_values);
2443
-			} catch(PDOException $e) {
2443
+			} catch (PDOException $e) {
2444 2444
 				return "error : ".$e->getMessage();
2445 2445
 			}
2446 2446
 		}
2447 2447
 	}
2448
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
2448
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
2449 2449
 		global $globalDBdriver;
2450 2450
 		if ($airport_icao != '') {
2451 2451
 			if ($globalDBdriver == 'mysql') {
@@ -2453,11 +2453,11 @@  discard block
 block discarded – undo
2453 2453
 			} else {
2454 2454
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2455 2455
 			}
2456
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2456
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2457 2457
 			try {
2458 2458
 				$sth = $this->db->prepare($query);
2459 2459
 				$sth->execute($query_values);
2460
-			} catch(PDOException $e) {
2460
+			} catch (PDOException $e) {
2461 2461
 				return "error : ".$e->getMessage();
2462 2462
 			}
2463 2463
 		}
@@ -2469,7 +2469,7 @@  discard block
 block discarded – undo
2469 2469
 		try {
2470 2470
 			$sth = $this->db->prepare($query);
2471 2471
 			$sth->execute($query_values);
2472
-		} catch(PDOException $e) {
2472
+		} catch (PDOException $e) {
2473 2473
 			return "error : ".$e->getMessage();
2474 2474
 		}
2475 2475
 	}
@@ -2479,7 +2479,7 @@  discard block
 block discarded – undo
2479 2479
 		try {
2480 2480
 			$sth = $this->db->prepare($query);
2481 2481
 			$sth->execute($query_values);
2482
-		} catch(PDOException $e) {
2482
+		} catch (PDOException $e) {
2483 2483
 			return "error : ".$e->getMessage();
2484 2484
 		}
2485 2485
 	}
@@ -2489,7 +2489,7 @@  discard block
 block discarded – undo
2489 2489
 		try {
2490 2490
 			$sth = $this->db->prepare($query);
2491 2491
 			$sth->execute($query_values);
2492
-		} catch(PDOException $e) {
2492
+		} catch (PDOException $e) {
2493 2493
 			return "error : ".$e->getMessage();
2494 2494
 		}
2495 2495
 	}
@@ -2499,7 +2499,7 @@  discard block
 block discarded – undo
2499 2499
 		try {
2500 2500
 			$sth = $this->db->prepare($query);
2501 2501
 			$sth->execute($query_values);
2502
-		} catch(PDOException $e) {
2502
+		} catch (PDOException $e) {
2503 2503
 			return "error : ".$e->getMessage();
2504 2504
 		}
2505 2505
 	}
@@ -2509,13 +2509,13 @@  discard block
 block discarded – undo
2509 2509
 		try {
2510 2510
 			$sth = $this->db->prepare($query);
2511 2511
 			$sth->execute($query_values);
2512
-		} catch(PDOException $e) {
2512
+		} catch (PDOException $e) {
2513 2513
 			return "error : ".$e->getMessage();
2514 2514
 		}
2515 2515
 	}
2516 2516
 
2517 2517
 	public function addOldStats() {
2518
-		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
2518
+		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents;
2519 2519
 		$Common = new Common();
2520 2520
 		$Connection = new Connection($this->db);
2521 2521
 		date_default_timezone_set('UTC');
@@ -2530,9 +2530,9 @@  discard block
 block discarded – undo
2530 2530
 			$filtername = 'marine';
2531 2531
 			if ($Connection->tableExists('countries')) {
2532 2532
 				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2533
-				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2533
+				$alldata = $Marine->countAllMarineOverCountries(false, 0, $last_update_day);
2534 2534
 				foreach ($alldata as $number) {
2535
-					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2535
+					echo $this->addStatCountryMarine($number['marine_country_iso2'], $number['marine_country_iso3'], $number['marine_country'], $number['marine_count'], '', '', $reset);
2536 2536
 				}
2537 2537
 			}
2538 2538
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2542,44 +2542,44 @@  discard block
 block discarded – undo
2542 2542
 			$lastyear = false;
2543 2543
 			foreach ($alldata as $number) {
2544 2544
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2545
-				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2545
+				$this->addStat('marine_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2546 2546
 			}
2547 2547
 			echo 'Marine data...'."\n";
2548 2548
 			$this->deleteStatMarine('month');
2549 2549
 			echo '-> countAllDatesLastMonth...'."\n";
2550 2550
 			$alldata = $Marine->countAllDatesLastMonth($filter_last_month);
2551 2551
 			foreach ($alldata as $number) {
2552
-				$this->addStatMarine('month',$number['date_name'],$number['date_count']);
2552
+				$this->addStatMarine('month', $number['date_name'], $number['date_count']);
2553 2553
 			}
2554 2554
 			echo '-> countAllDates...'."\n";
2555 2555
 			$previousdata = $this->countAllDatesMarine();
2556 2556
 			$this->deleteStatMarine('date');
2557
-			$alldata = $Common->array_merge_noappend($previousdata,$Marine->countAllDates($filter_last_month));
2557
+			$alldata = $Common->array_merge_noappend($previousdata, $Marine->countAllDates($filter_last_month));
2558 2558
 			$values = array();
2559 2559
 			foreach ($alldata as $cnt) {
2560 2560
 				$values[] = $cnt['date_count'];
2561 2561
 			}
2562
-			array_multisort($values,SORT_DESC,$alldata);
2563
-			array_splice($alldata,11);
2562
+			array_multisort($values, SORT_DESC, $alldata);
2563
+			array_splice($alldata, 11);
2564 2564
 			foreach ($alldata as $number) {
2565
-				$this->addStatMarine('date',$number['date_name'],$number['date_count']);
2565
+				$this->addStatMarine('date', $number['date_name'], $number['date_count']);
2566 2566
 			}
2567 2567
 			
2568 2568
 			$this->deleteStatMarine('hour');
2569 2569
 			echo '-> countAllHours...'."\n";
2570
-			$alldata = $Marine->countAllHours('hour',$filter_last_month);
2570
+			$alldata = $Marine->countAllHours('hour', $filter_last_month);
2571 2571
 			foreach ($alldata as $number) {
2572
-				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2572
+				$this->addStatMarine('hour', $number['hour_name'], $number['hour_count']);
2573 2573
 			}
2574 2574
 			if ($globalDebug) echo 'Count all types...'."\n";
2575
-			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2575
+			$alldata = $Marine->countAllMarineTypes(false, 0, $last_update_day);
2576 2576
 			foreach ($alldata as $number) {
2577
-				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
2577
+				$this->addStatMarineType($number['marine_type'], $number['marine_type_id'], $number['marine_type_count'], '', $reset);
2578 2578
 			}
2579 2579
 
2580 2580
 			echo 'Insert last stats update date...'."\n";
2581 2581
 			date_default_timezone_set('UTC');
2582
-			$this->addLastStatsUpdate('last_update_stats_marine',date('Y-m-d G:i:s'));
2582
+			$this->addLastStatsUpdate('last_update_stats_marine', date('Y-m-d G:i:s'));
2583 2583
 		}
2584 2584
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2585 2585
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
@@ -2591,9 +2591,9 @@  discard block
 block discarded – undo
2591 2591
 			$Tracker = new Tracker($this->db);
2592 2592
 			if ($Connection->tableExists('countries')) {
2593 2593
 				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2594
-				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2594
+				$alldata = $Tracker->countAllTrackerOverCountries(false, 0, $last_update_day);
2595 2595
 				foreach ($alldata as $number) {
2596
-					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2596
+					$this->addStatCountryTracker($number['tracker_country_iso2'], $number['tracker_country_iso3'], $number['tracker_country'], $number['tracker_count'], '', '', $reset);
2597 2597
 				}
2598 2598
 			}
2599 2599
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2603,43 +2603,43 @@  discard block
 block discarded – undo
2603 2603
 			$lastyear = false;
2604 2604
 			foreach ($alldata as $number) {
2605 2605
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2606
-				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2606
+				$this->addStat('tracker_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2607 2607
 			}
2608 2608
 			echo 'Tracker data...'."\n";
2609 2609
 			$this->deleteStatTracker('month');
2610 2610
 			echo '-> countAllDatesLastMonth...'."\n";
2611 2611
 			$alldata = $Tracker->countAllDatesLastMonth($filter_last_month);
2612 2612
 			foreach ($alldata as $number) {
2613
-				$this->addStatTracker('month',$number['date_name'],$number['date_count']);
2613
+				$this->addStatTracker('month', $number['date_name'], $number['date_count']);
2614 2614
 			}
2615 2615
 			echo '-> countAllDates...'."\n";
2616 2616
 			$previousdata = $this->countAllDatesTracker();
2617 2617
 			$this->deleteStatTracker('date');
2618
-			$alldata = $Common->array_merge_noappend($previousdata,$Tracker->countAllDates($filter_last_month));
2618
+			$alldata = $Common->array_merge_noappend($previousdata, $Tracker->countAllDates($filter_last_month));
2619 2619
 			$values = array();
2620 2620
 			foreach ($alldata as $cnt) {
2621 2621
 				$values[] = $cnt['date_count'];
2622 2622
 			}
2623
-			array_multisort($values,SORT_DESC,$alldata);
2624
-			array_splice($alldata,11);
2623
+			array_multisort($values, SORT_DESC, $alldata);
2624
+			array_splice($alldata, 11);
2625 2625
 			foreach ($alldata as $number) {
2626
-				$this->addStatTracker('date',$number['date_name'],$number['date_count']);
2626
+				$this->addStatTracker('date', $number['date_name'], $number['date_count']);
2627 2627
 			}
2628 2628
 			
2629 2629
 			$this->deleteStatTracker('hour');
2630 2630
 			echo '-> countAllHours...'."\n";
2631
-			$alldata = $Tracker->countAllHours('hour',$filter_last_month);
2631
+			$alldata = $Tracker->countAllHours('hour', $filter_last_month);
2632 2632
 			foreach ($alldata as $number) {
2633
-				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2633
+				$this->addStatTracker('hour', $number['hour_name'], $number['hour_count']);
2634 2634
 			}
2635 2635
 			if ($globalDebug) echo 'Count all types...'."\n";
2636
-			$alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day);
2636
+			$alldata = $Tracker->countAllTrackerTypes(false, 0, $last_update_day);
2637 2637
 			foreach ($alldata as $number) {
2638
-				$this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset);
2638
+				$this->addStatTrackerType($number['tracker_type'], $number['tracker_type_count'], '', $reset);
2639 2639
 			}
2640 2640
 			echo 'Insert last stats update date...'."\n";
2641 2641
 			date_default_timezone_set('UTC');
2642
-			$this->addLastStatsUpdate('last_update_stats_tracker',date('Y-m-d G:i:s'));
2642
+			$this->addLastStatsUpdate('last_update_stats_tracker', date('Y-m-d G:i:s'));
2643 2643
 		}
2644 2644
 
2645 2645
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
@@ -2657,41 +2657,41 @@  discard block
 block discarded – undo
2657 2657
 			$Spotter = new Spotter($this->db);
2658 2658
 
2659 2659
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2660
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2660
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
2661 2661
 			foreach ($alldata as $number) {
2662
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2662
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
2663 2663
 			}
2664 2664
 			if ($globalDebug) echo 'Count all airlines...'."\n";
2665
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2665
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
2666 2666
 			foreach ($alldata as $number) {
2667
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2667
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
2668 2668
 			}
2669 2669
 			if ($globalDebug) echo 'Count all registrations...'."\n";
2670
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2670
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
2671 2671
 			foreach ($alldata as $number) {
2672
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2672
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
2673 2673
 			}
2674 2674
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
2675
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2675
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
2676 2676
 			foreach ($alldata as $number) {
2677
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2677
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2678 2678
 			}
2679 2679
 			if ($globalDebug) echo 'Count all owners...'."\n";
2680
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2680
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
2681 2681
 			foreach ($alldata as $number) {
2682
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2682
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
2683 2683
 			}
2684 2684
 			if ($globalDebug) echo 'Count all pilots...'."\n";
2685
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2685
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
2686 2686
 			foreach ($alldata as $number) {
2687 2687
 				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2688
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2688
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
2689 2689
 			}
2690 2690
 			
2691 2691
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
2692
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2692
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
2693 2693
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2694
-			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2694
+			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
2695 2695
 			if ($globalDebug) echo 'Order departure airports...'."\n";
2696 2696
 			$alldata = array();
2697 2697
 			foreach ($pall as $value) {
@@ -2708,14 +2708,14 @@  discard block
 block discarded – undo
2708 2708
 			foreach ($alldata as $key => $row) {
2709 2709
 				$count[$key] = $row['airport_departure_icao_count'];
2710 2710
 			}
2711
-			array_multisort($count,SORT_DESC,$alldata);
2711
+			array_multisort($count, SORT_DESC, $alldata);
2712 2712
 			foreach ($alldata as $number) {
2713
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
2713
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset);
2714 2714
 			}
2715 2715
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2716
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2716
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
2717 2717
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2718
-			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2718
+			$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
2719 2719
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
2720 2720
 			$alldata = array();
2721 2721
 			foreach ($pall as $value) {
@@ -2732,18 +2732,18 @@  discard block
 block discarded – undo
2732 2732
 			foreach ($alldata as $key => $row) {
2733 2733
 				$count[$key] = $row['airport_arrival_icao_count'];
2734 2734
 			}
2735
-			array_multisort($count,SORT_DESC,$alldata);
2735
+			array_multisort($count, SORT_DESC, $alldata);
2736 2736
 			foreach ($alldata as $number) {
2737
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
2737
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset);
2738 2738
 			}
2739 2739
 			if ($Connection->tableExists('countries')) {
2740 2740
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2741 2741
 				//$SpotterArchive = new SpotterArchive();
2742 2742
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2743 2743
 				$Spotter = new Spotter($this->db);
2744
-				$alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day);
2744
+				$alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day);
2745 2745
 				foreach ($alldata as $number) {
2746
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
2746
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
2747 2747
 				}
2748 2748
 			}
2749 2749
 			
@@ -2753,12 +2753,12 @@  discard block
 block discarded – undo
2753 2753
 				$this->deleteStatsByType('fatalities_byyear');
2754 2754
 				$alldata = $Accident->countFatalitiesByYear();
2755 2755
 				foreach ($alldata as $number) {
2756
-					$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
2756
+					$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
2757 2757
 				}
2758 2758
 				$this->deleteStatsByType('fatalities_bymonth');
2759 2759
 				$alldata = $Accident->countFatalitiesLast12Months();
2760 2760
 				foreach ($alldata as $number) {
2761
-					$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
2761
+					$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
2762 2762
 				}
2763 2763
 			}
2764 2764
 
@@ -2772,37 +2772,37 @@  discard block
 block discarded – undo
2772 2772
 			$lastyear = false;
2773 2773
 			foreach ($alldata as $number) {
2774 2774
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2775
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2775
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2776 2776
 			}
2777 2777
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2778 2778
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2779 2779
 			foreach ($alldata as $number) {
2780
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2780
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2781 2781
 			}
2782 2782
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
2783 2783
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2784 2784
 			foreach ($alldata as $number) {
2785
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2785
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2786 2786
 			}
2787 2787
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2788 2788
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2789 2789
 			foreach ($alldata as $number) {
2790
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2790
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2791 2791
 			}
2792 2792
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2793 2793
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2794 2794
 			foreach ($alldata as $number) {
2795
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2795
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2796 2796
 			}
2797 2797
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2798 2798
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2799 2799
 			foreach ($alldata as $number) {
2800
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2800
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2801 2801
 			}
2802 2802
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2803 2803
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2804 2804
 			foreach ($alldata as $number) {
2805
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2805
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2806 2806
 			}
2807 2807
 			if ($globalDebug) echo 'Airports data...'."\n";
2808 2808
 			if ($globalDebug) echo '...Departure'."\n";
@@ -2847,7 +2847,7 @@  discard block
 block discarded – undo
2847 2847
 			}
2848 2848
 			$alldata = $pall;
2849 2849
 			foreach ($alldata as $number) {
2850
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
2850
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
2851 2851
 			}
2852 2852
 			echo '...Arrival'."\n";
2853 2853
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -2888,7 +2888,7 @@  discard block
 block discarded – undo
2888 2888
 			}
2889 2889
 			$alldata = $pall;
2890 2890
 			foreach ($alldata as $number) {
2891
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
2891
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
2892 2892
 			}
2893 2893
 
2894 2894
 			echo 'Flights data...'."\n";
@@ -2896,28 +2896,28 @@  discard block
 block discarded – undo
2896 2896
 			echo '-> countAllDatesLastMonth...'."\n";
2897 2897
 			$alldata = $Spotter->countAllDatesLastMonth($filter_last_month);
2898 2898
 			foreach ($alldata as $number) {
2899
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
2899
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
2900 2900
 			}
2901 2901
 			echo '-> countAllDates...'."\n";
2902 2902
 			$previousdata = $this->countAllDates();
2903 2903
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
2904 2904
 			$this->deleteStatFlight('date');
2905
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month));
2905
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month));
2906 2906
 			$values = array();
2907 2907
 			foreach ($alldata as $cnt) {
2908 2908
 				$values[] = $cnt['date_count'];
2909 2909
 			}
2910
-			array_multisort($values,SORT_DESC,$alldata);
2911
-			array_splice($alldata,11);
2910
+			array_multisort($values, SORT_DESC, $alldata);
2911
+			array_splice($alldata, 11);
2912 2912
 			foreach ($alldata as $number) {
2913
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
2913
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
2914 2914
 			}
2915 2915
 			
2916 2916
 			$this->deleteStatFlight('hour');
2917 2917
 			echo '-> countAllHours...'."\n";
2918
-			$alldata = $Spotter->countAllHours('hour',$filter_last_month);
2918
+			$alldata = $Spotter->countAllHours('hour', $filter_last_month);
2919 2919
 			foreach ($alldata as $number) {
2920
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
2920
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
2921 2921
 			}
2922 2922
 
2923 2923
 			// Count by airlines
@@ -2926,42 +2926,42 @@  discard block
 block discarded – undo
2926 2926
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2927 2927
 				$SpotterArchive = new SpotterArchive($this->db);
2928 2928
 				//$Spotter = new Spotter($this->db);
2929
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2929
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
2930 2930
 				//$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2931 2931
 				foreach ($alldata as $number) {
2932
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2932
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
2933 2933
 				}
2934 2934
 			}
2935 2935
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2936 2936
 			$Spotter = new Spotter($this->db);
2937
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2937
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
2938 2938
 			foreach ($alldata as $number) {
2939
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2939
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
2940 2940
 			}
2941 2941
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2942
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2942
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
2943 2943
 			foreach ($alldata as $number) {
2944
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2944
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
2945 2945
 			}
2946 2946
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2947
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2947
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
2948 2948
 			foreach ($alldata as $number) {
2949
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2949
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2950 2950
 			}
2951 2951
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2952
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2952
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
2953 2953
 			foreach ($alldata as $number) {
2954
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2954
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
2955 2955
 			}
2956 2956
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2957
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2957
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
2958 2958
 			foreach ($alldata as $number) {
2959
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2959
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
2960 2960
 			}
2961 2961
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2962
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2962
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
2963 2963
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2964
-			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2964
+			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
2965 2965
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2966 2966
 			//$alldata = array();
2967 2967
 			foreach ($dall as $value) {
@@ -2981,12 +2981,12 @@  discard block
 block discarded – undo
2981 2981
 			}
2982 2982
 			$alldata = $pall;
2983 2983
 			foreach ($alldata as $number) {
2984
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
2984
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset);
2985 2985
 			}
2986 2986
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2987
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2987
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
2988 2988
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2989
-			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2989
+			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
2990 2990
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2991 2991
 			//$alldata = array();
2992 2992
 			foreach ($dall as $value) {
@@ -3006,7 +3006,7 @@  discard block
 block discarded – undo
3006 3006
 			}
3007 3007
 			$alldata = $pall;
3008 3008
 			foreach ($alldata as $number) {
3009
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
3009
+				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset);
3010 3010
 			}
3011 3011
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
3012 3012
 			$Spotter = new Spotter($this->db);
@@ -3014,27 +3014,27 @@  discard block
 block discarded – undo
3014 3014
 			$lastyear = false;
3015 3015
 			foreach ($alldata as $number) {
3016 3016
 				if ($number['year_name'] != date('Y')) $lastyear = true;
3017
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3017
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3018 3018
 			}
3019 3019
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3020 3020
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
3021 3021
 			foreach ($alldata as $number) {
3022
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3022
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3023 3023
 			}
3024 3024
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3025 3025
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
3026 3026
 			foreach ($alldata as $number) {
3027
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3027
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3028 3028
 			}
3029 3029
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3030 3030
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
3031 3031
 			foreach ($alldata as $number) {
3032
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3032
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3033 3033
 			}
3034 3034
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3035 3035
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
3036 3036
 			foreach ($alldata as $number) {
3037
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3037
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3038 3038
 			}
3039 3039
 			if ($globalDebug) echo '...Departure'."\n";
3040 3040
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -3057,7 +3057,7 @@  discard block
 block discarded – undo
3057 3057
 			}
3058 3058
 			$alldata = $pall;
3059 3059
 			foreach ($alldata as $number) {
3060
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
3060
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']);
3061 3061
 			}
3062 3062
 			if ($globalDebug) echo '...Arrival'."\n";
3063 3063
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -3080,32 +3080,32 @@  discard block
 block discarded – undo
3080 3080
 			}
3081 3081
 			$alldata = $pall;
3082 3082
 			foreach ($alldata as $number) {
3083
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
3083
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']);
3084 3084
 			}
3085 3085
 
3086 3086
 			if ($globalDebug) echo 'Flights data...'."\n";
3087 3087
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3088 3088
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
3089 3089
 			foreach ($alldata as $number) {
3090
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
3090
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
3091 3091
 			}
3092 3092
 			if ($globalDebug) echo '-> countAllDates...'."\n";
3093 3093
 			//$previousdata = $this->countAllDatesByAirlines();
3094
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
3094
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month));
3095 3095
 			$values = array();
3096 3096
 			foreach ($alldata as $cnt) {
3097 3097
 				$values[] = $cnt['date_count'];
3098 3098
 			}
3099
-			array_multisort($values,SORT_DESC,$alldata);
3100
-			array_splice($alldata,11);
3099
+			array_multisort($values, SORT_DESC, $alldata);
3100
+			array_splice($alldata, 11);
3101 3101
 			foreach ($alldata as $number) {
3102
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
3102
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
3103 3103
 			}
3104 3104
 			
3105 3105
 			if ($globalDebug) echo '-> countAllHours...'."\n";
3106
-			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
3106
+			$alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month);
3107 3107
 			foreach ($alldata as $number) {
3108
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
3108
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
3109 3109
 			}
3110 3110
 
3111 3111
 			// Stats by filters
@@ -3129,7 +3129,7 @@  discard block
 block discarded – undo
3129 3129
 							$last_update_day = date('Y').'-01-01 00:00:00';
3130 3130
 						}
3131 3131
 					}
3132
-					if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
3132
+					if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
3133 3133
 						$last_update_day = date('Y').'-01-01 00:00:00';
3134 3134
 						$reset = true;
3135 3135
 					}
@@ -3137,38 +3137,38 @@  discard block
 block discarded – undo
3137 3137
 					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3138 3138
 					$Spotter = new Spotter($this->db);
3139 3139
 					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3140
-					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
3140
+					$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
3141 3141
 					foreach ($alldata as $number) {
3142
-						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
3142
+						$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
3143 3143
 					}
3144 3144
 					if ($globalDebug) echo 'Count all airlines...'."\n";
3145
-					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
3145
+					$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
3146 3146
 					foreach ($alldata as $number) {
3147
-						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
3147
+						$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
3148 3148
 					}
3149 3149
 					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3150
-					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
3150
+					$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
3151 3151
 					foreach ($alldata as $number) {
3152
-						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
3152
+						$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
3153 3153
 					}
3154 3154
 					if ($globalDebug) echo 'Count all callsigns...'."\n";
3155
-					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
3155
+					$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
3156 3156
 					foreach ($alldata as $number) {
3157
-						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
3157
+						$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
3158 3158
 					}
3159 3159
 					if ($globalDebug) echo 'Count all owners...'."\n";
3160
-					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
3160
+					$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
3161 3161
 					foreach ($alldata as $number) {
3162
-						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
3162
+						$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
3163 3163
 					}
3164 3164
 					if ($globalDebug) echo 'Count all pilots...'."\n";
3165
-					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
3165
+					$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
3166 3166
 					foreach ($alldata as $number) {
3167
-						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
3167
+						$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
3168 3168
 					}
3169 3169
 					if ($globalDebug) echo 'Count departure airports...'."\n";
3170
-					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
3171
-					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
3170
+					$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
3171
+					$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
3172 3172
 					$alldata = array();
3173 3173
 					foreach ($pall as $value) {
3174 3174
 						$icao = $value['airport_departure_icao'];
@@ -3184,13 +3184,13 @@  discard block
 block discarded – undo
3184 3184
 					foreach ($alldata as $key => $row) {
3185 3185
 						$count[$key] = $row['airport_departure_icao_count'];
3186 3186
 					}
3187
-					array_multisort($count,SORT_DESC,$alldata);
3187
+					array_multisort($count, SORT_DESC, $alldata);
3188 3188
 					foreach ($alldata as $number) {
3189
-						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
3189
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
3190 3190
 					}
3191 3191
 					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3192
-					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
3193
-					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
3192
+					$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
3193
+					$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
3194 3194
 					$alldata = array();
3195 3195
 					foreach ($pall as $value) {
3196 3196
 						$icao = $value['airport_arrival_icao'];
@@ -3206,9 +3206,9 @@  discard block
 block discarded – undo
3206 3206
 					foreach ($alldata as $key => $row) {
3207 3207
 						$count[$key] = $row['airport_arrival_icao_count'];
3208 3208
 					}
3209
-					array_multisort($count,SORT_DESC,$alldata);
3209
+					array_multisort($count, SORT_DESC, $alldata);
3210 3210
 					foreach ($alldata as $number) {
3211
-						echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
3211
+						echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
3212 3212
 					}
3213 3213
 					if ($globalDebug) echo 'Count all months...'."\n";
3214 3214
 					$Spotter = new Spotter($this->db);
@@ -3216,36 +3216,36 @@  discard block
 block discarded – undo
3216 3216
 					$lastyear = false;
3217 3217
 					foreach ($alldata as $number) {
3218 3218
 						if ($number['year_name'] != date('Y')) $lastyear = true;
3219
-						$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3219
+						$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3220 3220
 					}
3221 3221
 					if ($globalDebug) echo 'Count all owners by months...'."\n";
3222 3222
 					$alldata = $Spotter->countAllMonthsOwners($filter);
3223 3223
 					foreach ($alldata as $number) {
3224
-						$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3224
+						$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3225 3225
 					}
3226 3226
 					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3227 3227
 					$alldata = $Spotter->countAllMonthsPilots($filter);
3228 3228
 					foreach ($alldata as $number) {
3229
-						$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3229
+						$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3230 3230
 					}
3231 3231
 					if ($globalDebug) echo 'Count all military by months...'."\n";
3232 3232
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
3233 3233
 					foreach ($alldata as $number) {
3234
-						$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3234
+						$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3235 3235
 					}
3236 3236
 					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3237 3237
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
3238 3238
 				    	foreach ($alldata as $number) {
3239
-			    			$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3239
+			    			$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3240 3240
 					}
3241 3241
 					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3242 3242
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
3243 3243
 					foreach ($alldata as $number) {
3244
-						$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3244
+						$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3245 3245
 					}
3246 3246
 					echo '...Departure'."\n";
3247
-					$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
3248
-					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
3247
+					$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
3248
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
3249 3249
 					foreach ($dall as $value) {
3250 3250
 						$icao = $value['departure_airport_icao'];
3251 3251
 						$ddate = $value['date'];
@@ -3263,11 +3263,11 @@  discard block
 block discarded – undo
3263 3263
 					}
3264 3264
 					$alldata = $pall;
3265 3265
 					foreach ($alldata as $number) {
3266
-						$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
3266
+						$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name);
3267 3267
 					}
3268 3268
 					echo '...Arrival'."\n";
3269
-					$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
3270
-					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
3269
+					$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
3270
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
3271 3271
 					foreach ($dall as $value) {
3272 3272
 						$icao = $value['arrival_airport_icao'];
3273 3273
 						$ddate = $value['date'];
@@ -3285,39 +3285,39 @@  discard block
 block discarded – undo
3285 3285
 					}
3286 3286
 					$alldata = $pall;
3287 3287
 					foreach ($alldata as $number) {
3288
-						$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
3288
+						$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name);
3289 3289
 					}
3290 3290
 					echo 'Flights data...'."\n";
3291 3291
 					echo '-> countAllDatesLastMonth...'."\n";
3292 3292
 					$alldata = $Spotter->countAllDatesLastMonth($filter);
3293 3293
 					foreach ($alldata as $number) {
3294
-						$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
3294
+						$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
3295 3295
 					}
3296 3296
 					echo '-> countAllDates...'."\n";
3297
-					$previousdata = $this->countAllDates('',$filter_name);
3298
-					$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
3297
+					$previousdata = $this->countAllDates('', $filter_name);
3298
+					$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
3299 3299
 					$values = array();
3300 3300
 					foreach ($alldata as $cnt) {
3301 3301
 						$values[] = $cnt['date_count'];
3302 3302
 					}
3303
-					array_multisort($values,SORT_DESC,$alldata);
3304
-					array_splice($alldata,11);
3303
+					array_multisort($values, SORT_DESC, $alldata);
3304
+					array_splice($alldata, 11);
3305 3305
 					foreach ($alldata as $number) {
3306
-						$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
3306
+						$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
3307 3307
 					}
3308 3308
 				
3309 3309
 					echo '-> countAllHours...'."\n";
3310
-					$alldata = $Spotter->countAllHours('hour',$filter);
3310
+					$alldata = $Spotter->countAllHours('hour', $filter);
3311 3311
 					foreach ($alldata as $number) {
3312
-						$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
3312
+						$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
3313 3313
 					}
3314 3314
 					echo 'Insert last stats update date...'."\n";
3315 3315
 					date_default_timezone_set('UTC');
3316
-					$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
3316
+					$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
3317 3317
 					if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
3318
-						if (date('Y',strtotime($last_update_day)) != date('Y')) {
3318
+						if (date('Y', strtotime($last_update_day)) != date('Y')) {
3319 3319
 							$this->deleteOldStats($filter_name);
3320
-							$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
3320
+							$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
3321 3321
 						}
3322 3322
 					}
3323 3323
 				}
@@ -3330,16 +3330,16 @@  discard block
 block discarded – undo
3330 3330
 				// SUM all previous month to put as year
3331 3331
 				$previous_year = date('Y');
3332 3332
 				$previous_year--;
3333
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3334
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3335
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3336
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3333
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3334
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3335
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3336
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3337 3337
 				$allairlines = $this->getAllAirlineNames();
3338 3338
 				foreach ($allairlines as $data) {
3339
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3340
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3341
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3342
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3339
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3340
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3341
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3342
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3343 3343
 				}
3344 3344
 				
3345 3345
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -3348,21 +3348,21 @@  discard block
 block discarded – undo
3348 3348
 						try {
3349 3349
 							$sth = $this->db->prepare($query);
3350 3350
 							$sth->execute();
3351
-						} catch(PDOException $e) {
3351
+						} catch (PDOException $e) {
3352 3352
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3353 3353
 						}
3354 3354
 						$query = "INSERT INTO tracker_archive_output SELECT * FROM tracker_output WHERE tracker_output.date < '".date('Y')."-01-01 00:00:00'";
3355 3355
 						try {
3356 3356
 							$sth = $this->db->prepare($query);
3357 3357
 							$sth->execute();
3358
-						} catch(PDOException $e) {
3358
+						} catch (PDOException $e) {
3359 3359
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3360 3360
 						}
3361 3361
 						$query = "INSERT INTO marine_archive_output SELECT * FROM marine_output WHERE marine_output.date < '".date('Y')."-01-01 00:00:00'";
3362 3362
 						try {
3363 3363
 							$sth = $this->db->prepare($query);
3364 3364
 							$sth->execute();
3365
-						} catch(PDOException $e) {
3365
+						} catch (PDOException $e) {
3366 3366
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3367 3367
 						}
3368 3368
 					}
@@ -3375,7 +3375,7 @@  discard block
 block discarded – undo
3375 3375
 					try {
3376 3376
 						$sth = $this->db->prepare($query);
3377 3377
 						$sth->execute();
3378
-					} catch(PDOException $e) {
3378
+					} catch (PDOException $e) {
3379 3379
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3380 3380
 					}
3381 3381
 					if ($globalDBdriver == 'mysql') {
@@ -3386,7 +3386,7 @@  discard block
 block discarded – undo
3386 3386
 					try {
3387 3387
 						$sth = $this->db->prepare($query);
3388 3388
 						$sth->execute();
3389
-					} catch(PDOException $e) {
3389
+					} catch (PDOException $e) {
3390 3390
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3391 3391
 					}
3392 3392
 					if ($globalDBdriver == 'mysql') {
@@ -3397,15 +3397,15 @@  discard block
 block discarded – undo
3397 3397
 					try {
3398 3398
 						$sth = $this->db->prepare($query);
3399 3399
 						$sth->execute();
3400
-					} catch(PDOException $e) {
3400
+					} catch (PDOException $e) {
3401 3401
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3402 3402
 					}
3403 3403
 				}
3404 3404
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
3405 3405
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
3406
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
3406
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
3407 3407
 						$this->deleteOldStats();
3408
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
3408
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
3409 3409
 						$lastyearupdate = true;
3410 3410
 					}
3411 3411
 				}
@@ -3427,7 +3427,7 @@  discard block
 block discarded – undo
3427 3427
 					try {
3428 3428
 						$sth = $this->db->prepare($query);
3429 3429
 						$sth->execute();
3430
-					} catch(PDOException $e) {
3430
+					} catch (PDOException $e) {
3431 3431
 						return "error : ".$e->getMessage();
3432 3432
 					}
3433 3433
 					echo 'Archive old tracker data...'."\n";
@@ -3443,7 +3443,7 @@  discard block
 block discarded – undo
3443 3443
 					try {
3444 3444
 						$sth = $this->db->prepare($query);
3445 3445
 						$sth->execute();
3446
-					} catch(PDOException $e) {
3446
+					} catch (PDOException $e) {
3447 3447
 						return "error : ".$e->getMessage();
3448 3448
 					}
3449 3449
 					echo 'Archive old marine data...'."\n";
@@ -3459,7 +3459,7 @@  discard block
 block discarded – undo
3459 3459
 					try {
3460 3460
 						$sth = $this->db->prepare($query);
3461 3461
 						$sth->execute();
3462
-					} catch(PDOException $e) {
3462
+					} catch (PDOException $e) {
3463 3463
 						return "error : ".$e->getMessage();
3464 3464
 					}
3465 3465
 				}
@@ -3472,7 +3472,7 @@  discard block
 block discarded – undo
3472 3472
 				try {
3473 3473
 					$sth = $this->db->prepare($query);
3474 3474
 					$sth->execute();
3475
-				} catch(PDOException $e) {
3475
+				} catch (PDOException $e) {
3476 3476
 					return "error : ".$e->getMessage();
3477 3477
 				}
3478 3478
 				echo 'Deleting old tracker data...'."\n";
@@ -3484,7 +3484,7 @@  discard block
 block discarded – undo
3484 3484
 				try {
3485 3485
 					$sth = $this->db->prepare($query);
3486 3486
 					$sth->execute();
3487
-				} catch(PDOException $e) {
3487
+				} catch (PDOException $e) {
3488 3488
 					return "error : ".$e->getMessage();
3489 3489
 				}
3490 3490
 				echo 'Deleting old marine data...'."\n";
@@ -3496,14 +3496,14 @@  discard block
 block discarded – undo
3496 3496
 				try {
3497 3497
 					$sth = $this->db->prepare($query);
3498 3498
 					$sth->execute();
3499
-				} catch(PDOException $e) {
3499
+				} catch (PDOException $e) {
3500 3500
 					return "error : ".$e->getMessage();
3501 3501
 				}
3502 3502
 			}
3503 3503
 			if (!isset($lastyearupdate)) {
3504 3504
 				echo 'Insert last stats update date...'."\n";
3505 3505
 				date_default_timezone_set('UTC');
3506
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
3506
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
3507 3507
 			}
3508 3508
 			if ($globalStatsResetYear) {
3509 3509
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -26,33 +26,33 @@  discard block
 block discarded – undo
26 26
      * @param bool $and
27 27
      * @return string the SQL part
28 28
      */
29
-	public function getFilter($filter = array(),$where = false,$and = false) {
29
+	public function getFilter($filter = array(), $where = false, $and = false) {
30 30
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
31 31
 		$filters = array();
32 32
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
33 33
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
34 34
 				$filters = $globalStatsFilters[$globalFilterName];
35 35
 			} else {
36
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
36
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
37 37
 			}
38 38
 		}
39 39
 		if (isset($filter[0]['source'])) {
40
-			$filters = array_merge($filters,$filter);
40
+			$filters = array_merge($filters, $filter);
41 41
 		}
42
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
42
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
43 43
 		$filter_query_join = '';
44 44
 		$filter_query_where = '';
45
-		foreach($filters as $flt) {
45
+		foreach ($filters as $flt) {
46 46
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
47 47
 				if (isset($flt['source'])) {
48
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
48
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
49 49
 				} else {
50
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
50
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
51 51
 				}
52 52
 			}
53 53
 		}
54 54
 		if (isset($filter['source']) && !empty($filter['source'])) {
55
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
55
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
56 56
 		}
57 57
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
58 58
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -84,15 +84,15 @@  discard block
 block discarded – undo
84 84
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
85 85
 				}
86 86
 			}
87
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
87
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
88 88
 		}
89 89
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
90
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
90
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
91 91
 		}
92 92
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
93 93
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
94 94
 		if ($filter_query_where != '') {
95
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
95
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
96 96
 		}
97 97
 		$filter_query = $filter_query_join.$filter_query_where;
98 98
 		return $filter_query;
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 		if ($limit != '')
118 118
 		{
119 119
 			$limit_array = explode(',', $limit);
120
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
121
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
120
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
121
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
122 122
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
123 123
 			{
124 124
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		} else {
142 142
 			$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query;
143 143
 		}
144
-		$spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true);
144
+		$spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true);
145 145
 
146 146
 		return $spotter_array;
147 147
 	}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		global $globalDBdriver, $globalLiveInterval;
158 158
 		date_default_timezone_set('UTC');
159 159
 
160
-		$filter_query = $this->getFilter($filter,true,true);
160
+		$filter_query = $this->getFilter($filter, true, true);
161 161
 
162 162
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
163 163
 		if ($globalDBdriver == 'mysql') {
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		try {
176 176
 			$sth = $this->db->prepare($query);
177 177
 			$sth->execute();
178
-		} catch(PDOException $e) {
178
+		} catch (PDOException $e) {
179 179
 			echo $e->getMessage();
180 180
 			die;
181 181
 		}
@@ -192,25 +192,25 @@  discard block
 block discarded – undo
192 192
      * @param bool $limit
193 193
      * @return array the spotter information
194 194
      */
195
-	public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false)
195
+	public function getMinLastLiveTrackerData($coord, $filter = array(), $limit = false)
196 196
 	{
197 197
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit;
198 198
 		date_default_timezone_set('UTC');
199 199
 		$usecoord = false;
200 200
 		if (is_array($coord) && !empty($coord)) {
201
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
202
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
203
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
204
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
201
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
202
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
203
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
204
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
205 205
 			$usecoord = true;
206 206
 		}
207
-		$filter_query = $this->getFilter($filter,true,true);
207
+		$filter_query = $this->getFilter($filter, true, true);
208 208
 
209 209
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
210 210
 		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
211 211
 		if ($globalDBdriver == 'mysql') {
212 212
 			if (isset($globalArchive) && $globalArchive) {
213
-				$query  = "SELECT * FROM (
213
+				$query = "SELECT * FROM (
214 214
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
215 215
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
216 216
 				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			}
233 233
 		} else {
234 234
 			if (isset($globalArchive) && $globalArchive) {
235
-				$query  = "SELECT * FROM (
235
+				$query = "SELECT * FROM (
236 236
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
237 237
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
238 238
 				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		try {
257 257
 			$sth = $this->db->prepare($query);
258 258
 			$sth->execute();
259
-		} catch(PDOException $e) {
259
+		} catch (PDOException $e) {
260 260
 			echo $e->getMessage();
261 261
 			die;
262 262
 		}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	public function getLiveTrackerCount($filter = array())
274 274
 	{
275 275
 		global $globalDBdriver, $globalLiveInterval;
276
-		$filter_query = $this->getFilter($filter,true,true);
276
+		$filter_query = $this->getFilter($filter, true, true);
277 277
 
278 278
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
279 279
 		if ($globalDBdriver == 'mysql') {
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 		try {
285 285
 			$sth = $this->db->prepare($query);
286 286
 			$sth->execute();
287
-		} catch(PDOException $e) {
287
+		} catch (PDOException $e) {
288 288
 			echo $e->getMessage();
289 289
 			die;
290 290
 		}
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 		$filter_query = $this->getFilter($filter);
309 309
 
310 310
 		if (is_array($coord)) {
311
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
312
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
313
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
314
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
311
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
312
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
313
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
314
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
315 315
 		} else return array();
316 316
 		if ($globalDBdriver == 'mysql') {
317 317
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
335 335
 		$Tracker = new Tracker($this->db);
336 336
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
337
-		$filter_query = $this->getFilter($filter,true,true);
337
+		$filter_query = $this->getFilter($filter, true, true);
338 338
 
339 339
 		if (is_array($coord)) {
340
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
341
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
342
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
343
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
340
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
341
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
342
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
343
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
344 344
 		} else return array();
345 345
 		/*
346 346
 		if ($globalDBdriver == 'mysql') {
@@ -354,13 +354,13 @@  discard block
 block discarded – undo
354 354
 		*/
355 355
 		if ($globalDBdriver == 'mysql') {
356 356
 			if (isset($globalArchive) && $globalArchive === TRUE) {
357
-				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
357
+				$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
358 358
 				    FROM tracker_live 
359 359
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= tracker_live.date 
360 360
 				    AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
361 361
 				    AND tracker_live.latitude <> 0 AND tracker_live.longitude <> 0 ORDER BY date DESC';
362 362
 			} else {
363
-				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
363
+				$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
364 364
 				    FROM tracker_live 
365 365
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
366 366
 					FROM tracker_live l 
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 			}
373 373
 		} else {
374 374
 			if (isset($globalArchive) && $globalArchive === TRUE) {
375
-				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
375
+				$query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
376 376
 				    FROM tracker_live 
377 377
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date 
378 378
 				    AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
379 379
 				    AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
380 380
 				    AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' ORDER BY date DESC";
381 381
 			} else {
382
-				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
382
+				$query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
383 383
 				    FROM tracker_live 
384 384
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
385 385
 					FROM tracker_live l 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 				if ($interval == '1m')
440 440
 				{
441 441
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
442
-				} else if ($interval == '15m'){
442
+				} else if ($interval == '15m') {
443 443
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
444 444
 				}
445 445
 			}
@@ -447,14 +447,14 @@  discard block
 block discarded – undo
447 447
 			$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
448 448
 		}
449 449
 
450
-		$query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
450
+		$query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
451 451
                    WHERE tracker_live.latitude <> '' 
452 452
                                    AND tracker_live.longitude <> '' 
453 453
                    ".$additional_query."
454 454
                    HAVING distance < :radius  
455 455
                                    ORDER BY distance";
456 456
 
457
-		$spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
457
+		$spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
458 458
 
459 459
 		return $spotter_array;
460 460
 	}
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
 		date_default_timezone_set('UTC');
473 473
 
474 474
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
475
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
475
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
476 476
 
477
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
477
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true);
478 478
 
479 479
 		return $spotter_array;
480 480
 	}
@@ -486,16 +486,16 @@  discard block
 block discarded – undo
486 486
      * @param $date
487 487
      * @return array the spotter information
488 488
      */
489
-	public function getDateLiveTrackerDataByIdent($ident,$date)
489
+	public function getDateLiveTrackerDataByIdent($ident, $date)
490 490
 	{
491 491
 		$Tracker = new Tracker($this->db);
492 492
 		date_default_timezone_set('UTC');
493 493
 
494 494
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
495
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
495
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
496 496
 
497
-                $date = date('c',$date);
498
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
497
+                $date = date('c', $date);
498
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
499 499
 
500 500
 		return $spotter_array;
501 501
 	}
@@ -512,9 +512,9 @@  discard block
 block discarded – undo
512 512
 		date_default_timezone_set('UTC');
513 513
 
514 514
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
515
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
515
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
516 516
 
517
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
517
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true);
518 518
 
519 519
 		return $spotter_array;
520 520
 	}
@@ -526,15 +526,15 @@  discard block
 block discarded – undo
526 526
      * @param $date
527 527
      * @return array the spotter information
528 528
      */
529
-	public function getDateLiveTrackerDataById($id,$date)
529
+	public function getDateLiveTrackerDataById($id, $date)
530 530
 	{
531 531
 		$Tracker = new Tracker($this->db);
532 532
 		date_default_timezone_set('UTC');
533 533
 
534 534
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
535
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
536
-                $date = date('c',$date);
537
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
535
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
536
+                $date = date('c', $date);
537
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
538 538
 
539 539
 		return $spotter_array;
540 540
 	}
@@ -551,13 +551,13 @@  discard block
 block discarded – undo
551 551
 		date_default_timezone_set('UTC');
552 552
 
553 553
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
554
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
554
+                $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
555 555
 
556 556
     		try {
557 557
 			
558 558
 			$sth = $this->db->prepare($query);
559 559
 			$sth->execute(array(':ident' => $ident));
560
-		} catch(PDOException $e) {
560
+		} catch (PDOException $e) {
561 561
 			echo $e->getMessage();
562 562
 			die;
563 563
 		}
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
      * @param bool $liveinterval
574 574
      * @return array the spotter information
575 575
      */
576
-	public function getAllLiveTrackerDataById($id,$liveinterval = false)
576
+	public function getAllLiveTrackerDataById($id, $liveinterval = false)
577 577
 	{
578 578
 		global $globalDBdriver, $globalLiveInterval;
579 579
 		date_default_timezone_set('UTC');
@@ -582,19 +582,19 @@  discard block
 block discarded – undo
582 582
 		if ($globalDBdriver == 'mysql') {
583 583
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
584 584
 			if ($liveinterval === true) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
585
-			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'";
585
+			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c', $liveinterval)."'";
586 586
 			$query .= ' ORDER BY date';
587 587
 		} else {
588 588
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
589 589
 			if ($liveinterval === true) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
590
-			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'";
590
+			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c', $liveinterval)."'";
591 591
 			$query .= ' ORDER BY date';
592 592
 		}
593 593
 
594 594
 		try {
595 595
 			$sth = $this->db->prepare($query);
596 596
 			$sth->execute(array(':id' => $id));
597
-		} catch(PDOException $e) {
597
+		} catch (PDOException $e) {
598 598
 			echo $e->getMessage();
599 599
 			die;
600 600
 		}
@@ -612,12 +612,12 @@  discard block
 block discarded – undo
612 612
 	{
613 613
 		date_default_timezone_set('UTC');
614 614
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
615
-		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
615
+		$query = self::$global_query.' WHERE tracker_live.ident = :ident';
616 616
     		try {
617 617
 			
618 618
 			$sth = $this->db->prepare($query);
619 619
 			$sth->execute(array(':ident' => $ident));
620
-		} catch(PDOException $e) {
620
+		} catch (PDOException $e) {
621 621
 			echo $e->getMessage();
622 622
 			die;
623 623
 		}
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 			
648 648
 			$sth = $this->db->prepare($query);
649 649
 			$sth->execute();
650
-		} catch(PDOException $e) {
650
+		} catch (PDOException $e) {
651 651
 			return "error";
652 652
 		}
653 653
 
@@ -670,14 +670,14 @@  discard block
 block discarded – undo
670 670
 				
671 671
 				$sth = $this->db->prepare($query);
672 672
 				$sth->execute();
673
-			} catch(PDOException $e) {
673
+			} catch (PDOException $e) {
674 674
 				return "error";
675 675
 			}
676 676
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
677 677
                         $i = 0;
678
-                        $j =0;
678
+                        $j = 0;
679 679
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
680
-			foreach($all as $row)
680
+			foreach ($all as $row)
681 681
 			{
682 682
 				$i++;
683 683
 				$j++;
@@ -685,9 +685,9 @@  discard block
 block discarded – undo
685 685
 					if ($globalDebug) echo ".";
686 686
 				    	try {
687 687
 						
688
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
688
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
689 689
 						$sth->execute();
690
-					} catch(PDOException $e) {
690
+					} catch (PDOException $e) {
691 691
 						return "error";
692 692
 					}
693 693
                                 	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
@@ -698,9 +698,9 @@  discard block
 block discarded – undo
698 698
 			if ($i > 0) {
699 699
     				try {
700 700
 					
701
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
701
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
702 702
 					$sth->execute();
703
-				} catch(PDOException $e) {
703
+				} catch (PDOException $e) {
704 704
 					return "error";
705 705
 				}
706 706
 			}
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 				
714 714
 				$sth = $this->db->prepare($query);
715 715
 				$sth->execute();
716
-			} catch(PDOException $e) {
716
+			} catch (PDOException $e) {
717 717
 				return "error";
718 718
 			}
719 719
 /*			$query_delete = "DELETE FROM tracker_live WHERE famtrackid IN (";
@@ -761,13 +761,13 @@  discard block
 block discarded – undo
761 761
 	public function deleteLiveTrackerDataByIdent($ident)
762 762
 	{
763 763
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
764
-		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
764
+		$query = 'DELETE FROM tracker_live WHERE ident = :ident';
765 765
         
766 766
     		try {
767 767
 			
768 768
 			$sth = $this->db->prepare($query);
769 769
 			$sth->execute(array(':ident' => $ident));
770
-		} catch(PDOException $e) {
770
+		} catch (PDOException $e) {
771 771
 			return "error";
772 772
 		}
773 773
 
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
 	public function deleteLiveTrackerDataById($id)
784 784
 	{
785 785
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
786
-		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
786
+		$query = 'DELETE FROM tracker_live WHERE famtrackid = :id';
787 787
         
788 788
     		try {
789 789
 			
790 790
 			$sth = $this->db->prepare($query);
791 791
 			$sth->execute(array(':id' => $id));
792
-		} catch(PDOException $e) {
792
+		} catch (PDOException $e) {
793 793
 			return "error";
794 794
 		}
795 795
 
@@ -807,13 +807,13 @@  discard block
 block discarded – undo
807 807
 	{
808 808
 		global $globalDBdriver, $globalTimezone;
809 809
 		if ($globalDBdriver == 'mysql') {
810
-			$query  = 'SELECT tracker_live.ident FROM tracker_live 
810
+			$query = 'SELECT tracker_live.ident FROM tracker_live 
811 811
 				WHERE tracker_live.ident = :ident 
812 812
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
813 813
 				AND tracker_live.date < UTC_TIMESTAMP()';
814 814
 			$query_data = array(':ident' => $ident);
815 815
 		} else {
816
-			$query  = "SELECT tracker_live.ident FROM tracker_live 
816
+			$query = "SELECT tracker_live.ident FROM tracker_live 
817 817
 				WHERE tracker_live.ident = :ident 
818 818
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
819 819
 				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -822,8 +822,8 @@  discard block
 block discarded – undo
822 822
 		
823 823
 		$sth = $this->db->prepare($query);
824 824
 		$sth->execute($query_data);
825
-		$ident_result='';
826
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
825
+		$ident_result = '';
826
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
827 827
 		{
828 828
 			$ident_result = $row['ident'];
829 829
 		}
@@ -840,13 +840,13 @@  discard block
 block discarded – undo
840 840
 	{
841 841
 		global $globalDBdriver, $globalTimezone;
842 842
 		if ($globalDBdriver == 'mysql') {
843
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
843
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
844 844
 				WHERE tracker_live.ident = :ident 
845 845
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
846 846
 //				AND tracker_live.date < UTC_TIMESTAMP()";
847 847
 			$query_data = array(':ident' => $ident);
848 848
 		} else {
849
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
849
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
850 850
 				WHERE tracker_live.ident = :ident 
851 851
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
852 852
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -855,8 +855,8 @@  discard block
 block discarded – undo
855 855
 		
856 856
 		$sth = $this->db->prepare($query);
857 857
 		$sth->execute($query_data);
858
-		$ident_result='';
859
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
858
+		$ident_result = '';
859
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
860 860
 		{
861 861
 			$ident_result = $row['famtrackid'];
862 862
 		}
@@ -873,13 +873,13 @@  discard block
 block discarded – undo
873 873
 	{
874 874
 		global $globalDBdriver, $globalTimezone;
875 875
 		if ($globalDBdriver == 'mysql') {
876
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
876
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
877 877
 				WHERE tracker_live.famtrackid = :id 
878 878
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
879 879
 //				AND tracker_live.date < UTC_TIMESTAMP()";
880 880
 			$query_data = array(':id' => $id);
881 881
 		} else {
882
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
882
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
883 883
 				WHERE tracker_live.famtrackid = :id 
884 884
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
885 885
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -888,8 +888,8 @@  discard block
 block discarded – undo
888 888
 		
889 889
 		$sth = $this->db->prepare($query);
890 890
 		$sth->execute($query_data);
891
-		$ident_result='';
892
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
891
+		$ident_result = '';
892
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
893 893
 		{
894 894
 			$ident_result = $row['famtrackid'];
895 895
 		}
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
      * @param string $over_country
917 917
      * @return String success or false
918 918
      */
919
-	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
919
+	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
920 920
 	{
921 921
 		global $globalURL, $globalArchive, $globalDebug;
922 922
 		$Common = new Common();
@@ -975,21 +975,21 @@  discard block
 block discarded – undo
975 975
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
976 976
 
977 977
         
978
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
979
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
980
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
981
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
982
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
983
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
984
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
985
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
986
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
987
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
988
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
989
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
990
-
991
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
992
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
978
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
979
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
980
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
981
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
982
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
983
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
984
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
985
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
986
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
987
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
988
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
989
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
990
+
991
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
992
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
993 993
             	
994 994
 		$query = '';
995 995
 		if ($globalArchive) {
@@ -999,12 +999,12 @@  discard block
 block discarded – undo
999 999
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
1000 1000
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
1001 1001
 
1002
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type);
1002
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type);
1003 1003
 		try {
1004 1004
 			$sth = $this->db->prepare($query);
1005 1005
 			$sth->execute($query_values);
1006 1006
 			$sth->closeCursor();
1007
-		} catch(PDOException $e) {
1007
+		} catch (PDOException $e) {
1008 1008
 			return "error : ".$e->getMessage();
1009 1009
 		}
1010 1010
                 /*
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1015 1015
 		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
1016 1016
 		    $TrackerArchive = new TrackerArchive($this->db);
1017
-		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
1017
+		    $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country);
1018 1018
 		    if ($globalDebug) echo $result.')';
1019 1019
 		}
1020 1020
 
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 
1025 1025
 	public function getOrderBy()
1026 1026
 	{
1027
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
1027
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
1028 1028
 		return $orderby;
1029 1029
 	}
1030 1030
 
Please login to merge, or discard this patch.
require/class.MarineArchive.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -23,33 +23,33 @@  discard block
 block discarded – undo
23 23
      * @param bool $and
24 24
      * @return string the SQL part
25 25
      */
26
-	public function getFilter($filter = array(),$where = false,$and = false) {
26
+	public function getFilter($filter = array(), $where = false, $and = false) {
27 27
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
28 28
 		$filters = array();
29 29
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
30 30
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
31 31
 				$filters = $globalStatsFilters[$globalFilterName];
32 32
 			} else {
33
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
33
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
34 34
 			}
35 35
 		}
36 36
 		if (isset($filter[0]['source'])) {
37
-			$filters = array_merge($filters,$filter);
37
+			$filters = array_merge($filters, $filter);
38 38
 		}
39
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
39
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
40 40
 		$filter_query_join = '';
41 41
 		$filter_query_where = '';
42
-		foreach($filters as $flt) {
42
+		foreach ($filters as $flt) {
43 43
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
44 44
 				if (isset($flt['source'])) {
45
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
45
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
46 46
 				} else {
47
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
47
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
48 48
 				}
49 49
 			}
50 50
 		}
51 51
 		if (isset($filter['source']) && !empty($filter['source'])) {
52
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
52
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
53 53
 		}
54 54
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
55 55
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'";
78 78
 				}
79 79
 			}
80
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id";
80
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id";
81 81
 		}
82 82
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
83
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
83
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
84 84
 		}
85 85
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
86 86
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
87 87
 		if ($filter_query_where != '') {
88
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
88
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
89 89
 		}
90 90
 		$filter_query = $filter_query_join.$filter_query_where;
91 91
 		return $filter_query;
@@ -128,21 +128,21 @@  discard block
 block discarded – undo
128 128
 		require_once(dirname(__FILE__).'/class.Marine.php');
129 129
 		if ($over_country == '') {
130 130
 			$Marine = new Marine($this->db);
131
-			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude);
131
+			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude);
132 132
 			if (!empty($data_country)) $country = $data_country['iso2'];
133 133
 			else $country = '';
134 134
 		} else $country = $over_country;
135 135
 		
136 136
 		//$country = $over_country;
137 137
 		// Route is not added in marine_archive
138
-		$query  = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
138
+		$query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
139 139
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)';
140
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':mmsi' => $mmsi,':type' => $type,':type_id' => $typeid,':status' => $status,':status_id' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time);
140
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $typeid, ':status' => $status, ':status_id' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time);
141 141
 		try {
142 142
 			$sth = $this->db->prepare($query);
143 143
 			$sth->execute($query_values);
144 144
 			$sth->closeCursor();
145
-		} catch(PDOException $e) {
145
+		} catch (PDOException $e) {
146 146
 			return "error : ".$e->getMessage();
147 147
 		}
148 148
 		return "success";
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 
163 163
         $ident = filter_var($ident, FILTER_SANITIZE_STRING);
164 164
         //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
165
-        $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
166
-        $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
165
+        $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
166
+        $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident));
167 167
         return $spotter_array;
168 168
     }
169 169
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         $id = filter_var($id, FILTER_SANITIZE_STRING);
182 182
         //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
183 183
         //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
184
-        $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
184
+        $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
185 185
 
186 186
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
187 187
                   /*
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                 }
195 195
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
196 196
                 */
197
-        $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
197
+        $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id));
198 198
         return $spotter_array;
199 199
     }
200 200
 
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 	{
209 209
         date_default_timezone_set('UTC');
210 210
         $id = filter_var($id, FILTER_SANITIZE_STRING);
211
-        $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
211
+        $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
212 212
 
213 213
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
214 214
 
215 215
         try {
216 216
             $sth = $this->db->prepare($query);
217 217
             $sth->execute(array(':id' => $id));
218
-        } catch(PDOException $e) {
218
+        } catch (PDOException $e) {
219 219
             echo $e->getMessage();
220 220
             die;
221 221
         }
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
     {
234 234
         date_default_timezone_set('UTC');
235 235
         $id = filter_var($id, FILTER_SANITIZE_STRING);
236
-        $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
236
+        $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
237 237
 
238 238
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
239 239
 
240 240
         try {
241 241
             $sth = $this->db->prepare($query);
242 242
             $sth->execute(array(':id' => $id));
243
-        } catch(PDOException $e) {
243
+        } catch (PDOException $e) {
244 244
             echo $e->getMessage();
245 245
             die;
246 246
         }
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
         date_default_timezone_set('UTC');
263 263
 
264 264
         $ident = filter_var($ident, FILTER_SANITIZE_STRING);
265
-        $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
265
+        $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
266 266
 
267 267
         try {
268 268
             $sth = $this->db->prepare($query);
269 269
             $sth->execute(array(':ident' => $ident));
270
-        } catch(PDOException $e) {
270
+        } catch (PDOException $e) {
271 271
             echo $e->getMessage();
272 272
             die;
273 273
         }
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
         date_default_timezone_set('UTC');
289 289
 
290 290
         $id = filter_var($id, FILTER_SANITIZE_STRING);
291
-        $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
291
+        $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
292 292
 
293 293
         try {
294 294
             $sth = $this->db->prepare($query);
295 295
             $sth->execute(array(':id' => $id));
296
-        } catch(PDOException $e) {
296
+        } catch (PDOException $e) {
297 297
             echo $e->getMessage();
298 298
             die;
299 299
         }
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
         date_default_timezone_set('UTC');
314 314
 
315 315
         $id = filter_var($id, FILTER_SANITIZE_STRING);
316
-        $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
316
+        $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
317 317
 
318 318
         try {
319 319
             $sth = $this->db->prepare($query);
320 320
             $sth->execute(array(':id' => $id));
321
-        } catch(PDOException $e) {
321
+        } catch (PDOException $e) {
322 322
             echo $e->getMessage();
323 323
             die;
324 324
         }
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
         date_default_timezone_set('UTC');
341 341
 
342 342
         $ident = filter_var($ident, FILTER_SANITIZE_STRING);
343
-        $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
343
+        $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
344 344
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
345 345
 
346 346
         try {
347 347
             $sth = $this->db->prepare($query);
348 348
             $sth->execute(array(':ident' => $ident));
349
-        } catch(PDOException $e) {
349
+        } catch (PDOException $e) {
350 350
             echo $e->getMessage();
351 351
             die;
352 352
         }
@@ -364,12 +364,12 @@  discard block
 block discarded – undo
364 364
      * @param $date
365 365
      * @return array the spotter information
366 366
      */
367
-    public function getMarineArchiveData($ident,$fammarine_id,$date)
367
+    public function getMarineArchiveData($ident, $fammarine_id, $date)
368 368
     {
369 369
         $Marine = new Marine($this->db);
370 370
         $ident = filter_var($ident, FILTER_SANITIZE_STRING);
371 371
         $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
372
-        $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
372
+        $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%'));
373 373
         return $spotter_array;
374 374
     }
375 375
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 		try {
389 389
 			$sth = $this->db->prepare($query);
390 390
 			$sth->execute();
391
-		} catch(PDOException $e) {
391
+		} catch (PDOException $e) {
392 392
 			echo $e->getMessage();
393 393
 			die;
394 394
 		}
@@ -402,24 +402,24 @@  discard block
 block discarded – undo
402 402
      * @param array $filter
403 403
      * @return array the spotter information
404 404
      */
405
-    public function getMinLiveMarineData($begindate,$enddate,$filter = array())
405
+    public function getMinLiveMarineData($begindate, $enddate, $filter = array())
406 406
     {
407 407
         global $globalDBdriver;
408 408
         date_default_timezone_set('UTC');
409 409
 
410 410
         $filter_query = '';
411 411
         if (isset($filter['source']) && !empty($filter['source'])) {
412
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
412
+            $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
413 413
         }
414 414
         // Use spotter_output also ?
415 415
         if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
-            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
416
+            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
417 417
         }
418 418
         if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419 419
             $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
420 420
         }
421 421
         if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
422
+            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
423 423
         }
424 424
 
425 425
         //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -438,14 +438,14 @@  discard block
 block discarded – undo
438 438
 						GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id 
439 439
 				    AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
440 440
 */
441
-            $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
441
+            $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
442 442
 				    FROM marine_archive 
443 443
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
444 444
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
445 445
                         	    '.$filter_query.' ORDER BY fammarine_id';
446 446
         } else {
447 447
             //$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
448
-            $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
448
+            $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
449 449
                         	    FROM marine_archive 
450 450
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
451 451
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
         try {
456 456
             $sth = $this->db->prepare($query);
457 457
             $sth->execute();
458
-        } catch(PDOException $e) {
458
+        } catch (PDOException $e) {
459 459
             echo $e->getMessage();
460 460
             die;
461 461
         }
@@ -472,24 +472,24 @@  discard block
 block discarded – undo
472 472
      * @param array $filter
473 473
      * @return array the spotter information
474 474
      */
475
-    public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
475
+    public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array())
476 476
     {
477 477
         global $globalDBdriver;
478 478
         date_default_timezone_set('UTC');
479 479
 
480 480
         $filter_query = '';
481 481
         if (isset($filter['source']) && !empty($filter['source'])) {
482
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
482
+            $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
483 483
         }
484 484
         // Should use spotter_output also ?
485 485
         if (isset($filter['airlines']) && !empty($filter['airlines'])) {
486
-            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
486
+            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
487 487
         }
488 488
         if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
489 489
             $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
490 490
         }
491 491
         if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
492
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
492
+            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
493 493
         }
494 494
 
495 495
         //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
                     		    FROM marine_archive 
500 500
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
501 501
 			*/
502
-            $query  = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
502
+            $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
503 503
 				    FROM marine_archive_output 
504 504
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao 
505 505
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
515 515
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
516 516
                         */
517
-            $query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
517
+            $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
518 518
                         	    FROM marine_archive_output 
519 519
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
520 520
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         try {
527 527
             $sth = $this->db->prepare($query);
528 528
             $sth->execute();
529
-        } catch(PDOException $e) {
529
+        } catch (PDOException $e) {
530 530
             echo $e->getMessage();
531 531
             die;
532 532
         }
@@ -543,23 +543,23 @@  discard block
 block discarded – undo
543 543
      * @param array $filter
544 544
      * @return array the spotter information
545 545
      */
546
-    public function getLiveMarineCount($begindate,$enddate,$filter = array())
546
+    public function getLiveMarineCount($begindate, $enddate, $filter = array())
547 547
     {
548 548
         global $globalDBdriver, $globalLiveInterval;
549 549
         date_default_timezone_set('UTC');
550 550
 
551 551
         $filter_query = '';
552 552
         if (isset($filter['source']) && !empty($filter['source'])) {
553
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
553
+            $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
554 554
         }
555 555
         if (isset($filter['airlines']) && !empty($filter['airlines'])) {
556
-            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
556
+            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
557 557
         }
558 558
         if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
559 559
             $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
560 560
         }
561 561
         if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
562
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
562
+            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
563 563
         }
564 564
 
565 565
         //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
         try {
575 575
             $sth = $this->db->prepare($query);
576 576
             $sth->execute();
577
-        } catch(PDOException $e) {
577
+        } catch (PDOException $e) {
578 578
             echo $e->getMessage();
579 579
             die;
580 580
         }
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
      * @param array $filters
618 618
      * @return array the spotter information
619 619
      */
620
-    public function searchMarineData($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())
620
+    public function searchMarineData($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())
621 621
     {
622 622
         global $globalTimezone, $globalDBdriver;
623 623
         require_once(dirname(__FILE__).'/class.Translation.php');
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
             } else {
639 639
                 $q_array = explode(" ", $q);
640 640
 		
641
-                foreach ($q_array as $q_item){
641
+                foreach ($q_array as $q_item) {
642 642
                     $additional_query .= " AND (";
643 643
                     $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
644 644
                     $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 	
671 671
         if ($registration != "")
672 672
         {
673
-            $registration = filter_var($registration,FILTER_SANITIZE_STRING);
673
+            $registration = filter_var($registration, FILTER_SANITIZE_STRING);
674 674
             if (!is_string($registration))
675 675
             {
676 676
                 return array();
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 	
682 682
         if ($aircraft_icao != "")
683 683
         {
684
-            $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
684
+            $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
685 685
             if (!is_string($aircraft_icao))
686 686
             {
687 687
                 return array();
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	
693 693
         if ($aircraft_manufacturer != "")
694 694
         {
695
-            $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
695
+            $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
696 696
             if (!is_string($aircraft_manufacturer))
697 697
             {
698 698
                 return array();
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 	
714 714
         if ($airline_icao != "")
715 715
         {
716
-            $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
716
+            $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
717 717
             if (!is_string($airline_icao))
718 718
             {
719 719
                 return array();
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	
725 725
         if ($airline_country != "")
726 726
         {
727
-            $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
727
+            $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
728 728
             if (!is_string($airline_country))
729 729
             {
730 730
                 return array();
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 	
736 736
         if ($airline_type != "")
737 737
         {
738
-            $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
738
+            $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
739 739
             if (!is_string($airline_type))
740 740
             {
741 741
                 return array();
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 	
758 758
         if ($airport != "")
759 759
         {
760
-            $airport = filter_var($airport,FILTER_SANITIZE_STRING);
760
+            $airport = filter_var($airport, FILTER_SANITIZE_STRING);
761 761
             if (!is_string($airport))
762 762
             {
763 763
                 return array();
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 	
769 769
         if ($airport_country != "")
770 770
         {
771
-            $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
771
+            $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
772 772
             if (!is_string($airport_country))
773 773
             {
774 774
                 return array();
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
     
780 780
         if ($callsign != "")
781 781
         {
782
-            $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
782
+            $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
783 783
             if (!is_string($callsign))
784 784
             {
785 785
                 return array();
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
                 $translate = $Translation->ident2icao($callsign);
788 788
                 if ($translate != $callsign) {
789 789
                     $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
790
-                    $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
790
+                    $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
791 791
                 } else {
792 792
                     $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
793 793
                 }
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 
797 797
         if ($owner != "")
798 798
         {
799
-            $owner = filter_var($owner,FILTER_SANITIZE_STRING);
799
+            $owner = filter_var($owner, FILTER_SANITIZE_STRING);
800 800
             if (!is_string($owner))
801 801
             {
802 802
                 return array();
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 
808 808
         if ($pilot_name != "")
809 809
         {
810
-            $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
810
+            $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
811 811
             if (!is_string($pilot_name))
812 812
             {
813 813
                 return array();
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 	
819 819
         if ($pilot_id != "")
820 820
         {
821
-            $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
821
+            $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
822 822
             if (!is_string($pilot_id))
823 823
             {
824 824
                 return array();
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 	
830 830
         if ($departure_airport_route != "")
831 831
         {
832
-            $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
832
+            $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
833 833
             if (!is_string($departure_airport_route))
834 834
             {
835 835
                 return array();
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 	
841 841
         if ($arrival_airport_route != "")
842 842
         {
843
-            $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
843
+            $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
844 844
             if (!is_string($arrival_airport_route))
845 845
             {
846 846
                 return array();
@@ -853,8 +853,8 @@  discard block
 block discarded – undo
853 853
         {
854 854
             $altitude_array = explode(",", $altitude);
855 855
 	    
856
-            $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
857
-            $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
856
+            $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
857
+            $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
858 858
 	    
859 859
 
860 860
             if ($altitude_array[1] != "")
@@ -872,8 +872,8 @@  discard block
 block discarded – undo
872 872
         {
873 873
             $date_array = explode(",", $date_posted);
874 874
 	    
875
-            $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
876
-            $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
875
+            $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
876
+            $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
877 877
 	    
878 878
             if ($globalTimezone != '') {
879 879
                 date_default_timezone_set($globalTimezone);
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
         {
906 906
             $limit_array = explode(",", $limit);
907 907
 	    
908
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
909
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
908
+            $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
909
+            $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
910 910
 	    
911 911
             if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
912 912
             {
@@ -917,8 +917,8 @@  discard block
 block discarded – undo
917 917
 	
918 918
 
919 919
         if ($origLat != "" && $origLon != "" && $dist != "") {
920
-            $dist = number_format($dist*0.621371,2,'.','');
921
-            $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
920
+            $dist = number_format($dist*0.621371, 2, '.', '');
921
+            $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
922 922
                           FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
923 923
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
924 924
         } else {
@@ -935,12 +935,12 @@  discard block
 block discarded – undo
935 935
                 $additional_query .= " AND (marine_archive_output.waypoints <> '')";
936 936
             }
937 937
 
938
-            $query  = "SELECT marine_archive_output.* FROM marine_archive_output 
938
+            $query = "SELECT marine_archive_output.* FROM marine_archive_output 
939 939
 		    WHERE marine_archive_output.ident <> '' 
940 940
 		    ".$additional_query."
941 941
 		    ".$filter_query.$orderby_query;
942 942
         }
943
-        $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
943
+        $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
944 944
 
945 945
         return $spotter_array;
946 946
     }
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
         try {
958 958
             $sth = $this->db->prepare($query);
959 959
             $sth->execute();
960
-        } catch(PDOException $e) {
960
+        } catch (PDOException $e) {
961 961
             return "error";
962 962
         }
963 963
         return '';
@@ -997,8 +997,8 @@  discard block
 block discarded – undo
997 997
 	{
998 998
 	    $limit_array = explode(",", $limit);
999 999
 	    
1000
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1001
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1000
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1001
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1002 1002
 	    
1003 1003
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1004 1004
 	    {
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 	$query_values = array();
1043 1043
 	$limit_query = '';
1044 1044
 	$additional_query = '';
1045
-	$filter_query = $this->getFilter($filter,true,true);
1045
+	$filter_query = $this->getFilter($filter, true, true);
1046 1046
 	
1047 1047
 	if ($owner != "")
1048 1048
 	{
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 	{
1060 1060
 	    $limit_array = explode(",", $limit);
1061 1061
 	    
1062
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1063
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1062
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1063
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1064 1064
 	    
1065 1065
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1066 1066
 	    {
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 	$query_values = array();
1104 1104
 	$limit_query = '';
1105 1105
 	$additional_query = '';
1106
-	$filter_query = $this->getFilter($filter,true,true);
1106
+	$filter_query = $this->getFilter($filter, true, true);
1107 1107
 	
1108 1108
 	if ($pilot != "")
1109 1109
 	{
@@ -1115,8 +1115,8 @@  discard block
 block discarded – undo
1115 1115
 	{
1116 1116
 	    $limit_array = explode(",", $limit);
1117 1117
 	    
1118
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1119
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1118
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1119
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1120 1120
 	    
1121 1121
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1122 1122
 	    {
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
      * @param string $sincedate
1149 1149
      * @return array the airline country list
1150 1150
      */
1151
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1151
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1152 1152
     {
1153 1153
 	global $globalDBdriver;
1154 1154
 	/*
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 	$flight_array = array();
1178 1178
 	$temp_array = array();
1179 1179
         
1180
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1180
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1181 1181
 	{
1182 1182
 	    $temp_array['flight_count'] = $row['nb'];
1183 1183
 	    $temp_array['flight_country'] = $row['name'];
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
      * @param string $sincedate
1197 1197
      * @return array the airline country list
1198 1198
      */
1199
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1199
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1200 1200
     {
1201 1201
 	global $globalDBdriver;
1202 1202
 	/*
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
 	$flight_array = array();
1226 1226
 	$temp_array = array();
1227 1227
         
1228
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1228
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1229 1229
 	{
1230 1230
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1231 1231
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1244,14 +1244,14 @@  discard block
 block discarded – undo
1244 1244
      * @param $date
1245 1245
      * @return array the spotter information
1246 1246
      */
1247
-    public function getDateArchiveMarineDataById($id,$date)
1247
+    public function getDateArchiveMarineDataById($id, $date)
1248 1248
     {
1249 1249
 	$Marine = new Marine($this->db);
1250 1250
 	date_default_timezone_set('UTC');
1251 1251
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1252 1252
 	$query  = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';
1253
-	$date = date('c',$date);
1254
-	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1253
+	$date = date('c', $date);
1254
+	$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1255 1255
 	return $spotter_array;
1256 1256
     }
1257 1257
 
@@ -1262,14 +1262,14 @@  discard block
 block discarded – undo
1262 1262
      * @param $date
1263 1263
      * @return array the spotter information
1264 1264
      */
1265
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1265
+    public function getDateArchiveMarineDataByIdent($ident, $date)
1266 1266
     {
1267 1267
 	$Marine = new Marine($this->db);
1268 1268
 	date_default_timezone_set('UTC');
1269 1269
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1270 1270
 	$query  = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';
1271
-	$date = date('c',$date);
1272
-	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1271
+	$date = date('c', $date);
1272
+	$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1273 1273
 	return $spotter_array;
1274 1274
     }
1275 1275
 
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
      * @param array $filters
1283 1283
      * @return array the spotter information
1284 1284
      */
1285
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1285
+    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1286 1286
     {
1287 1287
         global $global_query;
1288 1288
         $Marine = new Marine($this->db);
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
         $query_values = array();
1291 1291
         $limit_query = '';
1292 1292
         $additional_query = '';
1293
-        $filter_query = $this->getFilter($filters,true,true);
1293
+        $filter_query = $this->getFilter($filters, true, true);
1294 1294
 	
1295 1295
         if ($airport != "")
1296 1296
         {
@@ -1307,8 +1307,8 @@  discard block
 block discarded – undo
1307 1307
         {
1308 1308
             $limit_array = explode(",", $limit);
1309 1309
 	    
1310
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1311
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1310
+            $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1311
+            $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1312 1312
 	    
1313 1313
             if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1314 1314
             {
Please login to merge, or discard this patch.
require/class.ATC.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -28,22 +28,22 @@  discard block
 block discarded – undo
28 28
      * @param bool $and
29 29
      * @return String the SQL part
30 30
      */
31
-	public function getFilter($filter = array(),$where = false,$and = false) {
31
+	public function getFilter($filter = array(), $where = false, $and = false) {
32 32
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
33 33
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
34 34
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
35
-				foreach($globalStatsFilters[$globalFilterName] as $source) {
35
+				foreach ($globalStatsFilters[$globalFilterName] as $source) {
36 36
 					if (isset($source['source'])) $filter['source'][] = $source['source'];
37 37
 				}
38 38
 			} else {
39 39
 				$filter = $globalStatsFilters[$globalFilterName];
40 40
 			}
41 41
 		}
42
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
42
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
43 43
 		$filter_query_join = '';
44 44
 		$filter_query_where = '';
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
49 49
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		try {
63 63
 			$sth = $this->db->prepare($query);
64 64
 			$sth->execute($query_values);
65
-		} catch(PDOException $e) {
65
+		} catch (PDOException $e) {
66 66
 			return "error : ".$e->getMessage();
67 67
 		}
68 68
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
 	 * @return Array Return ATC
76 76
 	*/
77 77
 	public function getById($id) {
78
-		$filter_query = $this->getFilter(array(),true,true);
78
+		$filter_query = $this->getFilter(array(), true, true);
79 79
 		$query = "SELECT * FROM atc".$filter_query." atc_id = :id";
80 80
 		$query_values = array(':id' => $id);
81 81
 		try {
82 82
 			$sth = $this->db->prepare($query);
83 83
 			$sth->execute($query_values);
84
-		} catch(PDOException $e) {
84
+		} catch (PDOException $e) {
85 85
 			return "error : ".$e->getMessage();
86 86
 		}
87 87
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -94,19 +94,19 @@  discard block
 block discarded – undo
94 94
 	 * @param String $format_source Format source
95 95
 	 * @return Array Return ATC
96 96
 	*/
97
-	public function getByIdent($ident,$format_source = '') {
98
-		$filter_query = $this->getFilter(array(),true,true);
97
+	public function getByIdent($ident, $format_source = '') {
98
+		$filter_query = $this->getFilter(array(), true, true);
99 99
 		if ($format_source == '') {
100 100
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident";
101 101
 			$query_values = array(':ident' => $ident);
102 102
 		} else {
103 103
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source";
104
-			$query_values = array(':ident' => $ident,':format_source' => $format_source);
104
+			$query_values = array(':ident' => $ident, ':format_source' => $format_source);
105 105
 		}
106 106
 		try {
107 107
 			$sth = $this->db->prepare($query);
108 108
 			$sth->execute($query_values);
109
-		} catch(PDOException $e) {
109
+		} catch (PDOException $e) {
110 110
 			return "error : ".$e->getMessage();
111 111
 		}
112 112
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
128 128
 	 * @param String $format_source Format source
129 129
 	 * @param String $source_name Source name
130 130
 	*/
131
-	public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
132
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
133
-		$info = str_replace('^','<br />',$info);
134
-		$info = str_replace('&amp;sect;','',$info);
135
-		$info = str_replace('"','',$info);
131
+	public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
132
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
133
+		$info = str_replace('^', '<br />', $info);
134
+		$info = str_replace('&amp;sect;', '', $info);
135
+		$info = str_replace('"', '', $info);
136 136
 		if ($type == '') $type = NULL;
137 137
 		$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
138
-		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
138
+		$query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
139 139
 		try {
140 140
 			$sth = $this->db->prepare($query);
141 141
 			$sth->execute($query_values);
142
-		} catch(PDOException $e) {
142
+		} catch (PDOException $e) {
143 143
 			return "error : ".$e->getMessage();
144 144
 		}
145 145
 		return '';
@@ -160,18 +160,18 @@  discard block
 block discarded – undo
160 160
 	 * @param String $format_source Format source
161 161
 	 * @param String $source_name Source name
162 162
 	*/
163
-	public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
164
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
165
-		$info = str_replace('^','<br />',$info);
166
-		$info = str_replace('&amp;sect;','',$info);
167
-		$info = str_replace('"','',$info);
163
+	public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
164
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
165
+		$info = str_replace('^', '<br />', $info);
166
+		$info = str_replace('&amp;sect;', '', $info);
167
+		$info = str_replace('"', '', $info);
168 168
 		if ($type == '') $type = NULL;
169 169
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
170
-		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
170
+		$query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
171 171
 		try {
172 172
 			$sth = $this->db->prepare($query);
173 173
 			$sth->execute($query_values);
174
-		} catch(PDOException $e) {
174
+		} catch (PDOException $e) {
175 175
 			return "error : ".$e->getMessage();
176 176
 		}
177 177
 		return '';
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		try {
188 188
 			$sth = $this->db->prepare($query);
189 189
 			$sth->execute($query_values);
190
-		} catch(PDOException $e) {
190
+		} catch (PDOException $e) {
191 191
 			return "error : ".$e->getMessage();
192 192
 		}
193 193
 		return '';
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
 	 * @param String $ident Flight ident
199 199
 	 * @param String $format_source Format source
200 200
 	*/
201
-	public function deleteByIdent($ident,$format_source) {
201
+	public function deleteByIdent($ident, $format_source) {
202 202
 		$query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source";
203
-		$query_values = array(':ident' => $ident,':format_source' => $format_source);
203
+		$query_values = array(':ident' => $ident, ':format_source' => $format_source);
204 204
 		try {
205 205
 			$sth = $this->db->prepare($query);
206 206
 			$sth->execute($query_values);
207
-		} catch(PDOException $e) {
207
+		} catch (PDOException $e) {
208 208
 			return "error : ".$e->getMessage();
209 209
 		}
210 210
 		return '';
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		try {
220 220
 			$sth = $this->db->prepare($query);
221 221
 			$sth->execute($query_values);
222
-		} catch(PDOException $e) {
222
+		} catch (PDOException $e) {
223 223
 			return "error : ".$e->getMessage();
224 224
 		}
225 225
 		return '';
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		try {
239 239
 			$sth = $this->db->prepare($query);
240 240
 			$sth->execute();
241
-		} catch(PDOException $e) {
241
+		} catch (PDOException $e) {
242 242
 			return "error";
243 243
 		}
244 244
 		return "success";
Please login to merge, or discard this patch.