Completed
Push — master ( ac909e...a14f10 )
by Yannick
06:55
created
require/class.Stats.php 2 patches
Indentation   +693 added lines, -693 removed lines patch added patch discarded remove patch
@@ -8,199 +8,199 @@  discard block
 block discarded – undo
8 8
 require_once(dirname(__FILE__).'/class.Common.php');
9 9
 class Stats {
10 10
 	public $db;
11
-        function __construct($dbc = null) {
11
+		function __construct($dbc = null) {
12 12
 		$Connection = new Connection($dbc);
13 13
 		$this->db = $Connection->db;
14
-        }
14
+		}
15 15
               
16 16
 	public function addLastStatsUpdate($type,$stats_date) {
17
-                $query = "DELETE FROM config WHERE name = :type;
17
+				$query = "DELETE FROM config WHERE name = :type;
18 18
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
19
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
20
-                 try {
21
-                        $sth = $this->db->prepare($query);
22
-                        $sth->execute($query_values);
23
-                } catch(PDOException $e) {
24
-                        return "error : ".$e->getMessage();
25
-                }
26
-        }
19
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
20
+				 try {
21
+						$sth = $this->db->prepare($query);
22
+						$sth->execute($query_values);
23
+				} catch(PDOException $e) {
24
+						return "error : ".$e->getMessage();
25
+				}
26
+		}
27 27
 
28 28
 	public function getLastStatsUpdate($type = 'last_update_stats') {
29
-                $query = "SELECT value FROM config WHERE name = :type";
30
-                 try {
31
-                        $sth = $this->db->prepare($query);
32
-                        $sth->execute(array(':type' => $type));
33
-                } catch(PDOException $e) {
34
-                        echo "error : ".$e->getMessage();
35
-                }
36
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
37
-                return $all;
38
-        }
29
+				$query = "SELECT value FROM config WHERE name = :type";
30
+				 try {
31
+						$sth = $this->db->prepare($query);
32
+						$sth->execute(array(':type' => $type));
33
+				} catch(PDOException $e) {
34
+						echo "error : ".$e->getMessage();
35
+				}
36
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
37
+				return $all;
38
+		}
39 39
 	public function getAllAirlineNames($airline_type = '') {
40
-                $query = "SELECT * FROM stats_airline ORDER BY airline_name ASC";
41
-                 try {
42
-                        $sth = $this->db->prepare($query);
43
-                        $sth->execute();
44
-                } catch(PDOException $e) {
45
-                        echo "error : ".$e->getMessage();
46
-                }
47
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
48
-                return $all;
49
-        }
40
+				$query = "SELECT * FROM stats_airline ORDER BY airline_name ASC";
41
+				 try {
42
+						$sth = $this->db->prepare($query);
43
+						$sth->execute();
44
+				} catch(PDOException $e) {
45
+						echo "error : ".$e->getMessage();
46
+				}
47
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
48
+				return $all;
49
+		}
50 50
 	public function getAllAircraftTypes() {
51
-                $query = "SELECT * FROM stats_aircraft ORDER BY aircraft_name ASC";
52
-                 try {
53
-                        $sth = $this->db->prepare($query);
54
-                        $sth->execute();
55
-                } catch(PDOException $e) {
56
-                        echo "error : ".$e->getMessage();
57
-                }
58
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
59
-                return $all;
60
-        }
51
+				$query = "SELECT * FROM stats_aircraft ORDER BY aircraft_name ASC";
52
+				 try {
53
+						$sth = $this->db->prepare($query);
54
+						$sth->execute();
55
+				} catch(PDOException $e) {
56
+						echo "error : ".$e->getMessage();
57
+				}
58
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
59
+				return $all;
60
+		}
61 61
 	public function getAllAirportNames() {
62
-                $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
63
-                 try {
64
-                        $sth = $this->db->prepare($query);
65
-                        $sth->execute();
66
-                } catch(PDOException $e) {
67
-                        echo "error : ".$e->getMessage();
68
-                }
69
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
70
-                return $all;
71
-        }
62
+				$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
63
+				 try {
64
+						$sth = $this->db->prepare($query);
65
+						$sth->execute();
66
+				} catch(PDOException $e) {
67
+						echo "error : ".$e->getMessage();
68
+				}
69
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
70
+				return $all;
71
+		}
72 72
 
73 73
 
74 74
 	public function countAllAircraftTypes($limit = true) {
75 75
 		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
76 76
 		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC";
77
-                 try {
78
-                        $sth = $this->db->prepare($query);
79
-                        $sth->execute();
80
-                } catch(PDOException $e) {
81
-                        echo "error : ".$e->getMessage();
82
-                }
83
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
84
-                if (empty($all)) {
85
-            	    $Spotter = new Spotter($this->db);
86
-            	    $all = $Spotter->countAllAircraftTypes($limit);
87
-                }
88
-                return $all;
77
+				 try {
78
+						$sth = $this->db->prepare($query);
79
+						$sth->execute();
80
+				} catch(PDOException $e) {
81
+						echo "error : ".$e->getMessage();
82
+				}
83
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
84
+				if (empty($all)) {
85
+					$Spotter = new Spotter($this->db);
86
+					$all = $Spotter->countAllAircraftTypes($limit);
87
+				}
88
+				return $all;
89 89
 	}
90 90
 	public function countAllAirlineCountries($limit = true) {
91 91
 		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 GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
92 92
 		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 GROUP BY airline_country ORDER BY airline_country_count DESC";
93
-                 try {
94
-                        $sth = $this->db->prepare($query);
95
-                        $sth->execute();
96
-                } catch(PDOException $e) {
97
-                        echo "error : ".$e->getMessage();
98
-                }
99
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
100
-                if (empty($all)) {
101
-            		$Spotter = new Spotter($this->db);
102
-            		$all = $Spotter->countAllAirlineCountries($limit);
93
+				 try {
94
+						$sth = $this->db->prepare($query);
95
+						$sth->execute();
96
+				} catch(PDOException $e) {
97
+						echo "error : ".$e->getMessage();
98
+				}
99
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
100
+				if (empty($all)) {
101
+					$Spotter = new Spotter($this->db);
102
+					$all = $Spotter->countAllAirlineCountries($limit);
103 103
                 
104
-                }
105
-                return $all;
104
+				}
105
+				return $all;
106 106
 	}
107 107
 	public function countAllAircraftManufacturers($limit = true) {
108 108
 		if ($limit) $query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
109 109
 		else $query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC";
110
-                 try {
111
-                        $sth = $this->db->prepare($query);
112
-                        $sth->execute();
113
-                } catch(PDOException $e) {
114
-                        echo "error : ".$e->getMessage();
115
-                }
116
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
117
-                if (empty($all)) {
118
-            		$Spotter = new Spotter($this->db);
110
+				 try {
111
+						$sth = $this->db->prepare($query);
112
+						$sth->execute();
113
+				} catch(PDOException $e) {
114
+						echo "error : ".$e->getMessage();
115
+				}
116
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
117
+				if (empty($all)) {
118
+					$Spotter = new Spotter($this->db);
119 119
 			$all = $Spotter->countAllAircraftManufacturers($limit);
120
-                }
121
-                return $all;
120
+				}
121
+				return $all;
122 122
 	}
123 123
 
124 124
 	public function countAllArrivalCountries($limit = true) {
125 125
 		if ($limit) $query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
126 126
 		else $query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly'";
127
-                 try {
128
-                        $sth = $this->db->prepare($query);
129
-                        $sth->execute();
130
-                } catch(PDOException $e) {
131
-                        echo "error : ".$e->getMessage();
132
-                }
133
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
134
-                if (empty($all)) {
135
-	                $Spotter = new Spotter($this->db);
136
-            		$all = $Spotter->countAllArrivalCountries($limit);
137
-                }
138
-                return $all;
127
+				 try {
128
+						$sth = $this->db->prepare($query);
129
+						$sth->execute();
130
+				} catch(PDOException $e) {
131
+						echo "error : ".$e->getMessage();
132
+				}
133
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
134
+				if (empty($all)) {
135
+					$Spotter = new Spotter($this->db);
136
+					$all = $Spotter->countAllArrivalCountries($limit);
137
+				}
138
+				return $all;
139 139
 	}
140 140
 	public function countAllDepartureCountries($limit = true) {
141 141
 		if ($limit) $query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
142 142
 		else $query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly'";
143
-                 try {
144
-                        $sth = $this->db->prepare($query);
145
-                        $sth->execute();
146
-                } catch(PDOException $e) {
147
-                        echo "error : ".$e->getMessage();
148
-                }
149
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
150
-                if (empty($all)) {
151
-		        $Spotter = new Spotter($this->db);
152
-    	    	        $all = $Spotter->countAllDepartureCountries($limit);
153
-                }
154
-                return $all;
143
+				 try {
144
+						$sth = $this->db->prepare($query);
145
+						$sth->execute();
146
+				} catch(PDOException $e) {
147
+						echo "error : ".$e->getMessage();
148
+				}
149
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
150
+				if (empty($all)) {
151
+				$Spotter = new Spotter($this->db);
152
+						$all = $Spotter->countAllDepartureCountries($limit);
153
+				}
154
+				return $all;
155 155
 	}
156 156
 
157 157
 	public function countAllAirlines($limit = true) {
158 158
 		if ($limit) $query = "SELECT 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 = airline_icao ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
159 159
 		else $query = "SELECT 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 = airline_icao ORDER BY airline_count DESC";
160
-                 try {
161
-                        $sth = $this->db->prepare($query);
162
-                        $sth->execute();
163
-                } catch(PDOException $e) {
164
-                        echo "error : ".$e->getMessage();
165
-                }
166
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
167
-                if (empty($all)) {
168
-	                $Spotter = new Spotter($this->db);
169
-    		        $all = $Spotter->countAllAirlines($limit);
170
-                }
171
-                return $all;
160
+				 try {
161
+						$sth = $this->db->prepare($query);
162
+						$sth->execute();
163
+				} catch(PDOException $e) {
164
+						echo "error : ".$e->getMessage();
165
+				}
166
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
167
+				if (empty($all)) {
168
+					$Spotter = new Spotter($this->db);
169
+					$all = $Spotter->countAllAirlines($limit);
170
+				}
171
+				return $all;
172 172
 	}
173 173
 	public function countAllAircraftRegistrations($limit = true) {
174 174
 		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 ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
175 175
 		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 ORDER BY aircraft_registration_count DESC";
176
-                 try {
177
-                        $sth = $this->db->prepare($query);
178
-                        $sth->execute();
179
-                } catch(PDOException $e) {
180
-                        echo "error : ".$e->getMessage();
181
-                }
182
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
183
-                if (empty($all)) {
184
-	                $Spotter = new Spotter($this->db);
185
-    		        $all = $Spotter->countAllAircraftRegistrations($limit);
186
-                }
187
-                return $all;
176
+				 try {
177
+						$sth = $this->db->prepare($query);
178
+						$sth->execute();
179
+				} catch(PDOException $e) {
180
+						echo "error : ".$e->getMessage();
181
+				}
182
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
183
+				if (empty($all)) {
184
+					$Spotter = new Spotter($this->db);
185
+					$all = $Spotter->countAllAircraftRegistrations($limit);
186
+				}
187
+				return $all;
188 188
 	}
189 189
 	public function countAllCallsigns($limit = true) {
190 190
 		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 ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
191 191
 		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 ORDER BY callsign_icao_count DESC";
192
-                 try {
193
-                        $sth = $this->db->prepare($query);
194
-                        $sth->execute();
195
-                } catch(PDOException $e) {
196
-                        echo "error : ".$e->getMessage();
197
-                }
198
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
199
-                if (empty($all)) {
200
-	                $Spotter = new Spotter($this->db);
201
-    		        $all = $Spotter->countAllCallsigns($limit);
202
-                }
203
-                return $all;
192
+				 try {
193
+						$sth = $this->db->prepare($query);
194
+						$sth->execute();
195
+				} catch(PDOException $e) {
196
+						echo "error : ".$e->getMessage();
197
+				}
198
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
199
+				if (empty($all)) {
200
+					$Spotter = new Spotter($this->db);
201
+					$all = $Spotter->countAllCallsigns($limit);
202
+				}
203
+				return $all;
204 204
 	}
205 205
 	public function countAllFlightOverCountries($limit = true) {
206 206
 		$Connection = new Connection();
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 				echo "error : ".$e->getMessage();
215 215
 			}
216 216
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
217
-                /*
217
+				/*
218 218
                 if (empty($all)) {
219 219
 	                $Spotter = new Spotter($this->db);
220 220
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -228,102 +228,102 @@  discard block
 block discarded – undo
228 228
 	public function countAllPilots($limit = true) {
229 229
 		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
230 230
 		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC";
231
-                 try {
232
-                        $sth = $this->db->prepare($query);
233
-                        $sth->execute();
234
-                } catch(PDOException $e) {
235
-                        echo "error : ".$e->getMessage();
236
-                }
237
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
238
-                if (empty($all)) {
239
-            		$Spotter = new Spotter($this->db);
240
-            		$all = $Spotter->countAllPilots($limit);
241
-                }
242
-                return $all;
231
+				 try {
232
+						$sth = $this->db->prepare($query);
233
+						$sth->execute();
234
+				} catch(PDOException $e) {
235
+						echo "error : ".$e->getMessage();
236
+				}
237
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
238
+				if (empty($all)) {
239
+					$Spotter = new Spotter($this->db);
240
+					$all = $Spotter->countAllPilots($limit);
241
+				}
242
+				return $all;
243 243
 	}
244 244
 	public function countAllOwners($limit = true) {
245 245
 		if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
246 246
 		else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC";
247
-                 try {
248
-                        $sth = $this->db->prepare($query);
249
-                        $sth->execute();
250
-                } catch(PDOException $e) {
251
-                        echo "error : ".$e->getMessage();
252
-                }
253
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
254
-                if (empty($all)) {
255
-            		$Spotter = new Spotter($this->db);
256
-            		$all = $Spotter->countAllOwners($limit);
257
-                }
258
-                return $all;
247
+				 try {
248
+						$sth = $this->db->prepare($query);
249
+						$sth->execute();
250
+				} catch(PDOException $e) {
251
+						echo "error : ".$e->getMessage();
252
+				}
253
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
254
+				if (empty($all)) {
255
+					$Spotter = new Spotter($this->db);
256
+					$all = $Spotter->countAllOwners($limit);
257
+				}
258
+				return $all;
259 259
 	}
260 260
 	public function countAllDepartureAirports($limit = true) {
261 261
 		if ($limit) $query = "SELECT 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 stats_type = 'yearly' LIMIT 10 OFFSET 0";
262 262
 		else $query = "SELECT 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 stats_type = 'yearly'";
263
-                 try {
264
-                        $sth = $this->db->prepare($query);
265
-                        $sth->execute();
266
-                } catch(PDOException $e) {
267
-                        echo "error : ".$e->getMessage();
268
-                }
269
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
270
-                if (empty($all)) {
271
-            		$Spotter = new Spotter($this->db);
272
-            		$pall = $Spotter->countAllDepartureAirports($limit);
273
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit);
274
-        		$all = array();
275
-        		foreach ($pall as $value) {
276
-        			$icao = $value['airport_departure_icao'];
277
-        			$all[$icao] = $value;
278
-        		}
263
+				 try {
264
+						$sth = $this->db->prepare($query);
265
+						$sth->execute();
266
+				} catch(PDOException $e) {
267
+						echo "error : ".$e->getMessage();
268
+				}
269
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
270
+				if (empty($all)) {
271
+					$Spotter = new Spotter($this->db);
272
+					$pall = $Spotter->countAllDepartureAirports($limit);
273
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit);
274
+				$all = array();
275
+				foreach ($pall as $value) {
276
+					$icao = $value['airport_departure_icao'];
277
+					$all[$icao] = $value;
278
+				}
279 279
         		
280
-        		foreach ($dall as $value) {
281
-        			$icao = $value['airport_departure_icao'];
282
-        			if (isset($all[$icao])) {                                                           
283
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
284
-        			} else $all[$icao] = $value;
285
-        		}
286
-        		$count = array();
287
-        		foreach ($all as $key => $row) {
288
-        			$count[$key] = $row['airport_departure_icao_count'];
289
-        		}
290
-        		array_multisort($count,SORT_DESC,$all);
291
-                }
292
-                return $all;
280
+				foreach ($dall as $value) {
281
+					$icao = $value['airport_departure_icao'];
282
+					if (isset($all[$icao])) {                                                           
283
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
284
+					} else $all[$icao] = $value;
285
+				}
286
+				$count = array();
287
+				foreach ($all as $key => $row) {
288
+					$count[$key] = $row['airport_departure_icao_count'];
289
+				}
290
+				array_multisort($count,SORT_DESC,$all);
291
+				}
292
+				return $all;
293 293
 	}
294 294
 	public function countAllArrivalAirports($limit = true) {
295 295
 		if ($limit) $query = "SELECT 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 stats_type = 'yearly' LIMIT 10 OFFSET 0";
296 296
 		else $query = "SELECT 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 stats_type = 'yearly'";
297
-                 try {
298
-                        $sth = $this->db->prepare($query);
299
-                        $sth->execute();
300
-                } catch(PDOException $e) {
301
-                        echo "error : ".$e->getMessage();
302
-                }
303
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
304
-                if (empty($all)) {
305
-            		$Spotter = new Spotter($this->db);
306
-        		$pall = $Spotter->countAllArrivalAirports($limit);
307
-        		$dall = $Spotter->countAllDetectedArrivalAirports($limit);
308
-        		$all = array();
309
-        		foreach ($pall as $value) {
310
-        			$icao = $value['airport_arrival_icao'];
311
-        			$all[$icao] = $value;
312
-        		}
297
+				 try {
298
+						$sth = $this->db->prepare($query);
299
+						$sth->execute();
300
+				} catch(PDOException $e) {
301
+						echo "error : ".$e->getMessage();
302
+				}
303
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
304
+				if (empty($all)) {
305
+					$Spotter = new Spotter($this->db);
306
+				$pall = $Spotter->countAllArrivalAirports($limit);
307
+				$dall = $Spotter->countAllDetectedArrivalAirports($limit);
308
+				$all = array();
309
+				foreach ($pall as $value) {
310
+					$icao = $value['airport_arrival_icao'];
311
+					$all[$icao] = $value;
312
+				}
313 313
         		
314
-        		foreach ($dall as $value) {
315
-        			$icao = $value['airport_arrival_icao'];
316
-        			if (isset($all[$icao])) {
317
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
318
-        			} else $all[$icao] = $value;
319
-        		}
320
-        		$count = array();
321
-        		foreach ($all as $key => $row) {
322
-        			$count[$key] = $row['airport_arrival_icao_count'];
323
-        		}
324
-        		array_multisort($count,SORT_DESC,$all);
325
-                }
326
-                return $all;
314
+				foreach ($dall as $value) {
315
+					$icao = $value['airport_arrival_icao'];
316
+					if (isset($all[$icao])) {
317
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
318
+					} else $all[$icao] = $value;
319
+				}
320
+				$count = array();
321
+				foreach ($all as $key => $row) {
322
+					$count[$key] = $row['airport_arrival_icao_count'];
323
+				}
324
+				array_multisort($count,SORT_DESC,$all);
325
+				}
326
+				return $all;
327 327
 	}
328 328
 	public function countAllMonthsLastYear($limit = true) {
329 329
 		global $globalDBdriver;
@@ -335,35 +335,35 @@  discard block
 block discarded – undo
335 335
 			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'";
336 336
 		}
337 337
 		$query_data = array();
338
-                 try {
339
-                        $sth = $this->db->prepare($query);
340
-                        $sth->execute($query_data);
341
-                } catch(PDOException $e) {
342
-                        echo "error : ".$e->getMessage();
343
-                }
344
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
345
-                if (empty($all)) {
346
-            		$Spotter = new Spotter($this->db);
347
-            		$all = $Spotter->countAllMonthsLastYear($limit);
348
-                }
349
-                return $all;
338
+				 try {
339
+						$sth = $this->db->prepare($query);
340
+						$sth->execute($query_data);
341
+				} catch(PDOException $e) {
342
+						echo "error : ".$e->getMessage();
343
+				}
344
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
345
+				if (empty($all)) {
346
+					$Spotter = new Spotter($this->db);
347
+					$all = $Spotter->countAllMonthsLastYear($limit);
348
+				}
349
+				return $all;
350 350
 	}
351 351
 	
352 352
 	public function countAllDatesLastMonth() {
353 353
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month'";
354 354
 		$query_data = array();
355
-                 try {
356
-                        $sth = $this->db->prepare($query);
357
-                        $sth->execute($query_data);
358
-                } catch(PDOException $e) {
359
-                        echo "error : ".$e->getMessage();
360
-                }
361
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
362
-                if (empty($all)) {
363
-            		$Spotter = new Spotter($this->db);
364
-            		$all = $Spotter->countAllDatesLastMonth();
365
-                }
366
-                return $all;
355
+				 try {
356
+						$sth = $this->db->prepare($query);
357
+						$sth->execute($query_data);
358
+				} catch(PDOException $e) {
359
+						echo "error : ".$e->getMessage();
360
+				}
361
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
362
+				if (empty($all)) {
363
+					$Spotter = new Spotter($this->db);
364
+					$all = $Spotter->countAllDatesLastMonth();
365
+				}
366
+				return $all;
367 367
 	}
368 368
 	public function countAllDatesLast7Days() {
369 369
 		global $globalDBdriver;
@@ -373,64 +373,64 @@  discard block
 block discarded – undo
373 373
 			$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'";
374 374
 		}
375 375
 		$query_data = array();
376
-                 try {
377
-                        $sth = $this->db->prepare($query);
378
-                        $sth->execute($query_data);
379
-                } catch(PDOException $e) {
380
-                        echo "error : ".$e->getMessage();
381
-                }
382
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
383
-                if (empty($all)) {
384
-            		$Spotter = new Spotter($this->db);
385
-            		$all = $Spotter->countAllDatesLast7Days();
386
-                }
387
-                return $all;
376
+				 try {
377
+						$sth = $this->db->prepare($query);
378
+						$sth->execute($query_data);
379
+				} catch(PDOException $e) {
380
+						echo "error : ".$e->getMessage();
381
+				}
382
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
383
+				if (empty($all)) {
384
+					$Spotter = new Spotter($this->db);
385
+					$all = $Spotter->countAllDatesLast7Days();
386
+				}
387
+				return $all;
388 388
 	}
389 389
 	public function countAllDates() {
390 390
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date'";
391 391
 		$query_data = array();
392
-                 try {
393
-                        $sth = $this->db->prepare($query);
394
-                        $sth->execute($query_data);
395
-                } catch(PDOException $e) {
396
-                        echo "error : ".$e->getMessage();
397
-                }
398
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
399
-                if (empty($all)) {
400
-            		$Spotter = new Spotter($this->db);
401
-            		$all = $Spotter->countAllDates();
402
-                }
403
-                return $all;
392
+				 try {
393
+						$sth = $this->db->prepare($query);
394
+						$sth->execute($query_data);
395
+				} catch(PDOException $e) {
396
+						echo "error : ".$e->getMessage();
397
+				}
398
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
399
+				if (empty($all)) {
400
+					$Spotter = new Spotter($this->db);
401
+					$all = $Spotter->countAllDates();
402
+				}
403
+				return $all;
404 404
 	}
405 405
 	public function countAllMonths() {
406
-	    	$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'";
407
-                 try {
408
-                        $sth = $this->db->prepare($query);
409
-                        $sth->execute();
410
-                } catch(PDOException $e) {
411
-                        echo "error : ".$e->getMessage();
412
-                }
413
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
414
-                if (empty($all)) {
415
-            		$Spotter = new Spotter($this->db);
416
-            		$all = $Spotter->countAllMonths();
417
-                }
418
-                return $all;
406
+			$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'";
407
+				 try {
408
+						$sth = $this->db->prepare($query);
409
+						$sth->execute();
410
+				} catch(PDOException $e) {
411
+						echo "error : ".$e->getMessage();
412
+				}
413
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
414
+				if (empty($all)) {
415
+					$Spotter = new Spotter($this->db);
416
+					$all = $Spotter->countAllMonths();
417
+				}
418
+				return $all;
419 419
 	}
420 420
 	public function countAllMilitaryMonths() {
421
-	    	$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'";
422
-                 try {
423
-                        $sth = $this->db->prepare($query);
424
-                        $sth->execute();
425
-                } catch(PDOException $e) {
426
-                        echo "error : ".$e->getMessage();
427
-                }
428
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
429
-                if (empty($all)) {
430
-            		$Spotter = new Spotter($this->db);
431
-            		$all = $Spotter->countAllMilitaryMonths();
432
-                }
433
-                return $all;
421
+			$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'";
422
+				 try {
423
+						$sth = $this->db->prepare($query);
424
+						$sth->execute();
425
+				} catch(PDOException $e) {
426
+						echo "error : ".$e->getMessage();
427
+				}
428
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
429
+				if (empty($all)) {
430
+					$Spotter = new Spotter($this->db);
431
+					$all = $Spotter->countAllMilitaryMonths();
432
+				}
433
+				return $all;
434 434
 	}
435 435
 	public function countAllHours($orderby = 'hour',$limit = true) {
436 436
 		global $globalTimezone, $globalDBdriver;
@@ -445,18 +445,18 @@  discard block
 block discarded – undo
445 445
 			}
446 446
 		}
447 447
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
448
-                 try {
449
-                        $sth = $this->db->prepare($query);
450
-                        $sth->execute();
451
-                } catch(PDOException $e) {
452
-                        echo "error : ".$e->getMessage();
453
-                }
454
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
455
-                if (empty($all)) {
456
-            		$Spotter = new Spotter($this->db);
457
-            		$all = $Spotter->countAllHours($orderby,$limit);
458
-                }
459
-                return $all;
448
+				 try {
449
+						$sth = $this->db->prepare($query);
450
+						$sth->execute();
451
+				} catch(PDOException $e) {
452
+						echo "error : ".$e->getMessage();
453
+				}
454
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
455
+				if (empty($all)) {
456
+					$Spotter = new Spotter($this->db);
457
+					$all = $Spotter->countAllHours($orderby,$limit);
458
+				}
459
+				return $all;
460 460
 	}
461 461
 	
462 462
 	public function countOverallFlights() {
@@ -493,14 +493,14 @@  discard block
 block discarded – undo
493 493
 	}
494 494
 	public function countOverallAirlines() {
495 495
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline";
496
-                 try {
497
-                        $sth = $this->db->prepare($query);
498
-                        $sth->execute();
499
-                } catch(PDOException $e) {
500
-                        echo "error : ".$e->getMessage();
501
-                }
502
-                $result = $sth->fetchAll(PDO::FETCH_ASSOC);
503
-                $all = $result[0]['nb_airline'];
496
+				 try {
497
+						$sth = $this->db->prepare($query);
498
+						$sth->execute();
499
+				} catch(PDOException $e) {
500
+						echo "error : ".$e->getMessage();
501
+				}
502
+				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
503
+				$all = $result[0]['nb_airline'];
504 504
 		//$all = $this->getSumStats('airlines_bymonth',date('Y'));
505 505
 		if (empty($all)) {
506 506
 			$Spotter = new Spotter($this->db);
@@ -539,157 +539,157 @@  discard block
 block discarded – undo
539 539
 	public function getLast7DaysAirports($airport_icao = '') {
540 540
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao ORDER BY date";
541 541
 		$query_values = array(':airport_icao' => $airport_icao);
542
-                 try {
543
-                        $sth = $this->db->prepare($query);
544
-                        $sth->execute($query_values);
545
-                } catch(PDOException $e) {
546
-                        echo "error : ".$e->getMessage();
547
-                }
548
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
549
-                return $all;
542
+				 try {
543
+						$sth = $this->db->prepare($query);
544
+						$sth->execute($query_values);
545
+				} catch(PDOException $e) {
546
+						echo "error : ".$e->getMessage();
547
+				}
548
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
549
+				return $all;
550 550
 	}
551 551
 	public function getStats($type) {
552
-                $query = "SELECT * FROM stats WHERE stats_type = :type ORDER BY stats_date";
553
-                $query_values = array(':type' => $type);
554
-                 try {
555
-                        $sth = $this->db->prepare($query);
556
-                        $sth->execute($query_values);
557
-                } catch(PDOException $e) {
558
-                        echo "error : ".$e->getMessage();
559
-                }
560
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
561
-                return $all;
562
-        }
552
+				$query = "SELECT * FROM stats WHERE stats_type = :type ORDER BY stats_date";
553
+				$query_values = array(':type' => $type);
554
+				 try {
555
+						$sth = $this->db->prepare($query);
556
+						$sth->execute($query_values);
557
+				} catch(PDOException $e) {
558
+						echo "error : ".$e->getMessage();
559
+				}
560
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
561
+				return $all;
562
+		}
563 563
 	public function getSumStats($type,$year) {
564
-    		global $globalArchiveMonths, $globalDBdriver;
565
-    		if ($globalDBdriver == 'mysql') {
566
-	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year";
567
-	        } else {
568
-            		$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year";
569
-                }
570
-                $query_values = array(':type' => $type, ':year' => $year);
571
-                 try {
572
-                        $sth = $this->db->prepare($query);
573
-                        $sth->execute($query_values);
574
-                } catch(PDOException $e) {
575
-                        echo "error : ".$e->getMessage();
576
-                }
577
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
578
-                return $all[0]['total'];
579
-        }
564
+			global $globalArchiveMonths, $globalDBdriver;
565
+			if ($globalDBdriver == 'mysql') {
566
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year";
567
+			} else {
568
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year";
569
+				}
570
+				$query_values = array(':type' => $type, ':year' => $year);
571
+				 try {
572
+						$sth = $this->db->prepare($query);
573
+						$sth->execute($query_values);
574
+				} catch(PDOException $e) {
575
+						echo "error : ".$e->getMessage();
576
+				}
577
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
578
+				return $all[0]['total'];
579
+		}
580 580
 	public function getStatsTotal($type) {
581
-    		global $globalArchiveMonths, $globalDBdriver;
582
-    		if ($globalDBdriver == 'mysql') {
581
+			global $globalArchiveMonths, $globalDBdriver;
582
+			if ($globalDBdriver == 'mysql') {
583 583
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH)";
584 584
 		} else {
585 585
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS'";
586
-                }
587
-                $query_values = array(':type' => $type);
588
-                 try {
589
-                        $sth = $this->db->prepare($query);
590
-                        $sth->execute($query_values);
591
-                } catch(PDOException $e) {
592
-                        echo "error : ".$e->getMessage();
593
-                }
594
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
595
-                return $all[0]['total'];
596
-        }
586
+				}
587
+				$query_values = array(':type' => $type);
588
+				 try {
589
+						$sth = $this->db->prepare($query);
590
+						$sth->execute($query_values);
591
+				} catch(PDOException $e) {
592
+						echo "error : ".$e->getMessage();
593
+				}
594
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
595
+				return $all[0]['total'];
596
+		}
597 597
 	public function getStatsAircraftTotal() {
598
-    		global $globalArchiveMonths, $globalDBdriver;
599
-    		if ($globalDBdriver == 'mysql') {
598
+			global $globalArchiveMonths, $globalDBdriver;
599
+			if ($globalDBdriver == 'mysql') {
600 600
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft";
601
-                } else {
601
+				} else {
602 602
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft";
603
-                }
604
-                 try {
605
-                        $sth = $this->db->prepare($query);
606
-                        $sth->execute();
607
-                } catch(PDOException $e) {
608
-                        echo "error : ".$e->getMessage();
609
-                }
610
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
611
-                return $all[0]['total'];
612
-        }
603
+				}
604
+				 try {
605
+						$sth = $this->db->prepare($query);
606
+						$sth->execute();
607
+				} catch(PDOException $e) {
608
+						echo "error : ".$e->getMessage();
609
+				}
610
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
611
+				return $all[0]['total'];
612
+		}
613 613
 	public function getStatsAirlineTotal() {
614
-    		global $globalArchiveMonths, $globalDBdriver;
615
-    		if ($globalDBdriver == 'mysql') {
614
+			global $globalArchiveMonths, $globalDBdriver;
615
+			if ($globalDBdriver == 'mysql') {
616 616
 			$query = "SELECT SUM(cnt) as total FROM stats_airline";
617
-                } else {
617
+				} else {
618 618
 			$query = "SELECT SUM(cnt) as total FROM stats_airline";
619
-                }
620
-                 try {
621
-                        $sth = $this->db->prepare($query);
622
-                        $sth->execute();
623
-                } catch(PDOException $e) {
624
-                        echo "error : ".$e->getMessage();
625
-                }
626
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
627
-                return $all[0]['total'];
628
-        }
619
+				}
620
+				 try {
621
+						$sth = $this->db->prepare($query);
622
+						$sth->execute();
623
+				} catch(PDOException $e) {
624
+						echo "error : ".$e->getMessage();
625
+				}
626
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
627
+				return $all[0]['total'];
628
+		}
629 629
 	public function getStatsOwnerTotal() {
630
-    		global $globalArchiveMonths, $globalDBdriver;
631
-    		if ($globalDBdriver == 'mysql') {
630
+			global $globalArchiveMonths, $globalDBdriver;
631
+			if ($globalDBdriver == 'mysql') {
632 632
 			$query = "SELECT SUM(cnt) as total FROM stats_owner";
633 633
 		} else {
634 634
 			$query = "SELECT SUM(cnt) as total FROM stats_owner";
635
-                }
636
-                 try {
637
-                        $sth = $this->db->prepare($query);
638
-                        $sth->execute();
639
-                } catch(PDOException $e) {
640
-                        echo "error : ".$e->getMessage();
641
-                }
642
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
643
-                return $all[0]['total'];
644
-        }
635
+				}
636
+				 try {
637
+						$sth = $this->db->prepare($query);
638
+						$sth->execute();
639
+				} catch(PDOException $e) {
640
+						echo "error : ".$e->getMessage();
641
+				}
642
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
643
+				return $all[0]['total'];
644
+		}
645 645
 	public function getStatsPilotTotal() {
646
-    		global $globalArchiveMonths, $globalDBdriver;
647
-    		if ($globalDBdriver == 'mysql') {
648
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot";
649
-            	} else {
650
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot";
651
-            	}
652
-                 try {
653
-                        $sth = $this->db->prepare($query);
654
-                        $sth->execute();
655
-                } catch(PDOException $e) {
656
-                        echo "error : ".$e->getMessage();
657
-                }
658
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
659
-                return $all[0]['total'];
660
-        }
646
+			global $globalArchiveMonths, $globalDBdriver;
647
+			if ($globalDBdriver == 'mysql') {
648
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot";
649
+				} else {
650
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot";
651
+				}
652
+				 try {
653
+						$sth = $this->db->prepare($query);
654
+						$sth->execute();
655
+				} catch(PDOException $e) {
656
+						echo "error : ".$e->getMessage();
657
+				}
658
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
659
+				return $all[0]['total'];
660
+		}
661 661
 
662 662
 	public function addStat($type,$cnt,$stats_date) {
663 663
 		global $globalDBdriver;
664 664
 		if ($globalDBdriver == 'mysql') {
665 665
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = :cnt";
666
-                } else {
666
+				} else {
667 667
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date; INSERT INTO stats (stats_type,cnt,stats_date) SELECT :type,:cnt,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date);"; 
668 668
 		}
669
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
670
-                 try {
671
-                        $sth = $this->db->prepare($query);
672
-                        $sth->execute($query_values);
673
-                } catch(PDOException $e) {
674
-                        return "error : ".$e->getMessage();
675
-                }
676
-        }
669
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
670
+				 try {
671
+						$sth = $this->db->prepare($query);
672
+						$sth->execute($query_values);
673
+				} catch(PDOException $e) {
674
+						return "error : ".$e->getMessage();
675
+				}
676
+		}
677 677
 	public function updateStat($type,$cnt,$stats_date) {
678 678
 		global $globalDBdriver;
679 679
 		if ($globalDBdriver == 'mysql') {
680 680
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
681 681
 		} else {
682
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
682
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
683 683
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date; INSERT INTO stats (stats_type,cnt,stats_date) SELECT :type,:cnt,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date);"; 
684
-                }
685
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
686
-                 try {
687
-                        $sth = $this->db->prepare($query);
688
-                        $sth->execute($query_values);
689
-                } catch(PDOException $e) {
690
-                        return "error : ".$e->getMessage();
691
-                }
692
-        }
684
+				}
685
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
686
+				 try {
687
+						$sth = $this->db->prepare($query);
688
+						$sth->execute($query_values);
689
+				} catch(PDOException $e) {
690
+						return "error : ".$e->getMessage();
691
+				}
692
+		}
693 693
 	public function getStatsSource($date,$stats_type = '') {
694 694
 		if ($stats_type == '') {
695 695
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -698,15 +698,15 @@  discard block
 block discarded – undo
698 698
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
699 699
 			$query_values = array(':date' => $date,':stats_type' => $stats_type);
700 700
 		}
701
-                 try {
702
-                        $sth = $this->db->prepare($query);
703
-                        $sth->execute($query_values);
704
-                } catch(PDOException $e) {
705
-                        echo "error : ".$e->getMessage();
706
-                }
707
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
708
-                return $all;
709
-        }
701
+				 try {
702
+						$sth = $this->db->prepare($query);
703
+						$sth->execute($query_values);
704
+				} catch(PDOException $e) {
705
+						echo "error : ".$e->getMessage();
706
+				}
707
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
708
+				return $all;
709
+		}
710 710
 
711 711
 	public function addStatSource($data,$source_name,$stats_type,$date) {
712 712
 		global $globalDBdriver;
@@ -714,25 +714,25 @@  discard block
 block discarded – undo
714 714
 			$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";
715 715
 		} else {
716 716
 			$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);"; 
717
-                }
718
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
719
-                 try {
720
-                        $sth = $this->db->prepare($query);
721
-                        $sth->execute($query_values);
722
-                } catch(PDOException $e) {
723
-                        return "error : ".$e->getMessage();
724
-                }
725
-        }
717
+				}
718
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
719
+				 try {
720
+						$sth = $this->db->prepare($query);
721
+						$sth->execute($query_values);
722
+				} catch(PDOException $e) {
723
+						return "error : ".$e->getMessage();
724
+				}
725
+		}
726 726
 	public function addStatFlight($type,$date_name,$cnt) {
727
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt) VALUES (:type,:flight_date,:cnt)";
728
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt);
729
-                 try {
730
-                        $sth = $this->db->prepare($query);
731
-                        $sth->execute($query_values);
732
-                } catch(PDOException $e) {
733
-                        return "error : ".$e->getMessage();
734
-                }
735
-        }
727
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt) VALUES (:type,:flight_date,:cnt)";
728
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt);
729
+				 try {
730
+						$sth = $this->db->prepare($query);
731
+						$sth->execute($query_values);
732
+				} catch(PDOException $e) {
733
+						return "error : ".$e->getMessage();
734
+				}
735
+		}
736 736
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '') {
737 737
 		global $globalDBdriver;
738 738
 		if ($globalDBdriver == 'mysql') {
@@ -740,14 +740,14 @@  discard block
 block discarded – undo
740 740
 		} else {
741 741
 			$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration; INSERT INTO stats_registration (aircraft_icao,registration,cnt) SELECT :aircraft_icao,:registration,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration);"; 
742 742
 		}
743
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt);
744
-                 try {
745
-                        $sth = $this->db->prepare($query);
746
-                        $sth->execute($query_values);
747
-                } catch(PDOException $e) {
748
-                        return "error : ".$e->getMessage();
749
-                }
750
-        }
743
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt);
744
+				 try {
745
+						$sth = $this->db->prepare($query);
746
+						$sth->execute($query_values);
747
+				} catch(PDOException $e) {
748
+						return "error : ".$e->getMessage();
749
+				}
750
+		}
751 751
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '') {
752 752
 		global $globalDBdriver;
753 753
 		if ($globalDBdriver == 'mysql') {
@@ -755,14 +755,14 @@  discard block
 block discarded – undo
755 755
 		} else {
756 756
 			$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt) SELECT :callsign_icao,:airline_icao,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao);"; 
757 757
 		}
758
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt);
759
-                 try {
760
-                        $sth = $this->db->prepare($query);
761
-                        $sth->execute($query_values);
762
-                } catch(PDOException $e) {
763
-                        return "error : ".$e->getMessage();
764
-                }
765
-        }
758
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt);
759
+				 try {
760
+						$sth = $this->db->prepare($query);
761
+						$sth->execute($query_values);
762
+				} catch(PDOException $e) {
763
+						return "error : ".$e->getMessage();
764
+				}
765
+		}
766 766
 	public function addStatCountry($iso2,$iso3,$name,$cnt) {
767 767
 		global $globalDBdriver;
768 768
 		if ($globalDBdriver == 'mysql') {
@@ -770,14 +770,14 @@  discard block
 block discarded – undo
770 770
 		} else {
771 771
 			$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2; INSERT INTO stats_country (iso2,iso3,name,cnt) SELECT :iso2,:iso3,:name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2);"; 
772 772
 		}
773
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt);
774
-                 try {
775
-                        $sth = $this->db->prepare($query);
776
-                        $sth->execute($query_values);
777
-                } catch(PDOException $e) {
778
-                        return "error : ".$e->getMessage();
779
-                }
780
-        }
773
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt);
774
+				 try {
775
+						$sth = $this->db->prepare($query);
776
+						$sth->execute($query_values);
777
+				} catch(PDOException $e) {
778
+						return "error : ".$e->getMessage();
779
+				}
780
+		}
781 781
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '') {
782 782
 		global $globalDBdriver;
783 783
 		if ($globalDBdriver == 'mysql') {
@@ -785,14 +785,14 @@  discard block
 block discarded – undo
785 785
 		} else {
786 786
 			$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt WHERE aircraft_icao = :aircraft_icao; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,cnt) SELECT :aircraft_icao,:aircraft_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao);"; 
787 787
 		}
788
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt);
789
-                 try {
790
-                        $sth = $this->db->prepare($query);
791
-                        $sth->execute($query_values);
792
-                } catch(PDOException $e) {
793
-                        return "error : ".$e->getMessage();
794
-                }
795
-        }
788
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt);
789
+				 try {
790
+						$sth = $this->db->prepare($query);
791
+						$sth->execute($query_values);
792
+				} catch(PDOException $e) {
793
+						return "error : ".$e->getMessage();
794
+				}
795
+		}
796 796
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '') {
797 797
 		global $globalDBdriver;
798 798
 		if ($globalDBdriver == 'mysql') {
@@ -800,14 +800,14 @@  discard block
 block discarded – undo
800 800
 		} else {
801 801
 			$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao; INSERT INTO stats_airline (airline_icao,airline_name,cnt) SELECT :airline_icao,:airline_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao);"; 
802 802
 		}
803
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt);
804
-                 try {
805
-                        $sth = $this->db->prepare($query);
806
-                        $sth->execute($query_values);
807
-                } catch(PDOException $e) {
808
-                        return "error : ".$e->getMessage();
809
-                }
810
-        }
803
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt);
804
+				 try {
805
+						$sth = $this->db->prepare($query);
806
+						$sth->execute($query_values);
807
+				} catch(PDOException $e) {
808
+						return "error : ".$e->getMessage();
809
+				}
810
+		}
811 811
 	public function addStatOwner($owner_name,$cnt) {
812 812
 		global $globalDBdriver;
813 813
 		if ($globalDBdriver == 'mysql') {
@@ -815,14 +815,14 @@  discard block
 block discarded – undo
815 815
 		} else {
816 816
 			$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name; INSERT INTO stats_owner (owner_name,cnt) SELECT :owner_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name);"; 
817 817
 		}
818
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt);
819
-                 try {
820
-                        $sth = $this->db->prepare($query);
821
-                        $sth->execute($query_values);
822
-                } catch(PDOException $e) {
823
-                        return "error : ".$e->getMessage();
824
-                }
825
-        }
818
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt);
819
+				 try {
820
+						$sth = $this->db->prepare($query);
821
+						$sth->execute($query_values);
822
+				} catch(PDOException $e) {
823
+						return "error : ".$e->getMessage();
824
+				}
825
+		}
826 826
 	public function addStatPilot($pilot_id,$cnt) {
827 827
 		global $globalDBdriver;
828 828
 		if ($globalDBdriver == 'mysql') {
@@ -830,14 +830,14 @@  discard block
 block discarded – undo
830 830
 		} else {
831 831
 			$query = "UPDATE stats_pilot SET cnt = cnt+:cnt WHERE pilot_id = :pilot_id; INSERT INTO stats_pilot (pilot_id,cnt) SELECT :pilot_id,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id);"; 
832 832
 		}
833
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt);
834
-                 try {
835
-                        $sth = $this->db->prepare($query);
836
-                        $sth->execute($query_values);
837
-                } catch(PDOException $e) {
838
-                        return "error : ".$e->getMessage();
839
-                }
840
-        }
833
+				$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt);
834
+				 try {
835
+						$sth = $this->db->prepare($query);
836
+						$sth->execute($query_values);
837
+				} catch(PDOException $e) {
838
+						return "error : ".$e->getMessage();
839
+				}
840
+		}
841 841
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure) {
842 842
 		global $globalDBdriver;
843 843
 		if ($globalDBdriver == 'mysql') {
@@ -845,14 +845,14 @@  discard block
 block discarded – undo
845 845
 		} else {
846 846
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'yearly');"; 
847 847
 		}
848
-                $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');
849
-                 try {
850
-                        $sth = $this->db->prepare($query);
851
-                        $sth->execute($query_values);
852
-                } catch(PDOException $e) {
853
-                        return "error : ".$e->getMessage();
854
-                }
855
-        }
848
+				$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');
849
+				 try {
850
+						$sth = $this->db->prepare($query);
851
+						$sth->execute($query_values);
852
+				} catch(PDOException $e) {
853
+						return "error : ".$e->getMessage();
854
+				}
855
+		}
856 856
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure) {
857 857
 		global $globalDBdriver;
858 858
 		if ($globalDBdriver == 'mysql') {
@@ -860,14 +860,14 @@  discard block
 block discarded – undo
860 860
 		} else {
861 861
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'daily');"; 
862 862
 		}
863
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date);
864
-                 try {
865
-                        $sth = $this->db->prepare($query);
866
-                        $sth->execute($query_values);
867
-                } catch(PDOException $e) {
868
-                        return "error : ".$e->getMessage();
869
-                }
870
-        }
863
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date);
864
+				 try {
865
+						$sth = $this->db->prepare($query);
866
+						$sth->execute($query_values);
867
+				} catch(PDOException $e) {
868
+						return "error : ".$e->getMessage();
869
+				}
870
+		}
871 871
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival) {
872 872
 		global $globalDBdriver;
873 873
 		if ($globalDBdriver == 'mysql') {
@@ -875,14 +875,14 @@  discard block
 block discarded – undo
875 875
 		} else {
876 876
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'yearly');"; 
877 877
 		}
878
-                $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');
879
-                 try {
880
-                        $sth = $this->db->prepare($query);
881
-                        $sth->execute($query_values);
882
-                } catch(PDOException $e) {
883
-                        return "error : ".$e->getMessage();
884
-                }
885
-        }
878
+				$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');
879
+				 try {
880
+						$sth = $this->db->prepare($query);
881
+						$sth->execute($query_values);
882
+				} catch(PDOException $e) {
883
+						return "error : ".$e->getMessage();
884
+				}
885
+		}
886 886
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival) {
887 887
 		global $globalDBdriver;
888 888
 		if ($globalDBdriver == 'mysql') {
@@ -890,55 +890,55 @@  discard block
 block discarded – undo
890 890
 		} else {
891 891
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'daily');"; 
892 892
 		}
893
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date);
894
-                 try {
895
-                        $sth = $this->db->prepare($query);
896
-                        $sth->execute($query_values);
897
-                } catch(PDOException $e) {
898
-                        return "error : ".$e->getMessage();
899
-                }
900
-        }
893
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date);
894
+				 try {
895
+						$sth = $this->db->prepare($query);
896
+						$sth->execute($query_values);
897
+				} catch(PDOException $e) {
898
+						return "error : ".$e->getMessage();
899
+				}
900
+		}
901 901
 
902 902
 	public function deleteStat($id) {
903
-                $query = "DELETE FROM stats WHERE stats_id = :id";
904
-                $query_values = array(':id' => $id);
905
-                 try {
906
-                        $sth = $this->db->prepare($query);
907
-                        $sth->execute($query_values);
908
-                } catch(PDOException $e) {
909
-                        return "error : ".$e->getMessage();
910
-                }
911
-        }
903
+				$query = "DELETE FROM stats WHERE stats_id = :id";
904
+				$query_values = array(':id' => $id);
905
+				 try {
906
+						$sth = $this->db->prepare($query);
907
+						$sth->execute($query_values);
908
+				} catch(PDOException $e) {
909
+						return "error : ".$e->getMessage();
910
+				}
911
+		}
912 912
 	public function deleteStatFlight($type) {
913
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
914
-                $query_values = array(':type' => $type);
915
-                 try {
916
-                        $sth = $this->db->prepare($query);
917
-                        $sth->execute($query_values);
918
-                } catch(PDOException $e) {
919
-                        return "error : ".$e->getMessage();
920
-                }
921
-        }
913
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
914
+				$query_values = array(':type' => $type);
915
+				 try {
916
+						$sth = $this->db->prepare($query);
917
+						$sth->execute($query_values);
918
+				} catch(PDOException $e) {
919
+						return "error : ".$e->getMessage();
920
+				}
921
+		}
922 922
 	public function deleteStatAirport($type) {
923
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
924
-                $query_values = array(':type' => $type);
925
-                 try {
926
-                        $sth = $this->db->prepare($query);
927
-                        $sth->execute($query_values);
928
-                } catch(PDOException $e) {
929
-                        return "error : ".$e->getMessage();
930
-                }
931
-        }
923
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
924
+				$query_values = array(':type' => $type);
925
+				 try {
926
+						$sth = $this->db->prepare($query);
927
+						$sth->execute($query_values);
928
+				} catch(PDOException $e) {
929
+						return "error : ".$e->getMessage();
930
+				}
931
+		}
932 932
         
933
-        public function addOldStats() {
934
-    		global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver;
935
-    		$Common = new Common();
936
-    		$Connection = new Connection();
937
-    		date_default_timezone_set('UTC');
938
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
933
+		public function addOldStats() {
934
+			global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver;
935
+			$Common = new Common();
936
+			$Connection = new Connection();
937
+			date_default_timezone_set('UTC');
938
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
939 939
 		//print_r($last_update);
940 940
 		$flightsbymonth = $this->getStats('flights_by_month');
941
-    		if (empty($last_update) && empty($flightsbymonth)) {
941
+			if (empty($last_update) && empty($flightsbymonth)) {
942 942
 			// Initial update
943 943
 			$Spotter = new Spotter($this->db);
944 944
 			$alldata = $Spotter->countAllMonths();
@@ -1079,46 +1079,46 @@  discard block
 block discarded – undo
1079 1079
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
1080 1080
 				}
1081 1081
 				$pall = $Spotter->countAllDepartureAirports(false,$globalArchiveMonths);
1082
-        			$dall = $Spotter->countAllDetectedDepartureAirports(false,$globalArchiveMonths);
1083
-	        		$alldata = array();
1084
-    				foreach ($pall as $value) {
1085
-	        			$icao = $value['airport_departure_icao'];
1086
-    					$alldata[$icao] = $value;
1087
-	        		}
1088
-	        		foreach ($dall as $value) {
1089
-    					$icao = $value['airport_departure_icao'];
1090
-        				if (isset($alldata[$icao])) {                                                           
1091
-        					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1092
-	        			} else $alldata[$icao] = $value;
1093
-    				}
1094
-        			$count = array();
1095
-        			foreach ($alldata as $key => $row) {
1096
-        				$count[$key] = $row['airport_departure_icao_count'];
1097
-	        		}
1098
-    				array_multisort($count,SORT_DESC,$alldata);
1082
+					$dall = $Spotter->countAllDetectedDepartureAirports(false,$globalArchiveMonths);
1083
+					$alldata = array();
1084
+					foreach ($pall as $value) {
1085
+						$icao = $value['airport_departure_icao'];
1086
+						$alldata[$icao] = $value;
1087
+					}
1088
+					foreach ($dall as $value) {
1089
+						$icao = $value['airport_departure_icao'];
1090
+						if (isset($alldata[$icao])) {                                                           
1091
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1092
+						} else $alldata[$icao] = $value;
1093
+					}
1094
+					$count = array();
1095
+					foreach ($alldata as $key => $row) {
1096
+						$count[$key] = $row['airport_departure_icao_count'];
1097
+					}
1098
+					array_multisort($count,SORT_DESC,$alldata);
1099 1099
 
1100 1100
 				//print_r($alldate);
1101 1101
 				foreach ($alldata as $number) {
1102 1102
 					$this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1103 1103
 				}
1104 1104
 				$pdata = $Spotter->countAllArrivalAirports(false,$globalArchiveMonths);
1105
-        			$dall = $Spotter->countAllDetectedArrivalAirports(false,$globalArchiveMonths);
1106
-	        		$alldata = array();
1107
-    				foreach ($pdata as $value) {
1108
-	        			$icao = $value['airport_arrival_icao'];
1109
-    					$alldata[$icao] = $value;
1110
-	        		}
1111
-	        		foreach ($dall as $value) {
1112
-    					$icao = $value['airport_arrival_icao'];
1113
-        				if (isset($alldata[$icao])) {                                                           
1114
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1115
-	        			} else $alldata[$icao] = $value;
1116
-    				}
1117
-        			$count = array();
1118
-        			foreach ($alldata as $key => $row) {
1119
-        				$count[$key] = $row['airport_arrival_icao_count'];
1120
-	        		}
1121
-    				array_multisort($count,SORT_DESC,$alldata);
1105
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,$globalArchiveMonths);
1106
+					$alldata = array();
1107
+					foreach ($pdata as $value) {
1108
+						$icao = $value['airport_arrival_icao'];
1109
+						$alldata[$icao] = $value;
1110
+					}
1111
+					foreach ($dall as $value) {
1112
+						$icao = $value['airport_arrival_icao'];
1113
+						if (isset($alldata[$icao])) {                                                           
1114
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1115
+						} else $alldata[$icao] = $value;
1116
+					}
1117
+					$count = array();
1118
+					foreach ($alldata as $key => $row) {
1119
+						$count[$key] = $row['airport_arrival_icao_count'];
1120
+					}
1121
+					array_multisort($count,SORT_DESC,$alldata);
1122 1122
 				foreach ($alldata as $number) {
1123 1123
 					$this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1124 1124
 				}
@@ -1186,46 +1186,46 @@  discard block
 block discarded – undo
1186 1186
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
1187 1187
 			}
1188 1188
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1189
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1190
-	        	$alldata = array();
1191
-    			foreach ($pall as $value) {
1192
-	        		$icao = $value['airport_departure_icao'];
1193
-    				$alldata[$icao] = $value;
1194
-	        	}
1195
-	        	foreach ($dall as $value) {
1196
-    				$icao = $value['airport_departure_icao'];
1197
-        			if (isset($alldata[$icao])) {                                                           
1198
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1199
-        			} else $alldata[$icao] = $value;
1189
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1190
+				$alldata = array();
1191
+				foreach ($pall as $value) {
1192
+					$icao = $value['airport_departure_icao'];
1193
+					$alldata[$icao] = $value;
1194
+				}
1195
+				foreach ($dall as $value) {
1196
+					$icao = $value['airport_departure_icao'];
1197
+					if (isset($alldata[$icao])) {                                                           
1198
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1199
+					} else $alldata[$icao] = $value;
1200 1200
 			}
1201
-    			$count = array();
1202
-    			foreach ($alldata as $key => $row) {
1203
-    				$count[$key] = $row['airport_departure_icao_count'];
1204
-        		}
1201
+				$count = array();
1202
+				foreach ($alldata as $key => $row) {
1203
+					$count[$key] = $row['airport_departure_icao_count'];
1204
+				}
1205 1205
 			array_multisort($count,SORT_DESC,$alldata);
1206 1206
 
1207 1207
 			foreach ($alldata as $number) {
1208 1208
 				$this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1209 1209
 			}
1210 1210
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1211
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1212
-	        	$alldata = array();
1213
-    			foreach ($pall as $value) {
1214
-	        		$icao = $value['airport_arrival_icao'];
1215
-    				$alldata[$icao] = $value;
1216
-	        	}
1217
-	        	foreach ($dall as $value) {
1218
-    				$icao = $value['airport_arrival_icao'];
1219
-        			if (isset($alldata[$icao])) {                                                           
1220
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1221
-	        		} else $alldata[$icao] = $value;
1222
-    			}
1223
-        		$count = array();
1224
-        		foreach ($alldata as $key => $row) {
1225
-        			$count[$key] = $row['airport_arrival_icao_count'];
1226
-	        	}
1227
-    			array_multisort($count,SORT_DESC,$alldata);
1228
-                        foreach ($alldata as $number) {
1211
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1212
+				$alldata = array();
1213
+				foreach ($pall as $value) {
1214
+					$icao = $value['airport_arrival_icao'];
1215
+					$alldata[$icao] = $value;
1216
+				}
1217
+				foreach ($dall as $value) {
1218
+					$icao = $value['airport_arrival_icao'];
1219
+					if (isset($alldata[$icao])) {                                                           
1220
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1221
+					} else $alldata[$icao] = $value;
1222
+				}
1223
+				$count = array();
1224
+				foreach ($alldata as $key => $row) {
1225
+					$count[$key] = $row['airport_arrival_icao_count'];
1226
+				}
1227
+				array_multisort($count,SORT_DESC,$alldata);
1228
+						foreach ($alldata as $number) {
1229 1229
 				$this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1230 1230
 			}
1231 1231
 			if ($Connection->tableExists('countries')) {
@@ -1275,45 +1275,45 @@  discard block
 block discarded – undo
1275 1275
 			echo '...Departure'."\n";
1276 1276
 			$this->deleteStatAirport('daily');
1277 1277
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1278
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1279
-	        	$alldata = array();
1280
-    			foreach ($pall as $value) {
1281
-	        		$icao = $value['departure_airport_icao'];
1282
-    				$alldata[$icao] = $value;
1283
-	        	}
1284
-	        	foreach ($dall as $value) {
1285
-    				$icao = $value['departure_airport_icao'];
1286
-        			if (isset($alldata[$icao])) {                                                           
1287
-        				$alldata[$icao]['departure_airport_count'] = $alldata[$icao]['departure_airport_count'] + $value['departure_airport_count'];
1288
-	        		} else $alldata[$icao] = $value;
1289
-    			}
1290
-        		$count = array();
1291
-        		foreach ($alldata as $key => $row) {
1292
-        			$count[$key] = $row['departure_airport_count'];
1293
-	        	}
1294
-    			array_multisort($count,SORT_DESC,$alldata);
1278
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1279
+				$alldata = array();
1280
+				foreach ($pall as $value) {
1281
+					$icao = $value['departure_airport_icao'];
1282
+					$alldata[$icao] = $value;
1283
+				}
1284
+				foreach ($dall as $value) {
1285
+					$icao = $value['departure_airport_icao'];
1286
+					if (isset($alldata[$icao])) {                                                           
1287
+						$alldata[$icao]['departure_airport_count'] = $alldata[$icao]['departure_airport_count'] + $value['departure_airport_count'];
1288
+					} else $alldata[$icao] = $value;
1289
+				}
1290
+				$count = array();
1291
+				foreach ($alldata as $key => $row) {
1292
+					$count[$key] = $row['departure_airport_count'];
1293
+				}
1294
+				array_multisort($count,SORT_DESC,$alldata);
1295 1295
 			foreach ($alldata as $number) {
1296 1296
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1297 1297
 			}
1298 1298
 			echo '...Arrival'."\n";
1299 1299
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1300
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1301
-	        	$alldata = array();
1302
-    			foreach ($pall as $value) {
1303
-	        		$icao = $value['arrival_airport_icao'];
1304
-    				$alldata[$icao] = $value;
1305
-	        	}
1306
-	        	foreach ($dall as $value) {
1307
-    				$icao = $value['arrival_airport_icao'];
1308
-        			if (isset($alldata[$icao])) {                                                           
1309
-        				$alldata[$icao]['arrival_airport_icao_count'] = $alldata[$icao]['arrival_airport_count'] + $value['arrival_airport_count'];
1310
-	        		} else $alldata[$icao] = $value;
1311
-    			}
1312
-        		$count = array();
1313
-        		foreach ($alldata as $key => $row) {
1314
-        			$count[$key] = $row['arrival_airport_count'];
1315
-	        	}
1316
-    			array_multisort($count,SORT_DESC,$alldata);
1300
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1301
+				$alldata = array();
1302
+				foreach ($pall as $value) {
1303
+					$icao = $value['arrival_airport_icao'];
1304
+					$alldata[$icao] = $value;
1305
+				}
1306
+				foreach ($dall as $value) {
1307
+					$icao = $value['arrival_airport_icao'];
1308
+					if (isset($alldata[$icao])) {                                                           
1309
+						$alldata[$icao]['arrival_airport_icao_count'] = $alldata[$icao]['arrival_airport_count'] + $value['arrival_airport_count'];
1310
+					} else $alldata[$icao] = $value;
1311
+				}
1312
+				$count = array();
1313
+				foreach ($alldata as $key => $row) {
1314
+					$count[$key] = $row['arrival_airport_count'];
1315
+				}
1316
+				array_multisort($count,SORT_DESC,$alldata);
1317 1317
 
1318 1318
 			foreach ($alldata as $number) {
1319 1319
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
Please login to merge, or discard this patch.
Spacing   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 		$this->db = $Connection->db;
14 14
         }
15 15
               
16
-	public function addLastStatsUpdate($type,$stats_date) {
16
+	public function addLastStatsUpdate($type, $stats_date) {
17 17
                 $query = "DELETE FROM config WHERE name = :type;
18 18
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
19
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
19
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
20 20
                  try {
21 21
                         $sth = $this->db->prepare($query);
22 22
                         $sth->execute($query_values);
23
-                } catch(PDOException $e) {
23
+                } catch (PDOException $e) {
24 24
                         return "error : ".$e->getMessage();
25 25
                 }
26 26
         }
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
                  try {
31 31
                         $sth = $this->db->prepare($query);
32 32
                         $sth->execute(array(':type' => $type));
33
-                } catch(PDOException $e) {
33
+                } catch (PDOException $e) {
34 34
                         echo "error : ".$e->getMessage();
35 35
                 }
36 36
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
                  try {
42 42
                         $sth = $this->db->prepare($query);
43 43
                         $sth->execute();
44
-                } catch(PDOException $e) {
44
+                } catch (PDOException $e) {
45 45
                         echo "error : ".$e->getMessage();
46 46
                 }
47 47
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                  try {
53 53
                         $sth = $this->db->prepare($query);
54 54
                         $sth->execute();
55
-                } catch(PDOException $e) {
55
+                } catch (PDOException $e) {
56 56
                         echo "error : ".$e->getMessage();
57 57
                 }
58 58
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                  try {
64 64
                         $sth = $this->db->prepare($query);
65 65
                         $sth->execute();
66
-                } catch(PDOException $e) {
66
+                } catch (PDOException $e) {
67 67
                         echo "error : ".$e->getMessage();
68 68
                 }
69 69
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                  try {
78 78
                         $sth = $this->db->prepare($query);
79 79
                         $sth->execute();
80
-                } catch(PDOException $e) {
80
+                } catch (PDOException $e) {
81 81
                         echo "error : ".$e->getMessage();
82 82
                 }
83 83
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                  try {
94 94
                         $sth = $this->db->prepare($query);
95 95
                         $sth->execute();
96
-                } catch(PDOException $e) {
96
+                } catch (PDOException $e) {
97 97
                         echo "error : ".$e->getMessage();
98 98
                 }
99 99
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
                  try {
111 111
                         $sth = $this->db->prepare($query);
112 112
                         $sth->execute();
113
-                } catch(PDOException $e) {
113
+                } catch (PDOException $e) {
114 114
                         echo "error : ".$e->getMessage();
115 115
                 }
116 116
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                  try {
128 128
                         $sth = $this->db->prepare($query);
129 129
                         $sth->execute();
130
-                } catch(PDOException $e) {
130
+                } catch (PDOException $e) {
131 131
                         echo "error : ".$e->getMessage();
132 132
                 }
133 133
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                  try {
144 144
                         $sth = $this->db->prepare($query);
145 145
                         $sth->execute();
146
-                } catch(PDOException $e) {
146
+                } catch (PDOException $e) {
147 147
                         echo "error : ".$e->getMessage();
148 148
                 }
149 149
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                  try {
161 161
                         $sth = $this->db->prepare($query);
162 162
                         $sth->execute();
163
-                } catch(PDOException $e) {
163
+                } catch (PDOException $e) {
164 164
                         echo "error : ".$e->getMessage();
165 165
                 }
166 166
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
                  try {
177 177
                         $sth = $this->db->prepare($query);
178 178
                         $sth->execute();
179
-                } catch(PDOException $e) {
179
+                } catch (PDOException $e) {
180 180
                         echo "error : ".$e->getMessage();
181 181
                 }
182 182
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
                  try {
193 193
                         $sth = $this->db->prepare($query);
194 194
                         $sth->execute();
195
-                } catch(PDOException $e) {
195
+                } catch (PDOException $e) {
196 196
                         echo "error : ".$e->getMessage();
197 197
                 }
198 198
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			 try {
211 211
 				$sth = $this->db->prepare($query);
212 212
 				$sth->execute();
213
-			} catch(PDOException $e) {
213
+			} catch (PDOException $e) {
214 214
 				echo "error : ".$e->getMessage();
215 215
 			}
216 216
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
                  try {
232 232
                         $sth = $this->db->prepare($query);
233 233
                         $sth->execute();
234
-                } catch(PDOException $e) {
234
+                } catch (PDOException $e) {
235 235
                         echo "error : ".$e->getMessage();
236 236
                 }
237 237
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                  try {
248 248
                         $sth = $this->db->prepare($query);
249 249
                         $sth->execute();
250
-                } catch(PDOException $e) {
250
+                } catch (PDOException $e) {
251 251
                         echo "error : ".$e->getMessage();
252 252
                 }
253 253
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
                  try {
264 264
                         $sth = $this->db->prepare($query);
265 265
                         $sth->execute();
266
-                } catch(PDOException $e) {
266
+                } catch (PDOException $e) {
267 267
                         echo "error : ".$e->getMessage();
268 268
                 }
269 269
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         		foreach ($all as $key => $row) {
288 288
         			$count[$key] = $row['airport_departure_icao_count'];
289 289
         		}
290
-        		array_multisort($count,SORT_DESC,$all);
290
+        		array_multisort($count, SORT_DESC, $all);
291 291
                 }
292 292
                 return $all;
293 293
 	}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                  try {
298 298
                         $sth = $this->db->prepare($query);
299 299
                         $sth->execute();
300
-                } catch(PDOException $e) {
300
+                } catch (PDOException $e) {
301 301
                         echo "error : ".$e->getMessage();
302 302
                 }
303 303
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
         		foreach ($all as $key => $row) {
322 322
         			$count[$key] = $row['airport_arrival_icao_count'];
323 323
         		}
324
-        		array_multisort($count,SORT_DESC,$all);
324
+        		array_multisort($count, SORT_DESC, $all);
325 325
                 }
326 326
                 return $all;
327 327
 	}
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                  try {
339 339
                         $sth = $this->db->prepare($query);
340 340
                         $sth->execute($query_data);
341
-                } catch(PDOException $e) {
341
+                } catch (PDOException $e) {
342 342
                         echo "error : ".$e->getMessage();
343 343
                 }
344 344
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                  try {
356 356
                         $sth = $this->db->prepare($query);
357 357
                         $sth->execute($query_data);
358
-                } catch(PDOException $e) {
358
+                } catch (PDOException $e) {
359 359
                         echo "error : ".$e->getMessage();
360 360
                 }
361 361
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                  try {
377 377
                         $sth = $this->db->prepare($query);
378 378
                         $sth->execute($query_data);
379
-                } catch(PDOException $e) {
379
+                } catch (PDOException $e) {
380 380
                         echo "error : ".$e->getMessage();
381 381
                 }
382 382
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
                  try {
393 393
                         $sth = $this->db->prepare($query);
394 394
                         $sth->execute($query_data);
395
-                } catch(PDOException $e) {
395
+                } catch (PDOException $e) {
396 396
                         echo "error : ".$e->getMessage();
397 397
                 }
398 398
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
                  try {
408 408
                         $sth = $this->db->prepare($query);
409 409
                         $sth->execute();
410
-                } catch(PDOException $e) {
410
+                } catch (PDOException $e) {
411 411
                         echo "error : ".$e->getMessage();
412 412
                 }
413 413
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
                  try {
423 423
                         $sth = $this->db->prepare($query);
424 424
                         $sth->execute();
425
-                } catch(PDOException $e) {
425
+                } catch (PDOException $e) {
426 426
                         echo "error : ".$e->getMessage();
427 427
                 }
428 428
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
                 }
433 433
                 return $all;
434 434
 	}
435
-	public function countAllHours($orderby = 'hour',$limit = true) {
435
+	public function countAllHours($orderby = 'hour', $limit = true) {
436 436
 		global $globalTimezone, $globalDBdriver;
437 437
 
438 438
 		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'";
@@ -448,19 +448,19 @@  discard block
 block discarded – undo
448 448
                  try {
449 449
                         $sth = $this->db->prepare($query);
450 450
                         $sth->execute();
451
-                } catch(PDOException $e) {
451
+                } catch (PDOException $e) {
452 452
                         echo "error : ".$e->getMessage();
453 453
                 }
454 454
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
455 455
                 if (empty($all)) {
456 456
             		$Spotter = new Spotter($this->db);
457
-            		$all = $Spotter->countAllHours($orderby,$limit);
457
+            		$all = $Spotter->countAllHours($orderby, $limit);
458 458
                 }
459 459
                 return $all;
460 460
 	}
461 461
 	
462 462
 	public function countOverallFlights() {
463
-		$all = $this->getSumStats('flights_bymonth',date('Y'));
463
+		$all = $this->getSumStats('flights_bymonth', date('Y'));
464 464
 		if (empty($all)) {
465 465
 			$Spotter = new Spotter($this->db);
466 466
 			$all = $Spotter->countOverallFlights();
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 		return $all;
469 469
 	}
470 470
 	public function countOverallMilitaryFlights() {
471
-		$all = $this->getSumStats('military_flights_bymonth',date('Y'));
471
+		$all = $this->getSumStats('military_flights_bymonth', date('Y'));
472 472
 		if (empty($all)) {
473 473
 			$Spotter = new Spotter($this->db);
474 474
 			$all = $Spotter->countOverallMilitaryFlights();
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 		return $all;
477 477
 	}
478 478
 	public function countOverallArrival() {
479
-		$all = $this->getSumStats('realarrivals_bymonth',date('Y'));
479
+		$all = $this->getSumStats('realarrivals_bymonth', date('Y'));
480 480
 		if (empty($all)) {
481 481
 			$Spotter = new Spotter($this->db);
482 482
 			$all = $Spotter->countOverallArrival();
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 		return $all;
485 485
 	}
486 486
 	public function countOverallAircrafts() {
487
-		$all = $this->getSumStats('aircrafts_bymonth',date('Y'));
487
+		$all = $this->getSumStats('aircrafts_bymonth', date('Y'));
488 488
 		if (empty($all)) {
489 489
 			$Spotter = new Spotter($this->db);
490 490
 			$all = $Spotter->countOverallAircrafts();
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
                  try {
497 497
                         $sth = $this->db->prepare($query);
498 498
                         $sth->execute();
499
-                } catch(PDOException $e) {
499
+                } catch (PDOException $e) {
500 500
                         echo "error : ".$e->getMessage();
501 501
                 }
502 502
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
521 521
                 $all = $result[0]['nb_owner'];
522 522
                 */
523
-		$all = $this->getSumStats('owners_bymonth',date('Y'));
523
+		$all = $this->getSumStats('owners_bymonth', date('Y'));
524 524
 		if (empty($all)) {
525 525
 			$Spotter = new Spotter($this->db);
526 526
 			$all = $Spotter->countOverallOwners();
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 		return $all;
529 529
 	}
530 530
 	public function countOverallPilots() {
531
-		$all = $this->getSumStats('pilots_bymonth',date('Y'));
531
+		$all = $this->getSumStats('pilots_bymonth', date('Y'));
532 532
 		if (empty($all)) {
533 533
 			$Spotter = new Spotter($this->db);
534 534
 			$all = $Spotter->countOverallPilots();
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
                  try {
543 543
                         $sth = $this->db->prepare($query);
544 544
                         $sth->execute($query_values);
545
-                } catch(PDOException $e) {
545
+                } catch (PDOException $e) {
546 546
                         echo "error : ".$e->getMessage();
547 547
                 }
548 548
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -554,13 +554,13 @@  discard block
 block discarded – undo
554 554
                  try {
555 555
                         $sth = $this->db->prepare($query);
556 556
                         $sth->execute($query_values);
557
-                } catch(PDOException $e) {
557
+                } catch (PDOException $e) {
558 558
                         echo "error : ".$e->getMessage();
559 559
                 }
560 560
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
561 561
                 return $all;
562 562
         }
563
-	public function getSumStats($type,$year) {
563
+	public function getSumStats($type, $year) {
564 564
     		global $globalArchiveMonths, $globalDBdriver;
565 565
     		if ($globalDBdriver == 'mysql') {
566 566
 	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year";
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
                  try {
572 572
                         $sth = $this->db->prepare($query);
573 573
                         $sth->execute($query_values);
574
-                } catch(PDOException $e) {
574
+                } catch (PDOException $e) {
575 575
                         echo "error : ".$e->getMessage();
576 576
                 }
577 577
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
                  try {
589 589
                         $sth = $this->db->prepare($query);
590 590
                         $sth->execute($query_values);
591
-                } catch(PDOException $e) {
591
+                } catch (PDOException $e) {
592 592
                         echo "error : ".$e->getMessage();
593 593
                 }
594 594
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
                  try {
605 605
                         $sth = $this->db->prepare($query);
606 606
                         $sth->execute();
607
-                } catch(PDOException $e) {
607
+                } catch (PDOException $e) {
608 608
                         echo "error : ".$e->getMessage();
609 609
                 }
610 610
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
                  try {
621 621
                         $sth = $this->db->prepare($query);
622 622
                         $sth->execute();
623
-                } catch(PDOException $e) {
623
+                } catch (PDOException $e) {
624 624
                         echo "error : ".$e->getMessage();
625 625
                 }
626 626
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
                  try {
637 637
                         $sth = $this->db->prepare($query);
638 638
                         $sth->execute();
639
-                } catch(PDOException $e) {
639
+                } catch (PDOException $e) {
640 640
                         echo "error : ".$e->getMessage();
641 641
                 }
642 642
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -652,29 +652,29 @@  discard block
 block discarded – undo
652 652
                  try {
653 653
                         $sth = $this->db->prepare($query);
654 654
                         $sth->execute();
655
-                } catch(PDOException $e) {
655
+                } catch (PDOException $e) {
656 656
                         echo "error : ".$e->getMessage();
657 657
                 }
658 658
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
659 659
                 return $all[0]['total'];
660 660
         }
661 661
 
662
-	public function addStat($type,$cnt,$stats_date) {
662
+	public function addStat($type, $cnt, $stats_date) {
663 663
 		global $globalDBdriver;
664 664
 		if ($globalDBdriver == 'mysql') {
665 665
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = :cnt";
666 666
                 } else {
667 667
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date; INSERT INTO stats (stats_type,cnt,stats_date) SELECT :type,:cnt,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date);"; 
668 668
 		}
669
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
669
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date);
670 670
                  try {
671 671
                         $sth = $this->db->prepare($query);
672 672
                         $sth->execute($query_values);
673
-                } catch(PDOException $e) {
673
+                } catch (PDOException $e) {
674 674
                         return "error : ".$e->getMessage();
675 675
                 }
676 676
         }
677
-	public function updateStat($type,$cnt,$stats_date) {
677
+	public function updateStat($type, $cnt, $stats_date) {
678 678
 		global $globalDBdriver;
679 679
 		if ($globalDBdriver == 'mysql') {
680 680
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
@@ -682,219 +682,219 @@  discard block
 block discarded – undo
682 682
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
683 683
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date; INSERT INTO stats (stats_type,cnt,stats_date) SELECT :type,:cnt,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date);"; 
684 684
                 }
685
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
685
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date);
686 686
                  try {
687 687
                         $sth = $this->db->prepare($query);
688 688
                         $sth->execute($query_values);
689
-                } catch(PDOException $e) {
689
+                } catch (PDOException $e) {
690 690
                         return "error : ".$e->getMessage();
691 691
                 }
692 692
         }
693
-	public function getStatsSource($date,$stats_type = '') {
693
+	public function getStatsSource($date, $stats_type = '') {
694 694
 		if ($stats_type == '') {
695 695
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
696 696
 			$query_values = array(':date' => $date);
697 697
 		} else {
698 698
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
699
-			$query_values = array(':date' => $date,':stats_type' => $stats_type);
699
+			$query_values = array(':date' => $date, ':stats_type' => $stats_type);
700 700
 		}
701 701
                  try {
702 702
                         $sth = $this->db->prepare($query);
703 703
                         $sth->execute($query_values);
704
-                } catch(PDOException $e) {
704
+                } catch (PDOException $e) {
705 705
                         echo "error : ".$e->getMessage();
706 706
                 }
707 707
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
708 708
                 return $all;
709 709
         }
710 710
 
711
-	public function addStatSource($data,$source_name,$stats_type,$date) {
711
+	public function addStatSource($data, $source_name, $stats_type, $date) {
712 712
 		global $globalDBdriver;
713 713
 		if ($globalDBdriver == 'mysql') {
714 714
 			$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";
715 715
 		} else {
716 716
 			$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);"; 
717 717
                 }
718
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
718
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
719 719
                  try {
720 720
                         $sth = $this->db->prepare($query);
721 721
                         $sth->execute($query_values);
722
-                } catch(PDOException $e) {
722
+                } catch (PDOException $e) {
723 723
                         return "error : ".$e->getMessage();
724 724
                 }
725 725
         }
726
-	public function addStatFlight($type,$date_name,$cnt) {
726
+	public function addStatFlight($type, $date_name, $cnt) {
727 727
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt) VALUES (:type,:flight_date,:cnt)";
728
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt);
728
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt);
729 729
                  try {
730 730
                         $sth = $this->db->prepare($query);
731 731
                         $sth->execute($query_values);
732
-                } catch(PDOException $e) {
732
+                } catch (PDOException $e) {
733 733
                         return "error : ".$e->getMessage();
734 734
                 }
735 735
         }
736
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '') {
736
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '') {
737 737
 		global $globalDBdriver;
738 738
 		if ($globalDBdriver == 'mysql') {
739 739
 			$query = "INSERT INTO stats_registration (aircraft_icao,registration,cnt) VALUES (:aircraft_icao,:registration,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
740 740
 		} else {
741 741
 			$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration; INSERT INTO stats_registration (aircraft_icao,registration,cnt) SELECT :aircraft_icao,:registration,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration);"; 
742 742
 		}
743
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt);
743
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt);
744 744
                  try {
745 745
                         $sth = $this->db->prepare($query);
746 746
                         $sth->execute($query_values);
747
-                } catch(PDOException $e) {
747
+                } catch (PDOException $e) {
748 748
                         return "error : ".$e->getMessage();
749 749
                 }
750 750
         }
751
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '') {
751
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '') {
752 752
 		global $globalDBdriver;
753 753
 		if ($globalDBdriver == 'mysql') {
754 754
 			$query = "INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt) VALUES (:callsign_icao,:airline_icao,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
755 755
 		} else {
756 756
 			$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt) SELECT :callsign_icao,:airline_icao,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao);"; 
757 757
 		}
758
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt);
758
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt);
759 759
                  try {
760 760
                         $sth = $this->db->prepare($query);
761 761
                         $sth->execute($query_values);
762
-                } catch(PDOException $e) {
762
+                } catch (PDOException $e) {
763 763
                         return "error : ".$e->getMessage();
764 764
                 }
765 765
         }
766
-	public function addStatCountry($iso2,$iso3,$name,$cnt) {
766
+	public function addStatCountry($iso2, $iso3, $name, $cnt) {
767 767
 		global $globalDBdriver;
768 768
 		if ($globalDBdriver == 'mysql') {
769 769
 			$query = "INSERT INTO stats_country (iso2,iso3,name,cnt) VALUES (:iso2,:iso3,:name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
770 770
 		} else {
771 771
 			$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2; INSERT INTO stats_country (iso2,iso3,name,cnt) SELECT :iso2,:iso3,:name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2);"; 
772 772
 		}
773
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt);
773
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt);
774 774
                  try {
775 775
                         $sth = $this->db->prepare($query);
776 776
                         $sth->execute($query_values);
777
-                } catch(PDOException $e) {
777
+                } catch (PDOException $e) {
778 778
                         return "error : ".$e->getMessage();
779 779
                 }
780 780
         }
781
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '') {
781
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '') {
782 782
 		global $globalDBdriver;
783 783
 		if ($globalDBdriver == 'mysql') {
784 784
 			$query = "INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,cnt) VALUES (:aircraft_icao,:aircraft_name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
785 785
 		} else {
786 786
 			$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt WHERE aircraft_icao = :aircraft_icao; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,cnt) SELECT :aircraft_icao,:aircraft_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao);"; 
787 787
 		}
788
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt);
788
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt);
789 789
                  try {
790 790
                         $sth = $this->db->prepare($query);
791 791
                         $sth->execute($query_values);
792
-                } catch(PDOException $e) {
792
+                } catch (PDOException $e) {
793 793
                         return "error : ".$e->getMessage();
794 794
                 }
795 795
         }
796
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '') {
796
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '') {
797 797
 		global $globalDBdriver;
798 798
 		if ($globalDBdriver == 'mysql') {
799 799
 			$query = "INSERT INTO stats_airline (airline_icao,airline_name,cnt) VALUES (:airline_icao,:airline_name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt,airline_name = :airline_name";
800 800
 		} else {
801 801
 			$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao; INSERT INTO stats_airline (airline_icao,airline_name,cnt) SELECT :airline_icao,:airline_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao);"; 
802 802
 		}
803
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt);
803
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt);
804 804
                  try {
805 805
                         $sth = $this->db->prepare($query);
806 806
                         $sth->execute($query_values);
807
-                } catch(PDOException $e) {
807
+                } catch (PDOException $e) {
808 808
                         return "error : ".$e->getMessage();
809 809
                 }
810 810
         }
811
-	public function addStatOwner($owner_name,$cnt) {
811
+	public function addStatOwner($owner_name, $cnt) {
812 812
 		global $globalDBdriver;
813 813
 		if ($globalDBdriver == 'mysql') {
814 814
 			$query = "INSERT INTO stats_owner (owner_name,cnt) VALUES (:owner_name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
815 815
 		} else {
816 816
 			$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name; INSERT INTO stats_owner (owner_name,cnt) SELECT :owner_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name);"; 
817 817
 		}
818
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt);
818
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt);
819 819
                  try {
820 820
                         $sth = $this->db->prepare($query);
821 821
                         $sth->execute($query_values);
822
-                } catch(PDOException $e) {
822
+                } catch (PDOException $e) {
823 823
                         return "error : ".$e->getMessage();
824 824
                 }
825 825
         }
826
-	public function addStatPilot($pilot_id,$cnt) {
826
+	public function addStatPilot($pilot_id, $cnt) {
827 827
 		global $globalDBdriver;
828 828
 		if ($globalDBdriver == 'mysql') {
829 829
 			$query = "INSERT INTO stats_pilot (pilot_id,cnt) VALUES (:pilot_id,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
830 830
 		} else {
831 831
 			$query = "UPDATE stats_pilot SET cnt = cnt+:cnt WHERE pilot_id = :pilot_id; INSERT INTO stats_pilot (pilot_id,cnt) SELECT :pilot_id,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id);"; 
832 832
 		}
833
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt);
833
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt);
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
                         return "error : ".$e->getMessage();
839 839
                 }
840 840
         }
841
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure) {
841
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure) {
842 842
 		global $globalDBdriver;
843 843
 		if ($globalDBdriver == 'mysql') {
844 844
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date) ON DUPLICATE KEY UPDATE departure = departure+:departure";
845 845
 		} else {
846 846
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'yearly');"; 
847 847
 		}
848
-                $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');
848
+                $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');
849 849
                  try {
850 850
                         $sth = $this->db->prepare($query);
851 851
                         $sth->execute($query_values);
852
-                } catch(PDOException $e) {
852
+                } catch (PDOException $e) {
853 853
                         return "error : ".$e->getMessage();
854 854
                 }
855 855
         }
856
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure) {
856
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure) {
857 857
 		global $globalDBdriver;
858 858
 		if ($globalDBdriver == 'mysql') {
859 859
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date) ON DUPLICATE KEY UPDATE departure = :departure";
860 860
 		} else {
861 861
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'daily');"; 
862 862
 		}
863
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date);
863
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date);
864 864
                  try {
865 865
                         $sth = $this->db->prepare($query);
866 866
                         $sth->execute($query_values);
867
-                } catch(PDOException $e) {
867
+                } catch (PDOException $e) {
868 868
                         return "error : ".$e->getMessage();
869 869
                 }
870 870
         }
871
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival) {
871
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival) {
872 872
 		global $globalDBdriver;
873 873
 		if ($globalDBdriver == 'mysql') {
874 874
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date) ON DUPLICATE KEY UPDATE arrival = arrival+:arrival";
875 875
 		} else {
876 876
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'yearly');"; 
877 877
 		}
878
-                $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');
878
+                $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');
879 879
                  try {
880 880
                         $sth = $this->db->prepare($query);
881 881
                         $sth->execute($query_values);
882
-                } catch(PDOException $e) {
882
+                } catch (PDOException $e) {
883 883
                         return "error : ".$e->getMessage();
884 884
                 }
885 885
         }
886
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival) {
886
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival) {
887 887
 		global $globalDBdriver;
888 888
 		if ($globalDBdriver == 'mysql') {
889 889
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date) ON DUPLICATE KEY UPDATE arrival = :arrival";
890 890
 		} else {
891 891
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'daily');"; 
892 892
 		}
893
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date);
893
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date);
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
                         return "error : ".$e->getMessage();
899 899
                 }
900 900
         }
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
                  try {
906 906
                         $sth = $this->db->prepare($query);
907 907
                         $sth->execute($query_values);
908
-                } catch(PDOException $e) {
908
+                } catch (PDOException $e) {
909 909
                         return "error : ".$e->getMessage();
910 910
                 }
911 911
         }
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
                  try {
916 916
                         $sth = $this->db->prepare($query);
917 917
                         $sth->execute($query_values);
918
-                } catch(PDOException $e) {
918
+                } catch (PDOException $e) {
919 919
                         return "error : ".$e->getMessage();
920 920
                 }
921 921
         }
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
                  try {
926 926
                         $sth = $this->db->prepare($query);
927 927
                         $sth->execute($query_values);
928
-                } catch(PDOException $e) {
928
+                } catch (PDOException $e) {
929 929
                         return "error : ".$e->getMessage();
930 930
                 }
931 931
         }
@@ -945,86 +945,86 @@  discard block
 block discarded – undo
945 945
 			$lastyear = false;
946 946
 			foreach ($alldata as $number) {
947 947
 				if ($number['year_name'] != date('Y')) $lastyear = true;
948
-				$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'])));
948
+				$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'])));
949 949
 			}
950 950
 			$alldata = $Spotter->countAllMilitaryMonths();
951 951
 			$lastyear = false;
952 952
 			foreach ($alldata as $number) {
953 953
 				if ($number['year_name'] != date('Y')) $lastyear = true;
954
-				$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'])));
954
+				$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'])));
955 955
 			}
956 956
 			$alldata = $Spotter->countAllMonthsOwners();
957 957
 			foreach ($alldata as $number) {
958
-				$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'])));
958
+				$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'])));
959 959
 			}
960 960
 			$alldata = $Spotter->countAllMonthsPilots();
961 961
 			foreach ($alldata as $number) {
962
-				$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'])));
962
+				$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'])));
963 963
 			}
964 964
 			$alldata = $Spotter->countAllMonthsAirlines();
965 965
 			foreach ($alldata as $number) {
966
-				$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'])));
966
+				$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'])));
967 967
 			}
968 968
 			$alldata = $Spotter->countAllMonthsAircrafts();
969 969
 			foreach ($alldata as $number) {
970
-				$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'])));
970
+				$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'])));
971 971
 			}
972 972
 			$alldata = $Spotter->countAllMonthsRealArrivals();
973 973
 			foreach ($alldata as $number) {
974
-				$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'])));
974
+				$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'])));
975 975
 			}
976 976
 			$this->deleteStatFlight('month');
977 977
 			$alldata = $Spotter->countAllDatesLastMonth();
978 978
 			foreach ($alldata as $number) {
979
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
979
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
980 980
 			}
981 981
 			$previousdata = $this->countAllDates();
982 982
 			$this->deleteStatFlight('date');
983
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
983
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
984 984
 			$values = array();
985 985
 			foreach ($alldata as $cnt) {
986 986
 				$values[] = $cnt['date_count'];
987 987
 			}
988
-			array_multisort($values,SORT_DESC,$alldata);
989
-			array_splice($alldata,11);
988
+			array_multisort($values, SORT_DESC, $alldata);
989
+			array_splice($alldata, 11);
990 990
 			foreach ($alldata as $number) {
991
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
991
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
992 992
 			}
993 993
 			$this->deleteStatFlight('hour');
994 994
 			$alldata = $Spotter->countAllHours('hour');
995 995
 			foreach ($alldata as $number) {
996
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
996
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
997 997
 			}
998 998
 			if ($lastyear) {
999 999
 				$monthsSinceLastYear = date('n');
1000
-				$alldata = $Spotter->countAllAircraftTypes(false,$monthsSinceLastYear);
1000
+				$alldata = $Spotter->countAllAircraftTypes(false, $monthsSinceLastYear);
1001 1001
 				foreach ($alldata as $number) {
1002
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name']);
1002
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name']);
1003 1003
 				}
1004
-				$alldata = $Spotter->countAllAirlines(false,$monthsSinceLastYear);
1004
+				$alldata = $Spotter->countAllAirlines(false, $monthsSinceLastYear);
1005 1005
 				foreach ($alldata as $number) {
1006
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1006
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
1007 1007
 				}
1008 1008
 				if ($Connection->tableExists('countries')) {
1009
-					$alldata = $Spotter->countAllFlightOverCountries(false,$monthsSinceLastYear);
1009
+					$alldata = $Spotter->countAllFlightOverCountries(false, $monthsSinceLastYear);
1010 1010
 					foreach ($alldata as $number) {
1011
-						$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
1011
+						$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
1012 1012
 					}
1013 1013
 				}
1014
-				$alldata = $Spotter->countAllOwners(false,$monthsSinceLastYear);
1014
+				$alldata = $Spotter->countAllOwners(false, $monthsSinceLastYear);
1015 1015
 				foreach ($alldata as $number) {
1016
-					$this->addStatOwner($number['owner_name'],$number['owner_count']);
1016
+					$this->addStatOwner($number['owner_name'], $number['owner_count']);
1017 1017
 				}
1018
-				$alldata = $Spotter->countAllPilots(false,$monthsSinceLastYear);
1018
+				$alldata = $Spotter->countAllPilots(false, $monthsSinceLastYear);
1019 1019
 				foreach ($alldata as $number) {
1020
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
1020
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count']);
1021 1021
 				}
1022 1022
 				$previous_year = date('Y');
1023 1023
 				$previous_year--;
1024
-				$this->addStat('aircrafts_byyear',$this->getStatsAircraftTotal(),$previous_year.'-01-01 00:00:00');
1025
-				$this->addStat('airlines_byyear',$this->getStatsAirlineTotal(),$previous_year.'-01-01 00:00:00');
1026
-				$this->addStat('owner_byyear',$this->getStatsOwnerTotal(),$previous_year.'-01-01 00:00:00');
1027
-				$this->addStat('pilot_byyear',$this->getStatsPilotTotal(),$previous_year.'-01-01 00:00:00');
1024
+				$this->addStat('aircrafts_byyear', $this->getStatsAircraftTotal(), $previous_year.'-01-01 00:00:00');
1025
+				$this->addStat('airlines_byyear', $this->getStatsAirlineTotal(), $previous_year.'-01-01 00:00:00');
1026
+				$this->addStat('owner_byyear', $this->getStatsOwnerTotal(), $previous_year.'-01-01 00:00:00');
1027
+				$this->addStat('pilot_byyear', $this->getStatsPilotTotal(), $previous_year.'-01-01 00:00:00');
1028 1028
 				
1029 1029
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
1030 1030
 					if ($globalArchive) {
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 						try {
1034 1034
 							$sth = $this->db->prepare($query);
1035 1035
 							$sth->execute();
1036
-						} catch(PDOException $e) {
1036
+						} catch (PDOException $e) {
1037 1037
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
1038 1038
 						}
1039 1039
 					}
@@ -1041,45 +1041,45 @@  discard block
 block discarded – undo
1041 1041
 					try {
1042 1042
 						$sth = $this->db->prepare($query);
1043 1043
 						$sth->execute();
1044
-					} catch(PDOException $e) {
1044
+					} catch (PDOException $e) {
1045 1045
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1046 1046
 					}
1047 1047
 				}
1048 1048
 			}
1049 1049
 			if (!isset($globalArchiveMonths) || $globalArchiveMonths == '') $globalArchiveMonths = 2;
1050 1050
 			if ($globalArchiveMonths > 0) {
1051
-				$alldata = $Spotter->countAllAircraftTypes(false,$globalArchiveMonths);
1051
+				$alldata = $Spotter->countAllAircraftTypes(false, $globalArchiveMonths);
1052 1052
 				foreach ($alldata as $number) {
1053
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name']);
1053
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name']);
1054 1054
 				}
1055
-				$alldata = $Spotter->countAllAirlines(false,$globalArchiveMonths);
1055
+				$alldata = $Spotter->countAllAirlines(false, $globalArchiveMonths);
1056 1056
 				foreach ($alldata as $number) {
1057
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1057
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
1058 1058
 				}
1059
-				$alldata = $Spotter->countAllAircraftRegistrations(false,$globalArchiveMonths);
1059
+				$alldata = $Spotter->countAllAircraftRegistrations(false, $globalArchiveMonths);
1060 1060
 				foreach ($alldata as $number) {
1061
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1061
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']);
1062 1062
 				}
1063
-				$alldata = $Spotter->countAllCallsigns(false,$globalArchiveMonths);
1063
+				$alldata = $Spotter->countAllCallsigns(false, $globalArchiveMonths);
1064 1064
 				foreach ($alldata as $number) {
1065
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1065
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1066 1066
 				}
1067
-				$alldata = $Spotter->countAllOwners(false,$globalArchiveMonths);
1067
+				$alldata = $Spotter->countAllOwners(false, $globalArchiveMonths);
1068 1068
 				foreach ($alldata as $number) {
1069
-					$this->addStatOwner($number['owner_name'],$number['owner_count']);
1069
+					$this->addStatOwner($number['owner_name'], $number['owner_count']);
1070 1070
 				}
1071 1071
 				if ($Connection->tableExists('countries')) {
1072
-					$alldata = $Spotter->countAllFlightOverCountries(false,$globalArchiveMonths);
1072
+					$alldata = $Spotter->countAllFlightOverCountries(false, $globalArchiveMonths);
1073 1073
 					foreach ($alldata as $number) {
1074
-						$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
1074
+						$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
1075 1075
 					}
1076 1076
 				}
1077
-				$alldata = $Spotter->countAllPilots(false,$globalArchiveMonths);
1077
+				$alldata = $Spotter->countAllPilots(false, $globalArchiveMonths);
1078 1078
 				foreach ($alldata as $number) {
1079
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
1079
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count']);
1080 1080
 				}
1081
-				$pall = $Spotter->countAllDepartureAirports(false,$globalArchiveMonths);
1082
-        			$dall = $Spotter->countAllDetectedDepartureAirports(false,$globalArchiveMonths);
1081
+				$pall = $Spotter->countAllDepartureAirports(false, $globalArchiveMonths);
1082
+        			$dall = $Spotter->countAllDetectedDepartureAirports(false, $globalArchiveMonths);
1083 1083
 	        		$alldata = array();
1084 1084
     				foreach ($pall as $value) {
1085 1085
 	        			$icao = $value['airport_departure_icao'];
@@ -1095,14 +1095,14 @@  discard block
 block discarded – undo
1095 1095
         			foreach ($alldata as $key => $row) {
1096 1096
         				$count[$key] = $row['airport_departure_icao_count'];
1097 1097
 	        		}
1098
-    				array_multisort($count,SORT_DESC,$alldata);
1098
+    				array_multisort($count, SORT_DESC, $alldata);
1099 1099
 
1100 1100
 				//print_r($alldate);
1101 1101
 				foreach ($alldata as $number) {
1102
-					$this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1102
+					$this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']);
1103 1103
 				}
1104
-				$pdata = $Spotter->countAllArrivalAirports(false,$globalArchiveMonths);
1105
-        			$dall = $Spotter->countAllDetectedArrivalAirports(false,$globalArchiveMonths);
1104
+				$pdata = $Spotter->countAllArrivalAirports(false, $globalArchiveMonths);
1105
+        			$dall = $Spotter->countAllDetectedArrivalAirports(false, $globalArchiveMonths);
1106 1106
 	        		$alldata = array();
1107 1107
     				foreach ($pdata as $value) {
1108 1108
 	        			$icao = $value['airport_arrival_icao'];
@@ -1118,14 +1118,14 @@  discard block
 block discarded – undo
1118 1118
         			foreach ($alldata as $key => $row) {
1119 1119
         				$count[$key] = $row['airport_arrival_icao_count'];
1120 1120
 	        		}
1121
-    				array_multisort($count,SORT_DESC,$alldata);
1121
+    				array_multisort($count, SORT_DESC, $alldata);
1122 1122
 				foreach ($alldata as $number) {
1123
-					$this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1123
+					$this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']);
1124 1124
 				}
1125
-				$this->addStat('aircrafts_byyear',$this->getStatsAircraftTotal(),date('Y').'-01-01 00:00:00');
1126
-				$this->addStat('airlines_byyear',$this->getStatsAirlineTotal(),date('Y').'-01-01 00:00:00');
1127
-				$this->addStat('owner_byyear',$this->getStatsOwnerTotal(),date('Y').'-01-01 00:00:00');
1128
-				$this->addStat('pilot_byyear',$this->getStatsPilotTotal(),date('Y').'-01-01 00:00:00');
1125
+				$this->addStat('aircrafts_byyear', $this->getStatsAircraftTotal(), date('Y').'-01-01 00:00:00');
1126
+				$this->addStat('airlines_byyear', $this->getStatsAirlineTotal(), date('Y').'-01-01 00:00:00');
1127
+				$this->addStat('owner_byyear', $this->getStatsOwnerTotal(), date('Y').'-01-01 00:00:00');
1128
+				$this->addStat('pilot_byyear', $this->getStatsPilotTotal(), date('Y').'-01-01 00:00:00');
1129 1129
 			
1130 1130
 				if ($globalArchive) {
1131 1131
 					if ($globalDBdriver == 'mysql') {
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 					try {
1137 1137
 						$sth = $this->db->prepare($query);
1138 1138
 						$sth->execute();
1139
-					} catch(PDOException $e) {
1139
+					} catch (PDOException $e) {
1140 1140
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1141 1141
 					}
1142 1142
 				}
@@ -1150,43 +1150,43 @@  discard block
 block discarded – undo
1150 1150
 				try {
1151 1151
 					$sth = $this->db->prepare($query);
1152 1152
 					$sth->execute();
1153
-				} catch(PDOException $e) {
1153
+				} catch (PDOException $e) {
1154 1154
 					return "error : ".$e->getMessage().' - query : '.$query."\n";
1155 1155
 				}
1156 1156
 			}
1157
-			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1157
+			$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
1158 1158
 		} else {
1159 1159
 			echo 'Update stats !'."\n";
1160 1160
 			if (isset($last_update[0]['value'])) {
1161 1161
 				$last_update_day = $last_update[0]['value'];
1162 1162
 			} else $last_update_day = '2012-12-12 12:12:12';
1163 1163
 			$Spotter = new Spotter($this->db);
1164
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1164
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1165 1165
 			foreach ($alldata as $number) {
1166
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name']);
1166
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name']);
1167 1167
 			}
1168
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1168
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1169 1169
 			foreach ($alldata as $number) {
1170
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1170
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
1171 1171
 			}
1172
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1172
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1173 1173
 			foreach ($alldata as $number) {
1174
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1174
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']);
1175 1175
 			}
1176
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1176
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1177 1177
 			foreach ($alldata as $number) {
1178
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1178
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1179 1179
 			}
1180
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1180
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1181 1181
 			foreach ($alldata as $number) {
1182
-				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1182
+				$this->addStatOwner($number['owner_name'], $number['owner_count']);
1183 1183
 			}
1184
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1184
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1185 1185
 			foreach ($alldata as $number) {
1186
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
1186
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count']);
1187 1187
 			}
1188
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1189
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1188
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1189
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1190 1190
 	        	$alldata = array();
1191 1191
     			foreach ($pall as $value) {
1192 1192
 	        		$icao = $value['airport_departure_icao'];
@@ -1202,13 +1202,13 @@  discard block
 block discarded – undo
1202 1202
     			foreach ($alldata as $key => $row) {
1203 1203
     				$count[$key] = $row['airport_departure_icao_count'];
1204 1204
         		}
1205
-			array_multisort($count,SORT_DESC,$alldata);
1205
+			array_multisort($count, SORT_DESC, $alldata);
1206 1206
 
1207 1207
 			foreach ($alldata as $number) {
1208
-				$this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1208
+				$this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']);
1209 1209
 			}
1210
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1211
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1210
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1211
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1212 1212
 	        	$alldata = array();
1213 1213
     			foreach ($pall as $value) {
1214 1214
 	        		$icao = $value['airport_arrival_icao'];
@@ -1224,15 +1224,15 @@  discard block
 block discarded – undo
1224 1224
         		foreach ($alldata as $key => $row) {
1225 1225
         			$count[$key] = $row['airport_arrival_icao_count'];
1226 1226
 	        	}
1227
-    			array_multisort($count,SORT_DESC,$alldata);
1227
+    			array_multisort($count, SORT_DESC, $alldata);
1228 1228
                         foreach ($alldata as $number) {
1229
-				$this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1229
+				$this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']);
1230 1230
 			}
1231 1231
 			if ($Connection->tableExists('countries')) {
1232 1232
 				$SpotterArchive = new SpotterArchive();
1233
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1233
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1234 1234
 				foreach ($alldata as $number) {
1235
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
1235
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
1236 1236
 				}
1237 1237
 			}
1238 1238
 			
@@ -1245,31 +1245,31 @@  discard block
 block discarded – undo
1245 1245
 			$lastyear = false;
1246 1246
 			foreach ($alldata as $number) {
1247 1247
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1248
-				$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'])));
1248
+				$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'])));
1249 1249
 			}
1250 1250
 			$alldata = $Spotter->countAllMilitaryMonths();
1251 1251
 			foreach ($alldata as $number) {
1252
-				$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'])));
1252
+				$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'])));
1253 1253
 			}
1254 1254
 			$alldata = $Spotter->countAllMonthsOwners();
1255 1255
 			foreach ($alldata as $number) {
1256
-				$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'])));
1256
+				$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'])));
1257 1257
 			}
1258 1258
 			$alldata = $Spotter->countAllMonthsPilots();
1259 1259
 			foreach ($alldata as $number) {
1260
-				$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'])));
1260
+				$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'])));
1261 1261
 			}
1262 1262
 			$alldata = $Spotter->countAllMonthsAirlines();
1263 1263
 			foreach ($alldata as $number) {
1264
-				$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'])));
1264
+				$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'])));
1265 1265
 			}
1266 1266
 			$alldata = $Spotter->countAllMonthsAircrafts();
1267 1267
 			foreach ($alldata as $number) {
1268
-				$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'])));
1268
+				$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'])));
1269 1269
 			}
1270 1270
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1271 1271
 			foreach ($alldata as $number) {
1272
-				$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'])));
1272
+				$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'])));
1273 1273
 			}
1274 1274
 			echo 'Airports data...'."\n";
1275 1275
 			echo '...Departure'."\n";
@@ -1291,9 +1291,9 @@  discard block
 block discarded – undo
1291 1291
         		foreach ($alldata as $key => $row) {
1292 1292
         			$count[$key] = $row['departure_airport_count'];
1293 1293
 	        	}
1294
-    			array_multisort($count,SORT_DESC,$alldata);
1294
+    			array_multisort($count, SORT_DESC, $alldata);
1295 1295
 			foreach ($alldata as $number) {
1296
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1296
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1297 1297
 			}
1298 1298
 			echo '...Arrival'."\n";
1299 1299
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1313,10 +1313,10 @@  discard block
 block discarded – undo
1313 1313
         		foreach ($alldata as $key => $row) {
1314 1314
         			$count[$key] = $row['arrival_airport_count'];
1315 1315
 	        	}
1316
-    			array_multisort($count,SORT_DESC,$alldata);
1316
+    			array_multisort($count, SORT_DESC, $alldata);
1317 1317
 
1318 1318
 			foreach ($alldata as $number) {
1319
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1319
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1320 1320
 			}
1321 1321
 
1322 1322
 			echo 'Flights data...'."\n";
@@ -1324,37 +1324,37 @@  discard block
 block discarded – undo
1324 1324
 			echo '-> countAllDatesLastMonth...'."\n";
1325 1325
 			$alldata = $Spotter->countAllDatesLastMonth();
1326 1326
 			foreach ($alldata as $number) {
1327
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1327
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1328 1328
 			}
1329 1329
 			echo '-> countAllDates...'."\n";
1330 1330
 			$previousdata = $this->countAllDates();
1331 1331
 			$this->deleteStatFlight('date');
1332
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1332
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1333 1333
 			$values = array();
1334 1334
 			foreach ($alldata as $cnt) {
1335 1335
 				$values[] = $cnt['date_count'];
1336 1336
 			}
1337
-			array_multisort($values,SORT_DESC,$alldata);
1338
-			array_splice($alldata,11);
1337
+			array_multisort($values, SORT_DESC, $alldata);
1338
+			array_splice($alldata, 11);
1339 1339
 			foreach ($alldata as $number) {
1340
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1340
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1341 1341
 			}
1342 1342
 			
1343 1343
 			$this->deleteStatFlight('hour');
1344 1344
 			echo '-> countAllHours...'."\n";
1345 1345
 			$alldata = $Spotter->countAllHours('hour');
1346 1346
 			foreach ($alldata as $number) {
1347
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1347
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1348 1348
 			}
1349 1349
 			if ($lastyear) {
1350 1350
 				echo 'Data from last year...'."\n";
1351 1351
 				// SUM all previous month to put as year
1352 1352
 				$previous_year = date('Y');
1353 1353
 				$previous_year--;
1354
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1355
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1356
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1357
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1354
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1355
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1356
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1357
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1358 1358
 				
1359 1359
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
1360 1360
 					if ($globalArchive) {
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 						try {
1363 1363
 							$sth = $this->db->prepare($query);
1364 1364
 							$sth->execute();
1365
-						} catch(PDOException $e) {
1365
+						} catch (PDOException $e) {
1366 1366
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
1367 1367
 						}
1368 1368
 					}
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
 					try {
1372 1372
 						$sth = $this->db->prepare($query);
1373 1373
 						$sth->execute();
1374
-					} catch(PDOException $e) {
1374
+					} catch (PDOException $e) {
1375 1375
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1376 1376
 					}
1377 1377
 				}
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
 					try {
1394 1394
 						$sth = $this->db->prepare($query);
1395 1395
 						$sth->execute();
1396
-					} catch(PDOException $e) {
1396
+					} catch (PDOException $e) {
1397 1397
 						return "error : ".$e->getMessage();
1398 1398
 					}
1399 1399
 				}
@@ -1407,13 +1407,13 @@  discard block
 block discarded – undo
1407 1407
 				try {
1408 1408
 					$sth = $this->db->prepare($query);
1409 1409
 					$sth->execute();
1410
-				} catch(PDOException $e) {
1410
+				} catch (PDOException $e) {
1411 1411
 					return "error : ".$e->getMessage();
1412 1412
 				}
1413 1413
 			}
1414 1414
 			echo 'Insert last stats update date...'."\n";
1415 1415
 			date_default_timezone_set('UTC');
1416
-			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1416
+			$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
1417 1417
 		}
1418 1418
 	}
1419 1419
 }
Please login to merge, or discard this patch.