Completed
Push — master ( 84cf6c...e73982 )
by Yannick
05:49
created
require/class.Stats.php 4 patches
Doc Comments   +31 added lines patch added patch discarded remove patch
@@ -17,6 +17,10 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
+	/**
21
+	 * @param string $type
22
+	 * @param string $stats_date
23
+	 */
20 24
 	public function addLastStatsUpdate($type,$stats_date) {
21 25
                 $query = "DELETE FROM config WHERE name = :type;
22 26
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
@@ -827,6 +831,11 @@  discard block
 block discarded – undo
827 831
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
828 832
                 return $all;
829 833
         }
834
+
835
+	/**
836
+	 * @param string $type
837
+	 * @param string $year
838
+	 */
830 839
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
831 840
 		if ($filter_name == '') $filter_name = $this->filter_name;
832 841
     		global $globalArchiveMonths, $globalDBdriver;
@@ -943,6 +952,10 @@  discard block
 block discarded – undo
943 952
                 return $all[0]['total'];
944 953
         }
945 954
 
955
+	/**
956
+	 * @param string $type
957
+	 * @param string $stats_date
958
+	 */
946 959
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
947 960
 		global $globalDBdriver;
948 961
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -996,6 +1009,9 @@  discard block
 block discarded – undo
996 1009
         }
997 1010
         */
998 1011
 
1012
+	/**
1013
+	 * @param string $stats_type
1014
+	 */
999 1015
 	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1000 1016
 		global $globalDBdriver;
1001 1017
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
@@ -1039,6 +1055,9 @@  discard block
 block discarded – undo
1039 1055
 		return $all;
1040 1056
 	}
1041 1057
 
1058
+	/**
1059
+	 * @param string $stats_type
1060
+	 */
1042 1061
 	public function addStatSource($data,$source_name,$stats_type,$date) {
1043 1062
 		global $globalDBdriver;
1044 1063
 		if ($globalDBdriver == 'mysql') {
@@ -1054,6 +1073,10 @@  discard block
 block discarded – undo
1054 1073
                         return "error : ".$e->getMessage();
1055 1074
                 }
1056 1075
         }
1076
+
1077
+	/**
1078
+	 * @param string $type
1079
+	 */
1057 1080
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1058 1081
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1059 1082
                 $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
@@ -1320,6 +1343,10 @@  discard block
 block discarded – undo
1320 1343
                         return "error : ".$e->getMessage();
1321 1344
                 }
1322 1345
         }
1346
+
1347
+	/**
1348
+	 * @param string $type
1349
+	 */
1323 1350
 	public function deleteStatFlight($type) {
1324 1351
                 $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1325 1352
                 $query_values = array(':type' => $type);
@@ -1330,6 +1357,10 @@  discard block
 block discarded – undo
1330 1357
                         return "error : ".$e->getMessage();
1331 1358
                 }
1332 1359
         }
1360
+
1361
+	/**
1362
+	 * @param string $type
1363
+	 */
1333 1364
 	public function deleteStatAirport($type) {
1334 1365
                 $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1335 1366
                 $query_values = array(':type' => $type);
Please login to merge, or discard this patch.
Spacing   +342 added lines, -342 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
-	public function addLastStatsUpdate($type,$stats_date) {
20
+	public function addLastStatsUpdate($type, $stats_date) {
21 21
                 $query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
23
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
24 24
                  try {
25 25
                         $sth = $this->db->prepare($query);
26 26
                         $sth->execute($query_values);
27
-                } catch(PDOException $e) {
27
+                } catch (PDOException $e) {
28 28
                         return "error : ".$e->getMessage();
29 29
                 }
30 30
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                  try {
35 35
                         $sth = $this->db->prepare($query);
36 36
                         $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
37
+                } catch (PDOException $e) {
38 38
                         echo "error : ".$e->getMessage();
39 39
                 }
40 40
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                  try {
55 55
                         $sth = $this->db->prepare($query);
56 56
                         $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                  try {
65 65
                         $sth = $this->db->prepare($query);
66 66
                         $sth->execute();
67
-                } catch(PDOException $e) {
67
+                } catch (PDOException $e) {
68 68
                         return "error : ".$e->getMessage();
69 69
                 }
70 70
                 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                  try {
73 73
                         $sth = $this->db->prepare($query);
74 74
                         $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
75
+                } catch (PDOException $e) {
76 76
                         return "error : ".$e->getMessage();
77 77
                 }
78 78
         }
@@ -82,69 +82,69 @@  discard block
 block discarded – undo
82 82
                  try {
83 83
                         $sth = $this->db->prepare($query);
84 84
                         $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
85
+                } catch (PDOException $e) {
86 86
                         echo "error : ".$e->getMessage();
87 87
                 }
88 88
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89 89
                 return $all;
90 90
         }
91
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
91
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93 93
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 94
                  try {
95 95
                         $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
96
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
97
+                } catch (PDOException $e) {
98 98
                         echo "error : ".$e->getMessage();
99 99
                 }
100 100
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101 101
                 return $all;
102 102
         }
103
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
103
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105 105
                 $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";
106 106
                  try {
107 107
                         $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
108
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
109
+                } catch (PDOException $e) {
110 110
                         echo "error : ".$e->getMessage();
111 111
                 }
112 112
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113 113
                 return $all;
114 114
         }
115
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
115
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117 117
                 $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";
118 118
                  try {
119 119
                         $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
120
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
121
+                } catch (PDOException $e) {
122 122
                         echo "error : ".$e->getMessage();
123 123
                 }
124 124
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125 125
                 return $all;
126 126
         }
127 127
 
128
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
128
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130 130
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 131
                  try {
132 132
                         $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
133
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
134
+                } catch (PDOException $e) {
135 135
                         echo "error : ".$e->getMessage();
136 136
                 }
137 137
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138 138
                 return $all;
139 139
         }
140 140
 
141
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
141
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143 143
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144 144
                  try {
145 145
                         $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
146
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
147
+                } catch (PDOException $e) {
148 148
                         echo "error : ".$e->getMessage();
149 149
                 }
150 150
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         }
153 153
 
154 154
 
155
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
155
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
156 156
 		global $globalStatsFilters;
157 157
 		if ($filter_name == '') $filter_name = $this->filter_name;
158 158
 		if ($year == '' && $month == '') {
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 			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";
161 161
 			try {
162 162
 				$sth = $this->db->prepare($query);
163
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
164
-			} catch(PDOException $e) {
163
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
164
+			} catch (PDOException $e) {
165 165
 				echo "error : ".$e->getMessage();
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
                 if (empty($all)) {
170 170
             	    $filters = array('airlines' => array($stats_airline));
171 171
             	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
172
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
173 173
             	    }
174 174
             	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
175
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters, $year, $month);
176 176
                 }
177 177
                 return $all;
178 178
 	}
179
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
179
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
180 180
 		global $globalStatsFilters;
181 181
 		if ($filter_name == '') $filter_name = $this->filter_name;
182 182
 		if ($year == '' && $month == '') {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			try {
186 186
 				$sth = $this->db->prepare($query);
187 187
 				$sth->execute(array(':filter_name' => $filter_name));
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				echo "error : ".$e->getMessage();
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
             		$Spotter = new Spotter($this->db);
195 195
             		$filters = array();
196 196
             		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
197
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
199
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters, $year, $month);
200 200
                 }
201 201
                 return $all;
202 202
 	}
203
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
203
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
204 204
 		global $globalStatsFilters;
205 205
 		if ($filter_name == '') $filter_name = $this->filter_name;
206 206
 		if ($year == '' && $month == '') {
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			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";
209 209
 			try {
210 210
 				$sth = $this->db->prepare($query);
211
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
212
-			} catch(PDOException $e) {
211
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
212
+			} catch (PDOException $e) {
213 213
 				echo "error : ".$e->getMessage();
214 214
 			}
215 215
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 		if (empty($all)) {
218 218
 			$filters = array('airlines' => array($stats_airline));
219 219
 			if ($filter_name != '') {
220
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
220
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
221 221
 			}
222 222
 			$Spotter = new Spotter($this->db);
223
-			$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
223
+			$all = $Spotter->countAllAircraftManufacturers($filters, $year, $month);
224 224
 		}
225 225
 		return $all;
226 226
 	}
227 227
 
228
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
228
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
229 229
 		global $globalStatsFilters;
230 230
 		if ($filter_name == '') $filter_name = $this->filter_name;
231 231
 		if ($year == '' && $month == '') {
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
234 234
 			try {
235 235
 				$sth = $this->db->prepare($query);
236
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
237
-			} catch(PDOException $e) {
236
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
237
+			} catch (PDOException $e) {
238 238
 				echo "error : ".$e->getMessage();
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
                 if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
244 244
 			if ($filter_name != '') {
245
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Spotter = new Spotter($this->db);
248
-			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
248
+			$all = $Spotter->countAllArrivalCountries($limit, $filters, $year, $month);
249 249
                 }
250 250
                 return $all;
251 251
 	}
@@ -256,23 +256,23 @@  discard block
 block discarded – undo
256 256
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
257 257
                  try {
258 258
                         $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
259
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
260
+                } catch (PDOException $e) {
261 261
                         echo "error : ".$e->getMessage();
262 262
                 }
263 263
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264 264
                 if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270
-			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
270
+			$all = $Spotter->countAllDepartureCountries($filters, $year, $month);
271 271
                 }
272 272
                 return $all;
273 273
 	}
274 274
 
275
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
275
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
276 276
 		global $globalStatsFilters;
277 277
 		if ($filter_name == '') $filter_name = $this->filter_name;
278 278
 		if ($year == '' && $month == '') {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			try {
282 282
 				$sth = $this->db->prepare($query);
283 283
 				$sth->execute(array(':filter_name' => $filter_name));
284
-			} catch(PDOException $e) {
284
+			} catch (PDOException $e) {
285 285
 				echo "error : ".$e->getMessage();
286 286
 			}
287 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 	                $Spotter = new Spotter($this->db);
291 291
             		$filters = array();
292 292
             		if ($filter_name != '') {
293
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
293
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
294 294
 			}
295 295
 
296
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
296
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters, $year, $month);
297 297
                 }
298 298
                 return $all;
299 299
 	}
300
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
300
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
301 301
 		global $globalStatsFilters;
302 302
 		if ($filter_name == '') $filter_name = $this->filter_name;
303 303
 		if ($year == '' && $month == '') {
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 			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";
306 306
 			try {
307 307
 				$sth = $this->db->prepare($query);
308
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
309
-			} catch(PDOException $e) {
308
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
309
+			} catch (PDOException $e) {
310 310
 				echo "error : ".$e->getMessage();
311 311
 			}
312 312
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -314,14 +314,14 @@  discard block
 block discarded – undo
314 314
                 if (empty($all)) {
315 315
 			$filters = array('airlines' => array($stats_airline));
316 316
 			if ($filter_name != '') {
317
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
317
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
318 318
 			}
319 319
 	                $Spotter = new Spotter($this->db);
320
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
320
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters, $year, $month);
321 321
                 }
322 322
                 return $all;
323 323
 	}
324
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
324
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
325 325
 		global $globalStatsFilters;
326 326
 		if ($filter_name == '') $filter_name = $this->filter_name;
327 327
 		if ($year == '' && $month == '') {
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 			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";
330 330
 			 try {
331 331
 				$sth = $this->db->prepare($query);
332
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
333
-			} catch(PDOException $e) {
332
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
333
+			} catch (PDOException $e) {
334 334
 				echo "error : ".$e->getMessage();
335 335
 			}
336 336
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 		if (empty($all)) {
339 339
 			$filters = array('airlines' => array($stats_airline));
340 340
 			if ($filter_name != '') {
341
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
341
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
342 342
 			}
343 343
 			$Spotter = new Spotter($this->db);
344
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
344
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters, $year, $month);
345 345
 		}
346 346
 		return $all;
347 347
 	}
348
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
348
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
349 349
 		$Connection = new Connection();
350 350
 		if ($filter_name == '') $filter_name = $this->filter_name;
351 351
 		if ($Connection->tableExists('countries')) {
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 				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";
355 355
 				 try {
356 356
 					$sth = $this->db->prepare($query);
357
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
358
-				} catch(PDOException $e) {
357
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
358
+				} catch (PDOException $e) {
359 359
 					echo "error : ".$e->getMessage();
360 360
 				}
361 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 			return array();
372 372
 		}
373 373
 	}
374
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
374
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
375 375
 		global $globalStatsFilters;
376 376
 		if ($filter_name == '') $filter_name = $this->filter_name;
377 377
 		if ($year == '' && $month == '') {
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 			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";
380 380
 			try {
381 381
 				$sth = $this->db->prepare($query);
382
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
383
-			} catch(PDOException $e) {
382
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
383
+			} catch (PDOException $e) {
384 384
 				echo "error : ".$e->getMessage();
385 385
 			}
386 386
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -388,15 +388,15 @@  discard block
 block discarded – undo
388 388
 		if (empty($all)) {
389 389
 			$filters = array('airlines' => array($stats_airline));
390 390
 			if ($filter_name != '') {
391
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
391
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
392 392
 			}
393 393
 			$Spotter = new Spotter($this->db);
394
-			$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
394
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters, $year, $month);
395 395
 		}
396 396
 		return $all;
397 397
 	}
398 398
 
399
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
399
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
400 400
 		global $globalStatsFilters;
401 401
 		if ($filter_name == '') $filter_name = $this->filter_name;
402 402
 		if ($year == '' && $month == '') {
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 			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";
405 405
 			try {
406 406
 				$sth = $this->db->prepare($query);
407
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
408
-			} catch(PDOException $e) {
407
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
408
+			} catch (PDOException $e) {
409 409
 				echo "error : ".$e->getMessage();
410 410
 			}
411 411
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -413,14 +413,14 @@  discard block
 block discarded – undo
413 413
                 if (empty($all)) {
414 414
 			$filters = array('airlines' => array($stats_airline));
415 415
 			if ($filter_name != '') {
416
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
416
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
417 417
 			}
418 418
             		$Spotter = new Spotter($this->db);
419
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
419
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters, $year, $month);
420 420
                 }
421 421
                 return $all;
422 422
 	}
423
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
423
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
424 424
 		global $globalStatsFilters;
425 425
 		if ($filter_name == '') $filter_name = $this->filter_name;
426 426
 		if ($year == '' && $month == '') {
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 			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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
429 429
 			try {
430 430
 				$sth = $this->db->prepare($query);
431
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
432
-			} catch(PDOException $e) {
431
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
432
+			} catch (PDOException $e) {
433 433
 				echo "error : ".$e->getMessage();
434 434
 			}
435 435
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
                 if (empty($all)) {
438 438
 			$filters = array('airlines' => array($stats_airline));
439 439
             		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
440
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
441 441
 			}
442 442
             		$Spotter = new Spotter($this->db);
443
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
443
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters, $year, $month);
444
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters, $year, $month);
445 445
         		$all = array();
446 446
         		foreach ($pall as $value) {
447 447
         			$icao = $value['airport_departure_icao'];
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
         		foreach ($all as $key => $row) {
459 459
         			$count[$key] = $row['airport_departure_icao_count'];
460 460
         		}
461
-        		array_multisort($count,SORT_DESC,$all);
461
+        		array_multisort($count, SORT_DESC, $all);
462 462
                 }
463 463
                 return $all;
464 464
 	}
465
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
465
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
466 466
 		global $globalStatsFilters;
467 467
 		if ($filter_name == '') $filter_name = $this->filter_name;
468 468
 		if ($year == '' && $month == '') {
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
 			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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
471 471
 			try {
472 472
 				$sth = $this->db->prepare($query);
473
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
474
-			} catch(PDOException $e) {
473
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
474
+			} catch (PDOException $e) {
475 475
 				echo "error : ".$e->getMessage();
476 476
 			}
477 477
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
 		if (empty($all)) {
480 480
 			$filters = array('airlines' => array($stats_airline));
481 481
 			if ($filter_name != '') {
482
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
482
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
483 483
 			}
484 484
 			$Spotter = new Spotter($this->db);
485
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
486
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
485
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters, $year, $month);
486
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters, $year, $month);
487 487
         		$all = array();
488 488
         		foreach ($pall as $value) {
489 489
         			$icao = $value['airport_arrival_icao'];
@@ -500,12 +500,12 @@  discard block
 block discarded – undo
500 500
         		foreach ($all as $key => $row) {
501 501
         			$count[$key] = $row['airport_arrival_icao_count'];
502 502
         		}
503
-        		array_multisort($count,SORT_DESC,$all);
503
+        		array_multisort($count, SORT_DESC, $all);
504 504
                 }
505 505
  
506 506
                 return $all;
507 507
 	}
508
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
508
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
509 509
 		global $globalDBdriver, $globalStatsFilters;
510 510
 		if ($filter_name == '') $filter_name = $this->filter_name;
511 511
 		if ($globalDBdriver == 'mysql') {
@@ -515,18 +515,18 @@  discard block
 block discarded – undo
515 515
 			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";
516 516
 			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";
517 517
 		}
518
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
518
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
519 519
                  try {
520 520
                         $sth = $this->db->prepare($query);
521 521
                         $sth->execute($query_data);
522
-                } catch(PDOException $e) {
522
+                } catch (PDOException $e) {
523 523
                         echo "error : ".$e->getMessage();
524 524
                 }
525 525
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
526 526
                 if (empty($all)) {
527 527
 			$filters = array('airlines' => array($stats_airline));
528 528
 			if ($filter_name != '') {
529
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
529
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
530 530
 			}
531 531
             		$Spotter = new Spotter($this->db);
532 532
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -535,29 +535,29 @@  discard block
 block discarded – undo
535 535
                 return $all;
536 536
 	}
537 537
 	
538
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
538
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
539 539
 		global $globalStatsFilters;
540 540
 		if ($filter_name == '') $filter_name = $this->filter_name;
541 541
 		$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";
542
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
542
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
543 543
                  try {
544 544
                         $sth = $this->db->prepare($query);
545 545
                         $sth->execute($query_data);
546
-                } catch(PDOException $e) {
546
+                } catch (PDOException $e) {
547 547
                         echo "error : ".$e->getMessage();
548 548
                 }
549 549
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550 550
                 if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
553
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
554 554
 			}
555 555
             		$Spotter = new Spotter($this->db);
556 556
             		$all = $Spotter->countAllDatesLastMonth($filters);
557 557
                 }
558 558
                 return $all;
559 559
 	}
560
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
560
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
561 561
 		global $globalDBdriver, $globalStatsFilters;
562 562
 		if ($filter_name == '') $filter_name = $this->filter_name;
563 563
 		if ($globalDBdriver == 'mysql') {
@@ -565,40 +565,40 @@  discard block
 block discarded – undo
565 565
 		} else {
566 566
 			$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";
567 567
 		}
568
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
568
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
569 569
                  try {
570 570
                         $sth = $this->db->prepare($query);
571 571
                         $sth->execute($query_data);
572
-                } catch(PDOException $e) {
572
+                } catch (PDOException $e) {
573 573
                         echo "error : ".$e->getMessage();
574 574
                 }
575 575
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
576 576
                 if (empty($all)) {
577 577
 			$filters = array('airlines' => array($stats_airline));
578 578
 			if ($filter_name != '') {
579
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
579
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
580 580
 			}
581 581
             		$Spotter = new Spotter($this->db);
582 582
             		$all = $Spotter->countAllDatesLast7Days($filters);
583 583
                 }
584 584
                 return $all;
585 585
 	}
586
-	public function countAllDates($stats_airline = '',$filter_name = '') {
586
+	public function countAllDates($stats_airline = '', $filter_name = '') {
587 587
 		global $globalStatsFilters;
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		$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";
590
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
590
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
591 591
                  try {
592 592
                         $sth = $this->db->prepare($query);
593 593
                         $sth->execute($query_data);
594
-                } catch(PDOException $e) {
594
+                } catch (PDOException $e) {
595 595
                         echo "error : ".$e->getMessage();
596 596
                 }
597 597
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
598 598
                 if (empty($all)) {
599 599
 			$filters = array('airlines' => array($stats_airline));
600 600
 			if ($filter_name != '') {
601
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
601
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
602 602
 			}
603 603
             		$Spotter = new Spotter($this->db);
604 604
             		$all = $Spotter->countAllDates($filters);
@@ -613,35 +613,35 @@  discard block
 block discarded – undo
613 613
                  try {
614 614
                         $sth = $this->db->prepare($query);
615 615
                         $sth->execute($query_data);
616
-                } catch(PDOException $e) {
616
+                } catch (PDOException $e) {
617 617
                         echo "error : ".$e->getMessage();
618 618
                 }
619 619
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
620 620
                 if (empty($all)) {
621 621
             		$filters = array();
622 622
             		if ($filter_name != '') {
623
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
623
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
624 624
 			}
625 625
             		$Spotter = new Spotter($this->db);
626 626
             		$all = $Spotter->countAllDatesByAirlines($filters);
627 627
                 }
628 628
                 return $all;
629 629
 	}
630
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
630
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
631 631
 		global $globalStatsFilters;
632 632
 		if ($filter_name == '') $filter_name = $this->filter_name;
633 633
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634 634
                  try {
635 635
                         $sth = $this->db->prepare($query);
636 636
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
-                } catch(PDOException $e) {
637
+                } catch (PDOException $e) {
638 638
                         echo "error : ".$e->getMessage();
639 639
                 }
640 640
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
641 641
                 if (empty($all)) {
642 642
 			$filters = array('airlines' => array($stats_airline));
643 643
 			if ($filter_name != '') {
644
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
644
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
645 645
 			}
646 646
             		$Spotter = new Spotter($this->db);
647 647
             		$all = $Spotter->countAllMonths($filters);
@@ -655,21 +655,21 @@  discard block
 block discarded – undo
655 655
                  try {
656 656
                         $sth = $this->db->prepare($query);
657 657
                         $sth->execute(array(':filter_name' => $filter_name));
658
-                } catch(PDOException $e) {
658
+                } catch (PDOException $e) {
659 659
                         echo "error : ".$e->getMessage();
660 660
                 }
661 661
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
662 662
                 if (empty($all)) {
663 663
             		$filters = array();
664 664
             		if ($filter_name != '') {
665
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
665
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
666 666
 			}
667 667
             		$Spotter = new Spotter($this->db);
668 668
             		$all = $Spotter->countAllMilitaryMonths($filters);
669 669
                 }
670 670
                 return $all;
671 671
 	}
672
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
672
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
673 673
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
674 674
 		if ($filter_name == '') $filter_name = $this->filter_name;
675 675
 		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";
@@ -686,82 +686,82 @@  discard block
 block discarded – undo
686 686
                  try {
687 687
                         $sth = $this->db->prepare($query);
688 688
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
689
-                } catch(PDOException $e) {
689
+                } catch (PDOException $e) {
690 690
                         echo "error : ".$e->getMessage();
691 691
                 }
692 692
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
693 693
                 if (empty($all)) {
694 694
 			$filters = array('airlines' => array($stats_airline));
695 695
 			if ($filter_name != '') {
696
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
696
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
697 697
 			}
698 698
             		$Spotter = new Spotter($this->db);
699
-            		$all = $Spotter->countAllHours($orderby,$filters);
699
+            		$all = $Spotter->countAllHours($orderby, $filters);
700 700
                 }
701 701
                 return $all;
702 702
 	}
703 703
 	
704
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
704
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
705 705
 		global $globalStatsFilters;
706 706
 		if ($filter_name == '') $filter_name = $this->filter_name;
707 707
 		if ($year == '') $year = date('Y');
708
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
708
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
709 709
 		if (empty($all)) {
710 710
 			$filters = array('airlines' => array($stats_airline));
711 711
 			if ($filter_name != '') {
712
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
712
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
713 713
 			}
714 714
 			$Spotter = new Spotter($this->db);
715
-			$all = $Spotter->countOverallFlights($filters,$year,$month);
715
+			$all = $Spotter->countOverallFlights($filters, $year, $month);
716 716
 		}
717 717
 		return $all;
718 718
 	}
719
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
719
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
720 720
 		global $globalStatsFilters;
721 721
 		if ($filter_name == '') $filter_name = $this->filter_name;
722 722
 		if ($year == '') $year = date('Y');
723
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
723
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
724 724
 		if (empty($all)) {
725 725
 		        $filters = array();
726 726
             		if ($filter_name != '') {
727
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
727
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
728 728
 			}
729 729
 			$Spotter = new Spotter($this->db);
730
-			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
730
+			$all = $Spotter->countOverallMilitaryFlights($filters, $year, $month);
731 731
 		}
732 732
 		return $all;
733 733
 	}
734
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
734
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
735 735
 		global $globalStatsFilters;
736 736
 		if ($filter_name == '') $filter_name = $this->filter_name;
737 737
 		if ($year == '') $year = date('Y');
738
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
738
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
739 739
 		if (empty($all)) {
740 740
 			$filters = array('airlines' => array($stats_airline));
741 741
 			if ($filter_name != '') {
742
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
742
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
743 743
 			}
744 744
 			$Spotter = new Spotter($this->db);
745
-			$all = $Spotter->countOverallArrival($filters,$year,$month);
745
+			$all = $Spotter->countOverallArrival($filters, $year, $month);
746 746
 		}
747 747
 		return $all;
748 748
 	}
749
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
749
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
750 750
 		global $globalStatsFilters;
751 751
 		if ($filter_name == '') $filter_name = $this->filter_name;
752 752
 		if ($year == '') $year = date('Y');
753
-		$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
753
+		$all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
754 754
 		if (empty($all)) {
755 755
 			$filters = array('airlines' => array($stats_airline));
756 756
 			if ($filter_name != '') {
757
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
757
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
758 758
 			}
759 759
 			$Spotter = new Spotter($this->db);
760
-			$all = $Spotter->countOverallAircrafts($filters,$year,$month);
760
+			$all = $Spotter->countOverallAircrafts($filters, $year, $month);
761 761
 		}
762 762
 		return $all;
763 763
 	}
764
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
764
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
765 765
 		global $globalStatsFilters;
766 766
 		if ($filter_name == '') $filter_name = $this->filter_name;
767 767
 		if ($year == '' && $month == '') {
@@ -769,23 +769,23 @@  discard block
 block discarded – undo
769 769
 			try {
770 770
 				$sth = $this->db->prepare($query);
771 771
 				$sth->execute(array(':filter_name' => $filter_name));
772
-			} catch(PDOException $e) {
772
+			} catch (PDOException $e) {
773 773
 				echo "error : ".$e->getMessage();
774 774
 			}
775 775
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
776 776
 			$all = $result[0]['nb_airline'];
777
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
777
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
778 778
 		if (empty($all)) {
779 779
             		$filters = array();
780 780
             		if ($filter_name != '') {
781
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
781
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
782 782
 			}
783 783
 			$Spotter = new Spotter($this->db);
784
-			$all = $Spotter->countOverallAirlines($filters,$year,$month);
784
+			$all = $Spotter->countOverallAirlines($filters, $year, $month);
785 785
 		}
786 786
 		return $all;
787 787
 	}
788
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
788
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
789 789
 		global $globalStatsFilters;
790 790
 		if ($filter_name == '') $filter_name = $this->filter_name;
791 791
 		if ($year == '') $year = date('Y');
@@ -800,83 +800,83 @@  discard block
 block discarded – undo
800 800
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
801 801
                 $all = $result[0]['nb_owner'];
802 802
                 */
803
-		$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
803
+		$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
804 804
 		if (empty($all)) {
805 805
 			$filters = array('airlines' => array($stats_airline));
806 806
 			if ($filter_name != '') {
807
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
807
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
808 808
 			}
809 809
 			$Spotter = new Spotter($this->db);
810
-			$all = $Spotter->countOverallOwners($filters,$year,$month);
810
+			$all = $Spotter->countOverallOwners($filters, $year, $month);
811 811
 		}
812 812
 		return $all;
813 813
 	}
814
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
814
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
815 815
 		global $globalStatsFilters;
816 816
 		if ($filter_name == '') $filter_name = $this->filter_name;
817 817
 		if ($year == '') $year = date('Y');
818
-		$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
818
+		$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
819 819
 		if (empty($all)) {
820 820
 			$filters = array('airlines' => array($stats_airline));
821 821
 			if ($filter_name != '') {
822
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
822
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
823 823
 			}
824 824
 			$Spotter = new Spotter($this->db);
825
-			$all = $Spotter->countOverallPilots($filters,$year,$month);
825
+			$all = $Spotter->countOverallPilots($filters, $year, $month);
826 826
 		}
827 827
 		return $all;
828 828
 	}
829 829
 
830
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
830
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
831 831
 		if ($filter_name == '') $filter_name = $this->filter_name;
832 832
 		$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";
833
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
833
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
834 834
                  try {
835 835
                         $sth = $this->db->prepare($query);
836 836
                         $sth->execute($query_values);
837
-                } catch(PDOException $e) {
837
+                } catch (PDOException $e) {
838 838
                         echo "error : ".$e->getMessage();
839 839
                 }
840 840
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
841 841
                 return $all;
842 842
 	}
843
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
843
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
844 844
 		if ($filter_name == '') $filter_name = $this->filter_name;
845 845
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
846
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
846
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
847 847
                  try {
848 848
                         $sth = $this->db->prepare($query);
849 849
                         $sth->execute($query_values);
850
-                } catch(PDOException $e) {
850
+                } catch (PDOException $e) {
851 851
                         echo "error : ".$e->getMessage();
852 852
                 }
853 853
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
854 854
                 return $all;
855 855
         }
856
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
856
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
857 857
 		if ($filter_name == '') $filter_name = $this->filter_name;
858 858
     		global $globalArchiveMonths, $globalDBdriver;
859 859
     		if ($globalDBdriver == 'mysql') {
860 860
     			if ($month == '') {
861 861
 				$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";
862
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
862
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
863 863
 			} else {
864 864
 				$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";
865
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
865
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
866 866
 			}
867 867
 		} else {
868 868
 			if ($month == '') {
869 869
 				$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";
870
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
870
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
871 871
 			} else {
872 872
 				$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";
873
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
873
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
874 874
 			}
875 875
                 }
876 876
                  try {
877 877
                         $sth = $this->db->prepare($query);
878 878
                         $sth->execute($query_values);
879
-                } catch(PDOException $e) {
879
+                } catch (PDOException $e) {
880 880
                         echo "error : ".$e->getMessage();
881 881
                 }
882 882
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
                  try {
895 895
                         $sth = $this->db->prepare($query);
896 896
                         $sth->execute($query_values);
897
-                } catch(PDOException $e) {
897
+                } catch (PDOException $e) {
898 898
                         echo "error : ".$e->getMessage();
899 899
                 }
900 900
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
                  try {
912 912
                         $sth = $this->db->prepare($query);
913 913
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
914
-                } catch(PDOException $e) {
914
+                } catch (PDOException $e) {
915 915
                         echo "error : ".$e->getMessage();
916 916
                 }
917 917
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
                  try {
929 929
                         $sth = $this->db->prepare($query);
930 930
                         $sth->execute(array(':filter_name' => $filter_name));
931
-                } catch(PDOException $e) {
931
+                } catch (PDOException $e) {
932 932
                         echo "error : ".$e->getMessage();
933 933
                 }
934 934
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
                  try {
946 946
                         $sth = $this->db->prepare($query);
947 947
                         $sth->execute(array(':filter_name' => $filter_name));
948
-                } catch(PDOException $e) {
948
+                } catch (PDOException $e) {
949 949
                         echo "error : ".$e->getMessage();
950 950
                 }
951 951
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -962,14 +962,14 @@  discard block
 block discarded – undo
962 962
                  try {
963 963
                         $sth = $this->db->prepare($query);
964 964
                         $sth->execute(array(':filter_name' => $filter_name));
965
-                } catch(PDOException $e) {
965
+                } catch (PDOException $e) {
966 966
                         echo "error : ".$e->getMessage();
967 967
                 }
968 968
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
969 969
                 return $all[0]['total'];
970 970
         }
971 971
 
972
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
972
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
973 973
 		global $globalDBdriver;
974 974
 		if ($filter_name == '') $filter_name = $this->filter_name;
975 975
 		if ($globalDBdriver == 'mysql') {
@@ -977,15 +977,15 @@  discard block
 block discarded – undo
977 977
                 } else {
978 978
 			$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);"; 
979 979
 		}
980
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
980
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
981 981
                  try {
982 982
                         $sth = $this->db->prepare($query);
983 983
                         $sth->execute($query_values);
984
-                } catch(PDOException $e) {
984
+                } catch (PDOException $e) {
985 985
                         return "error : ".$e->getMessage();
986 986
                 }
987 987
         }
988
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
988
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
989 989
 		global $globalDBdriver;
990 990
 		if ($filter_name == '') $filter_name = $this->filter_name;
991 991
 		if ($globalDBdriver == 'mysql') {
@@ -994,11 +994,11 @@  discard block
 block discarded – undo
994 994
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
995 995
 			$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);"; 
996 996
                 }
997
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
997
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
998 998
                  try {
999 999
                         $sth = $this->db->prepare($query);
1000 1000
                         $sth->execute($query_values);
1001
-                } catch(PDOException $e) {
1001
+                } catch (PDOException $e) {
1002 1002
                         return "error : ".$e->getMessage();
1003 1003
                 }
1004 1004
         }
@@ -1022,75 +1022,75 @@  discard block
 block discarded – undo
1022 1022
         }
1023 1023
         */
1024 1024
 
1025
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1025
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1026 1026
 		global $globalDBdriver;
1027 1027
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1028 1028
 		$query_values = array();
1029 1029
 		if ($globalDBdriver == 'mysql') {
1030 1030
 			if ($year != '') {
1031 1031
 				$query .= ' AND YEAR(stats_date) = :year';
1032
-				$query_values = array_merge($query_values,array(':year' => $year));
1032
+				$query_values = array_merge($query_values, array(':year' => $year));
1033 1033
 			}
1034 1034
 			if ($month != '') {
1035 1035
 				$query .= ' AND MONTH(stats_date) = :month';
1036
-				$query_values = array_merge($query_values,array(':month' => $month));
1036
+				$query_values = array_merge($query_values, array(':month' => $month));
1037 1037
 			}
1038 1038
 			if ($day != '') {
1039 1039
 				$query .= ' AND DAY(stats_date) = :day';
1040
-				$query_values = array_merge($query_values,array(':day' => $day));
1040
+				$query_values = array_merge($query_values, array(':day' => $day));
1041 1041
 			}
1042 1042
 		} else {
1043 1043
 			if ($year != '') {
1044 1044
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1045
-				$query_values = array_merge($query_values,array(':year' => $year));
1045
+				$query_values = array_merge($query_values, array(':year' => $year));
1046 1046
 			}
1047 1047
 			if ($month != '') {
1048 1048
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1049
-				$query_values = array_merge($query_values,array(':month' => $month));
1049
+				$query_values = array_merge($query_values, array(':month' => $month));
1050 1050
 			}
1051 1051
 			if ($day != '') {
1052 1052
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1053
-				$query_values = array_merge($query_values,array(':day' => $day));
1053
+				$query_values = array_merge($query_values, array(':day' => $day));
1054 1054
 			}
1055 1055
 		}
1056 1056
 		$query .= " ORDER BY source_name";
1057
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1057
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1058 1058
 		try {
1059 1059
 			$sth = $this->db->prepare($query);
1060 1060
 			$sth->execute($query_values);
1061
-		} catch(PDOException $e) {
1061
+		} catch (PDOException $e) {
1062 1062
 			echo "error : ".$e->getMessage();
1063 1063
 		}
1064 1064
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1065 1065
 		return $all;
1066 1066
 	}
1067 1067
 
1068
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1068
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1069 1069
 		global $globalDBdriver;
1070 1070
 		if ($globalDBdriver == 'mysql') {
1071 1071
 			$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";
1072 1072
 		} else {
1073 1073
 			$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);"; 
1074 1074
                 }
1075
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1075
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1076 1076
                  try {
1077 1077
                         $sth = $this->db->prepare($query);
1078 1078
                         $sth->execute($query_values);
1079
-                } catch(PDOException $e) {
1079
+                } catch (PDOException $e) {
1080 1080
                         return "error : ".$e->getMessage();
1081 1081
                 }
1082 1082
         }
1083
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1083
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1084 1084
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1085
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1085
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1086 1086
                  try {
1087 1087
                         $sth = $this->db->prepare($query);
1088 1088
                         $sth->execute($query_values);
1089
-                } catch(PDOException $e) {
1089
+                } catch (PDOException $e) {
1090 1090
                         return "error : ".$e->getMessage();
1091 1091
                 }
1092 1092
         }
1093
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1093
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1094 1094
 		global $globalDBdriver;
1095 1095
 		if ($globalDBdriver == 'mysql') {
1096 1096
 			if ($reset) {
@@ -1105,15 +1105,15 @@  discard block
 block discarded – undo
1105 1105
 				$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);"; 
1106 1106
 			}
1107 1107
 		}
1108
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1108
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1109 1109
                  try {
1110 1110
                         $sth = $this->db->prepare($query);
1111 1111
                         $sth->execute($query_values);
1112
-                } catch(PDOException $e) {
1112
+                } catch (PDOException $e) {
1113 1113
                         return "error : ".$e->getMessage();
1114 1114
                 }
1115 1115
         }
1116
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1116
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1117 1117
 		global $globalDBdriver;
1118 1118
 		if ($globalDBdriver == 'mysql') {
1119 1119
 			if ($reset) {
@@ -1128,15 +1128,15 @@  discard block
 block discarded – undo
1128 1128
 				$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);"; 
1129 1129
 			}
1130 1130
 		}
1131
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1131
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1132 1132
                  try {
1133 1133
                         $sth = $this->db->prepare($query);
1134 1134
                         $sth->execute($query_values);
1135
-                } catch(PDOException $e) {
1135
+                } catch (PDOException $e) {
1136 1136
                         return "error : ".$e->getMessage();
1137 1137
                 }
1138 1138
         }
1139
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1139
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
1140 1140
 		global $globalDBdriver;
1141 1141
 		if ($globalDBdriver == 'mysql') {
1142 1142
 			if ($reset) {
@@ -1151,15 +1151,15 @@  discard block
 block discarded – undo
1151 1151
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
1152 1152
 			}
1153 1153
 		}
1154
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1154
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1155 1155
                  try {
1156 1156
                         $sth = $this->db->prepare($query);
1157 1157
                         $sth->execute($query_values);
1158
-                } catch(PDOException $e) {
1158
+                } catch (PDOException $e) {
1159 1159
                         return "error : ".$e->getMessage();
1160 1160
                 }
1161 1161
         }
1162
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1162
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1163 1163
 		global $globalDBdriver;
1164 1164
 		if ($globalDBdriver == 'mysql') {
1165 1165
 			if ($reset) {
@@ -1174,15 +1174,15 @@  discard block
 block discarded – undo
1174 1174
 				$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);"; 
1175 1175
 			}
1176 1176
 		}
1177
-                $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);
1177
+                $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);
1178 1178
                  try {
1179 1179
                         $sth = $this->db->prepare($query);
1180 1180
                         $sth->execute($query_values);
1181
-                } catch(PDOException $e) {
1181
+                } catch (PDOException $e) {
1182 1182
                         return "error : ".$e->getMessage();
1183 1183
                 }
1184 1184
         }
1185
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1185
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1186 1186
 		global $globalDBdriver;
1187 1187
 		if ($globalDBdriver == 'mysql') {
1188 1188
 			if ($reset) {
@@ -1197,15 +1197,15 @@  discard block
 block discarded – undo
1197 1197
 				$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);"; 
1198 1198
 			}
1199 1199
 		}
1200
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1200
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1201 1201
                  try {
1202 1202
                         $sth = $this->db->prepare($query);
1203 1203
                         $sth->execute($query_values);
1204
-                } catch(PDOException $e) {
1204
+                } catch (PDOException $e) {
1205 1205
                         return "error : ".$e->getMessage();
1206 1206
                 }
1207 1207
         }
1208
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1208
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1209 1209
 		global $globalDBdriver;
1210 1210
 		if ($globalDBdriver == 'mysql') {
1211 1211
 			if ($reset) {
@@ -1220,15 +1220,15 @@  discard block
 block discarded – undo
1220 1220
 				$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);"; 
1221 1221
 			}
1222 1222
 		}
1223
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1223
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1224 1224
                  try {
1225 1225
                         $sth = $this->db->prepare($query);
1226 1226
                         $sth->execute($query_values);
1227
-                } catch(PDOException $e) {
1227
+                } catch (PDOException $e) {
1228 1228
                         return "error : ".$e->getMessage();
1229 1229
                 }
1230 1230
         }
1231
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1231
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1232 1232
 		global $globalDBdriver;
1233 1233
 		if ($globalDBdriver == 'mysql') {
1234 1234
 			if ($reset) {
@@ -1243,15 +1243,15 @@  discard block
 block discarded – undo
1243 1243
 				$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);"; 
1244 1244
 			}
1245 1245
 		}
1246
-                $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);
1246
+                $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);
1247 1247
                  try {
1248 1248
                         $sth = $this->db->prepare($query);
1249 1249
                         $sth->execute($query_values);
1250
-                } catch(PDOException $e) {
1250
+                } catch (PDOException $e) {
1251 1251
                         return "error : ".$e->getMessage();
1252 1252
                 }
1253 1253
         }
1254
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1254
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1255 1255
 		global $globalDBdriver;
1256 1256
 		if ($airport_icao != '') {
1257 1257
 			if ($globalDBdriver == 'mysql') {
@@ -1267,16 +1267,16 @@  discard block
 block discarded – undo
1267 1267
 					$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);"; 
1268 1268
 				}
1269 1269
 			}
1270
-			$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);
1270
+			$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);
1271 1271
 			try {
1272 1272
 				$sth = $this->db->prepare($query);
1273 1273
 				$sth->execute($query_values);
1274
-			} catch(PDOException $e) {
1274
+			} catch (PDOException $e) {
1275 1275
 				return "error : ".$e->getMessage();
1276 1276
 			}
1277 1277
                 }
1278 1278
         }
1279
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1279
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1280 1280
 		global $globalDBdriver;
1281 1281
 		if ($airport_icao != '') {
1282 1282
 			if ($globalDBdriver == 'mysql') {
@@ -1284,16 +1284,16 @@  discard block
 block discarded – undo
1284 1284
 			} else {
1285 1285
 				$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);"; 
1286 1286
 			}
1287
-			$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);
1287
+			$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);
1288 1288
 			 try {
1289 1289
 				$sth = $this->db->prepare($query);
1290 1290
 				$sth->execute($query_values);
1291
-			} catch(PDOException $e) {
1291
+			} catch (PDOException $e) {
1292 1292
 				return "error : ".$e->getMessage();
1293 1293
 			}
1294 1294
                 }
1295 1295
         }
1296
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1296
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1297 1297
 		global $globalDBdriver;
1298 1298
 		if ($airport_icao != '') {
1299 1299
 			if ($globalDBdriver == 'mysql') {
@@ -1309,16 +1309,16 @@  discard block
 block discarded – undo
1309 1309
 					$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);"; 
1310 1310
 				}
1311 1311
 			}
1312
-	                $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);
1312
+	                $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);
1313 1313
 			 try {
1314 1314
                     		$sth = $this->db->prepare($query);
1315 1315
 	                        $sth->execute($query_values);
1316
-    		        } catch(PDOException $e) {
1316
+    		        } catch (PDOException $e) {
1317 1317
             		        return "error : ".$e->getMessage();
1318 1318
 	                }
1319 1319
 	        }
1320 1320
         }
1321
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1321
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1322 1322
 		global $globalDBdriver;
1323 1323
 		if ($airport_icao != '') {
1324 1324
 			if ($globalDBdriver == 'mysql') {
@@ -1326,11 +1326,11 @@  discard block
 block discarded – undo
1326 1326
 			} else {
1327 1327
 				$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);"; 
1328 1328
 			}
1329
-			$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);
1329
+			$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);
1330 1330
 			try {
1331 1331
 				$sth = $this->db->prepare($query);
1332 1332
 				$sth->execute($query_values);
1333
-			} catch(PDOException $e) {
1333
+			} catch (PDOException $e) {
1334 1334
 				return "error : ".$e->getMessage();
1335 1335
 			}
1336 1336
                 }
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
                  try {
1343 1343
                         $sth = $this->db->prepare($query);
1344 1344
                         $sth->execute($query_values);
1345
-                } catch(PDOException $e) {
1345
+                } catch (PDOException $e) {
1346 1346
                         return "error : ".$e->getMessage();
1347 1347
                 }
1348 1348
         }
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
                  try {
1353 1353
                         $sth = $this->db->prepare($query);
1354 1354
                         $sth->execute($query_values);
1355
-                } catch(PDOException $e) {
1355
+                } catch (PDOException $e) {
1356 1356
                         return "error : ".$e->getMessage();
1357 1357
                 }
1358 1358
         }
@@ -1362,13 +1362,13 @@  discard block
 block discarded – undo
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
                         return "error : ".$e->getMessage();
1367 1367
                 }
1368 1368
         }
1369 1369
         
1370 1370
         public function addOldStats() {
1371
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1371
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear;
1372 1372
     		$Common = new Common();
1373 1373
     		$Connection = new Connection();
1374 1374
     		date_default_timezone_set('UTC');
@@ -1385,40 +1385,40 @@  discard block
 block discarded – undo
1385 1385
 			$Spotter = new Spotter($this->db);
1386 1386
 
1387 1387
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1388
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1388
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1389 1389
 			foreach ($alldata as $number) {
1390
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1390
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
1391 1391
 			}
1392 1392
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1393
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1393
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1394 1394
 			foreach ($alldata as $number) {
1395
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1395
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1396 1396
 			}
1397 1397
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1398
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1398
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1399 1399
 			foreach ($alldata as $number) {
1400
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1400
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1401 1401
 			}
1402 1402
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1403
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1403
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1404 1404
 			foreach ($alldata as $number) {
1405
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1405
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1406 1406
 			}
1407 1407
 			if ($globalDebug) echo 'Count all owners...'."\n";
1408
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1408
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1409 1409
 			foreach ($alldata as $number) {
1410
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1410
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1411 1411
 			}
1412 1412
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1413
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1413
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1414 1414
 			foreach ($alldata as $number) {
1415
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1415
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1416 1416
 			}
1417 1417
 			
1418 1418
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1419
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1419
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1420 1420
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1421
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1421
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1422 1422
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1423 1423
 	        	$alldata = array();
1424 1424
 	        	
@@ -1436,14 +1436,14 @@  discard block
 block discarded – undo
1436 1436
     			foreach ($alldata as $key => $row) {
1437 1437
     				$count[$key] = $row['airport_departure_icao_count'];
1438 1438
         		}
1439
-			array_multisort($count,SORT_DESC,$alldata);
1439
+			array_multisort($count, SORT_DESC, $alldata);
1440 1440
 			foreach ($alldata as $number) {
1441
-				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);
1441
+				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);
1442 1442
 			}
1443 1443
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1444
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1444
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1445 1445
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1446
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1446
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1447 1447
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1448 1448
 	        	$alldata = array();
1449 1449
     			foreach ($pall as $value) {
@@ -1460,16 +1460,16 @@  discard block
 block discarded – undo
1460 1460
         		foreach ($alldata as $key => $row) {
1461 1461
         			$count[$key] = $row['airport_arrival_icao_count'];
1462 1462
 	        	}
1463
-    			array_multisort($count,SORT_DESC,$alldata);
1463
+    			array_multisort($count, SORT_DESC, $alldata);
1464 1464
                         foreach ($alldata as $number) {
1465
-				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);
1465
+				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);
1466 1466
 			}
1467 1467
 			if ($Connection->tableExists('countries')) {
1468 1468
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1469 1469
 				$SpotterArchive = new SpotterArchive();
1470
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1470
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1471 1471
 				foreach ($alldata as $number) {
1472
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'',$reset);
1472
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', $reset);
1473 1473
 				}
1474 1474
 			}
1475 1475
 			
@@ -1483,37 +1483,37 @@  discard block
 block discarded – undo
1483 1483
 			$lastyear = false;
1484 1484
 			foreach ($alldata as $number) {
1485 1485
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1486
-				$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'])));
1486
+				$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'])));
1487 1487
 			}
1488 1488
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1489 1489
 			$alldata = $Spotter->countAllMilitaryMonths();
1490 1490
 			foreach ($alldata as $number) {
1491
-				$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'])));
1491
+				$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'])));
1492 1492
 			}
1493 1493
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1494 1494
 			$alldata = $Spotter->countAllMonthsOwners();
1495 1495
 			foreach ($alldata as $number) {
1496
-				$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'])));
1496
+				$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'])));
1497 1497
 			}
1498 1498
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1499 1499
 			$alldata = $Spotter->countAllMonthsPilots();
1500 1500
 			foreach ($alldata as $number) {
1501
-				$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'])));
1501
+				$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'])));
1502 1502
 			}
1503 1503
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1504 1504
 			$alldata = $Spotter->countAllMonthsAirlines();
1505 1505
 			foreach ($alldata as $number) {
1506
-				$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'])));
1506
+				$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'])));
1507 1507
 			}
1508 1508
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1509 1509
 			$alldata = $Spotter->countAllMonthsAircrafts();
1510 1510
 			foreach ($alldata as $number) {
1511
-				$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'])));
1511
+				$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'])));
1512 1512
 			}
1513 1513
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1514 1514
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1515 1515
 			foreach ($alldata as $number) {
1516
-				$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'])));
1516
+				$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'])));
1517 1517
 			}
1518 1518
 			if ($globalDebug) echo 'Airports data...'."\n";
1519 1519
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
     			}
1559 1559
     			$alldata = $pall;
1560 1560
 			foreach ($alldata as $number) {
1561
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1561
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1562 1562
 			}
1563 1563
 			echo '...Arrival'."\n";
1564 1564
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1600,7 +1600,7 @@  discard block
 block discarded – undo
1600 1600
     			}
1601 1601
     			$alldata = $pall;
1602 1602
 			foreach ($alldata as $number) {
1603
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1603
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1604 1604
 			}
1605 1605
 
1606 1606
 			echo 'Flights data...'."\n";
@@ -1608,28 +1608,28 @@  discard block
 block discarded – undo
1608 1608
 			echo '-> countAllDatesLastMonth...'."\n";
1609 1609
 			$alldata = $Spotter->countAllDatesLastMonth();
1610 1610
 			foreach ($alldata as $number) {
1611
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1611
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1612 1612
 			}
1613 1613
 			echo '-> countAllDates...'."\n";
1614 1614
 			$previousdata = $this->countAllDates();
1615 1615
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1616 1616
 			$this->deleteStatFlight('date');
1617
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1617
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1618 1618
 			$values = array();
1619 1619
 			foreach ($alldata as $cnt) {
1620 1620
 				$values[] = $cnt['date_count'];
1621 1621
 			}
1622
-			array_multisort($values,SORT_DESC,$alldata);
1623
-			array_splice($alldata,11);
1622
+			array_multisort($values, SORT_DESC, $alldata);
1623
+			array_splice($alldata, 11);
1624 1624
 			foreach ($alldata as $number) {
1625
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1625
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1626 1626
 			}
1627 1627
 			
1628 1628
 			$this->deleteStatFlight('hour');
1629 1629
 			echo '-> countAllHours...'."\n";
1630 1630
 			$alldata = $Spotter->countAllHours('hour');
1631 1631
 			foreach ($alldata as $number) {
1632
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1632
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1633 1633
 			}
1634 1634
 
1635 1635
 
@@ -1638,34 +1638,34 @@  discard block
 block discarded – undo
1638 1638
 			echo '--- Stats by airlines ---'."\n";
1639 1639
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1640 1640
 			$Spotter = new Spotter($this->db);
1641
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1641
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1642 1642
 			foreach ($alldata as $number) {
1643
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1643
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1644 1644
 			}
1645 1645
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1646
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1646
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1647 1647
 			foreach ($alldata as $number) {
1648
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1648
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1649 1649
 			}
1650 1650
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1651
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1651
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1652 1652
 			foreach ($alldata as $number) {
1653
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1653
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1654 1654
 			}
1655 1655
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1656
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1656
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1657 1657
 			foreach ($alldata as $number) {
1658
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1658
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1659 1659
 			}
1660 1660
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1661
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1661
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1662 1662
 			foreach ($alldata as $number) {
1663
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1663
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1664 1664
 			}
1665 1665
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1666
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1666
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1667 1667
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1668
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1668
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1669 1669
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1670 1670
 	        	//$alldata = array();
1671 1671
     			foreach ($dall as $value) {
@@ -1685,12 +1685,12 @@  discard block
 block discarded – undo
1685 1685
     			}
1686 1686
     			$alldata = $pall;
1687 1687
 			foreach ($alldata as $number) {
1688
-				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);
1688
+				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);
1689 1689
 			}
1690 1690
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1691
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1691
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1692 1692
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1693
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1693
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1694 1694
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1695 1695
 	        	//$alldata = array();
1696 1696
     			foreach ($dall as $value) {
@@ -1710,7 +1710,7 @@  discard block
 block discarded – undo
1710 1710
     			}
1711 1711
     			$alldata = $pall;
1712 1712
                         foreach ($alldata as $number) {
1713
-				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);
1713
+				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);
1714 1714
 			}
1715 1715
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1716 1716
 			$Spotter = new Spotter($this->db);
@@ -1718,27 +1718,27 @@  discard block
 block discarded – undo
1718 1718
 			$lastyear = false;
1719 1719
 			foreach ($alldata as $number) {
1720 1720
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1721
-				$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']);
1721
+				$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']);
1722 1722
 			}
1723 1723
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1724 1724
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1725 1725
 			foreach ($alldata as $number) {
1726
-				$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']);
1726
+				$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']);
1727 1727
 			}
1728 1728
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1729 1729
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1730 1730
 			foreach ($alldata as $number) {
1731
-				$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']);
1731
+				$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']);
1732 1732
 			}
1733 1733
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1734 1734
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1735 1735
 			foreach ($alldata as $number) {
1736
-				$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']);
1736
+				$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']);
1737 1737
 			}
1738 1738
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1739 1739
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1740 1740
 			foreach ($alldata as $number) {
1741
-				$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']);
1741
+				$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']);
1742 1742
 			}
1743 1743
 			if ($globalDebug) echo '...Departure'."\n";
1744 1744
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1761,7 +1761,7 @@  discard block
 block discarded – undo
1761 1761
     			}
1762 1762
     			$alldata = $pall;
1763 1763
 			foreach ($alldata as $number) {
1764
-				$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']);
1764
+				$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']);
1765 1765
 			}
1766 1766
 			if ($globalDebug) echo '...Arrival'."\n";
1767 1767
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1784,32 +1784,32 @@  discard block
 block discarded – undo
1784 1784
     			}
1785 1785
     			$alldata = $pall;
1786 1786
 			foreach ($alldata as $number) {
1787
-				$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']);
1787
+				$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']);
1788 1788
 			}
1789 1789
 
1790 1790
 			if ($globalDebug) echo 'Flights data...'."\n";
1791 1791
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1792 1792
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1793 1793
 			foreach ($alldata as $number) {
1794
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1794
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1795 1795
 			}
1796 1796
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1797 1797
 			//$previousdata = $this->countAllDatesByAirlines();
1798
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1798
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1799 1799
 			$values = array();
1800 1800
 			foreach ($alldata as $cnt) {
1801 1801
 				$values[] = $cnt['date_count'];
1802 1802
 			}
1803
-			array_multisort($values,SORT_DESC,$alldata);
1804
-			array_splice($alldata,11);
1803
+			array_multisort($values, SORT_DESC, $alldata);
1804
+			array_splice($alldata, 11);
1805 1805
 			foreach ($alldata as $number) {
1806
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1806
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1807 1807
 			}
1808 1808
 			
1809 1809
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1810 1810
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1811 1811
 			foreach ($alldata as $number) {
1812
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1812
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1813 1813
 			}
1814 1814
 			
1815 1815
 
@@ -1828,32 +1828,32 @@  discard block
 block discarded – undo
1828 1828
 				// Count by filter
1829 1829
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1830 1830
 				$Spotter = new Spotter($this->db);
1831
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1831
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1832 1832
 				foreach ($alldata as $number) {
1833
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
1833
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
1834 1834
 				}
1835
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
1835
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
1836 1836
 				foreach ($alldata as $number) {
1837
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
1837
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
1838 1838
 				}
1839
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1839
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1840 1840
 				foreach ($alldata as $number) {
1841
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
1841
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
1842 1842
 				}
1843
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1843
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1844 1844
 				foreach ($alldata as $number) {
1845
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
1845
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
1846 1846
 				}
1847
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1847
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1848 1848
 				foreach ($alldata as $number) {
1849
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
1849
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
1850 1850
 				}
1851
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1851
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1852 1852
 				foreach ($alldata as $number) {
1853
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1853
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
1854 1854
 				}
1855
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1856
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1855
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1856
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1857 1857
 		        	$alldata = array();
1858 1858
 	    			foreach ($pall as $value) {
1859 1859
 		        		$icao = $value['airport_departure_icao'];
@@ -1869,12 +1869,12 @@  discard block
 block discarded – undo
1869 1869
     				foreach ($alldata as $key => $row) {
1870 1870
     					$count[$key] = $row['airport_departure_icao_count'];
1871 1871
     				}
1872
-				array_multisort($count,SORT_DESC,$alldata);
1872
+				array_multisort($count, SORT_DESC, $alldata);
1873 1873
 				foreach ($alldata as $number) {
1874
-    					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);
1874
+    					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);
1875 1875
 				}
1876
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1877
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1876
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
1877
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
1878 1878
 				$alldata = array();
1879 1879
     				foreach ($pall as $value) {
1880 1880
 		        		$icao = $value['airport_arrival_icao'];
@@ -1890,40 +1890,40 @@  discard block
 block discarded – undo
1890 1890
         			foreach ($alldata as $key => $row) {
1891 1891
     					$count[$key] = $row['airport_arrival_icao_count'];
1892 1892
 		        	}
1893
-        			array_multisort($count,SORT_DESC,$alldata);
1893
+        			array_multisort($count, SORT_DESC, $alldata);
1894 1894
 				foreach ($alldata as $number) {
1895
-					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);
1895
+					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);
1896 1896
 				}
1897 1897
 				$Spotter = new Spotter($this->db);
1898 1898
 				$alldata = $Spotter->countAllMonths($filter);
1899 1899
 				$lastyear = false;
1900 1900
 				foreach ($alldata as $number) {
1901 1901
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1902
-					$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);
1902
+					$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);
1903 1903
 				}
1904 1904
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1905 1905
 				foreach ($alldata as $number) {
1906
-					$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);
1906
+					$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);
1907 1907
 				}
1908 1908
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1909 1909
 				foreach ($alldata as $number) {
1910
-					$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);
1910
+					$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);
1911 1911
 				}
1912 1912
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
1913 1913
 				foreach ($alldata as $number) {
1914
-					$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);
1914
+					$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);
1915 1915
 				}
1916 1916
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1917 1917
 				foreach ($alldata as $number) {
1918
-					$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);
1918
+					$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);
1919 1919
 				}
1920 1920
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1921 1921
 				foreach ($alldata as $number) {
1922
-					$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);
1922
+					$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);
1923 1923
 				}
1924 1924
 				echo '...Departure'."\n";
1925
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1926
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1925
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
1926
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
1927 1927
 				foreach ($dall as $value) {
1928 1928
     					$icao = $value['departure_airport_icao'];
1929 1929
     					$ddate = $value['date'];
@@ -1941,11 +1941,11 @@  discard block
 block discarded – undo
1941 1941
     				}
1942 1942
 	    			$alldata = $pall;
1943 1943
 				foreach ($alldata as $number) {
1944
-					$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);
1944
+					$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);
1945 1945
 				}
1946 1946
 				echo '...Arrival'."\n";
1947
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1948
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1947
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
1948
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
1949 1949
 				foreach ($dall as $value) {
1950 1950
 					$icao = $value['arrival_airport_icao'];
1951 1951
 					$ddate = $value['date'];
@@ -1963,40 +1963,40 @@  discard block
 block discarded – undo
1963 1963
     				}
1964 1964
     				$alldata = $pall;
1965 1965
 				foreach ($alldata as $number) {
1966
-					$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);
1966
+					$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);
1967 1967
 				}
1968 1968
     
1969 1969
 				echo 'Flights data...'."\n";
1970 1970
 				echo '-> countAllDatesLastMonth...'."\n";
1971 1971
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
1972 1972
 				foreach ($alldata as $number) {
1973
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
1973
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
1974 1974
 				}
1975 1975
 				echo '-> countAllDates...'."\n";
1976
-				$previousdata = $this->countAllDates('',$filter_name);
1977
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
1976
+				$previousdata = $this->countAllDates('', $filter_name);
1977
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
1978 1978
 				$values = array();
1979 1979
 				foreach ($alldata as $cnt) {
1980 1980
 					$values[] = $cnt['date_count'];
1981 1981
 				}
1982
-				array_multisort($values,SORT_DESC,$alldata);
1983
-				array_splice($alldata,11);
1982
+				array_multisort($values, SORT_DESC, $alldata);
1983
+				array_splice($alldata, 11);
1984 1984
 				foreach ($alldata as $number) {
1985
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
1985
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
1986 1986
 				}
1987 1987
 				
1988 1988
 				echo '-> countAllHours...'."\n";
1989
-				$alldata = $Spotter->countAllHours('hour',$filter);
1989
+				$alldata = $Spotter->countAllHours('hour', $filter);
1990 1990
 				foreach ($alldata as $number) {
1991
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
1991
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
1992 1992
 				}
1993 1993
 				echo 'Insert last stats update date...'."\n";
1994 1994
 				date_default_timezone_set('UTC');
1995
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
1995
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
1996 1996
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
1997
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
1997
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
1998 1998
 						$this->deleteOldStats($filter_name);
1999
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
1999
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2000 2000
 					}
2001 2001
 				}
2002 2002
 
@@ -2009,16 +2009,16 @@  discard block
 block discarded – undo
2009 2009
 				// SUM all previous month to put as year
2010 2010
 				$previous_year = date('Y');
2011 2011
 				$previous_year--;
2012
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2013
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2014
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2015
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2012
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2013
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2014
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2015
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2016 2016
 				$allairlines = $this->getAllAirlineNames();
2017 2017
 				foreach ($allairlines as $data) {
2018
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2019
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2020
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2021
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2018
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2019
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2020
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2021
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2022 2022
 				}
2023 2023
 				
2024 2024
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
 						try {
2028 2028
 							$sth = $this->db->prepare($query);
2029 2029
 							$sth->execute();
2030
-						} catch(PDOException $e) {
2030
+						} catch (PDOException $e) {
2031 2031
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2032 2032
 						}
2033 2033
 					}
@@ -2036,15 +2036,15 @@  discard block
 block discarded – undo
2036 2036
 					try {
2037 2037
 						$sth = $this->db->prepare($query);
2038 2038
 						$sth->execute();
2039
-					} catch(PDOException $e) {
2039
+					} catch (PDOException $e) {
2040 2040
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2041 2041
 					}
2042 2042
 				}
2043 2043
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2044 2044
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2045
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2045
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2046 2046
 						$this->deleteOldStats();
2047
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2047
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2048 2048
 						$lastyearupdate = true;
2049 2049
 					}
2050 2050
 				}
@@ -2066,7 +2066,7 @@  discard block
 block discarded – undo
2066 2066
 					try {
2067 2067
 						$sth = $this->db->prepare($query);
2068 2068
 						$sth->execute();
2069
-					} catch(PDOException $e) {
2069
+					} catch (PDOException $e) {
2070 2070
 						return "error : ".$e->getMessage();
2071 2071
 					}
2072 2072
 				}
@@ -2080,14 +2080,14 @@  discard block
 block discarded – undo
2080 2080
 				try {
2081 2081
 					$sth = $this->db->prepare($query);
2082 2082
 					$sth->execute();
2083
-				} catch(PDOException $e) {
2083
+				} catch (PDOException $e) {
2084 2084
 					return "error : ".$e->getMessage();
2085 2085
 				}
2086 2086
 			}
2087 2087
 			if (!isset($lastyearupdate)) {
2088 2088
 				echo 'Insert last stats update date...'."\n";
2089 2089
 				date_default_timezone_set('UTC');
2090
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2090
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2091 2091
 			}
2092 2092
 			if ($globalStatsResetYear) {
2093 2093
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +452 added lines, -156 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -77,7 +79,9 @@  discard block
 block discarded – undo
77 79
                 }
78 80
         }
79 81
 	public function getAllAirlineNames($filter_name = '') {
80
-		if ($filter_name == '') $filter_name = $this->filter_name;
82
+		if ($filter_name == '') {
83
+			$filter_name = $this->filter_name;
84
+		}
81 85
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82 86
                  try {
83 87
                         $sth = $this->db->prepare($query);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
                 return $all;
90 94
         }
91 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92
-		if ($filter_name == '') $filter_name = $this->filter_name;
96
+		if ($filter_name == '') {
97
+			$filter_name = $this->filter_name;
98
+		}
93 99
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 100
                  try {
95 101
                         $sth = $this->db->prepare($query);
@@ -101,7 +107,9 @@  discard block
 block discarded – undo
101 107
                 return $all;
102 108
         }
103 109
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104
-		if ($filter_name == '') $filter_name = $this->filter_name;
110
+		if ($filter_name == '') {
111
+			$filter_name = $this->filter_name;
112
+		}
105 113
                 $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";
106 114
                  try {
107 115
                         $sth = $this->db->prepare($query);
@@ -113,7 +121,9 @@  discard block
 block discarded – undo
113 121
                 return $all;
114 122
         }
115 123
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
124
+		if ($filter_name == '') {
125
+			$filter_name = $this->filter_name;
126
+		}
117 127
                 $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";
118 128
                  try {
119 129
                         $sth = $this->db->prepare($query);
@@ -126,7 +136,9 @@  discard block
 block discarded – undo
126 136
         }
127 137
 
128 138
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129
-		if ($filter_name == '') $filter_name = $this->filter_name;
139
+		if ($filter_name == '') {
140
+			$filter_name = $this->filter_name;
141
+		}
130 142
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 143
                  try {
132 144
                         $sth = $this->db->prepare($query);
@@ -139,7 +151,9 @@  discard block
 block discarded – undo
139 151
         }
140 152
 
141 153
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142
-		if ($filter_name == '') $filter_name = $this->filter_name;
154
+		if ($filter_name == '') {
155
+			$filter_name = $this->filter_name;
156
+		}
143 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";
144 158
                  try {
145 159
                         $sth = $this->db->prepare($query);
@@ -154,10 +168,15 @@  discard block
 block discarded – undo
154 168
 
155 169
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
156 170
 		global $globalStatsFilters;
157
-		if ($filter_name == '') $filter_name = $this->filter_name;
171
+		if ($filter_name == '') {
172
+			$filter_name = $this->filter_name;
173
+		}
158 174
 		if ($year == '' && $month == '') {
159
-			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";
160
-			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";
175
+			if ($limit) {
176
+				$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";
177
+			} else {
178
+				$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";
179
+			}
161 180
 			try {
162 181
 				$sth = $this->db->prepare($query);
163 182
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -165,7 +184,9 @@  discard block
 block discarded – undo
165 184
 				echo "error : ".$e->getMessage();
166 185
 			}
167 186
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168
-		} else $all = array();
187
+		} else {
188
+			$all = array();
189
+		}
169 190
                 if (empty($all)) {
170 191
             	    $filters = array('airlines' => array($stats_airline));
171 192
             	    if ($filter_name != '') {
@@ -178,10 +199,15 @@  discard block
 block discarded – undo
178 199
 	}
179 200
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 201
 		global $globalStatsFilters;
181
-		if ($filter_name == '') $filter_name = $this->filter_name;
202
+		if ($filter_name == '') {
203
+			$filter_name = $this->filter_name;
204
+		}
182 205
 		if ($year == '' && $month == '') {
183
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
184
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
206
+			if ($limit) {
207
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
208
+			} else {
209
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
210
+			}
185 211
 			try {
186 212
 				$sth = $this->db->prepare($query);
187 213
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -189,7 +215,9 @@  discard block
 block discarded – undo
189 215
 				echo "error : ".$e->getMessage();
190 216
 			}
191 217
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-		} else $all = array();
218
+		} else {
219
+			$all = array();
220
+		}
193 221
                 if (empty($all)) {
194 222
             		$Spotter = new Spotter($this->db);
195 223
             		$filters = array();
@@ -202,10 +230,15 @@  discard block
 block discarded – undo
202 230
 	}
203 231
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 232
 		global $globalStatsFilters;
205
-		if ($filter_name == '') $filter_name = $this->filter_name;
233
+		if ($filter_name == '') {
234
+			$filter_name = $this->filter_name;
235
+		}
206 236
 		if ($year == '' && $month == '') {
207
-			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";
208
-			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";
237
+			if ($limit) {
238
+				$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";
239
+			} else {
240
+				$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";
241
+			}
209 242
 			try {
210 243
 				$sth = $this->db->prepare($query);
211 244
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -213,7 +246,9 @@  discard block
 block discarded – undo
213 246
 				echo "error : ".$e->getMessage();
214 247
 			}
215 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
216
-		} else $all = array();
249
+		} else {
250
+			$all = array();
251
+		}
217 252
 		if (empty($all)) {
218 253
 			$filters = array('airlines' => array($stats_airline));
219 254
 			if ($filter_name != '') {
@@ -227,10 +262,15 @@  discard block
 block discarded – undo
227 262
 
228 263
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
229 264
 		global $globalStatsFilters;
230
-		if ($filter_name == '') $filter_name = $this->filter_name;
265
+		if ($filter_name == '') {
266
+			$filter_name = $this->filter_name;
267
+		}
231 268
 		if ($year == '' && $month == '') {
232
-			if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
233
-			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
269
+			if ($limit) {
270
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
271
+			} else {
272
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
273
+			}
234 274
 			try {
235 275
 				$sth = $this->db->prepare($query);
236 276
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -238,7 +278,9 @@  discard block
 block discarded – undo
238 278
 				echo "error : ".$e->getMessage();
239 279
 			}
240 280
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241
-		} else $all = array();
281
+		} else {
282
+			$all = array();
283
+		}
242 284
                 if (empty($all)) {
243 285
 			$filters = array('airlines' => array($stats_airline));
244 286
 			if ($filter_name != '') {
@@ -251,9 +293,14 @@  discard block
 block discarded – undo
251 293
 	}
252 294
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 295
 		global $globalStatsFilters;
254
-		if ($filter_name == '') $filter_name = $this->filter_name;
255
-		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
256
-		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
296
+		if ($filter_name == '') {
297
+			$filter_name = $this->filter_name;
298
+		}
299
+		if ($limit) {
300
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
301
+		} else {
302
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
303
+		}
257 304
                  try {
258 305
                         $sth = $this->db->prepare($query);
259 306
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -274,10 +321,15 @@  discard block
 block discarded – undo
274 321
 
275 322
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
276 323
 		global $globalStatsFilters;
277
-		if ($filter_name == '') $filter_name = $this->filter_name;
324
+		if ($filter_name == '') {
325
+			$filter_name = $this->filter_name;
326
+		}
278 327
 		if ($year == '' && $month == '') {
279
-			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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
280
-			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 ORDER BY airline_count DESC";
328
+			if ($limit) {
329
+				$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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
330
+			} else {
331
+				$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 ORDER BY airline_count DESC";
332
+			}
281 333
 			try {
282 334
 				$sth = $this->db->prepare($query);
283 335
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -285,7 +337,9 @@  discard block
 block discarded – undo
285 337
 				echo "error : ".$e->getMessage();
286 338
 			}
287 339
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
288
-		} else $all = array();
340
+		} else {
341
+			$all = array();
342
+		}
289 343
                 if (empty($all)) {
290 344
 	                $Spotter = new Spotter($this->db);
291 345
             		$filters = array();
@@ -299,10 +353,15 @@  discard block
 block discarded – undo
299 353
 	}
300 354
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
301 355
 		global $globalStatsFilters;
302
-		if ($filter_name == '') $filter_name = $this->filter_name;
356
+		if ($filter_name == '') {
357
+			$filter_name = $this->filter_name;
358
+		}
303 359
 		if ($year == '' && $month == '') {
304
-			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";
305
-			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";
360
+			if ($limit) {
361
+				$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";
362
+			} else {
363
+				$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";
364
+			}
306 365
 			try {
307 366
 				$sth = $this->db->prepare($query);
308 367
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -310,7 +369,9 @@  discard block
 block discarded – undo
310 369
 				echo "error : ".$e->getMessage();
311 370
 			}
312 371
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313
-		} else $all = array();
372
+		} else {
373
+			$all = array();
374
+		}
314 375
                 if (empty($all)) {
315 376
 			$filters = array('airlines' => array($stats_airline));
316 377
 			if ($filter_name != '') {
@@ -323,10 +384,15 @@  discard block
 block discarded – undo
323 384
 	}
324 385
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
325 386
 		global $globalStatsFilters;
326
-		if ($filter_name == '') $filter_name = $this->filter_name;
387
+		if ($filter_name == '') {
388
+			$filter_name = $this->filter_name;
389
+		}
327 390
 		if ($year == '' && $month == '') {
328
-			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";
329
-			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";
391
+			if ($limit) {
392
+				$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";
393
+			} else {
394
+				$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";
395
+			}
330 396
 			 try {
331 397
 				$sth = $this->db->prepare($query);
332 398
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -334,7 +400,9 @@  discard block
 block discarded – undo
334 400
 				echo "error : ".$e->getMessage();
335 401
 			}
336 402
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
337
-		} else $all = array();
403
+		} else {
404
+			$all = array();
405
+		}
338 406
 		if (empty($all)) {
339 407
 			$filters = array('airlines' => array($stats_airline));
340 408
 			if ($filter_name != '') {
@@ -347,11 +415,16 @@  discard block
 block discarded – undo
347 415
 	}
348 416
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
349 417
 		$Connection = new Connection();
350
-		if ($filter_name == '') $filter_name = $this->filter_name;
418
+		if ($filter_name == '') {
419
+			$filter_name = $this->filter_name;
420
+		}
351 421
 		if ($Connection->tableExists('countries')) {
352 422
 			if ($year == '' && $month == '') {
353
-				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";
354
-				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";
423
+				if ($limit) {
424
+					$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";
425
+				} else {
426
+					$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";
427
+				}
355 428
 				 try {
356 429
 					$sth = $this->db->prepare($query);
357 430
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -366,17 +439,24 @@  discard block
 block discarded – undo
366 439
                 }
367 440
                 */
368 441
 				return $all;
369
-			} else return array();
442
+			} else {
443
+				return array();
444
+			}
370 445
 		} else {
371 446
 			return array();
372 447
 		}
373 448
 	}
374 449
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
375 450
 		global $globalStatsFilters;
376
-		if ($filter_name == '') $filter_name = $this->filter_name;
451
+		if ($filter_name == '') {
452
+			$filter_name = $this->filter_name;
453
+		}
377 454
 		if ($year == '' && $month == '') {
378
-			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";
379
-			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";
455
+			if ($limit) {
456
+				$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";
457
+			} else {
458
+				$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";
459
+			}
380 460
 			try {
381 461
 				$sth = $this->db->prepare($query);
382 462
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -384,7 +464,9 @@  discard block
 block discarded – undo
384 464
 				echo "error : ".$e->getMessage();
385 465
 			}
386 466
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
387
-		} else $all = array();
467
+		} else {
468
+			$all = array();
469
+		}
388 470
 		if (empty($all)) {
389 471
 			$filters = array('airlines' => array($stats_airline));
390 472
 			if ($filter_name != '') {
@@ -398,10 +480,15 @@  discard block
 block discarded – undo
398 480
 
399 481
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
400 482
 		global $globalStatsFilters;
401
-		if ($filter_name == '') $filter_name = $this->filter_name;
483
+		if ($filter_name == '') {
484
+			$filter_name = $this->filter_name;
485
+		}
402 486
 		if ($year == '' && $month == '') {
403
-			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";
404
-			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";
487
+			if ($limit) {
488
+				$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";
489
+			} else {
490
+				$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";
491
+			}
405 492
 			try {
406 493
 				$sth = $this->db->prepare($query);
407 494
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -409,7 +496,9 @@  discard block
 block discarded – undo
409 496
 				echo "error : ".$e->getMessage();
410 497
 			}
411 498
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
412
-		} else $all = array();
499
+		} else {
500
+			$all = array();
501
+		}
413 502
                 if (empty($all)) {
414 503
 			$filters = array('airlines' => array($stats_airline));
415 504
 			if ($filter_name != '') {
@@ -422,10 +511,15 @@  discard block
 block discarded – undo
422 511
 	}
423 512
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
424 513
 		global $globalStatsFilters;
425
-		if ($filter_name == '') $filter_name = $this->filter_name;
514
+		if ($filter_name == '') {
515
+			$filter_name = $this->filter_name;
516
+		}
426 517
 		if ($year == '' && $month == '') {
427
-			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 FROM stats_airport WHERE 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";
428
-			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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
518
+			if ($limit) {
519
+				$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 FROM stats_airport WHERE 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";
520
+			} else {
521
+				$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 FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
522
+			}
429 523
 			try {
430 524
 				$sth = $this->db->prepare($query);
431 525
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -433,7 +527,9 @@  discard block
 block discarded – undo
433 527
 				echo "error : ".$e->getMessage();
434 528
 			}
435 529
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
436
-		} else $all = array();
530
+		} else {
531
+			$all = array();
532
+		}
437 533
                 if (empty($all)) {
438 534
 			$filters = array('airlines' => array($stats_airline));
439 535
             		if ($filter_name != '') {
@@ -452,7 +548,9 @@  discard block
 block discarded – undo
452 548
         			$icao = $value['airport_departure_icao'];
453 549
         			if (isset($all[$icao])) {
454 550
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
-        			} else $all[$icao] = $value;
551
+        			} else {
552
+        				$all[$icao] = $value;
553
+        			}
456 554
         		}
457 555
         		$count = array();
458 556
         		foreach ($all as $key => $row) {
@@ -464,10 +562,15 @@  discard block
 block discarded – undo
464 562
 	}
465 563
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
466 564
 		global $globalStatsFilters;
467
-		if ($filter_name == '') $filter_name = $this->filter_name;
565
+		if ($filter_name == '') {
566
+			$filter_name = $this->filter_name;
567
+		}
468 568
 		if ($year == '' && $month == '') {
469
-			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 FROM stats_airport WHERE 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";
470
-			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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
569
+			if ($limit) {
570
+				$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 FROM stats_airport WHERE 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";
571
+			} else {
572
+				$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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
573
+			}
471 574
 			try {
472 575
 				$sth = $this->db->prepare($query);
473 576
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -475,7 +578,9 @@  discard block
 block discarded – undo
475 578
 				echo "error : ".$e->getMessage();
476 579
 			}
477 580
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
478
-		} else $all = array();
581
+		} else {
582
+			$all = array();
583
+		}
479 584
 		if (empty($all)) {
480 585
 			$filters = array('airlines' => array($stats_airline));
481 586
 			if ($filter_name != '') {
@@ -494,7 +599,9 @@  discard block
 block discarded – undo
494 599
         			$icao = $value['airport_arrival_icao'];
495 600
         			if (isset($all[$icao])) {
496 601
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
-        			} else $all[$icao] = $value;
602
+        			} else {
603
+        				$all[$icao] = $value;
604
+        			}
498 605
         		}
499 606
         		$count = array();
500 607
         		foreach ($all as $key => $row) {
@@ -507,13 +614,21 @@  discard block
 block discarded – undo
507 614
 	}
508 615
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
509 616
 		global $globalDBdriver, $globalStatsFilters;
510
-		if ($filter_name == '') $filter_name = $this->filter_name;
617
+		if ($filter_name == '') {
618
+			$filter_name = $this->filter_name;
619
+		}
511 620
 		if ($globalDBdriver == 'mysql') {
512
-			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";
513
-			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";
621
+			if ($limit) {
622
+				$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";
623
+			} else {
624
+				$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";
625
+			}
514 626
 		} else {
515
-			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";
516
-			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";
627
+			if ($limit) {
628
+				$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";
629
+			} else {
630
+				$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";
631
+			}
517 632
 		}
518 633
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
519 634
                  try {
@@ -537,7 +652,9 @@  discard block
 block discarded – undo
537 652
 	
538 653
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
539 654
 		global $globalStatsFilters;
540
-		if ($filter_name == '') $filter_name = $this->filter_name;
655
+		if ($filter_name == '') {
656
+			$filter_name = $this->filter_name;
657
+		}
541 658
 		$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";
542 659
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
543 660
                  try {
@@ -559,7 +676,9 @@  discard block
 block discarded – undo
559 676
 	}
560 677
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
561 678
 		global $globalDBdriver, $globalStatsFilters;
562
-		if ($filter_name == '') $filter_name = $this->filter_name;
679
+		if ($filter_name == '') {
680
+			$filter_name = $this->filter_name;
681
+		}
563 682
 		if ($globalDBdriver == 'mysql') {
564 683
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
565 684
 		} else {
@@ -585,7 +704,9 @@  discard block
 block discarded – undo
585 704
 	}
586 705
 	public function countAllDates($stats_airline = '',$filter_name = '') {
587 706
 		global $globalStatsFilters;
588
-		if ($filter_name == '') $filter_name = $this->filter_name;
707
+		if ($filter_name == '') {
708
+			$filter_name = $this->filter_name;
709
+		}
589 710
 		$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";
590 711
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
591 712
                  try {
@@ -607,7 +728,9 @@  discard block
 block discarded – undo
607 728
 	}
608 729
 	public function countAllDatesByAirlines($filter_name = '') {
609 730
 		global $globalStatsFilters;
610
-		if ($filter_name == '') $filter_name = $this->filter_name;
731
+		if ($filter_name == '') {
732
+			$filter_name = $this->filter_name;
733
+		}
611 734
 		$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";
612 735
 		$query_data = array('filter_name' => $filter_name);
613 736
                  try {
@@ -629,7 +752,9 @@  discard block
 block discarded – undo
629 752
 	}
630 753
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
631 754
 		global $globalStatsFilters;
632
-		if ($filter_name == '') $filter_name = $this->filter_name;
755
+		if ($filter_name == '') {
756
+			$filter_name = $this->filter_name;
757
+		}
633 758
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634 759
                  try {
635 760
                         $sth = $this->db->prepare($query);
@@ -650,7 +775,9 @@  discard block
 block discarded – undo
650 775
 	}
651 776
 	public function countAllMilitaryMonths($filter_name = '') {
652 777
 		global $globalStatsFilters;
653
-		if ($filter_name == '') $filter_name = $this->filter_name;
778
+		if ($filter_name == '') {
779
+			$filter_name = $this->filter_name;
780
+		}
654 781
 	    	$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";
655 782
                  try {
656 783
                         $sth = $this->db->prepare($query);
@@ -671,9 +798,14 @@  discard block
 block discarded – undo
671 798
 	}
672 799
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
673 800
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
674
-		if ($filter_name == '') $filter_name = $this->filter_name;
675
-		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";
676
-		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";
801
+		if ($filter_name == '') {
802
+			$filter_name = $this->filter_name;
803
+		}
804
+		if ($limit) {
805
+			$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";
806
+		} else {
807
+			$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";
808
+		}
677 809
 		if ($orderby == 'hour') {
678 810
 			/*
679 811
 			if ($globalDBdriver == 'mysql') {
@@ -682,7 +814,9 @@  discard block
 block discarded – undo
682 814
 			*/
683 815
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
684 816
 		}
685
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
817
+		if ($orderby == 'count') {
818
+			$query .= " ORDER BY hour_count DESC";
819
+		}
686 820
                  try {
687 821
                         $sth = $this->db->prepare($query);
688 822
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -703,8 +837,12 @@  discard block
 block discarded – undo
703 837
 	
704 838
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
705 839
 		global $globalStatsFilters;
706
-		if ($filter_name == '') $filter_name = $this->filter_name;
707
-		if ($year == '') $year = date('Y');
840
+		if ($filter_name == '') {
841
+			$filter_name = $this->filter_name;
842
+		}
843
+		if ($year == '') {
844
+			$year = date('Y');
845
+		}
708 846
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
709 847
 		if (empty($all)) {
710 848
 			$filters = array('airlines' => array($stats_airline));
@@ -718,8 +856,12 @@  discard block
 block discarded – undo
718 856
 	}
719 857
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
720 858
 		global $globalStatsFilters;
721
-		if ($filter_name == '') $filter_name = $this->filter_name;
722
-		if ($year == '') $year = date('Y');
859
+		if ($filter_name == '') {
860
+			$filter_name = $this->filter_name;
861
+		}
862
+		if ($year == '') {
863
+			$year = date('Y');
864
+		}
723 865
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
724 866
 		if (empty($all)) {
725 867
 		        $filters = array();
@@ -733,8 +875,12 @@  discard block
 block discarded – undo
733 875
 	}
734 876
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
735 877
 		global $globalStatsFilters;
736
-		if ($filter_name == '') $filter_name = $this->filter_name;
737
-		if ($year == '') $year = date('Y');
878
+		if ($filter_name == '') {
879
+			$filter_name = $this->filter_name;
880
+		}
881
+		if ($year == '') {
882
+			$year = date('Y');
883
+		}
738 884
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
739 885
 		if (empty($all)) {
740 886
 			$filters = array('airlines' => array($stats_airline));
@@ -748,8 +894,12 @@  discard block
 block discarded – undo
748 894
 	}
749 895
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
750 896
 		global $globalStatsFilters;
751
-		if ($filter_name == '') $filter_name = $this->filter_name;
752
-		if ($year == '') $year = date('Y');
897
+		if ($filter_name == '') {
898
+			$filter_name = $this->filter_name;
899
+		}
900
+		if ($year == '') {
901
+			$year = date('Y');
902
+		}
753 903
 		$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
754 904
 		if (empty($all)) {
755 905
 			$filters = array('airlines' => array($stats_airline));
@@ -763,7 +913,9 @@  discard block
 block discarded – undo
763 913
 	}
764 914
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
765 915
 		global $globalStatsFilters;
766
-		if ($filter_name == '') $filter_name = $this->filter_name;
916
+		if ($filter_name == '') {
917
+			$filter_name = $this->filter_name;
918
+		}
767 919
 		if ($year == '' && $month == '') {
768 920
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
769 921
 			try {
@@ -774,7 +926,9 @@  discard block
 block discarded – undo
774 926
 			}
775 927
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
776 928
 			$all = $result[0]['nb_airline'];
777
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
929
+		} else {
930
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
931
+		}
778 932
 		if (empty($all)) {
779 933
             		$filters = array();
780 934
             		if ($filter_name != '') {
@@ -787,8 +941,12 @@  discard block
 block discarded – undo
787 941
 	}
788 942
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
789 943
 		global $globalStatsFilters;
790
-		if ($filter_name == '') $filter_name = $this->filter_name;
791
-		if ($year == '') $year = date('Y');
944
+		if ($filter_name == '') {
945
+			$filter_name = $this->filter_name;
946
+		}
947
+		if ($year == '') {
948
+			$year = date('Y');
949
+		}
792 950
 		/*
793 951
 		$query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";
794 952
                  try {
@@ -813,8 +971,12 @@  discard block
 block discarded – undo
813 971
 	}
814 972
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
815 973
 		global $globalStatsFilters;
816
-		if ($filter_name == '') $filter_name = $this->filter_name;
817
-		if ($year == '') $year = date('Y');
974
+		if ($filter_name == '') {
975
+			$filter_name = $this->filter_name;
976
+		}
977
+		if ($year == '') {
978
+			$year = date('Y');
979
+		}
818 980
 		$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
819 981
 		if (empty($all)) {
820 982
 			$filters = array('airlines' => array($stats_airline));
@@ -828,7 +990,9 @@  discard block
 block discarded – undo
828 990
 	}
829 991
 
830 992
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
831
-		if ($filter_name == '') $filter_name = $this->filter_name;
993
+		if ($filter_name == '') {
994
+			$filter_name = $this->filter_name;
995
+		}
832 996
 		$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";
833 997
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
834 998
                  try {
@@ -841,7 +1005,9 @@  discard block
 block discarded – undo
841 1005
                 return $all;
842 1006
 	}
843 1007
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
844
-		if ($filter_name == '') $filter_name = $this->filter_name;
1008
+		if ($filter_name == '') {
1009
+			$filter_name = $this->filter_name;
1010
+		}
845 1011
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
846 1012
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
847 1013
                  try {
@@ -854,7 +1020,9 @@  discard block
 block discarded – undo
854 1020
                 return $all;
855 1021
         }
856 1022
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
857
-		if ($filter_name == '') $filter_name = $this->filter_name;
1023
+		if ($filter_name == '') {
1024
+			$filter_name = $this->filter_name;
1025
+		}
858 1026
     		global $globalArchiveMonths, $globalDBdriver;
859 1027
     		if ($globalDBdriver == 'mysql') {
860 1028
     			if ($month == '') {
@@ -884,7 +1052,9 @@  discard block
 block discarded – undo
884 1052
         }
885 1053
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
886 1054
     		global $globalArchiveMonths, $globalDBdriver;
887
-		if ($filter_name == '') $filter_name = $this->filter_name;
1055
+		if ($filter_name == '') {
1056
+			$filter_name = $this->filter_name;
1057
+		}
888 1058
     		if ($globalDBdriver == 'mysql') {
889 1059
 			$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 = :stats_airline AND filter_name = :filter_name";
890 1060
 		} else {
@@ -902,7 +1072,9 @@  discard block
 block discarded – undo
902 1072
         }
903 1073
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
904 1074
     		global $globalArchiveMonths, $globalDBdriver;
905
-		if ($filter_name == '') $filter_name = $this->filter_name;
1075
+		if ($filter_name == '') {
1076
+			$filter_name = $this->filter_name;
1077
+		}
906 1078
     		if ($globalDBdriver == 'mysql') {
907 1079
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
908 1080
                 } else {
@@ -919,7 +1091,9 @@  discard block
 block discarded – undo
919 1091
         }
920 1092
 	public function getStatsAirlineTotal($filter_name = '') {
921 1093
     		global $globalArchiveMonths, $globalDBdriver;
922
-		if ($filter_name == '') $filter_name = $this->filter_name;
1094
+		if ($filter_name == '') {
1095
+			$filter_name = $this->filter_name;
1096
+		}
923 1097
     		if ($globalDBdriver == 'mysql') {
924 1098
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
925 1099
                 } else {
@@ -936,7 +1110,9 @@  discard block
 block discarded – undo
936 1110
         }
937 1111
 	public function getStatsOwnerTotal($filter_name = '') {
938 1112
     		global $globalArchiveMonths, $globalDBdriver;
939
-		if ($filter_name == '') $filter_name = $this->filter_name;
1113
+		if ($filter_name == '') {
1114
+			$filter_name = $this->filter_name;
1115
+		}
940 1116
     		if ($globalDBdriver == 'mysql') {
941 1117
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
942 1118
 		} else {
@@ -953,7 +1129,9 @@  discard block
 block discarded – undo
953 1129
         }
954 1130
 	public function getStatsPilotTotal($filter_name = '') {
955 1131
     		global $globalArchiveMonths, $globalDBdriver;
956
-		if ($filter_name == '') $filter_name = $this->filter_name;
1132
+		if ($filter_name == '') {
1133
+			$filter_name = $this->filter_name;
1134
+		}
957 1135
     		if ($globalDBdriver == 'mysql') {
958 1136
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
959 1137
             	} else {
@@ -971,7 +1149,9 @@  discard block
 block discarded – undo
971 1149
 
972 1150
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
973 1151
 		global $globalDBdriver;
974
-		if ($filter_name == '') $filter_name = $this->filter_name;
1152
+		if ($filter_name == '') {
1153
+			$filter_name = $this->filter_name;
1154
+		}
975 1155
 		if ($globalDBdriver == 'mysql') {
976 1156
 			$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";
977 1157
                 } else {
@@ -987,7 +1167,9 @@  discard block
 block discarded – undo
987 1167
         }
988 1168
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
989 1169
 		global $globalDBdriver;
990
-		if ($filter_name == '') $filter_name = $this->filter_name;
1170
+		if ($filter_name == '') {
1171
+			$filter_name = $this->filter_name;
1172
+		}
991 1173
 		if ($globalDBdriver == 'mysql') {
992 1174
 			$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";
993 1175
 		} else {
@@ -1373,10 +1555,14 @@  discard block
 block discarded – undo
1373 1555
     		$Connection = new Connection();
1374 1556
     		date_default_timezone_set('UTC');
1375 1557
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1376
-			if ($globalDebug) echo 'Update stats !'."\n";
1558
+			if ($globalDebug) {
1559
+				echo 'Update stats !'."\n";
1560
+			}
1377 1561
 			if (isset($last_update[0]['value'])) {
1378 1562
 				$last_update_day = $last_update[0]['value'];
1379
-			} else $last_update_day = '2012-12-12 12:12:12';
1563
+			} else {
1564
+				$last_update_day = '2012-12-12 12:12:12';
1565
+			}
1380 1566
 			$reset = false;
1381 1567
 			if ($globalStatsResetYear) {
1382 1568
 				$reset = true;
@@ -1384,42 +1570,60 @@  discard block
 block discarded – undo
1384 1570
 			}
1385 1571
 			$Spotter = new Spotter($this->db);
1386 1572
 
1387
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1573
+			if ($globalDebug) {
1574
+				echo 'Count all aircraft types...'."\n";
1575
+			}
1388 1576
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1389 1577
 			foreach ($alldata as $number) {
1390 1578
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1391 1579
 			}
1392
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1580
+			if ($globalDebug) {
1581
+				echo 'Count all airlines...'."\n";
1582
+			}
1393 1583
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1394 1584
 			foreach ($alldata as $number) {
1395 1585
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1396 1586
 			}
1397
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1587
+			if ($globalDebug) {
1588
+				echo 'Count all registrations...'."\n";
1589
+			}
1398 1590
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1399 1591
 			foreach ($alldata as $number) {
1400 1592
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1401 1593
 			}
1402
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1594
+			if ($globalDebug) {
1595
+				echo 'Count all callsigns...'."\n";
1596
+			}
1403 1597
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1404 1598
 			foreach ($alldata as $number) {
1405 1599
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1406 1600
 			}
1407
-			if ($globalDebug) echo 'Count all owners...'."\n";
1601
+			if ($globalDebug) {
1602
+				echo 'Count all owners...'."\n";
1603
+			}
1408 1604
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1409 1605
 			foreach ($alldata as $number) {
1410 1606
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1411 1607
 			}
1412
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1608
+			if ($globalDebug) {
1609
+				echo 'Count all pilots...'."\n";
1610
+			}
1413 1611
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1414 1612
 			foreach ($alldata as $number) {
1415 1613
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1416 1614
 			}
1417 1615
 			
1418
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1616
+			if ($globalDebug) {
1617
+				echo 'Count all departure airports...'."\n";
1618
+			}
1419 1619
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1420
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1620
+			if ($globalDebug) {
1621
+				echo 'Count all detected departure airports...'."\n";
1622
+			}
1421 1623
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1422
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1624
+			if ($globalDebug) {
1625
+				echo 'Order departure airports...'."\n";
1626
+			}
1423 1627
 	        	$alldata = array();
1424 1628
 	        	
1425 1629
     			foreach ($pall as $value) {
@@ -1430,7 +1634,9 @@  discard block
 block discarded – undo
1430 1634
     				$icao = $value['airport_departure_icao'];
1431 1635
         			if (isset($alldata[$icao])) {
1432 1636
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1433
-        			} else $alldata[$icao] = $value;
1637
+        			} else {
1638
+        				$alldata[$icao] = $value;
1639
+        			}
1434 1640
 			}
1435 1641
     			$count = array();
1436 1642
     			foreach ($alldata as $key => $row) {
@@ -1440,11 +1646,17 @@  discard block
 block discarded – undo
1440 1646
 			foreach ($alldata as $number) {
1441 1647
 				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);
1442 1648
 			}
1443
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1649
+			if ($globalDebug) {
1650
+				echo 'Count all arrival airports...'."\n";
1651
+			}
1444 1652
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1445
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1653
+			if ($globalDebug) {
1654
+				echo 'Count all detected arrival airports...'."\n";
1655
+			}
1446 1656
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1447
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1657
+			if ($globalDebug) {
1658
+				echo 'Order arrival airports...'."\n";
1659
+			}
1448 1660
 	        	$alldata = array();
1449 1661
     			foreach ($pall as $value) {
1450 1662
 	        		$icao = $value['airport_arrival_icao'];
@@ -1454,7 +1666,9 @@  discard block
 block discarded – undo
1454 1666
     				$icao = $value['airport_arrival_icao'];
1455 1667
         			if (isset($alldata[$icao])) {
1456 1668
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1457
-	        		} else $alldata[$icao] = $value;
1669
+	        		} else {
1670
+	        			$alldata[$icao] = $value;
1671
+	        		}
1458 1672
     			}
1459 1673
         		$count = array();
1460 1674
         		foreach ($alldata as $key => $row) {
@@ -1465,7 +1679,9 @@  discard block
 block discarded – undo
1465 1679
 				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);
1466 1680
 			}
1467 1681
 			if ($Connection->tableExists('countries')) {
1468
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1682
+				if ($globalDebug) {
1683
+					echo 'Count all flights by countries...'."\n";
1684
+				}
1469 1685
 				$SpotterArchive = new SpotterArchive();
1470 1686
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1471 1687
 				foreach ($alldata as $number) {
@@ -1477,46 +1693,66 @@  discard block
 block discarded – undo
1477 1693
 			// Add by month using getstat if month finish...
1478 1694
 
1479 1695
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1480
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1696
+			if ($globalDebug) {
1697
+				echo 'Count all flights by months...'."\n";
1698
+			}
1481 1699
 			$Spotter = new Spotter($this->db);
1482 1700
 			$alldata = $Spotter->countAllMonths();
1483 1701
 			$lastyear = false;
1484 1702
 			foreach ($alldata as $number) {
1485
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1703
+				if ($number['year_name'] != date('Y')) {
1704
+					$lastyear = true;
1705
+				}
1486 1706
 				$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'])));
1487 1707
 			}
1488
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1708
+			if ($globalDebug) {
1709
+				echo 'Count all military flights by months...'."\n";
1710
+			}
1489 1711
 			$alldata = $Spotter->countAllMilitaryMonths();
1490 1712
 			foreach ($alldata as $number) {
1491 1713
 				$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'])));
1492 1714
 			}
1493
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1715
+			if ($globalDebug) {
1716
+				echo 'Count all owners by months...'."\n";
1717
+			}
1494 1718
 			$alldata = $Spotter->countAllMonthsOwners();
1495 1719
 			foreach ($alldata as $number) {
1496 1720
 				$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'])));
1497 1721
 			}
1498
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1722
+			if ($globalDebug) {
1723
+				echo 'Count all pilots by months...'."\n";
1724
+			}
1499 1725
 			$alldata = $Spotter->countAllMonthsPilots();
1500 1726
 			foreach ($alldata as $number) {
1501 1727
 				$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'])));
1502 1728
 			}
1503
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1729
+			if ($globalDebug) {
1730
+				echo 'Count all airlines by months...'."\n";
1731
+			}
1504 1732
 			$alldata = $Spotter->countAllMonthsAirlines();
1505 1733
 			foreach ($alldata as $number) {
1506 1734
 				$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'])));
1507 1735
 			}
1508
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1736
+			if ($globalDebug) {
1737
+				echo 'Count all aircrafts by months...'."\n";
1738
+			}
1509 1739
 			$alldata = $Spotter->countAllMonthsAircrafts();
1510 1740
 			foreach ($alldata as $number) {
1511 1741
 				$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'])));
1512 1742
 			}
1513
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1743
+			if ($globalDebug) {
1744
+				echo 'Count all real arrivals by months...'."\n";
1745
+			}
1514 1746
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1515 1747
 			foreach ($alldata as $number) {
1516 1748
 				$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'])));
1517 1749
 			}
1518
-			if ($globalDebug) echo 'Airports data...'."\n";
1519
-			if ($globalDebug) echo '...Departure'."\n";
1750
+			if ($globalDebug) {
1751
+				echo 'Airports data...'."\n";
1752
+			}
1753
+			if ($globalDebug) {
1754
+				echo '...Departure'."\n";
1755
+			}
1520 1756
 			$this->deleteStatAirport('daily');
1521 1757
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1522 1758
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1636,37 +1872,53 @@  discard block
 block discarded – undo
1636 1872
 
1637 1873
 			// Count by airlines
1638 1874
 			echo '--- Stats by airlines ---'."\n";
1639
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1875
+			if ($globalDebug) {
1876
+				echo 'Count all aircraft types by airlines...'."\n";
1877
+			}
1640 1878
 			$Spotter = new Spotter($this->db);
1641 1879
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1642 1880
 			foreach ($alldata as $number) {
1643 1881
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1644 1882
 			}
1645
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1883
+			if ($globalDebug) {
1884
+				echo 'Count all aircraft registrations by airlines...'."\n";
1885
+			}
1646 1886
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1647 1887
 			foreach ($alldata as $number) {
1648 1888
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1649 1889
 			}
1650
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1890
+			if ($globalDebug) {
1891
+				echo 'Count all callsigns by airlines...'."\n";
1892
+			}
1651 1893
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1652 1894
 			foreach ($alldata as $number) {
1653 1895
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1654 1896
 			}
1655
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1897
+			if ($globalDebug) {
1898
+				echo 'Count all owners by airlines...'."\n";
1899
+			}
1656 1900
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1657 1901
 			foreach ($alldata as $number) {
1658 1902
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1659 1903
 			}
1660
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1904
+			if ($globalDebug) {
1905
+				echo 'Count all pilots by airlines...'."\n";
1906
+			}
1661 1907
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1662 1908
 			foreach ($alldata as $number) {
1663 1909
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1664 1910
 			}
1665
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1911
+			if ($globalDebug) {
1912
+				echo 'Count all departure airports by airlines...'."\n";
1913
+			}
1666 1914
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1667
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1915
+			if ($globalDebug) {
1916
+				echo 'Count all detected departure airports by airlines...'."\n";
1917
+			}
1668 1918
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1669
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1919
+			if ($globalDebug) {
1920
+				echo 'Order detected departure airports by airlines...'."\n";
1921
+			}
1670 1922
 	        	//$alldata = array();
1671 1923
     			foreach ($dall as $value) {
1672 1924
     				$icao = $value['airport_departure_icao'];
@@ -1687,11 +1939,17 @@  discard block
 block discarded – undo
1687 1939
 			foreach ($alldata as $number) {
1688 1940
 				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);
1689 1941
 			}
1690
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1942
+			if ($globalDebug) {
1943
+				echo 'Count all arrival airports by airlines...'."\n";
1944
+			}
1691 1945
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1692
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1946
+			if ($globalDebug) {
1947
+				echo 'Count all detected arrival airports by airlines...'."\n";
1948
+			}
1693 1949
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1694
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1950
+			if ($globalDebug) {
1951
+				echo 'Order arrival airports by airlines...'."\n";
1952
+			}
1695 1953
 	        	//$alldata = array();
1696 1954
     			foreach ($dall as $value) {
1697 1955
     				$icao = $value['airport_arrival_icao'];
@@ -1710,37 +1968,53 @@  discard block
 block discarded – undo
1710 1968
     			}
1711 1969
     			$alldata = $pall;
1712 1970
                         foreach ($alldata as $number) {
1713
-				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);
1971
+				if ($number['airline_icao'] != '') {
1972
+					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);
1973
+				}
1974
+			}
1975
+			if ($globalDebug) {
1976
+				echo 'Count all flights by months by airlines...'."\n";
1714 1977
 			}
1715
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1716 1978
 			$Spotter = new Spotter($this->db);
1717 1979
 			$alldata = $Spotter->countAllMonthsByAirlines();
1718 1980
 			$lastyear = false;
1719 1981
 			foreach ($alldata as $number) {
1720
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1982
+				if ($number['year_name'] != date('Y')) {
1983
+					$lastyear = true;
1984
+				}
1721 1985
 				$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']);
1722 1986
 			}
1723
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1987
+			if ($globalDebug) {
1988
+				echo 'Count all owners by months by airlines...'."\n";
1989
+			}
1724 1990
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1725 1991
 			foreach ($alldata as $number) {
1726 1992
 				$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']);
1727 1993
 			}
1728
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1994
+			if ($globalDebug) {
1995
+				echo 'Count all pilots by months by airlines...'."\n";
1996
+			}
1729 1997
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1730 1998
 			foreach ($alldata as $number) {
1731 1999
 				$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']);
1732 2000
 			}
1733
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2001
+			if ($globalDebug) {
2002
+				echo 'Count all aircrafts by months by airlines...'."\n";
2003
+			}
1734 2004
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1735 2005
 			foreach ($alldata as $number) {
1736 2006
 				$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']);
1737 2007
 			}
1738
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2008
+			if ($globalDebug) {
2009
+				echo 'Count all real arrivals by months by airlines...'."\n";
2010
+			}
1739 2011
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1740 2012
 			foreach ($alldata as $number) {
1741 2013
 				$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']);
1742 2014
 			}
1743
-			if ($globalDebug) echo '...Departure'."\n";
2015
+			if ($globalDebug) {
2016
+				echo '...Departure'."\n";
2017
+			}
1744 2018
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1745 2019
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1746 2020
     			foreach ($dall as $value) {
@@ -1763,7 +2037,9 @@  discard block
 block discarded – undo
1763 2037
 			foreach ($alldata as $number) {
1764 2038
 				$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']);
1765 2039
 			}
1766
-			if ($globalDebug) echo '...Arrival'."\n";
2040
+			if ($globalDebug) {
2041
+				echo '...Arrival'."\n";
2042
+			}
1767 2043
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1768 2044
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1769 2045
     			foreach ($dall as $value) {
@@ -1787,13 +2063,19 @@  discard block
 block discarded – undo
1787 2063
 				$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']);
1788 2064
 			}
1789 2065
 
1790
-			if ($globalDebug) echo 'Flights data...'."\n";
1791
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2066
+			if ($globalDebug) {
2067
+				echo 'Flights data...'."\n";
2068
+			}
2069
+			if ($globalDebug) {
2070
+				echo '-> countAllDatesLastMonth...'."\n";
2071
+			}
1792 2072
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1793 2073
 			foreach ($alldata as $number) {
1794 2074
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1795 2075
 			}
1796
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2076
+			if ($globalDebug) {
2077
+				echo '-> countAllDates...'."\n";
2078
+			}
1797 2079
 			//$previousdata = $this->countAllDatesByAirlines();
1798 2080
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1799 2081
 			$values = array();
@@ -1806,7 +2088,9 @@  discard block
 block discarded – undo
1806 2088
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1807 2089
 			}
1808 2090
 			
1809
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2091
+			if ($globalDebug) {
2092
+				echo '-> countAllHours...'."\n";
2093
+			}
1810 2094
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1811 2095
 			foreach ($alldata as $number) {
1812 2096
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1814,7 +2098,9 @@  discard block
 block discarded – undo
1814 2098
 			
1815 2099
 
1816 2100
 			// Stats by filters
1817
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2101
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2102
+				$globalStatsFilters = array();
2103
+			}
1818 2104
 			foreach ($globalStatsFilters as $name => $filter) {
1819 2105
 				//$filter_name = $filter['name'];
1820 2106
 				$filter_name = $name;
@@ -1822,11 +2108,15 @@  discard block
 block discarded – undo
1822 2108
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1823 2109
 				if (isset($last_update[0]['value'])) {
1824 2110
 					$last_update_day = $last_update[0]['value'];
1825
-				} else $last_update_day = '2012-12-12 12:12:12';
2111
+				} else {
2112
+					$last_update_day = '2012-12-12 12:12:12';
2113
+				}
1826 2114
 				$reset = false;
1827 2115
 
1828 2116
 				// Count by filter
1829
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2117
+				if ($globalDebug) {
2118
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2119
+				}
1830 2120
 				$Spotter = new Spotter($this->db);
1831 2121
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1832 2122
 				foreach ($alldata as $number) {
@@ -1863,7 +2153,9 @@  discard block
 block discarded – undo
1863 2153
 	    				$icao = $value['airport_departure_icao'];
1864 2154
         				if (isset($alldata[$icao])) {
1865 2155
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1866
-        				} else $alldata[$icao] = $value;
2156
+        				} else {
2157
+        					$alldata[$icao] = $value;
2158
+        				}
1867 2159
 				}
1868 2160
 	    			$count = array();
1869 2161
     				foreach ($alldata as $key => $row) {
@@ -1884,7 +2176,9 @@  discard block
 block discarded – undo
1884 2176
 	    				$icao = $value['airport_arrival_icao'];
1885 2177
         				if (isset($alldata[$icao])) {
1886 2178
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1887
-		        		} else $alldata[$icao] = $value;
2179
+		        		} else {
2180
+		        			$alldata[$icao] = $value;
2181
+		        		}
1888 2182
 	    			}
1889 2183
         			$count = array();
1890 2184
         			foreach ($alldata as $key => $row) {
@@ -1898,7 +2192,9 @@  discard block
 block discarded – undo
1898 2192
 				$alldata = $Spotter->countAllMonths($filter);
1899 2193
 				$lastyear = false;
1900 2194
 				foreach ($alldata as $number) {
1901
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2195
+					if ($number['year_name'] != date('Y')) {
2196
+						$lastyear = true;
2197
+					}
1902 2198
 					$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);
1903 2199
 				}
1904 2200
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.
Indentation   +757 added lines, -757 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
15 15
 		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-        }
18
+		}
19 19
               
20 20
 	public function addLastStatsUpdate($type,$stats_date) {
21
-                $query = "DELETE FROM config WHERE name = :type;
21
+				$query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
-                 try {
25
-                        $sth = $this->db->prepare($query);
26
-                        $sth->execute($query_values);
27
-                } catch(PDOException $e) {
28
-                        return "error : ".$e->getMessage();
29
-                }
30
-        }
23
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
24
+				 try {
25
+						$sth = $this->db->prepare($query);
26
+						$sth->execute($query_values);
27
+				} catch(PDOException $e) {
28
+						return "error : ".$e->getMessage();
29
+				}
30
+		}
31 31
 
32 32
 	public function getLastStatsUpdate($type = 'last_update_stats') {
33
-                $query = "SELECT value FROM config WHERE name = :type";
34
-                 try {
35
-                        $sth = $this->db->prepare($query);
36
-                        $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
38
-                        echo "error : ".$e->getMessage();
39
-                }
40
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
-                return $all;
42
-        }
43
-        public function deleteStats($filter_name = '') {
44
-        	/*
33
+				$query = "SELECT value FROM config WHERE name = :type";
34
+				 try {
35
+						$sth = $this->db->prepare($query);
36
+						$sth->execute(array(':type' => $type));
37
+				} catch(PDOException $e) {
38
+						echo "error : ".$e->getMessage();
39
+				}
40
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
+				return $all;
42
+		}
43
+		public function deleteStats($filter_name = '') {
44
+			/*
45 45
         	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
46 46
                  try {
47 47
                         $sth = $this->db->prepare($query);
@@ -50,106 +50,106 @@  discard block
 block discarded – undo
50 50
                         return "error : ".$e->getMessage();
51 51
                 }
52 52
                 */
53
-        	$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport 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_flight 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;";
54
-                 try {
55
-                        $sth = $this->db->prepare($query);
56
-                        $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-        }
61
-        public function deleteOldStats($filter_name = '') {
53
+			$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport 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_flight 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;";
54
+				 try {
55
+						$sth = $this->db->prepare($query);
56
+						$sth->execute(array(':filter_name' => $filter_name));
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+		}
61
+		public function deleteOldStats($filter_name = '') {
62 62
         	
63
-        	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
-                 try {
65
-                        $sth = $this->db->prepare($query);
66
-                        $sth->execute();
67
-                } catch(PDOException $e) {
68
-                        return "error : ".$e->getMessage();
69
-                }
63
+			$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
+				 try {
65
+						$sth = $this->db->prepare($query);
66
+						$sth->execute();
67
+				} catch(PDOException $e) {
68
+						return "error : ".$e->getMessage();
69
+				}
70 70
                 
71
-        	$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;";
72
-                 try {
73
-                        $sth = $this->db->prepare($query);
74
-                        $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
76
-                        return "error : ".$e->getMessage();
77
-                }
78
-        }
71
+			$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;";
72
+				 try {
73
+						$sth = $this->db->prepare($query);
74
+						$sth->execute(array(':filter_name' => $filter_name));
75
+				} catch(PDOException $e) {
76
+						return "error : ".$e->getMessage();
77
+				}
78
+		}
79 79
 	public function getAllAirlineNames($filter_name = '') {
80 80
 		if ($filter_name == '') $filter_name = $this->filter_name;
81
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
-                 try {
83
-                        $sth = $this->db->prepare($query);
84
-                        $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
86
-                        echo "error : ".$e->getMessage();
87
-                }
88
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
-                return $all;
90
-        }
81
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
+				 try {
83
+						$sth = $this->db->prepare($query);
84
+						$sth->execute(array(':filter_name' => $filter_name));
85
+				} catch(PDOException $e) {
86
+						echo "error : ".$e->getMessage();
87
+				}
88
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
+				return $all;
90
+		}
91 91
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
-                 try {
95
-                        $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
98
-                        echo "error : ".$e->getMessage();
99
-                }
100
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
-                return $all;
102
-        }
93
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
+				 try {
95
+						$sth = $this->db->prepare($query);
96
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
+				} catch(PDOException $e) {
98
+						echo "error : ".$e->getMessage();
99
+				}
100
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
+				return $all;
102
+		}
103 103
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105
-                $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";
106
-                 try {
107
-                        $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
110
-                        echo "error : ".$e->getMessage();
111
-                }
112
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
-                return $all;
114
-        }
105
+				$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";
106
+				 try {
107
+						$sth = $this->db->prepare($query);
108
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
+				} catch(PDOException $e) {
110
+						echo "error : ".$e->getMessage();
111
+				}
112
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
+				return $all;
114
+		}
115 115
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117
-                $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";
118
-                 try {
119
-                        $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
122
-                        echo "error : ".$e->getMessage();
123
-                }
124
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
-                return $all;
126
-        }
117
+				$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";
118
+				 try {
119
+						$sth = $this->db->prepare($query);
120
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
+				} catch(PDOException $e) {
122
+						echo "error : ".$e->getMessage();
123
+				}
124
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
+				return $all;
126
+		}
127 127
 
128 128
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130
-                $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
-                 try {
132
-                        $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
135
-                        echo "error : ".$e->getMessage();
136
-                }
137
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
-                return $all;
139
-        }
130
+				$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
+				 try {
132
+						$sth = $this->db->prepare($query);
133
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
+				} catch(PDOException $e) {
135
+						echo "error : ".$e->getMessage();
136
+				}
137
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
+				return $all;
139
+		}
140 140
 
141 141
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143
-                $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
-                 try {
145
-                        $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
148
-                        echo "error : ".$e->getMessage();
149
-                }
150
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
-                return $all;
152
-        }
143
+				$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
+				 try {
145
+						$sth = $this->db->prepare($query);
146
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
+				} catch(PDOException $e) {
148
+						echo "error : ".$e->getMessage();
149
+				}
150
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
+				return $all;
152
+		}
153 153
 
154 154
 
155 155
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168 168
 		} else $all = array();
169
-                if (empty($all)) {
170
-            	    $filters = array('airlines' => array($stats_airline));
171
-            	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
-            	    }
174
-            	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
-                }
177
-                return $all;
169
+				if (empty($all)) {
170
+					$filters = array('airlines' => array($stats_airline));
171
+					if ($filter_name != '') {
172
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
+					}
174
+					$Spotter = new Spotter($this->db);
175
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
+				}
177
+				return $all;
178 178
 	}
179 179
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 180
 		global $globalStatsFilters;
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192 192
 		} else $all = array();
193
-                if (empty($all)) {
194
-            		$Spotter = new Spotter($this->db);
195
-            		$filters = array();
196
-            		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
193
+				if (empty($all)) {
194
+					$Spotter = new Spotter($this->db);
195
+					$filters = array();
196
+					if ($filter_name != '') {
197
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
-                }
201
-                return $all;
199
+					$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
+				}
201
+				return $all;
202 202
 	}
203 203
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 204
 		global $globalStatsFilters;
@@ -239,37 +239,37 @@  discard block
 block discarded – undo
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241 241
 		} else $all = array();
242
-                if (empty($all)) {
242
+				if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
244 244
 			if ($filter_name != '') {
245
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Spotter = new Spotter($this->db);
248 248
 			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
249
-                }
250
-                return $all;
249
+				}
250
+				return $all;
251 251
 	}
252 252
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 253
 		global $globalStatsFilters;
254 254
 		if ($filter_name == '') $filter_name = $this->filter_name;
255 255
 		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
256 256
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
257
-                 try {
258
-                        $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
261
-                        echo "error : ".$e->getMessage();
262
-                }
263
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
-                if (empty($all)) {
257
+				 try {
258
+						$sth = $this->db->prepare($query);
259
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
+				} catch(PDOException $e) {
261
+						echo "error : ".$e->getMessage();
262
+				}
263
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
+				if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270 270
 			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
271
-                }
272
-                return $all;
271
+				}
272
+				return $all;
273 273
 	}
274 274
 
275 275
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 			}
287 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
288 288
 		} else $all = array();
289
-                if (empty($all)) {
290
-	                $Spotter = new Spotter($this->db);
291
-            		$filters = array();
292
-            		if ($filter_name != '') {
293
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
289
+				if (empty($all)) {
290
+					$Spotter = new Spotter($this->db);
291
+					$filters = array();
292
+					if ($filter_name != '') {
293
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
294 294
 			}
295 295
 
296
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
-                }
298
-                return $all;
296
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
+				}
298
+				return $all;
299 299
 	}
300 300
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
301 301
 		global $globalStatsFilters;
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
 			}
312 312
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313 313
 		} else $all = array();
314
-                if (empty($all)) {
314
+				if (empty($all)) {
315 315
 			$filters = array('airlines' => array($stats_airline));
316 316
 			if ($filter_name != '') {
317 317
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
318 318
 			}
319
-	                $Spotter = new Spotter($this->db);
320
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
-                }
322
-                return $all;
319
+					$Spotter = new Spotter($this->db);
320
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
+				}
322
+				return $all;
323 323
 	}
324 324
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
325 325
 		global $globalStatsFilters;
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 					echo "error : ".$e->getMessage();
360 360
 				}
361 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
362
-                /*
362
+				/*
363 363
                 if (empty($all)) {
364 364
 	                $Spotter = new Spotter($this->db);
365 365
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -410,15 +410,15 @@  discard block
 block discarded – undo
410 410
 			}
411 411
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
412 412
 		} else $all = array();
413
-                if (empty($all)) {
413
+				if (empty($all)) {
414 414
 			$filters = array('airlines' => array($stats_airline));
415 415
 			if ($filter_name != '') {
416 416
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
417 417
 			}
418
-            		$Spotter = new Spotter($this->db);
419
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
-                }
421
-                return $all;
418
+					$Spotter = new Spotter($this->db);
419
+					$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
+				}
421
+				return $all;
422 422
 	}
423 423
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
424 424
 		global $globalStatsFilters;
@@ -434,33 +434,33 @@  discard block
 block discarded – undo
434 434
 			}
435 435
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
436 436
 		} else $all = array();
437
-                if (empty($all)) {
437
+				if (empty($all)) {
438 438
 			$filters = array('airlines' => array($stats_airline));
439
-            		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
-			}
442
-            		$Spotter = new Spotter($this->db);
443
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
-        		$all = array();
446
-        		foreach ($pall as $value) {
447
-        			$icao = $value['airport_departure_icao'];
448
-        			$all[$icao] = $value;
449
-        		}
439
+					if ($filter_name != '') {
440
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
+			}
442
+					$Spotter = new Spotter($this->db);
443
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
+				$all = array();
446
+				foreach ($pall as $value) {
447
+					$icao = $value['airport_departure_icao'];
448
+					$all[$icao] = $value;
449
+				}
450 450
         		
451
-        		foreach ($dall as $value) {
452
-        			$icao = $value['airport_departure_icao'];
453
-        			if (isset($all[$icao])) {
454
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
-        			} else $all[$icao] = $value;
456
-        		}
457
-        		$count = array();
458
-        		foreach ($all as $key => $row) {
459
-        			$count[$key] = $row['airport_departure_icao_count'];
460
-        		}
461
-        		array_multisort($count,SORT_DESC,$all);
462
-                }
463
-                return $all;
451
+				foreach ($dall as $value) {
452
+					$icao = $value['airport_departure_icao'];
453
+					if (isset($all[$icao])) {
454
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
+					} else $all[$icao] = $value;
456
+				}
457
+				$count = array();
458
+				foreach ($all as $key => $row) {
459
+					$count[$key] = $row['airport_departure_icao_count'];
460
+				}
461
+				array_multisort($count,SORT_DESC,$all);
462
+				}
463
+				return $all;
464 464
 	}
465 465
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
466 466
 		global $globalStatsFilters;
@@ -484,26 +484,26 @@  discard block
 block discarded – undo
484 484
 			$Spotter = new Spotter($this->db);
485 485
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
486 486
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
487
-        		$all = array();
488
-        		foreach ($pall as $value) {
489
-        			$icao = $value['airport_arrival_icao'];
490
-        			$all[$icao] = $value;
491
-        		}
487
+				$all = array();
488
+				foreach ($pall as $value) {
489
+					$icao = $value['airport_arrival_icao'];
490
+					$all[$icao] = $value;
491
+				}
492 492
         		
493
-        		foreach ($dall as $value) {
494
-        			$icao = $value['airport_arrival_icao'];
495
-        			if (isset($all[$icao])) {
496
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
-        			} else $all[$icao] = $value;
498
-        		}
499
-        		$count = array();
500
-        		foreach ($all as $key => $row) {
501
-        			$count[$key] = $row['airport_arrival_icao_count'];
502
-        		}
503
-        		array_multisort($count,SORT_DESC,$all);
504
-                }
493
+				foreach ($dall as $value) {
494
+					$icao = $value['airport_arrival_icao'];
495
+					if (isset($all[$icao])) {
496
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
+					} else $all[$icao] = $value;
498
+				}
499
+				$count = array();
500
+				foreach ($all as $key => $row) {
501
+					$count[$key] = $row['airport_arrival_icao_count'];
502
+				}
503
+				array_multisort($count,SORT_DESC,$all);
504
+				}
505 505
  
506
-                return $all;
506
+				return $all;
507 507
 	}
508 508
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
509 509
 		global $globalDBdriver, $globalStatsFilters;
@@ -516,23 +516,23 @@  discard block
 block discarded – undo
516 516
 			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";
517 517
 		}
518 518
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
519
-                 try {
520
-                        $sth = $this->db->prepare($query);
521
-                        $sth->execute($query_data);
522
-                } catch(PDOException $e) {
523
-                        echo "error : ".$e->getMessage();
524
-                }
525
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
-                if (empty($all)) {
519
+				 try {
520
+						$sth = $this->db->prepare($query);
521
+						$sth->execute($query_data);
522
+				} catch(PDOException $e) {
523
+						echo "error : ".$e->getMessage();
524
+				}
525
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
+				if (empty($all)) {
527 527
 			$filters = array('airlines' => array($stats_airline));
528 528
 			if ($filter_name != '') {
529 529
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
530 530
 			}
531
-            		$Spotter = new Spotter($this->db);
532
-            		$all = $Spotter->countAllMonthsLastYear($filters);
533
-                }
531
+					$Spotter = new Spotter($this->db);
532
+					$all = $Spotter->countAllMonthsLastYear($filters);
533
+				}
534 534
                 
535
-                return $all;
535
+				return $all;
536 536
 	}
537 537
 	
538 538
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -540,22 +540,22 @@  discard block
 block discarded – undo
540 540
 		if ($filter_name == '') $filter_name = $this->filter_name;
541 541
 		$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";
542 542
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
543
-                 try {
544
-                        $sth = $this->db->prepare($query);
545
-                        $sth->execute($query_data);
546
-                } catch(PDOException $e) {
547
-                        echo "error : ".$e->getMessage();
548
-                }
549
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
-                if (empty($all)) {
543
+				 try {
544
+						$sth = $this->db->prepare($query);
545
+						$sth->execute($query_data);
546
+				} catch(PDOException $e) {
547
+						echo "error : ".$e->getMessage();
548
+				}
549
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
+				if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553 553
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
554 554
 			}
555
-            		$Spotter = new Spotter($this->db);
556
-            		$all = $Spotter->countAllDatesLastMonth($filters);
557
-                }
558
-                return $all;
555
+					$Spotter = new Spotter($this->db);
556
+					$all = $Spotter->countAllDatesLastMonth($filters);
557
+				}
558
+				return $all;
559 559
 	}
560 560
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
561 561
 		global $globalDBdriver, $globalStatsFilters;
@@ -566,110 +566,110 @@  discard block
 block discarded – undo
566 566
 			$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";
567 567
 		}
568 568
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
569
-                 try {
570
-                        $sth = $this->db->prepare($query);
571
-                        $sth->execute($query_data);
572
-                } catch(PDOException $e) {
573
-                        echo "error : ".$e->getMessage();
574
-                }
575
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
-                if (empty($all)) {
569
+				 try {
570
+						$sth = $this->db->prepare($query);
571
+						$sth->execute($query_data);
572
+				} catch(PDOException $e) {
573
+						echo "error : ".$e->getMessage();
574
+				}
575
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
+				if (empty($all)) {
577 577
 			$filters = array('airlines' => array($stats_airline));
578 578
 			if ($filter_name != '') {
579 579
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
580 580
 			}
581
-            		$Spotter = new Spotter($this->db);
582
-            		$all = $Spotter->countAllDatesLast7Days($filters);
583
-                }
584
-                return $all;
581
+					$Spotter = new Spotter($this->db);
582
+					$all = $Spotter->countAllDatesLast7Days($filters);
583
+				}
584
+				return $all;
585 585
 	}
586 586
 	public function countAllDates($stats_airline = '',$filter_name = '') {
587 587
 		global $globalStatsFilters;
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		$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";
590 590
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
591
-                 try {
592
-                        $sth = $this->db->prepare($query);
593
-                        $sth->execute($query_data);
594
-                } catch(PDOException $e) {
595
-                        echo "error : ".$e->getMessage();
596
-                }
597
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
-                if (empty($all)) {
591
+				 try {
592
+						$sth = $this->db->prepare($query);
593
+						$sth->execute($query_data);
594
+				} catch(PDOException $e) {
595
+						echo "error : ".$e->getMessage();
596
+				}
597
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
+				if (empty($all)) {
599 599
 			$filters = array('airlines' => array($stats_airline));
600 600
 			if ($filter_name != '') {
601
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
601
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
602 602
 			}
603
-            		$Spotter = new Spotter($this->db);
604
-            		$all = $Spotter->countAllDates($filters);
605
-                }
606
-                return $all;
603
+					$Spotter = new Spotter($this->db);
604
+					$all = $Spotter->countAllDates($filters);
605
+				}
606
+				return $all;
607 607
 	}
608 608
 	public function countAllDatesByAirlines($filter_name = '') {
609 609
 		global $globalStatsFilters;
610 610
 		if ($filter_name == '') $filter_name = $this->filter_name;
611 611
 		$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";
612 612
 		$query_data = array('filter_name' => $filter_name);
613
-                 try {
614
-                        $sth = $this->db->prepare($query);
615
-                        $sth->execute($query_data);
616
-                } catch(PDOException $e) {
617
-                        echo "error : ".$e->getMessage();
618
-                }
619
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
-                if (empty($all)) {
621
-            		$filters = array();
622
-            		if ($filter_name != '') {
623
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
613
+				 try {
614
+						$sth = $this->db->prepare($query);
615
+						$sth->execute($query_data);
616
+				} catch(PDOException $e) {
617
+						echo "error : ".$e->getMessage();
618
+				}
619
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
+				if (empty($all)) {
621
+					$filters = array();
622
+					if ($filter_name != '') {
623
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
624 624
 			}
625
-            		$Spotter = new Spotter($this->db);
626
-            		$all = $Spotter->countAllDatesByAirlines($filters);
627
-                }
628
-                return $all;
625
+					$Spotter = new Spotter($this->db);
626
+					$all = $Spotter->countAllDatesByAirlines($filters);
627
+				}
628
+				return $all;
629 629
 	}
630 630
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
631 631
 		global $globalStatsFilters;
632 632
 		if ($filter_name == '') $filter_name = $this->filter_name;
633
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634
-                 try {
635
-                        $sth = $this->db->prepare($query);
636
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
-                } catch(PDOException $e) {
638
-                        echo "error : ".$e->getMessage();
639
-                }
640
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
633
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634
+				 try {
635
+						$sth = $this->db->prepare($query);
636
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
+				} catch(PDOException $e) {
638
+						echo "error : ".$e->getMessage();
639
+				}
640
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
641 641
                 
642
-                if (empty($all)) {
642
+				if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645 645
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
646 646
 			}
647
-            		$Spotter = new Spotter($this->db);
648
-            		$all = $Spotter->countAllMonths($filters);
649
-                }
647
+					$Spotter = new Spotter($this->db);
648
+					$all = $Spotter->countAllMonths($filters);
649
+				}
650 650
                 
651
-                return $all;
651
+				return $all;
652 652
 	}
653 653
 	public function countAllMilitaryMonths($filter_name = '') {
654 654
 		global $globalStatsFilters;
655 655
 		if ($filter_name == '') $filter_name = $this->filter_name;
656
-	    	$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";
657
-                 try {
658
-                        $sth = $this->db->prepare($query);
659
-                        $sth->execute(array(':filter_name' => $filter_name));
660
-                } catch(PDOException $e) {
661
-                        echo "error : ".$e->getMessage();
662
-                }
663
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
-                if (empty($all)) {
665
-            		$filters = array();
666
-            		if ($filter_name != '') {
667
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
656
+			$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";
657
+				 try {
658
+						$sth = $this->db->prepare($query);
659
+						$sth->execute(array(':filter_name' => $filter_name));
660
+				} catch(PDOException $e) {
661
+						echo "error : ".$e->getMessage();
662
+				}
663
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
+				if (empty($all)) {
665
+					$filters = array();
666
+					if ($filter_name != '') {
667
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
668 668
 			}
669
-            		$Spotter = new Spotter($this->db);
670
-            		$all = $Spotter->countAllMilitaryMonths($filters);
671
-                }
672
-                return $all;
669
+					$Spotter = new Spotter($this->db);
670
+					$all = $Spotter->countAllMilitaryMonths($filters);
671
+				}
672
+				return $all;
673 673
 	}
674 674
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
675 675
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -685,22 +685,22 @@  discard block
 block discarded – undo
685 685
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
686 686
 		}
687 687
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
688
-                 try {
689
-                        $sth = $this->db->prepare($query);
690
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
-                } catch(PDOException $e) {
692
-                        echo "error : ".$e->getMessage();
693
-                }
694
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
-                if (empty($all)) {
688
+				 try {
689
+						$sth = $this->db->prepare($query);
690
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
+				} catch(PDOException $e) {
692
+						echo "error : ".$e->getMessage();
693
+				}
694
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
+				if (empty($all)) {
696 696
 			$filters = array('airlines' => array($stats_airline));
697 697
 			if ($filter_name != '') {
698
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
698
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
699 699
 			}
700
-            		$Spotter = new Spotter($this->db);
701
-            		$all = $Spotter->countAllHours($orderby,$filters);
702
-                }
703
-                return $all;
700
+					$Spotter = new Spotter($this->db);
701
+					$all = $Spotter->countAllHours($orderby,$filters);
702
+				}
703
+				return $all;
704 704
 	}
705 705
 	
706 706
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
@@ -724,9 +724,9 @@  discard block
 block discarded – undo
724 724
 		if ($year == '') $year = date('Y');
725 725
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
726 726
 		if (empty($all)) {
727
-		        $filters = array();
728
-            		if ($filter_name != '') {
729
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
727
+				$filters = array();
728
+					if ($filter_name != '') {
729
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
730 730
 			}
731 731
 			$Spotter = new Spotter($this->db);
732 732
 			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -778,9 +778,9 @@  discard block
 block discarded – undo
778 778
 			$all = $result[0]['nb_airline'];
779 779
 		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
780 780
 		if (empty($all)) {
781
-            		$filters = array();
782
-            		if ($filter_name != '') {
783
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
781
+					$filters = array();
782
+					if ($filter_name != '') {
783
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
784 784
 			}
785 785
 			$Spotter = new Spotter($this->db);
786 786
 			$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -833,33 +833,33 @@  discard block
 block discarded – undo
833 833
 		if ($filter_name == '') $filter_name = $this->filter_name;
834 834
 		$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";
835 835
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
836
-                 try {
837
-                        $sth = $this->db->prepare($query);
838
-                        $sth->execute($query_values);
839
-                } catch(PDOException $e) {
840
-                        echo "error : ".$e->getMessage();
841
-                }
842
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
843
-                return $all;
836
+				 try {
837
+						$sth = $this->db->prepare($query);
838
+						$sth->execute($query_values);
839
+				} catch(PDOException $e) {
840
+						echo "error : ".$e->getMessage();
841
+				}
842
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
843
+				return $all;
844 844
 	}
845 845
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
846 846
 		if ($filter_name == '') $filter_name = $this->filter_name;
847
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
848
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
849
-                 try {
850
-                        $sth = $this->db->prepare($query);
851
-                        $sth->execute($query_values);
852
-                } catch(PDOException $e) {
853
-                        echo "error : ".$e->getMessage();
854
-                }
855
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
856
-                return $all;
857
-        }
847
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
848
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
849
+				 try {
850
+						$sth = $this->db->prepare($query);
851
+						$sth->execute($query_values);
852
+				} catch(PDOException $e) {
853
+						echo "error : ".$e->getMessage();
854
+				}
855
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
856
+				return $all;
857
+		}
858 858
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
859 859
 		if ($filter_name == '') $filter_name = $this->filter_name;
860
-    		global $globalArchiveMonths, $globalDBdriver;
861
-    		if ($globalDBdriver == 'mysql') {
862
-    			if ($month == '') {
860
+			global $globalArchiveMonths, $globalDBdriver;
861
+			if ($globalDBdriver == 'mysql') {
862
+				if ($month == '') {
863 863
 				$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";
864 864
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
865 865
 			} else {
@@ -874,137 +874,137 @@  discard block
 block discarded – undo
874 874
 				$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";
875 875
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
876 876
 			}
877
-                }
878
-                 try {
879
-                        $sth = $this->db->prepare($query);
880
-                        $sth->execute($query_values);
881
-                } catch(PDOException $e) {
882
-                        echo "error : ".$e->getMessage();
883
-                }
884
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
885
-                return $all[0]['total'];
886
-        }
877
+				}
878
+				 try {
879
+						$sth = $this->db->prepare($query);
880
+						$sth->execute($query_values);
881
+				} catch(PDOException $e) {
882
+						echo "error : ".$e->getMessage();
883
+				}
884
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
885
+				return $all[0]['total'];
886
+		}
887 887
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
888
-    		global $globalArchiveMonths, $globalDBdriver;
888
+			global $globalArchiveMonths, $globalDBdriver;
889 889
 		if ($filter_name == '') $filter_name = $this->filter_name;
890
-    		if ($globalDBdriver == 'mysql') {
890
+			if ($globalDBdriver == 'mysql') {
891 891
 			$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 = :stats_airline AND filter_name = :filter_name";
892 892
 		} else {
893 893
 			$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 = :stats_airline AND filter_name = :filter_name";
894
-                }
895
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
896
-                 try {
897
-                        $sth = $this->db->prepare($query);
898
-                        $sth->execute($query_values);
899
-                } catch(PDOException $e) {
900
-                        echo "error : ".$e->getMessage();
901
-                }
902
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
903
-                return $all[0]['total'];
904
-        }
894
+				}
895
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
896
+				 try {
897
+						$sth = $this->db->prepare($query);
898
+						$sth->execute($query_values);
899
+				} catch(PDOException $e) {
900
+						echo "error : ".$e->getMessage();
901
+				}
902
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
903
+				return $all[0]['total'];
904
+		}
905 905
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
906
-    		global $globalArchiveMonths, $globalDBdriver;
906
+			global $globalArchiveMonths, $globalDBdriver;
907 907
 		if ($filter_name == '') $filter_name = $this->filter_name;
908
-    		if ($globalDBdriver == 'mysql') {
908
+			if ($globalDBdriver == 'mysql') {
909 909
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
910
-                } else {
910
+				} else {
911 911
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
912
-                }
913
-                 try {
914
-                        $sth = $this->db->prepare($query);
915
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
916
-                } catch(PDOException $e) {
917
-                        echo "error : ".$e->getMessage();
918
-                }
919
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
920
-                return $all[0]['total'];
921
-        }
912
+				}
913
+				 try {
914
+						$sth = $this->db->prepare($query);
915
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
916
+				} catch(PDOException $e) {
917
+						echo "error : ".$e->getMessage();
918
+				}
919
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
920
+				return $all[0]['total'];
921
+		}
922 922
 	public function getStatsAirlineTotal($filter_name = '') {
923
-    		global $globalArchiveMonths, $globalDBdriver;
923
+			global $globalArchiveMonths, $globalDBdriver;
924 924
 		if ($filter_name == '') $filter_name = $this->filter_name;
925
-    		if ($globalDBdriver == 'mysql') {
925
+			if ($globalDBdriver == 'mysql') {
926 926
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
927
-                } else {
927
+				} else {
928 928
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
929
-                }
930
-                 try {
931
-                        $sth = $this->db->prepare($query);
932
-                        $sth->execute(array(':filter_name' => $filter_name));
933
-                } catch(PDOException $e) {
934
-                        echo "error : ".$e->getMessage();
935
-                }
936
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
937
-                return $all[0]['total'];
938
-        }
929
+				}
930
+				 try {
931
+						$sth = $this->db->prepare($query);
932
+						$sth->execute(array(':filter_name' => $filter_name));
933
+				} catch(PDOException $e) {
934
+						echo "error : ".$e->getMessage();
935
+				}
936
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
937
+				return $all[0]['total'];
938
+		}
939 939
 	public function getStatsOwnerTotal($filter_name = '') {
940
-    		global $globalArchiveMonths, $globalDBdriver;
940
+			global $globalArchiveMonths, $globalDBdriver;
941 941
 		if ($filter_name == '') $filter_name = $this->filter_name;
942
-    		if ($globalDBdriver == 'mysql') {
942
+			if ($globalDBdriver == 'mysql') {
943 943
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
944 944
 		} else {
945 945
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
946
-                }
947
-                 try {
948
-                        $sth = $this->db->prepare($query);
949
-                        $sth->execute(array(':filter_name' => $filter_name));
950
-                } catch(PDOException $e) {
951
-                        echo "error : ".$e->getMessage();
952
-                }
953
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
954
-                return $all[0]['total'];
955
-        }
946
+				}
947
+				 try {
948
+						$sth = $this->db->prepare($query);
949
+						$sth->execute(array(':filter_name' => $filter_name));
950
+				} catch(PDOException $e) {
951
+						echo "error : ".$e->getMessage();
952
+				}
953
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
954
+				return $all[0]['total'];
955
+		}
956 956
 	public function getStatsPilotTotal($filter_name = '') {
957
-    		global $globalArchiveMonths, $globalDBdriver;
957
+			global $globalArchiveMonths, $globalDBdriver;
958 958
 		if ($filter_name == '') $filter_name = $this->filter_name;
959
-    		if ($globalDBdriver == 'mysql') {
960
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
961
-            	} else {
962
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
963
-            	}
964
-                 try {
965
-                        $sth = $this->db->prepare($query);
966
-                        $sth->execute(array(':filter_name' => $filter_name));
967
-                } catch(PDOException $e) {
968
-                        echo "error : ".$e->getMessage();
969
-                }
970
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
971
-                return $all[0]['total'];
972
-        }
959
+			if ($globalDBdriver == 'mysql') {
960
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
961
+				} else {
962
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
963
+				}
964
+				 try {
965
+						$sth = $this->db->prepare($query);
966
+						$sth->execute(array(':filter_name' => $filter_name));
967
+				} catch(PDOException $e) {
968
+						echo "error : ".$e->getMessage();
969
+				}
970
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
971
+				return $all[0]['total'];
972
+		}
973 973
 
974 974
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
975 975
 		global $globalDBdriver;
976 976
 		if ($filter_name == '') $filter_name = $this->filter_name;
977 977
 		if ($globalDBdriver == 'mysql') {
978 978
 			$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";
979
-                } else {
979
+				} else {
980 980
 			$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);"; 
981 981
 		}
982
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
983
-                 try {
984
-                        $sth = $this->db->prepare($query);
985
-                        $sth->execute($query_values);
986
-                } catch(PDOException $e) {
987
-                        return "error : ".$e->getMessage();
988
-                }
989
-        }
982
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
983
+				 try {
984
+						$sth = $this->db->prepare($query);
985
+						$sth->execute($query_values);
986
+				} catch(PDOException $e) {
987
+						return "error : ".$e->getMessage();
988
+				}
989
+		}
990 990
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
991 991
 		global $globalDBdriver;
992 992
 		if ($filter_name == '') $filter_name = $this->filter_name;
993 993
 		if ($globalDBdriver == 'mysql') {
994 994
 			$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";
995 995
 		} else {
996
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
996
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
997 997
 			$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);"; 
998
-                }
999
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1000
-                 try {
1001
-                        $sth = $this->db->prepare($query);
1002
-                        $sth->execute($query_values);
1003
-                } catch(PDOException $e) {
1004
-                        return "error : ".$e->getMessage();
1005
-                }
1006
-        }
1007
-        /*
998
+				}
999
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1000
+				 try {
1001
+						$sth = $this->db->prepare($query);
1002
+						$sth->execute($query_values);
1003
+				} catch(PDOException $e) {
1004
+						return "error : ".$e->getMessage();
1005
+				}
1006
+		}
1007
+		/*
1008 1008
 	public function getStatsSource($date,$stats_type = '') {
1009 1009
 		if ($stats_type == '') {
1010 1010
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -1073,25 +1073,25 @@  discard block
 block discarded – undo
1073 1073
 			$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";
1074 1074
 		} else {
1075 1075
 			$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);"; 
1076
-                }
1077
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1078
-                 try {
1079
-                        $sth = $this->db->prepare($query);
1080
-                        $sth->execute($query_values);
1081
-                } catch(PDOException $e) {
1082
-                        return "error : ".$e->getMessage();
1083
-                }
1084
-        }
1085
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1086
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1087
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1088
-                 try {
1089
-                        $sth = $this->db->prepare($query);
1090
-                        $sth->execute($query_values);
1091
-                } catch(PDOException $e) {
1092
-                        return "error : ".$e->getMessage();
1093
-                }
1094
-        }
1076
+				}
1077
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1078
+				 try {
1079
+						$sth = $this->db->prepare($query);
1080
+						$sth->execute($query_values);
1081
+				} catch(PDOException $e) {
1082
+						return "error : ".$e->getMessage();
1083
+				}
1084
+		}
1085
+	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1086
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1087
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1088
+				 try {
1089
+						$sth = $this->db->prepare($query);
1090
+						$sth->execute($query_values);
1091
+				} catch(PDOException $e) {
1092
+						return "error : ".$e->getMessage();
1093
+				}
1094
+		}
1095 1095
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1096 1096
 		global $globalDBdriver;
1097 1097
 		if ($globalDBdriver == 'mysql') {
@@ -1107,14 +1107,14 @@  discard block
 block discarded – undo
1107 1107
 				$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);"; 
1108 1108
 			}
1109 1109
 		}
1110
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1111
-                 try {
1112
-                        $sth = $this->db->prepare($query);
1113
-                        $sth->execute($query_values);
1114
-                } catch(PDOException $e) {
1115
-                        return "error : ".$e->getMessage();
1116
-                }
1117
-        }
1110
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1111
+				 try {
1112
+						$sth = $this->db->prepare($query);
1113
+						$sth->execute($query_values);
1114
+				} catch(PDOException $e) {
1115
+						return "error : ".$e->getMessage();
1116
+				}
1117
+		}
1118 1118
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1119 1119
 		global $globalDBdriver;
1120 1120
 		if ($globalDBdriver == 'mysql') {
@@ -1130,14 +1130,14 @@  discard block
 block discarded – undo
1130 1130
 				$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);"; 
1131 1131
 			}
1132 1132
 		}
1133
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1134
-                 try {
1135
-                        $sth = $this->db->prepare($query);
1136
-                        $sth->execute($query_values);
1137
-                } catch(PDOException $e) {
1138
-                        return "error : ".$e->getMessage();
1139
-                }
1140
-        }
1133
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1134
+				 try {
1135
+						$sth = $this->db->prepare($query);
1136
+						$sth->execute($query_values);
1137
+				} catch(PDOException $e) {
1138
+						return "error : ".$e->getMessage();
1139
+				}
1140
+		}
1141 1141
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1142 1142
 		global $globalDBdriver;
1143 1143
 		if ($globalDBdriver == 'mysql') {
@@ -1153,14 +1153,14 @@  discard block
 block discarded – undo
1153 1153
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
1154 1154
 			}
1155 1155
 		}
1156
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1157
-                 try {
1158
-                        $sth = $this->db->prepare($query);
1159
-                        $sth->execute($query_values);
1160
-                } catch(PDOException $e) {
1161
-                        return "error : ".$e->getMessage();
1162
-                }
1163
-        }
1156
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1157
+				 try {
1158
+						$sth = $this->db->prepare($query);
1159
+						$sth->execute($query_values);
1160
+				} catch(PDOException $e) {
1161
+						return "error : ".$e->getMessage();
1162
+				}
1163
+		}
1164 1164
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1165 1165
 		global $globalDBdriver;
1166 1166
 		if ($globalDBdriver == 'mysql') {
@@ -1176,14 +1176,14 @@  discard block
 block discarded – undo
1176 1176
 				$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);"; 
1177 1177
 			}
1178 1178
 		}
1179
-                $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);
1180
-                 try {
1181
-                        $sth = $this->db->prepare($query);
1182
-                        $sth->execute($query_values);
1183
-                } catch(PDOException $e) {
1184
-                        return "error : ".$e->getMessage();
1185
-                }
1186
-        }
1179
+				$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);
1180
+				 try {
1181
+						$sth = $this->db->prepare($query);
1182
+						$sth->execute($query_values);
1183
+				} catch(PDOException $e) {
1184
+						return "error : ".$e->getMessage();
1185
+				}
1186
+		}
1187 1187
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1188 1188
 		global $globalDBdriver;
1189 1189
 		if ($globalDBdriver == 'mysql') {
@@ -1199,14 +1199,14 @@  discard block
 block discarded – undo
1199 1199
 				$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);"; 
1200 1200
 			}
1201 1201
 		}
1202
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1203
-                 try {
1204
-                        $sth = $this->db->prepare($query);
1205
-                        $sth->execute($query_values);
1206
-                } catch(PDOException $e) {
1207
-                        return "error : ".$e->getMessage();
1208
-                }
1209
-        }
1202
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1203
+				 try {
1204
+						$sth = $this->db->prepare($query);
1205
+						$sth->execute($query_values);
1206
+				} catch(PDOException $e) {
1207
+						return "error : ".$e->getMessage();
1208
+				}
1209
+		}
1210 1210
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1211 1211
 		global $globalDBdriver;
1212 1212
 		if ($globalDBdriver == 'mysql') {
@@ -1222,14 +1222,14 @@  discard block
 block discarded – undo
1222 1222
 				$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);"; 
1223 1223
 			}
1224 1224
 		}
1225
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1226
-                 try {
1227
-                        $sth = $this->db->prepare($query);
1228
-                        $sth->execute($query_values);
1229
-                } catch(PDOException $e) {
1230
-                        return "error : ".$e->getMessage();
1231
-                }
1232
-        }
1225
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1226
+				 try {
1227
+						$sth = $this->db->prepare($query);
1228
+						$sth->execute($query_values);
1229
+				} catch(PDOException $e) {
1230
+						return "error : ".$e->getMessage();
1231
+				}
1232
+		}
1233 1233
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1234 1234
 		global $globalDBdriver;
1235 1235
 		if ($globalDBdriver == 'mysql') {
@@ -1245,14 +1245,14 @@  discard block
 block discarded – undo
1245 1245
 				$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);"; 
1246 1246
 			}
1247 1247
 		}
1248
-                $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);
1249
-                 try {
1250
-                        $sth = $this->db->prepare($query);
1251
-                        $sth->execute($query_values);
1252
-                } catch(PDOException $e) {
1253
-                        return "error : ".$e->getMessage();
1254
-                }
1255
-        }
1248
+				$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);
1249
+				 try {
1250
+						$sth = $this->db->prepare($query);
1251
+						$sth->execute($query_values);
1252
+				} catch(PDOException $e) {
1253
+						return "error : ".$e->getMessage();
1254
+				}
1255
+		}
1256 1256
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1257 1257
 		global $globalDBdriver;
1258 1258
 		if ($airport_icao != '') {
@@ -1276,8 +1276,8 @@  discard block
 block discarded – undo
1276 1276
 			} catch(PDOException $e) {
1277 1277
 				return "error : ".$e->getMessage();
1278 1278
 			}
1279
-                }
1280
-        }
1279
+				}
1280
+		}
1281 1281
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1282 1282
 		global $globalDBdriver;
1283 1283
 		if ($airport_icao != '') {
@@ -1293,8 +1293,8 @@  discard block
 block discarded – undo
1293 1293
 			} catch(PDOException $e) {
1294 1294
 				return "error : ".$e->getMessage();
1295 1295
 			}
1296
-                }
1297
-        }
1296
+				}
1297
+		}
1298 1298
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1299 1299
 		global $globalDBdriver;
1300 1300
 		if ($airport_icao != '') {
@@ -1311,15 +1311,15 @@  discard block
 block discarded – undo
1311 1311
 					$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);"; 
1312 1312
 				}
1313 1313
 			}
1314
-	                $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);
1314
+					$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);
1315 1315
 			 try {
1316
-                    		$sth = $this->db->prepare($query);
1317
-	                        $sth->execute($query_values);
1318
-    		        } catch(PDOException $e) {
1319
-            		        return "error : ".$e->getMessage();
1320
-	                }
1321
-	        }
1322
-        }
1316
+							$sth = $this->db->prepare($query);
1317
+							$sth->execute($query_values);
1318
+					} catch(PDOException $e) {
1319
+							return "error : ".$e->getMessage();
1320
+					}
1321
+			}
1322
+		}
1323 1323
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1324 1324
 		global $globalDBdriver;
1325 1325
 		if ($airport_icao != '') {
@@ -1335,46 +1335,46 @@  discard block
 block discarded – undo
1335 1335
 			} catch(PDOException $e) {
1336 1336
 				return "error : ".$e->getMessage();
1337 1337
 			}
1338
-                }
1339
-        }
1338
+				}
1339
+		}
1340 1340
 
1341 1341
 	public function deleteStat($id) {
1342
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1343
-                $query_values = array(':id' => $id);
1344
-                 try {
1345
-                        $sth = $this->db->prepare($query);
1346
-                        $sth->execute($query_values);
1347
-                } catch(PDOException $e) {
1348
-                        return "error : ".$e->getMessage();
1349
-                }
1350
-        }
1342
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1343
+				$query_values = array(':id' => $id);
1344
+				 try {
1345
+						$sth = $this->db->prepare($query);
1346
+						$sth->execute($query_values);
1347
+				} catch(PDOException $e) {
1348
+						return "error : ".$e->getMessage();
1349
+				}
1350
+		}
1351 1351
 	public function deleteStatFlight($type) {
1352
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1353
-                $query_values = array(':type' => $type);
1354
-                 try {
1355
-                        $sth = $this->db->prepare($query);
1356
-                        $sth->execute($query_values);
1357
-                } catch(PDOException $e) {
1358
-                        return "error : ".$e->getMessage();
1359
-                }
1360
-        }
1352
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1353
+				$query_values = array(':type' => $type);
1354
+				 try {
1355
+						$sth = $this->db->prepare($query);
1356
+						$sth->execute($query_values);
1357
+				} catch(PDOException $e) {
1358
+						return "error : ".$e->getMessage();
1359
+				}
1360
+		}
1361 1361
 	public function deleteStatAirport($type) {
1362
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1363
-                $query_values = array(':type' => $type);
1364
-                 try {
1365
-                        $sth = $this->db->prepare($query);
1366
-                        $sth->execute($query_values);
1367
-                } catch(PDOException $e) {
1368
-                        return "error : ".$e->getMessage();
1369
-                }
1370
-        }
1362
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1363
+				$query_values = array(':type' => $type);
1364
+				 try {
1365
+						$sth = $this->db->prepare($query);
1366
+						$sth->execute($query_values);
1367
+				} catch(PDOException $e) {
1368
+						return "error : ".$e->getMessage();
1369
+				}
1370
+		}
1371 1371
         
1372
-        public function addOldStats() {
1373
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1374
-    		$Common = new Common();
1375
-    		$Connection = new Connection();
1376
-    		date_default_timezone_set('UTC');
1377
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1372
+		public function addOldStats() {
1373
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1374
+			$Common = new Common();
1375
+			$Connection = new Connection();
1376
+			date_default_timezone_set('UTC');
1377
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1378 1378
 			if ($globalDebug) echo 'Update stats !'."\n";
1379 1379
 			if (isset($last_update[0]['value'])) {
1380 1380
 				$last_update_day = $last_update[0]['value'];
@@ -1420,24 +1420,24 @@  discard block
 block discarded – undo
1420 1420
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1421 1421
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1422 1422
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1423
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1423
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1424 1424
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1425
-	        	$alldata = array();
1425
+				$alldata = array();
1426 1426
 	        	
1427
-    			foreach ($pall as $value) {
1428
-	        		$icao = $value['airport_departure_icao'];
1429
-    				$alldata[$icao] = $value;
1430
-	        	}
1431
-	        	foreach ($dall as $value) {
1432
-    				$icao = $value['airport_departure_icao'];
1433
-        			if (isset($alldata[$icao])) {
1434
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1435
-        			} else $alldata[$icao] = $value;
1436
-			}
1437
-    			$count = array();
1438
-    			foreach ($alldata as $key => $row) {
1439
-    				$count[$key] = $row['airport_departure_icao_count'];
1440
-        		}
1427
+				foreach ($pall as $value) {
1428
+					$icao = $value['airport_departure_icao'];
1429
+					$alldata[$icao] = $value;
1430
+				}
1431
+				foreach ($dall as $value) {
1432
+					$icao = $value['airport_departure_icao'];
1433
+					if (isset($alldata[$icao])) {
1434
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1435
+					} else $alldata[$icao] = $value;
1436
+			}
1437
+				$count = array();
1438
+				foreach ($alldata as $key => $row) {
1439
+					$count[$key] = $row['airport_departure_icao_count'];
1440
+				}
1441 1441
 			array_multisort($count,SORT_DESC,$alldata);
1442 1442
 			foreach ($alldata as $number) {
1443 1443
 				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);
@@ -1445,25 +1445,25 @@  discard block
 block discarded – undo
1445 1445
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1446 1446
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1447 1447
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1448
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1448
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1449 1449
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1450
-	        	$alldata = array();
1451
-    			foreach ($pall as $value) {
1452
-	        		$icao = $value['airport_arrival_icao'];
1453
-    				$alldata[$icao] = $value;
1454
-	        	}
1455
-	        	foreach ($dall as $value) {
1456
-    				$icao = $value['airport_arrival_icao'];
1457
-        			if (isset($alldata[$icao])) {
1458
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1459
-	        		} else $alldata[$icao] = $value;
1460
-    			}
1461
-        		$count = array();
1462
-        		foreach ($alldata as $key => $row) {
1463
-        			$count[$key] = $row['airport_arrival_icao_count'];
1464
-	        	}
1465
-    			array_multisort($count,SORT_DESC,$alldata);
1466
-                        foreach ($alldata as $number) {
1450
+				$alldata = array();
1451
+				foreach ($pall as $value) {
1452
+					$icao = $value['airport_arrival_icao'];
1453
+					$alldata[$icao] = $value;
1454
+				}
1455
+				foreach ($dall as $value) {
1456
+					$icao = $value['airport_arrival_icao'];
1457
+					if (isset($alldata[$icao])) {
1458
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1459
+					} else $alldata[$icao] = $value;
1460
+				}
1461
+				$count = array();
1462
+				foreach ($alldata as $key => $row) {
1463
+					$count[$key] = $row['airport_arrival_icao_count'];
1464
+				}
1465
+				array_multisort($count,SORT_DESC,$alldata);
1466
+						foreach ($alldata as $number) {
1467 1467
 				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);
1468 1468
 			}
1469 1469
 			if ($Connection->tableExists('countries')) {
@@ -1523,8 +1523,8 @@  discard block
 block discarded – undo
1523 1523
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1524 1524
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1525 1525
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1526
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1527
-        		/*
1526
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1527
+				/*
1528 1528
 	        	$alldata = array();
1529 1529
     			foreach ($pall as $value) {
1530 1530
 	        		$icao = $value['departure_airport_icao'];
@@ -1543,29 +1543,29 @@  discard block
 block discarded – undo
1543 1543
 	        	}
1544 1544
     			array_multisort($count,SORT_DESC,$alldata);
1545 1545
     			*/
1546
-    			foreach ($dall as $value) {
1547
-    				$icao = $value['departure_airport_icao'];
1548
-    				$ddate = $value['date'];
1549
-    				$find = false;
1550
-    				foreach ($pall as $pvalue) {
1551
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1552
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1553
-    						$find = true;
1554
-    						break;
1555
-    					}
1556
-    				}
1557
-    				if ($find === false) {
1558
-    					$pall[] = $value;
1559
-    				}
1560
-    			}
1561
-    			$alldata = $pall;
1546
+				foreach ($dall as $value) {
1547
+					$icao = $value['departure_airport_icao'];
1548
+					$ddate = $value['date'];
1549
+					$find = false;
1550
+					foreach ($pall as $pvalue) {
1551
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1552
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1553
+							$find = true;
1554
+							break;
1555
+						}
1556
+					}
1557
+					if ($find === false) {
1558
+						$pall[] = $value;
1559
+					}
1560
+				}
1561
+				$alldata = $pall;
1562 1562
 			foreach ($alldata as $number) {
1563 1563
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1564 1564
 			}
1565 1565
 			echo '...Arrival'."\n";
1566 1566
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1567
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1568
-        		/*
1567
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1568
+				/*
1569 1569
 	        	$alldata = array();
1570 1570
     			foreach ($pall as $value) {
1571 1571
 	        		$icao = $value['arrival_airport_icao'];
@@ -1585,22 +1585,22 @@  discard block
 block discarded – undo
1585 1585
     			*/
1586 1586
 
1587 1587
 
1588
-    			foreach ($dall as $value) {
1589
-    				$icao = $value['arrival_airport_icao'];
1590
-    				$ddate = $value['date'];
1591
-    				$find = false;
1592
-    				foreach ($pall as $pvalue) {
1593
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1594
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1595
-    						$find = true;
1596
-    						break;
1597
-    					}
1598
-    				}
1599
-    				if ($find === false) {
1600
-    					$pall[] = $value;
1601
-    				}
1602
-    			}
1603
-    			$alldata = $pall;
1588
+				foreach ($dall as $value) {
1589
+					$icao = $value['arrival_airport_icao'];
1590
+					$ddate = $value['date'];
1591
+					$find = false;
1592
+					foreach ($pall as $pvalue) {
1593
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1594
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1595
+							$find = true;
1596
+							break;
1597
+						}
1598
+					}
1599
+					if ($find === false) {
1600
+						$pall[] = $value;
1601
+					}
1602
+				}
1603
+				$alldata = $pall;
1604 1604
 			foreach ($alldata as $number) {
1605 1605
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1606 1606
 			}
@@ -1667,51 +1667,51 @@  discard block
 block discarded – undo
1667 1667
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1668 1668
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1669 1669
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1670
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1670
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1671 1671
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1672
-	        	//$alldata = array();
1673
-    			foreach ($dall as $value) {
1674
-    				$icao = $value['airport_departure_icao'];
1675
-    				$dicao = $value['airline_icao'];
1676
-    				$find = false;
1677
-    				foreach ($pall as $pvalue) {
1678
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1679
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1680
-    						$find = true;
1681
-    						break;
1682
-    					}
1683
-    				}
1684
-    				if ($find === false) {
1685
-    					$pall[] = $value;
1686
-    				}
1687
-    			}
1688
-    			$alldata = $pall;
1672
+				//$alldata = array();
1673
+				foreach ($dall as $value) {
1674
+					$icao = $value['airport_departure_icao'];
1675
+					$dicao = $value['airline_icao'];
1676
+					$find = false;
1677
+					foreach ($pall as $pvalue) {
1678
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1679
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1680
+							$find = true;
1681
+							break;
1682
+						}
1683
+					}
1684
+					if ($find === false) {
1685
+						$pall[] = $value;
1686
+					}
1687
+				}
1688
+				$alldata = $pall;
1689 1689
 			foreach ($alldata as $number) {
1690 1690
 				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);
1691 1691
 			}
1692 1692
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1693 1693
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1694 1694
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1695
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1695
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1696 1696
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1697
-	        	//$alldata = array();
1698
-    			foreach ($dall as $value) {
1699
-    				$icao = $value['airport_arrival_icao'];
1700
-    				$dicao = $value['airline_icao'];
1701
-    				$find = false;
1702
-    				foreach ($pall as $pvalue) {
1703
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1704
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1705
-    						$find = true;
1706
-    						break;
1707
-    					}
1708
-    				}
1709
-    				if ($find === false) {
1710
-    					$pall[] = $value;
1711
-    				}
1712
-    			}
1713
-    			$alldata = $pall;
1714
-                        foreach ($alldata as $number) {
1697
+				//$alldata = array();
1698
+				foreach ($dall as $value) {
1699
+					$icao = $value['airport_arrival_icao'];
1700
+					$dicao = $value['airline_icao'];
1701
+					$find = false;
1702
+					foreach ($pall as $pvalue) {
1703
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1704
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1705
+							$find = true;
1706
+							break;
1707
+						}
1708
+					}
1709
+					if ($find === false) {
1710
+						$pall[] = $value;
1711
+					}
1712
+				}
1713
+				$alldata = $pall;
1714
+						foreach ($alldata as $number) {
1715 1715
 				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);
1716 1716
 			}
1717 1717
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1744,47 +1744,47 @@  discard block
 block discarded – undo
1744 1744
 			}
1745 1745
 			if ($globalDebug) echo '...Departure'."\n";
1746 1746
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1747
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1748
-    			foreach ($dall as $value) {
1749
-    				$icao = $value['departure_airport_icao'];
1750
-    				$airline = $value['airline_icao'];
1751
-    				$ddate = $value['date'];
1752
-    				$find = false;
1753
-    				foreach ($pall as $pvalue) {
1754
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1755
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1756
-    						$find = true;
1757
-    						break;
1758
-    					}
1759
-    				}
1760
-    				if ($find === false) {
1761
-    					$pall[] = $value;
1762
-    				}
1763
-    			}
1764
-    			$alldata = $pall;
1747
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1748
+				foreach ($dall as $value) {
1749
+					$icao = $value['departure_airport_icao'];
1750
+					$airline = $value['airline_icao'];
1751
+					$ddate = $value['date'];
1752
+					$find = false;
1753
+					foreach ($pall as $pvalue) {
1754
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1755
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1756
+							$find = true;
1757
+							break;
1758
+						}
1759
+					}
1760
+					if ($find === false) {
1761
+						$pall[] = $value;
1762
+					}
1763
+				}
1764
+				$alldata = $pall;
1765 1765
 			foreach ($alldata as $number) {
1766 1766
 				$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']);
1767 1767
 			}
1768 1768
 			if ($globalDebug) echo '...Arrival'."\n";
1769 1769
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1770
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1771
-    			foreach ($dall as $value) {
1772
-    				$icao = $value['arrival_airport_icao'];
1773
-    				$airline = $value['airline_icao'];
1774
-    				$ddate = $value['date'];
1775
-    				$find = false;
1776
-    				foreach ($pall as $pvalue) {
1777
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1778
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1779
-    						$find = true;
1780
-    						break;
1781
-    					}
1782
-    				}
1783
-    				if ($find === false) {
1784
-    					$pall[] = $value;
1785
-    				}
1786
-    			}
1787
-    			$alldata = $pall;
1770
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1771
+				foreach ($dall as $value) {
1772
+					$icao = $value['arrival_airport_icao'];
1773
+					$airline = $value['airline_icao'];
1774
+					$ddate = $value['date'];
1775
+					$find = false;
1776
+					foreach ($pall as $pvalue) {
1777
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1778
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1779
+							$find = true;
1780
+							break;
1781
+						}
1782
+					}
1783
+					if ($find === false) {
1784
+						$pall[] = $value;
1785
+					}
1786
+				}
1787
+				$alldata = $pall;
1788 1788
 			foreach ($alldata as $number) {
1789 1789
 				$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']);
1790 1790
 			}
@@ -1855,44 +1855,44 @@  discard block
 block discarded – undo
1855 1855
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1856 1856
 				}
1857 1857
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1858
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1859
-		        	$alldata = array();
1860
-	    			foreach ($pall as $value) {
1861
-		        		$icao = $value['airport_departure_icao'];
1862
-    					$alldata[$icao] = $value;
1863
-	    			}
1864
-		        	foreach ($dall as $value) {
1865
-	    				$icao = $value['airport_departure_icao'];
1866
-        				if (isset($alldata[$icao])) {
1867
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1868
-        				} else $alldata[$icao] = $value;
1869
-				}
1870
-	    			$count = array();
1871
-    				foreach ($alldata as $key => $row) {
1872
-    					$count[$key] = $row['airport_departure_icao_count'];
1873
-    				}
1858
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1859
+					$alldata = array();
1860
+					foreach ($pall as $value) {
1861
+						$icao = $value['airport_departure_icao'];
1862
+						$alldata[$icao] = $value;
1863
+					}
1864
+					foreach ($dall as $value) {
1865
+						$icao = $value['airport_departure_icao'];
1866
+						if (isset($alldata[$icao])) {
1867
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1868
+						} else $alldata[$icao] = $value;
1869
+				}
1870
+					$count = array();
1871
+					foreach ($alldata as $key => $row) {
1872
+						$count[$key] = $row['airport_departure_icao_count'];
1873
+					}
1874 1874
 				array_multisort($count,SORT_DESC,$alldata);
1875 1875
 				foreach ($alldata as $number) {
1876
-    					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);
1876
+						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);
1877 1877
 				}
1878 1878
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1879
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1879
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1880 1880
 				$alldata = array();
1881
-    				foreach ($pall as $value) {
1882
-		        		$icao = $value['airport_arrival_icao'];
1883
-    					$alldata[$icao] = $value;
1884
-	    			}
1885
-		        	foreach ($dall as $value) {
1886
-	    				$icao = $value['airport_arrival_icao'];
1887
-        				if (isset($alldata[$icao])) {
1888
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1889
-		        		} else $alldata[$icao] = $value;
1890
-	    			}
1891
-        			$count = array();
1892
-        			foreach ($alldata as $key => $row) {
1893
-    					$count[$key] = $row['airport_arrival_icao_count'];
1894
-		        	}
1895
-        			array_multisort($count,SORT_DESC,$alldata);
1881
+					foreach ($pall as $value) {
1882
+						$icao = $value['airport_arrival_icao'];
1883
+						$alldata[$icao] = $value;
1884
+					}
1885
+					foreach ($dall as $value) {
1886
+						$icao = $value['airport_arrival_icao'];
1887
+						if (isset($alldata[$icao])) {
1888
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1889
+						} else $alldata[$icao] = $value;
1890
+					}
1891
+					$count = array();
1892
+					foreach ($alldata as $key => $row) {
1893
+						$count[$key] = $row['airport_arrival_icao_count'];
1894
+					}
1895
+					array_multisort($count,SORT_DESC,$alldata);
1896 1896
 				foreach ($alldata as $number) {
1897 1897
 					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);
1898 1898
 				}
@@ -1925,45 +1925,45 @@  discard block
 block discarded – undo
1925 1925
 				}
1926 1926
 				echo '...Departure'."\n";
1927 1927
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1928
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1928
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1929 1929
 				foreach ($dall as $value) {
1930
-    					$icao = $value['departure_airport_icao'];
1931
-    					$ddate = $value['date'];
1932
-    					$find = false;
1933
-    					foreach ($pall as $pvalue) {
1934
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1935
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1936
-	    						$find = true;
1937
-    							break;
1938
-    						}
1939
-    					}
1940
-    					if ($find === false) {
1941
-    						$pall[] = $value;
1942
-	    				}
1943
-    				}
1944
-	    			$alldata = $pall;
1930
+						$icao = $value['departure_airport_icao'];
1931
+						$ddate = $value['date'];
1932
+						$find = false;
1933
+						foreach ($pall as $pvalue) {
1934
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1935
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1936
+								$find = true;
1937
+								break;
1938
+							}
1939
+						}
1940
+						if ($find === false) {
1941
+							$pall[] = $value;
1942
+						}
1943
+					}
1944
+					$alldata = $pall;
1945 1945
 				foreach ($alldata as $number) {
1946 1946
 					$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);
1947 1947
 				}
1948 1948
 				echo '...Arrival'."\n";
1949 1949
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1950
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1950
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1951 1951
 				foreach ($dall as $value) {
1952 1952
 					$icao = $value['arrival_airport_icao'];
1953 1953
 					$ddate = $value['date'];
1954
-    					$find = false;
1954
+						$find = false;
1955 1955
 					foreach ($pall as $pvalue) {
1956
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1957
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1958
-    							$find = true;
1959
-    							break;
1960
-	    					}
1961
-    					}
1962
-    					if ($find === false) {
1963
-    						$pall[] = $value;
1964
-	    				}
1965
-    				}
1966
-    				$alldata = $pall;
1956
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1957
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1958
+								$find = true;
1959
+								break;
1960
+							}
1961
+						}
1962
+						if ($find === false) {
1963
+							$pall[] = $value;
1964
+						}
1965
+					}
1966
+					$alldata = $pall;
1967 1967
 				foreach ($alldata as $number) {
1968 1968
 					$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);
1969 1969
 				}
Please login to merge, or discard this patch.
statistics-airline-country.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Airline by Country");
7 7
 if (!isset($filter_name)) $filter_name = '';
8 8
 require_once('header.php');
9
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
10
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
9
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
10
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
11 11
 include('statistics-sub-menu.php'); 
12 12
 
13 13
 print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	  </div>
17 17
       <p>'._("Below are the <strong>Top 10</strong> countries that an airline belongs to.").'</p>';
18 18
 
19
-$airline_array = $Stats->countAllAirlineCountries(true,$filter_name,$year,$month);
19
+$airline_array = $Stats->countAllAirlineCountries(true, $filter_name, $year, $month);
20 20
 if (count($airline_array) > 0) {
21 21
 print '<div id="chartCountry" class="chart" width="100%"></div>
22 22
       	<script> 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
             var data = google.visualization.arrayToDataTable([
27 27
             	["'._("Country").'", "'._("# of times").'"], ';
28 28
 $country_data = '';
29
-foreach($airline_array as $airline_item)
29
+foreach ($airline_array as $airline_item)
30 30
 {
31 31
 	$country_data .= '[ "'.$airline_item['airline_country'].'",'.$airline_item['airline_country_count'].'],';
32 32
 }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	print '</thead>';
61 61
 	print '<tbody>';
62 62
 	$i = 1;
63
-	foreach($airline_array as $airline_item)
63
+	foreach ($airline_array as $airline_item)
64 64
 	{
65 65
 		print '<tr>';
66 66
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,9 @@
 block discarded – undo
4 4
 require_once('require/class.Language.php');
5 5
 $Stats = new Stats();
6 6
 $title = _("Statistics").' - '._("Most common Airline by Country");
7
-if (!isset($filter_name)) $filter_name = '';
7
+if (!isset($filter_name)) {
8
+	$filter_name = '';
9
+}
8 10
 require_once('header.php');
9 11
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
10 12
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
statistics-sub-menu.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		</form>
32 32
 	</div>
33 33
 <?php 
34
-    if (isset($year) && $year == '' && isset($month) && $month == '') {
34
+	if (isset($year) && $year == '' && isset($month) && $month == '') {
35 35
 ?>
36 36
 <div class="sub-menu sub-menu-container">
37 37
 	<ul class="nav">
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		    </ul>
87 87
 		</li>
88 88
 		<?php
89
-		    if (isset($globalAccidents) && $globalAccidents) {
89
+			if (isset($globalAccidents) && $globalAccidents) {
90 90
 		?>
91 91
 		<li class="dropdown">
92 92
 		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
 		    </ul>
99 99
 		</li>
100 100
 		<?php
101
-		    }
101
+			}
102 102
 		?>
103 103
 	</ul>
104 104
 </div>
105 105
 <?php
106
-    } else {
106
+	} else {
107 107
 ?>
108 108
 <div class="sub-menu sub-menu-container">
109 109
 	<ul class="nav">
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		</li>
163 163
 		-->
164 164
 		<?php
165
-		    if (isset($globalAccidents) && $globalAccidents) {
165
+			if (isset($globalAccidents) && $globalAccidents) {
166 166
 		?>
167 167
 		<!--
168 168
 		<li class="dropdown">
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 		</li>
177 177
 		-->
178 178
 		<?php
179
-		    }
179
+			}
180 180
 		?>
181 181
 	</ul>
182 182
 </div>
183 183
 <?php
184
-    }
184
+	}
185 185
 ?>
186 186
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 					} else {
20 20
 						print '<option value="all">All</option>';
21 21
 					}
22
-					foreach($airlines as $airline) {
22
+					foreach ($airlines as $airline) {
23 23
 						if (isset($airline_icao) && $airline_icao == $airline['airline_icao']) {
24 24
 							print '<option value="'.$airline['airline_icao'].'" selected>'.$airline['airline_name'].'</option>';
25 25
 						} else {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 <div class="sub-menu sub-menu-container">
37 37
 	<ul class="nav">
38 38
 		<li class="dropdown">
39
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" >
39
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" >
40 40
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
41 41
 		    </a>
42 42
 		    <ul class="dropdown-menu">
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		    </ul>
48 48
 		</li>
49 49
 		<li class="dropdown">
50
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
50
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#">
51 51
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
52 52
 		    </a>
53 53
 		    <ul class="dropdown-menu" role="menu">
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		    </ul>
58 58
 		</li>
59 59
 		<li class="dropdown">
60
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
60
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
61 61
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
62 62
 		    </a>
63 63
 		    <ul class="dropdown-menu" role="menu">
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		    </ul>
69 69
 		</li>
70 70
 		<li class="dropdown">
71
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
71
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#">
72 72
 		      <?php echo _("Route"); ?> <span class="caret"></span>
73 73
 		    </a>
74 74
 		    <ul class="dropdown-menu" role="menu">
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		    </ul>
78 78
 		</li>
79 79
 		<li class="dropdown">
80
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
80
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
81 81
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
82 82
 		    </a>
83 83
 		    <ul class="dropdown-menu" role="menu">
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		    if (isset($globalAccidents) && $globalAccidents) {
90 90
 		?>
91 91
 		<li class="dropdown">
92
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
92
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#">
93 93
 		      <?php echo _("Fatalities"); ?> <span class="caret"></span>
94 94
 		    </a>
95 95
 		    <ul class="dropdown-menu" role="menu">
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 <div class="sub-menu sub-menu-container">
109 109
 	<ul class="nav">
110 110
 		<li class="dropdown">
111
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" >
111
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" >
112 112
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
113 113
 		    </a>
114 114
 		    <ul class="dropdown-menu">
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		    </ul>
120 120
 		</li>
121 121
 		<li class="dropdown">
122
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
122
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#">
123 123
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
124 124
 		    </a>
125 125
 		    <ul class="dropdown-menu" role="menu">
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		    </ul>
130 130
 		</li>
131 131
 		<li class="dropdown">
132
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
132
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
133 133
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
134 134
 		    </a>
135 135
 		    <ul class="dropdown-menu" role="menu">
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		</li>
142 142
 		<!--
143 143
 		<li class="dropdown">
144
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
144
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#">
145 145
 		      <?php echo _("Route"); ?> <span class="caret"></span>
146 146
 		    </a>
147 147
 		    <ul class="dropdown-menu" role="menu">
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		-->
153 153
 		<!--
154 154
 		<li class="dropdown">
155
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
155
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
156 156
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
157 157
 		    </a>
158 158
 		    <ul class="dropdown-menu" role="menu">
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 		?>
167 167
 		<!--
168 168
 		<li class="dropdown">
169
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
169
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#">
170 170
 		      <?php echo _("Fatalities"); ?> <span class="caret"></span>
171 171
 		    </a>
172 172
 		    <ul class="dropdown-menu" role="menu">
Please login to merge, or discard this patch.
Braces   +10 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,7 +4,13 @@  discard block
 block discarded – undo
4 4
 	<div class="stats_airline">
5 5
 	
6 6
 		<form id="changedate" method="post">
7
-			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') echo $year.'-'; ?><?php if (isset($month) && $month != '') echo $month; ?>" />
7
+			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') {
8
+	echo $year.'-';
9
+}
10
+?><?php if (isset($month) && $month != '') {
11
+	echo $month;
12
+}
13
+?>" />
8 14
 		</form>
9 15
 	
10 16
 		<form>
@@ -12,7 +18,9 @@  discard block
 block discarded – undo
12 18
 				<?php
13 19
 					require_once('require/class.Stats.php');
14 20
 					$Stats = new Stats();
15
-					if (!isset($filter_name)) $filter_name = '';
21
+					if (!isset($filter_name)) {
22
+						$filter_name = '';
23
+					}
16 24
 					$airlines = $Stats->getAllAirlineNames($filter_name);
17 25
 					if (isset($airline_icao) && ($airline_icao == '' || $airline_icao == 'all')) {
18 26
 						print '<option value="all" selected>All</option>';
Please login to merge, or discard this patch.
statistics-airline.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Airline");
7 7
 require_once('header.php');
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
10
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
9
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
10
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
11 11
 include('statistics-sub-menu.php'); 
12 12
 
13 13
 print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	  </div>
17 17
     	<p>'._("Below are the <strong>Top 10</strong> most common airlines.").'</p>';
18 18
 
19
-$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
19
+$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
20 20
 print '<div id="chart" class="chart" width="100%"></div>
21 21
       	<script> 
22 22
       		google.load("visualization", "1", {packages:["corechart"]});
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
             var data = google.visualization.arrayToDataTable([
26 26
             	["'._("Airline").'", "'._("# of times").'"], ';
27 27
 $airline_data = '';
28
-foreach($airline_array as $airline_item)
28
+foreach ($airline_array as $airline_item)
29 29
 {
30 30
 	$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
31 31
 }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	print '</thead>';
61 61
 	print '<tbody>';
62 62
 	$i = 1;
63
-	foreach($airline_array as $airline_item)
63
+	foreach ($airline_array as $airline_item)
64 64
 	{
65 65
 		print '<tr>';
66 66
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
 $Stats = new Stats();
6 6
 $title = _("Statistics").' - '._("Most common Airline");
7 7
 require_once('header.php');
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
10 12
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
11 13
 include('statistics-sub-menu.php'); 
Please login to merge, or discard this patch.
pilot-detailed.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@  discard block
 block discarded – undo
6 6
 //require_once('require/class.SpotterLive.php');
7 7
 require_once('require/class.SpotterArchive.php');
8 8
 
9
-if (!isset($_GET['pilot'])){
9
+if (!isset($_GET['pilot'])) {
10 10
 	header('Location: '.$globalURL.'/');
11 11
 } else {
12 12
 	$Spotter = new Spotter();
13 13
 	$SpotterArchive = new SpotterArchive();
14 14
 	$Translation = new Translation();
15 15
 	//calculuation for the pagination
16
-	if(!isset($_GET['limit']))
16
+	if (!isset($_GET['limit']))
17 17
 	{
18 18
 		$limit_start = 0;
19 19
 		$limit_end = 25;
@@ -34,24 +34,24 @@  discard block
 block discarded – undo
34 34
 	
35 35
 	$page_url = $globalURL.'/pilot/'.$_GET['pilot'];
36 36
 	
37
-	$pilot = filter_input(INPUT_GET,'pilot',FILTER_SANITIZE_STRING);
38
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
37
+	$pilot = filter_input(INPUT_GET, 'pilot', FILTER_SANITIZE_STRING);
38
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
39 39
 	if ($sort != '') 
40 40
 	{
41
-		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort);
41
+		$spotter_array = $Spotter->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, $sort);
42 42
 		if (empty($spotter_array)) {
43
-			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort);
43
+			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, $sort);
44 44
 		}
45 45
 	} else {
46
-		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference);
46
+		$spotter_array = $Spotter->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference);
47 47
 		if (empty($spotter_array)) {
48
-			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference);
48
+			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference);
49 49
 		}
50 50
 	}
51 51
 
52 52
 	if (!empty($spotter_array))
53 53
 	{
54
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
54
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['pilot_name']);
55 55
 		$ident = $spotter_array[0]['ident'];
56 56
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
57 57
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	
113 113
 		include('owner-sub-menu.php');
114 114
 		print '<div class="table column">';
115
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the pilot <strong>%s</strong>."),$spotter_array[0]['pilot_name']).'</p>';
115
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the pilot <strong>%s</strong>."), $spotter_array[0]['pilot_name']).'</p>';
116 116
 
117 117
 		include('table-output.php'); 
118 118
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,8 +53,12 @@  discard block
 block discarded – undo
53 53
 	{
54 54
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
55 55
 		$ident = $spotter_array[0]['ident'];
56
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
57
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
56
+		if (isset($spotter_array[0]['latitude'])) {
57
+			$latitude = $spotter_array[0]['latitude'];
58
+		}
59
+		if (isset($spotter_array[0]['longitude'])) {
60
+			$longitude = $spotter_array[0]['longitude'];
61
+		}
58 62
 		require_once('header.php');
59 63
 		/*
60 64
 		if (isset($globalArchive) && $globalArchive) {
@@ -107,7 +111,9 @@  discard block
 block discarded – undo
107 111
 		*/
108 112
 		print '<div class="info column">';
109 113
 		print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>';
110
-		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
114
+		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') {
115
+			print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
116
+		}
111 117
 		print '</div>';
112 118
 	
113 119
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.
owner-statistics-aircraft.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['owner'])) {
6
-        header('Location: '.$globalURL.'/owner');
7
-        die();
6
+		header('Location: '.$globalURL.'/owner');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
10
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
11
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
12 12
 if ($sort != '') {
13
-	$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort);
13
+	$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort);
14 14
 } else {
15
-	$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", '');
15
+	$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", '');
16 16
 }
17 17
 
18 18
 if (!empty($spotter_array))
19 19
 {
20
-	$title = sprintf(_("Most Common Aircraft of %s"),$spotter_array[0]['aircraft_owner']);
20
+	$title = sprintf(_("Most Common Aircraft of %s"), $spotter_array[0]['aircraft_owner']);
21 21
 	require_once('header.php');
22 22
 	print '<div class="info column">';
23 23
 	print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	include('owner-sub-menu.php');
29 29
 	print '<div class="column">';
30 30
 	print '<h2>'._("Most Common Aircraft").'</h2>';
31
-	print '<p>'.sprintf(_("The statistic below shows the most common aircrafts of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
31
+	print '<p>'.sprintf(_("The statistic below shows the most common aircrafts of flights owned by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
32 32
 
33 33
 	$aircraft_array = $Spotter->countAllAircraftTypesByOwner($owner);
34 34
 	if (!empty($aircraft_array))
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		print '</thead>';
43 43
 		print '<tbody>';
44 44
 		$i = 1;
45
-		foreach($aircraft_array as $aircraft_item)
45
+		foreach ($aircraft_array as $aircraft_item)
46 46
 		{
47 47
 			print '<tr>';
48 48
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
owner-statistics-time.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
12
-$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort);
10
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
11
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
12
+$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort);
13 13
 
14 14
 if (!empty($spotter_array))
15 15
 {
16
-	$title = sprintf(_("Most Common Time of Day of %s"),$spotter_array[0]['aircraft_owner']);
16
+	$title = sprintf(_("Most Common Time of Day of %s"), $spotter_array[0]['aircraft_owner']);
17 17
 	require_once('header.php');
18 18
 	print '<div class="info column">';
19 19
 	print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	include('owner-sub-menu.php');
25 25
 	print '<div class="column">';
26 26
 	print '<h2>'._("Most Common Time of Day").'</h2>';
27
-	print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
27
+	print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights owned by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
28 28
 
29 29
 	$hour_array = $Spotter->countAllHoursByOwner($owner);
30 30
 	print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             var data = google.visualization.arrayToDataTable([
37 37
             	["'._("Hour").'", "'._("# of Flights").'"], ';
38 38
 	$hour_data = '';
39
-	foreach($hour_array as $hour_item)
39
+	foreach ($hour_array as $hour_item)
40 40
 	{
41 41
 		$hour_data .= '[ "'.date("ga", strtotime($hour_item['hour_name'].":00")).'",'.$hour_item['hour_count'].'],';
42 42
 	}
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['owner'])) {
6
-        header('Location: '.$globalURL.'/owner');
7
-        die();
6
+		header('Location: '.$globalURL.'/owner');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
pilot-statistics-time.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['pilot'])) {
6
-        header('Location: '.$globalURL.'/pilot');
7
-        die();
6
+		header('Location: '.$globalURL.'/pilot');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11
-$pilot = filter_input(INPUT_GET,'pilot',FILTER_SANITIZE_STRING);
12
-$spotter_array = $Spotter->getSpotterDataByPilot($pilot,"0,1", $sort);
10
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
11
+$pilot = filter_input(INPUT_GET, 'pilot', FILTER_SANITIZE_STRING);
12
+$spotter_array = $Spotter->getSpotterDataByPilot($pilot, "0,1", $sort);
13 13
 
14 14
 if (!empty($spotter_array))
15 15
 {
16
-	$title = sprintf(_("Most Common Time of Day of %s"),$spotter_array[0]['pilot_name']);
16
+	$title = sprintf(_("Most Common Time of Day of %s"), $spotter_array[0]['pilot_name']);
17 17
 	require_once('header.php');
18 18
 	print '<div class="info column">';
19 19
 	print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>';
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	include('owner-sub-menu.php');
25 25
 	print '<div class="column">';
26 26
 	print '<h2>'._("Most Common Time of Day").'</h2>';
27
-	print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights piloted by <strong>%s</strong>."),$spotter_array[0]['pilot_name']).'</p>';
27
+	print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights piloted by <strong>%s</strong>."), $spotter_array[0]['pilot_name']).'</p>';
28 28
 
29 29
 	$hour_array = $Spotter->countAllHoursByPilot($pilot);
30 30
 	print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             var data = google.visualization.arrayToDataTable([
37 37
             	["'._("Hour").'", "'._("# of Flights").'"], ';
38 38
 	$hour_data = '';
39
-	foreach($hour_array as $hour_item)
39
+	foreach ($hour_array as $hour_item)
40 40
 	{
41 41
 		$hour_data .= '[ "'.date("ga", strtotime($hour_item['hour_name'].":00")).'",'.$hour_item['hour_count'].'],';
42 42
 	}
Please login to merge, or discard this patch.
pilot-statistics-airline.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11
-$pilot = filter_input(INPUT_GET,'pilot',FILTER_SANITIZE_STRING);
12
-$spotter_array = $Spotter->getSpotterDataByPilot($pilot,"0,1", $sort);
10
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
11
+$pilot = filter_input(INPUT_GET, 'pilot', FILTER_SANITIZE_STRING);
12
+$spotter_array = $Spotter->getSpotterDataByPilot($pilot, "0,1", $sort);
13 13
 
14 14
 if (!empty($spotter_array))
15 15
 {
16
-	$title = sprintf(_("Most Common Airlines of %s"),$spotter_array[0]['pilot_name']);
16
+	$title = sprintf(_("Most Common Airlines of %s"), $spotter_array[0]['pilot_name']);
17 17
 	require_once('header.php');
18 18
 	print '<div class="info column">';
19 19
 	print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>';
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	include('pilot-sub-menu.php');
25 25
 	print '<div class="column">';
26 26
 	print '<h2>'._("Most Common Airlines").'</h2>';
27
-	print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights owned by <strong>%s</strong>."),$spotter_array[0]['pilot_name']).'</p>';
27
+	print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights owned by <strong>%s</strong>."), $spotter_array[0]['pilot_name']).'</p>';
28 28
 
29 29
 	$airline_array = $Spotter->countAllAirlinesByPilot($pilot);
30 30
 	if (!empty($airline_array))
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		print '</thead>';
42 42
 		print '<tbody>';
43 43
 		$i = 1;
44
-		foreach($airline_array as $airline_item)
44
+		foreach ($airline_array as $airline_item)
45 45
 		{
46 46
 			print '<tr>';
47 47
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['pilot'])) {
6
-        header('Location: '.$globalURL.'/pilot');
7
-        die();
6
+		header('Location: '.$globalURL.'/pilot');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.