Completed
Push — master ( 65723a...e6f61d )
by Yannick
38:02 queued 05:59
created
require/class.Stats.php 4 patches
Doc Comments   +35 added lines patch added patch discarded remove patch
@@ -18,6 +18,10 @@  discard block
 block discarded – undo
18 18
 		$this->db = $Connection->db();
19 19
 	}
20 20
 
21
+	/**
22
+	 * @param string $type
23
+	 * @param string $stats_date
24
+	 */
21 25
 	public function addLastStatsUpdate($type,$stats_date) {
22 26
 		$query = "DELETE FROM config WHERE name = :type;
23 27
 			    INSERT INTO config (name,value) VALUES (:type,:stats_date);";
@@ -1368,6 +1372,10 @@  discard block
 block discarded – undo
1368 1372
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1369 1373
 		return $all;
1370 1374
 	}
1375
+
1376
+	/**
1377
+	 * @param string $type
1378
+	 */
1371 1379
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1372 1380
 		if ($filter_name == '') $filter_name = $this->filter_name;
1373 1381
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1379,6 +1387,11 @@  discard block
 block discarded – undo
1379 1387
 			echo "error : ".$e->getMessage();
1380 1388
 		}
1381 1389
 	}
1390
+
1391
+	/**
1392
+	 * @param string $type
1393
+	 * @param string $year
1394
+	 */
1382 1395
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1383 1396
 		if ($filter_name == '') $filter_name = $this->filter_name;
1384 1397
 		global $globalArchiveMonths, $globalDBdriver;
@@ -1578,6 +1591,10 @@  discard block
 block discarded – undo
1578 1591
 		else return 0;
1579 1592
 	}
1580 1593
 
1594
+	/**
1595
+	 * @param string $type
1596
+	 * @param string $stats_date
1597
+	 */
1581 1598
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1582 1599
 		global $globalDBdriver;
1583 1600
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -1631,6 +1648,9 @@  discard block
 block discarded – undo
1631 1648
         }
1632 1649
         */
1633 1650
 
1651
+	/**
1652
+	 * @param string $stats_type
1653
+	 */
1634 1654
 	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1635 1655
 		global $globalDBdriver;
1636 1656
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
@@ -1674,6 +1694,9 @@  discard block
 block discarded – undo
1674 1694
 		return $all;
1675 1695
 	}
1676 1696
 
1697
+	/**
1698
+	 * @param string $stats_type
1699
+	 */
1677 1700
 	public function addStatSource($data,$source_name,$stats_type,$date) {
1678 1701
 		global $globalDBdriver;
1679 1702
 		if ($globalDBdriver == 'mysql') {
@@ -1689,6 +1712,10 @@  discard block
 block discarded – undo
1689 1712
 			return "error : ".$e->getMessage();
1690 1713
 		}
1691 1714
 	}
1715
+
1716
+	/**
1717
+	 * @param string $type
1718
+	 */
1692 1719
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1693 1720
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1694 1721
 		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
@@ -1955,6 +1982,10 @@  discard block
 block discarded – undo
1955 1982
 			return "error : ".$e->getMessage();
1956 1983
 		}
1957 1984
 	}
1985
+
1986
+	/**
1987
+	 * @param string $type
1988
+	 */
1958 1989
 	public function deleteStatFlight($type) {
1959 1990
 		$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1960 1991
 		$query_values = array(':type' => $type);
@@ -1965,6 +1996,10 @@  discard block
 block discarded – undo
1965 1996
 			return "error : ".$e->getMessage();
1966 1997
 		}
1967 1998
 	}
1999
+
2000
+	/**
2001
+	 * @param string $type
2002
+	 */
1968 2003
 	public function deleteStatAirport($type) {
1969 2004
 		$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1970 2005
 		$query_values = array(':type' => $type);
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -404,17 +404,17 @@  discard block
 block discarded – undo
404 404
 			}
405 405
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
406 406
 		} else $all = array();
407
-                if (empty($all)) {
408
-	                $Spotter = new Spotter($this->db);
409
-            		$filters = array();
407
+				if (empty($all)) {
408
+					$Spotter = new Spotter($this->db);
409
+					$filters = array();
410 410
 			$filters = array('year' => $year,'month' => $month);
411
-            		if ($filter_name != '') {
412
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
411
+					if ($filter_name != '') {
412
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
413 413
 			}
414 414
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
415
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
416
-                }
417
-                return $all;
415
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters);
416
+				}
417
+				return $all;
418 418
 	}
419 419
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
420 420
 		global $globalStatsFilters;
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
 			return "error : ".$e->getMessage();
1612 1612
 		}
1613 1613
 	}
1614
-        /*
1614
+		/*
1615 1615
 	public function getStatsSource($date,$stats_type = '') {
1616 1616
 		if ($stats_type == '') {
1617 1617
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
Please login to merge, or discard this patch.
Spacing   +540 added lines, -540 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 		$this->db = $Connection->db();
19 19
 	}
20 20
 
21
-	public function addLastStatsUpdate($type,$stats_date) {
21
+	public function addLastStatsUpdate($type, $stats_date) {
22 22
 		$query = "DELETE FROM config WHERE name = :type;
23 23
 			    INSERT INTO config (name,value) VALUES (:type,:stats_date);";
24
-		$query_values = array('type' => $type,':stats_date' => $stats_date);
24
+		$query_values = array('type' => $type, ':stats_date' => $stats_date);
25 25
 		try {
26 26
 			$sth = $this->db->prepare($query);
27 27
 			$sth->execute($query_values);
28
-		} catch(PDOException $e) {
28
+		} catch (PDOException $e) {
29 29
 			return "error : ".$e->getMessage();
30 30
 		}
31 31
 	}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		try {
36 36
 			$sth = $this->db->prepare($query);
37 37
 			$sth->execute(array(':type' => $type));
38
-		} catch(PDOException $e) {
38
+		} catch (PDOException $e) {
39 39
 			echo "error : ".$e->getMessage();
40 40
 		}
41 41
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		try {
57 57
 			$sth = $this->db->prepare($query);
58 58
 			$sth->execute(array(':filter_name' => $filter_name));
59
-		} catch(PDOException $e) {
59
+		} catch (PDOException $e) {
60 60
 			return "error : ".$e->getMessage();
61 61
 		}
62 62
 	}
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 		try {
70 70
 			$sth = $this->db->prepare($query);
71 71
 			$sth->execute();
72
-		} catch(PDOException $e) {
72
+		} catch (PDOException $e) {
73 73
 			return "error : ".$e->getMessage();
74 74
 		}
75 75
 		$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;";
76 76
 		try {
77 77
 			$sth = $this->db->prepare($query);
78 78
 			$sth->execute(array(':filter_name' => $filter_name));
79
-		} catch(PDOException $e) {
79
+		} catch (PDOException $e) {
80 80
 			return "error : ".$e->getMessage();
81 81
 		}
82 82
 	}
@@ -88,77 +88,77 @@  discard block
 block discarded – undo
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
 			echo "error : ".$e->getMessage();
93 93
 		}
94 94
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
95 95
 		if (empty($all)) {
96 96
 			$filters = array();
97 97
 			if ($filter_name != '') {
98
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
98
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
99 99
 			}
100 100
 			$Spotter = new Spotter($this->db);
101
-			$all = $Spotter->getAllAirlineNames('',NULL,$filters);
101
+			$all = $Spotter->getAllAirlineNames('', NULL, $filters);
102 102
 		}
103 103
 		return $all;
104 104
 	}
105
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
105
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
106 106
 		if ($filter_name == '') $filter_name = $this->filter_name;
107 107
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
108 108
 		try {
109 109
 			$sth = $this->db->prepare($query);
110
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
111
-		} catch(PDOException $e) {
110
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
111
+		} catch (PDOException $e) {
112 112
 			echo "error : ".$e->getMessage();
113 113
 		}
114 114
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
115 115
 		return $all;
116 116
 	}
117
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
117
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
118 118
 		if ($filter_name == '') $filter_name = $this->filter_name;
119 119
 		$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";
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 getAllAirportNames($stats_airline = '',$filter_name = '') {
129
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
130 130
 		if ($filter_name == '') $filter_name = $this->filter_name;
131 131
 		$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";
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 141
 
142
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
142
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
143 143
 		if ($filter_name == '') $filter_name = $this->filter_name;
144 144
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
145 145
 		try {
146 146
 			$sth = $this->db->prepare($query);
147
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
148
-		} catch(PDOException $e) {
147
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
148
+		} catch (PDOException $e) {
149 149
 			echo "error : ".$e->getMessage();
150 150
 		}
151 151
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
152 152
 		return $all;
153 153
 	}
154 154
 
155
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
155
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
156 156
 		if ($filter_name == '') $filter_name = $this->filter_name;
157 157
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
158 158
 		try {
159 159
 			$sth = $this->db->prepare($query);
160
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
161
-		} catch(PDOException $e) {
160
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
161
+		} catch (PDOException $e) {
162 162
 			echo "error : ".$e->getMessage();
163 163
 		}
164 164
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -166,23 +166,23 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 
169
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
169
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
170 170
 		global $globalStatsFilters;
171 171
 		if ($filter_name == '') $filter_name = $this->filter_name;
172
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
172
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
173 173
 			$Spotter = new Spotter($this->db);
174
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
174
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
175 175
 			$alliance_airlines = array();
176 176
 			foreach ($airlines as $airline) {
177
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
177
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
178 178
 			}
179 179
 			if ($year == '' && $month == '') {
180
-				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 stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
181
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
180
+				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 stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
181
+				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
182 182
 				try {
183 183
 					$sth = $this->db->prepare($query);
184 184
 					$sth->execute(array(':filter_name' => $filter_name));
185
-				} catch(PDOException $e) {
185
+				} catch (PDOException $e) {
186 186
 					echo "error : ".$e->getMessage();
187 187
 				}
188 188
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -193,29 +193,29 @@  discard block
 block discarded – undo
193 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 stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
194 194
 				try {
195 195
 					$sth = $this->db->prepare($query);
196
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
197
-				} catch(PDOException $e) {
196
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
197
+				} catch (PDOException $e) {
198 198
 					echo "error : ".$e->getMessage();
199 199
 				}
200 200
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
201 201
 			} else $all = array();
202 202
 		}
203 203
 		if (empty($all)) {
204
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
205
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
204
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
205
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
206 206
 			} else {
207
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
207
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
208 208
 			}
209 209
 			if ($filter_name != '') {
210
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
210
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
211 211
 			}
212 212
 			$Spotter = new Spotter($this->db);
213 213
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
214
-			$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
214
+			$all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
215 215
 		}
216 216
 		return $all;
217 217
 	}
218
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
218
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
219 219
 		global $globalStatsFilters;
220 220
 		if ($filter_name == '') $filter_name = $this->filter_name;
221 221
 		if ($year == '' && $month == '') {
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 			try {
225 225
 				$sth = $this->db->prepare($query);
226 226
 				$sth->execute(array(':filter_name' => $filter_name));
227
-			} catch(PDOException $e) {
227
+			} catch (PDOException $e) {
228 228
 				echo "error : ".$e->getMessage();
229 229
 			}
230 230
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -232,32 +232,32 @@  discard block
 block discarded – undo
232 232
 		if (empty($all)) {
233 233
 			$Spotter = new Spotter($this->db);
234 234
 			$filters = array();
235
-			$filters = array('year' => $year,'month' => $month);
235
+			$filters = array('year' => $year, 'month' => $month);
236 236
 			if ($filter_name != '') {
237
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
237
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
238 238
 			}
239 239
 			//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
240
-			$all = $Spotter->countAllAirlineCountries($limit,$filters);
240
+			$all = $Spotter->countAllAirlineCountries($limit, $filters);
241 241
 		}
242 242
 		return $all;
243 243
 	}
244
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
244
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
245 245
 		global $globalStatsFilters;
246 246
 		if ($filter_name == '') $filter_name = $this->filter_name;
247
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
247
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
248 248
 			$Spotter = new Spotter($this->db);
249
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
249
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
250 250
 			$alliance_airlines = array();
251 251
 			foreach ($airlines as $airline) {
252
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
252
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
253 253
 			}
254 254
 			if ($year == '' && $month == '') {
255
-				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";
256
-				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";
255
+				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";
256
+				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";
257 257
 				try {
258 258
 					$sth = $this->db->prepare($query);
259 259
 					$sth->execute(array(':filter_name' => $filter_name));
260
-				} catch(PDOException $e) {
260
+				} catch (PDOException $e) {
261 261
 					echo "error : ".$e->getMessage();
262 262
 				}
263 263
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -268,21 +268,21 @@  discard block
 block discarded – undo
268 268
 				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";
269 269
 				try {
270 270
 					$sth = $this->db->prepare($query);
271
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
272
-				} catch(PDOException $e) {
271
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
272
+				} catch (PDOException $e) {
273 273
 					echo "error : ".$e->getMessage();
274 274
 				}
275 275
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
276 276
 			} else $all = array();
277 277
 		}
278 278
 		if (empty($all)) {
279
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
280
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
279
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
280
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
281 281
 			} else {
282
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
282
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
283 283
 			}
284 284
 			if ($filter_name != '') {
285
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
285
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
286 286
 			}
287 287
 			$Spotter = new Spotter($this->db);
288 288
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -291,23 +291,23 @@  discard block
 block discarded – undo
291 291
 		return $all;
292 292
 	}
293 293
 
294
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
294
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
295 295
 		global $globalStatsFilters;
296 296
 		if ($filter_name == '') $filter_name = $this->filter_name;
297
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
297
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
298 298
 			$Spotter = new Spotter($this->db);
299
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
299
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
300 300
 			$alliance_airlines = array();
301 301
 			foreach ($airlines as $airline) {
302
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
302
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
303 303
 			}
304 304
 			if ($year == '' && $month == '') {
305
-				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";
306
-				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";
305
+				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";
306
+				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";
307 307
 				try {
308 308
 					$sth = $this->db->prepare($query);
309 309
 					$sth->execute(array(':filter_name' => $filter_name));
310
-				} catch(PDOException $e) {
310
+				} catch (PDOException $e) {
311 311
 					echo "error : ".$e->getMessage();
312 312
 				}
313 313
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -318,61 +318,61 @@  discard block
 block discarded – undo
318 318
 				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";
319 319
 				try {
320 320
 					$sth = $this->db->prepare($query);
321
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
322
-				} catch(PDOException $e) {
321
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
322
+				} catch (PDOException $e) {
323 323
 					echo "error : ".$e->getMessage();
324 324
 				}
325 325
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
326 326
 			} else $all = array();
327 327
 		}
328 328
 		if (empty($all)) {
329
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
330
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
329
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
330
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
331 331
 			} else {
332
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
332
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
333 333
 			}
334 334
 			if ($filter_name != '') {
335
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
335
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
336 336
 			}
337 337
 			$Spotter = new Spotter($this->db);
338 338
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
339
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
339
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
340 340
 		}
341 341
 		return $all;
342 342
 	}
343 343
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
344 344
 		global $globalStatsFilters;
345 345
 		if ($filter_name == '') $filter_name = $this->filter_name;
346
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
346
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
347 347
 			$Spotter = new Spotter($this->db);
348
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
348
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
349 349
 			$alliance_airlines = array();
350 350
 			foreach ($airlines as $airline) {
351
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
351
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
352 352
 			}
353
-			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";
354
-			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";
353
+			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";
354
+			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";
355 355
 			$query_values = array(':filter_name' => $filter_name);
356 356
 		} else {
357 357
 			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";
358 358
 			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";
359
-			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
359
+			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
360 360
 		}
361 361
 		try {
362 362
 			$sth = $this->db->prepare($query);
363 363
 			$sth->execute($query_values);
364
-		} catch(PDOException $e) {
364
+		} catch (PDOException $e) {
365 365
 			echo "error : ".$e->getMessage();
366 366
 		}
367 367
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
368 368
 		if (empty($all)) {
369
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
370
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
369
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
370
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
371 371
 			} else {
372
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
372
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
373 373
 			}
374 374
 			if ($filter_name != '') {
375
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
375
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
376 376
 			}
377 377
 			$Spotter = new Spotter($this->db);
378 378
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 		return $all;
382 382
 	}
383 383
 
384
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
384
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
385 385
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
386 386
 		if ($filter_name == '') $filter_name = $this->filter_name;
387 387
 		if ($year == '' && $month == '') {
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 			if (isset($forsource)) {
391 391
 				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";
392 392
 				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";
393
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
393
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
394 394
 			} else {
395 395
 				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";
396 396
 				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";
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 			try {
400 400
 				$sth = $this->db->prepare($query);
401 401
 				$sth->execute($query_values);
402
-			} catch(PDOException $e) {
402
+			} catch (PDOException $e) {
403 403
 				echo "error : ".$e->getMessage();
404 404
 			}
405 405
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -407,32 +407,32 @@  discard block
 block discarded – undo
407 407
                 if (empty($all)) {
408 408
 	                $Spotter = new Spotter($this->db);
409 409
             		$filters = array();
410
-			$filters = array('year' => $year,'month' => $month);
410
+			$filters = array('year' => $year, 'month' => $month);
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
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
415
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
415
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
416 416
                 }
417 417
                 return $all;
418 418
 	}
419
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
419
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
420 420
 		global $globalStatsFilters;
421 421
 		if ($filter_name == '') $filter_name = $this->filter_name;
422
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
422
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
423 423
 			$Spotter = new Spotter($this->db);
424
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
424
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
425 425
 			$alliance_airlines = array();
426 426
 			foreach ($airlines as $airline) {
427
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
427
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
428 428
 			}
429 429
 			if ($year == '' && $month == '') {
430
-				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";
431
-				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";
430
+				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";
431
+				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";
432 432
 				try {
433 433
 					$sth = $this->db->prepare($query);
434 434
 					$sth->execute(array(':filter_name' => $filter_name));
435
-				} catch(PDOException $e) {
435
+				} catch (PDOException $e) {
436 436
 					echo "error : ".$e->getMessage();
437 437
 				}
438 438
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -443,45 +443,45 @@  discard block
 block discarded – undo
443 443
 				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";
444 444
 				try {
445 445
 					$sth = $this->db->prepare($query);
446
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
447
-				} catch(PDOException $e) {
446
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
447
+				} catch (PDOException $e) {
448 448
 					echo "error : ".$e->getMessage();
449 449
 				}
450 450
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
451 451
 			} else $all = array();
452 452
 		}
453 453
 		if (empty($all)) {
454
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
455
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
454
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
455
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
456 456
 			} else {
457
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
457
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
458 458
 			}
459 459
 			if ($filter_name != '') {
460
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
460
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
461 461
 			}
462 462
 			$Spotter = new Spotter($this->db);
463 463
 			//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
464
-			$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
464
+			$all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
465 465
 		}
466 466
 		return $all;
467 467
 	}
468
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
468
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
469 469
 		global $globalStatsFilters;
470 470
 		if ($filter_name == '') $filter_name = $this->filter_name;
471
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
471
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
472 472
 			$Spotter = new Spotter($this->db);
473
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
473
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
474 474
 			$alliance_airlines = array();
475 475
 			foreach ($airlines as $airline) {
476
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
476
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
477 477
 			}
478 478
 			if ($year == '' && $month == '') {
479
-				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";
480
-				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";
479
+				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";
480
+				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";
481 481
 				 try {
482 482
 					$sth = $this->db->prepare($query);
483 483
 					$sth->execute(array(':filter_name' => $filter_name));
484
-				} catch(PDOException $e) {
484
+				} catch (PDOException $e) {
485 485
 					echo "error : ".$e->getMessage();
486 486
 				}
487 487
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -492,46 +492,46 @@  discard block
 block discarded – undo
492 492
 				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";
493 493
 				 try {
494 494
 					$sth = $this->db->prepare($query);
495
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
496
-				} catch(PDOException $e) {
495
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
496
+				} catch (PDOException $e) {
497 497
 					echo "error : ".$e->getMessage();
498 498
 				}
499 499
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
500 500
 			} else $all = array();
501 501
 		}
502 502
 		if (empty($all)) {
503
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
504
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
503
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
504
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
505 505
 			} else {
506
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
506
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
507 507
 			}
508 508
 			if ($filter_name != '') {
509
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
509
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
510 510
 			}
511 511
 			$Spotter = new Spotter($this->db);
512 512
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
513
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
513
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
514 514
 		}
515 515
 		return $all;
516 516
 	}
517
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
517
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
518 518
 		$Connection = new Connection();
519 519
 		if ($filter_name == '') $filter_name = $this->filter_name;
520 520
 		if ($Connection->tableExists('countries')) {
521
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
521
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
522 522
 				$Spotter = new Spotter($this->db);
523
-				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
523
+				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
524 524
 				if ($year == '' && $month == '') {
525 525
 					$alliance_airlines = array();
526 526
 					foreach ($airlines as $airline) {
527
-						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
527
+						$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
528 528
 					}
529
-					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";
530
-					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";
529
+					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";
530
+					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";
531 531
 					 try {
532 532
 						$sth = $this->db->prepare($query);
533 533
 						$sth->execute(array(':filter_name' => $filter_name));
534
-					} catch(PDOException $e) {
534
+					} catch (PDOException $e) {
535 535
 						echo "error : ".$e->getMessage();
536 536
 					}
537 537
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -543,8 +543,8 @@  discard block
 block discarded – undo
543 543
 					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";
544 544
 					 try {
545 545
 						$sth = $this->db->prepare($query);
546
-						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
547
-					} catch(PDOException $e) {
546
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
547
+					} catch (PDOException $e) {
548 548
 						echo "error : ".$e->getMessage();
549 549
 					}
550 550
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 			return array();
562 562
 		}
563 563
 	}
564
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
564
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
565 565
 		global $globalStatsFilters;
566 566
 		if ($filter_name == '') $filter_name = $this->filter_name;
567 567
 		if ($year == '' && $month == '') {
@@ -569,41 +569,41 @@  discard block
 block discarded – undo
569 569
 			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";
570 570
 			try {
571 571
 				$sth = $this->db->prepare($query);
572
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
573
-			} catch(PDOException $e) {
572
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
573
+			} catch (PDOException $e) {
574 574
 				echo "error : ".$e->getMessage();
575 575
 			}
576 576
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
577 577
 		} else $all = array();
578 578
 		if (empty($all)) {
579
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
579
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
580 580
 			if ($filter_name != '') {
581
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
581
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
582 582
 			}
583 583
 			$Spotter = new Spotter($this->db);
584 584
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
585
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
585
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
586 586
 		}
587 587
 		return $all;
588 588
 	}
589 589
 
590
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
590
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
591 591
 		global $globalStatsFilters;
592 592
 		if ($filter_name == '') $filter_name = $this->filter_name;
593
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
593
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
594 594
 			$Spotter = new Spotter($this->db);
595
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
595
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
596 596
 			if ($year == '' && $month == '') {
597 597
 				$alliance_airlines = array();
598 598
 				foreach ($airlines as $airline) {
599
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
599
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
600 600
 				}
601
-				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";
602
-				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";
601
+				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";
602
+				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";
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);
@@ -614,45 +614,45 @@  discard block
 block discarded – undo
614 614
 				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";
615 615
 				try {
616 616
 					$sth = $this->db->prepare($query);
617
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
618
-				} catch(PDOException $e) {
617
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
618
+				} catch (PDOException $e) {
619 619
 					echo "error : ".$e->getMessage();
620 620
 				}
621 621
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
622 622
 			} else $all = array();
623 623
 		}
624 624
 		if (empty($all)) {
625
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
626
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
625
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
626
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
627 627
 			} else {
628
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
628
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
629 629
 			}
630 630
 			if ($filter_name != '') {
631
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
631
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
632 632
 			}
633 633
 			$Spotter = new Spotter($this->db);
634 634
 			//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
635
-			$all = $Spotter->countAllOwners($limit,0,'',$filters);
635
+			$all = $Spotter->countAllOwners($limit, 0, '', $filters);
636 636
 		}
637 637
 		return $all;
638 638
 	}
639
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
639
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
640 640
 		global $globalStatsFilters;
641 641
 		if ($filter_name == '') $filter_name = $this->filter_name;
642
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
642
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
643 643
 			$Spotter = new Spotter($this->db);
644
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
644
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
645 645
 			if ($year == '' && $month == '') {
646 646
 				$alliance_airlines = array();
647 647
 				foreach ($airlines as $airline) {
648
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
648
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
649 649
 				}
650
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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";
651
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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";
650
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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";
651
+				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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";
652 652
 				try {
653 653
 					$sth = $this->db->prepare($query);
654 654
 					$sth->execute(array(':filter_name' => $filter_name));
655
-				} catch(PDOException $e) {
655
+				} catch (PDOException $e) {
656 656
 					echo "error : ".$e->getMessage();
657 657
 				}
658 658
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -663,27 +663,27 @@  discard block
 block discarded – undo
663 663
 				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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";
664 664
 				try {
665 665
 					$sth = $this->db->prepare($query);
666
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
667
-				} catch(PDOException $e) {
666
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
667
+				} catch (PDOException $e) {
668 668
 					echo "error : ".$e->getMessage();
669 669
 				}
670 670
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
671 671
 			} else $all = array();
672 672
 		}
673 673
 		if (empty($all)) {
674
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
675
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
674
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
675
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
676 676
 			} else {
677
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
677
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
678 678
 			}
679 679
 			if ($filter_name != '') {
680
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
680
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
681 681
 			}
682 682
 			$Spotter = new Spotter($this->db);
683 683
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
684 684
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
685
-			$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
686
-			$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
685
+			$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
686
+			$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
687 687
 			$all = array();
688 688
 			foreach ($pall as $value) {
689 689
 				$icao = $value['airport_departure_icao'];
@@ -699,27 +699,27 @@  discard block
 block discarded – undo
699 699
 			foreach ($all as $key => $row) {
700 700
 				$count[$key] = $row['airport_departure_icao_count'];
701 701
 			}
702
-			array_multisort($count,SORT_DESC,$all);
702
+			array_multisort($count, SORT_DESC, $all);
703 703
 		}
704 704
 		return $all;
705 705
 	}
706
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
706
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
707 707
 		global $globalStatsFilters;
708 708
 		if ($filter_name == '') $filter_name = $this->filter_name;
709
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
709
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
710 710
 			$Spotter = new Spotter($this->db);
711
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
711
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
712 712
 			if ($year == '' && $month == '') {
713 713
 				$alliance_airlines = array();
714 714
 				foreach ($airlines as $airline) {
715
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
715
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
716 716
 				}
717
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
718
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
717
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
718
+				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
719 719
 				try {
720 720
 					$sth = $this->db->prepare($query);
721 721
 					$sth->execute(array(':filter_name' => $filter_name));
722
-				} catch(PDOException $e) {
722
+				} catch (PDOException $e) {
723 723
 					echo "error : ".$e->getMessage();
724 724
 				}
725 725
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -730,27 +730,27 @@  discard block
 block discarded – undo
730 730
 				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
731 731
 				try {
732 732
 					$sth = $this->db->prepare($query);
733
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
734
-				} catch(PDOException $e) {
733
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
734
+				} catch (PDOException $e) {
735 735
 					echo "error : ".$e->getMessage();
736 736
 				}
737 737
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
738 738
 			} else $all = array();
739 739
 		}
740 740
 		if (empty($all)) {
741
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
742
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
741
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
742
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
743 743
 			} else {
744
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
744
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
745 745
 			}
746 746
 			if ($filter_name != '') {
747
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
747
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
748 748
 			}
749 749
 			$Spotter = new Spotter($this->db);
750 750
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
751 751
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
752
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
753
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
752
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
753
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
754 754
 			$all = array();
755 755
 			foreach ($pall as $value) {
756 756
 				$icao = $value['airport_arrival_icao'];
@@ -766,26 +766,26 @@  discard block
 block discarded – undo
766 766
 			foreach ($all as $key => $row) {
767 767
 				$count[$key] = $row['airport_arrival_icao_count'];
768 768
 			}
769
-			array_multisort($count,SORT_DESC,$all);
769
+			array_multisort($count, SORT_DESC, $all);
770 770
 		}
771 771
 		return $all;
772 772
 	}
773
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
773
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
774 774
 		global $globalDBdriver, $globalStatsFilters;
775 775
 		if ($filter_name == '') $filter_name = $this->filter_name;
776
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
776
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
777 777
 			$Spotter = new Spotter($this->db);
778
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
778
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
779 779
 			$alliance_airlines = array();
780 780
 			foreach ($airlines as $airline) {
781
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
781
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
782 782
 			}
783 783
 			if ($globalDBdriver == 'mysql') {
784
-				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";
785
-				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";
784
+				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";
785
+				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";
786 786
 			} else {
787
-				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";
788
-				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";
787
+				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";
788
+				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";
789 789
 			}
790 790
 			$query_data = array(':filter_name' => $filter_name);
791 791
 		} else {
@@ -796,23 +796,23 @@  discard block
 block discarded – undo
796 796
 				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";
797 797
 				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";
798 798
 			}
799
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
799
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
800 800
 		}
801 801
 		try {
802 802
 			$sth = $this->db->prepare($query);
803 803
 			$sth->execute($query_data);
804
-		} catch(PDOException $e) {
804
+		} catch (PDOException $e) {
805 805
 			echo "error : ".$e->getMessage();
806 806
 		}
807 807
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
808 808
 		if (empty($all)) {
809
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
810
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
809
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
810
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
811 811
 			} else {
812 812
 				$filters = array('airlines' => array($stats_airline));
813 813
 			}
814 814
 			if ($filter_name != '') {
815
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
815
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
816 816
 			}
817 817
 			$Spotter = new Spotter($this->db);
818 818
 			$all = $Spotter->countAllMonthsLastYear($filters);
@@ -820,57 +820,57 @@  discard block
 block discarded – undo
820 820
 		return $all;
821 821
 	}
822 822
 	
823
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
823
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
824 824
 		global $globalStatsFilters;
825 825
 		if ($filter_name == '') $filter_name = $this->filter_name;
826
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
826
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
827 827
 			$Spotter = new Spotter($this->db);
828
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
828
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
829 829
 			$alliance_airlines = array();
830 830
 			foreach ($airlines as $airline) {
831
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
831
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
832 832
 			}
833
-			$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";
833
+			$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";
834 834
 			$query_data = array(':filter_name' => $filter_name);
835 835
 		} else {
836 836
 			$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";
837
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
837
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
838 838
 		}
839 839
 		try {
840 840
 			$sth = $this->db->prepare($query);
841 841
 			$sth->execute($query_data);
842
-		} catch(PDOException $e) {
842
+		} catch (PDOException $e) {
843 843
 			echo "error : ".$e->getMessage();
844 844
 		}
845 845
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
846 846
 		if (empty($all)) {
847
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
848
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
847
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
848
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
849 849
 			} else {
850 850
 				$filters = array('airlines' => array($stats_airline));
851 851
 			}
852 852
 			if ($filter_name != '') {
853
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
853
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
854 854
 			}
855 855
 			$Spotter = new Spotter($this->db);
856 856
 			$all = $Spotter->countAllDatesLastMonth($filters);
857 857
 		}
858 858
 		return $all;
859 859
 	}
860
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
860
+	public function countAllDatesLast7Days($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
-				$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";
871
+				$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";
872 872
 			} else {
873
-				$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";
873
+				$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";
874 874
 			}
875 875
 			$query_data = array(':filter_name' => $filter_name);
876 876
 		} else {
@@ -879,60 +879,60 @@  discard block
 block discarded – undo
879 879
 			} else {
880 880
 				$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";
881 881
 			}
882
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
882
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
883 883
 		}
884 884
 		try {
885 885
 			$sth = $this->db->prepare($query);
886 886
 			$sth->execute($query_data);
887
-		} catch(PDOException $e) {
887
+		} catch (PDOException $e) {
888 888
 			echo "error : ".$e->getMessage();
889 889
 		}
890 890
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
891 891
 		if (empty($all)) {
892
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
893
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
892
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
893
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
894 894
 			} else {
895 895
 				$filters = array('airlines' => array($stats_airline));
896 896
 			}
897 897
 			if ($filter_name != '') {
898
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
898
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
899 899
 			}
900 900
 			$Spotter = new Spotter($this->db);
901 901
 			$all = $Spotter->countAllDatesLast7Days($filters);
902 902
 		}
903 903
 		return $all;
904 904
 	}
905
-	public function countAllDates($stats_airline = '',$filter_name = '') {
905
+	public function countAllDates($stats_airline = '', $filter_name = '') {
906 906
 		global $globalStatsFilters;
907 907
 		if ($filter_name == '') $filter_name = $this->filter_name;
908
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
908
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
909 909
 			$Spotter = new Spotter($this->db);
910
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
910
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
911 911
 			$alliance_airlines = array();
912 912
 			foreach ($airlines as $airline) {
913
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
913
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
914 914
 			}
915
-			$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";
915
+			$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";
916 916
 			$query_data = array(':filter_name' => $filter_name);
917 917
 		} else {
918 918
 			$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";
919
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
919
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
920 920
 		}
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
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
930
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
929
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
930
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
931 931
 			} else {
932 932
 				$filters = array('airlines' => array($stats_airline));
933 933
 			}
934 934
 			if ($filter_name != '') {
935
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
935
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
936 936
 			}
937 937
 			$Spotter = new Spotter($this->db);
938 938
 			$all = $Spotter->countAllDates($filters);
@@ -947,34 +947,34 @@  discard block
 block discarded – undo
947 947
 		try {
948 948
 			$sth = $this->db->prepare($query);
949 949
 			$sth->execute($query_data);
950
-		} catch(PDOException $e) {
950
+		} catch (PDOException $e) {
951 951
 			echo "error : ".$e->getMessage();
952 952
 		}
953 953
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
954 954
 		if (empty($all)) {
955 955
 			$filters = array();
956 956
 			if ($filter_name != '') {
957
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
957
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
958 958
 			}
959 959
 			$Spotter = new Spotter($this->db);
960 960
 			$all = $Spotter->countAllDatesByAirlines($filters);
961 961
 		}
962 962
 		return $all;
963 963
 	}
964
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
964
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
965 965
 		global $globalStatsFilters, $globalDBdriver;
966 966
 		if ($filter_name == '') $filter_name = $this->filter_name;
967
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
967
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
968 968
 			$Spotter = new Spotter($this->db);
969
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
969
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
970 970
 			$alliance_airlines = array();
971 971
 			foreach ($airlines as $airline) {
972
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
972
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
973 973
 			}
974 974
 			if ($globalDBdriver == 'mysql') {
975
-				$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";
975
+				$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";
976 976
 			} else {
977
-				$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";
977
+				$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";
978 978
 			}
979 979
 			$query_data = array(':filter_name' => $filter_name);
980 980
 		} else {
@@ -988,18 +988,18 @@  discard block
 block discarded – undo
988 988
 		try {
989 989
 			$sth = $this->db->prepare($query);
990 990
 			$sth->execute($query_data);
991
-		} catch(PDOException $e) {
991
+		} catch (PDOException $e) {
992 992
 			echo "error : ".$e->getMessage();
993 993
 		}
994 994
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
995 995
 		if (empty($all)) {
996
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
997
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
996
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
997
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
998 998
 			} else {
999 999
 				$filters = array('airlines' => array($stats_airline));
1000 1000
 			}
1001 1001
 			if ($filter_name != '') {
1002
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1002
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1003 1003
 			}
1004 1004
 			$Spotter = new Spotter($this->db);
1005 1005
 			$all = $Spotter->countAllMonths($filters);
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
 		try {
1017 1017
 			$sth = $this->db->prepare($query);
1018 1018
 			$sth->execute();
1019
-		} catch(PDOException $e) {
1019
+		} catch (PDOException $e) {
1020 1020
 			echo "error : ".$e->getMessage();
1021 1021
 		}
1022 1022
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
 		try {
1037 1037
 			$sth = $this->db->prepare($query);
1038 1038
 			$sth->execute();
1039
-		} catch(PDOException $e) {
1039
+		} catch (PDOException $e) {
1040 1040
 			echo "error : ".$e->getMessage();
1041 1041
 		}
1042 1042
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1053,32 +1053,32 @@  discard block
 block discarded – undo
1053 1053
 		try {
1054 1054
 			$sth = $this->db->prepare($query);
1055 1055
 			$sth->execute(array(':filter_name' => $filter_name));
1056
-		} catch(PDOException $e) {
1056
+		} catch (PDOException $e) {
1057 1057
 			echo "error : ".$e->getMessage();
1058 1058
 		}
1059 1059
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1060 1060
 		if (empty($all)) {
1061 1061
 			$filters = array();
1062 1062
 			if ($filter_name != '') {
1063
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1063
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1064 1064
 			}
1065 1065
 			$Spotter = new Spotter($this->db);
1066 1066
 			$all = $Spotter->countAllMilitaryMonths($filters);
1067 1067
 		}
1068 1068
 		return $all;
1069 1069
 	}
1070
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1070
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
1071 1071
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1072 1072
 		if ($filter_name == '') $filter_name = $this->filter_name;
1073
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1073
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1074 1074
 			$Spotter = new Spotter($this->db);
1075
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1075
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1076 1076
 			$alliance_airlines = array();
1077 1077
 			foreach ($airlines as $airline) {
1078
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1078
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1079 1079
 			}
1080
-			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";
1081
-			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";
1080
+			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";
1081
+			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";
1082 1082
 			$query_data = array(':filter_name' => $filter_name);
1083 1083
 		} else {
1084 1084
 			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";
@@ -1096,37 +1096,37 @@  discard block
 block discarded – undo
1096 1096
 		try {
1097 1097
 			$sth = $this->db->prepare($query);
1098 1098
 			$sth->execute($query_data);
1099
-		} catch(PDOException $e) {
1099
+		} catch (PDOException $e) {
1100 1100
 			echo "error : ".$e->getMessage();
1101 1101
 		}
1102 1102
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1103 1103
 		if (empty($all)) {
1104
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1105
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1104
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1105
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1106 1106
 			} else {
1107 1107
 				$filters = array('airlines' => array($stats_airline));
1108 1108
 			}
1109 1109
 			if ($filter_name != '') {
1110
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1110
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1111 1111
 			}
1112 1112
 			$Spotter = new Spotter($this->db);
1113
-			$all = $Spotter->countAllHours($orderby,$filters);
1113
+			$all = $Spotter->countAllHours($orderby, $filters);
1114 1114
 		}
1115 1115
 		return $all;
1116 1116
 	}
1117
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1117
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1118 1118
 		global $globalStatsFilters;
1119 1119
 		if ($filter_name == '') $filter_name = $this->filter_name;
1120 1120
 		if ($year == '') $year = date('Y');
1121
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1121
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
1122 1122
 		if (empty($all)) {
1123
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1124
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1123
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1124
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1125 1125
 			} else {
1126
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1126
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1127 1127
 			}
1128 1128
 			if ($filter_name != '') {
1129
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1129
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1130 1130
 			}
1131 1131
 			$Spotter = new Spotter($this->db);
1132 1132
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1134,16 +1134,16 @@  discard block
 block discarded – undo
1134 1134
 		}
1135 1135
 		return $all;
1136 1136
 	}
1137
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1137
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
1138 1138
 		global $globalStatsFilters;
1139 1139
 		if ($filter_name == '') $filter_name = $this->filter_name;
1140 1140
 		if ($year == '') $year = date('Y');
1141
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1141
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
1142 1142
 		if (empty($all)) {
1143 1143
 			$filters = array();
1144
-			$filters = array('year' => $year,'month' => $month);
1144
+			$filters = array('year' => $year, 'month' => $month);
1145 1145
 			if ($filter_name != '') {
1146
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1146
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1147 1147
 			}
1148 1148
 			$Spotter = new Spotter($this->db);
1149 1149
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -1151,19 +1151,19 @@  discard block
 block discarded – undo
1151 1151
 		}
1152 1152
 		return $all;
1153 1153
 	}
1154
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1154
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1155 1155
 		global $globalStatsFilters;
1156 1156
 		if ($filter_name == '') $filter_name = $this->filter_name;
1157 1157
 		if ($year == '') $year = date('Y');
1158
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1158
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
1159 1159
 		if (empty($all)) {
1160
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1161
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1160
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1161
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1162 1162
 			} else {
1163
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1163
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1164 1164
 			}
1165 1165
 			if ($filter_name != '') {
1166
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1166
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1167 1167
 			}
1168 1168
 			$Spotter = new Spotter($this->db);
1169 1169
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -1171,48 +1171,48 @@  discard block
 block discarded – undo
1171 1171
 		}
1172 1172
 		return $all;
1173 1173
 	}
1174
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1174
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1175 1175
 		global $globalStatsFilters;
1176 1176
 		if ($filter_name == '') $filter_name = $this->filter_name;
1177
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1177
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1178 1178
 			$Spotter = new Spotter($this->db);
1179
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1179
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1180 1180
 			if ($year == '' && $month == '') {
1181 1181
 				$alliance_airlines = array();
1182 1182
 				foreach ($airlines as $airline) {
1183
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1183
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1184 1184
 				}
1185
-				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1185
+				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1186 1186
 				try {
1187 1187
 					$sth = $this->db->prepare($query);
1188 1188
 					$sth->execute(array(':filter_name' => $filter_name));
1189
-				} catch(PDOException $e) {
1189
+				} catch (PDOException $e) {
1190 1190
 					echo "error : ".$e->getMessage();
1191 1191
 				}
1192 1192
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1193 1193
 				$all = $result[0]['nb'];
1194
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1194
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1195 1195
 		} else {
1196 1196
 			if ($year == '' && $month == '') {
1197 1197
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1198 1198
 				try {
1199 1199
 					$sth = $this->db->prepare($query);
1200
-					$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
1201
-				} catch(PDOException $e) {
1200
+					$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
1201
+				} catch (PDOException $e) {
1202 1202
 					echo "error : ".$e->getMessage();
1203 1203
 				}
1204 1204
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1205 1205
 				$all = $result[0]['nb'];
1206
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1206
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1207 1207
 		}
1208 1208
 		if (empty($all)) {
1209
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1210
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1209
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1210
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1211 1211
 			} else {
1212
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1212
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1213 1213
 			}
1214 1214
 			if ($filter_name != '') {
1215
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1215
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1216 1216
 			}
1217 1217
 			$Spotter = new Spotter($this->db);
1218 1218
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
 		}
1221 1221
 		return $all;
1222 1222
 	}
1223
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1223
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
1224 1224
 		global $globalStatsFilters;
1225 1225
 		if ($filter_name == '') $filter_name = $this->filter_name;
1226 1226
 		if ($year == '' && $month == '') {
@@ -1228,17 +1228,17 @@  discard block
 block discarded – undo
1228 1228
 			try {
1229 1229
 				$sth = $this->db->prepare($query);
1230 1230
 				$sth->execute(array(':filter_name' => $filter_name));
1231
-			} catch(PDOException $e) {
1231
+			} catch (PDOException $e) {
1232 1232
 				echo "error : ".$e->getMessage();
1233 1233
 			}
1234 1234
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1235 1235
 			$all = $result[0]['nb_airline'];
1236
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1236
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
1237 1237
 		if (empty($all)) {
1238 1238
 			$filters = array();
1239
-			$filters = array('year' => $year,'month' => $month);
1239
+			$filters = array('year' => $year, 'month' => $month);
1240 1240
 			if ($filter_name != '') {
1241
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1241
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1242 1242
 			}
1243 1243
 			$Spotter = new Spotter($this->db);
1244 1244
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1246,29 +1246,29 @@  discard block
 block discarded – undo
1246 1246
 		}
1247 1247
 		return $all;
1248 1248
 	}
1249
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1249
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1250 1250
 		global $globalStatsFilters;
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
 			if ($year == '' && $month == '') {
1256 1256
 				$alliance_airlines = array();
1257 1257
 				foreach ($airlines as $airline) {
1258
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1258
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1259 1259
 				}
1260
-				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1260
+				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1261 1261
 				$query_values = array(':filter_name' => $filter_name);
1262 1262
 				try {
1263 1263
 					$sth = $this->db->prepare($query);
1264 1264
 					$sth->execute($query_values);
1265
-				} catch(PDOException $e) {
1265
+				} catch (PDOException $e) {
1266 1266
 					echo "error : ".$e->getMessage();
1267 1267
 				}
1268 1268
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1269 1269
 				$all = $result[0]['nb'];
1270 1270
 			} else {
1271
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1271
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1272 1272
 			}
1273 1273
 		} else {
1274 1274
 			if ($year == '' && $month == '') {
@@ -1277,23 +1277,23 @@  discard block
 block discarded – undo
1277 1277
 				try {
1278 1278
 					$sth = $this->db->prepare($query);
1279 1279
 					$sth->execute($query_values);
1280
-				} catch(PDOException $e) {
1280
+				} catch (PDOException $e) {
1281 1281
 					echo "error : ".$e->getMessage();
1282 1282
 				}
1283 1283
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1284 1284
 				$all = $result[0]['nb'];
1285 1285
 			} else {
1286
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1286
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1287 1287
 			}
1288 1288
 		}
1289 1289
 		if (empty($all)) {
1290
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1291
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1290
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1291
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1292 1292
 			} else {
1293
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1293
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1294 1294
 			}
1295 1295
 			if ($filter_name != '') {
1296
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1296
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1297 1297
 			}
1298 1298
 			$Spotter = new Spotter($this->db);
1299 1299
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 		}
1302 1302
 		return $all;
1303 1303
 	}
1304
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1304
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1305 1305
 		global $globalStatsFilters;
1306 1306
 		if ($filter_name == '') $filter_name = $this->filter_name;
1307 1307
 		//if ($year == '') $year = date('Y');
@@ -1311,18 +1311,18 @@  discard block
 block discarded – undo
1311 1311
 			try {
1312 1312
 				$sth = $this->db->prepare($query);
1313 1313
 				$sth->execute($query_values);
1314
-			} catch(PDOException $e) {
1314
+			} catch (PDOException $e) {
1315 1315
 				echo "error : ".$e->getMessage();
1316 1316
 			}
1317 1317
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1318 1318
 			$all = $result[0]['nb'];
1319 1319
 		} else {
1320
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
1320
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
1321 1321
 		}
1322 1322
 		if (empty($all)) {
1323
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1323
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1324 1324
 			if ($filter_name != '') {
1325
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1325
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1326 1326
 			}
1327 1327
 			$Spotter = new Spotter($this->db);
1328 1328
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -1331,104 +1331,104 @@  discard block
 block discarded – undo
1331 1331
 		return $all;
1332 1332
 	}
1333 1333
 
1334
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1334
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
1335 1335
 		if ($filter_name == '') $filter_name = $this->filter_name;
1336
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1336
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1337 1337
 			$Spotter = new Spotter($this->db);
1338
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1338
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1339 1339
 			$alliance_airlines = array();
1340 1340
 			foreach ($airlines as $airline) {
1341
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1341
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1342 1342
 			}
1343
-			$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";
1344
-			$query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name);
1343
+			$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";
1344
+			$query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name);
1345 1345
 		} else {
1346 1346
 			$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";
1347
-			$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1347
+			$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1348 1348
 		}
1349 1349
 		try {
1350 1350
 			$sth = $this->db->prepare($query);
1351 1351
 			$sth->execute($query_values);
1352
-		} catch(PDOException $e) {
1352
+		} catch (PDOException $e) {
1353 1353
 			echo "error : ".$e->getMessage();
1354 1354
 		}
1355 1355
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1356 1356
 		return $all;
1357 1357
 	}
1358
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
1358
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
1359 1359
 		if ($filter_name == '') $filter_name = $this->filter_name;
1360 1360
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1361
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1361
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1362 1362
 		try {
1363 1363
 			$sth = $this->db->prepare($query);
1364 1364
 			$sth->execute($query_values);
1365
-		} catch(PDOException $e) {
1365
+		} catch (PDOException $e) {
1366 1366
 			echo "error : ".$e->getMessage();
1367 1367
 		}
1368 1368
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1369 1369
 		return $all;
1370 1370
 	}
1371
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1371
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
1372 1372
 		if ($filter_name == '') $filter_name = $this->filter_name;
1373 1373
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1374
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1374
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1375 1375
 		try {
1376 1376
 			$sth = $this->db->prepare($query);
1377 1377
 			$sth->execute($query_values);
1378
-		} catch(PDOException $e) {
1378
+		} catch (PDOException $e) {
1379 1379
 			echo "error : ".$e->getMessage();
1380 1380
 		}
1381 1381
 	}
1382
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1382
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
1383 1383
 		if ($filter_name == '') $filter_name = $this->filter_name;
1384 1384
 		global $globalArchiveMonths, $globalDBdriver;
1385
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1385
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1386 1386
 			$Spotter = new Spotter($this->db);
1387
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1387
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1388 1388
 			$alliance_airlines = array();
1389 1389
 			foreach ($airlines as $airline) {
1390
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1390
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1391 1391
 			}
1392 1392
 			if ($globalDBdriver == 'mysql') {
1393 1393
 				if ($month == '') {
1394
-					$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";
1394
+					$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";
1395 1395
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1396 1396
 				} else {
1397
-					$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";
1398
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1397
+					$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";
1398
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1399 1399
 				}
1400 1400
 			} else {
1401 1401
 				if ($month == '') {
1402
-					$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";
1402
+					$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";
1403 1403
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1404 1404
 				} else {
1405
-					$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";
1406
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1405
+					$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";
1406
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1407 1407
 				}
1408 1408
 			}
1409 1409
 		} else {
1410 1410
 			if ($globalDBdriver == 'mysql') {
1411 1411
 				if ($month == '') {
1412 1412
 					$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";
1413
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1413
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1414 1414
 				} else {
1415 1415
 					$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";
1416
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1416
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1417 1417
 				}
1418 1418
 			} else {
1419 1419
 				if ($month == '') {
1420 1420
 					$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";
1421
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1421
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1422 1422
 				} else {
1423 1423
 					$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";
1424
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1424
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1425 1425
 				}
1426 1426
 			}
1427 1427
 		}
1428 1428
 		try {
1429 1429
 			$sth = $this->db->prepare($query);
1430 1430
 			$sth->execute($query_values);
1431
-		} catch(PDOException $e) {
1431
+		} catch (PDOException $e) {
1432 1432
 			echo "error : ".$e->getMessage();
1433 1433
 		}
1434 1434
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1437,17 +1437,17 @@  discard block
 block discarded – undo
1437 1437
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1438 1438
 		global $globalArchiveMonths, $globalDBdriver;
1439 1439
 		if ($filter_name == '') $filter_name = $this->filter_name;
1440
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1440
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1441 1441
 			$Spotter = new Spotter($this->db);
1442
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1442
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1443 1443
 			$alliance_airlines = array();
1444 1444
 			foreach ($airlines as $airline) {
1445
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1445
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1446 1446
 			}
1447 1447
 			if ($globalDBdriver == 'mysql') {
1448
-				$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";
1448
+				$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";
1449 1449
 			} else {
1450
-				$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";
1450
+				$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";
1451 1451
 			}
1452 1452
 			$query_values = array(':type' => $type, ':filter_name' => $filter_name);
1453 1453
 		} else {
@@ -1461,7 +1461,7 @@  discard block
 block discarded – undo
1461 1461
 		try {
1462 1462
 			$sth = $this->db->prepare($query);
1463 1463
 			$sth->execute($query_values);
1464
-		} catch(PDOException $e) {
1464
+		} catch (PDOException $e) {
1465 1465
 			echo "error : ".$e->getMessage();
1466 1466
 		}
1467 1467
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1470,17 +1470,17 @@  discard block
 block discarded – undo
1470 1470
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1471 1471
 		global $globalArchiveMonths, $globalDBdriver;
1472 1472
 		if ($filter_name == '') $filter_name = $this->filter_name;
1473
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1473
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1474 1474
 			$Spotter = new Spotter($this->db);
1475
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1475
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1476 1476
 			$alliance_airlines = array();
1477 1477
 			foreach ($airlines as $airline) {
1478
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1478
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1479 1479
 			}
1480 1480
 			if ($globalDBdriver == 'mysql') {
1481
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1481
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1482 1482
 			} else {
1483
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1483
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1484 1484
 			}
1485 1485
 		} else {
1486 1486
 			if ($globalDBdriver == 'mysql') {
@@ -1492,7 +1492,7 @@  discard block
 block discarded – undo
1492 1492
 		try {
1493 1493
 			$sth = $this->db->prepare($query);
1494 1494
 			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1495
-		} catch(PDOException $e) {
1495
+		} catch (PDOException $e) {
1496 1496
 			echo "error : ".$e->getMessage();
1497 1497
 		}
1498 1498
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
 		try {
1510 1510
 			$sth = $this->db->prepare($query);
1511 1511
 			$sth->execute(array(':filter_name' => $filter_name));
1512
-		} catch(PDOException $e) {
1512
+		} catch (PDOException $e) {
1513 1513
 			echo "error : ".$e->getMessage();
1514 1514
 		}
1515 1515
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1526,20 +1526,20 @@  discard block
 block discarded – undo
1526 1526
 		try {
1527 1527
 			$sth = $this->db->prepare($query);
1528 1528
 			$sth->execute(array(':filter_name' => $filter_name));
1529
-		} catch(PDOException $e) {
1529
+		} catch (PDOException $e) {
1530 1530
 			echo "error : ".$e->getMessage();
1531 1531
 		}
1532 1532
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1533 1533
 		return $all[0]['total'];
1534 1534
 	}
1535
-	public function getStatsOwner($owner_name,$filter_name = '') {
1535
+	public function getStatsOwner($owner_name, $filter_name = '') {
1536 1536
 		global $globalArchiveMonths, $globalDBdriver;
1537 1537
 		if ($filter_name == '') $filter_name = $this->filter_name;
1538 1538
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1539 1539
 		try {
1540 1540
 			$sth = $this->db->prepare($query);
1541
-			$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1542
-		} catch(PDOException $e) {
1541
+			$sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1542
+		} catch (PDOException $e) {
1543 1543
 			echo "error : ".$e->getMessage();
1544 1544
 		}
1545 1545
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1557,20 +1557,20 @@  discard block
 block discarded – undo
1557 1557
 		try {
1558 1558
 			$sth = $this->db->prepare($query);
1559 1559
 			$sth->execute(array(':filter_name' => $filter_name));
1560
-		} catch(PDOException $e) {
1560
+		} catch (PDOException $e) {
1561 1561
 			echo "error : ".$e->getMessage();
1562 1562
 		}
1563 1563
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1564 1564
 		return $all[0]['total'];
1565 1565
 	}
1566
-	public function getStatsPilot($pilot,$filter_name = '') {
1566
+	public function getStatsPilot($pilot, $filter_name = '') {
1567 1567
 		global $globalArchiveMonths, $globalDBdriver;
1568 1568
 		if ($filter_name == '') $filter_name = $this->filter_name;
1569 1569
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1570 1570
 		try {
1571 1571
 			$sth = $this->db->prepare($query);
1572
-			$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1573
-		} catch(PDOException $e) {
1572
+			$sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1573
+		} catch (PDOException $e) {
1574 1574
 			echo "error : ".$e->getMessage();
1575 1575
 		}
1576 1576
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 		else return 0;
1579 1579
 	}
1580 1580
 
1581
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1581
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1582 1582
 		global $globalDBdriver;
1583 1583
 		if ($filter_name == '') $filter_name = $this->filter_name;
1584 1584
 		if ($globalDBdriver == 'mysql') {
@@ -1586,15 +1586,15 @@  discard block
 block discarded – undo
1586 1586
 		} else {
1587 1587
 			$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);"; 
1588 1588
 		}
1589
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1589
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1590 1590
 		try {
1591 1591
 			$sth = $this->db->prepare($query);
1592 1592
 			$sth->execute($query_values);
1593
-		} catch(PDOException $e) {
1593
+		} catch (PDOException $e) {
1594 1594
 			return "error : ".$e->getMessage();
1595 1595
 		}
1596 1596
 	}
1597
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1597
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1598 1598
 		global $globalDBdriver;
1599 1599
 		if ($filter_name == '') $filter_name = $this->filter_name;
1600 1600
 		if ($globalDBdriver == 'mysql') {
@@ -1603,11 +1603,11 @@  discard block
 block discarded – undo
1603 1603
 			//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1604 1604
 			$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);"; 
1605 1605
 		}
1606
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1606
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1607 1607
 		try {
1608 1608
 			$sth = $this->db->prepare($query);
1609 1609
 			$sth->execute($query_values);
1610
-		} catch(PDOException $e) {
1610
+		} catch (PDOException $e) {
1611 1611
 			return "error : ".$e->getMessage();
1612 1612
 		}
1613 1613
 	}
@@ -1631,75 +1631,75 @@  discard block
 block discarded – undo
1631 1631
         }
1632 1632
         */
1633 1633
 
1634
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1634
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1635 1635
 		global $globalDBdriver;
1636 1636
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1637 1637
 		$query_values = array();
1638 1638
 		if ($globalDBdriver == 'mysql') {
1639 1639
 			if ($year != '') {
1640 1640
 				$query .= ' AND YEAR(stats_date) = :year';
1641
-				$query_values = array_merge($query_values,array(':year' => $year));
1641
+				$query_values = array_merge($query_values, array(':year' => $year));
1642 1642
 			}
1643 1643
 			if ($month != '') {
1644 1644
 				$query .= ' AND MONTH(stats_date) = :month';
1645
-				$query_values = array_merge($query_values,array(':month' => $month));
1645
+				$query_values = array_merge($query_values, array(':month' => $month));
1646 1646
 			}
1647 1647
 			if ($day != '') {
1648 1648
 				$query .= ' AND DAY(stats_date) = :day';
1649
-				$query_values = array_merge($query_values,array(':day' => $day));
1649
+				$query_values = array_merge($query_values, array(':day' => $day));
1650 1650
 			}
1651 1651
 		} else {
1652 1652
 			if ($year != '') {
1653 1653
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1654
-				$query_values = array_merge($query_values,array(':year' => $year));
1654
+				$query_values = array_merge($query_values, array(':year' => $year));
1655 1655
 			}
1656 1656
 			if ($month != '') {
1657 1657
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1658
-				$query_values = array_merge($query_values,array(':month' => $month));
1658
+				$query_values = array_merge($query_values, array(':month' => $month));
1659 1659
 			}
1660 1660
 			if ($day != '') {
1661 1661
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1662
-				$query_values = array_merge($query_values,array(':day' => $day));
1662
+				$query_values = array_merge($query_values, array(':day' => $day));
1663 1663
 			}
1664 1664
 		}
1665 1665
 		$query .= " ORDER BY source_name";
1666
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1666
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1667 1667
 		try {
1668 1668
 			$sth = $this->db->prepare($query);
1669 1669
 			$sth->execute($query_values);
1670
-		} catch(PDOException $e) {
1670
+		} catch (PDOException $e) {
1671 1671
 			echo "error : ".$e->getMessage();
1672 1672
 		}
1673 1673
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1674 1674
 		return $all;
1675 1675
 	}
1676 1676
 
1677
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1677
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1678 1678
 		global $globalDBdriver;
1679 1679
 		if ($globalDBdriver == 'mysql') {
1680 1680
 			$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";
1681 1681
 		} else {
1682 1682
 			$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);"; 
1683 1683
 		}
1684
-		$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1684
+		$query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1685 1685
 		try {
1686 1686
 			$sth = $this->db->prepare($query);
1687 1687
 			$sth->execute($query_values);
1688
-		} catch(PDOException $e) {
1688
+		} catch (PDOException $e) {
1689 1689
 			return "error : ".$e->getMessage();
1690 1690
 		}
1691 1691
 	}
1692
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1692
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1693 1693
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1694
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1694
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1695 1695
 		try {
1696 1696
 			$sth = $this->db->prepare($query);
1697 1697
 			$sth->execute($query_values);
1698
-		} catch(PDOException $e) {
1698
+		} catch (PDOException $e) {
1699 1699
 			return "error : ".$e->getMessage();
1700 1700
 		}
1701 1701
 	}
1702
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1702
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1703 1703
 		global $globalDBdriver;
1704 1704
 		if ($globalDBdriver == 'mysql') {
1705 1705
 			if ($reset) {
@@ -1714,15 +1714,15 @@  discard block
 block discarded – undo
1714 1714
 				$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);"; 
1715 1715
 			}
1716 1716
 		}
1717
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1717
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1718 1718
 		try {
1719 1719
 			$sth = $this->db->prepare($query);
1720 1720
 			$sth->execute($query_values);
1721
-		} catch(PDOException $e) {
1721
+		} catch (PDOException $e) {
1722 1722
 			return "error : ".$e->getMessage();
1723 1723
 		}
1724 1724
 	}
1725
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1725
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1726 1726
 		global $globalDBdriver;
1727 1727
 		if ($globalDBdriver == 'mysql') {
1728 1728
 			if ($reset) {
@@ -1737,15 +1737,15 @@  discard block
 block discarded – undo
1737 1737
 				$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);"; 
1738 1738
 			}
1739 1739
 		}
1740
-		$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1740
+		$query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1741 1741
 		try {
1742 1742
 			$sth = $this->db->prepare($query);
1743 1743
 			$sth->execute($query_values);
1744
-		} catch(PDOException $e) {
1744
+		} catch (PDOException $e) {
1745 1745
 			return "error : ".$e->getMessage();
1746 1746
 		}
1747 1747
 	}
1748
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1748
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1749 1749
 		global $globalDBdriver;
1750 1750
 		if ($globalDBdriver == 'mysql') {
1751 1751
 			if ($reset) {
@@ -1760,15 +1760,15 @@  discard block
 block discarded – undo
1760 1760
 				$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);"; 
1761 1761
 			}
1762 1762
 		}
1763
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1763
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1764 1764
 		try {
1765 1765
 			$sth = $this->db->prepare($query);
1766 1766
 			$sth->execute($query_values);
1767
-		} catch(PDOException $e) {
1767
+		} catch (PDOException $e) {
1768 1768
 			return "error : ".$e->getMessage();
1769 1769
 		}
1770 1770
 	}
1771
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1771
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1772 1772
 		global $globalDBdriver;
1773 1773
 		if ($globalDBdriver == 'mysql') {
1774 1774
 			if ($reset) {
@@ -1783,15 +1783,15 @@  discard block
 block discarded – undo
1783 1783
 				$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);"; 
1784 1784
 			}
1785 1785
 		}
1786
-		$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);
1786
+		$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);
1787 1787
 		try {
1788 1788
 			$sth = $this->db->prepare($query);
1789 1789
 			$sth->execute($query_values);
1790
-		} catch(PDOException $e) {
1790
+		} catch (PDOException $e) {
1791 1791
 			return "error : ".$e->getMessage();
1792 1792
 		}
1793 1793
 	}
1794
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1794
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1795 1795
 		global $globalDBdriver;
1796 1796
 		if ($globalDBdriver == 'mysql') {
1797 1797
 			if ($reset) {
@@ -1806,15 +1806,15 @@  discard block
 block discarded – undo
1806 1806
 				$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);"; 
1807 1807
 			}
1808 1808
 		}
1809
-		$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1809
+		$query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1810 1810
 		try {
1811 1811
 			$sth = $this->db->prepare($query);
1812 1812
 			$sth->execute($query_values);
1813
-		} catch(PDOException $e) {
1813
+		} catch (PDOException $e) {
1814 1814
 			return "error : ".$e->getMessage();
1815 1815
 		}
1816 1816
 	}
1817
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1817
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1818 1818
 		global $globalDBdriver;
1819 1819
 		if ($globalDBdriver == 'mysql') {
1820 1820
 			if ($reset) {
@@ -1829,15 +1829,15 @@  discard block
 block discarded – undo
1829 1829
 				$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);"; 
1830 1830
 			}
1831 1831
 		}
1832
-		$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1832
+		$query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1833 1833
 		try {
1834 1834
 			$sth = $this->db->prepare($query);
1835 1835
 			$sth->execute($query_values);
1836
-		} catch(PDOException $e) {
1836
+		} catch (PDOException $e) {
1837 1837
 			return "error : ".$e->getMessage();
1838 1838
 		}
1839 1839
 	}
1840
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1840
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1841 1841
 		global $globalDBdriver;
1842 1842
 		if ($globalDBdriver == 'mysql') {
1843 1843
 			if ($reset) {
@@ -1852,15 +1852,15 @@  discard block
 block discarded – undo
1852 1852
 				$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);"; 
1853 1853
 			}
1854 1854
 		}
1855
-		$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);
1855
+		$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);
1856 1856
 		try {
1857 1857
 			$sth = $this->db->prepare($query);
1858 1858
 			$sth->execute($query_values);
1859
-		} catch(PDOException $e) {
1859
+		} catch (PDOException $e) {
1860 1860
 			return "error : ".$e->getMessage();
1861 1861
 		}
1862 1862
 	}
1863
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1863
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1864 1864
 		global $globalDBdriver;
1865 1865
 		if ($airport_icao != '') {
1866 1866
 			if ($globalDBdriver == 'mysql') {
@@ -1876,16 +1876,16 @@  discard block
 block discarded – undo
1876 1876
 					$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);"; 
1877 1877
 				}
1878 1878
 			}
1879
-			$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);
1879
+			$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);
1880 1880
 			try {
1881 1881
 				$sth = $this->db->prepare($query);
1882 1882
 				$sth->execute($query_values);
1883
-			} catch(PDOException $e) {
1883
+			} catch (PDOException $e) {
1884 1884
 				return "error : ".$e->getMessage();
1885 1885
 			}
1886 1886
 		}
1887 1887
 	}
1888
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1888
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1889 1889
 		global $globalDBdriver;
1890 1890
 		if ($airport_icao != '') {
1891 1891
 			if ($globalDBdriver == 'mysql') {
@@ -1893,16 +1893,16 @@  discard block
 block discarded – undo
1893 1893
 			} else {
1894 1894
 				$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);"; 
1895 1895
 			}
1896
-			$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);
1896
+			$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);
1897 1897
 			 try {
1898 1898
 				$sth = $this->db->prepare($query);
1899 1899
 				$sth->execute($query_values);
1900
-			} catch(PDOException $e) {
1900
+			} catch (PDOException $e) {
1901 1901
 				return "error : ".$e->getMessage();
1902 1902
 			}
1903 1903
 		}
1904 1904
 	}
1905
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1905
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1906 1906
 		global $globalDBdriver;
1907 1907
 		if ($airport_icao != '') {
1908 1908
 			if ($globalDBdriver == 'mysql') {
@@ -1918,16 +1918,16 @@  discard block
 block discarded – undo
1918 1918
 					$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);"; 
1919 1919
 				}
1920 1920
 			}
1921
-			$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);
1921
+			$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);
1922 1922
 			try {
1923 1923
 				$sth = $this->db->prepare($query);
1924 1924
 				$sth->execute($query_values);
1925
-			} catch(PDOException $e) {
1925
+			} catch (PDOException $e) {
1926 1926
 				return "error : ".$e->getMessage();
1927 1927
 			}
1928 1928
 		}
1929 1929
 	}
1930
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1930
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1931 1931
 		global $globalDBdriver;
1932 1932
 		if ($airport_icao != '') {
1933 1933
 			if ($globalDBdriver == 'mysql') {
@@ -1935,11 +1935,11 @@  discard block
 block discarded – undo
1935 1935
 			} else {
1936 1936
 				$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);"; 
1937 1937
 			}
1938
-			$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);
1938
+			$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);
1939 1939
 			try {
1940 1940
 				$sth = $this->db->prepare($query);
1941 1941
 				$sth->execute($query_values);
1942
-			} catch(PDOException $e) {
1942
+			} catch (PDOException $e) {
1943 1943
 				return "error : ".$e->getMessage();
1944 1944
 			}
1945 1945
 		}
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
 		try {
1952 1952
 			$sth = $this->db->prepare($query);
1953 1953
 			$sth->execute($query_values);
1954
-		} catch(PDOException $e) {
1954
+		} catch (PDOException $e) {
1955 1955
 			return "error : ".$e->getMessage();
1956 1956
 		}
1957 1957
 	}
@@ -1961,7 +1961,7 @@  discard block
 block discarded – undo
1961 1961
 		try {
1962 1962
 			$sth = $this->db->prepare($query);
1963 1963
 			$sth->execute($query_values);
1964
-		} catch(PDOException $e) {
1964
+		} catch (PDOException $e) {
1965 1965
 			return "error : ".$e->getMessage();
1966 1966
 		}
1967 1967
 	}
@@ -1971,13 +1971,13 @@  discard block
 block discarded – undo
1971 1971
 		try {
1972 1972
 			$sth = $this->db->prepare($query);
1973 1973
 			$sth->execute($query_values);
1974
-		} catch(PDOException $e) {
1974
+		} catch (PDOException $e) {
1975 1975
 			return "error : ".$e->getMessage();
1976 1976
 		}
1977 1977
 	}
1978 1978
 
1979 1979
 	public function addOldStats() {
1980
-		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
1980
+		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents;
1981 1981
 		$Common = new Common();
1982 1982
 		$Connection = new Connection();
1983 1983
 		date_default_timezone_set('UTC');
@@ -1995,41 +1995,41 @@  discard block
 block discarded – undo
1995 1995
 			$Spotter = new Spotter($this->db);
1996 1996
 
1997 1997
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1998
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1998
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1999 1999
 			foreach ($alldata as $number) {
2000
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2000
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
2001 2001
 			}
2002 2002
 			if ($globalDebug) echo 'Count all airlines...'."\n";
2003
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2003
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
2004 2004
 			foreach ($alldata as $number) {
2005
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2005
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
2006 2006
 			}
2007 2007
 			if ($globalDebug) echo 'Count all registrations...'."\n";
2008
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2008
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
2009 2009
 			foreach ($alldata as $number) {
2010
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2010
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
2011 2011
 			}
2012 2012
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
2013
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2013
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
2014 2014
 			foreach ($alldata as $number) {
2015
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2015
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2016 2016
 			}
2017 2017
 			if ($globalDebug) echo 'Count all owners...'."\n";
2018
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2018
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
2019 2019
 			foreach ($alldata as $number) {
2020
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2020
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
2021 2021
 			}
2022 2022
 			if ($globalDebug) echo 'Count all pilots...'."\n";
2023
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2023
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
2024 2024
 			foreach ($alldata as $number) {
2025 2025
 				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2026
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2026
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
2027 2027
 			}
2028 2028
 			
2029 2029
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
2030
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2030
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
2031 2031
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2032
-			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2032
+			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
2033 2033
 			if ($globalDebug) echo 'Order departure airports...'."\n";
2034 2034
 			$alldata = array();
2035 2035
 			foreach ($pall as $value) {
@@ -2046,14 +2046,14 @@  discard block
 block discarded – undo
2046 2046
 			foreach ($alldata as $key => $row) {
2047 2047
 				$count[$key] = $row['airport_departure_icao_count'];
2048 2048
 			}
2049
-			array_multisort($count,SORT_DESC,$alldata);
2049
+			array_multisort($count, SORT_DESC, $alldata);
2050 2050
 			foreach ($alldata as $number) {
2051
-				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);
2051
+				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);
2052 2052
 			}
2053 2053
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2054
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2054
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
2055 2055
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2056
-			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2056
+			$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
2057 2057
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
2058 2058
 			$alldata = array();
2059 2059
 			foreach ($pall as $value) {
@@ -2070,18 +2070,18 @@  discard block
 block discarded – undo
2070 2070
 			foreach ($alldata as $key => $row) {
2071 2071
 				$count[$key] = $row['airport_arrival_icao_count'];
2072 2072
 			}
2073
-			array_multisort($count,SORT_DESC,$alldata);
2073
+			array_multisort($count, SORT_DESC, $alldata);
2074 2074
 			foreach ($alldata as $number) {
2075
-				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);
2075
+				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);
2076 2076
 			}
2077 2077
 			if ($Connection->tableExists('countries')) {
2078 2078
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2079 2079
 				//$SpotterArchive = new SpotterArchive();
2080 2080
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2081 2081
 				$Spotter = new Spotter($this->db);
2082
-				$alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day);
2082
+				$alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day);
2083 2083
 				foreach ($alldata as $number) {
2084
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
2084
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
2085 2085
 				}
2086 2086
 			}
2087 2087
 			
@@ -2091,12 +2091,12 @@  discard block
 block discarded – undo
2091 2091
 				$this->deleteStatsByType('fatalities_byyear');
2092 2092
 				$alldata = $Accident->countFatalitiesByYear();
2093 2093
 				foreach ($alldata as $number) {
2094
-					$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
2094
+					$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
2095 2095
 				}
2096 2096
 				$this->deleteStatsByType('fatalities_bymonth');
2097 2097
 				$alldata = $Accident->countFatalitiesLast12Months();
2098 2098
 				foreach ($alldata as $number) {
2099
-					$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
2099
+					$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
2100 2100
 				}
2101 2101
 			}
2102 2102
 
@@ -2110,37 +2110,37 @@  discard block
 block discarded – undo
2110 2110
 			$lastyear = false;
2111 2111
 			foreach ($alldata as $number) {
2112 2112
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2113
-				$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'])));
2113
+				$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'])));
2114 2114
 			}
2115 2115
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2116 2116
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2117 2117
 			foreach ($alldata as $number) {
2118
-				$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'])));
2118
+				$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'])));
2119 2119
 			}
2120 2120
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
2121 2121
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2122 2122
 			foreach ($alldata as $number) {
2123
-				$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'])));
2123
+				$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'])));
2124 2124
 			}
2125 2125
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2126 2126
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2127 2127
 			foreach ($alldata as $number) {
2128
-				$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'])));
2128
+				$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'])));
2129 2129
 			}
2130 2130
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2131 2131
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2132 2132
 			foreach ($alldata as $number) {
2133
-				$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'])));
2133
+				$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'])));
2134 2134
 			}
2135 2135
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2136 2136
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2137 2137
 			foreach ($alldata as $number) {
2138
-				$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'])));
2138
+				$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'])));
2139 2139
 			}
2140 2140
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2141 2141
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2142 2142
 			foreach ($alldata as $number) {
2143
-				$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'])));
2143
+				$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'])));
2144 2144
 			}
2145 2145
 			if ($globalDebug) echo 'Airports data...'."\n";
2146 2146
 			if ($globalDebug) echo '...Departure'."\n";
@@ -2185,7 +2185,7 @@  discard block
 block discarded – undo
2185 2185
 			}
2186 2186
 			$alldata = $pall;
2187 2187
 			foreach ($alldata as $number) {
2188
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
2188
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
2189 2189
 			}
2190 2190
 			echo '...Arrival'."\n";
2191 2191
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -2226,7 +2226,7 @@  discard block
 block discarded – undo
2226 2226
 			}
2227 2227
 			$alldata = $pall;
2228 2228
 			foreach ($alldata as $number) {
2229
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
2229
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
2230 2230
 			}
2231 2231
 
2232 2232
 			echo 'Flights data...'."\n";
@@ -2234,28 +2234,28 @@  discard block
 block discarded – undo
2234 2234
 			echo '-> countAllDatesLastMonth...'."\n";
2235 2235
 			$alldata = $Spotter->countAllDatesLastMonth($filter_last_month);
2236 2236
 			foreach ($alldata as $number) {
2237
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
2237
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
2238 2238
 			}
2239 2239
 			echo '-> countAllDates...'."\n";
2240 2240
 			$previousdata = $this->countAllDates();
2241 2241
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
2242 2242
 			$this->deleteStatFlight('date');
2243
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month));
2243
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month));
2244 2244
 			$values = array();
2245 2245
 			foreach ($alldata as $cnt) {
2246 2246
 				$values[] = $cnt['date_count'];
2247 2247
 			}
2248
-			array_multisort($values,SORT_DESC,$alldata);
2249
-			array_splice($alldata,11);
2248
+			array_multisort($values, SORT_DESC, $alldata);
2249
+			array_splice($alldata, 11);
2250 2250
 			foreach ($alldata as $number) {
2251
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
2251
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
2252 2252
 			}
2253 2253
 			
2254 2254
 			$this->deleteStatFlight('hour');
2255 2255
 			echo '-> countAllHours...'."\n";
2256
-			$alldata = $Spotter->countAllHours('hour',$filter_last_month);
2256
+			$alldata = $Spotter->countAllHours('hour', $filter_last_month);
2257 2257
 			foreach ($alldata as $number) {
2258
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
2258
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
2259 2259
 			}
2260 2260
 
2261 2261
 			// Count by airlines
@@ -2264,42 +2264,42 @@  discard block
 block discarded – undo
2264 2264
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2265 2265
 				$SpotterArchive = new SpotterArchive();
2266 2266
 				//$Spotter = new Spotter($this->db);
2267
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2267
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
2268 2268
 				//$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2269 2269
 				foreach ($alldata as $number) {
2270
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2270
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
2271 2271
 				}
2272 2272
 			}
2273 2273
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2274 2274
 			$Spotter = new Spotter($this->db);
2275
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2275
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
2276 2276
 			foreach ($alldata as $number) {
2277
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2277
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
2278 2278
 			}
2279 2279
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2280
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2280
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
2281 2281
 			foreach ($alldata as $number) {
2282
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2282
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
2283 2283
 			}
2284 2284
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2285
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2285
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
2286 2286
 			foreach ($alldata as $number) {
2287
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2287
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2288 2288
 			}
2289 2289
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2290
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2290
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
2291 2291
 			foreach ($alldata as $number) {
2292
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2292
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
2293 2293
 			}
2294 2294
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2295
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2295
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
2296 2296
 			foreach ($alldata as $number) {
2297
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2297
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
2298 2298
 			}
2299 2299
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2300
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2300
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
2301 2301
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2302
-			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2302
+			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
2303 2303
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2304 2304
 			//$alldata = array();
2305 2305
 			foreach ($dall as $value) {
@@ -2319,12 +2319,12 @@  discard block
 block discarded – undo
2319 2319
 			}
2320 2320
 			$alldata = $pall;
2321 2321
 			foreach ($alldata as $number) {
2322
-				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);
2322
+				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);
2323 2323
 			}
2324 2324
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2325
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2325
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
2326 2326
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2327
-			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2327
+			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
2328 2328
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2329 2329
 			//$alldata = array();
2330 2330
 			foreach ($dall as $value) {
@@ -2344,7 +2344,7 @@  discard block
 block discarded – undo
2344 2344
 			}
2345 2345
 			$alldata = $pall;
2346 2346
 			foreach ($alldata as $number) {
2347
-				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);
2347
+				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);
2348 2348
 			}
2349 2349
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2350 2350
 			$Spotter = new Spotter($this->db);
@@ -2352,27 +2352,27 @@  discard block
 block discarded – undo
2352 2352
 			$lastyear = false;
2353 2353
 			foreach ($alldata as $number) {
2354 2354
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2355
-				$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']);
2355
+				$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']);
2356 2356
 			}
2357 2357
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2358 2358
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2359 2359
 			foreach ($alldata as $number) {
2360
-				$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']);
2360
+				$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']);
2361 2361
 			}
2362 2362
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2363 2363
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2364 2364
 			foreach ($alldata as $number) {
2365
-				$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']);
2365
+				$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']);
2366 2366
 			}
2367 2367
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2368 2368
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2369 2369
 			foreach ($alldata as $number) {
2370
-				$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']);
2370
+				$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']);
2371 2371
 			}
2372 2372
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2373 2373
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2374 2374
 			foreach ($alldata as $number) {
2375
-				$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']);
2375
+				$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']);
2376 2376
 			}
2377 2377
 			if ($globalDebug) echo '...Departure'."\n";
2378 2378
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -2395,7 +2395,7 @@  discard block
 block discarded – undo
2395 2395
 			}
2396 2396
 			$alldata = $pall;
2397 2397
 			foreach ($alldata as $number) {
2398
-				$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']);
2398
+				$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']);
2399 2399
 			}
2400 2400
 			if ($globalDebug) echo '...Arrival'."\n";
2401 2401
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -2418,32 +2418,32 @@  discard block
 block discarded – undo
2418 2418
 			}
2419 2419
 			$alldata = $pall;
2420 2420
 			foreach ($alldata as $number) {
2421
-				$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']);
2421
+				$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']);
2422 2422
 			}
2423 2423
 
2424 2424
 			if ($globalDebug) echo 'Flights data...'."\n";
2425 2425
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2426 2426
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2427 2427
 			foreach ($alldata as $number) {
2428
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2428
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
2429 2429
 			}
2430 2430
 			if ($globalDebug) echo '-> countAllDates...'."\n";
2431 2431
 			//$previousdata = $this->countAllDatesByAirlines();
2432
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2432
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month));
2433 2433
 			$values = array();
2434 2434
 			foreach ($alldata as $cnt) {
2435 2435
 				$values[] = $cnt['date_count'];
2436 2436
 			}
2437
-			array_multisort($values,SORT_DESC,$alldata);
2438
-			array_splice($alldata,11);
2437
+			array_multisort($values, SORT_DESC, $alldata);
2438
+			array_splice($alldata, 11);
2439 2439
 			foreach ($alldata as $number) {
2440
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2440
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
2441 2441
 			}
2442 2442
 			
2443 2443
 			if ($globalDebug) echo '-> countAllHours...'."\n";
2444
-			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2444
+			$alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month);
2445 2445
 			foreach ($alldata as $number) {
2446
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2446
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
2447 2447
 			}
2448 2448
 
2449 2449
 			// Stats by filters
@@ -2466,7 +2466,7 @@  discard block
 block discarded – undo
2466 2466
 						$last_update_day = date('Y').'-01-01 00:00:00';
2467 2467
 					}
2468 2468
 				}
2469
-				if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
2469
+				if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
2470 2470
 					$last_update_day = date('Y').'-01-01 00:00:00';
2471 2471
 					$reset = true;
2472 2472
 				}
@@ -2475,32 +2475,32 @@  discard block
 block discarded – undo
2475 2475
 				// Count by filter
2476 2476
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2477 2477
 				$Spotter = new Spotter($this->db);
2478
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2478
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
2479 2479
 				foreach ($alldata as $number) {
2480
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2480
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
2481 2481
 				}
2482
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2482
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
2483 2483
 				foreach ($alldata as $number) {
2484
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2484
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
2485 2485
 				}
2486
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2486
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
2487 2487
 				foreach ($alldata as $number) {
2488
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2488
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
2489 2489
 				}
2490
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2490
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
2491 2491
 				foreach ($alldata as $number) {
2492
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2492
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
2493 2493
 				}
2494
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2494
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
2495 2495
 				foreach ($alldata as $number) {
2496
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2496
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
2497 2497
 				}
2498
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2498
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
2499 2499
 				foreach ($alldata as $number) {
2500
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2500
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
2501 2501
 				}
2502
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2503
-				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2502
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
2503
+				$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
2504 2504
 				$alldata = array();
2505 2505
 				foreach ($pall as $value) {
2506 2506
 					$icao = $value['airport_departure_icao'];
@@ -2516,12 +2516,12 @@  discard block
 block discarded – undo
2516 2516
 				foreach ($alldata as $key => $row) {
2517 2517
 					$count[$key] = $row['airport_departure_icao_count'];
2518 2518
 				}
2519
-				array_multisort($count,SORT_DESC,$alldata);
2519
+				array_multisort($count, SORT_DESC, $alldata);
2520 2520
 				foreach ($alldata as $number) {
2521
-					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);
2521
+					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);
2522 2522
 				}
2523
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2524
-				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2523
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
2524
+				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
2525 2525
 				$alldata = array();
2526 2526
 				foreach ($pall as $value) {
2527 2527
 					$icao = $value['airport_arrival_icao'];
@@ -2537,40 +2537,40 @@  discard block
 block discarded – undo
2537 2537
 				foreach ($alldata as $key => $row) {
2538 2538
 					$count[$key] = $row['airport_arrival_icao_count'];
2539 2539
 				}
2540
-				array_multisort($count,SORT_DESC,$alldata);
2540
+				array_multisort($count, SORT_DESC, $alldata);
2541 2541
 				foreach ($alldata as $number) {
2542
-					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);
2542
+					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);
2543 2543
 				}
2544 2544
 				$Spotter = new Spotter($this->db);
2545 2545
 				$alldata = $Spotter->countAllMonths($filter);
2546 2546
 				$lastyear = false;
2547 2547
 				foreach ($alldata as $number) {
2548 2548
 					if ($number['year_name'] != date('Y')) $lastyear = true;
2549
-					$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);
2549
+					$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);
2550 2550
 				}
2551 2551
 				$alldata = $Spotter->countAllMonthsOwners($filter);
2552 2552
 				foreach ($alldata as $number) {
2553
-					$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);
2553
+					$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);
2554 2554
 				}
2555 2555
 				$alldata = $Spotter->countAllMonthsPilots($filter);
2556 2556
 				foreach ($alldata as $number) {
2557
-					$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);
2557
+					$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);
2558 2558
 				}
2559 2559
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
2560 2560
 				foreach ($alldata as $number) {
2561
-					$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);
2561
+					$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);
2562 2562
 				}
2563 2563
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
2564 2564
 				foreach ($alldata as $number) {
2565
-					$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);
2565
+					$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);
2566 2566
 				}
2567 2567
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2568 2568
 				foreach ($alldata as $number) {
2569
-					$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);
2569
+					$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);
2570 2570
 				}
2571 2571
 				echo '...Departure'."\n";
2572
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
2573
-				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2572
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
2573
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
2574 2574
 				foreach ($dall as $value) {
2575 2575
 					$icao = $value['departure_airport_icao'];
2576 2576
 					$ddate = $value['date'];
@@ -2588,11 +2588,11 @@  discard block
 block discarded – undo
2588 2588
 				}
2589 2589
 				$alldata = $pall;
2590 2590
 				foreach ($alldata as $number) {
2591
-					$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);
2591
+					$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);
2592 2592
 				}
2593 2593
 				echo '...Arrival'."\n";
2594
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2595
-				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2594
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
2595
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
2596 2596
 				foreach ($dall as $value) {
2597 2597
 					$icao = $value['arrival_airport_icao'];
2598 2598
 					$ddate = $value['date'];
@@ -2610,39 +2610,39 @@  discard block
 block discarded – undo
2610 2610
 				}
2611 2611
 				$alldata = $pall;
2612 2612
 				foreach ($alldata as $number) {
2613
-					$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);
2613
+					$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);
2614 2614
 				}
2615 2615
 				echo 'Flights data...'."\n";
2616 2616
 				echo '-> countAllDatesLastMonth...'."\n";
2617 2617
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
2618 2618
 				foreach ($alldata as $number) {
2619
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
2619
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
2620 2620
 				}
2621 2621
 				echo '-> countAllDates...'."\n";
2622
-				$previousdata = $this->countAllDates('',$filter_name);
2623
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
2622
+				$previousdata = $this->countAllDates('', $filter_name);
2623
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
2624 2624
 				$values = array();
2625 2625
 				foreach ($alldata as $cnt) {
2626 2626
 					$values[] = $cnt['date_count'];
2627 2627
 				}
2628
-				array_multisort($values,SORT_DESC,$alldata);
2629
-				array_splice($alldata,11);
2628
+				array_multisort($values, SORT_DESC, $alldata);
2629
+				array_splice($alldata, 11);
2630 2630
 				foreach ($alldata as $number) {
2631
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
2631
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
2632 2632
 				}
2633 2633
 				
2634 2634
 				echo '-> countAllHours...'."\n";
2635
-				$alldata = $Spotter->countAllHours('hour',$filter);
2635
+				$alldata = $Spotter->countAllHours('hour', $filter);
2636 2636
 				foreach ($alldata as $number) {
2637
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
2637
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
2638 2638
 				}
2639 2639
 				echo 'Insert last stats update date...'."\n";
2640 2640
 				date_default_timezone_set('UTC');
2641
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
2641
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
2642 2642
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
2643
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
2643
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
2644 2644
 						$this->deleteOldStats($filter_name);
2645
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
2645
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2646 2646
 					}
2647 2647
 				}
2648 2648
 			}
@@ -2653,16 +2653,16 @@  discard block
 block discarded – undo
2653 2653
 				// SUM all previous month to put as year
2654 2654
 				$previous_year = date('Y');
2655 2655
 				$previous_year--;
2656
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2657
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2658
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2659
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2656
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2657
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2658
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2659
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2660 2660
 				$allairlines = $this->getAllAirlineNames();
2661 2661
 				foreach ($allairlines as $data) {
2662
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2663
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2664
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2665
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2662
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2663
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2664
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2665
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2666 2666
 				}
2667 2667
 				
2668 2668
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2671,7 +2671,7 @@  discard block
 block discarded – undo
2671 2671
 						try {
2672 2672
 							$sth = $this->db->prepare($query);
2673 2673
 							$sth->execute();
2674
-						} catch(PDOException $e) {
2674
+						} catch (PDOException $e) {
2675 2675
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2676 2676
 						}
2677 2677
 					}
@@ -2680,15 +2680,15 @@  discard block
 block discarded – undo
2680 2680
 					try {
2681 2681
 						$sth = $this->db->prepare($query);
2682 2682
 						$sth->execute();
2683
-					} catch(PDOException $e) {
2683
+					} catch (PDOException $e) {
2684 2684
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2685 2685
 					}
2686 2686
 				}
2687 2687
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2688 2688
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2689
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2689
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2690 2690
 						$this->deleteOldStats();
2691
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2691
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2692 2692
 						$lastyearupdate = true;
2693 2693
 					}
2694 2694
 				}
@@ -2710,7 +2710,7 @@  discard block
 block discarded – undo
2710 2710
 					try {
2711 2711
 						$sth = $this->db->prepare($query);
2712 2712
 						$sth->execute();
2713
-					} catch(PDOException $e) {
2713
+					} catch (PDOException $e) {
2714 2714
 						return "error : ".$e->getMessage();
2715 2715
 					}
2716 2716
 				}
@@ -2724,14 +2724,14 @@  discard block
 block discarded – undo
2724 2724
 				try {
2725 2725
 					$sth = $this->db->prepare($query);
2726 2726
 					$sth->execute();
2727
-				} catch(PDOException $e) {
2727
+				} catch (PDOException $e) {
2728 2728
 					return "error : ".$e->getMessage();
2729 2729
 				}
2730 2730
 			}
2731 2731
 			if (!isset($lastyearupdate)) {
2732 2732
 				echo 'Insert last stats update date...'."\n";
2733 2733
 				date_default_timezone_set('UTC');
2734
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2734
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2735 2735
 			}
2736 2736
 			if ($globalStatsResetYear) {
2737 2737
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +580 added lines, -204 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 	
14 14
 	public function __construct($dbc = null) {
15 15
 		global $globalFilterName;
16
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16
+		if (isset($globalFilterName)) {
17
+			$this->filter_name = $globalFilterName;
18
+		}
17 19
 		$Connection = new Connection($dbc);
18 20
 		$this->db = $Connection->db();
19 21
 	}
@@ -83,7 +85,9 @@  discard block
 block discarded – undo
83 85
 
84 86
 	public function getAllAirlineNames($filter_name = '') {
85 87
 		global $globalStatsFilters;
86
-		if ($filter_name == '') $filter_name = $this->filter_name;
88
+		if ($filter_name == '') {
89
+			$filter_name = $this->filter_name;
90
+		}
87 91
 		$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
88 92
 		 try {
89 93
 			$sth = $this->db->prepare($query);
@@ -103,7 +107,9 @@  discard block
 block discarded – undo
103 107
 		return $all;
104 108
 	}
105 109
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
106
-		if ($filter_name == '') $filter_name = $this->filter_name;
110
+		if ($filter_name == '') {
111
+			$filter_name = $this->filter_name;
112
+		}
107 113
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
108 114
 		try {
109 115
 			$sth = $this->db->prepare($query);
@@ -115,7 +121,9 @@  discard block
 block discarded – undo
115 121
 		return $all;
116 122
 	}
117 123
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
118
-		if ($filter_name == '') $filter_name = $this->filter_name;
124
+		if ($filter_name == '') {
125
+			$filter_name = $this->filter_name;
126
+		}
119 127
 		$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";
120 128
 		try {
121 129
 			$sth = $this->db->prepare($query);
@@ -127,7 +135,9 @@  discard block
 block discarded – undo
127 135
 		return $all;
128 136
 	}
129 137
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
130
-		if ($filter_name == '') $filter_name = $this->filter_name;
138
+		if ($filter_name == '') {
139
+			$filter_name = $this->filter_name;
140
+		}
131 141
 		$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";
132 142
 		try {
133 143
 			$sth = $this->db->prepare($query);
@@ -140,7 +150,9 @@  discard block
 block discarded – undo
140 150
 	}
141 151
 
142 152
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
143
-		if ($filter_name == '') $filter_name = $this->filter_name;
153
+		if ($filter_name == '') {
154
+			$filter_name = $this->filter_name;
155
+		}
144 156
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
145 157
 		try {
146 158
 			$sth = $this->db->prepare($query);
@@ -153,7 +165,9 @@  discard block
 block discarded – undo
153 165
 	}
154 166
 
155 167
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
156
-		if ($filter_name == '') $filter_name = $this->filter_name;
168
+		if ($filter_name == '') {
169
+			$filter_name = $this->filter_name;
170
+		}
157 171
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
158 172
 		try {
159 173
 			$sth = $this->db->prepare($query);
@@ -168,7 +182,9 @@  discard block
 block discarded – undo
168 182
 
169 183
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
170 184
 		global $globalStatsFilters;
171
-		if ($filter_name == '') $filter_name = $this->filter_name;
185
+		if ($filter_name == '') {
186
+			$filter_name = $this->filter_name;
187
+		}
172 188
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
173 189
 			$Spotter = new Spotter($this->db);
174 190
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -177,8 +193,11 @@  discard block
 block discarded – undo
177 193
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
178 194
 			}
179 195
 			if ($year == '' && $month == '') {
180
-				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 stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
181
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
196
+				if ($limit) {
197
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
198
+				} else {
199
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
200
+				}
182 201
 				try {
183 202
 					$sth = $this->db->prepare($query);
184 203
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -186,11 +205,16 @@  discard block
 block discarded – undo
186 205
 					echo "error : ".$e->getMessage();
187 206
 				}
188 207
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
189
-			} else $all = array();
208
+			} else {
209
+				$all = array();
210
+			}
190 211
 		} else {
191 212
 			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 stats_airline = :stats_airline 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 stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
213
+				if ($limit) {
214
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
215
+				} else {
216
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
217
+				}
194 218
 				try {
195 219
 					$sth = $this->db->prepare($query);
196 220
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -198,7 +222,9 @@  discard block
 block discarded – undo
198 222
 					echo "error : ".$e->getMessage();
199 223
 				}
200 224
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
201
-			} else $all = array();
225
+			} else {
226
+				$all = array();
227
+			}
202 228
 		}
203 229
 		if (empty($all)) {
204 230
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -217,10 +243,15 @@  discard block
 block discarded – undo
217 243
 	}
218 244
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
219 245
 		global $globalStatsFilters;
220
-		if ($filter_name == '') $filter_name = $this->filter_name;
246
+		if ($filter_name == '') {
247
+			$filter_name = $this->filter_name;
248
+		}
221 249
 		if ($year == '' && $month == '') {
222
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
223
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
250
+			if ($limit) {
251
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
252
+			} else {
253
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
254
+			}
224 255
 			try {
225 256
 				$sth = $this->db->prepare($query);
226 257
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -228,7 +259,9 @@  discard block
 block discarded – undo
228 259
 				echo "error : ".$e->getMessage();
229 260
 			}
230 261
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
231
-		} else $all = array();
262
+		} else {
263
+			$all = array();
264
+		}
232 265
 		if (empty($all)) {
233 266
 			$Spotter = new Spotter($this->db);
234 267
 			$filters = array();
@@ -243,7 +276,9 @@  discard block
 block discarded – undo
243 276
 	}
244 277
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
245 278
 		global $globalStatsFilters;
246
-		if ($filter_name == '') $filter_name = $this->filter_name;
279
+		if ($filter_name == '') {
280
+			$filter_name = $this->filter_name;
281
+		}
247 282
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
248 283
 			$Spotter = new Spotter($this->db);
249 284
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -252,8 +287,11 @@  discard block
 block discarded – undo
252 287
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
253 288
 			}
254 289
 			if ($year == '' && $month == '') {
255
-				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";
256
-				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";
290
+				if ($limit) {
291
+					$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";
292
+				} else {
293
+					$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
+				}
257 295
 				try {
258 296
 					$sth = $this->db->prepare($query);
259 297
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -261,11 +299,16 @@  discard block
 block discarded – undo
261 299
 					echo "error : ".$e->getMessage();
262 300
 				}
263 301
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
-			} else $all = array();
302
+			} else {
303
+				$all = array();
304
+			}
265 305
 		} else {
266 306
 			if ($year == '' && $month == '') {
267
-				if ($limit) $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 LIMIT 10 OFFSET 0";
268
-				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";
307
+				if ($limit) {
308
+					$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 LIMIT 10 OFFSET 0";
309
+				} else {
310
+					$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";
311
+				}
269 312
 				try {
270 313
 					$sth = $this->db->prepare($query);
271 314
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -273,7 +316,9 @@  discard block
 block discarded – undo
273 316
 					echo "error : ".$e->getMessage();
274 317
 				}
275 318
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
276
-			} else $all = array();
319
+			} else {
320
+				$all = array();
321
+			}
277 322
 		}
278 323
 		if (empty($all)) {
279 324
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -293,7 +338,9 @@  discard block
 block discarded – undo
293 338
 
294 339
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
295 340
 		global $globalStatsFilters;
296
-		if ($filter_name == '') $filter_name = $this->filter_name;
341
+		if ($filter_name == '') {
342
+			$filter_name = $this->filter_name;
343
+		}
297 344
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
298 345
 			$Spotter = new Spotter($this->db);
299 346
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -302,8 +349,11 @@  discard block
 block discarded – undo
302 349
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
303 350
 			}
304 351
 			if ($year == '' && $month == '') {
305
-				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";
306
-				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";
352
+				if ($limit) {
353
+					$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";
354
+				} else {
355
+					$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";
356
+				}
307 357
 				try {
308 358
 					$sth = $this->db->prepare($query);
309 359
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -311,11 +361,16 @@  discard block
 block discarded – undo
311 361
 					echo "error : ".$e->getMessage();
312 362
 				}
313 363
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
314
-			} else $all = array();
364
+			} else {
365
+				$all = array();
366
+			}
315 367
 		} else {
316 368
 			if ($year == '' && $month == '') {
317
-				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 = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
318
-				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";
369
+				if ($limit) {
370
+					$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 = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
371
+				} else {
372
+					$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";
373
+				}
319 374
 				try {
320 375
 					$sth = $this->db->prepare($query);
321 376
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -323,7 +378,9 @@  discard block
 block discarded – undo
323 378
 					echo "error : ".$e->getMessage();
324 379
 				}
325 380
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
326
-			} else $all = array();
381
+			} else {
382
+				$all = array();
383
+			}
327 384
 		}
328 385
 		if (empty($all)) {
329 386
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -342,7 +399,9 @@  discard block
 block discarded – undo
342 399
 	}
343 400
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
344 401
 		global $globalStatsFilters;
345
-		if ($filter_name == '') $filter_name = $this->filter_name;
402
+		if ($filter_name == '') {
403
+			$filter_name = $this->filter_name;
404
+		}
346 405
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
347 406
 			$Spotter = new Spotter($this->db);
348 407
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -350,12 +409,18 @@  discard block
 block discarded – undo
350 409
 			foreach ($airlines as $airline) {
351 410
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
352 411
 			}
353
-			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";
354
-			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";
412
+			if ($limit) {
413
+				$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";
414
+			} else {
415
+				$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";
416
+			}
355 417
 			$query_values = array(':filter_name' => $filter_name);
356 418
 		} else {
357
-			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";
358
-			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";
419
+			if ($limit) {
420
+				$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";
421
+			} else {
422
+				$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";
423
+			}
359 424
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
360 425
 		}
361 426
 		try {
@@ -383,17 +448,29 @@  discard block
 block discarded – undo
383 448
 
384 449
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
385 450
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
386
-		if ($filter_name == '') $filter_name = $this->filter_name;
451
+		if ($filter_name == '') {
452
+			$filter_name = $this->filter_name;
453
+		}
387 454
 		if ($year == '' && $month == '') {
388
-			if ($globalVATSIM) $forsource = 'vatsim';
389
-			if ($globalIVAO) $forsource = 'ivao';
455
+			if ($globalVATSIM) {
456
+				$forsource = 'vatsim';
457
+			}
458
+			if ($globalIVAO) {
459
+				$forsource = 'ivao';
460
+			}
390 461
 			if (isset($forsource)) {
391
-				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";
392
-				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";
462
+				if ($limit) {
463
+					$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";
464
+				} else {
465
+					$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";
466
+				}
393 467
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
394 468
 			} else {
395
-				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";
396
-				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";
469
+				if ($limit) {
470
+					$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";
471
+				} else {
472
+					$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";
473
+				}
397 474
 				$query_values = array(':filter_name' => $filter_name);
398 475
 			}
399 476
 			try {
@@ -403,7 +480,9 @@  discard block
 block discarded – undo
403 480
 				echo "error : ".$e->getMessage();
404 481
 			}
405 482
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
406
-		} else $all = array();
483
+		} else {
484
+			$all = array();
485
+		}
407 486
                 if (empty($all)) {
408 487
 	                $Spotter = new Spotter($this->db);
409 488
             		$filters = array();
@@ -418,7 +497,9 @@  discard block
 block discarded – undo
418 497
 	}
419 498
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
420 499
 		global $globalStatsFilters;
421
-		if ($filter_name == '') $filter_name = $this->filter_name;
500
+		if ($filter_name == '') {
501
+			$filter_name = $this->filter_name;
502
+		}
422 503
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
423 504
 			$Spotter = new Spotter($this->db);
424 505
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -427,8 +508,11 @@  discard block
 block discarded – undo
427 508
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
428 509
 			}
429 510
 			if ($year == '' && $month == '') {
430
-				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";
431
-				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";
511
+				if ($limit) {
512
+					$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";
513
+				} else {
514
+					$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";
515
+				}
432 516
 				try {
433 517
 					$sth = $this->db->prepare($query);
434 518
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -436,11 +520,16 @@  discard block
 block discarded – undo
436 520
 					echo "error : ".$e->getMessage();
437 521
 				}
438 522
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
439
-			} else $all = array();
523
+			} else {
524
+				$all = array();
525
+			}
440 526
 		} else {
441 527
 			if ($year == '' && $month == '') {
442
-				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 = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
443
-				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";
528
+				if ($limit) {
529
+					$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 = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
530
+				} else {
531
+					$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";
532
+				}
444 533
 				try {
445 534
 					$sth = $this->db->prepare($query);
446 535
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -448,7 +537,9 @@  discard block
 block discarded – undo
448 537
 					echo "error : ".$e->getMessage();
449 538
 				}
450 539
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
451
-			} else $all = array();
540
+			} else {
541
+				$all = array();
542
+			}
452 543
 		}
453 544
 		if (empty($all)) {
454 545
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -467,7 +558,9 @@  discard block
 block discarded – undo
467 558
 	}
468 559
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
469 560
 		global $globalStatsFilters;
470
-		if ($filter_name == '') $filter_name = $this->filter_name;
561
+		if ($filter_name == '') {
562
+			$filter_name = $this->filter_name;
563
+		}
471 564
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
472 565
 			$Spotter = new Spotter($this->db);
473 566
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -476,8 +569,11 @@  discard block
 block discarded – undo
476 569
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
477 570
 			}
478 571
 			if ($year == '' && $month == '') {
479
-				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";
480
-				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";
572
+				if ($limit) {
573
+					$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";
574
+				} else {
575
+					$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";
576
+				}
481 577
 				 try {
482 578
 					$sth = $this->db->prepare($query);
483 579
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -485,11 +581,16 @@  discard block
 block discarded – undo
485 581
 					echo "error : ".$e->getMessage();
486 582
 				}
487 583
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
488
-			} else $all = array();
584
+			} else {
585
+				$all = array();
586
+			}
489 587
 		} else {
490 588
 			if ($year == '' && $month == '') {
491
-				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 = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
492
-				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";
589
+				if ($limit) {
590
+					$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 LIMIT 10 OFFSET 0";
591
+				} else {
592
+					$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";
593
+				}
493 594
 				 try {
494 595
 					$sth = $this->db->prepare($query);
495 596
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -497,7 +598,9 @@  discard block
 block discarded – undo
497 598
 					echo "error : ".$e->getMessage();
498 599
 				}
499 600
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
500
-			} else $all = array();
601
+			} else {
602
+				$all = array();
603
+			}
501 604
 		}
502 605
 		if (empty($all)) {
503 606
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -516,7 +619,9 @@  discard block
 block discarded – undo
516 619
 	}
517 620
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
518 621
 		$Connection = new Connection();
519
-		if ($filter_name == '') $filter_name = $this->filter_name;
622
+		if ($filter_name == '') {
623
+			$filter_name = $this->filter_name;
624
+		}
520 625
 		if ($Connection->tableExists('countries')) {
521 626
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
522 627
 				$Spotter = new Spotter($this->db);
@@ -526,8 +631,11 @@  discard block
 block discarded – undo
526 631
 					foreach ($airlines as $airline) {
527 632
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
528 633
 					}
529
-					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";
530
-					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";
634
+					if ($limit) {
635
+						$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";
636
+					} else {
637
+						$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";
638
+					}
531 639
 					 try {
532 640
 						$sth = $this->db->prepare($query);
533 641
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -536,11 +644,16 @@  discard block
 block discarded – undo
536 644
 					}
537 645
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
538 646
 					return $all;
539
-				} else return array();
647
+				} else {
648
+					return array();
649
+				}
540 650
 			} else {
541 651
 				if ($year == '' && $month == '') {
542
-					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 = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
543
-					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";
652
+					if ($limit) {
653
+						$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 LIMIT 20 OFFSET 0";
654
+					} else {
655
+						$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";
656
+					}
544 657
 					 try {
545 658
 						$sth = $this->db->prepare($query);
546 659
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -549,7 +662,9 @@  discard block
 block discarded – undo
549 662
 					}
550 663
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
551 664
 					return $all;
552
-				} else return array();
665
+				} else {
666
+					return array();
667
+				}
553 668
 			}
554 669
 		} else {
555 670
 			/*
@@ -563,10 +678,15 @@  discard block
 block discarded – undo
563 678
 	}
564 679
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
565 680
 		global $globalStatsFilters;
566
-		if ($filter_name == '') $filter_name = $this->filter_name;
681
+		if ($filter_name == '') {
682
+			$filter_name = $this->filter_name;
683
+		}
567 684
 		if ($year == '' && $month == '') {
568
-			if ($limit) $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 LIMIT 10 OFFSET 0";
569
-			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";
685
+			if ($limit) {
686
+				$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 LIMIT 10 OFFSET 0";
687
+			} else {
688
+				$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";
689
+			}
570 690
 			try {
571 691
 				$sth = $this->db->prepare($query);
572 692
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -574,7 +694,9 @@  discard block
 block discarded – undo
574 694
 				echo "error : ".$e->getMessage();
575 695
 			}
576 696
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
577
-		} else $all = array();
697
+		} else {
698
+			$all = array();
699
+		}
578 700
 		if (empty($all)) {
579 701
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
580 702
 			if ($filter_name != '') {
@@ -589,7 +711,9 @@  discard block
 block discarded – undo
589 711
 
590 712
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
591 713
 		global $globalStatsFilters;
592
-		if ($filter_name == '') $filter_name = $this->filter_name;
714
+		if ($filter_name == '') {
715
+			$filter_name = $this->filter_name;
716
+		}
593 717
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
594 718
 			$Spotter = new Spotter($this->db);
595 719
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -598,8 +722,11 @@  discard block
 block discarded – undo
598 722
 				foreach ($airlines as $airline) {
599 723
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
600 724
 				}
601
-				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";
602
-				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";
725
+				if ($limit) {
726
+					$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";
727
+				} else {
728
+					$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";
729
+				}
603 730
 				try {
604 731
 					$sth = $this->db->prepare($query);
605 732
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -607,11 +734,16 @@  discard block
 block discarded – undo
607 734
 					echo "error : ".$e->getMessage();
608 735
 				}
609 736
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
610
-			} else $all = array();
737
+			} else {
738
+				$all = array();
739
+			}
611 740
 		} else {
612 741
 			if ($year == '' && $month == '') {
613
-				if ($limit) $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 LIMIT 10 OFFSET 0";
614
-				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";
742
+				if ($limit) {
743
+					$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 LIMIT 10 OFFSET 0";
744
+				} else {
745
+					$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";
746
+				}
615 747
 				try {
616 748
 					$sth = $this->db->prepare($query);
617 749
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -619,7 +751,9 @@  discard block
 block discarded – undo
619 751
 					echo "error : ".$e->getMessage();
620 752
 				}
621 753
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
622
-			} else $all = array();
754
+			} else {
755
+				$all = array();
756
+			}
623 757
 		}
624 758
 		if (empty($all)) {
625 759
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -638,7 +772,9 @@  discard block
 block discarded – undo
638 772
 	}
639 773
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
640 774
 		global $globalStatsFilters;
641
-		if ($filter_name == '') $filter_name = $this->filter_name;
775
+		if ($filter_name == '') {
776
+			$filter_name = $this->filter_name;
777
+		}
642 778
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
643 779
 			$Spotter = new Spotter($this->db);
644 780
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -647,8 +783,11 @@  discard block
 block discarded – undo
647 783
 				foreach ($airlines as $airline) {
648 784
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
649 785
 				}
650
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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";
651
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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";
786
+				if ($limit) {
787
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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";
788
+				} else {
789
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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";
790
+				}
652 791
 				try {
653 792
 					$sth = $this->db->prepare($query);
654 793
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -656,11 +795,16 @@  discard block
 block discarded – undo
656 795
 					echo "error : ".$e->getMessage();
657 796
 				}
658 797
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
659
-			} else $all = array();
798
+			} else {
799
+				$all = array();
800
+			}
660 801
 		} else {
661 802
 			if ($year == '' && $month == '') {
662
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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 LIMIT 10 OFFSET 0";
663
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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";
803
+				if ($limit) {
804
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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 LIMIT 10 OFFSET 0";
805
+				} else {
806
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,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";
807
+				}
664 808
 				try {
665 809
 					$sth = $this->db->prepare($query);
666 810
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -668,7 +812,9 @@  discard block
 block discarded – undo
668 812
 					echo "error : ".$e->getMessage();
669 813
 				}
670 814
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
671
-			} else $all = array();
815
+			} else {
816
+				$all = array();
817
+			}
672 818
 		}
673 819
 		if (empty($all)) {
674 820
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -693,7 +839,9 @@  discard block
 block discarded – undo
693 839
 				$icao = $value['airport_departure_icao'];
694 840
 				if (isset($all[$icao])) {
695 841
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
696
-				} else $all[$icao] = $value;
842
+				} else {
843
+					$all[$icao] = $value;
844
+				}
697 845
 			}
698 846
 			$count = array();
699 847
 			foreach ($all as $key => $row) {
@@ -705,7 +853,9 @@  discard block
 block discarded – undo
705 853
 	}
706 854
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
707 855
 		global $globalStatsFilters;
708
-		if ($filter_name == '') $filter_name = $this->filter_name;
856
+		if ($filter_name == '') {
857
+			$filter_name = $this->filter_name;
858
+		}
709 859
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
710 860
 			$Spotter = new Spotter($this->db);
711 861
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -714,8 +864,11 @@  discard block
 block discarded – undo
714 864
 				foreach ($airlines as $airline) {
715 865
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
716 866
 				}
717
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
718
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
867
+				if ($limit) {
868
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
869
+				} else {
870
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
871
+				}
719 872
 				try {
720 873
 					$sth = $this->db->prepare($query);
721 874
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -723,11 +876,16 @@  discard block
 block discarded – undo
723 876
 					echo "error : ".$e->getMessage();
724 877
 				}
725 878
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
726
-			} else $all = array();
879
+			} else {
880
+				$all = array();
881
+			}
727 882
 		} else {
728 883
 			if ($year == '' && $month == '') {
729
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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 LIMIT 10 OFFSET 0";
730
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
884
+				if ($limit) {
885
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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 LIMIT 10 OFFSET 0";
886
+				} else {
887
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
888
+				}
731 889
 				try {
732 890
 					$sth = $this->db->prepare($query);
733 891
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -735,7 +893,9 @@  discard block
 block discarded – undo
735 893
 					echo "error : ".$e->getMessage();
736 894
 				}
737 895
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
738
-			} else $all = array();
896
+			} else {
897
+				$all = array();
898
+			}
739 899
 		}
740 900
 		if (empty($all)) {
741 901
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -760,7 +920,9 @@  discard block
 block discarded – undo
760 920
 				$icao = $value['airport_arrival_icao'];
761 921
 				if (isset($all[$icao])) {
762 922
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
763
-				} else $all[$icao] = $value;
923
+				} else {
924
+					$all[$icao] = $value;
925
+				}
764 926
 			}
765 927
 			$count = array();
766 928
 			foreach ($all as $key => $row) {
@@ -772,7 +934,9 @@  discard block
 block discarded – undo
772 934
 	}
773 935
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
774 936
 		global $globalDBdriver, $globalStatsFilters;
775
-		if ($filter_name == '') $filter_name = $this->filter_name;
937
+		if ($filter_name == '') {
938
+			$filter_name = $this->filter_name;
939
+		}
776 940
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
777 941
 			$Spotter = new Spotter($this->db);
778 942
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -781,20 +945,32 @@  discard block
 block discarded – undo
781 945
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
782 946
 			}
783 947
 			if ($globalDBdriver == 'mysql') {
784
-				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";
785
-				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";
948
+				if ($limit) {
949
+					$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";
950
+				} else {
951
+					$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";
952
+				}
786 953
 			} else {
787
-				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";
788
-				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";
954
+				if ($limit) {
955
+					$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";
956
+				} else {
957
+					$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";
958
+				}
789 959
 			}
790 960
 			$query_data = array(':filter_name' => $filter_name);
791 961
 		} else {
792 962
 			if ($globalDBdriver == 'mysql') {
793
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
794
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(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";
963
+				if ($limit) {
964
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
965
+				} else {
966
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(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";
967
+				}
795 968
 			} else {
796
-				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";
797
-				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";
969
+				if ($limit) {
970
+					$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";
971
+				} else {
972
+					$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";
973
+				}
798 974
 			}
799 975
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
800 976
 		}
@@ -822,7 +998,9 @@  discard block
 block discarded – undo
822 998
 	
823 999
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
824 1000
 		global $globalStatsFilters;
825
-		if ($filter_name == '') $filter_name = $this->filter_name;
1001
+		if ($filter_name == '') {
1002
+			$filter_name = $this->filter_name;
1003
+		}
826 1004
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
827 1005
 			$Spotter = new Spotter($this->db);
828 1006
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -859,7 +1037,9 @@  discard block
 block discarded – undo
859 1037
 	}
860 1038
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
861 1039
 		global $globalDBdriver, $globalStatsFilters;
862
-		if ($filter_name == '') $filter_name = $this->filter_name;
1040
+		if ($filter_name == '') {
1041
+			$filter_name = $this->filter_name;
1042
+		}
863 1043
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
864 1044
 			$Spotter = new Spotter($this->db);
865 1045
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -904,7 +1084,9 @@  discard block
 block discarded – undo
904 1084
 	}
905 1085
 	public function countAllDates($stats_airline = '',$filter_name = '') {
906 1086
 		global $globalStatsFilters;
907
-		if ($filter_name == '') $filter_name = $this->filter_name;
1087
+		if ($filter_name == '') {
1088
+			$filter_name = $this->filter_name;
1089
+		}
908 1090
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
909 1091
 			$Spotter = new Spotter($this->db);
910 1092
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -941,7 +1123,9 @@  discard block
 block discarded – undo
941 1123
 	}
942 1124
 	public function countAllDatesByAirlines($filter_name = '') {
943 1125
 		global $globalStatsFilters;
944
-		if ($filter_name == '') $filter_name = $this->filter_name;
1126
+		if ($filter_name == '') {
1127
+			$filter_name = $this->filter_name;
1128
+		}
945 1129
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
946 1130
 		$query_data = array('filter_name' => $filter_name);
947 1131
 		try {
@@ -963,7 +1147,9 @@  discard block
 block discarded – undo
963 1147
 	}
964 1148
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
965 1149
 		global $globalStatsFilters, $globalDBdriver;
966
-		if ($filter_name == '') $filter_name = $this->filter_name;
1150
+		if ($filter_name == '') {
1151
+			$filter_name = $this->filter_name;
1152
+		}
967 1153
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
968 1154
 			$Spotter = new Spotter($this->db);
969 1155
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1048,7 +1234,9 @@  discard block
 block discarded – undo
1048 1234
 	}
1049 1235
 	public function countAllMilitaryMonths($filter_name = '') {
1050 1236
 		global $globalStatsFilters;
1051
-		if ($filter_name == '') $filter_name = $this->filter_name;
1237
+		if ($filter_name == '') {
1238
+			$filter_name = $this->filter_name;
1239
+		}
1052 1240
 		$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
1053 1241
 		try {
1054 1242
 			$sth = $this->db->prepare($query);
@@ -1069,7 +1257,9 @@  discard block
 block discarded – undo
1069 1257
 	}
1070 1258
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1071 1259
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1072
-		if ($filter_name == '') $filter_name = $this->filter_name;
1260
+		if ($filter_name == '') {
1261
+			$filter_name = $this->filter_name;
1262
+		}
1073 1263
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1074 1264
 			$Spotter = new Spotter($this->db);
1075 1265
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1077,12 +1267,18 @@  discard block
 block discarded – undo
1077 1267
 			foreach ($airlines as $airline) {
1078 1268
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1079 1269
 			}
1080
-			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";
1081
-			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";
1270
+			if ($limit) {
1271
+				$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";
1272
+			} else {
1273
+				$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";
1274
+			}
1082 1275
 			$query_data = array(':filter_name' => $filter_name);
1083 1276
 		} else {
1084
-			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";
1085
-			else $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";
1277
+			if ($limit) {
1278
+				$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";
1279
+			} else {
1280
+				$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";
1281
+			}
1086 1282
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1087 1283
 		}
1088 1284
 		if ($orderby == 'hour') {
@@ -1092,7 +1288,9 @@  discard block
 block discarded – undo
1092 1288
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1093 1289
 			}
1094 1290
 		}
1095
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1291
+		if ($orderby == 'count') {
1292
+			$query .= " ORDER BY hour_count DESC";
1293
+		}
1096 1294
 		try {
1097 1295
 			$sth = $this->db->prepare($query);
1098 1296
 			$sth->execute($query_data);
@@ -1116,8 +1314,12 @@  discard block
 block discarded – undo
1116 1314
 	}
1117 1315
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1118 1316
 		global $globalStatsFilters;
1119
-		if ($filter_name == '') $filter_name = $this->filter_name;
1120
-		if ($year == '') $year = date('Y');
1317
+		if ($filter_name == '') {
1318
+			$filter_name = $this->filter_name;
1319
+		}
1320
+		if ($year == '') {
1321
+			$year = date('Y');
1322
+		}
1121 1323
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1122 1324
 		if (empty($all)) {
1123 1325
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1136,8 +1338,12 @@  discard block
 block discarded – undo
1136 1338
 	}
1137 1339
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1138 1340
 		global $globalStatsFilters;
1139
-		if ($filter_name == '') $filter_name = $this->filter_name;
1140
-		if ($year == '') $year = date('Y');
1341
+		if ($filter_name == '') {
1342
+			$filter_name = $this->filter_name;
1343
+		}
1344
+		if ($year == '') {
1345
+			$year = date('Y');
1346
+		}
1141 1347
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1142 1348
 		if (empty($all)) {
1143 1349
 			$filters = array();
@@ -1153,8 +1359,12 @@  discard block
 block discarded – undo
1153 1359
 	}
1154 1360
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1155 1361
 		global $globalStatsFilters;
1156
-		if ($filter_name == '') $filter_name = $this->filter_name;
1157
-		if ($year == '') $year = date('Y');
1362
+		if ($filter_name == '') {
1363
+			$filter_name = $this->filter_name;
1364
+		}
1365
+		if ($year == '') {
1366
+			$year = date('Y');
1367
+		}
1158 1368
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1159 1369
 		if (empty($all)) {
1160 1370
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1173,7 +1383,9 @@  discard block
 block discarded – undo
1173 1383
 	}
1174 1384
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1175 1385
 		global $globalStatsFilters;
1176
-		if ($filter_name == '') $filter_name = $this->filter_name;
1386
+		if ($filter_name == '') {
1387
+			$filter_name = $this->filter_name;
1388
+		}
1177 1389
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1178 1390
 			$Spotter = new Spotter($this->db);
1179 1391
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1191,7 +1403,9 @@  discard block
 block discarded – undo
1191 1403
 				}
1192 1404
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1193 1405
 				$all = $result[0]['nb'];
1194
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1406
+			} else {
1407
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1408
+			}
1195 1409
 		} else {
1196 1410
 			if ($year == '' && $month == '') {
1197 1411
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1203,7 +1417,9 @@  discard block
 block discarded – undo
1203 1417
 				}
1204 1418
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1205 1419
 				$all = $result[0]['nb'];
1206
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1420
+			} else {
1421
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1422
+			}
1207 1423
 		}
1208 1424
 		if (empty($all)) {
1209 1425
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1222,7 +1438,9 @@  discard block
 block discarded – undo
1222 1438
 	}
1223 1439
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1224 1440
 		global $globalStatsFilters;
1225
-		if ($filter_name == '') $filter_name = $this->filter_name;
1441
+		if ($filter_name == '') {
1442
+			$filter_name = $this->filter_name;
1443
+		}
1226 1444
 		if ($year == '' && $month == '') {
1227 1445
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1228 1446
 			try {
@@ -1233,7 +1451,9 @@  discard block
 block discarded – undo
1233 1451
 			}
1234 1452
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1235 1453
 			$all = $result[0]['nb_airline'];
1236
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1454
+		} else {
1455
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1456
+		}
1237 1457
 		if (empty($all)) {
1238 1458
 			$filters = array();
1239 1459
 			$filters = array('year' => $year,'month' => $month);
@@ -1248,7 +1468,9 @@  discard block
 block discarded – undo
1248 1468
 	}
1249 1469
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1250 1470
 		global $globalStatsFilters;
1251
-		if ($filter_name == '') $filter_name = $this->filter_name;
1471
+		if ($filter_name == '') {
1472
+			$filter_name = $this->filter_name;
1473
+		}
1252 1474
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1253 1475
 			$Spotter = new Spotter($this->db);
1254 1476
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1303,7 +1525,9 @@  discard block
 block discarded – undo
1303 1525
 	}
1304 1526
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1305 1527
 		global $globalStatsFilters;
1306
-		if ($filter_name == '') $filter_name = $this->filter_name;
1528
+		if ($filter_name == '') {
1529
+			$filter_name = $this->filter_name;
1530
+		}
1307 1531
 		//if ($year == '') $year = date('Y');
1308 1532
 		if ($year == '' && $month == '') {
1309 1533
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1332,7 +1556,9 @@  discard block
 block discarded – undo
1332 1556
 	}
1333 1557
 
1334 1558
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1335
-		if ($filter_name == '') $filter_name = $this->filter_name;
1559
+		if ($filter_name == '') {
1560
+			$filter_name = $this->filter_name;
1561
+		}
1336 1562
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1337 1563
 			$Spotter = new Spotter($this->db);
1338 1564
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1356,7 +1582,9 @@  discard block
 block discarded – undo
1356 1582
 		return $all;
1357 1583
 	}
1358 1584
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1359
-		if ($filter_name == '') $filter_name = $this->filter_name;
1585
+		if ($filter_name == '') {
1586
+			$filter_name = $this->filter_name;
1587
+		}
1360 1588
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1361 1589
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1362 1590
 		try {
@@ -1369,7 +1597,9 @@  discard block
 block discarded – undo
1369 1597
 		return $all;
1370 1598
 	}
1371 1599
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1372
-		if ($filter_name == '') $filter_name = $this->filter_name;
1600
+		if ($filter_name == '') {
1601
+			$filter_name = $this->filter_name;
1602
+		}
1373 1603
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1374 1604
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1375 1605
 		try {
@@ -1380,7 +1610,9 @@  discard block
 block discarded – undo
1380 1610
 		}
1381 1611
 	}
1382 1612
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1383
-		if ($filter_name == '') $filter_name = $this->filter_name;
1613
+		if ($filter_name == '') {
1614
+			$filter_name = $this->filter_name;
1615
+		}
1384 1616
 		global $globalArchiveMonths, $globalDBdriver;
1385 1617
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1386 1618
 			$Spotter = new Spotter($this->db);
@@ -1436,7 +1668,9 @@  discard block
 block discarded – undo
1436 1668
 	}
1437 1669
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1438 1670
 		global $globalArchiveMonths, $globalDBdriver;
1439
-		if ($filter_name == '') $filter_name = $this->filter_name;
1671
+		if ($filter_name == '') {
1672
+			$filter_name = $this->filter_name;
1673
+		}
1440 1674
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1441 1675
 			$Spotter = new Spotter($this->db);
1442 1676
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1469,7 +1703,9 @@  discard block
 block discarded – undo
1469 1703
 	}
1470 1704
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1471 1705
 		global $globalArchiveMonths, $globalDBdriver;
1472
-		if ($filter_name == '') $filter_name = $this->filter_name;
1706
+		if ($filter_name == '') {
1707
+			$filter_name = $this->filter_name;
1708
+		}
1473 1709
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1474 1710
 			$Spotter = new Spotter($this->db);
1475 1711
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1500,7 +1736,9 @@  discard block
 block discarded – undo
1500 1736
 	}
1501 1737
 	public function getStatsAirlineTotal($filter_name = '') {
1502 1738
 		global $globalArchiveMonths, $globalDBdriver;
1503
-		if ($filter_name == '') $filter_name = $this->filter_name;
1739
+		if ($filter_name == '') {
1740
+			$filter_name = $this->filter_name;
1741
+		}
1504 1742
 		if ($globalDBdriver == 'mysql') {
1505 1743
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1506 1744
 		} else {
@@ -1517,7 +1755,9 @@  discard block
 block discarded – undo
1517 1755
 	}
1518 1756
 	public function getStatsOwnerTotal($filter_name = '') {
1519 1757
 		global $globalArchiveMonths, $globalDBdriver;
1520
-		if ($filter_name == '') $filter_name = $this->filter_name;
1758
+		if ($filter_name == '') {
1759
+			$filter_name = $this->filter_name;
1760
+		}
1521 1761
 		if ($globalDBdriver == 'mysql') {
1522 1762
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1523 1763
 		} else {
@@ -1534,7 +1774,9 @@  discard block
 block discarded – undo
1534 1774
 	}
1535 1775
 	public function getStatsOwner($owner_name,$filter_name = '') {
1536 1776
 		global $globalArchiveMonths, $globalDBdriver;
1537
-		if ($filter_name == '') $filter_name = $this->filter_name;
1777
+		if ($filter_name == '') {
1778
+			$filter_name = $this->filter_name;
1779
+		}
1538 1780
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1539 1781
 		try {
1540 1782
 			$sth = $this->db->prepare($query);
@@ -1543,12 +1785,17 @@  discard block
 block discarded – undo
1543 1785
 			echo "error : ".$e->getMessage();
1544 1786
 		}
1545 1787
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1546
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1547
-		else return 0;
1788
+		if (isset($all[0]['cnt'])) {
1789
+			return $all[0]['cnt'];
1790
+		} else {
1791
+			return 0;
1792
+		}
1548 1793
 	}
1549 1794
 	public function getStatsPilotTotal($filter_name = '') {
1550 1795
 		global $globalArchiveMonths, $globalDBdriver;
1551
-		if ($filter_name == '') $filter_name = $this->filter_name;
1796
+		if ($filter_name == '') {
1797
+			$filter_name = $this->filter_name;
1798
+		}
1552 1799
 		if ($globalDBdriver == 'mysql') {
1553 1800
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1554 1801
 		} else {
@@ -1565,7 +1812,9 @@  discard block
 block discarded – undo
1565 1812
 	}
1566 1813
 	public function getStatsPilot($pilot,$filter_name = '') {
1567 1814
 		global $globalArchiveMonths, $globalDBdriver;
1568
-		if ($filter_name == '') $filter_name = $this->filter_name;
1815
+		if ($filter_name == '') {
1816
+			$filter_name = $this->filter_name;
1817
+		}
1569 1818
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1570 1819
 		try {
1571 1820
 			$sth = $this->db->prepare($query);
@@ -1574,13 +1823,18 @@  discard block
 block discarded – undo
1574 1823
 			echo "error : ".$e->getMessage();
1575 1824
 		}
1576 1825
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1577
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1578
-		else return 0;
1826
+		if (isset($all[0]['cnt'])) {
1827
+			return $all[0]['cnt'];
1828
+		} else {
1829
+			return 0;
1830
+		}
1579 1831
 	}
1580 1832
 
1581 1833
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1582 1834
 		global $globalDBdriver;
1583
-		if ($filter_name == '') $filter_name = $this->filter_name;
1835
+		if ($filter_name == '') {
1836
+			$filter_name = $this->filter_name;
1837
+		}
1584 1838
 		if ($globalDBdriver == 'mysql') {
1585 1839
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
1586 1840
 		} else {
@@ -1596,7 +1850,9 @@  discard block
 block discarded – undo
1596 1850
 	}
1597 1851
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1598 1852
 		global $globalDBdriver;
1599
-		if ($filter_name == '') $filter_name = $this->filter_name;
1853
+		if ($filter_name == '') {
1854
+			$filter_name = $this->filter_name;
1855
+		}
1600 1856
 		if ($globalDBdriver == 'mysql') {
1601 1857
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1602 1858
 		} else {
@@ -1982,10 +2238,14 @@  discard block
 block discarded – undo
1982 2238
 		$Connection = new Connection();
1983 2239
 		date_default_timezone_set('UTC');
1984 2240
 		$last_update = $this->getLastStatsUpdate('last_update_stats');
1985
-			if ($globalDebug) echo 'Update stats !'."\n";
2241
+			if ($globalDebug) {
2242
+				echo 'Update stats !'."\n";
2243
+			}
1986 2244
 			if (isset($last_update[0]['value'])) {
1987 2245
 				$last_update_day = $last_update[0]['value'];
1988
-			} else $last_update_day = '2012-12-12 12:12:12';
2246
+			} else {
2247
+				$last_update_day = '2012-12-12 12:12:12';
2248
+			}
1989 2249
 			$reset = false;
1990 2250
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
1991 2251
 			if ($globalStatsResetYear) {
@@ -1994,43 +2254,63 @@  discard block
 block discarded – undo
1994 2254
 			}
1995 2255
 			$Spotter = new Spotter($this->db);
1996 2256
 
1997
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2257
+			if ($globalDebug) {
2258
+				echo 'Count all aircraft types...'."\n";
2259
+			}
1998 2260
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1999 2261
 			foreach ($alldata as $number) {
2000 2262
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2001 2263
 			}
2002
-			if ($globalDebug) echo 'Count all airlines...'."\n";
2264
+			if ($globalDebug) {
2265
+				echo 'Count all airlines...'."\n";
2266
+			}
2003 2267
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2004 2268
 			foreach ($alldata as $number) {
2005 2269
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2006 2270
 			}
2007
-			if ($globalDebug) echo 'Count all registrations...'."\n";
2271
+			if ($globalDebug) {
2272
+				echo 'Count all registrations...'."\n";
2273
+			}
2008 2274
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2009 2275
 			foreach ($alldata as $number) {
2010 2276
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2011 2277
 			}
2012
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
2278
+			if ($globalDebug) {
2279
+				echo 'Count all callsigns...'."\n";
2280
+			}
2013 2281
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2014 2282
 			foreach ($alldata as $number) {
2015 2283
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2016 2284
 			}
2017
-			if ($globalDebug) echo 'Count all owners...'."\n";
2285
+			if ($globalDebug) {
2286
+				echo 'Count all owners...'."\n";
2287
+			}
2018 2288
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2019 2289
 			foreach ($alldata as $number) {
2020 2290
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2021 2291
 			}
2022
-			if ($globalDebug) echo 'Count all pilots...'."\n";
2292
+			if ($globalDebug) {
2293
+				echo 'Count all pilots...'."\n";
2294
+			}
2023 2295
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2024 2296
 			foreach ($alldata as $number) {
2025
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2297
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
2298
+					$number['pilot_id'] = $number['pilot_name'];
2299
+				}
2026 2300
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2027 2301
 			}
2028 2302
 			
2029
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
2303
+			if ($globalDebug) {
2304
+				echo 'Count all departure airports...'."\n";
2305
+			}
2030 2306
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2031
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2307
+			if ($globalDebug) {
2308
+				echo 'Count all detected departure airports...'."\n";
2309
+			}
2032 2310
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2033
-			if ($globalDebug) echo 'Order departure airports...'."\n";
2311
+			if ($globalDebug) {
2312
+				echo 'Order departure airports...'."\n";
2313
+			}
2034 2314
 			$alldata = array();
2035 2315
 			foreach ($pall as $value) {
2036 2316
 				$icao = $value['airport_departure_icao'];
@@ -2040,7 +2320,9 @@  discard block
 block discarded – undo
2040 2320
 				$icao = $value['airport_departure_icao'];
2041 2321
 				if (isset($alldata[$icao])) {
2042 2322
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2043
-				} else $alldata[$icao] = $value;
2323
+				} else {
2324
+					$alldata[$icao] = $value;
2325
+				}
2044 2326
 			}
2045 2327
 			$count = array();
2046 2328
 			foreach ($alldata as $key => $row) {
@@ -2050,11 +2332,17 @@  discard block
 block discarded – undo
2050 2332
 			foreach ($alldata as $number) {
2051 2333
 				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);
2052 2334
 			}
2053
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2335
+			if ($globalDebug) {
2336
+				echo 'Count all arrival airports...'."\n";
2337
+			}
2054 2338
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2055
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2339
+			if ($globalDebug) {
2340
+				echo 'Count all detected arrival airports...'."\n";
2341
+			}
2056 2342
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2057
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
2343
+			if ($globalDebug) {
2344
+				echo 'Order arrival airports...'."\n";
2345
+			}
2058 2346
 			$alldata = array();
2059 2347
 			foreach ($pall as $value) {
2060 2348
 				$icao = $value['airport_arrival_icao'];
@@ -2064,7 +2352,9 @@  discard block
 block discarded – undo
2064 2352
 				$icao = $value['airport_arrival_icao'];
2065 2353
 				if (isset($alldata[$icao])) {
2066 2354
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2067
-				} else $alldata[$icao] = $value;
2355
+				} else {
2356
+					$alldata[$icao] = $value;
2357
+				}
2068 2358
 			}
2069 2359
 			$count = array();
2070 2360
 			foreach ($alldata as $key => $row) {
@@ -2075,7 +2365,9 @@  discard block
 block discarded – undo
2075 2365
 				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);
2076 2366
 			}
2077 2367
 			if ($Connection->tableExists('countries')) {
2078
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2368
+				if ($globalDebug) {
2369
+					echo 'Count all flights by countries...'."\n";
2370
+				}
2079 2371
 				//$SpotterArchive = new SpotterArchive();
2080 2372
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2081 2373
 				$Spotter = new Spotter($this->db);
@@ -2086,7 +2378,9 @@  discard block
 block discarded – undo
2086 2378
 			}
2087 2379
 			
2088 2380
 			if (isset($globalAccidents) && $globalAccidents) {
2089
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
2381
+				if ($globalDebug) {
2382
+					echo 'Count fatalities stats...'."\n";
2383
+				}
2090 2384
 				$Accident = new Accident();
2091 2385
 				$this->deleteStatsByType('fatalities_byyear');
2092 2386
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2102,48 +2396,68 @@  discard block
 block discarded – undo
2102 2396
 
2103 2397
 			// Add by month using getstat if month finish...
2104 2398
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2105
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
2399
+			if ($globalDebug) {
2400
+				echo 'Count all flights by months...'."\n";
2401
+			}
2106 2402
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2107 2403
 			$filter_last_month = array('since_date' => $last_month);
2108 2404
 			$Spotter = new Spotter($this->db);
2109 2405
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2110 2406
 			$lastyear = false;
2111 2407
 			foreach ($alldata as $number) {
2112
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2408
+				if ($number['year_name'] != date('Y')) {
2409
+					$lastyear = true;
2410
+				}
2113 2411
 				$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'])));
2114 2412
 			}
2115
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2413
+			if ($globalDebug) {
2414
+				echo 'Count all military flights by months...'."\n";
2415
+			}
2116 2416
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2117 2417
 			foreach ($alldata as $number) {
2118 2418
 				$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'])));
2119 2419
 			}
2120
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
2420
+			if ($globalDebug) {
2421
+				echo 'Count all owners by months...'."\n";
2422
+			}
2121 2423
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2122 2424
 			foreach ($alldata as $number) {
2123 2425
 				$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'])));
2124 2426
 			}
2125
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2427
+			if ($globalDebug) {
2428
+				echo 'Count all pilots by months...'."\n";
2429
+			}
2126 2430
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2127 2431
 			foreach ($alldata as $number) {
2128 2432
 				$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'])));
2129 2433
 			}
2130
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2434
+			if ($globalDebug) {
2435
+				echo 'Count all airlines by months...'."\n";
2436
+			}
2131 2437
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2132 2438
 			foreach ($alldata as $number) {
2133 2439
 				$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'])));
2134 2440
 			}
2135
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2441
+			if ($globalDebug) {
2442
+				echo 'Count all aircrafts by months...'."\n";
2443
+			}
2136 2444
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2137 2445
 			foreach ($alldata as $number) {
2138 2446
 				$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'])));
2139 2447
 			}
2140
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2448
+			if ($globalDebug) {
2449
+				echo 'Count all real arrivals by months...'."\n";
2450
+			}
2141 2451
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2142 2452
 			foreach ($alldata as $number) {
2143 2453
 				$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'])));
2144 2454
 			}
2145
-			if ($globalDebug) echo 'Airports data...'."\n";
2146
-			if ($globalDebug) echo '...Departure'."\n";
2455
+			if ($globalDebug) {
2456
+				echo 'Airports data...'."\n";
2457
+			}
2458
+			if ($globalDebug) {
2459
+				echo '...Departure'."\n";
2460
+			}
2147 2461
 			$this->deleteStatAirport('daily');
2148 2462
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2149 2463
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2261,7 +2575,9 @@  discard block
 block discarded – undo
2261 2575
 			// Count by airlines
2262 2576
 			echo '--- Stats by airlines ---'."\n";
2263 2577
 			if ($Connection->tableExists('countries')) {
2264
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2578
+				if ($globalDebug) {
2579
+					echo 'Count all flights by countries by airlines...'."\n";
2580
+				}
2265 2581
 				$SpotterArchive = new SpotterArchive();
2266 2582
 				//$Spotter = new Spotter($this->db);
2267 2583
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2270,37 +2586,53 @@  discard block
 block discarded – undo
2270 2586
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2271 2587
 				}
2272 2588
 			}
2273
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2589
+			if ($globalDebug) {
2590
+				echo 'Count all aircraft types by airlines...'."\n";
2591
+			}
2274 2592
 			$Spotter = new Spotter($this->db);
2275 2593
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2276 2594
 			foreach ($alldata as $number) {
2277 2595
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2278 2596
 			}
2279
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2597
+			if ($globalDebug) {
2598
+				echo 'Count all aircraft registrations by airlines...'."\n";
2599
+			}
2280 2600
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2281 2601
 			foreach ($alldata as $number) {
2282 2602
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2283 2603
 			}
2284
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2604
+			if ($globalDebug) {
2605
+				echo 'Count all callsigns by airlines...'."\n";
2606
+			}
2285 2607
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2286 2608
 			foreach ($alldata as $number) {
2287 2609
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2288 2610
 			}
2289
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2611
+			if ($globalDebug) {
2612
+				echo 'Count all owners by airlines...'."\n";
2613
+			}
2290 2614
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2291 2615
 			foreach ($alldata as $number) {
2292 2616
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2293 2617
 			}
2294
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2618
+			if ($globalDebug) {
2619
+				echo 'Count all pilots by airlines...'."\n";
2620
+			}
2295 2621
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2296 2622
 			foreach ($alldata as $number) {
2297 2623
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2298 2624
 			}
2299
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2625
+			if ($globalDebug) {
2626
+				echo 'Count all departure airports by airlines...'."\n";
2627
+			}
2300 2628
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2301
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2629
+			if ($globalDebug) {
2630
+				echo 'Count all detected departure airports by airlines...'."\n";
2631
+			}
2302 2632
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2303
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2633
+			if ($globalDebug) {
2634
+				echo 'Order detected departure airports by airlines...'."\n";
2635
+			}
2304 2636
 			//$alldata = array();
2305 2637
 			foreach ($dall as $value) {
2306 2638
 				$icao = $value['airport_departure_icao'];
@@ -2321,11 +2653,17 @@  discard block
 block discarded – undo
2321 2653
 			foreach ($alldata as $number) {
2322 2654
 				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);
2323 2655
 			}
2324
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2656
+			if ($globalDebug) {
2657
+				echo 'Count all arrival airports by airlines...'."\n";
2658
+			}
2325 2659
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2326
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2660
+			if ($globalDebug) {
2661
+				echo 'Count all detected arrival airports by airlines...'."\n";
2662
+			}
2327 2663
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2328
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2664
+			if ($globalDebug) {
2665
+				echo 'Order arrival airports by airlines...'."\n";
2666
+			}
2329 2667
 			//$alldata = array();
2330 2668
 			foreach ($dall as $value) {
2331 2669
 				$icao = $value['airport_arrival_icao'];
@@ -2344,37 +2682,53 @@  discard block
 block discarded – undo
2344 2682
 			}
2345 2683
 			$alldata = $pall;
2346 2684
 			foreach ($alldata as $number) {
2347
-				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);
2685
+				if ($number['airline_icao'] != '') {
2686
+					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);
2687
+				}
2688
+			}
2689
+			if ($globalDebug) {
2690
+				echo 'Count all flights by months by airlines...'."\n";
2348 2691
 			}
2349
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2350 2692
 			$Spotter = new Spotter($this->db);
2351 2693
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
2352 2694
 			$lastyear = false;
2353 2695
 			foreach ($alldata as $number) {
2354
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2696
+				if ($number['year_name'] != date('Y')) {
2697
+					$lastyear = true;
2698
+				}
2355 2699
 				$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']);
2356 2700
 			}
2357
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2701
+			if ($globalDebug) {
2702
+				echo 'Count all owners by months by airlines...'."\n";
2703
+			}
2358 2704
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2359 2705
 			foreach ($alldata as $number) {
2360 2706
 				$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']);
2361 2707
 			}
2362
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2708
+			if ($globalDebug) {
2709
+				echo 'Count all pilots by months by airlines...'."\n";
2710
+			}
2363 2711
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2364 2712
 			foreach ($alldata as $number) {
2365 2713
 				$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']);
2366 2714
 			}
2367
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2715
+			if ($globalDebug) {
2716
+				echo 'Count all aircrafts by months by airlines...'."\n";
2717
+			}
2368 2718
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2369 2719
 			foreach ($alldata as $number) {
2370 2720
 				$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']);
2371 2721
 			}
2372
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2722
+			if ($globalDebug) {
2723
+				echo 'Count all real arrivals by months by airlines...'."\n";
2724
+			}
2373 2725
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2374 2726
 			foreach ($alldata as $number) {
2375 2727
 				$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']);
2376 2728
 			}
2377
-			if ($globalDebug) echo '...Departure'."\n";
2729
+			if ($globalDebug) {
2730
+				echo '...Departure'."\n";
2731
+			}
2378 2732
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
2379 2733
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
2380 2734
 			foreach ($dall as $value) {
@@ -2397,7 +2751,9 @@  discard block
 block discarded – undo
2397 2751
 			foreach ($alldata as $number) {
2398 2752
 				$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']);
2399 2753
 			}
2400
-			if ($globalDebug) echo '...Arrival'."\n";
2754
+			if ($globalDebug) {
2755
+				echo '...Arrival'."\n";
2756
+			}
2401 2757
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
2402 2758
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
2403 2759
 			foreach ($dall as $value) {
@@ -2421,13 +2777,19 @@  discard block
 block discarded – undo
2421 2777
 				$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']);
2422 2778
 			}
2423 2779
 
2424
-			if ($globalDebug) echo 'Flights data...'."\n";
2425
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2780
+			if ($globalDebug) {
2781
+				echo 'Flights data...'."\n";
2782
+			}
2783
+			if ($globalDebug) {
2784
+				echo '-> countAllDatesLastMonth...'."\n";
2785
+			}
2426 2786
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2427 2787
 			foreach ($alldata as $number) {
2428 2788
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2429 2789
 			}
2430
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2790
+			if ($globalDebug) {
2791
+				echo '-> countAllDates...'."\n";
2792
+			}
2431 2793
 			//$previousdata = $this->countAllDatesByAirlines();
2432 2794
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2433 2795
 			$values = array();
@@ -2440,21 +2802,27 @@  discard block
 block discarded – undo
2440 2802
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2441 2803
 			}
2442 2804
 			
2443
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2805
+			if ($globalDebug) {
2806
+				echo '-> countAllHours...'."\n";
2807
+			}
2444 2808
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2445 2809
 			foreach ($alldata as $number) {
2446 2810
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2447 2811
 			}
2448 2812
 
2449 2813
 			// Stats by filters
2450
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2814
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2815
+				$globalStatsFilters = array();
2816
+			}
2451 2817
 			foreach ($globalStatsFilters as $name => $filter) {
2452 2818
 				//$filter_name = $filter['name'];
2453 2819
 				$filter_name = $name;
2454 2820
 				$reset = false;
2455 2821
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
2456 2822
 				if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
2457
-					if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
2823
+					if ($globalDebug) {
2824
+						echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
2825
+					}
2458 2826
 					$this->deleteOldStats($filter_name);
2459 2827
 					unset($last_update);
2460 2828
 				}
@@ -2473,7 +2841,9 @@  discard block
 block discarded – undo
2473 2841
 				
2474 2842
 
2475 2843
 				// Count by filter
2476
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2844
+				if ($globalDebug) {
2845
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2846
+				}
2477 2847
 				$Spotter = new Spotter($this->db);
2478 2848
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2479 2849
 				foreach ($alldata as $number) {
@@ -2510,7 +2880,9 @@  discard block
 block discarded – undo
2510 2880
 					$icao = $value['airport_departure_icao'];
2511 2881
 					if (isset($alldata[$icao])) {
2512 2882
 						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2513
-					} else $alldata[$icao] = $value;
2883
+					} else {
2884
+						$alldata[$icao] = $value;
2885
+					}
2514 2886
 				}
2515 2887
 				$count = array();
2516 2888
 				foreach ($alldata as $key => $row) {
@@ -2531,7 +2903,9 @@  discard block
 block discarded – undo
2531 2903
 					$icao = $value['airport_arrival_icao'];
2532 2904
 					if (isset($alldata[$icao])) {
2533 2905
 						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2534
-					} else $alldata[$icao] = $value;
2906
+					} else {
2907
+						$alldata[$icao] = $value;
2908
+					}
2535 2909
 				}
2536 2910
 				$count = array();
2537 2911
 				foreach ($alldata as $key => $row) {
@@ -2545,7 +2919,9 @@  discard block
 block discarded – undo
2545 2919
 				$alldata = $Spotter->countAllMonths($filter);
2546 2920
 				$lastyear = false;
2547 2921
 				foreach ($alldata as $number) {
2548
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2922
+					if ($number['year_name'] != date('Y')) {
2923
+						$lastyear = true;
2924
+					}
2549 2925
 					$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);
2550 2926
 				}
2551 2927
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.