@@ -15,10 +15,14 @@ discard block |
||
15 | 15 | |
16 | 16 | public function __construct($dbc = null) { |
17 | 17 | global $globalFilterName; |
18 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
18 | + if (isset($globalFilterName)) { |
|
19 | + $this->filter_name = $globalFilterName; |
|
20 | + } |
|
19 | 21 | $Connection = new Connection($dbc); |
20 | 22 | $this->db = $Connection->db(); |
21 | - if ($this->db === null) die('Error: No DB connection. (Stats)'); |
|
23 | + if ($this->db === null) { |
|
24 | + die('Error: No DB connection. (Stats)'); |
|
25 | + } |
|
22 | 26 | } |
23 | 27 | |
24 | 28 | public function addLastStatsUpdate($type,$stats_date) { |
@@ -86,7 +90,9 @@ discard block |
||
86 | 90 | |
87 | 91 | public function getAllAirlineNames($filter_name = '') { |
88 | 92 | global $globalStatsFilters; |
89 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
93 | + if ($filter_name == '') { |
|
94 | + $filter_name = $this->filter_name; |
|
95 | + } |
|
90 | 96 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
91 | 97 | try { |
92 | 98 | $sth = $this->db->prepare($query); |
@@ -106,7 +112,9 @@ discard block |
||
106 | 112 | return $all; |
107 | 113 | } |
108 | 114 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
109 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
115 | + if ($filter_name == '') { |
|
116 | + $filter_name = $this->filter_name; |
|
117 | + } |
|
110 | 118 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
111 | 119 | try { |
112 | 120 | $sth = $this->db->prepare($query); |
@@ -118,7 +126,9 @@ discard block |
||
118 | 126 | return $all; |
119 | 127 | } |
120 | 128 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
121 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
129 | + if ($filter_name == '') { |
|
130 | + $filter_name = $this->filter_name; |
|
131 | + } |
|
122 | 132 | $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"; |
123 | 133 | try { |
124 | 134 | $sth = $this->db->prepare($query); |
@@ -130,7 +140,9 @@ discard block |
||
130 | 140 | return $all; |
131 | 141 | } |
132 | 142 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
133 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
143 | + if ($filter_name == '') { |
|
144 | + $filter_name = $this->filter_name; |
|
145 | + } |
|
134 | 146 | $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"; |
135 | 147 | try { |
136 | 148 | $sth = $this->db->prepare($query); |
@@ -143,7 +155,9 @@ discard block |
||
143 | 155 | } |
144 | 156 | |
145 | 157 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
146 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
158 | + if ($filter_name == '') { |
|
159 | + $filter_name = $this->filter_name; |
|
160 | + } |
|
147 | 161 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
148 | 162 | try { |
149 | 163 | $sth = $this->db->prepare($query); |
@@ -156,7 +170,9 @@ discard block |
||
156 | 170 | } |
157 | 171 | |
158 | 172 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
159 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
173 | + if ($filter_name == '') { |
|
174 | + $filter_name = $this->filter_name; |
|
175 | + } |
|
160 | 176 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
161 | 177 | try { |
162 | 178 | $sth = $this->db->prepare($query); |
@@ -171,7 +187,9 @@ discard block |
||
171 | 187 | |
172 | 188 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
173 | 189 | global $globalStatsFilters; |
174 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
190 | + if ($filter_name == '') { |
|
191 | + $filter_name = $this->filter_name; |
|
192 | + } |
|
175 | 193 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
176 | 194 | $Spotter = new Spotter($this->db); |
177 | 195 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -180,8 +198,11 @@ discard block |
||
180 | 198 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
181 | 199 | } |
182 | 200 | if ($year == '' && $month == '') { |
183 | - 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 aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
184 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
201 | + if ($limit) { |
|
202 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
203 | + } else { |
|
204 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
205 | + } |
|
185 | 206 | try { |
186 | 207 | $sth = $this->db->prepare($query); |
187 | 208 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -189,11 +210,16 @@ discard block |
||
189 | 210 | echo "error : ".$e->getMessage(); |
190 | 211 | } |
191 | 212 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
192 | - } else $all = array(); |
|
213 | + } else { |
|
214 | + $all = array(); |
|
215 | + } |
|
193 | 216 | } else { |
194 | 217 | if ($year == '' && $month == '') { |
195 | - 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 aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
196 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
218 | + if ($limit) { |
|
219 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
220 | + } else { |
|
221 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
222 | + } |
|
197 | 223 | try { |
198 | 224 | $sth = $this->db->prepare($query); |
199 | 225 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -201,7 +227,9 @@ discard block |
||
201 | 227 | echo "error : ".$e->getMessage(); |
202 | 228 | } |
203 | 229 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
204 | - } else $all = array(); |
|
230 | + } else { |
|
231 | + $all = array(); |
|
232 | + } |
|
205 | 233 | } |
206 | 234 | if (empty($all)) { |
207 | 235 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -220,10 +248,15 @@ discard block |
||
220 | 248 | } |
221 | 249 | public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') { |
222 | 250 | global $globalStatsFilters; |
223 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
251 | + if ($filter_name == '') { |
|
252 | + $filter_name = $this->filter_name; |
|
253 | + } |
|
224 | 254 | if ($year == '' && $month == '') { |
225 | - if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0"; |
|
226 | - else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
255 | + if ($limit) { |
|
256 | + $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0"; |
|
257 | + } else { |
|
258 | + $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
259 | + } |
|
227 | 260 | try { |
228 | 261 | $sth = $this->db->prepare($query); |
229 | 262 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -231,7 +264,9 @@ discard block |
||
231 | 264 | echo "error : ".$e->getMessage(); |
232 | 265 | } |
233 | 266 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
234 | - } else $all = array(); |
|
267 | + } else { |
|
268 | + $all = array(); |
|
269 | + } |
|
235 | 270 | if (empty($all)) { |
236 | 271 | $filters = array('year' => $year,'month' => $month); |
237 | 272 | if ($filter_name != '') { |
@@ -245,10 +280,15 @@ discard block |
||
245 | 280 | } |
246 | 281 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
247 | 282 | global $globalStatsFilters; |
248 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
283 | + if ($filter_name == '') { |
|
284 | + $filter_name = $this->filter_name; |
|
285 | + } |
|
249 | 286 | if ($year == '' && $month == '') { |
250 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
251 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
287 | + if ($limit) { |
|
288 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
289 | + } else { |
|
290 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
291 | + } |
|
252 | 292 | try { |
253 | 293 | $sth = $this->db->prepare($query); |
254 | 294 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -256,7 +296,9 @@ discard block |
||
256 | 296 | echo "error : ".$e->getMessage(); |
257 | 297 | } |
258 | 298 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
259 | - } else $all = array(); |
|
299 | + } else { |
|
300 | + $all = array(); |
|
301 | + } |
|
260 | 302 | if (empty($all)) { |
261 | 303 | $Spotter = new Spotter($this->db); |
262 | 304 | $filters = array(); |
@@ -271,7 +313,9 @@ discard block |
||
271 | 313 | } |
272 | 314 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
273 | 315 | global $globalStatsFilters; |
274 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
316 | + if ($filter_name == '') { |
|
317 | + $filter_name = $this->filter_name; |
|
318 | + } |
|
275 | 319 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
276 | 320 | $Spotter = new Spotter($this->db); |
277 | 321 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -280,8 +324,11 @@ discard block |
||
280 | 324 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
281 | 325 | } |
282 | 326 | if ($year == '' && $month == '') { |
283 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
284 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
327 | + if ($limit) { |
|
328 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
329 | + } else { |
|
330 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
331 | + } |
|
285 | 332 | try { |
286 | 333 | $sth = $this->db->prepare($query); |
287 | 334 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -289,11 +336,16 @@ discard block |
||
289 | 336 | echo "error : ".$e->getMessage(); |
290 | 337 | } |
291 | 338 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
292 | - } else $all = array(); |
|
339 | + } else { |
|
340 | + $all = array(); |
|
341 | + } |
|
293 | 342 | } else { |
294 | 343 | if ($year == '' && $month == '') { |
295 | - 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"; |
|
296 | - 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"; |
|
344 | + if ($limit) { |
|
345 | + $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"; |
|
346 | + } else { |
|
347 | + $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"; |
|
348 | + } |
|
297 | 349 | try { |
298 | 350 | $sth = $this->db->prepare($query); |
299 | 351 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -301,7 +353,9 @@ discard block |
||
301 | 353 | echo "error : ".$e->getMessage(); |
302 | 354 | } |
303 | 355 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
304 | - } else $all = array(); |
|
356 | + } else { |
|
357 | + $all = array(); |
|
358 | + } |
|
305 | 359 | } |
306 | 360 | if (empty($all)) { |
307 | 361 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -321,7 +375,9 @@ discard block |
||
321 | 375 | |
322 | 376 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
323 | 377 | global $globalStatsFilters; |
324 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
378 | + if ($filter_name == '') { |
|
379 | + $filter_name = $this->filter_name; |
|
380 | + } |
|
325 | 381 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
326 | 382 | $Spotter = new Spotter($this->db); |
327 | 383 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -330,8 +386,11 @@ discard block |
||
330 | 386 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
331 | 387 | } |
332 | 388 | if ($year == '' && $month == '') { |
333 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
334 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
389 | + if ($limit) { |
|
390 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
391 | + } else { |
|
392 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
393 | + } |
|
335 | 394 | try { |
336 | 395 | $sth = $this->db->prepare($query); |
337 | 396 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -339,11 +398,16 @@ discard block |
||
339 | 398 | echo "error : ".$e->getMessage(); |
340 | 399 | } |
341 | 400 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
342 | - } else $all = array(); |
|
401 | + } else { |
|
402 | + $all = array(); |
|
403 | + } |
|
343 | 404 | } else { |
344 | 405 | if ($year == '' && $month == '') { |
345 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
346 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
406 | + if ($limit) { |
|
407 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
408 | + } else { |
|
409 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
410 | + } |
|
347 | 411 | try { |
348 | 412 | $sth = $this->db->prepare($query); |
349 | 413 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -351,7 +415,9 @@ discard block |
||
351 | 415 | echo "error : ".$e->getMessage(); |
352 | 416 | } |
353 | 417 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
354 | - } else $all = array(); |
|
418 | + } else { |
|
419 | + $all = array(); |
|
420 | + } |
|
355 | 421 | } |
356 | 422 | if (empty($all)) { |
357 | 423 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -370,7 +436,9 @@ discard block |
||
370 | 436 | } |
371 | 437 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
372 | 438 | global $globalStatsFilters; |
373 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
439 | + if ($filter_name == '') { |
|
440 | + $filter_name = $this->filter_name; |
|
441 | + } |
|
374 | 442 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
375 | 443 | $Spotter = new Spotter($this->db); |
376 | 444 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -378,12 +446,18 @@ discard block |
||
378 | 446 | foreach ($airlines as $airline) { |
379 | 447 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
380 | 448 | } |
381 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
382 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
449 | + if ($limit) { |
|
450 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
451 | + } else { |
|
452 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
453 | + } |
|
383 | 454 | $query_values = array(':filter_name' => $filter_name); |
384 | 455 | } else { |
385 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
386 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
456 | + if ($limit) { |
|
457 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
458 | + } else { |
|
459 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
460 | + } |
|
387 | 461 | $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
388 | 462 | } |
389 | 463 | try { |
@@ -411,17 +485,29 @@ discard block |
||
411 | 485 | |
412 | 486 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
413 | 487 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
414 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
488 | + if ($filter_name == '') { |
|
489 | + $filter_name = $this->filter_name; |
|
490 | + } |
|
415 | 491 | if ($year == '' && $month == '') { |
416 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
417 | - if ($globalIVAO) $forsource = 'ivao'; |
|
492 | + if ($globalVATSIM) { |
|
493 | + $forsource = 'vatsim'; |
|
494 | + } |
|
495 | + if ($globalIVAO) { |
|
496 | + $forsource = 'ivao'; |
|
497 | + } |
|
418 | 498 | if (isset($forsource)) { |
419 | - 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"; |
|
420 | - 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"; |
|
499 | + if ($limit) { |
|
500 | + $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"; |
|
501 | + } else { |
|
502 | + $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"; |
|
503 | + } |
|
421 | 504 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
422 | 505 | } else { |
423 | - 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"; |
|
424 | - 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"; |
|
506 | + if ($limit) { |
|
507 | + $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"; |
|
508 | + } else { |
|
509 | + $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"; |
|
510 | + } |
|
425 | 511 | $query_values = array(':filter_name' => $filter_name); |
426 | 512 | } |
427 | 513 | try { |
@@ -431,7 +517,9 @@ discard block |
||
431 | 517 | echo "error : ".$e->getMessage(); |
432 | 518 | } |
433 | 519 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
434 | - } else $all = array(); |
|
520 | + } else { |
|
521 | + $all = array(); |
|
522 | + } |
|
435 | 523 | if (empty($all)) { |
436 | 524 | $Spotter = new Spotter($this->db); |
437 | 525 | $filters = array(); |
@@ -446,7 +534,9 @@ discard block |
||
446 | 534 | } |
447 | 535 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
448 | 536 | global $globalStatsFilters; |
449 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
537 | + if ($filter_name == '') { |
|
538 | + $filter_name = $this->filter_name; |
|
539 | + } |
|
450 | 540 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
451 | 541 | $Spotter = new Spotter($this->db); |
452 | 542 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -455,8 +545,11 @@ discard block |
||
455 | 545 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
456 | 546 | } |
457 | 547 | if ($year == '' && $month == '') { |
458 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
459 | - else $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
548 | + if ($limit) { |
|
549 | + $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
550 | + } else { |
|
551 | + $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
552 | + } |
|
460 | 553 | try { |
461 | 554 | $sth = $this->db->prepare($query); |
462 | 555 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -464,11 +557,16 @@ discard block |
||
464 | 557 | echo "error : ".$e->getMessage(); |
465 | 558 | } |
466 | 559 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
467 | - } else $all = array(); |
|
560 | + } else { |
|
561 | + $all = array(); |
|
562 | + } |
|
468 | 563 | } else { |
469 | 564 | if ($year == '' && $month == '') { |
470 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC LIMIT 10 OFFSET 0"; |
|
471 | - else $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC"; |
|
565 | + if ($limit) { |
|
566 | + $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC LIMIT 10 OFFSET 0"; |
|
567 | + } else { |
|
568 | + $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC"; |
|
569 | + } |
|
472 | 570 | try { |
473 | 571 | $sth = $this->db->prepare($query); |
474 | 572 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -476,7 +574,9 @@ discard block |
||
476 | 574 | echo "error : ".$e->getMessage(); |
477 | 575 | } |
478 | 576 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
479 | - } else $all = array(); |
|
577 | + } else { |
|
578 | + $all = array(); |
|
579 | + } |
|
480 | 580 | } |
481 | 581 | if (empty($all)) { |
482 | 582 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -495,7 +595,9 @@ discard block |
||
495 | 595 | } |
496 | 596 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
497 | 597 | global $globalStatsFilters; |
498 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
598 | + if ($filter_name == '') { |
|
599 | + $filter_name = $this->filter_name; |
|
600 | + } |
|
499 | 601 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
500 | 602 | $Spotter = new Spotter($this->db); |
501 | 603 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -504,8 +606,11 @@ discard block |
||
504 | 606 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
505 | 607 | } |
506 | 608 | if ($year == '' && $month == '') { |
507 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
508 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
609 | + if ($limit) { |
|
610 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
611 | + } else { |
|
612 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
613 | + } |
|
509 | 614 | try { |
510 | 615 | $sth = $this->db->prepare($query); |
511 | 616 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -513,11 +618,16 @@ discard block |
||
513 | 618 | echo "error : ".$e->getMessage(); |
514 | 619 | } |
515 | 620 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
516 | - } else $all = array(); |
|
621 | + } else { |
|
622 | + $all = array(); |
|
623 | + } |
|
517 | 624 | } else { |
518 | 625 | if ($year == '' && $month == '') { |
519 | - 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"; |
|
520 | - 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"; |
|
626 | + if ($limit) { |
|
627 | + $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"; |
|
628 | + } else { |
|
629 | + $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"; |
|
630 | + } |
|
521 | 631 | try { |
522 | 632 | $sth = $this->db->prepare($query); |
523 | 633 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -525,7 +635,9 @@ discard block |
||
525 | 635 | echo "error : ".$e->getMessage(); |
526 | 636 | } |
527 | 637 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
528 | - } else $all = array(); |
|
638 | + } else { |
|
639 | + $all = array(); |
|
640 | + } |
|
529 | 641 | } |
530 | 642 | if (empty($all)) { |
531 | 643 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -544,7 +656,9 @@ discard block |
||
544 | 656 | } |
545 | 657 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
546 | 658 | $Connection = new Connection($this->db); |
547 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
659 | + if ($filter_name == '') { |
|
660 | + $filter_name = $this->filter_name; |
|
661 | + } |
|
548 | 662 | if ($Connection->tableExists('countries')) { |
549 | 663 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
550 | 664 | $Spotter = new Spotter($this->db); |
@@ -554,8 +668,11 @@ discard block |
||
554 | 668 | foreach ($airlines as $airline) { |
555 | 669 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
556 | 670 | } |
557 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
558 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
671 | + if ($limit) { |
|
672 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
673 | + } else { |
|
674 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
675 | + } |
|
559 | 676 | try { |
560 | 677 | $sth = $this->db->prepare($query); |
561 | 678 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -564,11 +681,16 @@ discard block |
||
564 | 681 | } |
565 | 682 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
566 | 683 | return $all; |
567 | - } else return array(); |
|
684 | + } else { |
|
685 | + return array(); |
|
686 | + } |
|
568 | 687 | } else { |
569 | 688 | if ($year == '' && $month == '') { |
570 | - 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"; |
|
571 | - 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"; |
|
689 | + if ($limit) { |
|
690 | + $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"; |
|
691 | + } else { |
|
692 | + $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"; |
|
693 | + } |
|
572 | 694 | try { |
573 | 695 | $sth = $this->db->prepare($query); |
574 | 696 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -577,20 +699,29 @@ discard block |
||
577 | 699 | } |
578 | 700 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
579 | 701 | return $all; |
580 | - } else return array(); |
|
702 | + } else { |
|
703 | + return array(); |
|
704 | + } |
|
581 | 705 | } |
582 | 706 | $Spotter = new Spotter($this->db); |
583 | 707 | return $Spotter->countAllFlightOverCountries($limit); |
584 | - } else return array(); |
|
708 | + } else { |
|
709 | + return array(); |
|
710 | + } |
|
585 | 711 | } |
586 | 712 | public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
587 | 713 | $Connection = new Connection($this->db); |
588 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
714 | + if ($filter_name == '') { |
|
715 | + $filter_name = $this->filter_name; |
|
716 | + } |
|
589 | 717 | if ($Connection->tableExists('countries')) { |
590 | 718 | $all = array(); |
591 | 719 | if ($year == '' && $month == '') { |
592 | - if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0"; |
|
593 | - else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC"; |
|
720 | + if ($limit) { |
|
721 | + $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0"; |
|
722 | + } else { |
|
723 | + $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC"; |
|
724 | + } |
|
594 | 725 | try { |
595 | 726 | $sth = $this->db->prepare($query); |
596 | 727 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -608,17 +739,24 @@ discard block |
||
608 | 739 | $all = $Marine->countAllMarineOverCountries($limit,0,'',$filters); |
609 | 740 | } |
610 | 741 | return $all; |
611 | - } else return array(); |
|
742 | + } else { |
|
743 | + return array(); |
|
744 | + } |
|
612 | 745 | } |
613 | 746 | public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
614 | 747 | global $globalStatsFilters; |
615 | 748 | $Connection = new Connection($this->db); |
616 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
749 | + if ($filter_name == '') { |
|
750 | + $filter_name = $this->filter_name; |
|
751 | + } |
|
617 | 752 | if ($Connection->tableExists('countries')) { |
618 | 753 | $all = array(); |
619 | 754 | if ($year == '' && $month == '') { |
620 | - if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0"; |
|
621 | - else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC"; |
|
755 | + if ($limit) { |
|
756 | + $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0"; |
|
757 | + } else { |
|
758 | + $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC"; |
|
759 | + } |
|
622 | 760 | try { |
623 | 761 | $sth = $this->db->prepare($query); |
624 | 762 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -637,14 +775,21 @@ discard block |
||
637 | 775 | $all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters); |
638 | 776 | } |
639 | 777 | return $all; |
640 | - } else return array(); |
|
778 | + } else { |
|
779 | + return array(); |
|
780 | + } |
|
641 | 781 | } |
642 | 782 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
643 | 783 | global $globalStatsFilters; |
644 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
784 | + if ($filter_name == '') { |
|
785 | + $filter_name = $this->filter_name; |
|
786 | + } |
|
645 | 787 | if ($year == '' && $month == '') { |
646 | - 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"; |
|
647 | - 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"; |
|
788 | + if ($limit) { |
|
789 | + $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"; |
|
790 | + } else { |
|
791 | + $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"; |
|
792 | + } |
|
648 | 793 | try { |
649 | 794 | $sth = $this->db->prepare($query); |
650 | 795 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -652,7 +797,9 @@ discard block |
||
652 | 797 | echo "error : ".$e->getMessage(); |
653 | 798 | } |
654 | 799 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
655 | - } else $all = array(); |
|
800 | + } else { |
|
801 | + $all = array(); |
|
802 | + } |
|
656 | 803 | if (empty($all)) { |
657 | 804 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
658 | 805 | if ($filter_name != '') { |
@@ -667,7 +814,9 @@ discard block |
||
667 | 814 | |
668 | 815 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
669 | 816 | global $globalStatsFilters; |
670 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
817 | + if ($filter_name == '') { |
|
818 | + $filter_name = $this->filter_name; |
|
819 | + } |
|
671 | 820 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
672 | 821 | $Spotter = new Spotter($this->db); |
673 | 822 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -676,8 +825,11 @@ discard block |
||
676 | 825 | foreach ($airlines as $airline) { |
677 | 826 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
678 | 827 | } |
679 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
680 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
828 | + if ($limit) { |
|
829 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
830 | + } else { |
|
831 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
832 | + } |
|
681 | 833 | try { |
682 | 834 | $sth = $this->db->prepare($query); |
683 | 835 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -685,11 +837,16 @@ discard block |
||
685 | 837 | echo "error : ".$e->getMessage(); |
686 | 838 | } |
687 | 839 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
688 | - } else $all = array(); |
|
840 | + } else { |
|
841 | + $all = array(); |
|
842 | + } |
|
689 | 843 | } else { |
690 | 844 | if ($year == '' && $month == '') { |
691 | - 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"; |
|
692 | - 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"; |
|
845 | + if ($limit) { |
|
846 | + $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"; |
|
847 | + } else { |
|
848 | + $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"; |
|
849 | + } |
|
693 | 850 | try { |
694 | 851 | $sth = $this->db->prepare($query); |
695 | 852 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -697,7 +854,9 @@ discard block |
||
697 | 854 | echo "error : ".$e->getMessage(); |
698 | 855 | } |
699 | 856 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
700 | - } else $all = array(); |
|
857 | + } else { |
|
858 | + $all = array(); |
|
859 | + } |
|
701 | 860 | } |
702 | 861 | if (empty($all)) { |
703 | 862 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -716,7 +875,9 @@ discard block |
||
716 | 875 | } |
717 | 876 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
718 | 877 | global $globalStatsFilters; |
719 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
878 | + if ($filter_name == '') { |
|
879 | + $filter_name = $this->filter_name; |
|
880 | + } |
|
720 | 881 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
721 | 882 | $Spotter = new Spotter($this->db); |
722 | 883 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -725,8 +886,11 @@ discard block |
||
725 | 886 | foreach ($airlines as $airline) { |
726 | 887 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
727 | 888 | } |
728 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
729 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
889 | + if ($limit) { |
|
890 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
891 | + } else { |
|
892 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
893 | + } |
|
730 | 894 | try { |
731 | 895 | $sth = $this->db->prepare($query); |
732 | 896 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -734,11 +898,16 @@ discard block |
||
734 | 898 | echo "error : ".$e->getMessage(); |
735 | 899 | } |
736 | 900 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
737 | - } else $all = array(); |
|
901 | + } else { |
|
902 | + $all = array(); |
|
903 | + } |
|
738 | 904 | } else { |
739 | 905 | if ($year == '' && $month == '') { |
740 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
741 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
906 | + if ($limit) { |
|
907 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
908 | + } else { |
|
909 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
910 | + } |
|
742 | 911 | try { |
743 | 912 | $sth = $this->db->prepare($query); |
744 | 913 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -746,7 +915,9 @@ discard block |
||
746 | 915 | echo "error : ".$e->getMessage(); |
747 | 916 | } |
748 | 917 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
749 | - } else $all = array(); |
|
918 | + } else { |
|
919 | + $all = array(); |
|
920 | + } |
|
750 | 921 | } |
751 | 922 | if (empty($all)) { |
752 | 923 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -771,7 +942,9 @@ discard block |
||
771 | 942 | $icao = $value['airport_departure_icao']; |
772 | 943 | if (isset($all[$icao])) { |
773 | 944 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
774 | - } else $all[$icao] = $value; |
|
945 | + } else { |
|
946 | + $all[$icao] = $value; |
|
947 | + } |
|
775 | 948 | } |
776 | 949 | $count = array(); |
777 | 950 | foreach ($all as $key => $row) { |
@@ -783,7 +956,9 @@ discard block |
||
783 | 956 | } |
784 | 957 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
785 | 958 | global $globalStatsFilters; |
786 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
959 | + if ($filter_name == '') { |
|
960 | + $filter_name = $this->filter_name; |
|
961 | + } |
|
787 | 962 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
788 | 963 | $Spotter = new Spotter($this->db); |
789 | 964 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -792,8 +967,11 @@ discard block |
||
792 | 967 | foreach ($airlines as $airline) { |
793 | 968 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
794 | 969 | } |
795 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
796 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
970 | + if ($limit) { |
|
971 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
972 | + } else { |
|
973 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
974 | + } |
|
797 | 975 | try { |
798 | 976 | $sth = $this->db->prepare($query); |
799 | 977 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -801,11 +979,16 @@ discard block |
||
801 | 979 | echo "error : ".$e->getMessage(); |
802 | 980 | } |
803 | 981 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
804 | - } else $all = array(); |
|
982 | + } else { |
|
983 | + $all = array(); |
|
984 | + } |
|
805 | 985 | } else { |
806 | 986 | if ($year == '' && $month == '') { |
807 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
808 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
987 | + if ($limit) { |
|
988 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
989 | + } else { |
|
990 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
991 | + } |
|
809 | 992 | try { |
810 | 993 | $sth = $this->db->prepare($query); |
811 | 994 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -813,7 +996,9 @@ discard block |
||
813 | 996 | echo "error : ".$e->getMessage(); |
814 | 997 | } |
815 | 998 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
816 | - } else $all = array(); |
|
999 | + } else { |
|
1000 | + $all = array(); |
|
1001 | + } |
|
817 | 1002 | } |
818 | 1003 | if (empty($all)) { |
819 | 1004 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -838,7 +1023,9 @@ discard block |
||
838 | 1023 | $icao = $value['airport_arrival_icao']; |
839 | 1024 | if (isset($all[$icao])) { |
840 | 1025 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
841 | - } else $all[$icao] = $value; |
|
1026 | + } else { |
|
1027 | + $all[$icao] = $value; |
|
1028 | + } |
|
842 | 1029 | } |
843 | 1030 | $count = array(); |
844 | 1031 | foreach ($all as $key => $row) { |
@@ -850,7 +1037,9 @@ discard block |
||
850 | 1037 | } |
851 | 1038 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
852 | 1039 | global $globalDBdriver, $globalStatsFilters; |
853 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1040 | + if ($filter_name == '') { |
|
1041 | + $filter_name = $this->filter_name; |
|
1042 | + } |
|
854 | 1043 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
855 | 1044 | $Spotter = new Spotter($this->db); |
856 | 1045 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -859,20 +1048,32 @@ discard block |
||
859 | 1048 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
860 | 1049 | } |
861 | 1050 | if ($globalDBdriver == 'mysql') { |
862 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
863 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1051 | + if ($limit) { |
|
1052 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1053 | + } else { |
|
1054 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1055 | + } |
|
864 | 1056 | } else { |
865 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
866 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1057 | + if ($limit) { |
|
1058 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1059 | + } else { |
|
1060 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
1061 | + } |
|
867 | 1062 | } |
868 | 1063 | $query_data = array(':filter_name' => $filter_name); |
869 | 1064 | } else { |
870 | 1065 | if ($globalDBdriver == 'mysql') { |
871 | - 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"; |
|
872 | - 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"; |
|
1066 | + if ($limit) { |
|
1067 | + $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"; |
|
1068 | + } else { |
|
1069 | + $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"; |
|
1070 | + } |
|
873 | 1071 | } else { |
874 | - 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"; |
|
875 | - 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"; |
|
1072 | + if ($limit) { |
|
1073 | + $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"; |
|
1074 | + } else { |
|
1075 | + $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"; |
|
1076 | + } |
|
876 | 1077 | } |
877 | 1078 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
878 | 1079 | } |
@@ -900,13 +1101,21 @@ discard block |
||
900 | 1101 | |
901 | 1102 | public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') { |
902 | 1103 | global $globalDBdriver, $globalStatsFilters; |
903 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1104 | + if ($filter_name == '') { |
|
1105 | + $filter_name = $this->filter_name; |
|
1106 | + } |
|
904 | 1107 | if ($globalDBdriver == 'mysql') { |
905 | - 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 = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
906 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1108 | + if ($limit) { |
|
1109 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name"; |
|
1110 | + } else { |
|
1111 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1112 | + } |
|
907 | 1113 | } else { |
908 | - 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 = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
909 | - 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 = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1114 | + if ($limit) { |
|
1115 | + $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 = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name"; |
|
1116 | + } else { |
|
1117 | + $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 = 'marine_bymonth' AND filter_name = :filter_name"; |
|
1118 | + } |
|
910 | 1119 | } |
911 | 1120 | $query_data = array(':filter_name' => $filter_name); |
912 | 1121 | try { |
@@ -929,7 +1138,9 @@ discard block |
||
929 | 1138 | |
930 | 1139 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
931 | 1140 | global $globalStatsFilters; |
932 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1141 | + if ($filter_name == '') { |
|
1142 | + $filter_name = $this->filter_name; |
|
1143 | + } |
|
933 | 1144 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
934 | 1145 | $Spotter = new Spotter($this->db); |
935 | 1146 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -966,7 +1177,9 @@ discard block |
||
966 | 1177 | } |
967 | 1178 | public function countAllMarineDatesLastMonth($filter_name = '') { |
968 | 1179 | global $globalStatsFilters; |
969 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1180 | + if ($filter_name == '') { |
|
1181 | + $filter_name = $this->filter_name; |
|
1182 | + } |
|
970 | 1183 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND filter_name = :filter_name"; |
971 | 1184 | $query_data = array(':filter_name' => $filter_name); |
972 | 1185 | try { |
@@ -988,7 +1201,9 @@ discard block |
||
988 | 1201 | } |
989 | 1202 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
990 | 1203 | global $globalDBdriver, $globalStatsFilters; |
991 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1204 | + if ($filter_name == '') { |
|
1205 | + $filter_name = $this->filter_name; |
|
1206 | + } |
|
992 | 1207 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
993 | 1208 | $Spotter = new Spotter($this->db); |
994 | 1209 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1033,7 +1248,9 @@ discard block |
||
1033 | 1248 | } |
1034 | 1249 | public function countAllMarineDatesLast7Days($filter_name = '') { |
1035 | 1250 | global $globalDBdriver, $globalStatsFilters; |
1036 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1251 | + if ($filter_name == '') { |
|
1252 | + $filter_name = $this->filter_name; |
|
1253 | + } |
|
1037 | 1254 | if ($globalDBdriver == 'mysql') { |
1038 | 1255 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND marine_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name"; |
1039 | 1256 | } else { |
@@ -1059,7 +1276,9 @@ discard block |
||
1059 | 1276 | } |
1060 | 1277 | public function countAllDates($stats_airline = '',$filter_name = '') { |
1061 | 1278 | global $globalStatsFilters; |
1062 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1279 | + if ($filter_name == '') { |
|
1280 | + $filter_name = $this->filter_name; |
|
1281 | + } |
|
1063 | 1282 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1064 | 1283 | $Spotter = new Spotter($this->db); |
1065 | 1284 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1096,7 +1315,9 @@ discard block |
||
1096 | 1315 | } |
1097 | 1316 | public function countAllDatesMarine($filter_name = '') { |
1098 | 1317 | global $globalStatsFilters; |
1099 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1318 | + if ($filter_name == '') { |
|
1319 | + $filter_name = $this->filter_name; |
|
1320 | + } |
|
1100 | 1321 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC"; |
1101 | 1322 | $query_data = array(':filter_name' => $filter_name); |
1102 | 1323 | try { |
@@ -1118,7 +1339,9 @@ discard block |
||
1118 | 1339 | } |
1119 | 1340 | public function countAllDatesTracker($filter_name = '') { |
1120 | 1341 | global $globalStatsFilters; |
1121 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1342 | + if ($filter_name == '') { |
|
1343 | + $filter_name = $this->filter_name; |
|
1344 | + } |
|
1122 | 1345 | $query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC"; |
1123 | 1346 | $query_data = array(':filter_name' => $filter_name); |
1124 | 1347 | try { |
@@ -1140,7 +1363,9 @@ discard block |
||
1140 | 1363 | } |
1141 | 1364 | public function countAllDatesByAirlines($filter_name = '') { |
1142 | 1365 | global $globalStatsFilters; |
1143 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1366 | + if ($filter_name == '') { |
|
1367 | + $filter_name = $this->filter_name; |
|
1368 | + } |
|
1144 | 1369 | $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"; |
1145 | 1370 | $query_data = array('filter_name' => $filter_name); |
1146 | 1371 | try { |
@@ -1162,7 +1387,9 @@ discard block |
||
1162 | 1387 | } |
1163 | 1388 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
1164 | 1389 | global $globalStatsFilters, $globalDBdriver; |
1165 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1390 | + if ($filter_name == '') { |
|
1391 | + $filter_name = $this->filter_name; |
|
1392 | + } |
|
1166 | 1393 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1167 | 1394 | $Spotter = new Spotter($this->db); |
1168 | 1395 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1247,7 +1474,9 @@ discard block |
||
1247 | 1474 | } |
1248 | 1475 | public function countAllMilitaryMonths($filter_name = '') { |
1249 | 1476 | global $globalStatsFilters; |
1250 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1477 | + if ($filter_name == '') { |
|
1478 | + $filter_name = $this->filter_name; |
|
1479 | + } |
|
1251 | 1480 | $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"; |
1252 | 1481 | try { |
1253 | 1482 | $sth = $this->db->prepare($query); |
@@ -1268,7 +1497,9 @@ discard block |
||
1268 | 1497 | } |
1269 | 1498 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
1270 | 1499 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
1271 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1500 | + if ($filter_name == '') { |
|
1501 | + $filter_name = $this->filter_name; |
|
1502 | + } |
|
1272 | 1503 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1273 | 1504 | $Spotter = new Spotter($this->db); |
1274 | 1505 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1276,12 +1507,18 @@ discard block |
||
1276 | 1507 | foreach ($airlines as $airline) { |
1277 | 1508 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
1278 | 1509 | } |
1279 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1280 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1510 | + if ($limit) { |
|
1511 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1512 | + } else { |
|
1513 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
1514 | + } |
|
1281 | 1515 | $query_data = array(':filter_name' => $filter_name); |
1282 | 1516 | } else { |
1283 | - 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"; |
|
1284 | - 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"; |
|
1517 | + if ($limit) { |
|
1518 | + $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"; |
|
1519 | + } else { |
|
1520 | + $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"; |
|
1521 | + } |
|
1285 | 1522 | $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
1286 | 1523 | } |
1287 | 1524 | if ($orderby == 'hour') { |
@@ -1291,7 +1528,9 @@ discard block |
||
1291 | 1528 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
1292 | 1529 | } |
1293 | 1530 | } |
1294 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
1531 | + if ($orderby == 'count') { |
|
1532 | + $query .= " ORDER BY hour_count DESC"; |
|
1533 | + } |
|
1295 | 1534 | try { |
1296 | 1535 | $sth = $this->db->prepare($query); |
1297 | 1536 | $sth->execute($query_data); |
@@ -1315,9 +1554,14 @@ discard block |
||
1315 | 1554 | } |
1316 | 1555 | public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') { |
1317 | 1556 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
1318 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1319 | - if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1320 | - else $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1557 | + if ($filter_name == '') { |
|
1558 | + $filter_name = $this->filter_name; |
|
1559 | + } |
|
1560 | + if ($limit) { |
|
1561 | + $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1562 | + } else { |
|
1563 | + $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
|
1564 | + } |
|
1321 | 1565 | $query_data = array(':filter_name' => $filter_name); |
1322 | 1566 | if ($orderby == 'hour') { |
1323 | 1567 | if ($globalDBdriver == 'mysql') { |
@@ -1326,7 +1570,9 @@ discard block |
||
1326 | 1570 | $query .= " ORDER BY CAST(marine_date AS integer) ASC"; |
1327 | 1571 | } |
1328 | 1572 | } |
1329 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
1573 | + if ($orderby == 'count') { |
|
1574 | + $query .= " ORDER BY hour_count DESC"; |
|
1575 | + } |
|
1330 | 1576 | try { |
1331 | 1577 | $sth = $this->db->prepare($query); |
1332 | 1578 | $sth->execute($query_data); |
@@ -1346,8 +1592,12 @@ discard block |
||
1346 | 1592 | } |
1347 | 1593 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
1348 | 1594 | global $globalStatsFilters; |
1349 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1350 | - if ($year == '') $year = date('Y'); |
|
1595 | + if ($filter_name == '') { |
|
1596 | + $filter_name = $this->filter_name; |
|
1597 | + } |
|
1598 | + if ($year == '') { |
|
1599 | + $year = date('Y'); |
|
1600 | + } |
|
1351 | 1601 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
1352 | 1602 | if (empty($all)) { |
1353 | 1603 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1366,8 +1616,12 @@ discard block |
||
1366 | 1616 | } |
1367 | 1617 | public function countOverallMarine($filter_name = '',$year = '',$month = '') { |
1368 | 1618 | global $globalStatsFilters; |
1369 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1370 | - if ($year == '') $year = date('Y'); |
|
1619 | + if ($filter_name == '') { |
|
1620 | + $filter_name = $this->filter_name; |
|
1621 | + } |
|
1622 | + if ($year == '') { |
|
1623 | + $year = date('Y'); |
|
1624 | + } |
|
1371 | 1625 | $all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month); |
1372 | 1626 | if (empty($all)) { |
1373 | 1627 | $filters = array('year' => $year,'month' => $month); |
@@ -1382,8 +1636,12 @@ discard block |
||
1382 | 1636 | } |
1383 | 1637 | public function countOverallTracker($filter_name = '',$year = '',$month = '') { |
1384 | 1638 | global $globalStatsFilters; |
1385 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1386 | - if ($year == '') $year = date('Y'); |
|
1639 | + if ($filter_name == '') { |
|
1640 | + $filter_name = $this->filter_name; |
|
1641 | + } |
|
1642 | + if ($year == '') { |
|
1643 | + $year = date('Y'); |
|
1644 | + } |
|
1387 | 1645 | $all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month); |
1388 | 1646 | if (empty($all)) { |
1389 | 1647 | $filters = array('year' => $year,'month' => $month); |
@@ -1398,8 +1656,12 @@ discard block |
||
1398 | 1656 | } |
1399 | 1657 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
1400 | 1658 | global $globalStatsFilters; |
1401 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1402 | - if ($year == '') $year = date('Y'); |
|
1659 | + if ($filter_name == '') { |
|
1660 | + $filter_name = $this->filter_name; |
|
1661 | + } |
|
1662 | + if ($year == '') { |
|
1663 | + $year = date('Y'); |
|
1664 | + } |
|
1403 | 1665 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
1404 | 1666 | if (empty($all)) { |
1405 | 1667 | $filters = array(); |
@@ -1415,8 +1677,12 @@ discard block |
||
1415 | 1677 | } |
1416 | 1678 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
1417 | 1679 | global $globalStatsFilters; |
1418 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1419 | - if ($year == '') $year = date('Y'); |
|
1680 | + if ($filter_name == '') { |
|
1681 | + $filter_name = $this->filter_name; |
|
1682 | + } |
|
1683 | + if ($year == '') { |
|
1684 | + $year = date('Y'); |
|
1685 | + } |
|
1420 | 1686 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
1421 | 1687 | if (empty($all)) { |
1422 | 1688 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1435,7 +1701,9 @@ discard block |
||
1435 | 1701 | } |
1436 | 1702 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
1437 | 1703 | global $globalStatsFilters; |
1438 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1704 | + if ($filter_name == '') { |
|
1705 | + $filter_name = $this->filter_name; |
|
1706 | + } |
|
1439 | 1707 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1440 | 1708 | $Spotter = new Spotter($this->db); |
1441 | 1709 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1453,7 +1721,9 @@ discard block |
||
1453 | 1721 | } |
1454 | 1722 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1455 | 1723 | $all = $result[0]['nb']; |
1456 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1724 | + } else { |
|
1725 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1726 | + } |
|
1457 | 1727 | } else { |
1458 | 1728 | if ($year == '' && $month == '') { |
1459 | 1729 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1465,7 +1735,9 @@ discard block |
||
1465 | 1735 | } |
1466 | 1736 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1467 | 1737 | $all = $result[0]['nb']; |
1468 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1738 | + } else { |
|
1739 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
1740 | + } |
|
1469 | 1741 | } |
1470 | 1742 | if (empty($all)) { |
1471 | 1743 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1484,7 +1756,9 @@ discard block |
||
1484 | 1756 | } |
1485 | 1757 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
1486 | 1758 | global $globalStatsFilters; |
1487 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1759 | + if ($filter_name == '') { |
|
1760 | + $filter_name = $this->filter_name; |
|
1761 | + } |
|
1488 | 1762 | if ($year == '' && $month == '') { |
1489 | 1763 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
1490 | 1764 | try { |
@@ -1495,7 +1769,9 @@ discard block |
||
1495 | 1769 | } |
1496 | 1770 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
1497 | 1771 | $all = $result[0]['nb_airline']; |
1498 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1772 | + } else { |
|
1773 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1774 | + } |
|
1499 | 1775 | if (empty($all)) { |
1500 | 1776 | $filters = array(); |
1501 | 1777 | $filters = array('year' => $year,'month' => $month); |
@@ -1510,7 +1786,9 @@ discard block |
||
1510 | 1786 | } |
1511 | 1787 | public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') { |
1512 | 1788 | global $globalStatsFilters; |
1513 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1789 | + if ($filter_name == '') { |
|
1790 | + $filter_name = $this->filter_name; |
|
1791 | + } |
|
1514 | 1792 | $all = array(); |
1515 | 1793 | if ($year == '' && $month == '') { |
1516 | 1794 | $query = "SELECT COUNT(*) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name"; |
@@ -1537,7 +1815,9 @@ discard block |
||
1537 | 1815 | } |
1538 | 1816 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
1539 | 1817 | global $globalStatsFilters; |
1540 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1818 | + if ($filter_name == '') { |
|
1819 | + $filter_name = $this->filter_name; |
|
1820 | + } |
|
1541 | 1821 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1542 | 1822 | $Spotter = new Spotter($this->db); |
1543 | 1823 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1592,7 +1872,9 @@ discard block |
||
1592 | 1872 | } |
1593 | 1873 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
1594 | 1874 | global $globalStatsFilters; |
1595 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1875 | + if ($filter_name == '') { |
|
1876 | + $filter_name = $this->filter_name; |
|
1877 | + } |
|
1596 | 1878 | //if ($year == '') $year = date('Y'); |
1597 | 1879 | if ($year == '' && $month == '') { |
1598 | 1880 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1621,7 +1903,9 @@ discard block |
||
1621 | 1903 | } |
1622 | 1904 | |
1623 | 1905 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
1624 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1906 | + if ($filter_name == '') { |
|
1907 | + $filter_name = $this->filter_name; |
|
1908 | + } |
|
1625 | 1909 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1626 | 1910 | $Spotter = new Spotter($this->db); |
1627 | 1911 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1645,7 +1929,9 @@ discard block |
||
1645 | 1929 | return $all; |
1646 | 1930 | } |
1647 | 1931 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
1648 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1932 | + if ($filter_name == '') { |
|
1933 | + $filter_name = $this->filter_name; |
|
1934 | + } |
|
1649 | 1935 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
1650 | 1936 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
1651 | 1937 | try { |
@@ -1658,7 +1944,9 @@ discard block |
||
1658 | 1944 | return $all; |
1659 | 1945 | } |
1660 | 1946 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
1661 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1947 | + if ($filter_name == '') { |
|
1948 | + $filter_name = $this->filter_name; |
|
1949 | + } |
|
1662 | 1950 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1663 | 1951 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
1664 | 1952 | try { |
@@ -1669,7 +1957,9 @@ discard block |
||
1669 | 1957 | } |
1670 | 1958 | } |
1671 | 1959 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
1672 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1960 | + if ($filter_name == '') { |
|
1961 | + $filter_name = $this->filter_name; |
|
1962 | + } |
|
1673 | 1963 | global $globalArchiveMonths, $globalDBdriver; |
1674 | 1964 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1675 | 1965 | $Spotter = new Spotter($this->db); |
@@ -1725,7 +2015,9 @@ discard block |
||
1725 | 2015 | } |
1726 | 2016 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
1727 | 2017 | global $globalArchiveMonths, $globalDBdriver; |
1728 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2018 | + if ($filter_name == '') { |
|
2019 | + $filter_name = $this->filter_name; |
|
2020 | + } |
|
1729 | 2021 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1730 | 2022 | $Spotter = new Spotter($this->db); |
1731 | 2023 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1758,7 +2050,9 @@ discard block |
||
1758 | 2050 | } |
1759 | 2051 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
1760 | 2052 | global $globalArchiveMonths, $globalDBdriver; |
1761 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2053 | + if ($filter_name == '') { |
|
2054 | + $filter_name = $this->filter_name; |
|
2055 | + } |
|
1762 | 2056 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
1763 | 2057 | $Spotter = new Spotter($this->db); |
1764 | 2058 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1789,7 +2083,9 @@ discard block |
||
1789 | 2083 | } |
1790 | 2084 | public function getStatsAirlineTotal($filter_name = '') { |
1791 | 2085 | global $globalArchiveMonths, $globalDBdriver; |
1792 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2086 | + if ($filter_name == '') { |
|
2087 | + $filter_name = $this->filter_name; |
|
2088 | + } |
|
1793 | 2089 | if ($globalDBdriver == 'mysql') { |
1794 | 2090 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
1795 | 2091 | } else { |
@@ -1806,7 +2102,9 @@ discard block |
||
1806 | 2102 | } |
1807 | 2103 | public function getStatsOwnerTotal($filter_name = '') { |
1808 | 2104 | global $globalArchiveMonths, $globalDBdriver; |
1809 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2105 | + if ($filter_name == '') { |
|
2106 | + $filter_name = $this->filter_name; |
|
2107 | + } |
|
1810 | 2108 | if ($globalDBdriver == 'mysql') { |
1811 | 2109 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1812 | 2110 | } else { |
@@ -1823,7 +2121,9 @@ discard block |
||
1823 | 2121 | } |
1824 | 2122 | public function getStatsOwner($owner_name,$filter_name = '') { |
1825 | 2123 | global $globalArchiveMonths, $globalDBdriver; |
1826 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2124 | + if ($filter_name == '') { |
|
2125 | + $filter_name = $this->filter_name; |
|
2126 | + } |
|
1827 | 2127 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1828 | 2128 | try { |
1829 | 2129 | $sth = $this->db->prepare($query); |
@@ -1832,12 +2132,17 @@ discard block |
||
1832 | 2132 | echo "error : ".$e->getMessage(); |
1833 | 2133 | } |
1834 | 2134 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1835 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1836 | - else return 0; |
|
2135 | + if (isset($all[0]['cnt'])) { |
|
2136 | + return $all[0]['cnt']; |
|
2137 | + } else { |
|
2138 | + return 0; |
|
2139 | + } |
|
1837 | 2140 | } |
1838 | 2141 | public function getStatsPilotTotal($filter_name = '') { |
1839 | 2142 | global $globalArchiveMonths, $globalDBdriver; |
1840 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2143 | + if ($filter_name == '') { |
|
2144 | + $filter_name = $this->filter_name; |
|
2145 | + } |
|
1841 | 2146 | if ($globalDBdriver == 'mysql') { |
1842 | 2147 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
1843 | 2148 | } else { |
@@ -1854,7 +2159,9 @@ discard block |
||
1854 | 2159 | } |
1855 | 2160 | public function getStatsPilot($pilot,$filter_name = '') { |
1856 | 2161 | global $globalArchiveMonths, $globalDBdriver; |
1857 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2162 | + if ($filter_name == '') { |
|
2163 | + $filter_name = $this->filter_name; |
|
2164 | + } |
|
1858 | 2165 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1859 | 2166 | try { |
1860 | 2167 | $sth = $this->db->prepare($query); |
@@ -1863,13 +2170,18 @@ discard block |
||
1863 | 2170 | echo "error : ".$e->getMessage(); |
1864 | 2171 | } |
1865 | 2172 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1866 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1867 | - else return 0; |
|
2173 | + if (isset($all[0]['cnt'])) { |
|
2174 | + return $all[0]['cnt']; |
|
2175 | + } else { |
|
2176 | + return 0; |
|
2177 | + } |
|
1868 | 2178 | } |
1869 | 2179 | |
1870 | 2180 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1871 | 2181 | global $globalDBdriver; |
1872 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2182 | + if ($filter_name == '') { |
|
2183 | + $filter_name = $this->filter_name; |
|
2184 | + } |
|
1873 | 2185 | if ($globalDBdriver == 'mysql') { |
1874 | 2186 | $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"; |
1875 | 2187 | } else { |
@@ -1885,7 +2197,9 @@ discard block |
||
1885 | 2197 | } |
1886 | 2198 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1887 | 2199 | global $globalDBdriver; |
1888 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
2200 | + if ($filter_name == '') { |
|
2201 | + $filter_name = $this->filter_name; |
|
2202 | + } |
|
1889 | 2203 | if ($globalDBdriver == 'mysql') { |
1890 | 2204 | $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"; |
1891 | 2205 | } else { |
@@ -2381,27 +2695,37 @@ discard block |
||
2381 | 2695 | date_default_timezone_set('UTC'); |
2382 | 2696 | if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) { |
2383 | 2697 | $last_update = $this->getLastStatsUpdate('last_update_stats_marine'); |
2384 | - if ($globalDebug) echo '!!! Update Marine stats !!!'."\n"; |
|
2698 | + if ($globalDebug) { |
|
2699 | + echo '!!! Update Marine stats !!!'."\n"; |
|
2700 | + } |
|
2385 | 2701 | if (isset($last_update[0]['value'])) { |
2386 | 2702 | $last_update_day = $last_update[0]['value']; |
2387 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2703 | + } else { |
|
2704 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2705 | + } |
|
2388 | 2706 | $reset = false; |
2389 | 2707 | $Marine = new Marine($this->db); |
2390 | 2708 | $filtername = 'marine'; |
2391 | 2709 | if ($Connection->tableExists('countries')) { |
2392 | - if ($globalDebug) echo 'Count all vessels by countries...'."\n"; |
|
2710 | + if ($globalDebug) { |
|
2711 | + echo 'Count all vessels by countries...'."\n"; |
|
2712 | + } |
|
2393 | 2713 | $alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day); |
2394 | 2714 | foreach ($alldata as $number) { |
2395 | 2715 | echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset); |
2396 | 2716 | } |
2397 | 2717 | } |
2398 | - if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
|
2718 | + if ($globalDebug) { |
|
2719 | + echo 'Count all vessels by months...'."\n"; |
|
2720 | + } |
|
2399 | 2721 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
2400 | 2722 | $filter_last_month = array('since_date' => $last_month); |
2401 | 2723 | $alldata = $Marine->countAllMonths($filter_last_month); |
2402 | 2724 | $lastyear = false; |
2403 | 2725 | foreach ($alldata as $number) { |
2404 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2726 | + if ($number['year_name'] != date('Y')) { |
|
2727 | + $lastyear = true; |
|
2728 | + } |
|
2405 | 2729 | $this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2406 | 2730 | } |
2407 | 2731 | echo 'Marine data...'."\n"; |
@@ -2431,7 +2755,9 @@ discard block |
||
2431 | 2755 | foreach ($alldata as $number) { |
2432 | 2756 | $this->addStatMarine('hour',$number['hour_name'],$number['hour_count']); |
2433 | 2757 | } |
2434 | - if ($globalDebug) echo 'Count all types...'."\n"; |
|
2758 | + if ($globalDebug) { |
|
2759 | + echo 'Count all types...'."\n"; |
|
2760 | + } |
|
2435 | 2761 | $alldata = $Marine->countAllMarineTypes(false,0,$last_update_day); |
2436 | 2762 | foreach ($alldata as $number) { |
2437 | 2763 | $this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset); |
@@ -2443,26 +2769,36 @@ discard block |
||
2443 | 2769 | } |
2444 | 2770 | if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) { |
2445 | 2771 | $last_update = $this->getLastStatsUpdate('last_update_stats_tracker'); |
2446 | - if ($globalDebug) echo '!!! Update tracker stats !!!'."\n"; |
|
2772 | + if ($globalDebug) { |
|
2773 | + echo '!!! Update tracker stats !!!'."\n"; |
|
2774 | + } |
|
2447 | 2775 | if (isset($last_update[0]['value'])) { |
2448 | 2776 | $last_update_day = $last_update[0]['value']; |
2449 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2777 | + } else { |
|
2778 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2779 | + } |
|
2450 | 2780 | $reset = false; |
2451 | 2781 | $Tracker = new Tracker($this->db); |
2452 | 2782 | if ($Connection->tableExists('countries')) { |
2453 | - if ($globalDebug) echo 'Count all trackers by countries...'."\n"; |
|
2783 | + if ($globalDebug) { |
|
2784 | + echo 'Count all trackers by countries...'."\n"; |
|
2785 | + } |
|
2454 | 2786 | $alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day); |
2455 | 2787 | foreach ($alldata as $number) { |
2456 | 2788 | $this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset); |
2457 | 2789 | } |
2458 | 2790 | } |
2459 | - if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
|
2791 | + if ($globalDebug) { |
|
2792 | + echo 'Count all vessels by months...'."\n"; |
|
2793 | + } |
|
2460 | 2794 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
2461 | 2795 | $filter_last_month = array('since_date' => $last_month); |
2462 | 2796 | $alldata = $Tracker->countAllMonths($filter_last_month); |
2463 | 2797 | $lastyear = false; |
2464 | 2798 | foreach ($alldata as $number) { |
2465 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2799 | + if ($number['year_name'] != date('Y')) { |
|
2800 | + $lastyear = true; |
|
2801 | + } |
|
2466 | 2802 | $this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
2467 | 2803 | } |
2468 | 2804 | echo 'Tracker data...'."\n"; |
@@ -2499,10 +2835,14 @@ discard block |
||
2499 | 2835 | |
2500 | 2836 | if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) { |
2501 | 2837 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
2502 | - if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n"; |
|
2838 | + if ($globalDebug) { |
|
2839 | + echo '!!! Update aicraft stats !!!'."\n"; |
|
2840 | + } |
|
2503 | 2841 | if (isset($last_update[0]['value'])) { |
2504 | 2842 | $last_update_day = $last_update[0]['value']; |
2505 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2843 | + } else { |
|
2844 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2845 | + } |
|
2506 | 2846 | $reset = false; |
2507 | 2847 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
2508 | 2848 | if ($globalStatsResetYear) { |
@@ -2511,43 +2851,63 @@ discard block |
||
2511 | 2851 | } |
2512 | 2852 | $Spotter = new Spotter($this->db); |
2513 | 2853 | |
2514 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
2854 | + if ($globalDebug) { |
|
2855 | + echo 'Count all aircraft types...'."\n"; |
|
2856 | + } |
|
2515 | 2857 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
2516 | 2858 | foreach ($alldata as $number) { |
2517 | 2859 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
2518 | 2860 | } |
2519 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
2861 | + if ($globalDebug) { |
|
2862 | + echo 'Count all airlines...'."\n"; |
|
2863 | + } |
|
2520 | 2864 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
2521 | 2865 | foreach ($alldata as $number) { |
2522 | 2866 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
2523 | 2867 | } |
2524 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
2868 | + if ($globalDebug) { |
|
2869 | + echo 'Count all registrations...'."\n"; |
|
2870 | + } |
|
2525 | 2871 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
2526 | 2872 | foreach ($alldata as $number) { |
2527 | 2873 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
2528 | 2874 | } |
2529 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
2875 | + if ($globalDebug) { |
|
2876 | + echo 'Count all callsigns...'."\n"; |
|
2877 | + } |
|
2530 | 2878 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
2531 | 2879 | foreach ($alldata as $number) { |
2532 | 2880 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
2533 | 2881 | } |
2534 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
2882 | + if ($globalDebug) { |
|
2883 | + echo 'Count all owners...'."\n"; |
|
2884 | + } |
|
2535 | 2885 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
2536 | 2886 | foreach ($alldata as $number) { |
2537 | 2887 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
2538 | 2888 | } |
2539 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
2889 | + if ($globalDebug) { |
|
2890 | + echo 'Count all pilots...'."\n"; |
|
2891 | + } |
|
2540 | 2892 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
2541 | 2893 | foreach ($alldata as $number) { |
2542 | - if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
|
2894 | + if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') { |
|
2895 | + $number['pilot_id'] = $number['pilot_name']; |
|
2896 | + } |
|
2543 | 2897 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
2544 | 2898 | } |
2545 | 2899 | |
2546 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
2900 | + if ($globalDebug) { |
|
2901 | + echo 'Count all departure airports...'."\n"; |
|
2902 | + } |
|
2547 | 2903 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
2548 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
2904 | + if ($globalDebug) { |
|
2905 | + echo 'Count all detected departure airports...'."\n"; |
|
2906 | + } |
|
2549 | 2907 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
2550 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
2908 | + if ($globalDebug) { |
|
2909 | + echo 'Order departure airports...'."\n"; |
|
2910 | + } |
|
2551 | 2911 | $alldata = array(); |
2552 | 2912 | foreach ($pall as $value) { |
2553 | 2913 | $icao = $value['airport_departure_icao']; |
@@ -2557,7 +2917,9 @@ discard block |
||
2557 | 2917 | $icao = $value['airport_departure_icao']; |
2558 | 2918 | if (isset($alldata[$icao])) { |
2559 | 2919 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
2560 | - } else $alldata[$icao] = $value; |
|
2920 | + } else { |
|
2921 | + $alldata[$icao] = $value; |
|
2922 | + } |
|
2561 | 2923 | } |
2562 | 2924 | $count = array(); |
2563 | 2925 | foreach ($alldata as $key => $row) { |
@@ -2567,11 +2929,17 @@ discard block |
||
2567 | 2929 | foreach ($alldata as $number) { |
2568 | 2930 | 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); |
2569 | 2931 | } |
2570 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
2932 | + if ($globalDebug) { |
|
2933 | + echo 'Count all arrival airports...'."\n"; |
|
2934 | + } |
|
2571 | 2935 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
2572 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
2936 | + if ($globalDebug) { |
|
2937 | + echo 'Count all detected arrival airports...'."\n"; |
|
2938 | + } |
|
2573 | 2939 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
2574 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
2940 | + if ($globalDebug) { |
|
2941 | + echo 'Order arrival airports...'."\n"; |
|
2942 | + } |
|
2575 | 2943 | $alldata = array(); |
2576 | 2944 | foreach ($pall as $value) { |
2577 | 2945 | $icao = $value['airport_arrival_icao']; |
@@ -2581,7 +2949,9 @@ discard block |
||
2581 | 2949 | $icao = $value['airport_arrival_icao']; |
2582 | 2950 | if (isset($alldata[$icao])) { |
2583 | 2951 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
2584 | - } else $alldata[$icao] = $value; |
|
2952 | + } else { |
|
2953 | + $alldata[$icao] = $value; |
|
2954 | + } |
|
2585 | 2955 | } |
2586 | 2956 | $count = array(); |
2587 | 2957 | foreach ($alldata as $key => $row) { |
@@ -2592,7 +2962,9 @@ discard block |
||
2592 | 2962 | 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); |
2593 | 2963 | } |
2594 | 2964 | if ($Connection->tableExists('countries')) { |
2595 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
2965 | + if ($globalDebug) { |
|
2966 | + echo 'Count all flights by countries...'."\n"; |
|
2967 | + } |
|
2596 | 2968 | //$SpotterArchive = new SpotterArchive(); |
2597 | 2969 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
2598 | 2970 | $Spotter = new Spotter($this->db); |
@@ -2603,7 +2975,9 @@ discard block |
||
2603 | 2975 | } |
2604 | 2976 | |
2605 | 2977 | if (isset($globalAccidents) && $globalAccidents) { |
2606 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
2978 | + if ($globalDebug) { |
|
2979 | + echo 'Count fatalities stats...'."\n"; |
|
2980 | + } |
|
2607 | 2981 | $Accident = new Accident($this->db); |
2608 | 2982 | $this->deleteStatsByType('fatalities_byyear'); |
2609 | 2983 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -2619,48 +2993,68 @@ discard block |
||
2619 | 2993 | |
2620 | 2994 | // Add by month using getstat if month finish... |
2621 | 2995 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
2622 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
2996 | + if ($globalDebug) { |
|
2997 | + echo 'Count all flights by months...'."\n"; |
|
2998 | + } |
|
2623 | 2999 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
2624 | 3000 | $filter_last_month = array('since_date' => $last_month); |
2625 | 3001 | $Spotter = new Spotter($this->db); |
2626 | 3002 | $alldata = $Spotter->countAllMonths($filter_last_month); |
2627 | 3003 | $lastyear = false; |
2628 | 3004 | foreach ($alldata as $number) { |
2629 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
3005 | + if ($number['year_name'] != date('Y')) { |
|
3006 | + $lastyear = true; |
|
3007 | + } |
|
2630 | 3008 | $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']))); |
2631 | 3009 | } |
2632 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
3010 | + if ($globalDebug) { |
|
3011 | + echo 'Count all military flights by months...'."\n"; |
|
3012 | + } |
|
2633 | 3013 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
2634 | 3014 | foreach ($alldata as $number) { |
2635 | 3015 | $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']))); |
2636 | 3016 | } |
2637 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
3017 | + if ($globalDebug) { |
|
3018 | + echo 'Count all owners by months...'."\n"; |
|
3019 | + } |
|
2638 | 3020 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
2639 | 3021 | foreach ($alldata as $number) { |
2640 | 3022 | $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']))); |
2641 | 3023 | } |
2642 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
3024 | + if ($globalDebug) { |
|
3025 | + echo 'Count all pilots by months...'."\n"; |
|
3026 | + } |
|
2643 | 3027 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
2644 | 3028 | foreach ($alldata as $number) { |
2645 | 3029 | $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']))); |
2646 | 3030 | } |
2647 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
3031 | + if ($globalDebug) { |
|
3032 | + echo 'Count all airlines by months...'."\n"; |
|
3033 | + } |
|
2648 | 3034 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
2649 | 3035 | foreach ($alldata as $number) { |
2650 | 3036 | $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']))); |
2651 | 3037 | } |
2652 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
3038 | + if ($globalDebug) { |
|
3039 | + echo 'Count all aircrafts by months...'."\n"; |
|
3040 | + } |
|
2653 | 3041 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
2654 | 3042 | foreach ($alldata as $number) { |
2655 | 3043 | $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']))); |
2656 | 3044 | } |
2657 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
3045 | + if ($globalDebug) { |
|
3046 | + echo 'Count all real arrivals by months...'."\n"; |
|
3047 | + } |
|
2658 | 3048 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
2659 | 3049 | foreach ($alldata as $number) { |
2660 | 3050 | $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']))); |
2661 | 3051 | } |
2662 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
2663 | - if ($globalDebug) echo '...Departure'."\n"; |
|
3052 | + if ($globalDebug) { |
|
3053 | + echo 'Airports data...'."\n"; |
|
3054 | + } |
|
3055 | + if ($globalDebug) { |
|
3056 | + echo '...Departure'."\n"; |
|
3057 | + } |
|
2664 | 3058 | $this->deleteStatAirport('daily'); |
2665 | 3059 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
2666 | 3060 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -2778,7 +3172,9 @@ discard block |
||
2778 | 3172 | // Count by airlines |
2779 | 3173 | echo '--- Stats by airlines ---'."\n"; |
2780 | 3174 | if ($Connection->tableExists('countries')) { |
2781 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
3175 | + if ($globalDebug) { |
|
3176 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
3177 | + } |
|
2782 | 3178 | $SpotterArchive = new SpotterArchive($this->db); |
2783 | 3179 | //$Spotter = new Spotter($this->db); |
2784 | 3180 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
@@ -2787,37 +3183,53 @@ discard block |
||
2787 | 3183 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
2788 | 3184 | } |
2789 | 3185 | } |
2790 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
3186 | + if ($globalDebug) { |
|
3187 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
3188 | + } |
|
2791 | 3189 | $Spotter = new Spotter($this->db); |
2792 | 3190 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
2793 | 3191 | foreach ($alldata as $number) { |
2794 | 3192 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
2795 | 3193 | } |
2796 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
3194 | + if ($globalDebug) { |
|
3195 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
3196 | + } |
|
2797 | 3197 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
2798 | 3198 | foreach ($alldata as $number) { |
2799 | 3199 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
2800 | 3200 | } |
2801 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
3201 | + if ($globalDebug) { |
|
3202 | + echo 'Count all callsigns by airlines...'."\n"; |
|
3203 | + } |
|
2802 | 3204 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
2803 | 3205 | foreach ($alldata as $number) { |
2804 | 3206 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
2805 | 3207 | } |
2806 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
3208 | + if ($globalDebug) { |
|
3209 | + echo 'Count all owners by airlines...'."\n"; |
|
3210 | + } |
|
2807 | 3211 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
2808 | 3212 | foreach ($alldata as $number) { |
2809 | 3213 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
2810 | 3214 | } |
2811 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
3215 | + if ($globalDebug) { |
|
3216 | + echo 'Count all pilots by airlines...'."\n"; |
|
3217 | + } |
|
2812 | 3218 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
2813 | 3219 | foreach ($alldata as $number) { |
2814 | 3220 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
2815 | 3221 | } |
2816 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
3222 | + if ($globalDebug) { |
|
3223 | + echo 'Count all departure airports by airlines...'."\n"; |
|
3224 | + } |
|
2817 | 3225 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
2818 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
3226 | + if ($globalDebug) { |
|
3227 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
3228 | + } |
|
2819 | 3229 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
2820 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
3230 | + if ($globalDebug) { |
|
3231 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
3232 | + } |
|
2821 | 3233 | //$alldata = array(); |
2822 | 3234 | foreach ($dall as $value) { |
2823 | 3235 | $icao = $value['airport_departure_icao']; |
@@ -2838,11 +3250,17 @@ discard block |
||
2838 | 3250 | foreach ($alldata as $number) { |
2839 | 3251 | 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); |
2840 | 3252 | } |
2841 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
3253 | + if ($globalDebug) { |
|
3254 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
3255 | + } |
|
2842 | 3256 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
2843 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
3257 | + if ($globalDebug) { |
|
3258 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
3259 | + } |
|
2844 | 3260 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
2845 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
3261 | + if ($globalDebug) { |
|
3262 | + echo 'Order arrival airports by airlines...'."\n"; |
|
3263 | + } |
|
2846 | 3264 | //$alldata = array(); |
2847 | 3265 | foreach ($dall as $value) { |
2848 | 3266 | $icao = $value['airport_arrival_icao']; |
@@ -2861,37 +3279,53 @@ discard block |
||
2861 | 3279 | } |
2862 | 3280 | $alldata = $pall; |
2863 | 3281 | foreach ($alldata as $number) { |
2864 | - 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); |
|
3282 | + if ($number['airline_icao'] != '') { |
|
3283 | + 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); |
|
3284 | + } |
|
3285 | + } |
|
3286 | + if ($globalDebug) { |
|
3287 | + echo 'Count all flights by months by airlines...'."\n"; |
|
2865 | 3288 | } |
2866 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
2867 | 3289 | $Spotter = new Spotter($this->db); |
2868 | 3290 | $alldata = $Spotter->countAllMonthsByAirlines($filter_last_month); |
2869 | 3291 | $lastyear = false; |
2870 | 3292 | foreach ($alldata as $number) { |
2871 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
3293 | + if ($number['year_name'] != date('Y')) { |
|
3294 | + $lastyear = true; |
|
3295 | + } |
|
2872 | 3296 | $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']); |
2873 | 3297 | } |
2874 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
3298 | + if ($globalDebug) { |
|
3299 | + echo 'Count all owners by months by airlines...'."\n"; |
|
3300 | + } |
|
2875 | 3301 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
2876 | 3302 | foreach ($alldata as $number) { |
2877 | 3303 | $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']); |
2878 | 3304 | } |
2879 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
3305 | + if ($globalDebug) { |
|
3306 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
3307 | + } |
|
2880 | 3308 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
2881 | 3309 | foreach ($alldata as $number) { |
2882 | 3310 | $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']); |
2883 | 3311 | } |
2884 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
3312 | + if ($globalDebug) { |
|
3313 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
3314 | + } |
|
2885 | 3315 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
2886 | 3316 | foreach ($alldata as $number) { |
2887 | 3317 | $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']); |
2888 | 3318 | } |
2889 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
3319 | + if ($globalDebug) { |
|
3320 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
3321 | + } |
|
2890 | 3322 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
2891 | 3323 | foreach ($alldata as $number) { |
2892 | 3324 | $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']); |
2893 | 3325 | } |
2894 | - if ($globalDebug) echo '...Departure'."\n"; |
|
3326 | + if ($globalDebug) { |
|
3327 | + echo '...Departure'."\n"; |
|
3328 | + } |
|
2895 | 3329 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
2896 | 3330 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
2897 | 3331 | foreach ($dall as $value) { |
@@ -2914,7 +3348,9 @@ discard block |
||
2914 | 3348 | foreach ($alldata as $number) { |
2915 | 3349 | $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']); |
2916 | 3350 | } |
2917 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
3351 | + if ($globalDebug) { |
|
3352 | + echo '...Arrival'."\n"; |
|
3353 | + } |
|
2918 | 3354 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
2919 | 3355 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
2920 | 3356 | foreach ($dall as $value) { |
@@ -2938,13 +3374,19 @@ discard block |
||
2938 | 3374 | $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']); |
2939 | 3375 | } |
2940 | 3376 | |
2941 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
2942 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
3377 | + if ($globalDebug) { |
|
3378 | + echo 'Flights data...'."\n"; |
|
3379 | + } |
|
3380 | + if ($globalDebug) { |
|
3381 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
3382 | + } |
|
2943 | 3383 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
2944 | 3384 | foreach ($alldata as $number) { |
2945 | 3385 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
2946 | 3386 | } |
2947 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
3387 | + if ($globalDebug) { |
|
3388 | + echo '-> countAllDates...'."\n"; |
|
3389 | + } |
|
2948 | 3390 | //$previousdata = $this->countAllDatesByAirlines(); |
2949 | 3391 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
2950 | 3392 | $values = array(); |
@@ -2957,14 +3399,18 @@ discard block |
||
2957 | 3399 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
2958 | 3400 | } |
2959 | 3401 | |
2960 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
3402 | + if ($globalDebug) { |
|
3403 | + echo '-> countAllHours...'."\n"; |
|
3404 | + } |
|
2961 | 3405 | $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
2962 | 3406 | foreach ($alldata as $number) { |
2963 | 3407 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
2964 | 3408 | } |
2965 | 3409 | |
2966 | 3410 | // Stats by filters |
2967 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
3411 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
3412 | + $globalStatsFilters = array(); |
|
3413 | + } |
|
2968 | 3414 | foreach ($globalStatsFilters as $name => $filter) { |
2969 | 3415 | if (!empty($filter)) { |
2970 | 3416 | //$filter_name = $filter['name']; |
@@ -2972,7 +3418,9 @@ discard block |
||
2972 | 3418 | $reset = false; |
2973 | 3419 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
2974 | 3420 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
2975 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
3421 | + if ($globalDebug) { |
|
3422 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
3423 | + } |
|
2976 | 3424 | $this->deleteOldStats($filter_name); |
2977 | 3425 | unset($last_update); |
2978 | 3426 | } |
@@ -2989,39 +3437,55 @@ discard block |
||
2989 | 3437 | $reset = true; |
2990 | 3438 | } |
2991 | 3439 | // Count by filter |
2992 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
3440 | + if ($globalDebug) { |
|
3441 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
3442 | + } |
|
2993 | 3443 | $Spotter = new Spotter($this->db); |
2994 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
3444 | + if ($globalDebug) { |
|
3445 | + echo 'Count all aircraft types...'."\n"; |
|
3446 | + } |
|
2995 | 3447 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
2996 | 3448 | foreach ($alldata as $number) { |
2997 | 3449 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
2998 | 3450 | } |
2999 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
3451 | + if ($globalDebug) { |
|
3452 | + echo 'Count all airlines...'."\n"; |
|
3453 | + } |
|
3000 | 3454 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
3001 | 3455 | foreach ($alldata as $number) { |
3002 | 3456 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
3003 | 3457 | } |
3004 | - if ($globalDebug) echo 'Count all aircraft registrations...'."\n"; |
|
3458 | + if ($globalDebug) { |
|
3459 | + echo 'Count all aircraft registrations...'."\n"; |
|
3460 | + } |
|
3005 | 3461 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
3006 | 3462 | foreach ($alldata as $number) { |
3007 | 3463 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
3008 | 3464 | } |
3009 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
3465 | + if ($globalDebug) { |
|
3466 | + echo 'Count all callsigns...'."\n"; |
|
3467 | + } |
|
3010 | 3468 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
3011 | 3469 | foreach ($alldata as $number) { |
3012 | 3470 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
3013 | 3471 | } |
3014 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
3472 | + if ($globalDebug) { |
|
3473 | + echo 'Count all owners...'."\n"; |
|
3474 | + } |
|
3015 | 3475 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
3016 | 3476 | foreach ($alldata as $number) { |
3017 | 3477 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
3018 | 3478 | } |
3019 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
3479 | + if ($globalDebug) { |
|
3480 | + echo 'Count all pilots...'."\n"; |
|
3481 | + } |
|
3020 | 3482 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
3021 | 3483 | foreach ($alldata as $number) { |
3022 | 3484 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
3023 | 3485 | } |
3024 | - if ($globalDebug) echo 'Count departure airports...'."\n"; |
|
3486 | + if ($globalDebug) { |
|
3487 | + echo 'Count departure airports...'."\n"; |
|
3488 | + } |
|
3025 | 3489 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
3026 | 3490 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
3027 | 3491 | $alldata = array(); |
@@ -3033,7 +3497,9 @@ discard block |
||
3033 | 3497 | $icao = $value['airport_departure_icao']; |
3034 | 3498 | if (isset($alldata[$icao])) { |
3035 | 3499 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
3036 | - } else $alldata[$icao] = $value; |
|
3500 | + } else { |
|
3501 | + $alldata[$icao] = $value; |
|
3502 | + } |
|
3037 | 3503 | } |
3038 | 3504 | $count = array(); |
3039 | 3505 | foreach ($alldata as $key => $row) { |
@@ -3043,7 +3509,9 @@ discard block |
||
3043 | 3509 | foreach ($alldata as $number) { |
3044 | 3510 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
3045 | 3511 | } |
3046 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
3512 | + if ($globalDebug) { |
|
3513 | + echo 'Count all arrival airports...'."\n"; |
|
3514 | + } |
|
3047 | 3515 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
3048 | 3516 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
3049 | 3517 | $alldata = array(); |
@@ -3055,7 +3523,9 @@ discard block |
||
3055 | 3523 | $icao = $value['airport_arrival_icao']; |
3056 | 3524 | if (isset($alldata[$icao])) { |
3057 | 3525 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
3058 | - } else $alldata[$icao] = $value; |
|
3526 | + } else { |
|
3527 | + $alldata[$icao] = $value; |
|
3528 | + } |
|
3059 | 3529 | } |
3060 | 3530 | $count = array(); |
3061 | 3531 | foreach ($alldata as $key => $row) { |
@@ -3065,35 +3535,49 @@ discard block |
||
3065 | 3535 | foreach ($alldata as $number) { |
3066 | 3536 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
3067 | 3537 | } |
3068 | - if ($globalDebug) echo 'Count all months...'."\n"; |
|
3538 | + if ($globalDebug) { |
|
3539 | + echo 'Count all months...'."\n"; |
|
3540 | + } |
|
3069 | 3541 | $Spotter = new Spotter($this->db); |
3070 | 3542 | $alldata = $Spotter->countAllMonths($filter); |
3071 | 3543 | $lastyear = false; |
3072 | 3544 | foreach ($alldata as $number) { |
3073 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
3545 | + if ($number['year_name'] != date('Y')) { |
|
3546 | + $lastyear = true; |
|
3547 | + } |
|
3074 | 3548 | $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); |
3075 | 3549 | } |
3076 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
3550 | + if ($globalDebug) { |
|
3551 | + echo 'Count all owners by months...'."\n"; |
|
3552 | + } |
|
3077 | 3553 | $alldata = $Spotter->countAllMonthsOwners($filter); |
3078 | 3554 | foreach ($alldata as $number) { |
3079 | 3555 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3080 | 3556 | } |
3081 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
3557 | + if ($globalDebug) { |
|
3558 | + echo 'Count all pilots by months...'."\n"; |
|
3559 | + } |
|
3082 | 3560 | $alldata = $Spotter->countAllMonthsPilots($filter); |
3083 | 3561 | foreach ($alldata as $number) { |
3084 | 3562 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3085 | 3563 | } |
3086 | - if ($globalDebug) echo 'Count all military by months...'."\n"; |
|
3564 | + if ($globalDebug) { |
|
3565 | + echo 'Count all military by months...'."\n"; |
|
3566 | + } |
|
3087 | 3567 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
3088 | 3568 | foreach ($alldata as $number) { |
3089 | 3569 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3090 | 3570 | } |
3091 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
3571 | + if ($globalDebug) { |
|
3572 | + echo 'Count all aircrafts by months...'."\n"; |
|
3573 | + } |
|
3092 | 3574 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
3093 | 3575 | foreach ($alldata as $number) { |
3094 | 3576 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
3095 | 3577 | } |
3096 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
3578 | + if ($globalDebug) { |
|
3579 | + echo 'Count all real arrivals by months...'."\n"; |
|
3580 | + } |
|
3097 | 3581 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
3098 | 3582 | foreach ($alldata as $number) { |
3099 | 3583 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |