@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct($dbc = null) { |
14 | 14 | global $globalFilterName; |
15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
15 | + if (isset($globalFilterName)) { |
|
16 | + $this->filter_name = $globalFilterName; |
|
17 | + } |
|
16 | 18 | $Connection = new Connection($dbc); |
17 | 19 | $this->db = $Connection->db(); |
18 | 20 | } |
@@ -41,7 +43,9 @@ discard block |
||
41 | 43 | return $all; |
42 | 44 | } |
43 | 45 | public function getAllAirlineNames($filter_name = '') { |
44 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
46 | + if ($filter_name == '') { |
|
47 | + $filter_name = $this->filter_name; |
|
48 | + } |
|
45 | 49 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
46 | 50 | try { |
47 | 51 | $sth = $this->db->prepare($query); |
@@ -53,7 +57,9 @@ discard block |
||
53 | 57 | return $all; |
54 | 58 | } |
55 | 59 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
56 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
60 | + if ($filter_name == '') { |
|
61 | + $filter_name = $this->filter_name; |
|
62 | + } |
|
57 | 63 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
58 | 64 | try { |
59 | 65 | $sth = $this->db->prepare($query); |
@@ -65,7 +71,9 @@ discard block |
||
65 | 71 | return $all; |
66 | 72 | } |
67 | 73 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
68 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
74 | + if ($filter_name == '') { |
|
75 | + $filter_name = $this->filter_name; |
|
76 | + } |
|
69 | 77 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
70 | 78 | try { |
71 | 79 | $sth = $this->db->prepare($query); |
@@ -77,7 +85,9 @@ discard block |
||
77 | 85 | return $all; |
78 | 86 | } |
79 | 87 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
80 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
88 | + if ($filter_name == '') { |
|
89 | + $filter_name = $this->filter_name; |
|
90 | + } |
|
81 | 91 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
82 | 92 | try { |
83 | 93 | $sth = $this->db->prepare($query); |
@@ -92,9 +102,14 @@ discard block |
||
92 | 102 | |
93 | 103 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
94 | 104 | global $globalStatsFilters; |
95 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
96 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
97 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
105 | + if ($filter_name == '') { |
|
106 | + $filter_name = $this->filter_name; |
|
107 | + } |
|
108 | + if ($limit) { |
|
109 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
110 | + } else { |
|
111 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
112 | + } |
|
98 | 113 | try { |
99 | 114 | $sth = $this->db->prepare($query); |
100 | 115 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -114,9 +129,14 @@ discard block |
||
114 | 129 | } |
115 | 130 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
116 | 131 | global $globalStatsFilters; |
117 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
118 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
119 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
132 | + if ($filter_name == '') { |
|
133 | + $filter_name = $this->filter_name; |
|
134 | + } |
|
135 | + if ($limit) { |
|
136 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
137 | + } else { |
|
138 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
139 | + } |
|
120 | 140 | try { |
121 | 141 | $sth = $this->db->prepare($query); |
122 | 142 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -136,9 +156,14 @@ discard block |
||
136 | 156 | } |
137 | 157 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
138 | 158 | global $globalStatsFilters; |
139 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
140 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
141 | - 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"; |
|
159 | + if ($filter_name == '') { |
|
160 | + $filter_name = $this->filter_name; |
|
161 | + } |
|
162 | + if ($limit) { |
|
163 | + $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"; |
|
164 | + } else { |
|
165 | + $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"; |
|
166 | + } |
|
142 | 167 | try { |
143 | 168 | $sth = $this->db->prepare($query); |
144 | 169 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -159,9 +184,14 @@ discard block |
||
159 | 184 | |
160 | 185 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
161 | 186 | global $globalStatsFilters; |
162 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
163 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
164 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
187 | + if ($filter_name == '') { |
|
188 | + $filter_name = $this->filter_name; |
|
189 | + } |
|
190 | + if ($limit) { |
|
191 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
192 | + } else { |
|
193 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
194 | + } |
|
165 | 195 | try { |
166 | 196 | $sth = $this->db->prepare($query); |
167 | 197 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -181,9 +211,14 @@ discard block |
||
181 | 211 | } |
182 | 212 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
183 | 213 | global $globalStatsFilters; |
184 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
185 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
186 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
214 | + if ($filter_name == '') { |
|
215 | + $filter_name = $this->filter_name; |
|
216 | + } |
|
217 | + if ($limit) { |
|
218 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
219 | + } else { |
|
220 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
221 | + } |
|
187 | 222 | try { |
188 | 223 | $sth = $this->db->prepare($query); |
189 | 224 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -204,9 +239,14 @@ discard block |
||
204 | 239 | |
205 | 240 | public function countAllAirlines($limit = true,$filter_name = '') { |
206 | 241 | global $globalStatsFilters; |
207 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
208 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
209 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
|
242 | + if ($filter_name == '') { |
|
243 | + $filter_name = $this->filter_name; |
|
244 | + } |
|
245 | + if ($limit) { |
|
246 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
247 | + } else { |
|
248 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
|
249 | + } |
|
210 | 250 | try { |
211 | 251 | $sth = $this->db->prepare($query); |
212 | 252 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -227,9 +267,14 @@ discard block |
||
227 | 267 | } |
228 | 268 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
229 | 269 | global $globalStatsFilters; |
230 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
231 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
232 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
270 | + if ($filter_name == '') { |
|
271 | + $filter_name = $this->filter_name; |
|
272 | + } |
|
273 | + if ($limit) { |
|
274 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
275 | + } else { |
|
276 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
277 | + } |
|
233 | 278 | try { |
234 | 279 | $sth = $this->db->prepare($query); |
235 | 280 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -249,9 +294,14 @@ discard block |
||
249 | 294 | } |
250 | 295 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
251 | 296 | global $globalStatsFilters; |
252 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
253 | - 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"; |
|
254 | - 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"; |
|
297 | + if ($filter_name == '') { |
|
298 | + $filter_name = $this->filter_name; |
|
299 | + } |
|
300 | + if ($limit) { |
|
301 | + $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"; |
|
302 | + } else { |
|
303 | + $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"; |
|
304 | + } |
|
255 | 305 | try { |
256 | 306 | $sth = $this->db->prepare($query); |
257 | 307 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -271,10 +321,15 @@ discard block |
||
271 | 321 | } |
272 | 322 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
273 | 323 | $Connection = new Connection(); |
274 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
324 | + if ($filter_name == '') { |
|
325 | + $filter_name = $this->filter_name; |
|
326 | + } |
|
275 | 327 | if ($Connection->tableExists('countries')) { |
276 | - 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"; |
|
277 | - 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"; |
|
328 | + if ($limit) { |
|
329 | + $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"; |
|
330 | + } else { |
|
331 | + $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"; |
|
332 | + } |
|
278 | 333 | try { |
279 | 334 | $sth = $this->db->prepare($query); |
280 | 335 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -295,9 +350,14 @@ discard block |
||
295 | 350 | } |
296 | 351 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
297 | 352 | global $globalStatsFilters; |
298 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
299 | - 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"; |
|
300 | - 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"; |
|
353 | + if ($filter_name == '') { |
|
354 | + $filter_name = $this->filter_name; |
|
355 | + } |
|
356 | + if ($limit) { |
|
357 | + $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"; |
|
358 | + } else { |
|
359 | + $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"; |
|
360 | + } |
|
301 | 361 | try { |
302 | 362 | $sth = $this->db->prepare($query); |
303 | 363 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -317,9 +377,14 @@ discard block |
||
317 | 377 | } |
318 | 378 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
319 | 379 | global $globalStatsFilters; |
320 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
321 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
322 | - 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"; |
|
380 | + if ($filter_name == '') { |
|
381 | + $filter_name = $this->filter_name; |
|
382 | + } |
|
383 | + if ($limit) { |
|
384 | + $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"; |
|
385 | + } else { |
|
386 | + $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"; |
|
387 | + } |
|
323 | 388 | try { |
324 | 389 | $sth = $this->db->prepare($query); |
325 | 390 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -339,9 +404,14 @@ discard block |
||
339 | 404 | } |
340 | 405 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
341 | 406 | global $globalStatsFilters; |
342 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
343 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
344 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
407 | + if ($filter_name == '') { |
|
408 | + $filter_name = $this->filter_name; |
|
409 | + } |
|
410 | + if ($limit) { |
|
411 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
412 | + } else { |
|
413 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
414 | + } |
|
345 | 415 | try { |
346 | 416 | $sth = $this->db->prepare($query); |
347 | 417 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -367,7 +437,9 @@ discard block |
||
367 | 437 | $icao = $value['airport_departure_icao']; |
368 | 438 | if (isset($all[$icao])) { |
369 | 439 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
370 | - } else $all[$icao] = $value; |
|
440 | + } else { |
|
441 | + $all[$icao] = $value; |
|
442 | + } |
|
371 | 443 | } |
372 | 444 | $count = array(); |
373 | 445 | foreach ($all as $key => $row) { |
@@ -379,9 +451,14 @@ discard block |
||
379 | 451 | } |
380 | 452 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
381 | 453 | global $globalStatsFilters; |
382 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
383 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
384 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
454 | + if ($filter_name == '') { |
|
455 | + $filter_name = $this->filter_name; |
|
456 | + } |
|
457 | + if ($limit) { |
|
458 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
459 | + } else { |
|
460 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
461 | + } |
|
385 | 462 | try { |
386 | 463 | $sth = $this->db->prepare($query); |
387 | 464 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -407,7 +484,9 @@ discard block |
||
407 | 484 | $icao = $value['airport_arrival_icao']; |
408 | 485 | if (isset($all[$icao])) { |
409 | 486 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
410 | - } else $all[$icao] = $value; |
|
487 | + } else { |
|
488 | + $all[$icao] = $value; |
|
489 | + } |
|
411 | 490 | } |
412 | 491 | $count = array(); |
413 | 492 | foreach ($all as $key => $row) { |
@@ -420,13 +499,21 @@ discard block |
||
420 | 499 | } |
421 | 500 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
422 | 501 | global $globalDBdriver, $globalStatsFilters; |
423 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
502 | + if ($filter_name == '') { |
|
503 | + $filter_name = $this->filter_name; |
|
504 | + } |
|
424 | 505 | if ($globalDBdriver == 'mysql') { |
425 | - 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"; |
|
426 | - 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"; |
|
506 | + if ($limit) { |
|
507 | + $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"; |
|
508 | + } else { |
|
509 | + $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"; |
|
510 | + } |
|
427 | 511 | } else { |
428 | - 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"; |
|
429 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
512 | + if ($limit) { |
|
513 | + $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"; |
|
514 | + } else { |
|
515 | + $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"; |
|
516 | + } |
|
430 | 517 | } |
431 | 518 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
432 | 519 | try { |
@@ -450,7 +537,9 @@ discard block |
||
450 | 537 | |
451 | 538 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
452 | 539 | global $globalStatsFilters; |
453 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
540 | + if ($filter_name == '') { |
|
541 | + $filter_name = $this->filter_name; |
|
542 | + } |
|
454 | 543 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
455 | 544 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
456 | 545 | try { |
@@ -472,7 +561,9 @@ discard block |
||
472 | 561 | } |
473 | 562 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
474 | 563 | global $globalDBdriver, $globalStatsFilters; |
475 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
564 | + if ($filter_name == '') { |
|
565 | + $filter_name = $this->filter_name; |
|
566 | + } |
|
476 | 567 | if ($globalDBdriver == 'mysql') { |
477 | 568 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
478 | 569 | } else { |
@@ -498,7 +589,9 @@ discard block |
||
498 | 589 | } |
499 | 590 | public function countAllDates($stats_airline = '',$filter_name = '') { |
500 | 591 | global $globalStatsFilters; |
501 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
592 | + if ($filter_name == '') { |
|
593 | + $filter_name = $this->filter_name; |
|
594 | + } |
|
502 | 595 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
503 | 596 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
504 | 597 | try { |
@@ -520,7 +613,9 @@ discard block |
||
520 | 613 | } |
521 | 614 | public function countAllDatesByAirlines($filter_name = '') { |
522 | 615 | global $globalStatsFilters; |
523 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
616 | + if ($filter_name == '') { |
|
617 | + $filter_name = $this->filter_name; |
|
618 | + } |
|
524 | 619 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
525 | 620 | $query_data = array('filter_name' => $filter_name); |
526 | 621 | try { |
@@ -542,7 +637,9 @@ discard block |
||
542 | 637 | } |
543 | 638 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
544 | 639 | global $globalStatsFilters; |
545 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
640 | + if ($filter_name == '') { |
|
641 | + $filter_name = $this->filter_name; |
|
642 | + } |
|
546 | 643 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
547 | 644 | try { |
548 | 645 | $sth = $this->db->prepare($query); |
@@ -563,7 +660,9 @@ discard block |
||
563 | 660 | } |
564 | 661 | public function countAllMilitaryMonths($filter_name = '') { |
565 | 662 | global $globalStatsFilters; |
566 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
663 | + if ($filter_name == '') { |
|
664 | + $filter_name = $this->filter_name; |
|
665 | + } |
|
567 | 666 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
568 | 667 | try { |
569 | 668 | $sth = $this->db->prepare($query); |
@@ -584,9 +683,14 @@ discard block |
||
584 | 683 | } |
585 | 684 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
586 | 685 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
587 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
588 | - 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"; |
|
589 | - 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"; |
|
686 | + if ($filter_name == '') { |
|
687 | + $filter_name = $this->filter_name; |
|
688 | + } |
|
689 | + if ($limit) { |
|
690 | + $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"; |
|
691 | + } else { |
|
692 | + $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"; |
|
693 | + } |
|
590 | 694 | if ($orderby == 'hour') { |
591 | 695 | /* |
592 | 696 | if ($globalDBdriver == 'mysql') { |
@@ -595,7 +699,9 @@ discard block |
||
595 | 699 | */ |
596 | 700 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
597 | 701 | } |
598 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
702 | + if ($orderby == 'count') { |
|
703 | + $query .= " ORDER BY hour_count DESC"; |
|
704 | + } |
|
599 | 705 | try { |
600 | 706 | $sth = $this->db->prepare($query); |
601 | 707 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -616,7 +722,9 @@ discard block |
||
616 | 722 | |
617 | 723 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
618 | 724 | global $globalStatsFilters; |
619 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
725 | + if ($filter_name == '') { |
|
726 | + $filter_name = $this->filter_name; |
|
727 | + } |
|
620 | 728 | $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
621 | 729 | if (empty($all)) { |
622 | 730 | $filters = array('airlines' => array($stats_airline)); |
@@ -630,7 +738,9 @@ discard block |
||
630 | 738 | } |
631 | 739 | public function countOverallMilitaryFlights($filter_name = '') { |
632 | 740 | global $globalStatsFilters; |
633 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
741 | + if ($filter_name == '') { |
|
742 | + $filter_name = $this->filter_name; |
|
743 | + } |
|
634 | 744 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
635 | 745 | if (empty($all)) { |
636 | 746 | $filters = array(); |
@@ -644,7 +754,9 @@ discard block |
||
644 | 754 | } |
645 | 755 | public function countOverallArrival($stats_airline = '',$filter_name = '') { |
646 | 756 | global $globalStatsFilters; |
647 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
757 | + if ($filter_name == '') { |
|
758 | + $filter_name = $this->filter_name; |
|
759 | + } |
|
648 | 760 | $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
649 | 761 | if (empty($all)) { |
650 | 762 | $filters = array('airlines' => array($stats_airline)); |
@@ -658,7 +770,9 @@ discard block |
||
658 | 770 | } |
659 | 771 | public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
660 | 772 | global $globalStatsFilters; |
661 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
773 | + if ($filter_name == '') { |
|
774 | + $filter_name = $this->filter_name; |
|
775 | + } |
|
662 | 776 | $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
663 | 777 | if (empty($all)) { |
664 | 778 | $filters = array('airlines' => array($stats_airline)); |
@@ -672,7 +786,9 @@ discard block |
||
672 | 786 | } |
673 | 787 | public function countOverallAirlines($filter_name = '') { |
674 | 788 | global $globalStatsFilters; |
675 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
789 | + if ($filter_name == '') { |
|
790 | + $filter_name = $this->filter_name; |
|
791 | + } |
|
676 | 792 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
677 | 793 | try { |
678 | 794 | $sth = $this->db->prepare($query); |
@@ -695,7 +811,9 @@ discard block |
||
695 | 811 | } |
696 | 812 | public function countOverallOwners($stats_airline = '',$filter_name = '') { |
697 | 813 | global $globalStatsFilters; |
698 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
814 | + if ($filter_name == '') { |
|
815 | + $filter_name = $this->filter_name; |
|
816 | + } |
|
699 | 817 | /* |
700 | 818 | $query = "SELECT COUNT(*) AS nb_owner FROM stats_owner"; |
701 | 819 | try { |
@@ -720,7 +838,9 @@ discard block |
||
720 | 838 | } |
721 | 839 | public function countOverallPilots($stats_airline = '',$filter_name = '') { |
722 | 840 | global $globalStatsFilters; |
723 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
841 | + if ($filter_name == '') { |
|
842 | + $filter_name = $this->filter_name; |
|
843 | + } |
|
724 | 844 | $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
725 | 845 | if (empty($all)) { |
726 | 846 | $filters = array('airlines' => array($stats_airline)); |
@@ -734,7 +854,9 @@ discard block |
||
734 | 854 | } |
735 | 855 | |
736 | 856 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
737 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
857 | + if ($filter_name == '') { |
|
858 | + $filter_name = $this->filter_name; |
|
859 | + } |
|
738 | 860 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
739 | 861 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
740 | 862 | try { |
@@ -747,7 +869,9 @@ discard block |
||
747 | 869 | return $all; |
748 | 870 | } |
749 | 871 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
750 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
872 | + if ($filter_name == '') { |
|
873 | + $filter_name = $this->filter_name; |
|
874 | + } |
|
751 | 875 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
752 | 876 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
753 | 877 | try { |
@@ -760,7 +884,9 @@ discard block |
||
760 | 884 | return $all; |
761 | 885 | } |
762 | 886 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
763 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
887 | + if ($filter_name == '') { |
|
888 | + $filter_name = $this->filter_name; |
|
889 | + } |
|
764 | 890 | global $globalArchiveMonths, $globalDBdriver; |
765 | 891 | if ($globalDBdriver == 'mysql') { |
766 | 892 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -779,7 +905,9 @@ discard block |
||
779 | 905 | } |
780 | 906 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
781 | 907 | global $globalArchiveMonths, $globalDBdriver; |
782 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
908 | + if ($filter_name == '') { |
|
909 | + $filter_name = $this->filter_name; |
|
910 | + } |
|
783 | 911 | if ($globalDBdriver == 'mysql') { |
784 | 912 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
785 | 913 | } else { |
@@ -797,7 +925,9 @@ discard block |
||
797 | 925 | } |
798 | 926 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
799 | 927 | global $globalArchiveMonths, $globalDBdriver; |
800 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
928 | + if ($filter_name == '') { |
|
929 | + $filter_name = $this->filter_name; |
|
930 | + } |
|
801 | 931 | if ($globalDBdriver == 'mysql') { |
802 | 932 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
803 | 933 | } else { |
@@ -814,7 +944,9 @@ discard block |
||
814 | 944 | } |
815 | 945 | public function getStatsAirlineTotal($filter_name = '') { |
816 | 946 | global $globalArchiveMonths, $globalDBdriver; |
817 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
947 | + if ($filter_name == '') { |
|
948 | + $filter_name = $this->filter_name; |
|
949 | + } |
|
818 | 950 | if ($globalDBdriver == 'mysql') { |
819 | 951 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
820 | 952 | } else { |
@@ -831,7 +963,9 @@ discard block |
||
831 | 963 | } |
832 | 964 | public function getStatsOwnerTotal($filter_name = '') { |
833 | 965 | global $globalArchiveMonths, $globalDBdriver; |
834 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
966 | + if ($filter_name == '') { |
|
967 | + $filter_name = $this->filter_name; |
|
968 | + } |
|
835 | 969 | if ($globalDBdriver == 'mysql') { |
836 | 970 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
837 | 971 | } else { |
@@ -848,7 +982,9 @@ discard block |
||
848 | 982 | } |
849 | 983 | public function getStatsPilotTotal($filter_name = '') { |
850 | 984 | global $globalArchiveMonths, $globalDBdriver; |
851 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
985 | + if ($filter_name == '') { |
|
986 | + $filter_name = $this->filter_name; |
|
987 | + } |
|
852 | 988 | if ($globalDBdriver == 'mysql') { |
853 | 989 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
854 | 990 | } else { |
@@ -866,7 +1002,9 @@ discard block |
||
866 | 1002 | |
867 | 1003 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
868 | 1004 | global $globalDBdriver; |
869 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1005 | + if ($filter_name == '') { |
|
1006 | + $filter_name = $this->filter_name; |
|
1007 | + } |
|
870 | 1008 | if ($globalDBdriver == 'mysql') { |
871 | 1009 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
872 | 1010 | } else { |
@@ -882,7 +1020,9 @@ discard block |
||
882 | 1020 | } |
883 | 1021 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
884 | 1022 | global $globalDBdriver; |
885 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1023 | + if ($filter_name == '') { |
|
1024 | + $filter_name = $this->filter_name; |
|
1025 | + } |
|
886 | 1026 | if ($globalDBdriver == 'mysql') { |
887 | 1027 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
888 | 1028 | } else { |
@@ -1365,47 +1505,69 @@ discard block |
||
1365 | 1505 | $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
1366 | 1506 | } else { |
1367 | 1507 | */ |
1368 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1369 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1508 | + if ($globalDebug) { |
|
1509 | + echo 'Update stats !'."\n"; |
|
1510 | + } |
|
1511 | + if ($globalDebug) { |
|
1512 | + echo 'Count all aircraft types...'."\n"; |
|
1513 | + } |
|
1370 | 1514 | if (isset($last_update[0]['value'])) { |
1371 | 1515 | $last_update_day = $last_update[0]['value']; |
1372 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1516 | + } else { |
|
1517 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1518 | + } |
|
1373 | 1519 | $Spotter = new Spotter($this->db); |
1374 | 1520 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1375 | 1521 | foreach ($alldata as $number) { |
1376 | 1522 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
1377 | 1523 | } |
1378 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1524 | + if ($globalDebug) { |
|
1525 | + echo 'Count all airlines...'."\n"; |
|
1526 | + } |
|
1379 | 1527 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1380 | 1528 | foreach ($alldata as $number) { |
1381 | 1529 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
1382 | 1530 | } |
1383 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1531 | + if ($globalDebug) { |
|
1532 | + echo 'Count all registrations...'."\n"; |
|
1533 | + } |
|
1384 | 1534 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1385 | 1535 | foreach ($alldata as $number) { |
1386 | 1536 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
1387 | 1537 | } |
1388 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1538 | + if ($globalDebug) { |
|
1539 | + echo 'Count all callsigns...'."\n"; |
|
1540 | + } |
|
1389 | 1541 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1390 | 1542 | foreach ($alldata as $number) { |
1391 | 1543 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1392 | 1544 | } |
1393 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1545 | + if ($globalDebug) { |
|
1546 | + echo 'Count all owners...'."\n"; |
|
1547 | + } |
|
1394 | 1548 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1395 | 1549 | foreach ($alldata as $number) { |
1396 | 1550 | $this->addStatOwner($number['owner_name'],$number['owner_count']); |
1397 | 1551 | } |
1398 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1552 | + if ($globalDebug) { |
|
1553 | + echo 'Count all pilots...'."\n"; |
|
1554 | + } |
|
1399 | 1555 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1400 | 1556 | foreach ($alldata as $number) { |
1401 | 1557 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name']); |
1402 | 1558 | } |
1403 | 1559 | |
1404 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1560 | + if ($globalDebug) { |
|
1561 | + echo 'Count all departure airports...'."\n"; |
|
1562 | + } |
|
1405 | 1563 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1406 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1564 | + if ($globalDebug) { |
|
1565 | + echo 'Count all detected departure airports...'."\n"; |
|
1566 | + } |
|
1407 | 1567 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1408 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1568 | + if ($globalDebug) { |
|
1569 | + echo 'Order departure airports...'."\n"; |
|
1570 | + } |
|
1409 | 1571 | $alldata = array(); |
1410 | 1572 | |
1411 | 1573 | foreach ($pall as $value) { |
@@ -1416,7 +1578,9 @@ discard block |
||
1416 | 1578 | $icao = $value['airport_departure_icao']; |
1417 | 1579 | if (isset($alldata[$icao])) { |
1418 | 1580 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1419 | - } else $alldata[$icao] = $value; |
|
1581 | + } else { |
|
1582 | + $alldata[$icao] = $value; |
|
1583 | + } |
|
1420 | 1584 | } |
1421 | 1585 | $count = array(); |
1422 | 1586 | foreach ($alldata as $key => $row) { |
@@ -1426,11 +1590,17 @@ discard block |
||
1426 | 1590 | foreach ($alldata as $number) { |
1427 | 1591 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
1428 | 1592 | } |
1429 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1593 | + if ($globalDebug) { |
|
1594 | + echo 'Count all arrival airports...'."\n"; |
|
1595 | + } |
|
1430 | 1596 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1431 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1597 | + if ($globalDebug) { |
|
1598 | + echo 'Count all detected arrival airports...'."\n"; |
|
1599 | + } |
|
1432 | 1600 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1433 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1601 | + if ($globalDebug) { |
|
1602 | + echo 'Order arrival airports...'."\n"; |
|
1603 | + } |
|
1434 | 1604 | $alldata = array(); |
1435 | 1605 | foreach ($pall as $value) { |
1436 | 1606 | $icao = $value['airport_arrival_icao']; |
@@ -1440,7 +1610,9 @@ discard block |
||
1440 | 1610 | $icao = $value['airport_arrival_icao']; |
1441 | 1611 | if (isset($alldata[$icao])) { |
1442 | 1612 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1443 | - } else $alldata[$icao] = $value; |
|
1613 | + } else { |
|
1614 | + $alldata[$icao] = $value; |
|
1615 | + } |
|
1444 | 1616 | } |
1445 | 1617 | $count = array(); |
1446 | 1618 | foreach ($alldata as $key => $row) { |
@@ -1451,7 +1623,9 @@ discard block |
||
1451 | 1623 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1452 | 1624 | } |
1453 | 1625 | if ($Connection->tableExists('countries')) { |
1454 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1626 | + if ($globalDebug) { |
|
1627 | + echo 'Count all flights by countries...'."\n"; |
|
1628 | + } |
|
1455 | 1629 | $SpotterArchive = new SpotterArchive(); |
1456 | 1630 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1457 | 1631 | foreach ($alldata as $number) { |
@@ -1463,46 +1637,66 @@ discard block |
||
1463 | 1637 | // Add by month using getstat if month finish... |
1464 | 1638 | |
1465 | 1639 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1466 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1640 | + if ($globalDebug) { |
|
1641 | + echo 'Count all flights by months...'."\n"; |
|
1642 | + } |
|
1467 | 1643 | $Spotter = new Spotter($this->db); |
1468 | 1644 | $alldata = $Spotter->countAllMonths(); |
1469 | 1645 | $lastyear = false; |
1470 | 1646 | foreach ($alldata as $number) { |
1471 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1647 | + if ($number['year_name'] != date('Y')) { |
|
1648 | + $lastyear = true; |
|
1649 | + } |
|
1472 | 1650 | $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']))); |
1473 | 1651 | } |
1474 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1652 | + if ($globalDebug) { |
|
1653 | + echo 'Count all military flights by months...'."\n"; |
|
1654 | + } |
|
1475 | 1655 | $alldata = $Spotter->countAllMilitaryMonths(); |
1476 | 1656 | foreach ($alldata as $number) { |
1477 | 1657 | $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']))); |
1478 | 1658 | } |
1479 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1659 | + if ($globalDebug) { |
|
1660 | + echo 'Count all owners by months...'."\n"; |
|
1661 | + } |
|
1480 | 1662 | $alldata = $Spotter->countAllMonthsOwners(); |
1481 | 1663 | foreach ($alldata as $number) { |
1482 | 1664 | $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']))); |
1483 | 1665 | } |
1484 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1666 | + if ($globalDebug) { |
|
1667 | + echo 'Count all pilots by months...'."\n"; |
|
1668 | + } |
|
1485 | 1669 | $alldata = $Spotter->countAllMonthsPilots(); |
1486 | 1670 | foreach ($alldata as $number) { |
1487 | 1671 | $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']))); |
1488 | 1672 | } |
1489 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1673 | + if ($globalDebug) { |
|
1674 | + echo 'Count all airlines by months...'."\n"; |
|
1675 | + } |
|
1490 | 1676 | $alldata = $Spotter->countAllMonthsAirlines(); |
1491 | 1677 | foreach ($alldata as $number) { |
1492 | 1678 | $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']))); |
1493 | 1679 | } |
1494 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1680 | + if ($globalDebug) { |
|
1681 | + echo 'Count all aircrafts by months...'."\n"; |
|
1682 | + } |
|
1495 | 1683 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1496 | 1684 | foreach ($alldata as $number) { |
1497 | 1685 | $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']))); |
1498 | 1686 | } |
1499 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1687 | + if ($globalDebug) { |
|
1688 | + echo 'Count all real arrivals by months...'."\n"; |
|
1689 | + } |
|
1500 | 1690 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1501 | 1691 | foreach ($alldata as $number) { |
1502 | 1692 | $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']))); |
1503 | 1693 | } |
1504 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1505 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1694 | + if ($globalDebug) { |
|
1695 | + echo 'Airports data...'."\n"; |
|
1696 | + } |
|
1697 | + if ($globalDebug) { |
|
1698 | + echo '...Departure'."\n"; |
|
1699 | + } |
|
1506 | 1700 | $this->deleteStatAirport('daily'); |
1507 | 1701 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1508 | 1702 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1622,37 +1816,53 @@ discard block |
||
1622 | 1816 | |
1623 | 1817 | // Count by airlines |
1624 | 1818 | echo '--- Stats by airlines ---'."\n"; |
1625 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
1819 | + if ($globalDebug) { |
|
1820 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
1821 | + } |
|
1626 | 1822 | $Spotter = new Spotter($this->db); |
1627 | 1823 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1628 | 1824 | foreach ($alldata as $number) { |
1629 | 1825 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
1630 | 1826 | } |
1631 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1827 | + if ($globalDebug) { |
|
1828 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1829 | + } |
|
1632 | 1830 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1633 | 1831 | foreach ($alldata as $number) { |
1634 | 1832 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
1635 | 1833 | } |
1636 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
1834 | + if ($globalDebug) { |
|
1835 | + echo 'Count all callsigns by airlines...'."\n"; |
|
1836 | + } |
|
1637 | 1837 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1638 | 1838 | foreach ($alldata as $number) { |
1639 | 1839 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1640 | 1840 | } |
1641 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
1841 | + if ($globalDebug) { |
|
1842 | + echo 'Count all owners by airlines...'."\n"; |
|
1843 | + } |
|
1642 | 1844 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1643 | 1845 | foreach ($alldata as $number) { |
1644 | 1846 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
1645 | 1847 | } |
1646 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
1848 | + if ($globalDebug) { |
|
1849 | + echo 'Count all pilots by airlines...'."\n"; |
|
1850 | + } |
|
1647 | 1851 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1648 | 1852 | foreach ($alldata as $number) { |
1649 | 1853 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao']); |
1650 | 1854 | } |
1651 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
1855 | + if ($globalDebug) { |
|
1856 | + echo 'Count all departure airports by airlines...'."\n"; |
|
1857 | + } |
|
1652 | 1858 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1653 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
1859 | + if ($globalDebug) { |
|
1860 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
1861 | + } |
|
1654 | 1862 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1655 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
1863 | + if ($globalDebug) { |
|
1864 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
1865 | + } |
|
1656 | 1866 | //$alldata = array(); |
1657 | 1867 | foreach ($dall as $value) { |
1658 | 1868 | $icao = $value['airport_departure_icao']; |
@@ -1673,11 +1883,17 @@ discard block |
||
1673 | 1883 | foreach ($alldata as $number) { |
1674 | 1884 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao']); |
1675 | 1885 | } |
1676 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
1886 | + if ($globalDebug) { |
|
1887 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
1888 | + } |
|
1677 | 1889 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1678 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1890 | + if ($globalDebug) { |
|
1891 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1892 | + } |
|
1679 | 1893 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1680 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
1894 | + if ($globalDebug) { |
|
1895 | + echo 'Order arrival airports by airlines...'."\n"; |
|
1896 | + } |
|
1681 | 1897 | //$alldata = array(); |
1682 | 1898 | foreach ($dall as $value) { |
1683 | 1899 | $icao = $value['airport_arrival_icao']; |
@@ -1698,35 +1914,49 @@ discard block |
||
1698 | 1914 | foreach ($alldata as $number) { |
1699 | 1915 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao']); |
1700 | 1916 | } |
1701 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1917 | + if ($globalDebug) { |
|
1918 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1919 | + } |
|
1702 | 1920 | $Spotter = new Spotter($this->db); |
1703 | 1921 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1704 | 1922 | $lastyear = false; |
1705 | 1923 | foreach ($alldata as $number) { |
1706 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1924 | + if ($number['year_name'] != date('Y')) { |
|
1925 | + $lastyear = true; |
|
1926 | + } |
|
1707 | 1927 | $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']); |
1708 | 1928 | } |
1709 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
1929 | + if ($globalDebug) { |
|
1930 | + echo 'Count all owners by months by airlines...'."\n"; |
|
1931 | + } |
|
1710 | 1932 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1711 | 1933 | foreach ($alldata as $number) { |
1712 | 1934 | $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']); |
1713 | 1935 | } |
1714 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
1936 | + if ($globalDebug) { |
|
1937 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
1938 | + } |
|
1715 | 1939 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1716 | 1940 | foreach ($alldata as $number) { |
1717 | 1941 | $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']); |
1718 | 1942 | } |
1719 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1943 | + if ($globalDebug) { |
|
1944 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1945 | + } |
|
1720 | 1946 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1721 | 1947 | foreach ($alldata as $number) { |
1722 | 1948 | $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']); |
1723 | 1949 | } |
1724 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1950 | + if ($globalDebug) { |
|
1951 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1952 | + } |
|
1725 | 1953 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1726 | 1954 | foreach ($alldata as $number) { |
1727 | 1955 | $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']); |
1728 | 1956 | } |
1729 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1957 | + if ($globalDebug) { |
|
1958 | + echo '...Departure'."\n"; |
|
1959 | + } |
|
1730 | 1960 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1731 | 1961 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1732 | 1962 | foreach ($dall as $value) { |
@@ -1749,7 +1979,9 @@ discard block |
||
1749 | 1979 | foreach ($alldata as $number) { |
1750 | 1980 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
1751 | 1981 | } |
1752 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
1982 | + if ($globalDebug) { |
|
1983 | + echo '...Arrival'."\n"; |
|
1984 | + } |
|
1753 | 1985 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1754 | 1986 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1755 | 1987 | foreach ($dall as $value) { |
@@ -1773,13 +2005,19 @@ discard block |
||
1773 | 2005 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
1774 | 2006 | } |
1775 | 2007 | |
1776 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1777 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2008 | + if ($globalDebug) { |
|
2009 | + echo 'Flights data...'."\n"; |
|
2010 | + } |
|
2011 | + if ($globalDebug) { |
|
2012 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2013 | + } |
|
1778 | 2014 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1779 | 2015 | foreach ($alldata as $number) { |
1780 | 2016 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1781 | 2017 | } |
1782 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2018 | + if ($globalDebug) { |
|
2019 | + echo '-> countAllDates...'."\n"; |
|
2020 | + } |
|
1783 | 2021 | //$previousdata = $this->countAllDatesByAirlines(); |
1784 | 2022 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1785 | 2023 | $values = array(); |
@@ -1792,19 +2030,25 @@ discard block |
||
1792 | 2030 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1793 | 2031 | } |
1794 | 2032 | |
1795 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2033 | + if ($globalDebug) { |
|
2034 | + echo '-> countAllHours...'."\n"; |
|
2035 | + } |
|
1796 | 2036 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1797 | 2037 | foreach ($alldata as $number) { |
1798 | 2038 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
1799 | 2039 | } |
1800 | 2040 | |
1801 | 2041 | |
1802 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2042 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2043 | + $globalStatsFilters = array(); |
|
2044 | + } |
|
1803 | 2045 | foreach ($globalStatsFilters as $name => $filter) { |
1804 | 2046 | //$filter_name = $filter['name']; |
1805 | 2047 | $filter_name = $name; |
1806 | 2048 | // Count by filter |
1807 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2049 | + if ($globalDebug) { |
|
2050 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2051 | + } |
|
1808 | 2052 | $Spotter = new Spotter($this->db); |
1809 | 2053 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
1810 | 2054 | foreach ($alldata as $number) { |
@@ -1842,7 +2086,9 @@ discard block |
||
1842 | 2086 | $icao = $value['airport_departure_icao']; |
1843 | 2087 | if (isset($alldata[$icao])) { |
1844 | 2088 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1845 | - } else $alldata[$icao] = $value; |
|
2089 | + } else { |
|
2090 | + $alldata[$icao] = $value; |
|
2091 | + } |
|
1846 | 2092 | } |
1847 | 2093 | $count = array(); |
1848 | 2094 | foreach ($alldata as $key => $row) { |
@@ -1863,7 +2109,9 @@ discard block |
||
1863 | 2109 | $icao = $value['airport_arrival_icao']; |
1864 | 2110 | if (isset($alldata[$icao])) { |
1865 | 2111 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1866 | - } else $alldata[$icao] = $value; |
|
2112 | + } else { |
|
2113 | + $alldata[$icao] = $value; |
|
2114 | + } |
|
1867 | 2115 | } |
1868 | 2116 | $count = array(); |
1869 | 2117 | foreach ($alldata as $key => $row) { |
@@ -1877,7 +2125,9 @@ discard block |
||
1877 | 2125 | $alldata = $Spotter->countAllMonths($filter); |
1878 | 2126 | $lastyear = false; |
1879 | 2127 | foreach ($alldata as $number) { |
1880 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2128 | + if ($number['year_name'] != date('Y')) { |
|
2129 | + $lastyear = true; |
|
2130 | + } |
|
1881 | 2131 | $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); |
1882 | 2132 | } |
1883 | 2133 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -804,12 +856,16 @@ discard block |
||
804 | 856 | if ($globalDBdriver == 'mysql') { |
805 | 857 | if (!$Connection->tableExists('tle')) { |
806 | 858 | $error .= create_db::import_file('../db/tle.sql'); |
807 | - if ($error != '') return $error; |
|
859 | + if ($error != '') { |
|
860 | + return $error; |
|
861 | + } |
|
808 | 862 | } |
809 | 863 | } else { |
810 | 864 | if (!$Connection->tableExists('tle')) { |
811 | 865 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
812 | - if ($error != '') return $error; |
|
866 | + if ($error != '') { |
|
867 | + return $error; |
|
868 | + } |
|
813 | 869 | } |
814 | 870 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
815 | 871 | try { |
@@ -849,7 +905,9 @@ discard block |
||
849 | 905 | } else { |
850 | 906 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 907 | } |
852 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
908 | + if ($error != '') { |
|
909 | + return 'Import airlines.sql : '.$error; |
|
910 | + } |
|
853 | 911 | if (!$Connection->checkColumnName('airlines','forsource')) { |
854 | 912 | // Add forsource to airlines |
855 | 913 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1171,8 +1229,11 @@ discard block |
||
1171 | 1229 | if ($Connection->tableExists('aircraft')) { |
1172 | 1230 | if (!$Connection->tableExists('config')) { |
1173 | 1231 | $version = '1'; |
1174 | - if ($update) return self::update_from_1(); |
|
1175 | - else return $version; |
|
1232 | + if ($update) { |
|
1233 | + return self::update_from_1(); |
|
1234 | + } else { |
|
1235 | + return $version; |
|
1236 | + } |
|
1176 | 1237 | } else { |
1177 | 1238 | $Connection = new Connection(); |
1178 | 1239 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1186,114 +1247,197 @@ discard block |
||
1186 | 1247 | if ($update) { |
1187 | 1248 | if ($result['value'] == '2') { |
1188 | 1249 | $error = self::update_from_2(); |
1189 | - if ($error != '') return $error; |
|
1190 | - else return self::check_version(true); |
|
1250 | + if ($error != '') { |
|
1251 | + return $error; |
|
1252 | + } else { |
|
1253 | + return self::check_version(true); |
|
1254 | + } |
|
1191 | 1255 | } elseif ($result['value'] == '3') { |
1192 | 1256 | $error = self::update_from_3(); |
1193 | - if ($error != '') return $error; |
|
1194 | - else return self::check_version(true); |
|
1257 | + if ($error != '') { |
|
1258 | + return $error; |
|
1259 | + } else { |
|
1260 | + return self::check_version(true); |
|
1261 | + } |
|
1195 | 1262 | } elseif ($result['value'] == '4') { |
1196 | 1263 | $error = self::update_from_4(); |
1197 | - if ($error != '') return $error; |
|
1198 | - else return self::check_version(true); |
|
1264 | + if ($error != '') { |
|
1265 | + return $error; |
|
1266 | + } else { |
|
1267 | + return self::check_version(true); |
|
1268 | + } |
|
1199 | 1269 | } elseif ($result['value'] == '5') { |
1200 | 1270 | $error = self::update_from_5(); |
1201 | - if ($error != '') return $error; |
|
1202 | - else return self::check_version(true); |
|
1271 | + if ($error != '') { |
|
1272 | + return $error; |
|
1273 | + } else { |
|
1274 | + return self::check_version(true); |
|
1275 | + } |
|
1203 | 1276 | } elseif ($result['value'] == '6') { |
1204 | 1277 | $error = self::update_from_6(); |
1205 | - if ($error != '') return $error; |
|
1206 | - else return self::check_version(true); |
|
1278 | + if ($error != '') { |
|
1279 | + return $error; |
|
1280 | + } else { |
|
1281 | + return self::check_version(true); |
|
1282 | + } |
|
1207 | 1283 | } elseif ($result['value'] == '7') { |
1208 | 1284 | $error = self::update_from_7(); |
1209 | - if ($error != '') return $error; |
|
1210 | - else return self::check_version(true); |
|
1285 | + if ($error != '') { |
|
1286 | + return $error; |
|
1287 | + } else { |
|
1288 | + return self::check_version(true); |
|
1289 | + } |
|
1211 | 1290 | } elseif ($result['value'] == '8') { |
1212 | 1291 | $error = self::update_from_8(); |
1213 | - if ($error != '') return $error; |
|
1214 | - else return self::check_version(true); |
|
1292 | + if ($error != '') { |
|
1293 | + return $error; |
|
1294 | + } else { |
|
1295 | + return self::check_version(true); |
|
1296 | + } |
|
1215 | 1297 | } elseif ($result['value'] == '9') { |
1216 | 1298 | $error = self::update_from_9(); |
1217 | - if ($error != '') return $error; |
|
1218 | - else return self::check_version(true); |
|
1299 | + if ($error != '') { |
|
1300 | + return $error; |
|
1301 | + } else { |
|
1302 | + return self::check_version(true); |
|
1303 | + } |
|
1219 | 1304 | } elseif ($result['value'] == '10') { |
1220 | 1305 | $error = self::update_from_10(); |
1221 | - if ($error != '') return $error; |
|
1222 | - else return self::check_version(true); |
|
1306 | + if ($error != '') { |
|
1307 | + return $error; |
|
1308 | + } else { |
|
1309 | + return self::check_version(true); |
|
1310 | + } |
|
1223 | 1311 | } elseif ($result['value'] == '11') { |
1224 | 1312 | $error = self::update_from_11(); |
1225 | - if ($error != '') return $error; |
|
1226 | - else return self::check_version(true); |
|
1313 | + if ($error != '') { |
|
1314 | + return $error; |
|
1315 | + } else { |
|
1316 | + return self::check_version(true); |
|
1317 | + } |
|
1227 | 1318 | } elseif ($result['value'] == '12') { |
1228 | 1319 | $error = self::update_from_12(); |
1229 | - if ($error != '') return $error; |
|
1230 | - else return self::check_version(true); |
|
1320 | + if ($error != '') { |
|
1321 | + return $error; |
|
1322 | + } else { |
|
1323 | + return self::check_version(true); |
|
1324 | + } |
|
1231 | 1325 | } elseif ($result['value'] == '13') { |
1232 | 1326 | $error = self::update_from_13(); |
1233 | - if ($error != '') return $error; |
|
1234 | - else return self::check_version(true); |
|
1327 | + if ($error != '') { |
|
1328 | + return $error; |
|
1329 | + } else { |
|
1330 | + return self::check_version(true); |
|
1331 | + } |
|
1235 | 1332 | } elseif ($result['value'] == '14') { |
1236 | 1333 | $error = self::update_from_14(); |
1237 | - if ($error != '') return $error; |
|
1238 | - else return self::check_version(true); |
|
1334 | + if ($error != '') { |
|
1335 | + return $error; |
|
1336 | + } else { |
|
1337 | + return self::check_version(true); |
|
1338 | + } |
|
1239 | 1339 | } elseif ($result['value'] == '15') { |
1240 | 1340 | $error = self::update_from_15(); |
1241 | - if ($error != '') return $error; |
|
1242 | - else return self::check_version(true); |
|
1341 | + if ($error != '') { |
|
1342 | + return $error; |
|
1343 | + } else { |
|
1344 | + return self::check_version(true); |
|
1345 | + } |
|
1243 | 1346 | } elseif ($result['value'] == '16') { |
1244 | 1347 | $error = self::update_from_16(); |
1245 | - if ($error != '') return $error; |
|
1246 | - else return self::check_version(true); |
|
1348 | + if ($error != '') { |
|
1349 | + return $error; |
|
1350 | + } else { |
|
1351 | + return self::check_version(true); |
|
1352 | + } |
|
1247 | 1353 | } elseif ($result['value'] == '17') { |
1248 | 1354 | $error = self::update_from_17(); |
1249 | - if ($error != '') return $error; |
|
1250 | - else return self::check_version(true); |
|
1355 | + if ($error != '') { |
|
1356 | + return $error; |
|
1357 | + } else { |
|
1358 | + return self::check_version(true); |
|
1359 | + } |
|
1251 | 1360 | } elseif ($result['value'] == '18') { |
1252 | 1361 | $error = self::update_from_18(); |
1253 | - if ($error != '') return $error; |
|
1254 | - else return self::check_version(true); |
|
1362 | + if ($error != '') { |
|
1363 | + return $error; |
|
1364 | + } else { |
|
1365 | + return self::check_version(true); |
|
1366 | + } |
|
1255 | 1367 | } elseif ($result['value'] == '19') { |
1256 | 1368 | $error = self::update_from_19(); |
1257 | - if ($error != '') return $error; |
|
1258 | - else return self::check_version(true); |
|
1369 | + if ($error != '') { |
|
1370 | + return $error; |
|
1371 | + } else { |
|
1372 | + return self::check_version(true); |
|
1373 | + } |
|
1259 | 1374 | } elseif ($result['value'] == '20') { |
1260 | 1375 | $error = self::update_from_20(); |
1261 | - if ($error != '') return $error; |
|
1262 | - else return self::check_version(true); |
|
1376 | + if ($error != '') { |
|
1377 | + return $error; |
|
1378 | + } else { |
|
1379 | + return self::check_version(true); |
|
1380 | + } |
|
1263 | 1381 | } elseif ($result['value'] == '21') { |
1264 | 1382 | $error = self::update_from_21(); |
1265 | - if ($error != '') return $error; |
|
1266 | - else return self::check_version(true); |
|
1383 | + if ($error != '') { |
|
1384 | + return $error; |
|
1385 | + } else { |
|
1386 | + return self::check_version(true); |
|
1387 | + } |
|
1267 | 1388 | } elseif ($result['value'] == '22') { |
1268 | 1389 | $error = self::update_from_22(); |
1269 | - if ($error != '') return $error; |
|
1270 | - else return self::check_version(true); |
|
1390 | + if ($error != '') { |
|
1391 | + return $error; |
|
1392 | + } else { |
|
1393 | + return self::check_version(true); |
|
1394 | + } |
|
1271 | 1395 | } elseif ($result['value'] == '23') { |
1272 | 1396 | $error = self::update_from_23(); |
1273 | - if ($error != '') return $error; |
|
1274 | - else return self::check_version(true); |
|
1397 | + if ($error != '') { |
|
1398 | + return $error; |
|
1399 | + } else { |
|
1400 | + return self::check_version(true); |
|
1401 | + } |
|
1275 | 1402 | } elseif ($result['value'] == '24') { |
1276 | 1403 | $error = self::update_from_24(); |
1277 | - if ($error != '') return $error; |
|
1278 | - else return self::check_version(true); |
|
1404 | + if ($error != '') { |
|
1405 | + return $error; |
|
1406 | + } else { |
|
1407 | + return self::check_version(true); |
|
1408 | + } |
|
1279 | 1409 | } elseif ($result['value'] == '25') { |
1280 | 1410 | $error = self::update_from_25(); |
1281 | - if ($error != '') return $error; |
|
1282 | - else return self::check_version(true); |
|
1411 | + if ($error != '') { |
|
1412 | + return $error; |
|
1413 | + } else { |
|
1414 | + return self::check_version(true); |
|
1415 | + } |
|
1283 | 1416 | } elseif ($result['value'] == '26') { |
1284 | 1417 | $error = self::update_from_26(); |
1285 | - if ($error != '') return $error; |
|
1286 | - else return self::check_version(true); |
|
1418 | + if ($error != '') { |
|
1419 | + return $error; |
|
1420 | + } else { |
|
1421 | + return self::check_version(true); |
|
1422 | + } |
|
1287 | 1423 | } elseif ($result['value'] == '27') { |
1288 | 1424 | $error = self::update_from_27(); |
1289 | - if ($error != '') return $error; |
|
1290 | - else return self::check_version(true); |
|
1291 | - } else return ''; |
|
1425 | + if ($error != '') { |
|
1426 | + return $error; |
|
1427 | + } else { |
|
1428 | + return self::check_version(true); |
|
1429 | + } |
|
1430 | + } else { |
|
1431 | + return ''; |
|
1432 | + } |
|
1433 | + } else { |
|
1434 | + return $result['value']; |
|
1292 | 1435 | } |
1293 | - else return $result['value']; |
|
1294 | 1436 | } |
1295 | 1437 | |
1296 | - } else return $version; |
|
1438 | + } else { |
|
1439 | + return $version; |
|
1440 | + } |
|
1297 | 1441 | } |
1298 | 1442 | |
1299 | 1443 | } |