@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct($dbc = null) { |
14 | 14 | global $globalFilterName; |
15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
15 | + if (isset($globalFilterName)) { |
|
16 | + $this->filter_name = $globalFilterName; |
|
17 | + } |
|
16 | 18 | $Connection = new Connection($dbc); |
17 | 19 | $this->db = $Connection->db(); |
18 | 20 | } |
@@ -77,7 +79,9 @@ discard block |
||
77 | 79 | } |
78 | 80 | } |
79 | 81 | public function getAllAirlineNames($filter_name = '') { |
80 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
82 | + if ($filter_name == '') { |
|
83 | + $filter_name = $this->filter_name; |
|
84 | + } |
|
81 | 85 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
82 | 86 | try { |
83 | 87 | $sth = $this->db->prepare($query); |
@@ -89,7 +93,9 @@ discard block |
||
89 | 93 | return $all; |
90 | 94 | } |
91 | 95 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
92 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
96 | + if ($filter_name == '') { |
|
97 | + $filter_name = $this->filter_name; |
|
98 | + } |
|
93 | 99 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
94 | 100 | try { |
95 | 101 | $sth = $this->db->prepare($query); |
@@ -101,7 +107,9 @@ discard block |
||
101 | 107 | return $all; |
102 | 108 | } |
103 | 109 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
104 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
110 | + if ($filter_name == '') { |
|
111 | + $filter_name = $this->filter_name; |
|
112 | + } |
|
105 | 113 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
106 | 114 | try { |
107 | 115 | $sth = $this->db->prepare($query); |
@@ -113,7 +121,9 @@ discard block |
||
113 | 121 | return $all; |
114 | 122 | } |
115 | 123 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
116 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
124 | + if ($filter_name == '') { |
|
125 | + $filter_name = $this->filter_name; |
|
126 | + } |
|
117 | 127 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
118 | 128 | try { |
119 | 129 | $sth = $this->db->prepare($query); |
@@ -126,7 +136,9 @@ discard block |
||
126 | 136 | } |
127 | 137 | |
128 | 138 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
129 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
139 | + if ($filter_name == '') { |
|
140 | + $filter_name = $this->filter_name; |
|
141 | + } |
|
130 | 142 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
131 | 143 | try { |
132 | 144 | $sth = $this->db->prepare($query); |
@@ -139,7 +151,9 @@ discard block |
||
139 | 151 | } |
140 | 152 | |
141 | 153 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
142 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
154 | + if ($filter_name == '') { |
|
155 | + $filter_name = $this->filter_name; |
|
156 | + } |
|
143 | 157 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
144 | 158 | try { |
145 | 159 | $sth = $this->db->prepare($query); |
@@ -154,10 +168,15 @@ discard block |
||
154 | 168 | |
155 | 169 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
156 | 170 | global $globalStatsFilters; |
157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
171 | + if ($filter_name == '') { |
|
172 | + $filter_name = $this->filter_name; |
|
173 | + } |
|
158 | 174 | if ($year == '' && $month == '') { |
159 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
160 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
175 | + if ($limit) { |
|
176 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
177 | + } else { |
|
178 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
179 | + } |
|
161 | 180 | try { |
162 | 181 | $sth = $this->db->prepare($query); |
163 | 182 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -165,7 +184,9 @@ discard block |
||
165 | 184 | echo "error : ".$e->getMessage(); |
166 | 185 | } |
167 | 186 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
168 | - } else $all = array(); |
|
187 | + } else { |
|
188 | + $all = array(); |
|
189 | + } |
|
169 | 190 | if (empty($all)) { |
170 | 191 | $filters = array('airlines' => array($stats_airline)); |
171 | 192 | if ($filter_name != '') { |
@@ -178,10 +199,15 @@ discard block |
||
178 | 199 | } |
179 | 200 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
180 | 201 | global $globalStatsFilters; |
181 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
202 | + if ($filter_name == '') { |
|
203 | + $filter_name = $this->filter_name; |
|
204 | + } |
|
182 | 205 | if ($year == '' && $month == '') { |
183 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
184 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
206 | + if ($limit) { |
|
207 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
208 | + } else { |
|
209 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
210 | + } |
|
185 | 211 | try { |
186 | 212 | $sth = $this->db->prepare($query); |
187 | 213 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -189,7 +215,9 @@ discard block |
||
189 | 215 | echo "error : ".$e->getMessage(); |
190 | 216 | } |
191 | 217 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
192 | - } else $all = array(); |
|
218 | + } else { |
|
219 | + $all = array(); |
|
220 | + } |
|
193 | 221 | if (empty($all)) { |
194 | 222 | $Spotter = new Spotter($this->db); |
195 | 223 | $filters = array(); |
@@ -202,10 +230,15 @@ discard block |
||
202 | 230 | } |
203 | 231 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
204 | 232 | global $globalStatsFilters; |
205 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
233 | + if ($filter_name == '') { |
|
234 | + $filter_name = $this->filter_name; |
|
235 | + } |
|
206 | 236 | if ($year == '' && $month == '') { |
207 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
208 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
237 | + if ($limit) { |
|
238 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
239 | + } else { |
|
240 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
241 | + } |
|
209 | 242 | try { |
210 | 243 | $sth = $this->db->prepare($query); |
211 | 244 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -213,7 +246,9 @@ discard block |
||
213 | 246 | echo "error : ".$e->getMessage(); |
214 | 247 | } |
215 | 248 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
216 | - } else $all = array(); |
|
249 | + } else { |
|
250 | + $all = array(); |
|
251 | + } |
|
217 | 252 | if (empty($all)) { |
218 | 253 | $filters = array('airlines' => array($stats_airline)); |
219 | 254 | if ($filter_name != '') { |
@@ -227,10 +262,15 @@ discard block |
||
227 | 262 | |
228 | 263 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
229 | 264 | global $globalStatsFilters; |
230 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
265 | + if ($filter_name == '') { |
|
266 | + $filter_name = $this->filter_name; |
|
267 | + } |
|
231 | 268 | if ($year == '' && $month == '') { |
232 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
233 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
269 | + if ($limit) { |
|
270 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
271 | + } else { |
|
272 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
273 | + } |
|
234 | 274 | try { |
235 | 275 | $sth = $this->db->prepare($query); |
236 | 276 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -238,7 +278,9 @@ discard block |
||
238 | 278 | echo "error : ".$e->getMessage(); |
239 | 279 | } |
240 | 280 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
241 | - } else $all = array(); |
|
281 | + } else { |
|
282 | + $all = array(); |
|
283 | + } |
|
242 | 284 | if (empty($all)) { |
243 | 285 | $filters = array('airlines' => array($stats_airline)); |
244 | 286 | if ($filter_name != '') { |
@@ -251,9 +293,14 @@ discard block |
||
251 | 293 | } |
252 | 294 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
253 | 295 | global $globalStatsFilters; |
254 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
255 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
256 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
296 | + if ($filter_name == '') { |
|
297 | + $filter_name = $this->filter_name; |
|
298 | + } |
|
299 | + if ($limit) { |
|
300 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
301 | + } else { |
|
302 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
303 | + } |
|
257 | 304 | try { |
258 | 305 | $sth = $this->db->prepare($query); |
259 | 306 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -274,17 +321,29 @@ discard block |
||
274 | 321 | |
275 | 322 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
276 | 323 | global $globalStatsFilters; |
277 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
324 | + if ($filter_name == '') { |
|
325 | + $filter_name = $this->filter_name; |
|
326 | + } |
|
278 | 327 | if ($year == '' && $month == '') { |
279 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
280 | - if ($globalIVAO) $forsource = 'ivao'; |
|
328 | + if ($globalVATSIM) { |
|
329 | + $forsource = 'vatsim'; |
|
330 | + } |
|
331 | + if ($globalIVAO) { |
|
332 | + $forsource = 'ivao'; |
|
333 | + } |
|
281 | 334 | if (isset($forsource)) { |
282 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
283 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
335 | + if ($limit) { |
|
336 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
337 | + } else { |
|
338 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
339 | + } |
|
284 | 340 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
285 | 341 | } else { |
286 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
287 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
342 | + if ($limit) { |
|
343 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
344 | + } else { |
|
345 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
346 | + } |
|
288 | 347 | $query_values = array(':filter_name' => $filter_name); |
289 | 348 | } |
290 | 349 | try { |
@@ -294,7 +353,9 @@ discard block |
||
294 | 353 | echo "error : ".$e->getMessage(); |
295 | 354 | } |
296 | 355 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
297 | - } else $all = array(); |
|
356 | + } else { |
|
357 | + $all = array(); |
|
358 | + } |
|
298 | 359 | if (empty($all)) { |
299 | 360 | $Spotter = new Spotter($this->db); |
300 | 361 | $filters = array(); |
@@ -307,10 +368,15 @@ discard block |
||
307 | 368 | } |
308 | 369 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
309 | 370 | global $globalStatsFilters; |
310 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
371 | + if ($filter_name == '') { |
|
372 | + $filter_name = $this->filter_name; |
|
373 | + } |
|
311 | 374 | if ($year == '' && $month == '') { |
312 | - 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"; |
|
313 | - 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"; |
|
375 | + if ($limit) { |
|
376 | + $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"; |
|
377 | + } else { |
|
378 | + $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"; |
|
379 | + } |
|
314 | 380 | try { |
315 | 381 | $sth = $this->db->prepare($query); |
316 | 382 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -318,7 +384,9 @@ discard block |
||
318 | 384 | echo "error : ".$e->getMessage(); |
319 | 385 | } |
320 | 386 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
321 | - } else $all = array(); |
|
387 | + } else { |
|
388 | + $all = array(); |
|
389 | + } |
|
322 | 390 | if (empty($all)) { |
323 | 391 | $filters = array('airlines' => array($stats_airline)); |
324 | 392 | if ($filter_name != '') { |
@@ -331,10 +399,15 @@ discard block |
||
331 | 399 | } |
332 | 400 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
333 | 401 | global $globalStatsFilters; |
334 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
402 | + if ($filter_name == '') { |
|
403 | + $filter_name = $this->filter_name; |
|
404 | + } |
|
335 | 405 | if ($year == '' && $month == '') { |
336 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
337 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
406 | + if ($limit) { |
|
407 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
408 | + } else { |
|
409 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
410 | + } |
|
338 | 411 | try { |
339 | 412 | $sth = $this->db->prepare($query); |
340 | 413 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -342,7 +415,9 @@ discard block |
||
342 | 415 | echo "error : ".$e->getMessage(); |
343 | 416 | } |
344 | 417 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
345 | - } else $all = array(); |
|
418 | + } else { |
|
419 | + $all = array(); |
|
420 | + } |
|
346 | 421 | if (empty($all)) { |
347 | 422 | $filters = array('airlines' => array($stats_airline)); |
348 | 423 | if ($filter_name != '') { |
@@ -355,11 +430,16 @@ discard block |
||
355 | 430 | } |
356 | 431 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
357 | 432 | $Connection = new Connection(); |
358 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
433 | + if ($filter_name == '') { |
|
434 | + $filter_name = $this->filter_name; |
|
435 | + } |
|
359 | 436 | if ($Connection->tableExists('countries')) { |
360 | 437 | if ($year == '' && $month == '') { |
361 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
362 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
438 | + if ($limit) { |
|
439 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
440 | + } else { |
|
441 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
442 | + } |
|
363 | 443 | try { |
364 | 444 | $sth = $this->db->prepare($query); |
365 | 445 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -374,17 +454,24 @@ discard block |
||
374 | 454 | } |
375 | 455 | */ |
376 | 456 | return $all; |
377 | - } else return array(); |
|
457 | + } else { |
|
458 | + return array(); |
|
459 | + } |
|
378 | 460 | } else { |
379 | 461 | return array(); |
380 | 462 | } |
381 | 463 | } |
382 | 464 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
383 | 465 | global $globalStatsFilters; |
384 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
466 | + if ($filter_name == '') { |
|
467 | + $filter_name = $this->filter_name; |
|
468 | + } |
|
385 | 469 | if ($year == '' && $month == '') { |
386 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
387 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
470 | + if ($limit) { |
|
471 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
472 | + } else { |
|
473 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
474 | + } |
|
388 | 475 | try { |
389 | 476 | $sth = $this->db->prepare($query); |
390 | 477 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -392,7 +479,9 @@ discard block |
||
392 | 479 | echo "error : ".$e->getMessage(); |
393 | 480 | } |
394 | 481 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
395 | - } else $all = array(); |
|
482 | + } else { |
|
483 | + $all = array(); |
|
484 | + } |
|
396 | 485 | if (empty($all)) { |
397 | 486 | $filters = array('airlines' => array($stats_airline)); |
398 | 487 | if ($filter_name != '') { |
@@ -406,10 +495,15 @@ discard block |
||
406 | 495 | |
407 | 496 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
408 | 497 | global $globalStatsFilters; |
409 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
498 | + if ($filter_name == '') { |
|
499 | + $filter_name = $this->filter_name; |
|
500 | + } |
|
410 | 501 | if ($year == '' && $month == '') { |
411 | - 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"; |
|
412 | - 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"; |
|
502 | + if ($limit) { |
|
503 | + $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"; |
|
504 | + } else { |
|
505 | + $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"; |
|
506 | + } |
|
413 | 507 | try { |
414 | 508 | $sth = $this->db->prepare($query); |
415 | 509 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -417,7 +511,9 @@ discard block |
||
417 | 511 | echo "error : ".$e->getMessage(); |
418 | 512 | } |
419 | 513 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
420 | - } else $all = array(); |
|
514 | + } else { |
|
515 | + $all = array(); |
|
516 | + } |
|
421 | 517 | if (empty($all)) { |
422 | 518 | $filters = array('airlines' => array($stats_airline)); |
423 | 519 | if ($filter_name != '') { |
@@ -430,10 +526,15 @@ discard block |
||
430 | 526 | } |
431 | 527 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
432 | 528 | global $globalStatsFilters; |
433 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
529 | + if ($filter_name == '') { |
|
530 | + $filter_name = $this->filter_name; |
|
531 | + } |
|
434 | 532 | if ($year == '' && $month == '') { |
435 | - 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"; |
|
436 | - 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"; |
|
533 | + if ($limit) { |
|
534 | + $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"; |
|
535 | + } else { |
|
536 | + $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"; |
|
537 | + } |
|
437 | 538 | try { |
438 | 539 | $sth = $this->db->prepare($query); |
439 | 540 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -441,7 +542,9 @@ discard block |
||
441 | 542 | echo "error : ".$e->getMessage(); |
442 | 543 | } |
443 | 544 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
444 | - } else $all = array(); |
|
545 | + } else { |
|
546 | + $all = array(); |
|
547 | + } |
|
445 | 548 | if (empty($all)) { |
446 | 549 | $filters = array('airlines' => array($stats_airline)); |
447 | 550 | if ($filter_name != '') { |
@@ -460,7 +563,9 @@ discard block |
||
460 | 563 | $icao = $value['airport_departure_icao']; |
461 | 564 | if (isset($all[$icao])) { |
462 | 565 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
463 | - } else $all[$icao] = $value; |
|
566 | + } else { |
|
567 | + $all[$icao] = $value; |
|
568 | + } |
|
464 | 569 | } |
465 | 570 | $count = array(); |
466 | 571 | foreach ($all as $key => $row) { |
@@ -472,10 +577,15 @@ discard block |
||
472 | 577 | } |
473 | 578 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
474 | 579 | global $globalStatsFilters; |
475 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
580 | + if ($filter_name == '') { |
|
581 | + $filter_name = $this->filter_name; |
|
582 | + } |
|
476 | 583 | if ($year == '' && $month == '') { |
477 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
478 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
584 | + if ($limit) { |
|
585 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
586 | + } else { |
|
587 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
588 | + } |
|
479 | 589 | try { |
480 | 590 | $sth = $this->db->prepare($query); |
481 | 591 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -483,7 +593,9 @@ discard block |
||
483 | 593 | echo "error : ".$e->getMessage(); |
484 | 594 | } |
485 | 595 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
486 | - } else $all = array(); |
|
596 | + } else { |
|
597 | + $all = array(); |
|
598 | + } |
|
487 | 599 | if (empty($all)) { |
488 | 600 | $filters = array('airlines' => array($stats_airline)); |
489 | 601 | if ($filter_name != '') { |
@@ -502,7 +614,9 @@ discard block |
||
502 | 614 | $icao = $value['airport_arrival_icao']; |
503 | 615 | if (isset($all[$icao])) { |
504 | 616 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
505 | - } else $all[$icao] = $value; |
|
617 | + } else { |
|
618 | + $all[$icao] = $value; |
|
619 | + } |
|
506 | 620 | } |
507 | 621 | $count = array(); |
508 | 622 | foreach ($all as $key => $row) { |
@@ -515,13 +629,21 @@ discard block |
||
515 | 629 | } |
516 | 630 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
517 | 631 | global $globalDBdriver, $globalStatsFilters; |
518 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
632 | + if ($filter_name == '') { |
|
633 | + $filter_name = $this->filter_name; |
|
634 | + } |
|
519 | 635 | if ($globalDBdriver == 'mysql') { |
520 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
521 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
636 | + if ($limit) { |
|
637 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
638 | + } else { |
|
639 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
640 | + } |
|
522 | 641 | } else { |
523 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
524 | - 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"; |
|
642 | + if ($limit) { |
|
643 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
644 | + } else { |
|
645 | + $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"; |
|
646 | + } |
|
525 | 647 | } |
526 | 648 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
527 | 649 | try { |
@@ -545,7 +667,9 @@ discard block |
||
545 | 667 | |
546 | 668 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
547 | 669 | global $globalStatsFilters; |
548 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
670 | + if ($filter_name == '') { |
|
671 | + $filter_name = $this->filter_name; |
|
672 | + } |
|
549 | 673 | $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"; |
550 | 674 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
551 | 675 | try { |
@@ -567,7 +691,9 @@ discard block |
||
567 | 691 | } |
568 | 692 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
569 | 693 | global $globalDBdriver, $globalStatsFilters; |
570 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
694 | + if ($filter_name == '') { |
|
695 | + $filter_name = $this->filter_name; |
|
696 | + } |
|
571 | 697 | if ($globalDBdriver == 'mysql') { |
572 | 698 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
573 | 699 | } else { |
@@ -593,7 +719,9 @@ discard block |
||
593 | 719 | } |
594 | 720 | public function countAllDates($stats_airline = '',$filter_name = '') { |
595 | 721 | global $globalStatsFilters; |
596 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
722 | + if ($filter_name == '') { |
|
723 | + $filter_name = $this->filter_name; |
|
724 | + } |
|
597 | 725 | $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"; |
598 | 726 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
599 | 727 | try { |
@@ -615,7 +743,9 @@ discard block |
||
615 | 743 | } |
616 | 744 | public function countAllDatesByAirlines($filter_name = '') { |
617 | 745 | global $globalStatsFilters; |
618 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
746 | + if ($filter_name == '') { |
|
747 | + $filter_name = $this->filter_name; |
|
748 | + } |
|
619 | 749 | $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"; |
620 | 750 | $query_data = array('filter_name' => $filter_name); |
621 | 751 | try { |
@@ -637,7 +767,9 @@ discard block |
||
637 | 767 | } |
638 | 768 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
639 | 769 | global $globalStatsFilters; |
640 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
770 | + if ($filter_name == '') { |
|
771 | + $filter_name = $this->filter_name; |
|
772 | + } |
|
641 | 773 | $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"; |
642 | 774 | try { |
643 | 775 | $sth = $this->db->prepare($query); |
@@ -660,7 +792,9 @@ discard block |
||
660 | 792 | } |
661 | 793 | public function countAllMilitaryMonths($filter_name = '') { |
662 | 794 | global $globalStatsFilters; |
663 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
795 | + if ($filter_name == '') { |
|
796 | + $filter_name = $this->filter_name; |
|
797 | + } |
|
664 | 798 | $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"; |
665 | 799 | try { |
666 | 800 | $sth = $this->db->prepare($query); |
@@ -681,9 +815,14 @@ discard block |
||
681 | 815 | } |
682 | 816 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
683 | 817 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
684 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
685 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
686 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
818 | + if ($filter_name == '') { |
|
819 | + $filter_name = $this->filter_name; |
|
820 | + } |
|
821 | + if ($limit) { |
|
822 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
823 | + } else { |
|
824 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
825 | + } |
|
687 | 826 | if ($orderby == 'hour') { |
688 | 827 | /* |
689 | 828 | if ($globalDBdriver == 'mysql') { |
@@ -692,7 +831,9 @@ discard block |
||
692 | 831 | */ |
693 | 832 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
694 | 833 | } |
695 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
834 | + if ($orderby == 'count') { |
|
835 | + $query .= " ORDER BY hour_count DESC"; |
|
836 | + } |
|
696 | 837 | try { |
697 | 838 | $sth = $this->db->prepare($query); |
698 | 839 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -713,8 +854,12 @@ discard block |
||
713 | 854 | |
714 | 855 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
715 | 856 | global $globalStatsFilters; |
716 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
717 | - if ($year == '') $year = date('Y'); |
|
857 | + if ($filter_name == '') { |
|
858 | + $filter_name = $this->filter_name; |
|
859 | + } |
|
860 | + if ($year == '') { |
|
861 | + $year = date('Y'); |
|
862 | + } |
|
718 | 863 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
719 | 864 | if (empty($all)) { |
720 | 865 | $filters = array('airlines' => array($stats_airline)); |
@@ -728,8 +873,12 @@ discard block |
||
728 | 873 | } |
729 | 874 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
730 | 875 | global $globalStatsFilters; |
731 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
732 | - if ($year == '') $year = date('Y'); |
|
876 | + if ($filter_name == '') { |
|
877 | + $filter_name = $this->filter_name; |
|
878 | + } |
|
879 | + if ($year == '') { |
|
880 | + $year = date('Y'); |
|
881 | + } |
|
733 | 882 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
734 | 883 | if (empty($all)) { |
735 | 884 | $filters = array(); |
@@ -743,8 +892,12 @@ discard block |
||
743 | 892 | } |
744 | 893 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
745 | 894 | global $globalStatsFilters; |
746 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
747 | - if ($year == '') $year = date('Y'); |
|
895 | + if ($filter_name == '') { |
|
896 | + $filter_name = $this->filter_name; |
|
897 | + } |
|
898 | + if ($year == '') { |
|
899 | + $year = date('Y'); |
|
900 | + } |
|
748 | 901 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
749 | 902 | if (empty($all)) { |
750 | 903 | $filters = array('airlines' => array($stats_airline)); |
@@ -758,7 +911,9 @@ discard block |
||
758 | 911 | } |
759 | 912 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
760 | 913 | global $globalStatsFilters; |
761 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
914 | + if ($filter_name == '') { |
|
915 | + $filter_name = $this->filter_name; |
|
916 | + } |
|
762 | 917 | if ($year == '' && $month == '') { |
763 | 918 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
764 | 919 | try { |
@@ -769,7 +924,9 @@ discard block |
||
769 | 924 | } |
770 | 925 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
771 | 926 | $all = $result[0]['nb']; |
772 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
927 | + } else { |
|
928 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
929 | + } |
|
773 | 930 | if (empty($all)) { |
774 | 931 | $filters = array('airlines' => array($stats_airline)); |
775 | 932 | if ($filter_name != '') { |
@@ -782,7 +939,9 @@ discard block |
||
782 | 939 | } |
783 | 940 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
784 | 941 | global $globalStatsFilters; |
785 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
942 | + if ($filter_name == '') { |
|
943 | + $filter_name = $this->filter_name; |
|
944 | + } |
|
786 | 945 | if ($year == '' && $month == '') { |
787 | 946 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
788 | 947 | try { |
@@ -793,7 +952,9 @@ discard block |
||
793 | 952 | } |
794 | 953 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
795 | 954 | $all = $result[0]['nb_airline']; |
796 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
955 | + } else { |
|
956 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
957 | + } |
|
797 | 958 | if (empty($all)) { |
798 | 959 | $filters = array(); |
799 | 960 | if ($filter_name != '') { |
@@ -806,7 +967,9 @@ discard block |
||
806 | 967 | } |
807 | 968 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
808 | 969 | global $globalStatsFilters; |
809 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
970 | + if ($filter_name == '') { |
|
971 | + $filter_name = $this->filter_name; |
|
972 | + } |
|
810 | 973 | if ($year == '' && $month == '') { |
811 | 974 | $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
812 | 975 | $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
@@ -833,7 +996,9 @@ discard block |
||
833 | 996 | } |
834 | 997 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
835 | 998 | global $globalStatsFilters; |
836 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
999 | + if ($filter_name == '') { |
|
1000 | + $filter_name = $this->filter_name; |
|
1001 | + } |
|
837 | 1002 | //if ($year == '') $year = date('Y'); |
838 | 1003 | if ($year == '' && $month == '') { |
839 | 1004 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -861,7 +1026,9 @@ discard block |
||
861 | 1026 | } |
862 | 1027 | |
863 | 1028 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
864 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1029 | + if ($filter_name == '') { |
|
1030 | + $filter_name = $this->filter_name; |
|
1031 | + } |
|
865 | 1032 | $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"; |
866 | 1033 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
867 | 1034 | try { |
@@ -874,7 +1041,9 @@ discard block |
||
874 | 1041 | return $all; |
875 | 1042 | } |
876 | 1043 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
877 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1044 | + if ($filter_name == '') { |
|
1045 | + $filter_name = $this->filter_name; |
|
1046 | + } |
|
878 | 1047 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
879 | 1048 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
880 | 1049 | try { |
@@ -887,7 +1056,9 @@ discard block |
||
887 | 1056 | return $all; |
888 | 1057 | } |
889 | 1058 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
890 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1059 | + if ($filter_name == '') { |
|
1060 | + $filter_name = $this->filter_name; |
|
1061 | + } |
|
891 | 1062 | global $globalArchiveMonths, $globalDBdriver; |
892 | 1063 | if ($globalDBdriver == 'mysql') { |
893 | 1064 | if ($month == '') { |
@@ -917,7 +1088,9 @@ discard block |
||
917 | 1088 | } |
918 | 1089 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
919 | 1090 | global $globalArchiveMonths, $globalDBdriver; |
920 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1091 | + if ($filter_name == '') { |
|
1092 | + $filter_name = $this->filter_name; |
|
1093 | + } |
|
921 | 1094 | if ($globalDBdriver == 'mysql') { |
922 | 1095 | $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"; |
923 | 1096 | } else { |
@@ -935,7 +1108,9 @@ discard block |
||
935 | 1108 | } |
936 | 1109 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
937 | 1110 | global $globalArchiveMonths, $globalDBdriver; |
938 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1111 | + if ($filter_name == '') { |
|
1112 | + $filter_name = $this->filter_name; |
|
1113 | + } |
|
939 | 1114 | if ($globalDBdriver == 'mysql') { |
940 | 1115 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
941 | 1116 | } else { |
@@ -952,7 +1127,9 @@ discard block |
||
952 | 1127 | } |
953 | 1128 | public function getStatsAirlineTotal($filter_name = '') { |
954 | 1129 | global $globalArchiveMonths, $globalDBdriver; |
955 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1130 | + if ($filter_name == '') { |
|
1131 | + $filter_name = $this->filter_name; |
|
1132 | + } |
|
956 | 1133 | if ($globalDBdriver == 'mysql') { |
957 | 1134 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
958 | 1135 | } else { |
@@ -969,7 +1146,9 @@ discard block |
||
969 | 1146 | } |
970 | 1147 | public function getStatsOwnerTotal($filter_name = '') { |
971 | 1148 | global $globalArchiveMonths, $globalDBdriver; |
972 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1149 | + if ($filter_name == '') { |
|
1150 | + $filter_name = $this->filter_name; |
|
1151 | + } |
|
973 | 1152 | if ($globalDBdriver == 'mysql') { |
974 | 1153 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
975 | 1154 | } else { |
@@ -986,7 +1165,9 @@ discard block |
||
986 | 1165 | } |
987 | 1166 | public function getStatsOwner($owner_name,$filter_name = '') { |
988 | 1167 | global $globalArchiveMonths, $globalDBdriver; |
989 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1168 | + if ($filter_name == '') { |
|
1169 | + $filter_name = $this->filter_name; |
|
1170 | + } |
|
990 | 1171 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
991 | 1172 | try { |
992 | 1173 | $sth = $this->db->prepare($query); |
@@ -995,12 +1176,17 @@ discard block |
||
995 | 1176 | echo "error : ".$e->getMessage(); |
996 | 1177 | } |
997 | 1178 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
998 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
999 | - else return 0; |
|
1179 | + if (isset($all[0]['cnt'])) { |
|
1180 | + return $all[0]['cnt']; |
|
1181 | + } else { |
|
1182 | + return 0; |
|
1183 | + } |
|
1000 | 1184 | } |
1001 | 1185 | public function getStatsPilotTotal($filter_name = '') { |
1002 | 1186 | global $globalArchiveMonths, $globalDBdriver; |
1003 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1187 | + if ($filter_name == '') { |
|
1188 | + $filter_name = $this->filter_name; |
|
1189 | + } |
|
1004 | 1190 | if ($globalDBdriver == 'mysql') { |
1005 | 1191 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
1006 | 1192 | } else { |
@@ -1017,7 +1203,9 @@ discard block |
||
1017 | 1203 | } |
1018 | 1204 | public function getStatsPilot($pilot,$filter_name = '') { |
1019 | 1205 | global $globalArchiveMonths, $globalDBdriver; |
1020 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1206 | + if ($filter_name == '') { |
|
1207 | + $filter_name = $this->filter_name; |
|
1208 | + } |
|
1021 | 1209 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1022 | 1210 | try { |
1023 | 1211 | $sth = $this->db->prepare($query); |
@@ -1026,13 +1214,18 @@ discard block |
||
1026 | 1214 | echo "error : ".$e->getMessage(); |
1027 | 1215 | } |
1028 | 1216 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1029 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1030 | - else return 0; |
|
1217 | + if (isset($all[0]['cnt'])) { |
|
1218 | + return $all[0]['cnt']; |
|
1219 | + } else { |
|
1220 | + return 0; |
|
1221 | + } |
|
1031 | 1222 | } |
1032 | 1223 | |
1033 | 1224 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1034 | 1225 | global $globalDBdriver; |
1035 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1226 | + if ($filter_name == '') { |
|
1227 | + $filter_name = $this->filter_name; |
|
1228 | + } |
|
1036 | 1229 | if ($globalDBdriver == 'mysql') { |
1037 | 1230 | $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"; |
1038 | 1231 | } else { |
@@ -1048,7 +1241,9 @@ discard block |
||
1048 | 1241 | } |
1049 | 1242 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1050 | 1243 | global $globalDBdriver; |
1051 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1244 | + if ($filter_name == '') { |
|
1245 | + $filter_name = $this->filter_name; |
|
1246 | + } |
|
1052 | 1247 | if ($globalDBdriver == 'mysql') { |
1053 | 1248 | $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"; |
1054 | 1249 | } else { |
@@ -1434,10 +1629,14 @@ discard block |
||
1434 | 1629 | $Connection = new Connection(); |
1435 | 1630 | date_default_timezone_set('UTC'); |
1436 | 1631 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
1437 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1632 | + if ($globalDebug) { |
|
1633 | + echo 'Update stats !'."\n"; |
|
1634 | + } |
|
1438 | 1635 | if (isset($last_update[0]['value'])) { |
1439 | 1636 | $last_update_day = $last_update[0]['value']; |
1440 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1637 | + } else { |
|
1638 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1639 | + } |
|
1441 | 1640 | $reset = false; |
1442 | 1641 | if ($globalStatsResetYear) { |
1443 | 1642 | $reset = true; |
@@ -1445,42 +1644,60 @@ discard block |
||
1445 | 1644 | } |
1446 | 1645 | $Spotter = new Spotter($this->db); |
1447 | 1646 | |
1448 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1647 | + if ($globalDebug) { |
|
1648 | + echo 'Count all aircraft types...'."\n"; |
|
1649 | + } |
|
1449 | 1650 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1450 | 1651 | foreach ($alldata as $number) { |
1451 | 1652 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
1452 | 1653 | } |
1453 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1654 | + if ($globalDebug) { |
|
1655 | + echo 'Count all airlines...'."\n"; |
|
1656 | + } |
|
1454 | 1657 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1455 | 1658 | foreach ($alldata as $number) { |
1456 | 1659 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
1457 | 1660 | } |
1458 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1661 | + if ($globalDebug) { |
|
1662 | + echo 'Count all registrations...'."\n"; |
|
1663 | + } |
|
1459 | 1664 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1460 | 1665 | foreach ($alldata as $number) { |
1461 | 1666 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
1462 | 1667 | } |
1463 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1668 | + if ($globalDebug) { |
|
1669 | + echo 'Count all callsigns...'."\n"; |
|
1670 | + } |
|
1464 | 1671 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1465 | 1672 | foreach ($alldata as $number) { |
1466 | 1673 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1467 | 1674 | } |
1468 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1675 | + if ($globalDebug) { |
|
1676 | + echo 'Count all owners...'."\n"; |
|
1677 | + } |
|
1469 | 1678 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1470 | 1679 | foreach ($alldata as $number) { |
1471 | 1680 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
1472 | 1681 | } |
1473 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1682 | + if ($globalDebug) { |
|
1683 | + echo 'Count all pilots...'."\n"; |
|
1684 | + } |
|
1474 | 1685 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1475 | 1686 | foreach ($alldata as $number) { |
1476 | 1687 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
1477 | 1688 | } |
1478 | 1689 | |
1479 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1690 | + if ($globalDebug) { |
|
1691 | + echo 'Count all departure airports...'."\n"; |
|
1692 | + } |
|
1480 | 1693 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1481 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1694 | + if ($globalDebug) { |
|
1695 | + echo 'Count all detected departure airports...'."\n"; |
|
1696 | + } |
|
1482 | 1697 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1483 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1698 | + if ($globalDebug) { |
|
1699 | + echo 'Order departure airports...'."\n"; |
|
1700 | + } |
|
1484 | 1701 | $alldata = array(); |
1485 | 1702 | |
1486 | 1703 | foreach ($pall as $value) { |
@@ -1491,7 +1708,9 @@ discard block |
||
1491 | 1708 | $icao = $value['airport_departure_icao']; |
1492 | 1709 | if (isset($alldata[$icao])) { |
1493 | 1710 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1494 | - } else $alldata[$icao] = $value; |
|
1711 | + } else { |
|
1712 | + $alldata[$icao] = $value; |
|
1713 | + } |
|
1495 | 1714 | } |
1496 | 1715 | $count = array(); |
1497 | 1716 | foreach ($alldata as $key => $row) { |
@@ -1501,11 +1720,17 @@ discard block |
||
1501 | 1720 | foreach ($alldata as $number) { |
1502 | 1721 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
1503 | 1722 | } |
1504 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1723 | + if ($globalDebug) { |
|
1724 | + echo 'Count all arrival airports...'."\n"; |
|
1725 | + } |
|
1505 | 1726 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1506 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1727 | + if ($globalDebug) { |
|
1728 | + echo 'Count all detected arrival airports...'."\n"; |
|
1729 | + } |
|
1507 | 1730 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1508 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1731 | + if ($globalDebug) { |
|
1732 | + echo 'Order arrival airports...'."\n"; |
|
1733 | + } |
|
1509 | 1734 | $alldata = array(); |
1510 | 1735 | foreach ($pall as $value) { |
1511 | 1736 | $icao = $value['airport_arrival_icao']; |
@@ -1515,7 +1740,9 @@ discard block |
||
1515 | 1740 | $icao = $value['airport_arrival_icao']; |
1516 | 1741 | if (isset($alldata[$icao])) { |
1517 | 1742 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1518 | - } else $alldata[$icao] = $value; |
|
1743 | + } else { |
|
1744 | + $alldata[$icao] = $value; |
|
1745 | + } |
|
1519 | 1746 | } |
1520 | 1747 | $count = array(); |
1521 | 1748 | foreach ($alldata as $key => $row) { |
@@ -1526,7 +1753,9 @@ discard block |
||
1526 | 1753 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
1527 | 1754 | } |
1528 | 1755 | if ($Connection->tableExists('countries')) { |
1529 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1756 | + if ($globalDebug) { |
|
1757 | + echo 'Count all flights by countries...'."\n"; |
|
1758 | + } |
|
1530 | 1759 | $SpotterArchive = new SpotterArchive(); |
1531 | 1760 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1532 | 1761 | foreach ($alldata as $number) { |
@@ -1538,46 +1767,66 @@ discard block |
||
1538 | 1767 | // Add by month using getstat if month finish... |
1539 | 1768 | |
1540 | 1769 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1541 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1770 | + if ($globalDebug) { |
|
1771 | + echo 'Count all flights by months...'."\n"; |
|
1772 | + } |
|
1542 | 1773 | $Spotter = new Spotter($this->db); |
1543 | 1774 | $alldata = $Spotter->countAllMonths(); |
1544 | 1775 | $lastyear = false; |
1545 | 1776 | foreach ($alldata as $number) { |
1546 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1777 | + if ($number['year_name'] != date('Y')) { |
|
1778 | + $lastyear = true; |
|
1779 | + } |
|
1547 | 1780 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1548 | 1781 | } |
1549 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1782 | + if ($globalDebug) { |
|
1783 | + echo 'Count all military flights by months...'."\n"; |
|
1784 | + } |
|
1550 | 1785 | $alldata = $Spotter->countAllMilitaryMonths(); |
1551 | 1786 | foreach ($alldata as $number) { |
1552 | 1787 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1553 | 1788 | } |
1554 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1789 | + if ($globalDebug) { |
|
1790 | + echo 'Count all owners by months...'."\n"; |
|
1791 | + } |
|
1555 | 1792 | $alldata = $Spotter->countAllMonthsOwners(); |
1556 | 1793 | foreach ($alldata as $number) { |
1557 | 1794 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1558 | 1795 | } |
1559 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1796 | + if ($globalDebug) { |
|
1797 | + echo 'Count all pilots by months...'."\n"; |
|
1798 | + } |
|
1560 | 1799 | $alldata = $Spotter->countAllMonthsPilots(); |
1561 | 1800 | foreach ($alldata as $number) { |
1562 | 1801 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1563 | 1802 | } |
1564 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1803 | + if ($globalDebug) { |
|
1804 | + echo 'Count all airlines by months...'."\n"; |
|
1805 | + } |
|
1565 | 1806 | $alldata = $Spotter->countAllMonthsAirlines(); |
1566 | 1807 | foreach ($alldata as $number) { |
1567 | 1808 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1568 | 1809 | } |
1569 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1810 | + if ($globalDebug) { |
|
1811 | + echo 'Count all aircrafts by months...'."\n"; |
|
1812 | + } |
|
1570 | 1813 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1571 | 1814 | foreach ($alldata as $number) { |
1572 | 1815 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1573 | 1816 | } |
1574 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1817 | + if ($globalDebug) { |
|
1818 | + echo 'Count all real arrivals by months...'."\n"; |
|
1819 | + } |
|
1575 | 1820 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1576 | 1821 | foreach ($alldata as $number) { |
1577 | 1822 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1578 | 1823 | } |
1579 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1580 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1824 | + if ($globalDebug) { |
|
1825 | + echo 'Airports data...'."\n"; |
|
1826 | + } |
|
1827 | + if ($globalDebug) { |
|
1828 | + echo '...Departure'."\n"; |
|
1829 | + } |
|
1581 | 1830 | $this->deleteStatAirport('daily'); |
1582 | 1831 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1583 | 1832 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1698,44 +1947,62 @@ discard block |
||
1698 | 1947 | // Count by airlines |
1699 | 1948 | echo '--- Stats by airlines ---'."\n"; |
1700 | 1949 | if ($Connection->tableExists('countries')) { |
1701 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
1950 | + if ($globalDebug) { |
|
1951 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
1952 | + } |
|
1702 | 1953 | $SpotterArchive = new SpotterArchive(); |
1703 | 1954 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
1704 | 1955 | foreach ($alldata as $number) { |
1705 | 1956 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
1706 | 1957 | } |
1707 | 1958 | } |
1708 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
1959 | + if ($globalDebug) { |
|
1960 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
1961 | + } |
|
1709 | 1962 | $Spotter = new Spotter($this->db); |
1710 | 1963 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1711 | 1964 | foreach ($alldata as $number) { |
1712 | 1965 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
1713 | 1966 | } |
1714 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1967 | + if ($globalDebug) { |
|
1968 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1969 | + } |
|
1715 | 1970 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1716 | 1971 | foreach ($alldata as $number) { |
1717 | 1972 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
1718 | 1973 | } |
1719 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
1974 | + if ($globalDebug) { |
|
1975 | + echo 'Count all callsigns by airlines...'."\n"; |
|
1976 | + } |
|
1720 | 1977 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1721 | 1978 | foreach ($alldata as $number) { |
1722 | 1979 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1723 | 1980 | } |
1724 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
1981 | + if ($globalDebug) { |
|
1982 | + echo 'Count all owners by airlines...'."\n"; |
|
1983 | + } |
|
1725 | 1984 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1726 | 1985 | foreach ($alldata as $number) { |
1727 | 1986 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
1728 | 1987 | } |
1729 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
1988 | + if ($globalDebug) { |
|
1989 | + echo 'Count all pilots by airlines...'."\n"; |
|
1990 | + } |
|
1730 | 1991 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1731 | 1992 | foreach ($alldata as $number) { |
1732 | 1993 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
1733 | 1994 | } |
1734 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
1995 | + if ($globalDebug) { |
|
1996 | + echo 'Count all departure airports by airlines...'."\n"; |
|
1997 | + } |
|
1735 | 1998 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1736 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
1999 | + if ($globalDebug) { |
|
2000 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
2001 | + } |
|
1737 | 2002 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1738 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
2003 | + if ($globalDebug) { |
|
2004 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
2005 | + } |
|
1739 | 2006 | //$alldata = array(); |
1740 | 2007 | foreach ($dall as $value) { |
1741 | 2008 | $icao = $value['airport_departure_icao']; |
@@ -1756,11 +2023,17 @@ discard block |
||
1756 | 2023 | foreach ($alldata as $number) { |
1757 | 2024 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
1758 | 2025 | } |
1759 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
2026 | + if ($globalDebug) { |
|
2027 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
2028 | + } |
|
1760 | 2029 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1761 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2030 | + if ($globalDebug) { |
|
2031 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2032 | + } |
|
1762 | 2033 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1763 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
2034 | + if ($globalDebug) { |
|
2035 | + echo 'Order arrival airports by airlines...'."\n"; |
|
2036 | + } |
|
1764 | 2037 | //$alldata = array(); |
1765 | 2038 | foreach ($dall as $value) { |
1766 | 2039 | $icao = $value['airport_arrival_icao']; |
@@ -1779,37 +2052,53 @@ discard block |
||
1779 | 2052 | } |
1780 | 2053 | $alldata = $pall; |
1781 | 2054 | foreach ($alldata as $number) { |
1782 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
2055 | + if ($number['airline_icao'] != '') { |
|
2056 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
2057 | + } |
|
2058 | + } |
|
2059 | + if ($globalDebug) { |
|
2060 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1783 | 2061 | } |
1784 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1785 | 2062 | $Spotter = new Spotter($this->db); |
1786 | 2063 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1787 | 2064 | $lastyear = false; |
1788 | 2065 | foreach ($alldata as $number) { |
1789 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2066 | + if ($number['year_name'] != date('Y')) { |
|
2067 | + $lastyear = true; |
|
2068 | + } |
|
1790 | 2069 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1791 | 2070 | } |
1792 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
2071 | + if ($globalDebug) { |
|
2072 | + echo 'Count all owners by months by airlines...'."\n"; |
|
2073 | + } |
|
1793 | 2074 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1794 | 2075 | foreach ($alldata as $number) { |
1795 | 2076 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1796 | 2077 | } |
1797 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
2078 | + if ($globalDebug) { |
|
2079 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
2080 | + } |
|
1798 | 2081 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1799 | 2082 | foreach ($alldata as $number) { |
1800 | 2083 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1801 | 2084 | } |
1802 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2085 | + if ($globalDebug) { |
|
2086 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2087 | + } |
|
1803 | 2088 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1804 | 2089 | foreach ($alldata as $number) { |
1805 | 2090 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1806 | 2091 | } |
1807 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2092 | + if ($globalDebug) { |
|
2093 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2094 | + } |
|
1808 | 2095 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1809 | 2096 | foreach ($alldata as $number) { |
1810 | 2097 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1811 | 2098 | } |
1812 | - if ($globalDebug) echo '...Departure'."\n"; |
|
2099 | + if ($globalDebug) { |
|
2100 | + echo '...Departure'."\n"; |
|
2101 | + } |
|
1813 | 2102 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1814 | 2103 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1815 | 2104 | foreach ($dall as $value) { |
@@ -1832,7 +2121,9 @@ discard block |
||
1832 | 2121 | foreach ($alldata as $number) { |
1833 | 2122 | $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']); |
1834 | 2123 | } |
1835 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
2124 | + if ($globalDebug) { |
|
2125 | + echo '...Arrival'."\n"; |
|
2126 | + } |
|
1836 | 2127 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1837 | 2128 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1838 | 2129 | foreach ($dall as $value) { |
@@ -1856,13 +2147,19 @@ discard block |
||
1856 | 2147 | $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']); |
1857 | 2148 | } |
1858 | 2149 | |
1859 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1860 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2150 | + if ($globalDebug) { |
|
2151 | + echo 'Flights data...'."\n"; |
|
2152 | + } |
|
2153 | + if ($globalDebug) { |
|
2154 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2155 | + } |
|
1861 | 2156 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1862 | 2157 | foreach ($alldata as $number) { |
1863 | 2158 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1864 | 2159 | } |
1865 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2160 | + if ($globalDebug) { |
|
2161 | + echo '-> countAllDates...'."\n"; |
|
2162 | + } |
|
1866 | 2163 | //$previousdata = $this->countAllDatesByAirlines(); |
1867 | 2164 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1868 | 2165 | $values = array(); |
@@ -1875,7 +2172,9 @@ discard block |
||
1875 | 2172 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1876 | 2173 | } |
1877 | 2174 | |
1878 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2175 | + if ($globalDebug) { |
|
2176 | + echo '-> countAllHours...'."\n"; |
|
2177 | + } |
|
1879 | 2178 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1880 | 2179 | foreach ($alldata as $number) { |
1881 | 2180 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
@@ -1883,7 +2182,9 @@ discard block |
||
1883 | 2182 | |
1884 | 2183 | |
1885 | 2184 | // Stats by filters |
1886 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2185 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2186 | + $globalStatsFilters = array(); |
|
2187 | + } |
|
1887 | 2188 | foreach ($globalStatsFilters as $name => $filter) { |
1888 | 2189 | //$filter_name = $filter['name']; |
1889 | 2190 | $filter_name = $name; |
@@ -1891,11 +2192,15 @@ discard block |
||
1891 | 2192 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
1892 | 2193 | if (isset($last_update[0]['value'])) { |
1893 | 2194 | $last_update_day = $last_update[0]['value']; |
1894 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2195 | + } else { |
|
2196 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2197 | + } |
|
1895 | 2198 | $reset = false; |
1896 | 2199 | |
1897 | 2200 | // Count by filter |
1898 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2201 | + if ($globalDebug) { |
|
2202 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2203 | + } |
|
1899 | 2204 | $Spotter = new Spotter($this->db); |
1900 | 2205 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
1901 | 2206 | foreach ($alldata as $number) { |
@@ -1932,7 +2237,9 @@ discard block |
||
1932 | 2237 | $icao = $value['airport_departure_icao']; |
1933 | 2238 | if (isset($alldata[$icao])) { |
1934 | 2239 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1935 | - } else $alldata[$icao] = $value; |
|
2240 | + } else { |
|
2241 | + $alldata[$icao] = $value; |
|
2242 | + } |
|
1936 | 2243 | } |
1937 | 2244 | $count = array(); |
1938 | 2245 | foreach ($alldata as $key => $row) { |
@@ -1953,7 +2260,9 @@ discard block |
||
1953 | 2260 | $icao = $value['airport_arrival_icao']; |
1954 | 2261 | if (isset($alldata[$icao])) { |
1955 | 2262 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1956 | - } else $alldata[$icao] = $value; |
|
2263 | + } else { |
|
2264 | + $alldata[$icao] = $value; |
|
2265 | + } |
|
1957 | 2266 | } |
1958 | 2267 | $count = array(); |
1959 | 2268 | foreach ($alldata as $key => $row) { |
@@ -1967,7 +2276,9 @@ discard block |
||
1967 | 2276 | $alldata = $Spotter->countAllMonths($filter); |
1968 | 2277 | $lastyear = false; |
1969 | 2278 | foreach ($alldata as $number) { |
1970 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2279 | + if ($number['year_name'] != date('Y')) { |
|
2280 | + $lastyear = true; |
|
2281 | + } |
|
1971 | 2282 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
1972 | 2283 | } |
1973 | 2284 | $alldata = $Spotter->countAllMonthsOwners($filter); |