Completed
Push — master ( ac5e38...54c225 )
by Yannick
06:46
created
require/class.Stats.php 1 patch
Indentation   +825 added lines, -825 removed lines patch added patch discarded remove patch
@@ -15,79 +15,79 @@  discard block
 block discarded – undo
15 15
 		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-        }
18
+		}
19 19
               
20 20
 	public function addLastStatsUpdate($type,$stats_date) {
21
-                $query = "DELETE FROM config WHERE name = :type;
21
+				$query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
-                 try {
25
-                        $sth = $this->db->prepare($query);
26
-                        $sth->execute($query_values);
27
-                } catch(PDOException $e) {
28
-                        return "error : ".$e->getMessage();
29
-                }
30
-        }
23
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
24
+				 try {
25
+						$sth = $this->db->prepare($query);
26
+						$sth->execute($query_values);
27
+				} catch(PDOException $e) {
28
+						return "error : ".$e->getMessage();
29
+				}
30
+		}
31 31
 
32 32
 	public function getLastStatsUpdate($type = 'last_update_stats') {
33
-                $query = "SELECT value FROM config WHERE name = :type";
34
-                 try {
35
-                        $sth = $this->db->prepare($query);
36
-                        $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
38
-                        echo "error : ".$e->getMessage();
39
-                }
40
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
-                return $all;
42
-        }
33
+				$query = "SELECT value FROM config WHERE name = :type";
34
+				 try {
35
+						$sth = $this->db->prepare($query);
36
+						$sth->execute(array(':type' => $type));
37
+				} catch(PDOException $e) {
38
+						echo "error : ".$e->getMessage();
39
+				}
40
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
+				return $all;
42
+		}
43 43
 	public function getAllAirlineNames($filter_name = '') {
44 44
 		if ($filter_name == '') $filter_name = $this->filter_name;
45
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
46
-                 try {
47
-                        $sth = $this->db->prepare($query);
48
-                        $sth->execute(array(':filter_name' => $filter_name));
49
-                } catch(PDOException $e) {
50
-                        echo "error : ".$e->getMessage();
51
-                }
52
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
53
-                return $all;
54
-        }
45
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
46
+				 try {
47
+						$sth = $this->db->prepare($query);
48
+						$sth->execute(array(':filter_name' => $filter_name));
49
+				} catch(PDOException $e) {
50
+						echo "error : ".$e->getMessage();
51
+				}
52
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
53
+				return $all;
54
+		}
55 55
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
56 56
 		if ($filter_name == '') $filter_name = $this->filter_name;
57
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
58
-                 try {
59
-                        $sth = $this->db->prepare($query);
60
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
61
-                } catch(PDOException $e) {
62
-                        echo "error : ".$e->getMessage();
63
-                }
64
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
65
-                return $all;
66
-        }
57
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
58
+				 try {
59
+						$sth = $this->db->prepare($query);
60
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
61
+				} catch(PDOException $e) {
62
+						echo "error : ".$e->getMessage();
63
+				}
64
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
65
+				return $all;
66
+		}
67 67
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
68 68
 		if ($filter_name == '') $filter_name = $this->filter_name;
69
-                $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
70
-                 try {
71
-                        $sth = $this->db->prepare($query);
72
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
73
-                } catch(PDOException $e) {
74
-                        echo "error : ".$e->getMessage();
75
-                }
76
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
77
-                return $all;
78
-        }
69
+				$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
70
+				 try {
71
+						$sth = $this->db->prepare($query);
72
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
73
+				} catch(PDOException $e) {
74
+						echo "error : ".$e->getMessage();
75
+				}
76
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
77
+				return $all;
78
+		}
79 79
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
80 80
 		if ($filter_name == '') $filter_name = $this->filter_name;
81
-                $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
82
-                 try {
83
-                        $sth = $this->db->prepare($query);
84
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
86
-                        echo "error : ".$e->getMessage();
87
-                }
88
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
-                return $all;
90
-        }
81
+				$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
82
+				 try {
83
+						$sth = $this->db->prepare($query);
84
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
85
+				} catch(PDOException $e) {
86
+						echo "error : ".$e->getMessage();
87
+				}
88
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
+				return $all;
90
+		}
91 91
 
92 92
 
93 93
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
@@ -95,66 +95,66 @@  discard block
 block discarded – undo
95 95
 		if ($filter_name == '') $filter_name = $this->filter_name;
96 96
 		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
97 97
 		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
98
-                 try {
99
-                        $sth = $this->db->prepare($query);
100
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
101
-                } catch(PDOException $e) {
102
-                        echo "error : ".$e->getMessage();
103
-                }
104
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
105
-                if (empty($all)) {
106
-            	    $filters = array('airlines' => array($stats_airline));
107
-            	    if ($filter_name != '') {
108
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
109
-            	    }
110
-            	    $Spotter = new Spotter($this->db);
111
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
112
-                }
113
-                return $all;
98
+				 try {
99
+						$sth = $this->db->prepare($query);
100
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
101
+				} catch(PDOException $e) {
102
+						echo "error : ".$e->getMessage();
103
+				}
104
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
105
+				if (empty($all)) {
106
+					$filters = array('airlines' => array($stats_airline));
107
+					if ($filter_name != '') {
108
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
109
+					}
110
+					$Spotter = new Spotter($this->db);
111
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
112
+				}
113
+				return $all;
114 114
 	}
115 115
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
116 116
 		global $globalStatsFilters;
117 117
 		if ($filter_name == '') $filter_name = $this->filter_name;
118 118
 		if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
119 119
 		else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
120
-                 try {
121
-                        $sth = $this->db->prepare($query);
122
-                        $sth->execute(array(':filter_name' => $filter_name));
123
-                } catch(PDOException $e) {
124
-                        echo "error : ".$e->getMessage();
125
-                }
126
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
127
-                if (empty($all)) {
128
-            		$Spotter = new Spotter($this->db);
129
-            		$filters = array();
130
-            		if ($filter_name != '') {
131
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
132
-			}
133
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
134
-                }
135
-                return $all;
120
+				 try {
121
+						$sth = $this->db->prepare($query);
122
+						$sth->execute(array(':filter_name' => $filter_name));
123
+				} catch(PDOException $e) {
124
+						echo "error : ".$e->getMessage();
125
+				}
126
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
127
+				if (empty($all)) {
128
+					$Spotter = new Spotter($this->db);
129
+					$filters = array();
130
+					if ($filter_name != '') {
131
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
132
+			}
133
+					$all = $Spotter->countAllAirlineCountries($limit,$filters);
134
+				}
135
+				return $all;
136 136
 	}
137 137
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
138 138
 		global $globalStatsFilters;
139 139
 		if ($filter_name == '') $filter_name = $this->filter_name;
140 140
 		if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
141 141
 		else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
142
-                 try {
143
-                        $sth = $this->db->prepare($query);
144
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
145
-                } catch(PDOException $e) {
146
-                        echo "error : ".$e->getMessage();
147
-                }
148
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
149
-                if (empty($all)) {
150
-            		$filters = array('airlines' => array($stats_airline));
151
-            		if ($filter_name != '') {
152
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
142
+				 try {
143
+						$sth = $this->db->prepare($query);
144
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
145
+				} catch(PDOException $e) {
146
+						echo "error : ".$e->getMessage();
147
+				}
148
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
149
+				if (empty($all)) {
150
+					$filters = array('airlines' => array($stats_airline));
151
+					if ($filter_name != '') {
152
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
153 153
 			}
154
-            		$Spotter = new Spotter($this->db);
154
+					$Spotter = new Spotter($this->db);
155 155
 			$all = $Spotter->countAllAircraftManufacturers($filters);
156
-                }
157
-                return $all;
156
+				}
157
+				return $all;
158 158
 	}
159 159
 
160 160
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
@@ -162,44 +162,44 @@  discard block
 block discarded – undo
162 162
 		if ($filter_name == '') $filter_name = $this->filter_name;
163 163
 		if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
164 164
 		else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
165
-                 try {
166
-                        $sth = $this->db->prepare($query);
167
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
168
-                } catch(PDOException $e) {
169
-                        echo "error : ".$e->getMessage();
170
-                }
171
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
172
-                if (empty($all)) {
165
+				 try {
166
+						$sth = $this->db->prepare($query);
167
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
168
+				} catch(PDOException $e) {
169
+						echo "error : ".$e->getMessage();
170
+				}
171
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
172
+				if (empty($all)) {
173 173
 			$filters = array('airlines' => array($stats_airline));
174 174
 			if ($filter_name != '') {
175
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
175
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
176 176
 			}
177 177
 			$Spotter = new Spotter($this->db);
178 178
 			$all = $Spotter->countAllArrivalCountries($limit,$filters);
179
-                }
180
-                return $all;
179
+				}
180
+				return $all;
181 181
 	}
182 182
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
183 183
 		global $globalStatsFilters;
184 184
 		if ($filter_name == '') $filter_name = $this->filter_name;
185 185
 		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
186 186
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
187
-                 try {
188
-                        $sth = $this->db->prepare($query);
189
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
190
-                } catch(PDOException $e) {
191
-                        echo "error : ".$e->getMessage();
192
-                }
193
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
194
-                if (empty($all)) {
187
+				 try {
188
+						$sth = $this->db->prepare($query);
189
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
190
+				} catch(PDOException $e) {
191
+						echo "error : ".$e->getMessage();
192
+				}
193
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
194
+				if (empty($all)) {
195 195
 			$filters = array('airlines' => array($stats_airline));
196 196
 			if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
197
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
198 198
 			}
199 199
 			$Spotter = new Spotter($this->db);
200 200
 			$all = $Spotter->countAllDepartureCountries($filters);
201
-                }
202
-                return $all;
201
+				}
202
+				return $all;
203 203
 	}
204 204
 
205 205
 	public function countAllAirlines($limit = true,$filter_name = '') {
@@ -207,45 +207,45 @@  discard block
 block discarded – undo
207 207
 		if ($filter_name == '') $filter_name = $this->filter_name;
208 208
 		if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
209 209
 		else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
210
-                 try {
211
-                        $sth = $this->db->prepare($query);
212
-                        $sth->execute(array(':filter_name' => $filter_name));
213
-                } catch(PDOException $e) {
214
-                        echo "error : ".$e->getMessage();
215
-                }
216
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
217
-                if (empty($all)) {
218
-	                $Spotter = new Spotter($this->db);
219
-            		$filters = array();
220
-            		if ($filter_name != '') {
221
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
210
+				 try {
211
+						$sth = $this->db->prepare($query);
212
+						$sth->execute(array(':filter_name' => $filter_name));
213
+				} catch(PDOException $e) {
214
+						echo "error : ".$e->getMessage();
215
+				}
216
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
217
+				if (empty($all)) {
218
+					$Spotter = new Spotter($this->db);
219
+					$filters = array();
220
+					if ($filter_name != '') {
221
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
222 222
 			}
223 223
 
224
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
225
-                }
226
-                return $all;
224
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters);
225
+				}
226
+				return $all;
227 227
 	}
228 228
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
229 229
 		global $globalStatsFilters;
230 230
 		if ($filter_name == '') $filter_name = $this->filter_name;
231 231
 		if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
232 232
 		else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
233
-                 try {
234
-                        $sth = $this->db->prepare($query);
235
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
236
-                } catch(PDOException $e) {
237
-                        echo "error : ".$e->getMessage();
238
-                }
239
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
240
-                if (empty($all)) {
233
+				 try {
234
+						$sth = $this->db->prepare($query);
235
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
236
+				} catch(PDOException $e) {
237
+						echo "error : ".$e->getMessage();
238
+				}
239
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
240
+				if (empty($all)) {
241 241
 			$filters = array('airlines' => array($stats_airline));
242 242
 			if ($filter_name != '') {
243 243
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
244 244
 			}
245
-	                $Spotter = new Spotter($this->db);
246
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
247
-                }
248
-                return $all;
245
+					$Spotter = new Spotter($this->db);
246
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
247
+				}
248
+				return $all;
249 249
 	}
250 250
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
251 251
 		global $globalStatsFilters;
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 				echo "error : ".$e->getMessage();
283 283
 			}
284 284
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
285
-                /*
285
+				/*
286 286
                 if (empty($all)) {
287 287
 	                $Spotter = new Spotter($this->db);
288 288
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -298,84 +298,84 @@  discard block
 block discarded – undo
298 298
 		if ($filter_name == '') $filter_name = $this->filter_name;
299 299
 		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
300 300
 		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
301
-                 try {
302
-                        $sth = $this->db->prepare($query);
303
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
304
-                } catch(PDOException $e) {
305
-                        echo "error : ".$e->getMessage();
306
-                }
307
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
308
-                if (empty($all)) {
301
+				 try {
302
+						$sth = $this->db->prepare($query);
303
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
304
+				} catch(PDOException $e) {
305
+						echo "error : ".$e->getMessage();
306
+				}
307
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
308
+				if (empty($all)) {
309 309
 			$filters = array('airlines' => array($stats_airline));
310 310
 			if ($filter_name != '') {
311 311
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
312 312
 			}
313
-            		$Spotter = new Spotter($this->db);
314
-            		$all = $Spotter->countAllPilots($limit,0,'',$filters);
315
-                }
316
-                return $all;
313
+					$Spotter = new Spotter($this->db);
314
+					$all = $Spotter->countAllPilots($limit,0,'',$filters);
315
+				}
316
+				return $all;
317 317
 	}
318 318
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
319 319
 		global $globalStatsFilters;
320 320
 		if ($filter_name == '') $filter_name = $this->filter_name;
321 321
 		if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
322 322
 		else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
323
-                 try {
324
-                        $sth = $this->db->prepare($query);
325
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
326
-                } catch(PDOException $e) {
327
-                        echo "error : ".$e->getMessage();
328
-                }
329
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
330
-                if (empty($all)) {
323
+				 try {
324
+						$sth = $this->db->prepare($query);
325
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
326
+				} catch(PDOException $e) {
327
+						echo "error : ".$e->getMessage();
328
+				}
329
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
330
+				if (empty($all)) {
331 331
 			$filters = array('airlines' => array($stats_airline));
332 332
 			if ($filter_name != '') {
333 333
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
334 334
 			}
335
-            		$Spotter = new Spotter($this->db);
336
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
337
-                }
338
-                return $all;
335
+					$Spotter = new Spotter($this->db);
336
+					$all = $Spotter->countAllOwners($limit,0,'',$filters);
337
+				}
338
+				return $all;
339 339
 	}
340 340
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
341 341
 		global $globalStatsFilters;
342 342
 		if ($filter_name == '') $filter_name = $this->filter_name;
343 343
 		if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
344 344
 		else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
345
-                 try {
346
-                        $sth = $this->db->prepare($query);
347
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
348
-                } catch(PDOException $e) {
349
-                        echo "error : ".$e->getMessage();
350
-                }
351
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
352
-                if (empty($all)) {
345
+				 try {
346
+						$sth = $this->db->prepare($query);
347
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
348
+				} catch(PDOException $e) {
349
+						echo "error : ".$e->getMessage();
350
+				}
351
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
352
+				if (empty($all)) {
353 353
 			$filters = array('airlines' => array($stats_airline));
354
-            		if ($filter_name != '') {
355
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
356
-			}
357
-            		$Spotter = new Spotter($this->db);
358
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
359
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
360
-        		$all = array();
361
-        		foreach ($pall as $value) {
362
-        			$icao = $value['airport_departure_icao'];
363
-        			$all[$icao] = $value;
364
-        		}
354
+					if ($filter_name != '') {
355
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
356
+			}
357
+					$Spotter = new Spotter($this->db);
358
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
359
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
360
+				$all = array();
361
+				foreach ($pall as $value) {
362
+					$icao = $value['airport_departure_icao'];
363
+					$all[$icao] = $value;
364
+				}
365 365
         		
366
-        		foreach ($dall as $value) {
367
-        			$icao = $value['airport_departure_icao'];
368
-        			if (isset($all[$icao])) {
369
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
370
-        			} else $all[$icao] = $value;
371
-        		}
372
-        		$count = array();
373
-        		foreach ($all as $key => $row) {
374
-        			$count[$key] = $row['airport_departure_icao_count'];
375
-        		}
376
-        		array_multisort($count,SORT_DESC,$all);
377
-                }
378
-                return $all;
366
+				foreach ($dall as $value) {
367
+					$icao = $value['airport_departure_icao'];
368
+					if (isset($all[$icao])) {
369
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
370
+					} else $all[$icao] = $value;
371
+				}
372
+				$count = array();
373
+				foreach ($all as $key => $row) {
374
+					$count[$key] = $row['airport_departure_icao_count'];
375
+				}
376
+				array_multisort($count,SORT_DESC,$all);
377
+				}
378
+				return $all;
379 379
 	}
380 380
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
381 381
 		global $globalStatsFilters;
@@ -397,26 +397,26 @@  discard block
 block discarded – undo
397 397
 			$Spotter = new Spotter($this->db);
398 398
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
399 399
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
400
-        		$all = array();
401
-        		foreach ($pall as $value) {
402
-        			$icao = $value['airport_arrival_icao'];
403
-        			$all[$icao] = $value;
404
-        		}
400
+				$all = array();
401
+				foreach ($pall as $value) {
402
+					$icao = $value['airport_arrival_icao'];
403
+					$all[$icao] = $value;
404
+				}
405 405
         		
406
-        		foreach ($dall as $value) {
407
-        			$icao = $value['airport_arrival_icao'];
408
-        			if (isset($all[$icao])) {
409
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
410
-        			} else $all[$icao] = $value;
411
-        		}
412
-        		$count = array();
413
-        		foreach ($all as $key => $row) {
414
-        			$count[$key] = $row['airport_arrival_icao_count'];
415
-        		}
416
-        		array_multisort($count,SORT_DESC,$all);
417
-                }
406
+				foreach ($dall as $value) {
407
+					$icao = $value['airport_arrival_icao'];
408
+					if (isset($all[$icao])) {
409
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
410
+					} else $all[$icao] = $value;
411
+				}
412
+				$count = array();
413
+				foreach ($all as $key => $row) {
414
+					$count[$key] = $row['airport_arrival_icao_count'];
415
+				}
416
+				array_multisort($count,SORT_DESC,$all);
417
+				}
418 418
  
419
-                return $all;
419
+				return $all;
420 420
 	}
421 421
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
422 422
 		global $globalDBdriver, $globalStatsFilters;
@@ -429,23 +429,23 @@  discard block
 block discarded – undo
429 429
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
430 430
 		}
431 431
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
432
-                 try {
433
-                        $sth = $this->db->prepare($query);
434
-                        $sth->execute($query_data);
435
-                } catch(PDOException $e) {
436
-                        echo "error : ".$e->getMessage();
437
-                }
438
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
439
-                if (empty($all)) {
432
+				 try {
433
+						$sth = $this->db->prepare($query);
434
+						$sth->execute($query_data);
435
+				} catch(PDOException $e) {
436
+						echo "error : ".$e->getMessage();
437
+				}
438
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
439
+				if (empty($all)) {
440 440
 			$filters = array('airlines' => array($stats_airline));
441 441
 			if ($filter_name != '') {
442 442
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
443 443
 			}
444
-            		$Spotter = new Spotter($this->db);
445
-            		$all = $Spotter->countAllMonthsLastYear($filters);
446
-                }
444
+					$Spotter = new Spotter($this->db);
445
+					$all = $Spotter->countAllMonthsLastYear($filters);
446
+				}
447 447
                 
448
-                return $all;
448
+				return $all;
449 449
 	}
450 450
 	
451 451
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -453,22 +453,22 @@  discard block
 block discarded – undo
453 453
 		if ($filter_name == '') $filter_name = $this->filter_name;
454 454
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
455 455
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
456
-                 try {
457
-                        $sth = $this->db->prepare($query);
458
-                        $sth->execute($query_data);
459
-                } catch(PDOException $e) {
460
-                        echo "error : ".$e->getMessage();
461
-                }
462
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
463
-                if (empty($all)) {
456
+				 try {
457
+						$sth = $this->db->prepare($query);
458
+						$sth->execute($query_data);
459
+				} catch(PDOException $e) {
460
+						echo "error : ".$e->getMessage();
461
+				}
462
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
463
+				if (empty($all)) {
464 464
 			$filters = array('airlines' => array($stats_airline));
465 465
 			if ($filter_name != '') {
466 466
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
467 467
 			}
468
-            		$Spotter = new Spotter($this->db);
469
-            		$all = $Spotter->countAllDatesLastMonth($filters);
470
-                }
471
-                return $all;
468
+					$Spotter = new Spotter($this->db);
469
+					$all = $Spotter->countAllDatesLastMonth($filters);
470
+				}
471
+				return $all;
472 472
 	}
473 473
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
474 474
 		global $globalDBdriver, $globalStatsFilters;
@@ -479,108 +479,108 @@  discard block
 block discarded – undo
479 479
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
480 480
 		}
481 481
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
482
-                 try {
483
-                        $sth = $this->db->prepare($query);
484
-                        $sth->execute($query_data);
485
-                } catch(PDOException $e) {
486
-                        echo "error : ".$e->getMessage();
487
-                }
488
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
489
-                if (empty($all)) {
482
+				 try {
483
+						$sth = $this->db->prepare($query);
484
+						$sth->execute($query_data);
485
+				} catch(PDOException $e) {
486
+						echo "error : ".$e->getMessage();
487
+				}
488
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
489
+				if (empty($all)) {
490 490
 			$filters = array('airlines' => array($stats_airline));
491 491
 			if ($filter_name != '') {
492 492
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
493 493
 			}
494
-            		$Spotter = new Spotter($this->db);
495
-            		$all = $Spotter->countAllDatesLast7Days($filters);
496
-                }
497
-                return $all;
494
+					$Spotter = new Spotter($this->db);
495
+					$all = $Spotter->countAllDatesLast7Days($filters);
496
+				}
497
+				return $all;
498 498
 	}
499 499
 	public function countAllDates($stats_airline = '',$filter_name = '') {
500 500
 		global $globalStatsFilters;
501 501
 		if ($filter_name == '') $filter_name = $this->filter_name;
502 502
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
503 503
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
504
-                 try {
505
-                        $sth = $this->db->prepare($query);
506
-                        $sth->execute($query_data);
507
-                } catch(PDOException $e) {
508
-                        echo "error : ".$e->getMessage();
509
-                }
510
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
511
-                if (empty($all)) {
504
+				 try {
505
+						$sth = $this->db->prepare($query);
506
+						$sth->execute($query_data);
507
+				} catch(PDOException $e) {
508
+						echo "error : ".$e->getMessage();
509
+				}
510
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
511
+				if (empty($all)) {
512 512
 			$filters = array('airlines' => array($stats_airline));
513 513
 			if ($filter_name != '') {
514
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
514
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
515 515
 			}
516
-            		$Spotter = new Spotter($this->db);
517
-            		$all = $Spotter->countAllDates($filters);
518
-                }
519
-                return $all;
516
+					$Spotter = new Spotter($this->db);
517
+					$all = $Spotter->countAllDates($filters);
518
+				}
519
+				return $all;
520 520
 	}
521 521
 	public function countAllDatesByAirlines($filter_name = '') {
522 522
 		global $globalStatsFilters;
523 523
 		if ($filter_name == '') $filter_name = $this->filter_name;
524 524
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
525 525
 		$query_data = array('filter_name' => $filter_name);
526
-                 try {
527
-                        $sth = $this->db->prepare($query);
528
-                        $sth->execute($query_data);
529
-                } catch(PDOException $e) {
530
-                        echo "error : ".$e->getMessage();
531
-                }
532
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
533
-                if (empty($all)) {
534
-            		$filters = array();
535
-            		if ($filter_name != '') {
536
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
537
-			}
538
-            		$Spotter = new Spotter($this->db);
539
-            		$all = $Spotter->countAllDatesByAirlines($filters);
540
-                }
541
-                return $all;
526
+				 try {
527
+						$sth = $this->db->prepare($query);
528
+						$sth->execute($query_data);
529
+				} catch(PDOException $e) {
530
+						echo "error : ".$e->getMessage();
531
+				}
532
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
533
+				if (empty($all)) {
534
+					$filters = array();
535
+					if ($filter_name != '') {
536
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
537
+			}
538
+					$Spotter = new Spotter($this->db);
539
+					$all = $Spotter->countAllDatesByAirlines($filters);
540
+				}
541
+				return $all;
542 542
 	}
543 543
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
544 544
 		global $globalStatsFilters;
545 545
 		if ($filter_name == '') $filter_name = $this->filter_name;
546
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
547
-                 try {
548
-                        $sth = $this->db->prepare($query);
549
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
550
-                } catch(PDOException $e) {
551
-                        echo "error : ".$e->getMessage();
552
-                }
553
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
554
-                if (empty($all)) {
546
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
547
+				 try {
548
+						$sth = $this->db->prepare($query);
549
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
550
+				} catch(PDOException $e) {
551
+						echo "error : ".$e->getMessage();
552
+				}
553
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
554
+				if (empty($all)) {
555 555
 			$filters = array('airlines' => array($stats_airline));
556 556
 			if ($filter_name != '') {
557 557
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
558 558
 			}
559
-            		$Spotter = new Spotter($this->db);
560
-            		$all = $Spotter->countAllMonths($filters);
561
-                }
562
-                return $all;
559
+					$Spotter = new Spotter($this->db);
560
+					$all = $Spotter->countAllMonths($filters);
561
+				}
562
+				return $all;
563 563
 	}
564 564
 	public function countAllMilitaryMonths($filter_name = '') {
565 565
 		global $globalStatsFilters;
566 566
 		if ($filter_name == '') $filter_name = $this->filter_name;
567
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
568
-                 try {
569
-                        $sth = $this->db->prepare($query);
570
-                        $sth->execute(array(':filter_name' => $filter_name));
571
-                } catch(PDOException $e) {
572
-                        echo "error : ".$e->getMessage();
573
-                }
574
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
575
-                if (empty($all)) {
576
-            		$filters = array();
577
-            		if ($filter_name != '') {
578
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
579
-			}
580
-            		$Spotter = new Spotter($this->db);
581
-            		$all = $Spotter->countAllMilitaryMonths($filters);
582
-                }
583
-                return $all;
567
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
568
+				 try {
569
+						$sth = $this->db->prepare($query);
570
+						$sth->execute(array(':filter_name' => $filter_name));
571
+				} catch(PDOException $e) {
572
+						echo "error : ".$e->getMessage();
573
+				}
574
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
575
+				if (empty($all)) {
576
+					$filters = array();
577
+					if ($filter_name != '') {
578
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
579
+			}
580
+					$Spotter = new Spotter($this->db);
581
+					$all = $Spotter->countAllMilitaryMonths($filters);
582
+				}
583
+				return $all;
584 584
 	}
585 585
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
586 586
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -596,22 +596,22 @@  discard block
 block discarded – undo
596 596
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
597 597
 		}
598 598
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
599
-                 try {
600
-                        $sth = $this->db->prepare($query);
601
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
602
-                } catch(PDOException $e) {
603
-                        echo "error : ".$e->getMessage();
604
-                }
605
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
606
-                if (empty($all)) {
599
+				 try {
600
+						$sth = $this->db->prepare($query);
601
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
602
+				} catch(PDOException $e) {
603
+						echo "error : ".$e->getMessage();
604
+				}
605
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
606
+				if (empty($all)) {
607 607
 			$filters = array('airlines' => array($stats_airline));
608 608
 			if ($filter_name != '') {
609
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
609
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
610 610
 			}
611
-            		$Spotter = new Spotter($this->db);
612
-            		$all = $Spotter->countAllHours($orderby,$filters);
613
-                }
614
-                return $all;
611
+					$Spotter = new Spotter($this->db);
612
+					$all = $Spotter->countAllHours($orderby,$filters);
613
+				}
614
+				return $all;
615 615
 	}
616 616
 	
617 617
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
@@ -633,9 +633,9 @@  discard block
 block discarded – undo
633 633
 		if ($filter_name == '') $filter_name = $this->filter_name;
634 634
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
635 635
 		if (empty($all)) {
636
-		        $filters = array();
637
-            		if ($filter_name != '') {
638
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
636
+				$filters = array();
637
+					if ($filter_name != '') {
638
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
639 639
 			}
640 640
 			$Spotter = new Spotter($this->db);
641 641
 			$all = $Spotter->countOverallMilitaryFlights($filters);
@@ -674,19 +674,19 @@  discard block
 block discarded – undo
674 674
 		global $globalStatsFilters;
675 675
 		if ($filter_name == '') $filter_name = $this->filter_name;
676 676
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
677
-                 try {
678
-                        $sth = $this->db->prepare($query);
679
-                        $sth->execute(array(':filter_name' => $filter_name));
680
-                } catch(PDOException $e) {
681
-                        echo "error : ".$e->getMessage();
682
-                }
683
-                $result = $sth->fetchAll(PDO::FETCH_ASSOC);
684
-                $all = $result[0]['nb_airline'];
677
+				 try {
678
+						$sth = $this->db->prepare($query);
679
+						$sth->execute(array(':filter_name' => $filter_name));
680
+				} catch(PDOException $e) {
681
+						echo "error : ".$e->getMessage();
682
+				}
683
+				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
684
+				$all = $result[0]['nb_airline'];
685 685
 		//$all = $this->getSumStats('airlines_bymonth',date('Y'));
686 686
 		if (empty($all)) {
687
-            		$filters = array();
688
-            		if ($filter_name != '') {
689
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
687
+					$filters = array();
688
+					if ($filter_name != '') {
689
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
690 690
 			}
691 691
 			$Spotter = new Spotter($this->db);
692 692
 			$all = $Spotter->countOverallAirlines($filters);
@@ -737,166 +737,166 @@  discard block
 block discarded – undo
737 737
 		if ($filter_name == '') $filter_name = $this->filter_name;
738 738
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
739 739
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
740
-                 try {
741
-                        $sth = $this->db->prepare($query);
742
-                        $sth->execute($query_values);
743
-                } catch(PDOException $e) {
744
-                        echo "error : ".$e->getMessage();
745
-                }
746
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
747
-                return $all;
740
+				 try {
741
+						$sth = $this->db->prepare($query);
742
+						$sth->execute($query_values);
743
+				} catch(PDOException $e) {
744
+						echo "error : ".$e->getMessage();
745
+				}
746
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
747
+				return $all;
748 748
 	}
749 749
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
750 750
 		if ($filter_name == '') $filter_name = $this->filter_name;
751
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
752
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
753
-                 try {
754
-                        $sth = $this->db->prepare($query);
755
-                        $sth->execute($query_values);
756
-                } catch(PDOException $e) {
757
-                        echo "error : ".$e->getMessage();
758
-                }
759
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
760
-                return $all;
761
-        }
751
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
752
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
753
+				 try {
754
+						$sth = $this->db->prepare($query);
755
+						$sth->execute($query_values);
756
+				} catch(PDOException $e) {
757
+						echo "error : ".$e->getMessage();
758
+				}
759
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
760
+				return $all;
761
+		}
762 762
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
763 763
 		if ($filter_name == '') $filter_name = $this->filter_name;
764
-    		global $globalArchiveMonths, $globalDBdriver;
765
-    		if ($globalDBdriver == 'mysql') {
766
-	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
767
-	        } else {
768
-            		$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
769
-                }
770
-                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
771
-                 try {
772
-                        $sth = $this->db->prepare($query);
773
-                        $sth->execute($query_values);
774
-                } catch(PDOException $e) {
775
-                        echo "error : ".$e->getMessage();
776
-                }
777
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
778
-                return $all[0]['total'];
779
-        }
764
+			global $globalArchiveMonths, $globalDBdriver;
765
+			if ($globalDBdriver == 'mysql') {
766
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
767
+			} else {
768
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
769
+				}
770
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
771
+				 try {
772
+						$sth = $this->db->prepare($query);
773
+						$sth->execute($query_values);
774
+				} catch(PDOException $e) {
775
+						echo "error : ".$e->getMessage();
776
+				}
777
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
778
+				return $all[0]['total'];
779
+		}
780 780
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
781
-    		global $globalArchiveMonths, $globalDBdriver;
781
+			global $globalArchiveMonths, $globalDBdriver;
782 782
 		if ($filter_name == '') $filter_name = $this->filter_name;
783
-    		if ($globalDBdriver == 'mysql') {
783
+			if ($globalDBdriver == 'mysql') {
784 784
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
785 785
 		} else {
786 786
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
787
-                }
788
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
789
-                 try {
790
-                        $sth = $this->db->prepare($query);
791
-                        $sth->execute($query_values);
792
-                } catch(PDOException $e) {
793
-                        echo "error : ".$e->getMessage();
794
-                }
795
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
796
-                return $all[0]['total'];
797
-        }
787
+				}
788
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
789
+				 try {
790
+						$sth = $this->db->prepare($query);
791
+						$sth->execute($query_values);
792
+				} catch(PDOException $e) {
793
+						echo "error : ".$e->getMessage();
794
+				}
795
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
796
+				return $all[0]['total'];
797
+		}
798 798
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
799
-    		global $globalArchiveMonths, $globalDBdriver;
799
+			global $globalArchiveMonths, $globalDBdriver;
800 800
 		if ($filter_name == '') $filter_name = $this->filter_name;
801
-    		if ($globalDBdriver == 'mysql') {
801
+			if ($globalDBdriver == 'mysql') {
802 802
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
803
-                } else {
803
+				} else {
804 804
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
805
-                }
806
-                 try {
807
-                        $sth = $this->db->prepare($query);
808
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
809
-                } catch(PDOException $e) {
810
-                        echo "error : ".$e->getMessage();
811
-                }
812
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
813
-                return $all[0]['total'];
814
-        }
805
+				}
806
+				 try {
807
+						$sth = $this->db->prepare($query);
808
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
809
+				} catch(PDOException $e) {
810
+						echo "error : ".$e->getMessage();
811
+				}
812
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
813
+				return $all[0]['total'];
814
+		}
815 815
 	public function getStatsAirlineTotal($filter_name = '') {
816
-    		global $globalArchiveMonths, $globalDBdriver;
816
+			global $globalArchiveMonths, $globalDBdriver;
817 817
 		if ($filter_name == '') $filter_name = $this->filter_name;
818
-    		if ($globalDBdriver == 'mysql') {
818
+			if ($globalDBdriver == 'mysql') {
819 819
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
820
-                } else {
820
+				} else {
821 821
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
822
-                }
823
-                 try {
824
-                        $sth = $this->db->prepare($query);
825
-                        $sth->execute(array(':filter_name' => $filter_name));
826
-                } catch(PDOException $e) {
827
-                        echo "error : ".$e->getMessage();
828
-                }
829
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
830
-                return $all[0]['total'];
831
-        }
822
+				}
823
+				 try {
824
+						$sth = $this->db->prepare($query);
825
+						$sth->execute(array(':filter_name' => $filter_name));
826
+				} catch(PDOException $e) {
827
+						echo "error : ".$e->getMessage();
828
+				}
829
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
830
+				return $all[0]['total'];
831
+		}
832 832
 	public function getStatsOwnerTotal($filter_name = '') {
833
-    		global $globalArchiveMonths, $globalDBdriver;
833
+			global $globalArchiveMonths, $globalDBdriver;
834 834
 		if ($filter_name == '') $filter_name = $this->filter_name;
835
-    		if ($globalDBdriver == 'mysql') {
835
+			if ($globalDBdriver == 'mysql') {
836 836
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
837 837
 		} else {
838 838
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
839
-                }
840
-                 try {
841
-                        $sth = $this->db->prepare($query);
842
-                        $sth->execute(array(':filter_name' => $filter_name));
843
-                } catch(PDOException $e) {
844
-                        echo "error : ".$e->getMessage();
845
-                }
846
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
847
-                return $all[0]['total'];
848
-        }
839
+				}
840
+				 try {
841
+						$sth = $this->db->prepare($query);
842
+						$sth->execute(array(':filter_name' => $filter_name));
843
+				} catch(PDOException $e) {
844
+						echo "error : ".$e->getMessage();
845
+				}
846
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
847
+				return $all[0]['total'];
848
+		}
849 849
 	public function getStatsPilotTotal($filter_name = '') {
850
-    		global $globalArchiveMonths, $globalDBdriver;
850
+			global $globalArchiveMonths, $globalDBdriver;
851 851
 		if ($filter_name == '') $filter_name = $this->filter_name;
852
-    		if ($globalDBdriver == 'mysql') {
853
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
854
-            	} else {
855
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
856
-            	}
857
-                 try {
858
-                        $sth = $this->db->prepare($query);
859
-                        $sth->execute(array(':filter_name' => $filter_name));
860
-                } catch(PDOException $e) {
861
-                        echo "error : ".$e->getMessage();
862
-                }
863
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
864
-                return $all[0]['total'];
865
-        }
852
+			if ($globalDBdriver == 'mysql') {
853
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
854
+				} else {
855
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
856
+				}
857
+				 try {
858
+						$sth = $this->db->prepare($query);
859
+						$sth->execute(array(':filter_name' => $filter_name));
860
+				} catch(PDOException $e) {
861
+						echo "error : ".$e->getMessage();
862
+				}
863
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
864
+				return $all[0]['total'];
865
+		}
866 866
 
867 867
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
868 868
 		global $globalDBdriver;
869 869
 		if ($filter_name == '') $filter_name = $this->filter_name;
870 870
 		if ($globalDBdriver == 'mysql') {
871 871
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
872
-                } else {
872
+				} else {
873 873
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
874 874
 		}
875
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
876
-                 try {
877
-                        $sth = $this->db->prepare($query);
878
-                        $sth->execute($query_values);
879
-                } catch(PDOException $e) {
880
-                        return "error : ".$e->getMessage();
881
-                }
882
-        }
875
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
876
+				 try {
877
+						$sth = $this->db->prepare($query);
878
+						$sth->execute($query_values);
879
+				} catch(PDOException $e) {
880
+						return "error : ".$e->getMessage();
881
+				}
882
+		}
883 883
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
884 884
 		global $globalDBdriver;
885 885
 		if ($filter_name == '') $filter_name = $this->filter_name;
886 886
 		if ($globalDBdriver == 'mysql') {
887 887
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
888 888
 		} else {
889
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
889
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
890 890
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
891
-                }
892
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
893
-                 try {
894
-                        $sth = $this->db->prepare($query);
895
-                        $sth->execute($query_values);
896
-                } catch(PDOException $e) {
897
-                        return "error : ".$e->getMessage();
898
-                }
899
-        }
891
+				}
892
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
893
+				 try {
894
+						$sth = $this->db->prepare($query);
895
+						$sth->execute($query_values);
896
+				} catch(PDOException $e) {
897
+						return "error : ".$e->getMessage();
898
+				}
899
+		}
900 900
 	public function getStatsSource($date,$stats_type = '') {
901 901
 		if ($stats_type == '') {
902 902
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -905,15 +905,15 @@  discard block
 block discarded – undo
905 905
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
906 906
 			$query_values = array(':date' => $date,':stats_type' => $stats_type);
907 907
 		}
908
-                 try {
909
-                        $sth = $this->db->prepare($query);
910
-                        $sth->execute($query_values);
911
-                } catch(PDOException $e) {
912
-                        echo "error : ".$e->getMessage();
913
-                }
914
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
915
-                return $all;
916
-        }
908
+				 try {
909
+						$sth = $this->db->prepare($query);
910
+						$sth->execute($query_values);
911
+				} catch(PDOException $e) {
912
+						echo "error : ".$e->getMessage();
913
+				}
914
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
915
+				return $all;
916
+		}
917 917
 
918 918
 	public function addStatSource($data,$source_name,$stats_type,$date) {
919 919
 		global $globalDBdriver;
@@ -921,25 +921,25 @@  discard block
 block discarded – undo
921 921
 			$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";
922 922
 		} else {
923 923
 			$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);"; 
924
-                }
925
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
926
-                 try {
927
-                        $sth = $this->db->prepare($query);
928
-                        $sth->execute($query_values);
929
-                } catch(PDOException $e) {
930
-                        return "error : ".$e->getMessage();
931
-                }
932
-        }
924
+				}
925
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
926
+				 try {
927
+						$sth = $this->db->prepare($query);
928
+						$sth->execute($query_values);
929
+				} catch(PDOException $e) {
930
+						return "error : ".$e->getMessage();
931
+				}
932
+		}
933 933
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
934
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
935
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
936
-                 try {
937
-                        $sth = $this->db->prepare($query);
938
-                        $sth->execute($query_values);
939
-                } catch(PDOException $e) {
940
-                        return "error : ".$e->getMessage();
941
-                }
942
-        }
934
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
935
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
936
+				 try {
937
+						$sth = $this->db->prepare($query);
938
+						$sth->execute($query_values);
939
+				} catch(PDOException $e) {
940
+						return "error : ".$e->getMessage();
941
+				}
942
+		}
943 943
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') {
944 944
 		global $globalDBdriver;
945 945
 		if ($globalDBdriver == 'mysql') {
@@ -947,14 +947,14 @@  discard block
 block discarded – undo
947 947
 		} else {
948 948
 			$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
949 949
 		}
950
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
951
-                 try {
952
-                        $sth = $this->db->prepare($query);
953
-                        $sth->execute($query_values);
954
-                } catch(PDOException $e) {
955
-                        return "error : ".$e->getMessage();
956
-                }
957
-        }
950
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
951
+				 try {
952
+						$sth = $this->db->prepare($query);
953
+						$sth->execute($query_values);
954
+				} catch(PDOException $e) {
955
+						return "error : ".$e->getMessage();
956
+				}
957
+		}
958 958
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') {
959 959
 		global $globalDBdriver;
960 960
 		if ($globalDBdriver == 'mysql') {
@@ -962,14 +962,14 @@  discard block
 block discarded – undo
962 962
 		} else {
963 963
 			$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
964 964
 		}
965
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
966
-                 try {
967
-                        $sth = $this->db->prepare($query);
968
-                        $sth->execute($query_values);
969
-                } catch(PDOException $e) {
970
-                        return "error : ".$e->getMessage();
971
-                }
972
-        }
965
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
966
+				 try {
967
+						$sth = $this->db->prepare($query);
968
+						$sth->execute($query_values);
969
+				} catch(PDOException $e) {
970
+						return "error : ".$e->getMessage();
971
+				}
972
+		}
973 973
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') {
974 974
 		global $globalDBdriver;
975 975
 		if ($globalDBdriver == 'mysql') {
@@ -977,14 +977,14 @@  discard block
 block discarded – undo
977 977
 		} else {
978 978
 			$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
979 979
 		}
980
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
981
-                 try {
982
-                        $sth = $this->db->prepare($query);
983
-                        $sth->execute($query_values);
984
-                } catch(PDOException $e) {
985
-                        return "error : ".$e->getMessage();
986
-                }
987
-        }
980
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
981
+				 try {
982
+						$sth = $this->db->prepare($query);
983
+						$sth->execute($query_values);
984
+				} catch(PDOException $e) {
985
+						return "error : ".$e->getMessage();
986
+				}
987
+		}
988 988
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') {
989 989
 		global $globalDBdriver;
990 990
 		if ($globalDBdriver == 'mysql') {
@@ -992,14 +992,14 @@  discard block
 block discarded – undo
992 992
 		} else {
993 993
 			$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
994 994
 		}
995
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
996
-                 try {
997
-                        $sth = $this->db->prepare($query);
998
-                        $sth->execute($query_values);
999
-                } catch(PDOException $e) {
1000
-                        return "error : ".$e->getMessage();
1001
-                }
1002
-        }
995
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
996
+				 try {
997
+						$sth = $this->db->prepare($query);
998
+						$sth->execute($query_values);
999
+				} catch(PDOException $e) {
1000
+						return "error : ".$e->getMessage();
1001
+				}
1002
+		}
1003 1003
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') {
1004 1004
 		global $globalDBdriver;
1005 1005
 		if ($globalDBdriver == 'mysql') {
@@ -1007,14 +1007,14 @@  discard block
 block discarded – undo
1007 1007
 		} else {
1008 1008
 			$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1009 1009
 		}
1010
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1011
-                 try {
1012
-                        $sth = $this->db->prepare($query);
1013
-                        $sth->execute($query_values);
1014
-                } catch(PDOException $e) {
1015
-                        return "error : ".$e->getMessage();
1016
-                }
1017
-        }
1010
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1011
+				 try {
1012
+						$sth = $this->db->prepare($query);
1013
+						$sth->execute($query_values);
1014
+				} catch(PDOException $e) {
1015
+						return "error : ".$e->getMessage();
1016
+				}
1017
+		}
1018 1018
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') {
1019 1019
 		global $globalDBdriver;
1020 1020
 		if ($globalDBdriver == 'mysql') {
@@ -1022,14 +1022,14 @@  discard block
 block discarded – undo
1022 1022
 		} else {
1023 1023
 			$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1024 1024
 		}
1025
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1026
-                 try {
1027
-                        $sth = $this->db->prepare($query);
1028
-                        $sth->execute($query_values);
1029
-                } catch(PDOException $e) {
1030
-                        return "error : ".$e->getMessage();
1031
-                }
1032
-        }
1025
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1026
+				 try {
1027
+						$sth = $this->db->prepare($query);
1028
+						$sth->execute($query_values);
1029
+				} catch(PDOException $e) {
1030
+						return "error : ".$e->getMessage();
1031
+				}
1032
+		}
1033 1033
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '') {
1034 1034
 		global $globalDBdriver;
1035 1035
 		if ($globalDBdriver == 'mysql') {
@@ -1037,14 +1037,14 @@  discard block
 block discarded – undo
1037 1037
 		} else {
1038 1038
 			$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1039 1039
 		}
1040
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1041
-                 try {
1042
-                        $sth = $this->db->prepare($query);
1043
-                        $sth->execute($query_values);
1044
-                } catch(PDOException $e) {
1045
-                        return "error : ".$e->getMessage();
1046
-                }
1047
-        }
1040
+				$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1041
+				 try {
1042
+						$sth = $this->db->prepare($query);
1043
+						$sth->execute($query_values);
1044
+				} catch(PDOException $e) {
1045
+						return "error : ".$e->getMessage();
1046
+				}
1047
+		}
1048 1048
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1049 1049
 		global $globalDBdriver;
1050 1050
 		if ($globalDBdriver == 'mysql') {
@@ -1052,14 +1052,14 @@  discard block
 block discarded – undo
1052 1052
 		} else {
1053 1053
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1054 1054
 		}
1055
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1056
-                 try {
1057
-                        $sth = $this->db->prepare($query);
1058
-                        $sth->execute($query_values);
1059
-                } catch(PDOException $e) {
1060
-                        return "error : ".$e->getMessage();
1061
-                }
1062
-        }
1055
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1056
+				 try {
1057
+						$sth = $this->db->prepare($query);
1058
+						$sth->execute($query_values);
1059
+				} catch(PDOException $e) {
1060
+						return "error : ".$e->getMessage();
1061
+				}
1062
+		}
1063 1063
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1064 1064
 		global $globalDBdriver;
1065 1065
 		if ($globalDBdriver == 'mysql') {
@@ -1067,14 +1067,14 @@  discard block
 block discarded – undo
1067 1067
 		} else {
1068 1068
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1069 1069
 		}
1070
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1071
-                 try {
1072
-                        $sth = $this->db->prepare($query);
1073
-                        $sth->execute($query_values);
1074
-                } catch(PDOException $e) {
1075
-                        return "error : ".$e->getMessage();
1076
-                }
1077
-        }
1070
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1071
+				 try {
1072
+						$sth = $this->db->prepare($query);
1073
+						$sth->execute($query_values);
1074
+				} catch(PDOException $e) {
1075
+						return "error : ".$e->getMessage();
1076
+				}
1077
+		}
1078 1078
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1079 1079
 		global $globalDBdriver;
1080 1080
 		if ($globalDBdriver == 'mysql') {
@@ -1082,14 +1082,14 @@  discard block
 block discarded – undo
1082 1082
 		} else {
1083 1083
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1084 1084
 		}
1085
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1086
-                 try {
1087
-                        $sth = $this->db->prepare($query);
1088
-                        $sth->execute($query_values);
1089
-                } catch(PDOException $e) {
1090
-                        return "error : ".$e->getMessage();
1091
-                }
1092
-        }
1085
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1086
+				 try {
1087
+						$sth = $this->db->prepare($query);
1088
+						$sth->execute($query_values);
1089
+				} catch(PDOException $e) {
1090
+						return "error : ".$e->getMessage();
1091
+				}
1092
+		}
1093 1093
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1094 1094
 		global $globalDBdriver;
1095 1095
 		if ($globalDBdriver == 'mysql') {
@@ -1097,52 +1097,52 @@  discard block
 block discarded – undo
1097 1097
 		} else {
1098 1098
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1099 1099
 		}
1100
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1101
-                 try {
1102
-                        $sth = $this->db->prepare($query);
1103
-                        $sth->execute($query_values);
1104
-                } catch(PDOException $e) {
1105
-                        return "error : ".$e->getMessage();
1106
-                }
1107
-        }
1100
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1101
+				 try {
1102
+						$sth = $this->db->prepare($query);
1103
+						$sth->execute($query_values);
1104
+				} catch(PDOException $e) {
1105
+						return "error : ".$e->getMessage();
1106
+				}
1107
+		}
1108 1108
 
1109 1109
 	public function deleteStat($id) {
1110
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1111
-                $query_values = array(':id' => $id);
1112
-                 try {
1113
-                        $sth = $this->db->prepare($query);
1114
-                        $sth->execute($query_values);
1115
-                } catch(PDOException $e) {
1116
-                        return "error : ".$e->getMessage();
1117
-                }
1118
-        }
1110
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1111
+				$query_values = array(':id' => $id);
1112
+				 try {
1113
+						$sth = $this->db->prepare($query);
1114
+						$sth->execute($query_values);
1115
+				} catch(PDOException $e) {
1116
+						return "error : ".$e->getMessage();
1117
+				}
1118
+		}
1119 1119
 	public function deleteStatFlight($type) {
1120
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1121
-                $query_values = array(':type' => $type);
1122
-                 try {
1123
-                        $sth = $this->db->prepare($query);
1124
-                        $sth->execute($query_values);
1125
-                } catch(PDOException $e) {
1126
-                        return "error : ".$e->getMessage();
1127
-                }
1128
-        }
1120
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1121
+				$query_values = array(':type' => $type);
1122
+				 try {
1123
+						$sth = $this->db->prepare($query);
1124
+						$sth->execute($query_values);
1125
+				} catch(PDOException $e) {
1126
+						return "error : ".$e->getMessage();
1127
+				}
1128
+		}
1129 1129
 	public function deleteStatAirport($type) {
1130
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1131
-                $query_values = array(':type' => $type);
1132
-                 try {
1133
-                        $sth = $this->db->prepare($query);
1134
-                        $sth->execute($query_values);
1135
-                } catch(PDOException $e) {
1136
-                        return "error : ".$e->getMessage();
1137
-                }
1138
-        }
1130
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1131
+				$query_values = array(':type' => $type);
1132
+				 try {
1133
+						$sth = $this->db->prepare($query);
1134
+						$sth->execute($query_values);
1135
+				} catch(PDOException $e) {
1136
+						return "error : ".$e->getMessage();
1137
+				}
1138
+		}
1139 1139
         
1140
-        public function addOldStats() {
1141
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters;
1142
-    		$Common = new Common();
1143
-    		$Connection = new Connection();
1144
-    		date_default_timezone_set('UTC');
1145
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1140
+		public function addOldStats() {
1141
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters;
1142
+			$Common = new Common();
1143
+			$Connection = new Connection();
1144
+			date_default_timezone_set('UTC');
1145
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1146 1146
 		//print_r($last_update);
1147 1147
 		/*
1148 1148
 		$flightsbymonth = $this->getStats('flights_by_month');
@@ -1404,24 +1404,24 @@  discard block
 block discarded – undo
1404 1404
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1405 1405
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1406 1406
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1407
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1407
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1408 1408
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1409
-	        	$alldata = array();
1409
+				$alldata = array();
1410 1410
 	        	
1411
-    			foreach ($pall as $value) {
1412
-	        		$icao = $value['airport_departure_icao'];
1413
-    				$alldata[$icao] = $value;
1414
-	        	}
1415
-	        	foreach ($dall as $value) {
1416
-    				$icao = $value['airport_departure_icao'];
1417
-        			if (isset($alldata[$icao])) {
1418
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1419
-        			} else $alldata[$icao] = $value;
1420
-			}
1421
-    			$count = array();
1422
-    			foreach ($alldata as $key => $row) {
1423
-    				$count[$key] = $row['airport_departure_icao_count'];
1424
-        		}
1411
+				foreach ($pall as $value) {
1412
+					$icao = $value['airport_departure_icao'];
1413
+					$alldata[$icao] = $value;
1414
+				}
1415
+				foreach ($dall as $value) {
1416
+					$icao = $value['airport_departure_icao'];
1417
+					if (isset($alldata[$icao])) {
1418
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1419
+					} else $alldata[$icao] = $value;
1420
+			}
1421
+				$count = array();
1422
+				foreach ($alldata as $key => $row) {
1423
+					$count[$key] = $row['airport_departure_icao_count'];
1424
+				}
1425 1425
 			array_multisort($count,SORT_DESC,$alldata);
1426 1426
 			foreach ($alldata as $number) {
1427 1427
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
@@ -1429,25 +1429,25 @@  discard block
 block discarded – undo
1429 1429
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1430 1430
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1431 1431
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1432
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1432
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1433 1433
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1434
-	        	$alldata = array();
1435
-    			foreach ($pall as $value) {
1436
-	        		$icao = $value['airport_arrival_icao'];
1437
-    				$alldata[$icao] = $value;
1438
-	        	}
1439
-	        	foreach ($dall as $value) {
1440
-    				$icao = $value['airport_arrival_icao'];
1441
-        			if (isset($alldata[$icao])) {
1442
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1443
-	        		} else $alldata[$icao] = $value;
1444
-    			}
1445
-        		$count = array();
1446
-        		foreach ($alldata as $key => $row) {
1447
-        			$count[$key] = $row['airport_arrival_icao_count'];
1448
-	        	}
1449
-    			array_multisort($count,SORT_DESC,$alldata);
1450
-                        foreach ($alldata as $number) {
1434
+				$alldata = array();
1435
+				foreach ($pall as $value) {
1436
+					$icao = $value['airport_arrival_icao'];
1437
+					$alldata[$icao] = $value;
1438
+				}
1439
+				foreach ($dall as $value) {
1440
+					$icao = $value['airport_arrival_icao'];
1441
+					if (isset($alldata[$icao])) {
1442
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1443
+					} else $alldata[$icao] = $value;
1444
+				}
1445
+				$count = array();
1446
+				foreach ($alldata as $key => $row) {
1447
+					$count[$key] = $row['airport_arrival_icao_count'];
1448
+				}
1449
+				array_multisort($count,SORT_DESC,$alldata);
1450
+						foreach ($alldata as $number) {
1451 1451
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1452 1452
 			}
1453 1453
 			if ($Connection->tableExists('countries')) {
@@ -1507,8 +1507,8 @@  discard block
 block discarded – undo
1507 1507
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1508 1508
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1509 1509
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1510
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1511
-        		/*
1510
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1511
+				/*
1512 1512
 	        	$alldata = array();
1513 1513
     			foreach ($pall as $value) {
1514 1514
 	        		$icao = $value['departure_airport_icao'];
@@ -1527,29 +1527,29 @@  discard block
 block discarded – undo
1527 1527
 	        	}
1528 1528
     			array_multisort($count,SORT_DESC,$alldata);
1529 1529
     			*/
1530
-    			foreach ($dall as $value) {
1531
-    				$icao = $value['departure_airport_icao'];
1532
-    				$ddate = $value['date'];
1533
-    				$find = false;
1534
-    				foreach ($pall as $pvalue) {
1535
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1536
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1537
-    						$find = true;
1538
-    						break;
1539
-    					}
1540
-    				}
1541
-    				if ($find === false) {
1542
-    					$pall[] = $value;
1543
-    				}
1544
-    			}
1545
-    			$alldata = $pall;
1530
+				foreach ($dall as $value) {
1531
+					$icao = $value['departure_airport_icao'];
1532
+					$ddate = $value['date'];
1533
+					$find = false;
1534
+					foreach ($pall as $pvalue) {
1535
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1536
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1537
+							$find = true;
1538
+							break;
1539
+						}
1540
+					}
1541
+					if ($find === false) {
1542
+						$pall[] = $value;
1543
+					}
1544
+				}
1545
+				$alldata = $pall;
1546 1546
 			foreach ($alldata as $number) {
1547 1547
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1548 1548
 			}
1549 1549
 			echo '...Arrival'."\n";
1550 1550
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1551
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1552
-        		/*
1551
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1552
+				/*
1553 1553
 	        	$alldata = array();
1554 1554
     			foreach ($pall as $value) {
1555 1555
 	        		$icao = $value['arrival_airport_icao'];
@@ -1569,22 +1569,22 @@  discard block
 block discarded – undo
1569 1569
     			*/
1570 1570
 
1571 1571
 
1572
-    			foreach ($dall as $value) {
1573
-    				$icao = $value['arrival_airport_icao'];
1574
-    				$ddate = $value['date'];
1575
-    				$find = false;
1576
-    				foreach ($pall as $pvalue) {
1577
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1578
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1579
-    						$find = true;
1580
-    						break;
1581
-    					}
1582
-    				}
1583
-    				if ($find === false) {
1584
-    					$pall[] = $value;
1585
-    				}
1586
-    			}
1587
-    			$alldata = $pall;
1572
+				foreach ($dall as $value) {
1573
+					$icao = $value['arrival_airport_icao'];
1574
+					$ddate = $value['date'];
1575
+					$find = false;
1576
+					foreach ($pall as $pvalue) {
1577
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1578
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1579
+							$find = true;
1580
+							break;
1581
+						}
1582
+					}
1583
+					if ($find === false) {
1584
+						$pall[] = $value;
1585
+					}
1586
+				}
1587
+				$alldata = $pall;
1588 1588
 			foreach ($alldata as $number) {
1589 1589
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1590 1590
 			}
@@ -1651,51 +1651,51 @@  discard block
 block discarded – undo
1651 1651
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1652 1652
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1653 1653
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1654
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1654
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1655 1655
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1656
-	        	//$alldata = array();
1657
-    			foreach ($dall as $value) {
1658
-    				$icao = $value['airport_departure_icao'];
1659
-    				$dicao = $value['airline_icao'];
1660
-    				$find = false;
1661
-    				foreach ($pall as $pvalue) {
1662
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1663
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1664
-    						$find = true;
1665
-    						break;
1666
-    					}
1667
-    				}
1668
-    				if ($find === false) {
1669
-    					$pall[] = $value;
1670
-    				}
1671
-    			}
1672
-    			$alldata = $pall;
1656
+				//$alldata = array();
1657
+				foreach ($dall as $value) {
1658
+					$icao = $value['airport_departure_icao'];
1659
+					$dicao = $value['airline_icao'];
1660
+					$find = false;
1661
+					foreach ($pall as $pvalue) {
1662
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1663
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1664
+							$find = true;
1665
+							break;
1666
+						}
1667
+					}
1668
+					if ($find === false) {
1669
+						$pall[] = $value;
1670
+					}
1671
+				}
1672
+				$alldata = $pall;
1673 1673
 			foreach ($alldata as $number) {
1674 1674
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao']);
1675 1675
 			}
1676 1676
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1677 1677
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1678 1678
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1679
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1679
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1680 1680
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1681
-	        	//$alldata = array();
1682
-    			foreach ($dall as $value) {
1683
-    				$icao = $value['airport_arrival_icao'];
1684
-    				$dicao = $value['airline_icao'];
1685
-    				$find = false;
1686
-    				foreach ($pall as $pvalue) {
1687
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1688
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1689
-    						$find = true;
1690
-    						break;
1691
-    					}
1692
-    				}
1693
-    				if ($find === false) {
1694
-    					$pall[] = $value;
1695
-    				}
1696
-    			}
1697
-    			$alldata = $pall;
1698
-                        foreach ($alldata as $number) {
1681
+				//$alldata = array();
1682
+				foreach ($dall as $value) {
1683
+					$icao = $value['airport_arrival_icao'];
1684
+					$dicao = $value['airline_icao'];
1685
+					$find = false;
1686
+					foreach ($pall as $pvalue) {
1687
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1688
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1689
+							$find = true;
1690
+							break;
1691
+						}
1692
+					}
1693
+					if ($find === false) {
1694
+						$pall[] = $value;
1695
+					}
1696
+				}
1697
+				$alldata = $pall;
1698
+						foreach ($alldata as $number) {
1699 1699
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao']);
1700 1700
 			}
1701 1701
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1728,47 +1728,47 @@  discard block
 block discarded – undo
1728 1728
 			}
1729 1729
 			if ($globalDebug) echo '...Departure'."\n";
1730 1730
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1731
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1732
-    			foreach ($dall as $value) {
1733
-    				$icao = $value['departure_airport_icao'];
1734
-    				$airline = $value['airline_icao'];
1735
-    				$ddate = $value['date'];
1736
-    				$find = false;
1737
-    				foreach ($pall as $pvalue) {
1738
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1739
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1740
-    						$find = true;
1741
-    						break;
1742
-    					}
1743
-    				}
1744
-    				if ($find === false) {
1745
-    					$pall[] = $value;
1746
-    				}
1747
-    			}
1748
-    			$alldata = $pall;
1731
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1732
+				foreach ($dall as $value) {
1733
+					$icao = $value['departure_airport_icao'];
1734
+					$airline = $value['airline_icao'];
1735
+					$ddate = $value['date'];
1736
+					$find = false;
1737
+					foreach ($pall as $pvalue) {
1738
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1739
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1740
+							$find = true;
1741
+							break;
1742
+						}
1743
+					}
1744
+					if ($find === false) {
1745
+						$pall[] = $value;
1746
+					}
1747
+				}
1748
+				$alldata = $pall;
1749 1749
 			foreach ($alldata as $number) {
1750 1750
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1751 1751
 			}
1752 1752
 			if ($globalDebug) echo '...Arrival'."\n";
1753 1753
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1754
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1755
-    			foreach ($dall as $value) {
1756
-    				$icao = $value['arrival_airport_icao'];
1757
-    				$airline = $value['airline_icao'];
1758
-    				$ddate = $value['date'];
1759
-    				$find = false;
1760
-    				foreach ($pall as $pvalue) {
1761
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1762
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1763
-    						$find = true;
1764
-    						break;
1765
-    					}
1766
-    				}
1767
-    				if ($find === false) {
1768
-    					$pall[] = $value;
1769
-    				}
1770
-    			}
1771
-    			$alldata = $pall;
1754
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1755
+				foreach ($dall as $value) {
1756
+					$icao = $value['arrival_airport_icao'];
1757
+					$airline = $value['airline_icao'];
1758
+					$ddate = $value['date'];
1759
+					$find = false;
1760
+					foreach ($pall as $pvalue) {
1761
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1762
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1763
+							$find = true;
1764
+							break;
1765
+						}
1766
+					}
1767
+					if ($find === false) {
1768
+						$pall[] = $value;
1769
+					}
1770
+				}
1771
+				$alldata = $pall;
1772 1772
 			foreach ($alldata as $number) {
1773 1773
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1774 1774
 			}
@@ -1832,44 +1832,44 @@  discard block
 block discarded – undo
1832 1832
 				}
1833 1833
     			
1834 1834
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1835
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1836
-		        	$alldata = array();
1837
-	    			foreach ($pall as $value) {
1838
-		        		$icao = $value['airport_departure_icao'];
1839
-    					$alldata[$icao] = $value;
1840
-	    			}
1841
-		        	foreach ($dall as $value) {
1842
-	    				$icao = $value['airport_departure_icao'];
1843
-        				if (isset($alldata[$icao])) {
1844
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1845
-        				} else $alldata[$icao] = $value;
1846
-				}
1847
-	    			$count = array();
1848
-    				foreach ($alldata as $key => $row) {
1849
-    					$count[$key] = $row['airport_departure_icao_count'];
1850
-    				}
1835
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1836
+					$alldata = array();
1837
+					foreach ($pall as $value) {
1838
+						$icao = $value['airport_departure_icao'];
1839
+						$alldata[$icao] = $value;
1840
+					}
1841
+					foreach ($dall as $value) {
1842
+						$icao = $value['airport_departure_icao'];
1843
+						if (isset($alldata[$icao])) {
1844
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1845
+						} else $alldata[$icao] = $value;
1846
+				}
1847
+					$count = array();
1848
+					foreach ($alldata as $key => $row) {
1849
+						$count[$key] = $row['airport_departure_icao_count'];
1850
+					}
1851 1851
 				array_multisort($count,SORT_DESC,$alldata);
1852 1852
 				foreach ($alldata as $number) {
1853
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name);
1853
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name);
1854 1854
 				}
1855 1855
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter);
1856
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);
1856
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);
1857 1857
 				$alldata = array();
1858
-    				foreach ($pall as $value) {
1859
-		        		$icao = $value['airport_arrival_icao'];
1860
-    					$alldata[$icao] = $value;
1861
-	    			}
1862
-		        	foreach ($dall as $value) {
1863
-	    				$icao = $value['airport_arrival_icao'];
1864
-        				if (isset($alldata[$icao])) {
1865
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1866
-		        		} else $alldata[$icao] = $value;
1867
-	    			}
1868
-        			$count = array();
1869
-        			foreach ($alldata as $key => $row) {
1870
-    					$count[$key] = $row['airport_arrival_icao_count'];
1871
-		        	}
1872
-        			array_multisort($count,SORT_DESC,$alldata);
1858
+					foreach ($pall as $value) {
1859
+						$icao = $value['airport_arrival_icao'];
1860
+						$alldata[$icao] = $value;
1861
+					}
1862
+					foreach ($dall as $value) {
1863
+						$icao = $value['airport_arrival_icao'];
1864
+						if (isset($alldata[$icao])) {
1865
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1866
+						} else $alldata[$icao] = $value;
1867
+					}
1868
+					$count = array();
1869
+					foreach ($alldata as $key => $row) {
1870
+						$count[$key] = $row['airport_arrival_icao_count'];
1871
+					}
1872
+					array_multisort($count,SORT_DESC,$alldata);
1873 1873
 				foreach ($alldata as $number) {
1874 1874
 					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name);
1875 1875
 				}
@@ -1898,45 +1898,45 @@  discard block
 block discarded – undo
1898 1898
 				}
1899 1899
 				echo '...Departure'."\n";
1900 1900
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1901
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1901
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1902 1902
 				foreach ($dall as $value) {
1903
-    					$icao = $value['departure_airport_icao'];
1904
-    					$ddate = $value['date'];
1905
-    					$find = false;
1906
-    					foreach ($pall as $pvalue) {
1907
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1908
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1909
-	    						$find = true;
1910
-    							break;
1911
-    						}
1912
-    					}
1913
-    					if ($find === false) {
1914
-    						$pall[] = $value;
1915
-	    				}
1916
-    				}
1917
-	    			$alldata = $pall;
1903
+						$icao = $value['departure_airport_icao'];
1904
+						$ddate = $value['date'];
1905
+						$find = false;
1906
+						foreach ($pall as $pvalue) {
1907
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1908
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1909
+								$find = true;
1910
+								break;
1911
+							}
1912
+						}
1913
+						if ($find === false) {
1914
+							$pall[] = $value;
1915
+						}
1916
+					}
1917
+					$alldata = $pall;
1918 1918
 				foreach ($alldata as $number) {
1919 1919
 					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
1920 1920
 				}
1921 1921
 				echo '...Arrival'."\n";
1922 1922
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1923
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1923
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1924 1924
 				foreach ($dall as $value) {
1925 1925
 					$icao = $value['arrival_airport_icao'];
1926 1926
 					$ddate = $value['date'];
1927
-    					$find = false;
1927
+						$find = false;
1928 1928
 					foreach ($pall as $pvalue) {
1929
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1930
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1931
-    							$find = true;
1932
-    							break;
1933
-	    					}
1934
-    					}
1935
-    					if ($find === false) {
1936
-    						$pall[] = $value;
1937
-	    				}
1938
-    				}
1939
-    				$alldata = $pall;
1929
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1930
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1931
+								$find = true;
1932
+								break;
1933
+							}
1934
+						}
1935
+						if ($find === false) {
1936
+							$pall[] = $value;
1937
+						}
1938
+					}
1939
+					$alldata = $pall;
1940 1940
 				foreach ($alldata as $number) {
1941 1941
 					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
1942 1942
 				}
Please login to merge, or discard this patch.