@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | $this->db = $Connection->db(); |
18 | 18 | } |
19 | 19 | |
20 | - public function addLastStatsUpdate($type,$stats_date) { |
|
20 | + public function addLastStatsUpdate($type, $stats_date) { |
|
21 | 21 | $query = "DELETE FROM config WHERE name = :type; |
22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
23 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
24 | 24 | try { |
25 | 25 | $sth = $this->db->prepare($query); |
26 | 26 | $sth->execute($query_values); |
27 | - } catch(PDOException $e) { |
|
27 | + } catch (PDOException $e) { |
|
28 | 28 | return "error : ".$e->getMessage(); |
29 | 29 | } |
30 | 30 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | try { |
35 | 35 | $sth = $this->db->prepare($query); |
36 | 36 | $sth->execute(array(':type' => $type)); |
37 | - } catch(PDOException $e) { |
|
37 | + } catch (PDOException $e) { |
|
38 | 38 | echo "error : ".$e->getMessage(); |
39 | 39 | } |
40 | 40 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -46,43 +46,43 @@ discard block |
||
46 | 46 | try { |
47 | 47 | $sth = $this->db->prepare($query); |
48 | 48 | $sth->execute(array(':filter_name' => $filter_name)); |
49 | - } catch(PDOException $e) { |
|
49 | + } catch (PDOException $e) { |
|
50 | 50 | echo "error : ".$e->getMessage(); |
51 | 51 | } |
52 | 52 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
53 | 53 | return $all; |
54 | 54 | } |
55 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
55 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
56 | 56 | if ($filter_name == '') $filter_name = $this->filter_name; |
57 | 57 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
58 | 58 | try { |
59 | 59 | $sth = $this->db->prepare($query); |
60 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
61 | - } catch(PDOException $e) { |
|
60 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
61 | + } catch (PDOException $e) { |
|
62 | 62 | echo "error : ".$e->getMessage(); |
63 | 63 | } |
64 | 64 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
65 | 65 | return $all; |
66 | 66 | } |
67 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
67 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
68 | 68 | if ($filter_name == '') $filter_name = $this->filter_name; |
69 | 69 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
70 | 70 | try { |
71 | 71 | $sth = $this->db->prepare($query); |
72 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
73 | - } catch(PDOException $e) { |
|
72 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
73 | + } catch (PDOException $e) { |
|
74 | 74 | echo "error : ".$e->getMessage(); |
75 | 75 | } |
76 | 76 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
77 | 77 | return $all; |
78 | 78 | } |
79 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
79 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
80 | 80 | if ($filter_name == '') $filter_name = $this->filter_name; |
81 | 81 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
82 | 82 | try { |
83 | 83 | $sth = $this->db->prepare($query); |
84 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
85 | - } catch(PDOException $e) { |
|
84 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
85 | + } catch (PDOException $e) { |
|
86 | 86 | echo "error : ".$e->getMessage(); |
87 | 87 | } |
88 | 88 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -97,22 +97,22 @@ discard block |
||
97 | 97 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
98 | 98 | try { |
99 | 99 | $sth = $this->db->prepare($query); |
100 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
101 | - } catch(PDOException $e) { |
|
100 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
101 | + } catch (PDOException $e) { |
|
102 | 102 | echo "error : ".$e->getMessage(); |
103 | 103 | } |
104 | 104 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
105 | 105 | if (empty($all)) { |
106 | 106 | $filters = array('airlines' => array($stats_airline)); |
107 | 107 | if ($filter_name != '') { |
108 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
108 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
109 | 109 | } |
110 | 110 | $Spotter = new Spotter($this->db); |
111 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
111 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
112 | 112 | } |
113 | 113 | return $all; |
114 | 114 | } |
115 | - public function countAllAirlineCountries($limit = true,$filter_name = '') { |
|
115 | + public function countAllAirlineCountries($limit = true, $filter_name = '') { |
|
116 | 116 | global $globalStatsFilters; |
117 | 117 | if ($filter_name == '') $filter_name = $this->filter_name; |
118 | 118 | if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | try { |
121 | 121 | $sth = $this->db->prepare($query); |
122 | 122 | $sth->execute(array(':filter_name' => $filter_name)); |
123 | - } catch(PDOException $e) { |
|
123 | + } catch (PDOException $e) { |
|
124 | 124 | echo "error : ".$e->getMessage(); |
125 | 125 | } |
126 | 126 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -128,28 +128,28 @@ discard block |
||
128 | 128 | $Spotter = new Spotter($this->db); |
129 | 129 | $filters = array(); |
130 | 130 | if ($filter_name != '') { |
131 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
131 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
132 | 132 | } |
133 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
133 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
134 | 134 | } |
135 | 135 | return $all; |
136 | 136 | } |
137 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
|
137 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '') { |
|
138 | 138 | global $globalStatsFilters; |
139 | 139 | if ($filter_name == '') $filter_name = $this->filter_name; |
140 | 140 | if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
141 | 141 | else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
142 | 142 | try { |
143 | 143 | $sth = $this->db->prepare($query); |
144 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
145 | - } catch(PDOException $e) { |
|
144 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
145 | + } catch (PDOException $e) { |
|
146 | 146 | echo "error : ".$e->getMessage(); |
147 | 147 | } |
148 | 148 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
149 | 149 | if (empty($all)) { |
150 | 150 | $filters = array('airlines' => array($stats_airline)); |
151 | 151 | if ($filter_name != '') { |
152 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
152 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
153 | 153 | } |
154 | 154 | $Spotter = new Spotter($this->db); |
155 | 155 | $all = $Spotter->countAllAircraftManufacturers($filters); |
@@ -164,18 +164,18 @@ discard block |
||
164 | 164 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
165 | 165 | try { |
166 | 166 | $sth = $this->db->prepare($query); |
167 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
168 | - } catch(PDOException $e) { |
|
167 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
168 | + } catch (PDOException $e) { |
|
169 | 169 | echo "error : ".$e->getMessage(); |
170 | 170 | } |
171 | 171 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
172 | 172 | if (empty($all)) { |
173 | 173 | $filters = array('airlines' => array($stats_airline)); |
174 | 174 | if ($filter_name != '') { |
175 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
175 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
176 | 176 | } |
177 | 177 | $Spotter = new Spotter($this->db); |
178 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
178 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
179 | 179 | } |
180 | 180 | return $all; |
181 | 181 | } |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
187 | 187 | try { |
188 | 188 | $sth = $this->db->prepare($query); |
189 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
190 | - } catch(PDOException $e) { |
|
189 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
190 | + } catch (PDOException $e) { |
|
191 | 191 | echo "error : ".$e->getMessage(); |
192 | 192 | } |
193 | 193 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
194 | 194 | if (empty($all)) { |
195 | 195 | $filters = array('airlines' => array($stats_airline)); |
196 | 196 | if ($filter_name != '') { |
197 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
197 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
198 | 198 | } |
199 | 199 | $Spotter = new Spotter($this->db); |
200 | 200 | $all = $Spotter->countAllDepartureCountries($filters); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | return $all; |
203 | 203 | } |
204 | 204 | |
205 | - public function countAllAirlines($limit = true,$filter_name = '') { |
|
205 | + public function countAllAirlines($limit = true, $filter_name = '') { |
|
206 | 206 | global $globalStatsFilters; |
207 | 207 | if ($filter_name == '') $filter_name = $this->filter_name; |
208 | 208 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | try { |
211 | 211 | $sth = $this->db->prepare($query); |
212 | 212 | $sth->execute(array(':filter_name' => $filter_name)); |
213 | - } catch(PDOException $e) { |
|
213 | + } catch (PDOException $e) { |
|
214 | 214 | echo "error : ".$e->getMessage(); |
215 | 215 | } |
216 | 216 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -218,58 +218,58 @@ discard block |
||
218 | 218 | $Spotter = new Spotter($this->db); |
219 | 219 | $filters = array(); |
220 | 220 | if ($filter_name != '') { |
221 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
221 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
222 | 222 | } |
223 | 223 | |
224 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
224 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
225 | 225 | } |
226 | 226 | return $all; |
227 | 227 | } |
228 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
|
228 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '') { |
|
229 | 229 | global $globalStatsFilters; |
230 | 230 | if ($filter_name == '') $filter_name = $this->filter_name; |
231 | 231 | if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
232 | 232 | else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
233 | 233 | try { |
234 | 234 | $sth = $this->db->prepare($query); |
235 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
236 | - } catch(PDOException $e) { |
|
235 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
236 | + } catch (PDOException $e) { |
|
237 | 237 | echo "error : ".$e->getMessage(); |
238 | 238 | } |
239 | 239 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
240 | 240 | if (empty($all)) { |
241 | 241 | $filters = array('airlines' => array($stats_airline)); |
242 | 242 | if ($filter_name != '') { |
243 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
243 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
244 | 244 | } |
245 | 245 | $Spotter = new Spotter($this->db); |
246 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
246 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
247 | 247 | } |
248 | 248 | return $all; |
249 | 249 | } |
250 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
|
250 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '') { |
|
251 | 251 | global $globalStatsFilters; |
252 | 252 | if ($filter_name == '') $filter_name = $this->filter_name; |
253 | 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 | 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"; |
255 | 255 | try { |
256 | 256 | $sth = $this->db->prepare($query); |
257 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
258 | - } catch(PDOException $e) { |
|
257 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
258 | + } catch (PDOException $e) { |
|
259 | 259 | echo "error : ".$e->getMessage(); |
260 | 260 | } |
261 | 261 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
262 | 262 | if (empty($all)) { |
263 | 263 | $filters = array('airlines' => array($stats_airline)); |
264 | 264 | if ($filter_name != '') { |
265 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
265 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
266 | 266 | } |
267 | 267 | $Spotter = new Spotter($this->db); |
268 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
268 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
269 | 269 | } |
270 | 270 | return $all; |
271 | 271 | } |
272 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
|
272 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '') { |
|
273 | 273 | $Connection = new Connection(); |
274 | 274 | if ($filter_name == '') $filter_name = $this->filter_name; |
275 | 275 | if ($Connection->tableExists('countries')) { |
@@ -277,8 +277,8 @@ discard block |
||
277 | 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"; |
278 | 278 | try { |
279 | 279 | $sth = $this->db->prepare($query); |
280 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
281 | - } catch(PDOException $e) { |
|
280 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
281 | + } catch (PDOException $e) { |
|
282 | 282 | echo "error : ".$e->getMessage(); |
283 | 283 | } |
284 | 284 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -293,70 +293,70 @@ discard block |
||
293 | 293 | return array(); |
294 | 294 | } |
295 | 295 | } |
296 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
|
296 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '') { |
|
297 | 297 | global $globalStatsFilters; |
298 | 298 | if ($filter_name == '') $filter_name = $this->filter_name; |
299 | 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 | 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"; |
301 | 301 | try { |
302 | 302 | $sth = $this->db->prepare($query); |
303 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
304 | - } catch(PDOException $e) { |
|
303 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
304 | + } catch (PDOException $e) { |
|
305 | 305 | echo "error : ".$e->getMessage(); |
306 | 306 | } |
307 | 307 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
308 | 308 | if (empty($all)) { |
309 | 309 | $filters = array('airlines' => array($stats_airline)); |
310 | 310 | if ($filter_name != '') { |
311 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
311 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
312 | 312 | } |
313 | 313 | $Spotter = new Spotter($this->db); |
314 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
314 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
315 | 315 | } |
316 | 316 | return $all; |
317 | 317 | } |
318 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
|
318 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '') { |
|
319 | 319 | global $globalStatsFilters; |
320 | 320 | if ($filter_name == '') $filter_name = $this->filter_name; |
321 | 321 | if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
322 | 322 | else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
323 | 323 | try { |
324 | 324 | $sth = $this->db->prepare($query); |
325 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
326 | - } catch(PDOException $e) { |
|
325 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
326 | + } catch (PDOException $e) { |
|
327 | 327 | echo "error : ".$e->getMessage(); |
328 | 328 | } |
329 | 329 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
330 | 330 | if (empty($all)) { |
331 | 331 | $filters = array('airlines' => array($stats_airline)); |
332 | 332 | if ($filter_name != '') { |
333 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
333 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
334 | 334 | } |
335 | 335 | $Spotter = new Spotter($this->db); |
336 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
336 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
337 | 337 | } |
338 | 338 | return $all; |
339 | 339 | } |
340 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
|
340 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '') { |
|
341 | 341 | global $globalStatsFilters; |
342 | 342 | if ($filter_name == '') $filter_name = $this->filter_name; |
343 | 343 | if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
344 | 344 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
345 | 345 | try { |
346 | 346 | $sth = $this->db->prepare($query); |
347 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
348 | - } catch(PDOException $e) { |
|
347 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
348 | + } catch (PDOException $e) { |
|
349 | 349 | echo "error : ".$e->getMessage(); |
350 | 350 | } |
351 | 351 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
352 | 352 | if (empty($all)) { |
353 | 353 | $filters = array('airlines' => array($stats_airline)); |
354 | 354 | if ($filter_name != '') { |
355 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
355 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
356 | 356 | } |
357 | 357 | $Spotter = new Spotter($this->db); |
358 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
359 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
358 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
359 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
360 | 360 | $all = array(); |
361 | 361 | foreach ($pall as $value) { |
362 | 362 | $icao = $value['airport_departure_icao']; |
@@ -373,30 +373,30 @@ discard block |
||
373 | 373 | foreach ($all as $key => $row) { |
374 | 374 | $count[$key] = $row['airport_departure_icao_count']; |
375 | 375 | } |
376 | - array_multisort($count,SORT_DESC,$all); |
|
376 | + array_multisort($count, SORT_DESC, $all); |
|
377 | 377 | } |
378 | 378 | return $all; |
379 | 379 | } |
380 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
|
380 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '') { |
|
381 | 381 | global $globalStatsFilters; |
382 | 382 | if ($filter_name == '') $filter_name = $this->filter_name; |
383 | 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 | 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"; |
385 | 385 | try { |
386 | 386 | $sth = $this->db->prepare($query); |
387 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
388 | - } catch(PDOException $e) { |
|
387 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
388 | + } catch (PDOException $e) { |
|
389 | 389 | echo "error : ".$e->getMessage(); |
390 | 390 | } |
391 | 391 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
392 | 392 | if (empty($all)) { |
393 | 393 | $filters = array('airlines' => array($stats_airline)); |
394 | 394 | if ($filter_name != '') { |
395 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
395 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
396 | 396 | } |
397 | 397 | $Spotter = new Spotter($this->db); |
398 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
399 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
398 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
399 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
400 | 400 | $all = array(); |
401 | 401 | foreach ($pall as $value) { |
402 | 402 | $icao = $value['airport_arrival_icao']; |
@@ -413,12 +413,12 @@ discard block |
||
413 | 413 | foreach ($all as $key => $row) { |
414 | 414 | $count[$key] = $row['airport_arrival_icao_count']; |
415 | 415 | } |
416 | - array_multisort($count,SORT_DESC,$all); |
|
416 | + array_multisort($count, SORT_DESC, $all); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | return $all; |
420 | 420 | } |
421 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
421 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
422 | 422 | global $globalDBdriver, $globalStatsFilters; |
423 | 423 | if ($filter_name == '') $filter_name = $this->filter_name; |
424 | 424 | if ($globalDBdriver == 'mysql') { |
@@ -428,18 +428,18 @@ discard block |
||
428 | 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 | 429 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
430 | 430 | } |
431 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
431 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
432 | 432 | try { |
433 | 433 | $sth = $this->db->prepare($query); |
434 | 434 | $sth->execute($query_data); |
435 | - } catch(PDOException $e) { |
|
435 | + } catch (PDOException $e) { |
|
436 | 436 | echo "error : ".$e->getMessage(); |
437 | 437 | } |
438 | 438 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
439 | 439 | if (empty($all)) { |
440 | 440 | $filters = array('airlines' => array($stats_airline)); |
441 | 441 | if ($filter_name != '') { |
442 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
442 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
443 | 443 | } |
444 | 444 | $Spotter = new Spotter($this->db); |
445 | 445 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -448,29 +448,29 @@ discard block |
||
448 | 448 | return $all; |
449 | 449 | } |
450 | 450 | |
451 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
451 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
452 | 452 | global $globalStatsFilters; |
453 | 453 | if ($filter_name == '') $filter_name = $this->filter_name; |
454 | 454 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
455 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
455 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
456 | 456 | try { |
457 | 457 | $sth = $this->db->prepare($query); |
458 | 458 | $sth->execute($query_data); |
459 | - } catch(PDOException $e) { |
|
459 | + } catch (PDOException $e) { |
|
460 | 460 | echo "error : ".$e->getMessage(); |
461 | 461 | } |
462 | 462 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
463 | 463 | if (empty($all)) { |
464 | 464 | $filters = array('airlines' => array($stats_airline)); |
465 | 465 | if ($filter_name != '') { |
466 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
466 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
467 | 467 | } |
468 | 468 | $Spotter = new Spotter($this->db); |
469 | 469 | $all = $Spotter->countAllDatesLastMonth($filters); |
470 | 470 | } |
471 | 471 | return $all; |
472 | 472 | } |
473 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
473 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
474 | 474 | global $globalDBdriver, $globalStatsFilters; |
475 | 475 | if ($filter_name == '') $filter_name = $this->filter_name; |
476 | 476 | if ($globalDBdriver == 'mysql') { |
@@ -478,40 +478,40 @@ discard block |
||
478 | 478 | } else { |
479 | 479 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
480 | 480 | } |
481 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
481 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
482 | 482 | try { |
483 | 483 | $sth = $this->db->prepare($query); |
484 | 484 | $sth->execute($query_data); |
485 | - } catch(PDOException $e) { |
|
485 | + } catch (PDOException $e) { |
|
486 | 486 | echo "error : ".$e->getMessage(); |
487 | 487 | } |
488 | 488 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
489 | 489 | if (empty($all)) { |
490 | 490 | $filters = array('airlines' => array($stats_airline)); |
491 | 491 | if ($filter_name != '') { |
492 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
492 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
493 | 493 | } |
494 | 494 | $Spotter = new Spotter($this->db); |
495 | 495 | $all = $Spotter->countAllDatesLast7Days($filters); |
496 | 496 | } |
497 | 497 | return $all; |
498 | 498 | } |
499 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
499 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
500 | 500 | global $globalStatsFilters; |
501 | 501 | if ($filter_name == '') $filter_name = $this->filter_name; |
502 | 502 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
503 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
503 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
504 | 504 | try { |
505 | 505 | $sth = $this->db->prepare($query); |
506 | 506 | $sth->execute($query_data); |
507 | - } catch(PDOException $e) { |
|
507 | + } catch (PDOException $e) { |
|
508 | 508 | echo "error : ".$e->getMessage(); |
509 | 509 | } |
510 | 510 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
511 | 511 | if (empty($all)) { |
512 | 512 | $filters = array('airlines' => array($stats_airline)); |
513 | 513 | if ($filter_name != '') { |
514 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
514 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
515 | 515 | } |
516 | 516 | $Spotter = new Spotter($this->db); |
517 | 517 | $all = $Spotter->countAllDates($filters); |
@@ -526,35 +526,35 @@ discard block |
||
526 | 526 | try { |
527 | 527 | $sth = $this->db->prepare($query); |
528 | 528 | $sth->execute($query_data); |
529 | - } catch(PDOException $e) { |
|
529 | + } catch (PDOException $e) { |
|
530 | 530 | echo "error : ".$e->getMessage(); |
531 | 531 | } |
532 | 532 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
533 | 533 | if (empty($all)) { |
534 | 534 | $filters = array(); |
535 | 535 | if ($filter_name != '') { |
536 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
536 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
537 | 537 | } |
538 | 538 | $Spotter = new Spotter($this->db); |
539 | 539 | $all = $Spotter->countAllDatesByAirlines($filters); |
540 | 540 | } |
541 | 541 | return $all; |
542 | 542 | } |
543 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
543 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
544 | 544 | global $globalStatsFilters; |
545 | 545 | if ($filter_name == '') $filter_name = $this->filter_name; |
546 | 546 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
547 | 547 | try { |
548 | 548 | $sth = $this->db->prepare($query); |
549 | 549 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
550 | - } catch(PDOException $e) { |
|
550 | + } catch (PDOException $e) { |
|
551 | 551 | echo "error : ".$e->getMessage(); |
552 | 552 | } |
553 | 553 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
554 | 554 | if (empty($all)) { |
555 | 555 | $filters = array('airlines' => array($stats_airline)); |
556 | 556 | if ($filter_name != '') { |
557 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
557 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
558 | 558 | } |
559 | 559 | $Spotter = new Spotter($this->db); |
560 | 560 | $all = $Spotter->countAllMonths($filters); |
@@ -568,21 +568,21 @@ discard block |
||
568 | 568 | try { |
569 | 569 | $sth = $this->db->prepare($query); |
570 | 570 | $sth->execute(array(':filter_name' => $filter_name)); |
571 | - } catch(PDOException $e) { |
|
571 | + } catch (PDOException $e) { |
|
572 | 572 | echo "error : ".$e->getMessage(); |
573 | 573 | } |
574 | 574 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
575 | 575 | if (empty($all)) { |
576 | 576 | $filters = array(); |
577 | 577 | if ($filter_name != '') { |
578 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
578 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
579 | 579 | } |
580 | 580 | $Spotter = new Spotter($this->db); |
581 | 581 | $all = $Spotter->countAllMilitaryMonths($filters); |
582 | 582 | } |
583 | 583 | return $all; |
584 | 584 | } |
585 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
585 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
586 | 586 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
587 | 587 | if ($filter_name == '') $filter_name = $this->filter_name; |
588 | 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"; |
@@ -599,17 +599,17 @@ discard block |
||
599 | 599 | try { |
600 | 600 | $sth = $this->db->prepare($query); |
601 | 601 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
602 | - } catch(PDOException $e) { |
|
602 | + } catch (PDOException $e) { |
|
603 | 603 | echo "error : ".$e->getMessage(); |
604 | 604 | } |
605 | 605 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
606 | 606 | if (empty($all)) { |
607 | 607 | $filters = array('airlines' => array($stats_airline)); |
608 | 608 | if ($filter_name != '') { |
609 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
609 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
610 | 610 | } |
611 | 611 | $Spotter = new Spotter($this->db); |
612 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
612 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
613 | 613 | } |
614 | 614 | return $all; |
615 | 615 | } |
@@ -617,11 +617,11 @@ discard block |
||
617 | 617 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
618 | 618 | global $globalStatsFilters; |
619 | 619 | if ($filter_name == '') $filter_name = $this->filter_name; |
620 | - $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
|
620 | + $all = $this->getSumStats('flights_bymonth', date('Y'), $stats_airline, $filter_name); |
|
621 | 621 | if (empty($all)) { |
622 | 622 | $filters = array('airlines' => array($stats_airline)); |
623 | 623 | if ($filter_name != '') { |
624 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
624 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
625 | 625 | } |
626 | 626 | $Spotter = new Spotter($this->db); |
627 | 627 | $all = $Spotter->countOverallFlights($filters); |
@@ -631,39 +631,39 @@ discard block |
||
631 | 631 | public function countOverallMilitaryFlights($filter_name = '') { |
632 | 632 | global $globalStatsFilters; |
633 | 633 | if ($filter_name == '') $filter_name = $this->filter_name; |
634 | - $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
|
634 | + $all = $this->getSumStats('military_flights_bymonth', date('Y'), '', $filter_name); |
|
635 | 635 | if (empty($all)) { |
636 | 636 | $filters = array(); |
637 | 637 | if ($filter_name != '') { |
638 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
638 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
639 | 639 | } |
640 | 640 | $Spotter = new Spotter($this->db); |
641 | 641 | $all = $Spotter->countOverallMilitaryFlights($filters); |
642 | 642 | } |
643 | 643 | return $all; |
644 | 644 | } |
645 | - public function countOverallArrival($stats_airline = '',$filter_name = '') { |
|
645 | + public function countOverallArrival($stats_airline = '', $filter_name = '') { |
|
646 | 646 | global $globalStatsFilters; |
647 | 647 | if ($filter_name == '') $filter_name = $this->filter_name; |
648 | - $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
|
648 | + $all = $this->getSumStats('realarrivals_bymonth', date('Y'), $stats_airline, $filter_name); |
|
649 | 649 | if (empty($all)) { |
650 | 650 | $filters = array('airlines' => array($stats_airline)); |
651 | 651 | if ($filter_name != '') { |
652 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
652 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
653 | 653 | } |
654 | 654 | $Spotter = new Spotter($this->db); |
655 | 655 | $all = $Spotter->countOverallArrival($filters); |
656 | 656 | } |
657 | 657 | return $all; |
658 | 658 | } |
659 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
|
659 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '') { |
|
660 | 660 | global $globalStatsFilters; |
661 | 661 | if ($filter_name == '') $filter_name = $this->filter_name; |
662 | - $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
|
662 | + $all = $this->getSumStats('aircrafts_bymonth', date('Y'), $stats_airline, $filter_name); |
|
663 | 663 | if (empty($all)) { |
664 | 664 | $filters = array('airlines' => array($stats_airline)); |
665 | 665 | if ($filter_name != '') { |
666 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
666 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
667 | 667 | } |
668 | 668 | $Spotter = new Spotter($this->db); |
669 | 669 | $all = $Spotter->countOverallAircrafts($filters); |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | try { |
678 | 678 | $sth = $this->db->prepare($query); |
679 | 679 | $sth->execute(array(':filter_name' => $filter_name)); |
680 | - } catch(PDOException $e) { |
|
680 | + } catch (PDOException $e) { |
|
681 | 681 | echo "error : ".$e->getMessage(); |
682 | 682 | } |
683 | 683 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -686,14 +686,14 @@ discard block |
||
686 | 686 | if (empty($all)) { |
687 | 687 | $filters = array(); |
688 | 688 | if ($filter_name != '') { |
689 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
689 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
690 | 690 | } |
691 | 691 | $Spotter = new Spotter($this->db); |
692 | 692 | $all = $Spotter->countOverallAirlines($filters); |
693 | 693 | } |
694 | 694 | return $all; |
695 | 695 | } |
696 | - public function countOverallOwners($stats_airline = '',$filter_name = '') { |
|
696 | + public function countOverallOwners($stats_airline = '', $filter_name = '') { |
|
697 | 697 | global $globalStatsFilters; |
698 | 698 | if ($filter_name == '') $filter_name = $this->filter_name; |
699 | 699 | /* |
@@ -707,25 +707,25 @@ discard block |
||
707 | 707 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
708 | 708 | $all = $result[0]['nb_owner']; |
709 | 709 | */ |
710 | - $all = $this->getSumStats('owners_bymonth',date('Y'),$stats_airline,$filter_name); |
|
710 | + $all = $this->getSumStats('owners_bymonth', date('Y'), $stats_airline, $filter_name); |
|
711 | 711 | if (empty($all)) { |
712 | 712 | $filters = array('airlines' => array($stats_airline)); |
713 | 713 | if ($filter_name != '') { |
714 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
714 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
715 | 715 | } |
716 | 716 | $Spotter = new Spotter($this->db); |
717 | 717 | $all = $Spotter->countOverallOwners($filters); |
718 | 718 | } |
719 | 719 | return $all; |
720 | 720 | } |
721 | - public function countOverallPilots($stats_airline = '',$filter_name = '') { |
|
721 | + public function countOverallPilots($stats_airline = '', $filter_name = '') { |
|
722 | 722 | global $globalStatsFilters; |
723 | 723 | if ($filter_name == '') $filter_name = $this->filter_name; |
724 | - $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
|
724 | + $all = $this->getSumStats('pilots_bymonth', date('Y'), $stats_airline, $filter_name); |
|
725 | 725 | if (empty($all)) { |
726 | 726 | $filters = array('airlines' => array($stats_airline)); |
727 | 727 | if ($filter_name != '') { |
728 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
728 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
729 | 729 | } |
730 | 730 | $Spotter = new Spotter($this->db); |
731 | 731 | $all = $Spotter->countOverallPilots($filters); |
@@ -733,33 +733,33 @@ discard block |
||
733 | 733 | return $all; |
734 | 734 | } |
735 | 735 | |
736 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
736 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
737 | 737 | if ($filter_name == '') $filter_name = $this->filter_name; |
738 | 738 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
739 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
739 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
740 | 740 | try { |
741 | 741 | $sth = $this->db->prepare($query); |
742 | 742 | $sth->execute($query_values); |
743 | - } catch(PDOException $e) { |
|
743 | + } catch (PDOException $e) { |
|
744 | 744 | echo "error : ".$e->getMessage(); |
745 | 745 | } |
746 | 746 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
747 | 747 | return $all; |
748 | 748 | } |
749 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
749 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
750 | 750 | if ($filter_name == '') $filter_name = $this->filter_name; |
751 | 751 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
752 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
752 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
753 | 753 | try { |
754 | 754 | $sth = $this->db->prepare($query); |
755 | 755 | $sth->execute($query_values); |
756 | - } catch(PDOException $e) { |
|
756 | + } catch (PDOException $e) { |
|
757 | 757 | echo "error : ".$e->getMessage(); |
758 | 758 | } |
759 | 759 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
760 | 760 | return $all; |
761 | 761 | } |
762 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
|
762 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '') { |
|
763 | 763 | if ($filter_name == '') $filter_name = $this->filter_name; |
764 | 764 | global $globalArchiveMonths, $globalDBdriver; |
765 | 765 | if ($globalDBdriver == 'mysql') { |
@@ -767,11 +767,11 @@ discard block |
||
767 | 767 | } else { |
768 | 768 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
769 | 769 | } |
770 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
770 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
771 | 771 | try { |
772 | 772 | $sth = $this->db->prepare($query); |
773 | 773 | $sth->execute($query_values); |
774 | - } catch(PDOException $e) { |
|
774 | + } catch (PDOException $e) { |
|
775 | 775 | echo "error : ".$e->getMessage(); |
776 | 776 | } |
777 | 777 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | try { |
790 | 790 | $sth = $this->db->prepare($query); |
791 | 791 | $sth->execute($query_values); |
792 | - } catch(PDOException $e) { |
|
792 | + } catch (PDOException $e) { |
|
793 | 793 | echo "error : ".$e->getMessage(); |
794 | 794 | } |
795 | 795 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | try { |
807 | 807 | $sth = $this->db->prepare($query); |
808 | 808 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
809 | - } catch(PDOException $e) { |
|
809 | + } catch (PDOException $e) { |
|
810 | 810 | echo "error : ".$e->getMessage(); |
811 | 811 | } |
812 | 812 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | try { |
824 | 824 | $sth = $this->db->prepare($query); |
825 | 825 | $sth->execute(array(':filter_name' => $filter_name)); |
826 | - } catch(PDOException $e) { |
|
826 | + } catch (PDOException $e) { |
|
827 | 827 | echo "error : ".$e->getMessage(); |
828 | 828 | } |
829 | 829 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | try { |
841 | 841 | $sth = $this->db->prepare($query); |
842 | 842 | $sth->execute(array(':filter_name' => $filter_name)); |
843 | - } catch(PDOException $e) { |
|
843 | + } catch (PDOException $e) { |
|
844 | 844 | echo "error : ".$e->getMessage(); |
845 | 845 | } |
846 | 846 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -857,14 +857,14 @@ discard block |
||
857 | 857 | try { |
858 | 858 | $sth = $this->db->prepare($query); |
859 | 859 | $sth->execute(array(':filter_name' => $filter_name)); |
860 | - } catch(PDOException $e) { |
|
860 | + } catch (PDOException $e) { |
|
861 | 861 | echo "error : ".$e->getMessage(); |
862 | 862 | } |
863 | 863 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
864 | 864 | return $all[0]['total']; |
865 | 865 | } |
866 | 866 | |
867 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
867 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
868 | 868 | global $globalDBdriver; |
869 | 869 | if ($filter_name == '') $filter_name = $this->filter_name; |
870 | 870 | if ($globalDBdriver == 'mysql') { |
@@ -872,15 +872,15 @@ discard block |
||
872 | 872 | } else { |
873 | 873 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
874 | 874 | } |
875 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
875 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
876 | 876 | try { |
877 | 877 | $sth = $this->db->prepare($query); |
878 | 878 | $sth->execute($query_values); |
879 | - } catch(PDOException $e) { |
|
879 | + } catch (PDOException $e) { |
|
880 | 880 | return "error : ".$e->getMessage(); |
881 | 881 | } |
882 | 882 | } |
883 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
883 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
884 | 884 | global $globalDBdriver; |
885 | 885 | if ($filter_name == '') $filter_name = $this->filter_name; |
886 | 886 | if ($globalDBdriver == 'mysql') { |
@@ -889,219 +889,219 @@ discard block |
||
889 | 889 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
890 | 890 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
891 | 891 | } |
892 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
892 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
893 | 893 | try { |
894 | 894 | $sth = $this->db->prepare($query); |
895 | 895 | $sth->execute($query_values); |
896 | - } catch(PDOException $e) { |
|
896 | + } catch (PDOException $e) { |
|
897 | 897 | return "error : ".$e->getMessage(); |
898 | 898 | } |
899 | 899 | } |
900 | - public function getStatsSource($date,$stats_type = '') { |
|
900 | + public function getStatsSource($date, $stats_type = '') { |
|
901 | 901 | if ($stats_type == '') { |
902 | 902 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
903 | 903 | $query_values = array(':date' => $date); |
904 | 904 | } else { |
905 | 905 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
906 | - $query_values = array(':date' => $date,':stats_type' => $stats_type); |
|
906 | + $query_values = array(':date' => $date, ':stats_type' => $stats_type); |
|
907 | 907 | } |
908 | 908 | try { |
909 | 909 | $sth = $this->db->prepare($query); |
910 | 910 | $sth->execute($query_values); |
911 | - } catch(PDOException $e) { |
|
911 | + } catch (PDOException $e) { |
|
912 | 912 | echo "error : ".$e->getMessage(); |
913 | 913 | } |
914 | 914 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
915 | 915 | return $all; |
916 | 916 | } |
917 | 917 | |
918 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
918 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
919 | 919 | global $globalDBdriver; |
920 | 920 | if ($globalDBdriver == 'mysql') { |
921 | 921 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
922 | 922 | } else { |
923 | 923 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
924 | 924 | } |
925 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
925 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
926 | 926 | try { |
927 | 927 | $sth = $this->db->prepare($query); |
928 | 928 | $sth->execute($query_values); |
929 | - } catch(PDOException $e) { |
|
929 | + } catch (PDOException $e) { |
|
930 | 930 | return "error : ".$e->getMessage(); |
931 | 931 | } |
932 | 932 | } |
933 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
933 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
934 | 934 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
935 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
935 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
936 | 936 | try { |
937 | 937 | $sth = $this->db->prepare($query); |
938 | 938 | $sth->execute($query_values); |
939 | - } catch(PDOException $e) { |
|
939 | + } catch (PDOException $e) { |
|
940 | 940 | return "error : ".$e->getMessage(); |
941 | 941 | } |
942 | 942 | } |
943 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
|
943 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '') { |
|
944 | 944 | global $globalDBdriver; |
945 | 945 | if ($globalDBdriver == 'mysql') { |
946 | 946 | $query = "INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) VALUES (:aircraft_icao,:registration,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
947 | 947 | } else { |
948 | 948 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
949 | 949 | } |
950 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
950 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
951 | 951 | try { |
952 | 952 | $sth = $this->db->prepare($query); |
953 | 953 | $sth->execute($query_values); |
954 | - } catch(PDOException $e) { |
|
954 | + } catch (PDOException $e) { |
|
955 | 955 | return "error : ".$e->getMessage(); |
956 | 956 | } |
957 | 957 | } |
958 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
|
958 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '') { |
|
959 | 959 | global $globalDBdriver; |
960 | 960 | if ($globalDBdriver == 'mysql') { |
961 | 961 | $query = "INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) VALUES (:callsign_icao,:airline_icao,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
962 | 962 | } else { |
963 | 963 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
964 | 964 | } |
965 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
965 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
966 | 966 | try { |
967 | 967 | $sth = $this->db->prepare($query); |
968 | 968 | $sth->execute($query_values); |
969 | - } catch(PDOException $e) { |
|
969 | + } catch (PDOException $e) { |
|
970 | 970 | return "error : ".$e->getMessage(); |
971 | 971 | } |
972 | 972 | } |
973 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
|
973 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '') { |
|
974 | 974 | global $globalDBdriver; |
975 | 975 | if ($globalDBdriver == 'mysql') { |
976 | 976 | $query = "INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) VALUES (:iso2,:iso3,:name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
977 | 977 | } else { |
978 | 978 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; |
979 | 979 | } |
980 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
980 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
981 | 981 | try { |
982 | 982 | $sth = $this->db->prepare($query); |
983 | 983 | $sth->execute($query_values); |
984 | - } catch(PDOException $e) { |
|
984 | + } catch (PDOException $e) { |
|
985 | 985 | return "error : ".$e->getMessage(); |
986 | 986 | } |
987 | 987 | } |
988 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
|
988 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
|
989 | 989 | global $globalDBdriver; |
990 | 990 | if ($globalDBdriver == 'mysql') { |
991 | 991 | $query = "INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline, filter_name) VALUES (:aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, stats_airline = :stats_airline"; |
992 | 992 | } else { |
993 | 993 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
994 | 994 | } |
995 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
995 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
996 | 996 | try { |
997 | 997 | $sth = $this->db->prepare($query); |
998 | 998 | $sth->execute($query_values); |
999 | - } catch(PDOException $e) { |
|
999 | + } catch (PDOException $e) { |
|
1000 | 1000 | return "error : ".$e->getMessage(); |
1001 | 1001 | } |
1002 | 1002 | } |
1003 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
|
1003 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '') { |
|
1004 | 1004 | global $globalDBdriver; |
1005 | 1005 | if ($globalDBdriver == 'mysql') { |
1006 | 1006 | $query = "INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) VALUES (:airline_icao,:airline_name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt,airline_name = :airline_name"; |
1007 | 1007 | } else { |
1008 | 1008 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1009 | 1009 | } |
1010 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1010 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1011 | 1011 | try { |
1012 | 1012 | $sth = $this->db->prepare($query); |
1013 | 1013 | $sth->execute($query_values); |
1014 | - } catch(PDOException $e) { |
|
1014 | + } catch (PDOException $e) { |
|
1015 | 1015 | return "error : ".$e->getMessage(); |
1016 | 1016 | } |
1017 | 1017 | } |
1018 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
|
1018 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
1019 | 1019 | global $globalDBdriver; |
1020 | 1020 | if ($globalDBdriver == 'mysql') { |
1021 | 1021 | $query = "INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) VALUES (:owner_name,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt"; |
1022 | 1022 | } else { |
1023 | 1023 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1024 | 1024 | } |
1025 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1025 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1026 | 1026 | try { |
1027 | 1027 | $sth = $this->db->prepare($query); |
1028 | 1028 | $sth->execute($query_values); |
1029 | - } catch(PDOException $e) { |
|
1029 | + } catch (PDOException $e) { |
|
1030 | 1030 | return "error : ".$e->getMessage(); |
1031 | 1031 | } |
1032 | 1032 | } |
1033 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '') { |
|
1033 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '') { |
|
1034 | 1034 | global $globalDBdriver; |
1035 | 1035 | if ($globalDBdriver == 'mysql') { |
1036 | 1036 | $query = "INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) VALUES (:pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, pilot_name = :pilot_name"; |
1037 | 1037 | } else { |
1038 | 1038 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1039 | 1039 | } |
1040 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1040 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1041 | 1041 | try { |
1042 | 1042 | $sth = $this->db->prepare($query); |
1043 | 1043 | $sth->execute($query_values); |
1044 | - } catch(PDOException $e) { |
|
1044 | + } catch (PDOException $e) { |
|
1045 | 1045 | return "error : ".$e->getMessage(); |
1046 | 1046 | } |
1047 | 1047 | } |
1048 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1048 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1049 | 1049 | global $globalDBdriver; |
1050 | 1050 | if ($globalDBdriver == 'mysql') { |
1051 | 1051 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = departure+:departure"; |
1052 | 1052 | } else { |
1053 | 1053 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1054 | 1054 | } |
1055 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1055 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1056 | 1056 | try { |
1057 | 1057 | $sth = $this->db->prepare($query); |
1058 | 1058 | $sth->execute($query_values); |
1059 | - } catch(PDOException $e) { |
|
1059 | + } catch (PDOException $e) { |
|
1060 | 1060 | return "error : ".$e->getMessage(); |
1061 | 1061 | } |
1062 | 1062 | } |
1063 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1063 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1064 | 1064 | global $globalDBdriver; |
1065 | 1065 | if ($globalDBdriver == 'mysql') { |
1066 | 1066 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = :departure"; |
1067 | 1067 | } else { |
1068 | 1068 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1069 | 1069 | } |
1070 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1070 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1071 | 1071 | try { |
1072 | 1072 | $sth = $this->db->prepare($query); |
1073 | 1073 | $sth->execute($query_values); |
1074 | - } catch(PDOException $e) { |
|
1074 | + } catch (PDOException $e) { |
|
1075 | 1075 | return "error : ".$e->getMessage(); |
1076 | 1076 | } |
1077 | 1077 | } |
1078 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1078 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1079 | 1079 | global $globalDBdriver; |
1080 | 1080 | if ($globalDBdriver == 'mysql') { |
1081 | 1081 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = arrival+:arrival"; |
1082 | 1082 | } else { |
1083 | 1083 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1084 | 1084 | } |
1085 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1085 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1086 | 1086 | try { |
1087 | 1087 | $sth = $this->db->prepare($query); |
1088 | 1088 | $sth->execute($query_values); |
1089 | - } catch(PDOException $e) { |
|
1089 | + } catch (PDOException $e) { |
|
1090 | 1090 | return "error : ".$e->getMessage(); |
1091 | 1091 | } |
1092 | 1092 | } |
1093 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1093 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1094 | 1094 | global $globalDBdriver; |
1095 | 1095 | if ($globalDBdriver == 'mysql') { |
1096 | 1096 | $query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = :arrival"; |
1097 | 1097 | } else { |
1098 | 1098 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1099 | 1099 | } |
1100 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1100 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1101 | 1101 | try { |
1102 | 1102 | $sth = $this->db->prepare($query); |
1103 | 1103 | $sth->execute($query_values); |
1104 | - } catch(PDOException $e) { |
|
1104 | + } catch (PDOException $e) { |
|
1105 | 1105 | return "error : ".$e->getMessage(); |
1106 | 1106 | } |
1107 | 1107 | } |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | try { |
1113 | 1113 | $sth = $this->db->prepare($query); |
1114 | 1114 | $sth->execute($query_values); |
1115 | - } catch(PDOException $e) { |
|
1115 | + } catch (PDOException $e) { |
|
1116 | 1116 | return "error : ".$e->getMessage(); |
1117 | 1117 | } |
1118 | 1118 | } |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | try { |
1123 | 1123 | $sth = $this->db->prepare($query); |
1124 | 1124 | $sth->execute($query_values); |
1125 | - } catch(PDOException $e) { |
|
1125 | + } catch (PDOException $e) { |
|
1126 | 1126 | return "error : ".$e->getMessage(); |
1127 | 1127 | } |
1128 | 1128 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | try { |
1133 | 1133 | $sth = $this->db->prepare($query); |
1134 | 1134 | $sth->execute($query_values); |
1135 | - } catch(PDOException $e) { |
|
1135 | + } catch (PDOException $e) { |
|
1136 | 1136 | return "error : ".$e->getMessage(); |
1137 | 1137 | } |
1138 | 1138 | } |
@@ -1371,40 +1371,40 @@ discard block |
||
1371 | 1371 | $last_update_day = $last_update[0]['value']; |
1372 | 1372 | } else $last_update_day = '2012-12-12 12:12:12'; |
1373 | 1373 | $Spotter = new Spotter($this->db); |
1374 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
1374 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
1375 | 1375 | foreach ($alldata as $number) { |
1376 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
|
1376 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer']); |
|
1377 | 1377 | } |
1378 | 1378 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
1379 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
1379 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
1380 | 1380 | foreach ($alldata as $number) { |
1381 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
|
1381 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']); |
|
1382 | 1382 | } |
1383 | 1383 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
1384 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
1384 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
1385 | 1385 | foreach ($alldata as $number) { |
1386 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
|
1386 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']); |
|
1387 | 1387 | } |
1388 | 1388 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
1389 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
1389 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
1390 | 1390 | foreach ($alldata as $number) { |
1391 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
|
1391 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']); |
|
1392 | 1392 | } |
1393 | 1393 | if ($globalDebug) echo 'Count all owners...'."\n"; |
1394 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
1394 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
1395 | 1395 | foreach ($alldata as $number) { |
1396 | - $this->addStatOwner($number['owner_name'],$number['owner_count']); |
|
1396 | + $this->addStatOwner($number['owner_name'], $number['owner_count']); |
|
1397 | 1397 | } |
1398 | 1398 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
1399 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
1399 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
1400 | 1400 | foreach ($alldata as $number) { |
1401 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name']); |
|
1401 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name']); |
|
1402 | 1402 | } |
1403 | 1403 | |
1404 | 1404 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1405 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
1405 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
1406 | 1406 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1407 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1407 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
1408 | 1408 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1409 | 1409 | $alldata = array(); |
1410 | 1410 | |
@@ -1422,14 +1422,14 @@ discard block |
||
1422 | 1422 | foreach ($alldata as $key => $row) { |
1423 | 1423 | $count[$key] = $row['airport_departure_icao_count']; |
1424 | 1424 | } |
1425 | - array_multisort($count,SORT_DESC,$alldata); |
|
1425 | + array_multisort($count, SORT_DESC, $alldata); |
|
1426 | 1426 | foreach ($alldata as $number) { |
1427 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
|
1427 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']); |
|
1428 | 1428 | } |
1429 | 1429 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1430 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
1430 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
1431 | 1431 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1432 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1432 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
1433 | 1433 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1434 | 1434 | $alldata = array(); |
1435 | 1435 | foreach ($pall as $value) { |
@@ -1446,16 +1446,16 @@ discard block |
||
1446 | 1446 | foreach ($alldata as $key => $row) { |
1447 | 1447 | $count[$key] = $row['airport_arrival_icao_count']; |
1448 | 1448 | } |
1449 | - array_multisort($count,SORT_DESC,$alldata); |
|
1449 | + array_multisort($count, SORT_DESC, $alldata); |
|
1450 | 1450 | foreach ($alldata as $number) { |
1451 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
|
1451 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']); |
|
1452 | 1452 | } |
1453 | 1453 | if ($Connection->tableExists('countries')) { |
1454 | 1454 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
1455 | 1455 | $SpotterArchive = new SpotterArchive(); |
1456 | - $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
|
1456 | + $alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day); |
|
1457 | 1457 | foreach ($alldata as $number) { |
1458 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']); |
|
1458 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']); |
|
1459 | 1459 | } |
1460 | 1460 | } |
1461 | 1461 | |
@@ -1469,37 +1469,37 @@ discard block |
||
1469 | 1469 | $lastyear = false; |
1470 | 1470 | foreach ($alldata as $number) { |
1471 | 1471 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1472 | - $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']))); |
|
1472 | + $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 | 1473 | } |
1474 | 1474 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
1475 | 1475 | $alldata = $Spotter->countAllMilitaryMonths(); |
1476 | 1476 | foreach ($alldata as $number) { |
1477 | - $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']))); |
|
1477 | + $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 | 1478 | } |
1479 | 1479 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
1480 | 1480 | $alldata = $Spotter->countAllMonthsOwners(); |
1481 | 1481 | foreach ($alldata as $number) { |
1482 | - $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']))); |
|
1482 | + $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 | 1483 | } |
1484 | 1484 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
1485 | 1485 | $alldata = $Spotter->countAllMonthsPilots(); |
1486 | 1486 | foreach ($alldata as $number) { |
1487 | - $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']))); |
|
1487 | + $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 | 1488 | } |
1489 | 1489 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
1490 | 1490 | $alldata = $Spotter->countAllMonthsAirlines(); |
1491 | 1491 | foreach ($alldata as $number) { |
1492 | - $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']))); |
|
1492 | + $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 | 1493 | } |
1494 | 1494 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
1495 | 1495 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1496 | 1496 | foreach ($alldata as $number) { |
1497 | - $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']))); |
|
1497 | + $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 | 1498 | } |
1499 | 1499 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
1500 | 1500 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1501 | 1501 | foreach ($alldata as $number) { |
1502 | - $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']))); |
|
1502 | + $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 | 1503 | } |
1504 | 1504 | if ($globalDebug) echo 'Airports data...'."\n"; |
1505 | 1505 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | } |
1545 | 1545 | $alldata = $pall; |
1546 | 1546 | foreach ($alldata as $number) { |
1547 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
1547 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
1548 | 1548 | } |
1549 | 1549 | echo '...Arrival'."\n"; |
1550 | 1550 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -1586,7 +1586,7 @@ discard block |
||
1586 | 1586 | } |
1587 | 1587 | $alldata = $pall; |
1588 | 1588 | foreach ($alldata as $number) { |
1589 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
1589 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
1590 | 1590 | } |
1591 | 1591 | |
1592 | 1592 | echo 'Flights data...'."\n"; |
@@ -1594,28 +1594,28 @@ discard block |
||
1594 | 1594 | echo '-> countAllDatesLastMonth...'."\n"; |
1595 | 1595 | $alldata = $Spotter->countAllDatesLastMonth(); |
1596 | 1596 | foreach ($alldata as $number) { |
1597 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
1597 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
1598 | 1598 | } |
1599 | 1599 | echo '-> countAllDates...'."\n"; |
1600 | 1600 | $previousdata = $this->countAllDates(); |
1601 | 1601 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
1602 | 1602 | $this->deleteStatFlight('date'); |
1603 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates()); |
|
1603 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates()); |
|
1604 | 1604 | $values = array(); |
1605 | 1605 | foreach ($alldata as $cnt) { |
1606 | 1606 | $values[] = $cnt['date_count']; |
1607 | 1607 | } |
1608 | - array_multisort($values,SORT_DESC,$alldata); |
|
1609 | - array_splice($alldata,11); |
|
1608 | + array_multisort($values, SORT_DESC, $alldata); |
|
1609 | + array_splice($alldata, 11); |
|
1610 | 1610 | foreach ($alldata as $number) { |
1611 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
1611 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
1612 | 1612 | } |
1613 | 1613 | |
1614 | 1614 | $this->deleteStatFlight('hour'); |
1615 | 1615 | echo '-> countAllHours...'."\n"; |
1616 | 1616 | $alldata = $Spotter->countAllHours('hour'); |
1617 | 1617 | foreach ($alldata as $number) { |
1618 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
1618 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
1619 | 1619 | } |
1620 | 1620 | |
1621 | 1621 | |
@@ -1624,34 +1624,34 @@ discard block |
||
1624 | 1624 | echo '--- Stats by airlines ---'."\n"; |
1625 | 1625 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
1626 | 1626 | $Spotter = new Spotter($this->db); |
1627 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
1627 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
1628 | 1628 | foreach ($alldata as $number) { |
1629 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
|
1629 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao']); |
|
1630 | 1630 | } |
1631 | 1631 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
1632 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
1632 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
1633 | 1633 | foreach ($alldata as $number) { |
1634 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
|
1634 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao']); |
|
1635 | 1635 | } |
1636 | 1636 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
1637 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
1637 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
1638 | 1638 | foreach ($alldata as $number) { |
1639 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
|
1639 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']); |
|
1640 | 1640 | } |
1641 | 1641 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
1642 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
1642 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
1643 | 1643 | foreach ($alldata as $number) { |
1644 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
|
1644 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao']); |
|
1645 | 1645 | } |
1646 | 1646 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
1647 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
1647 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
1648 | 1648 | foreach ($alldata as $number) { |
1649 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao']); |
|
1649 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao']); |
|
1650 | 1650 | } |
1651 | 1651 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1652 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1652 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1653 | 1653 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1654 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1654 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1655 | 1655 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1656 | 1656 | //$alldata = array(); |
1657 | 1657 | foreach ($dall as $value) { |
@@ -1671,12 +1671,12 @@ discard block |
||
1671 | 1671 | } |
1672 | 1672 | $alldata = $pall; |
1673 | 1673 | foreach ($alldata as $number) { |
1674 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao']); |
|
1674 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao']); |
|
1675 | 1675 | } |
1676 | 1676 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1677 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1677 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1678 | 1678 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1679 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1679 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1680 | 1680 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1681 | 1681 | //$alldata = array(); |
1682 | 1682 | foreach ($dall as $value) { |
@@ -1696,7 +1696,7 @@ discard block |
||
1696 | 1696 | } |
1697 | 1697 | $alldata = $pall; |
1698 | 1698 | foreach ($alldata as $number) { |
1699 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao']); |
|
1699 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao']); |
|
1700 | 1700 | } |
1701 | 1701 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
1702 | 1702 | $Spotter = new Spotter($this->db); |
@@ -1704,27 +1704,27 @@ discard block |
||
1704 | 1704 | $lastyear = false; |
1705 | 1705 | foreach ($alldata as $number) { |
1706 | 1706 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1707 | - $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']); |
|
1707 | + $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 | 1708 | } |
1709 | 1709 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
1710 | 1710 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1711 | 1711 | foreach ($alldata as $number) { |
1712 | - $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']); |
|
1712 | + $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 | 1713 | } |
1714 | 1714 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
1715 | 1715 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1716 | 1716 | foreach ($alldata as $number) { |
1717 | - $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']); |
|
1717 | + $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 | 1718 | } |
1719 | 1719 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
1720 | 1720 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1721 | 1721 | foreach ($alldata as $number) { |
1722 | - $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']); |
|
1722 | + $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 | 1723 | } |
1724 | 1724 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
1725 | 1725 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1726 | 1726 | foreach ($alldata as $number) { |
1727 | - $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']); |
|
1727 | + $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 | 1728 | } |
1729 | 1729 | if ($globalDebug) echo '...Departure'."\n"; |
1730 | 1730 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -1747,7 +1747,7 @@ discard block |
||
1747 | 1747 | } |
1748 | 1748 | $alldata = $pall; |
1749 | 1749 | foreach ($alldata as $number) { |
1750 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
|
1750 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']); |
|
1751 | 1751 | } |
1752 | 1752 | if ($globalDebug) echo '...Arrival'."\n"; |
1753 | 1753 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -1770,32 +1770,32 @@ discard block |
||
1770 | 1770 | } |
1771 | 1771 | $alldata = $pall; |
1772 | 1772 | foreach ($alldata as $number) { |
1773 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
|
1773 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']); |
|
1774 | 1774 | } |
1775 | 1775 | |
1776 | 1776 | if ($globalDebug) echo 'Flights data...'."\n"; |
1777 | 1777 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
1778 | 1778 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1779 | 1779 | foreach ($alldata as $number) { |
1780 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
1780 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1781 | 1781 | } |
1782 | 1782 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
1783 | 1783 | //$previousdata = $this->countAllDatesByAirlines(); |
1784 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
|
1784 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines()); |
|
1785 | 1785 | $values = array(); |
1786 | 1786 | foreach ($alldata as $cnt) { |
1787 | 1787 | $values[] = $cnt['date_count']; |
1788 | 1788 | } |
1789 | - array_multisort($values,SORT_DESC,$alldata); |
|
1790 | - array_splice($alldata,11); |
|
1789 | + array_multisort($values, SORT_DESC, $alldata); |
|
1790 | + array_splice($alldata, 11); |
|
1791 | 1791 | foreach ($alldata as $number) { |
1792 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
1792 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1793 | 1793 | } |
1794 | 1794 | |
1795 | 1795 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
1796 | 1796 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1797 | 1797 | foreach ($alldata as $number) { |
1798 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
1798 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
1799 | 1799 | } |
1800 | 1800 | |
1801 | 1801 | |
@@ -1806,33 +1806,33 @@ discard block |
||
1806 | 1806 | // Count by filter |
1807 | 1807 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
1808 | 1808 | $Spotter = new Spotter($this->db); |
1809 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
1809 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
1810 | 1810 | foreach ($alldata as $number) { |
1811 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name); |
|
1811 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name); |
|
1812 | 1812 | } |
1813 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
1813 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
1814 | 1814 | foreach ($alldata as $number) { |
1815 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name); |
|
1815 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name); |
|
1816 | 1816 | } |
1817 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
1817 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
1818 | 1818 | foreach ($alldata as $number) { |
1819 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name); |
|
1819 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name); |
|
1820 | 1820 | } |
1821 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
1821 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
1822 | 1822 | foreach ($alldata as $number) { |
1823 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name); |
|
1823 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name); |
|
1824 | 1824 | } |
1825 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
1825 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
1826 | 1826 | foreach ($alldata as $number) { |
1827 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name); |
|
1827 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name); |
|
1828 | 1828 | } |
1829 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
1829 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
1830 | 1830 | foreach ($alldata as $number) { |
1831 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name); |
|
1831 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name); |
|
1832 | 1832 | } |
1833 | 1833 | |
1834 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
1835 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1834 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
1835 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
1836 | 1836 | $alldata = array(); |
1837 | 1837 | foreach ($pall as $value) { |
1838 | 1838 | $icao = $value['airport_departure_icao']; |
@@ -1848,12 +1848,12 @@ discard block |
||
1848 | 1848 | foreach ($alldata as $key => $row) { |
1849 | 1849 | $count[$key] = $row['airport_departure_icao_count']; |
1850 | 1850 | } |
1851 | - array_multisort($count,SORT_DESC,$alldata); |
|
1851 | + array_multisort($count, SORT_DESC, $alldata); |
|
1852 | 1852 | foreach ($alldata as $number) { |
1853 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name); |
|
1853 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name); |
|
1854 | 1854 | } |
1855 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter); |
|
1856 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1855 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, $filter); |
|
1856 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, $filter); |
|
1857 | 1857 | $alldata = array(); |
1858 | 1858 | foreach ($pall as $value) { |
1859 | 1859 | $icao = $value['airport_arrival_icao']; |
@@ -1869,36 +1869,36 @@ discard block |
||
1869 | 1869 | foreach ($alldata as $key => $row) { |
1870 | 1870 | $count[$key] = $row['airport_arrival_icao_count']; |
1871 | 1871 | } |
1872 | - array_multisort($count,SORT_DESC,$alldata); |
|
1872 | + array_multisort($count, SORT_DESC, $alldata); |
|
1873 | 1873 | foreach ($alldata as $number) { |
1874 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name); |
|
1874 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name); |
|
1875 | 1875 | } |
1876 | 1876 | $Spotter = new Spotter($this->db); |
1877 | 1877 | $alldata = $Spotter->countAllMonths($filter); |
1878 | 1878 | $lastyear = false; |
1879 | 1879 | foreach ($alldata as $number) { |
1880 | 1880 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1881 | - $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); |
|
1881 | + $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 | 1882 | } |
1883 | 1883 | $alldata = $Spotter->countAllMonthsOwners($filter); |
1884 | 1884 | foreach ($alldata as $number) { |
1885 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
1885 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
1886 | 1886 | } |
1887 | 1887 | $alldata = $Spotter->countAllMonthsPilots($filter); |
1888 | 1888 | foreach ($alldata as $number) { |
1889 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
1889 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
1890 | 1890 | } |
1891 | 1891 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
1892 | 1892 | foreach ($alldata as $number) { |
1893 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
1893 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
1894 | 1894 | } |
1895 | 1895 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
1896 | 1896 | foreach ($alldata as $number) { |
1897 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
1897 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
1898 | 1898 | } |
1899 | 1899 | echo '...Departure'."\n"; |
1900 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
1901 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1900 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
1901 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
1902 | 1902 | foreach ($dall as $value) { |
1903 | 1903 | $icao = $value['departure_airport_icao']; |
1904 | 1904 | $ddate = $value['date']; |
@@ -1916,11 +1916,11 @@ discard block |
||
1916 | 1916 | } |
1917 | 1917 | $alldata = $pall; |
1918 | 1918 | foreach ($alldata as $number) { |
1919 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
|
1919 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name); |
|
1920 | 1920 | } |
1921 | 1921 | echo '...Arrival'."\n"; |
1922 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
1923 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1922 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
1923 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
1924 | 1924 | foreach ($dall as $value) { |
1925 | 1925 | $icao = $value['arrival_airport_icao']; |
1926 | 1926 | $ddate = $value['date']; |
@@ -1938,32 +1938,32 @@ discard block |
||
1938 | 1938 | } |
1939 | 1939 | $alldata = $pall; |
1940 | 1940 | foreach ($alldata as $number) { |
1941 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
|
1941 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name); |
|
1942 | 1942 | } |
1943 | 1943 | |
1944 | 1944 | echo 'Flights data...'."\n"; |
1945 | 1945 | echo '-> countAllDatesLastMonth...'."\n"; |
1946 | 1946 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
1947 | 1947 | foreach ($alldata as $number) { |
1948 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
1948 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
1949 | 1949 | } |
1950 | 1950 | echo '-> countAllDates...'."\n"; |
1951 | - $previousdata = $this->countAllDates('',$filter_name); |
|
1952 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
1951 | + $previousdata = $this->countAllDates('', $filter_name); |
|
1952 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
1953 | 1953 | $values = array(); |
1954 | 1954 | foreach ($alldata as $cnt) { |
1955 | 1955 | $values[] = $cnt['date_count']; |
1956 | 1956 | } |
1957 | - array_multisort($values,SORT_DESC,$alldata); |
|
1958 | - array_splice($alldata,11); |
|
1957 | + array_multisort($values, SORT_DESC, $alldata); |
|
1958 | + array_splice($alldata, 11); |
|
1959 | 1959 | foreach ($alldata as $number) { |
1960 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
1960 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
1961 | 1961 | } |
1962 | 1962 | |
1963 | 1963 | echo '-> countAllHours...'."\n"; |
1964 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
1964 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
1965 | 1965 | foreach ($alldata as $number) { |
1966 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
1966 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
1967 | 1967 | } |
1968 | 1968 | } |
1969 | 1969 | |
@@ -1974,16 +1974,16 @@ discard block |
||
1974 | 1974 | // SUM all previous month to put as year |
1975 | 1975 | $previous_year = date('Y'); |
1976 | 1976 | $previous_year--; |
1977 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1978 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1979 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1980 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1977 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1978 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1979 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1980 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1981 | 1981 | $allairlines = $this->getAllAirlineNames(); |
1982 | 1982 | foreach ($allairlines as $data) { |
1983 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1984 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1985 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1986 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1983 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1984 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1985 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1986 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1987 | 1987 | } |
1988 | 1988 | |
1989 | 1989 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -1992,7 +1992,7 @@ discard block |
||
1992 | 1992 | try { |
1993 | 1993 | $sth = $this->db->prepare($query); |
1994 | 1994 | $sth->execute(); |
1995 | - } catch(PDOException $e) { |
|
1995 | + } catch (PDOException $e) { |
|
1996 | 1996 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
1997 | 1997 | } |
1998 | 1998 | } |
@@ -2001,7 +2001,7 @@ discard block |
||
2001 | 2001 | try { |
2002 | 2002 | $sth = $this->db->prepare($query); |
2003 | 2003 | $sth->execute(); |
2004 | - } catch(PDOException $e) { |
|
2004 | + } catch (PDOException $e) { |
|
2005 | 2005 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2006 | 2006 | } |
2007 | 2007 | } |
@@ -2023,7 +2023,7 @@ discard block |
||
2023 | 2023 | try { |
2024 | 2024 | $sth = $this->db->prepare($query); |
2025 | 2025 | $sth->execute(); |
2026 | - } catch(PDOException $e) { |
|
2026 | + } catch (PDOException $e) { |
|
2027 | 2027 | return "error : ".$e->getMessage(); |
2028 | 2028 | } |
2029 | 2029 | } |
@@ -2037,13 +2037,13 @@ discard block |
||
2037 | 2037 | try { |
2038 | 2038 | $sth = $this->db->prepare($query); |
2039 | 2039 | $sth->execute(); |
2040 | - } catch(PDOException $e) { |
|
2040 | + } catch (PDOException $e) { |
|
2041 | 2041 | return "error : ".$e->getMessage(); |
2042 | 2042 | } |
2043 | 2043 | } |
2044 | 2044 | echo 'Insert last stats update date...'."\n"; |
2045 | 2045 | date_default_timezone_set('UTC'); |
2046 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
2046 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
2047 | 2047 | //} |
2048 | 2048 | } |
2049 | 2049 | } |
@@ -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); |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | fclose($fp); |
25 | 25 | } |
26 | 26 | |
27 | - public static function gunzip($in_file,$out_file_name = '') { |
|
27 | + public static function gunzip($in_file, $out_file_name = '') { |
|
28 | 28 | //echo $in_file.' -> '.$out_file_name."\n"; |
29 | 29 | $buffer_size = 4096; // read 4kb at a time |
30 | 30 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
31 | 31 | if ($in_file != '' && file_exists($in_file)) { |
32 | 32 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
33 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
34 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
35 | 35 | else { |
36 | 36 | echo 'gzopen not available'; |
37 | 37 | die; |
38 | 38 | } |
39 | 39 | $out_file = fopen($out_file_name, 'wb'); |
40 | - while(!gzeof($file)) { |
|
40 | + while (!gzeof($file)) { |
|
41 | 41 | fwrite($out_file, gzread($file, $buffer_size)); |
42 | 42 | } |
43 | 43 | fclose($out_file); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | try { |
62 | 62 | self::$db_sqlite = new PDO('sqlite:'.$database); |
63 | 63 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
64 | - } catch(PDOException $e) { |
|
64 | + } catch (PDOException $e) { |
|
65 | 65 | return "error : ".$e->getMessage(); |
66 | 66 | } |
67 | 67 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | //$Connection = new Connection(); |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(array(':source' => $database_file)); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error : ".$e->getMessage(); |
81 | 81 | } |
82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | try { |
88 | 88 | $sth = update_db::$db_sqlite->prepare($query); |
89 | 89 | $sth->execute(); |
90 | - } catch(PDOException $e) { |
|
90 | + } catch (PDOException $e) { |
|
91 | 91 | return "error : ".$e->getMessage(); |
92 | 92 | } |
93 | 93 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
99 | 99 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
100 | 100 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
101 | - $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
|
101 | + $query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file); |
|
102 | 102 | $sth_dest->execute($query_dest_values); |
103 | 103 | } |
104 | 104 | if ($globalTransaction) $Connection->db->commit(); |
105 | - } catch(PDOException $e) { |
|
105 | + } catch (PDOException $e) { |
|
106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
@@ -118,26 +118,26 @@ discard block |
||
118 | 118 | //$Connection = new Connection(); |
119 | 119 | $sth = $Connection->db->prepare($query); |
120 | 120 | $sth->execute(array(':source' => 'oneworld')); |
121 | - } catch(PDOException $e) { |
|
121 | + } catch (PDOException $e) { |
|
122 | 122 | return "error : ".$e->getMessage(); |
123 | 123 | } |
124 | 124 | |
125 | 125 | if ($globalDebug) echo " - Add routes to DB -"; |
126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
127 | 127 | $Spotter = new Spotter(); |
128 | - if ($fh = fopen($database_file,"r")) { |
|
128 | + if ($fh = fopen($database_file, "r")) { |
|
129 | 129 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
130 | 130 | $Connection = new Connection(); |
131 | 131 | $sth_dest = $Connection->db->prepare($query_dest); |
132 | 132 | if ($globalTransaction) $Connection->db->beginTransaction(); |
133 | 133 | while (!feof($fh)) { |
134 | - $line = fgetcsv($fh,9999,','); |
|
134 | + $line = fgetcsv($fh, 9999, ','); |
|
135 | 135 | if ($line[0] != '') { |
136 | 136 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
137 | 137 | try { |
138 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
|
138 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); |
|
139 | 139 | $sth_dest->execute($query_dest_values); |
140 | - } catch(PDOException $e) { |
|
140 | + } catch (PDOException $e) { |
|
141 | 141 | if ($globalTransaction) $Connection->db->rollBack(); |
142 | 142 | return "error : ".$e->getMessage(); |
143 | 143 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | //$Connection = new Connection(); |
160 | 160 | $sth = $Connection->db->prepare($query); |
161 | 161 | $sth->execute(array(':source' => 'skyteam')); |
162 | - } catch(PDOException $e) { |
|
162 | + } catch (PDOException $e) { |
|
163 | 163 | return "error : ".$e->getMessage(); |
164 | 164 | } |
165 | 165 | |
@@ -167,24 +167,24 @@ discard block |
||
167 | 167 | |
168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
169 | 169 | $Spotter = new Spotter(); |
170 | - if ($fh = fopen($database_file,"r")) { |
|
170 | + if ($fh = fopen($database_file, "r")) { |
|
171 | 171 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
172 | 172 | $Connection = new Connection(); |
173 | 173 | $sth_dest = $Connection->db->prepare($query_dest); |
174 | 174 | try { |
175 | 175 | if ($globalTransaction) $Connection->db->beginTransaction(); |
176 | 176 | while (!feof($fh)) { |
177 | - $line = fgetcsv($fh,9999,','); |
|
177 | + $line = fgetcsv($fh, 9999, ','); |
|
178 | 178 | if ($line[0] != '') { |
179 | - $datebe = explode(' - ',$line[2]); |
|
179 | + $datebe = explode(' - ', $line[2]); |
|
180 | 180 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
181 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
181 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
182 | 182 | $sth_dest->execute($query_dest_values); |
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
186 | 186 | if ($globalTransaction) $Connection->db->commit(); |
187 | - } catch(PDOException $e) { |
|
187 | + } catch (PDOException $e) { |
|
188 | 188 | if ($globalTransaction) $Connection->db->rollBack(); |
189 | 189 | return "error : ".$e->getMessage(); |
190 | 190 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $Connection = new Connection(); |
200 | 200 | $sth = $Connection->db->prepare($query); |
201 | 201 | $sth->execute(array(':source' => $database_file)); |
202 | - } catch(PDOException $e) { |
|
202 | + } catch (PDOException $e) { |
|
203 | 203 | return "error : ".$e->getMessage(); |
204 | 204 | } |
205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $Connection = new Connection(); |
208 | 208 | $sth = $Connection->db->prepare($query); |
209 | 209 | $sth->execute(array(':source' => $database_file)); |
210 | - } catch(PDOException $e) { |
|
210 | + } catch (PDOException $e) { |
|
211 | 211 | return "error : ".$e->getMessage(); |
212 | 212 | } |
213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | try { |
217 | 217 | $sth = update_db::$db_sqlite->prepare($query); |
218 | 218 | $sth->execute(); |
219 | - } catch(PDOException $e) { |
|
219 | + } catch (PDOException $e) { |
|
220 | 220 | return "error : ".$e->getMessage(); |
221 | 221 | } |
222 | 222 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
234 | 234 | if ($values['UserString4'] == 'M') $type = 'military'; |
235 | 235 | else $type = null; |
236 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
236 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
237 | 237 | $sth_dest->execute($query_dest_values); |
238 | 238 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
239 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
239 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
240 | 240 | $sth_dest_owner->execute($query_dest_owner_values); |
241 | 241 | } |
242 | 242 | } |
243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
244 | - } catch(PDOException $e) { |
|
244 | + } catch (PDOException $e) { |
|
245 | 245 | return "error : ".$e->getMessage(); |
246 | 246 | } |
247 | 247 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $Connection = new Connection(); |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(array(':source' => $database_file)); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error : ".$e->getMessage(); |
255 | 255 | } |
256 | 256 | return ''; |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | $Connection = new Connection(); |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(array(':source' => $database_file)); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error : ".$e->getMessage(); |
270 | 270 | } |
271 | 271 | |
272 | - if ($fh = fopen($database_file,"r")) { |
|
272 | + if ($fh = fopen($database_file, "r")) { |
|
273 | 273 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
274 | 274 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
275 | 275 | |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | if ($globalTransaction) $Connection->db->beginTransaction(); |
280 | 280 | while (!feof($fh)) { |
281 | 281 | $values = array(); |
282 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
282 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
283 | 283 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
284 | - $values['ModeS'] = substr($line,0,6); |
|
285 | - $values['Registration'] = trim(substr($line,69,6)); |
|
286 | - $aircraft_name = trim(substr($line,48,6)); |
|
284 | + $values['ModeS'] = substr($line, 0, 6); |
|
285 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
286 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
287 | 287 | // Check if we can find ICAO, else set it to GLID |
288 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
288 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
289 | 289 | $search_more = ''; |
290 | 290 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
291 | 291 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -297,20 +297,20 @@ discard block |
||
297 | 297 | if (isset($result['icao']) && $result['icao'] != '') { |
298 | 298 | $values['ICAOTypeCode'] = $result['icao']; |
299 | 299 | } |
300 | - } catch(PDOException $e) { |
|
300 | + } catch (PDOException $e) { |
|
301 | 301 | return "error : ".$e->getMessage(); |
302 | 302 | } |
303 | 303 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
304 | 304 | // Add data to db |
305 | 305 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
306 | 306 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
307 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
307 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
308 | 308 | //print_r($query_dest_values); |
309 | 309 | $sth_dest->execute($query_dest_values); |
310 | 310 | } |
311 | 311 | } |
312 | 312 | if ($globalTransaction) $Connection->db->commit(); |
313 | - } catch(PDOException $e) { |
|
313 | + } catch (PDOException $e) { |
|
314 | 314 | return "error : ".$e->getMessage(); |
315 | 315 | } |
316 | 316 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $Connection = new Connection(); |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(array(':source' => $database_file)); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error : ".$e->getMessage(); |
325 | 325 | } |
326 | 326 | return ''; |
@@ -334,11 +334,11 @@ discard block |
||
334 | 334 | $Connection = new Connection(); |
335 | 335 | $sth = $Connection->db->prepare($query); |
336 | 336 | $sth->execute(array(':source' => $database_file)); |
337 | - } catch(PDOException $e) { |
|
337 | + } catch (PDOException $e) { |
|
338 | 338 | return "error : ".$e->getMessage(); |
339 | 339 | } |
340 | 340 | |
341 | - if ($fh = fopen($database_file,"r")) { |
|
341 | + if ($fh = fopen($database_file, "r")) { |
|
342 | 342 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
343 | 343 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
344 | 344 | |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | $sth_dest = $Connection->db->prepare($query_dest); |
347 | 347 | try { |
348 | 348 | if ($globalTransaction) $Connection->db->beginTransaction(); |
349 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
349 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
350 | 350 | while (!feof($fh)) { |
351 | - $line = fgetcsv($fh,9999,',',"'"); |
|
351 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
352 | 352 | |
353 | 353 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
354 | 354 | //print_r($line); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $values['Registration'] = $line[3]; |
357 | 357 | $aircraft_name = $line[2]; |
358 | 358 | // Check if we can find ICAO, else set it to GLID |
359 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
359 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
360 | 360 | $search_more = ''; |
361 | 361 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
362 | 362 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -365,20 +365,20 @@ discard block |
||
365 | 365 | $sth_search->execute(); |
366 | 366 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
367 | 367 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
368 | - } catch(PDOException $e) { |
|
368 | + } catch (PDOException $e) { |
|
369 | 369 | return "error : ".$e->getMessage(); |
370 | 370 | } |
371 | 371 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
372 | 372 | // Add data to db |
373 | 373 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
374 | 374 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
375 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
375 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
376 | 376 | //print_r($query_dest_values); |
377 | 377 | $sth_dest->execute($query_dest_values); |
378 | 378 | } |
379 | 379 | } |
380 | 380 | if ($globalTransaction) $Connection->db->commit(); |
381 | - } catch(PDOException $e) { |
|
381 | + } catch (PDOException $e) { |
|
382 | 382 | return "error : ".$e->getMessage(); |
383 | 383 | } |
384 | 384 | } |
@@ -388,13 +388,13 @@ discard block |
||
388 | 388 | $Connection = new Connection(); |
389 | 389 | $sth = $Connection->db->prepare($query); |
390 | 390 | $sth->execute(array(':source' => $database_file)); |
391 | - } catch(PDOException $e) { |
|
391 | + } catch (PDOException $e) { |
|
392 | 392 | return "error : ".$e->getMessage(); |
393 | 393 | } |
394 | 394 | return ''; |
395 | 395 | } |
396 | 396 | |
397 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
397 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
398 | 398 | global $globalTransaction; |
399 | 399 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
400 | 400 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -402,11 +402,11 @@ discard block |
||
402 | 402 | $Connection = new Connection(); |
403 | 403 | $sth = $Connection->db->prepare($query); |
404 | 404 | $sth->execute(array(':source' => $database_file)); |
405 | - } catch(PDOException $e) { |
|
405 | + } catch (PDOException $e) { |
|
406 | 406 | return "error : ".$e->getMessage(); |
407 | 407 | } |
408 | 408 | |
409 | - if ($fh = fopen($database_file,"r")) { |
|
409 | + if ($fh = fopen($database_file, "r")) { |
|
410 | 410 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
411 | 411 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
412 | 412 | |
@@ -414,9 +414,9 @@ discard block |
||
414 | 414 | $sth_dest = $Connection->db->prepare($query_dest); |
415 | 415 | try { |
416 | 416 | if ($globalTransaction) $Connection->db->beginTransaction(); |
417 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
417 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
418 | 418 | while (!feof($fh)) { |
419 | - $line = fgetcsv($fh,9999,',','"'); |
|
419 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
420 | 420 | $values = array(); |
421 | 421 | //print_r($line); |
422 | 422 | if ($country == 'F') { |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | $values['base'] = $line[4]; |
425 | 425 | $values['owner'] = $line[5]; |
426 | 426 | if ($line[6] == '') $values['date_first_reg'] = null; |
427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
427 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
428 | 428 | $values['cancel'] = $line[7]; |
429 | 429 | } elseif ($country == 'EI') { |
430 | 430 | // TODO : add modeS & reg to aircraft_modes |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $values['base'] = $line[3]; |
433 | 433 | $values['owner'] = $line[2]; |
434 | 434 | if ($line[1] == '') $values['date_first_reg'] = null; |
435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
435 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
436 | 436 | $values['cancel'] = ''; |
437 | 437 | } elseif ($country == 'HB') { |
438 | 438 | // TODO : add modeS & reg to aircraft_modes |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | $values['base'] = null; |
448 | 448 | $values['owner'] = $line[5]; |
449 | 449 | if ($line[18] == '') $values['date_first_reg'] = null; |
450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
450 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
451 | 451 | $values['cancel'] = ''; |
452 | 452 | } elseif ($country == 'VH') { |
453 | 453 | // TODO : add modeS & reg to aircraft_modes |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | $values['base'] = null; |
456 | 456 | $values['owner'] = $line[12]; |
457 | 457 | if ($line[28] == '') $values['date_first_reg'] = null; |
458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
458 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
459 | 459 | |
460 | 460 | $values['cancel'] = $line[39]; |
461 | 461 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -475,28 +475,28 @@ discard block |
||
475 | 475 | $values['base'] = null; |
476 | 476 | $values['owner'] = $line[8]; |
477 | 477 | if ($line[7] == '') $values['date_first_reg'] = null; |
478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
478 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
479 | 479 | $values['cancel'] = ''; |
480 | 480 | } elseif ($country == 'PP') { |
481 | 481 | $values['registration'] = $line[0]; |
482 | 482 | $values['base'] = null; |
483 | 483 | $values['owner'] = $line[4]; |
484 | 484 | if ($line[6] == '') $values['date_first_reg'] = null; |
485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
485 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
486 | 486 | $values['cancel'] = $line[7]; |
487 | 487 | } elseif ($country == 'E7') { |
488 | 488 | $values['registration'] = $line[0]; |
489 | 489 | $values['base'] = null; |
490 | 490 | $values['owner'] = $line[4]; |
491 | 491 | if ($line[5] == '') $values['date_first_reg'] = null; |
492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
492 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
493 | 493 | $values['cancel'] = ''; |
494 | 494 | } elseif ($country == '8Q') { |
495 | 495 | $values['registration'] = $line[0]; |
496 | 496 | $values['base'] = null; |
497 | 497 | $values['owner'] = $line[3]; |
498 | 498 | if ($line[7] == '') $values['date_first_reg'] = null; |
499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
499 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
500 | 500 | $values['cancel'] = ''; |
501 | 501 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
502 | 502 | $values['registration'] = $line[0]; |
@@ -506,12 +506,12 @@ discard block |
||
506 | 506 | $values['cancel'] = ''; |
507 | 507 | } |
508 | 508 | if ($values['cancel'] == '' && $values['registration'] != null) { |
509 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
509 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
510 | 510 | $sth_dest->execute($query_dest_values); |
511 | 511 | } |
512 | 512 | } |
513 | 513 | if ($globalTransaction) $Connection->db->commit(); |
514 | - } catch(PDOException $e) { |
|
514 | + } catch (PDOException $e) { |
|
515 | 515 | return "error : ".$e->getMessage(); |
516 | 516 | } |
517 | 517 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | $Connection = new Connection(); |
627 | 627 | $sth = $Connection->db->prepare($query); |
628 | 628 | $sth->execute(); |
629 | - } catch(PDOException $e) { |
|
629 | + } catch (PDOException $e) { |
|
630 | 630 | return "error : ".$e->getMessage(); |
631 | 631 | } |
632 | 632 | |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | $Connection = new Connection(); |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error : ".$e->getMessage(); |
641 | 641 | } |
642 | 642 | |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | if ($globalTransaction) $Connection->db->beginTransaction(); |
648 | 648 | |
649 | 649 | $i = 0; |
650 | - while($row = sparql_fetch_array($result)) |
|
650 | + while ($row = sparql_fetch_array($result)) |
|
651 | 651 | { |
652 | 652 | if ($i >= 1) { |
653 | 653 | //print_r($row); |
@@ -667,31 +667,31 @@ discard block |
||
667 | 667 | $row['image'] = ''; |
668 | 668 | $row['image_thumb'] = ''; |
669 | 669 | } else { |
670 | - $image = str_replace(' ','_',$row['image']); |
|
670 | + $image = str_replace(' ', '_', $row['image']); |
|
671 | 671 | $digest = md5($image); |
672 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
673 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
674 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
675 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
672 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
673 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
674 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
675 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
676 | 676 | } |
677 | 677 | |
678 | - $country = explode('-',$row['country']); |
|
678 | + $country = explode('-', $row['country']); |
|
679 | 679 | $row['country'] = $country[0]; |
680 | 680 | |
681 | 681 | $row['type'] = trim($row['type']); |
682 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
682 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
683 | 683 | $row['type'] = 'Military'; |
684 | 684 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
685 | 685 | $row['type'] = 'small_airport'; |
686 | 686 | } |
687 | 687 | |
688 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
689 | - $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
688 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
689 | + $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
690 | 690 | //print_r($query_dest_values); |
691 | 691 | |
692 | 692 | try { |
693 | 693 | $sth_dest->execute($query_dest_values); |
694 | - } catch(PDOException $e) { |
|
694 | + } catch (PDOException $e) { |
|
695 | 695 | return "error : ".$e->getMessage(); |
696 | 696 | } |
697 | 697 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | $Connection = new Connection(); |
706 | 706 | $sth = $Connection->db->prepare($query); |
707 | 707 | $sth->execute(); |
708 | - } catch(PDOException $e) { |
|
708 | + } catch (PDOException $e) { |
|
709 | 709 | return "error : ".$e->getMessage(); |
710 | 710 | } |
711 | 711 | |
@@ -713,12 +713,12 @@ discard block |
||
713 | 713 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
714 | 714 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
715 | 715 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
716 | - $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
|
716 | + $query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => ''); |
|
717 | 717 | try { |
718 | 718 | $Connection = new Connection(); |
719 | 719 | $sth = $Connection->db->prepare($query); |
720 | 720 | $sth->execute($query_values); |
721 | - } catch(PDOException $e) { |
|
721 | + } catch (PDOException $e) { |
|
722 | 722 | return "error : ".$e->getMessage(); |
723 | 723 | } |
724 | 724 | $i++; |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | echo "Download data from ourairports.com...\n"; |
737 | 737 | $delimiter = ','; |
738 | 738 | $out_file = $tmp_dir.'airports.csv'; |
739 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
739 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
740 | 740 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
741 | 741 | echo "Add data from ourairports.com...\n"; |
742 | 742 | |
@@ -747,32 +747,32 @@ discard block |
||
747 | 747 | //$Connection->db->beginTransaction(); |
748 | 748 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
749 | 749 | { |
750 | - if(!$header) $header = $row; |
|
750 | + if (!$header) $header = $row; |
|
751 | 751 | else { |
752 | 752 | $data = array(); |
753 | 753 | $data = array_combine($header, $row); |
754 | 754 | try { |
755 | 755 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); |
756 | 756 | $sth->execute(array(':icao' => $data['gps_code'])); |
757 | - } catch(PDOException $e) { |
|
757 | + } catch (PDOException $e) { |
|
758 | 758 | return "error : ".$e->getMessage(); |
759 | 759 | } |
760 | 760 | if ($sth->fetchColumn() > 0) { |
761 | 761 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
762 | 762 | try { |
763 | 763 | $sth = $Connection->db->prepare($query); |
764 | - $sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); |
|
765 | - } catch(PDOException $e) { |
|
764 | + $sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); |
|
765 | + } catch (PDOException $e) { |
|
766 | 766 | return "error : ".$e->getMessage(); |
767 | 767 | } |
768 | 768 | } else { |
769 | 769 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) |
770 | 770 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
771 | - $query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
771 | + $query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
772 | 772 | try { |
773 | 773 | $sth = $Connection->db->prepare($query); |
774 | 774 | $sth->execute($query_values); |
775 | - } catch(PDOException $e) { |
|
775 | + } catch (PDOException $e) { |
|
776 | 776 | return "error : ".$e->getMessage(); |
777 | 777 | } |
778 | 778 | $i++; |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | |
786 | 786 | echo "Download data from another free database...\n"; |
787 | 787 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
788 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
788 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
789 | 789 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
790 | 790 | update_db::unzip($out_file); |
791 | 791 | $header = NULL; |
@@ -797,15 +797,15 @@ discard block |
||
797 | 797 | //$Connection->db->beginTransaction(); |
798 | 798 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
799 | 799 | { |
800 | - if(!$header) $header = $row; |
|
800 | + if (!$header) $header = $row; |
|
801 | 801 | else { |
802 | 802 | $data = $row; |
803 | 803 | |
804 | 804 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
805 | 805 | try { |
806 | 806 | $sth = $Connection->db->prepare($query); |
807 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
808 | - } catch(PDOException $e) { |
|
807 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
808 | + } catch (PDOException $e) { |
|
809 | 809 | return "error : ".$e->getMessage(); |
810 | 810 | } |
811 | 811 | } |
@@ -819,15 +819,15 @@ discard block |
||
819 | 819 | try { |
820 | 820 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); |
821 | 821 | $sth->execute(); |
822 | - } catch(PDOException $e) { |
|
822 | + } catch (PDOException $e) { |
|
823 | 823 | return "error : ".$e->getMessage(); |
824 | 824 | } |
825 | 825 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
826 | 826 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
827 | 827 | try { |
828 | 828 | $sth2 = $Connection->db->prepare($query2); |
829 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
830 | - } catch(PDOException $e) { |
|
829 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
830 | + } catch (PDOException $e) { |
|
831 | 831 | return "error : ".$e->getMessage(); |
832 | 832 | } |
833 | 833 | } |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | $Connection = new Connection(); |
852 | 852 | $sth = $Connection->db->prepare($query); |
853 | 853 | $sth->execute(array(':source' => 'translation.csv')); |
854 | - } catch(PDOException $e) { |
|
854 | + } catch (PDOException $e) { |
|
855 | 855 | return "error : ".$e->getMessage(); |
856 | 856 | } |
857 | 857 | |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
869 | 869 | { |
870 | 870 | $i++; |
871 | - if($i > 12) { |
|
871 | + if ($i > 12) { |
|
872 | 872 | $data = $row; |
873 | 873 | $operator = $data[2]; |
874 | 874 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | //echo substr($operator, 0, 2)."\n";; |
877 | 877 | if (count($airline_array) > 0) { |
878 | 878 | //print_r($airline_array); |
879 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
879 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
880 | 880 | } |
881 | 881 | } |
882 | 882 | |
@@ -884,14 +884,14 @@ discard block |
||
884 | 884 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
885 | 885 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
886 | 886 | if (count($airline_array) > 0) { |
887 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
887 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
888 | 888 | } |
889 | 889 | } |
890 | 890 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
891 | 891 | try { |
892 | 892 | $sth = $Connection->db->prepare($query); |
893 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
894 | - } catch(PDOException $e) { |
|
893 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
894 | + } catch (PDOException $e) { |
|
895 | 895 | return "error : ".$e->getMessage(); |
896 | 896 | } |
897 | 897 | } |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | $Connection = new Connection(); |
912 | 912 | $sth = $Connection->db->prepare($query); |
913 | 913 | $sth->execute(array(':source' => 'website_fam')); |
914 | - } catch(PDOException $e) { |
|
914 | + } catch (PDOException $e) { |
|
915 | 915 | return "error : ".$e->getMessage(); |
916 | 916 | } |
917 | 917 | |
@@ -931,8 +931,8 @@ discard block |
||
931 | 931 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
932 | 932 | try { |
933 | 933 | $sth = $Connection->db->prepare($query); |
934 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
935 | - } catch(PDOException $e) { |
|
934 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
935 | + } catch (PDOException $e) { |
|
936 | 936 | return "error : ".$e->getMessage(); |
937 | 937 | } |
938 | 938 | } |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | return ''; |
945 | 945 | } |
946 | 946 | |
947 | - public static function tle($filename,$tletype) { |
|
947 | + public static function tle($filename, $tletype) { |
|
948 | 948 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
949 | 949 | global $tmp_dir, $globalTransaction; |
950 | 950 | //$Spotter = new Spotter(); |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | $Connection = new Connection(); |
955 | 955 | $sth = $Connection->db->prepare($query); |
956 | 956 | $sth->execute(array(':source' => $filename)); |
957 | - } catch(PDOException $e) { |
|
957 | + } catch (PDOException $e) { |
|
958 | 958 | return "error : ".$e->getMessage(); |
959 | 959 | } |
960 | 960 | |
@@ -979,8 +979,8 @@ discard block |
||
979 | 979 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
980 | 980 | try { |
981 | 981 | $sth = $Connection->db->prepare($query); |
982 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
983 | - } catch(PDOException $e) { |
|
982 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
983 | + } catch (PDOException $e) { |
|
984 | 984 | return "error : ".$e->getMessage(); |
985 | 985 | } |
986 | 986 | |
@@ -1000,28 +1000,28 @@ discard block |
||
1000 | 1000 | */ |
1001 | 1001 | private static function table2array($data) { |
1002 | 1002 | $html = str_get_html($data); |
1003 | - $tabledata=array(); |
|
1004 | - foreach($html->find('tr') as $element) |
|
1003 | + $tabledata = array(); |
|
1004 | + foreach ($html->find('tr') as $element) |
|
1005 | 1005 | { |
1006 | 1006 | $td = array(); |
1007 | - foreach( $element->find('th') as $row) |
|
1007 | + foreach ($element->find('th') as $row) |
|
1008 | 1008 | { |
1009 | 1009 | $td [] = trim($row->plaintext); |
1010 | 1010 | } |
1011 | - $td=array_filter($td); |
|
1011 | + $td = array_filter($td); |
|
1012 | 1012 | $tabledata[] = $td; |
1013 | 1013 | |
1014 | 1014 | $td = array(); |
1015 | 1015 | $tdi = array(); |
1016 | - foreach( $element->find('td') as $row) |
|
1016 | + foreach ($element->find('td') as $row) |
|
1017 | 1017 | { |
1018 | 1018 | $td [] = trim($row->plaintext); |
1019 | 1019 | $tdi [] = trim($row->innertext); |
1020 | 1020 | } |
1021 | - $td=array_filter($td); |
|
1022 | - $tdi=array_filter($tdi); |
|
1021 | + $td = array_filter($td); |
|
1022 | + $tdi = array_filter($tdi); |
|
1023 | 1023 | // $tabledata[]=array_merge($td,$tdi); |
1024 | - $tabledata[]=$td; |
|
1024 | + $tabledata[] = $td; |
|
1025 | 1025 | } |
1026 | 1026 | return(array_filter($tabledata)); |
1027 | 1027 | } |
@@ -1094,13 +1094,13 @@ discard block |
||
1094 | 1094 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1095 | 1095 | { |
1096 | 1096 | $i++; |
1097 | - if($i > 3 && count($row) > 2) { |
|
1097 | + if ($i > 3 && count($row) > 2) { |
|
1098 | 1098 | $data = array_values(array_filter($row)); |
1099 | 1099 | $cntdata = count($data); |
1100 | 1100 | if ($cntdata > 10) { |
1101 | 1101 | $value = $data[9]; |
1102 | 1102 | |
1103 | - for ($i =10;$i < $cntdata;$i++) { |
|
1103 | + for ($i = 10; $i < $cntdata; $i++) { |
|
1104 | 1104 | $value .= ' '.$data[$i]; |
1105 | 1105 | } |
1106 | 1106 | $data[9] = $value; |
@@ -1110,8 +1110,8 @@ discard block |
||
1110 | 1110 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
1111 | 1111 | try { |
1112 | 1112 | $sth = $Connection->db->prepare($query); |
1113 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1114 | - } catch(PDOException $e) { |
|
1113 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1114 | + } catch (PDOException $e) { |
|
1115 | 1115 | return "error : ".$e->getMessage(); |
1116 | 1116 | } |
1117 | 1117 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | $Connection = new Connection(); |
1133 | 1133 | $sth = $Connection->db->prepare($query); |
1134 | 1134 | $sth->execute(); |
1135 | - } catch(PDOException $e) { |
|
1135 | + } catch (PDOException $e) { |
|
1136 | 1136 | return "error : ".$e->getMessage(); |
1137 | 1137 | } |
1138 | 1138 | |
@@ -1144,12 +1144,12 @@ discard block |
||
1144 | 1144 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1145 | 1145 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1146 | 1146 | { |
1147 | - if(count($row) > 1) { |
|
1147 | + if (count($row) > 1) { |
|
1148 | 1148 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
1149 | 1149 | try { |
1150 | 1150 | $sth = $Connection->db->prepare($query); |
1151 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
1152 | - } catch(PDOException $e) { |
|
1151 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
1152 | + } catch (PDOException $e) { |
|
1153 | 1153 | return "error : ".$e->getMessage(); |
1154 | 1154 | } |
1155 | 1155 | } |
@@ -1169,21 +1169,21 @@ discard block |
||
1169 | 1169 | try { |
1170 | 1170 | $sth = $Connection->db->prepare($query); |
1171 | 1171 | $sth->execute(); |
1172 | - } catch(PDOException $e) { |
|
1172 | + } catch (PDOException $e) { |
|
1173 | 1173 | return "error : ".$e->getMessage(); |
1174 | 1174 | } |
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | |
1178 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1178 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1179 | 1179 | else { |
1180 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1180 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1181 | 1181 | $query = "CREATE EXTENSION postgis"; |
1182 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
1182 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
1183 | 1183 | try { |
1184 | 1184 | $sth = $Connection->db->prepare($query); |
1185 | 1185 | $sth->execute(); |
1186 | - } catch(PDOException $e) { |
|
1186 | + } catch (PDOException $e) { |
|
1187 | 1187 | return "error : ".$e->getMessage(); |
1188 | 1188 | } |
1189 | 1189 | } |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | include_once('class.create_db.php'); |
1197 | 1197 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1198 | 1198 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
1199 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
1199 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
1200 | 1200 | $error = ''; |
1201 | 1201 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1202 | 1202 | if ($globalDebug) echo "Gunzip..."; |
@@ -1228,14 +1228,14 @@ discard block |
||
1228 | 1228 | try { |
1229 | 1229 | $sth = $Connection->db->prepare($query); |
1230 | 1230 | $sth->execute(); |
1231 | - } catch(PDOException $e) { |
|
1231 | + } catch (PDOException $e) { |
|
1232 | 1232 | echo "error : ".$e->getMessage(); |
1233 | 1233 | } |
1234 | 1234 | } |
1235 | 1235 | if ($globalDBdriver == 'mysql') { |
1236 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1236 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1237 | 1237 | } else { |
1238 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1238 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1239 | 1239 | } |
1240 | 1240 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
1241 | 1241 | return $error; |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
1249 | 1249 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
1250 | 1250 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
1251 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
1251 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
1252 | 1252 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
1253 | 1253 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
1254 | 1254 | return $error; |
@@ -1268,7 +1268,7 @@ discard block |
||
1268 | 1268 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1269 | 1269 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
1270 | 1270 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1271 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1271 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1272 | 1272 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
1273 | 1273 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
1274 | 1274 | if ($error != '') { |
@@ -1281,7 +1281,7 @@ discard block |
||
1281 | 1281 | global $tmp_dir, $globalDebug; |
1282 | 1282 | $error = ''; |
1283 | 1283 | if ($globalDebug) echo "Routes : Download..."; |
1284 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
1284 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
1285 | 1285 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1286 | 1286 | if ($globalDebug) echo "Gunzip..."; |
1287 | 1287 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | global $tmp_dir, $globalDebug; |
1298 | 1298 | $error = ''; |
1299 | 1299 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
1300 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
1300 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
1301 | 1301 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1302 | 1302 | if ($globalDebug) echo "Gunzip..."; |
1303 | 1303 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1313,7 +1313,7 @@ discard block |
||
1313 | 1313 | global $tmp_dir, $globalDebug; |
1314 | 1314 | $error = ''; |
1315 | 1315 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
1316 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
1316 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
1317 | 1317 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1318 | 1318 | if ($globalDebug) echo "Gunzip..."; |
1319 | 1319 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | } elseif ($globalDebug) echo "Done\n"; |
1341 | 1341 | */ |
1342 | 1342 | if ($globalDebug) echo "Modes : Download..."; |
1343 | - update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1343 | + update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip', $tmp_dir.'basestation_latest.zip', 'http://planebase.biz/bstnsqb'); |
|
1344 | 1344 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1345 | 1345 | if ($globalDebug) echo "Unzip..."; |
1346 | 1346 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
@@ -1356,7 +1356,7 @@ discard block |
||
1356 | 1356 | public static function update_ModeS_flarm() { |
1357 | 1357 | global $tmp_dir, $globalDebug; |
1358 | 1358 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
1359 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
1359 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
1360 | 1360 | if (file_exists($tmp_dir.'data.fln')) { |
1361 | 1361 | if ($globalDebug) echo "Add to DB..."; |
1362 | 1362 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | public static function update_ModeS_ogn() { |
1371 | 1371 | global $tmp_dir, $globalDebug; |
1372 | 1372 | if ($globalDebug) echo "Modes OGN: Download..."; |
1373 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
1373 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
1374 | 1374 | if (file_exists($tmp_dir.'ogn.csv')) { |
1375 | 1375 | if ($globalDebug) echo "Add to DB..."; |
1376 | 1376 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1385,173 +1385,173 @@ discard block |
||
1385 | 1385 | global $tmp_dir, $globalDebug; |
1386 | 1386 | |
1387 | 1387 | if ($globalDebug) echo "Owner France: Download..."; |
1388 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
1388 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
1389 | 1389 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1390 | 1390 | if ($globalDebug) echo "Add to DB..."; |
1391 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
1391 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
1392 | 1392 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
1393 | 1393 | if ($error != '') { |
1394 | 1394 | return $error; |
1395 | 1395 | } elseif ($globalDebug) echo "Done\n"; |
1396 | 1396 | |
1397 | 1397 | if ($globalDebug) echo "Owner Ireland: Download..."; |
1398 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
1398 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
1399 | 1399 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1400 | 1400 | if ($globalDebug) echo "Add to DB..."; |
1401 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
1401 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
1402 | 1402 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
1403 | 1403 | if ($error != '') { |
1404 | 1404 | return $error; |
1405 | 1405 | } elseif ($globalDebug) echo "Done\n"; |
1406 | 1406 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
1407 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
1407 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
1408 | 1408 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1409 | 1409 | if ($globalDebug) echo "Add to DB..."; |
1410 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
1410 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
1411 | 1411 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
1412 | 1412 | if ($error != '') { |
1413 | 1413 | return $error; |
1414 | 1414 | } elseif ($globalDebug) echo "Done\n"; |
1415 | 1415 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
1416 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
1416 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
1417 | 1417 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1418 | 1418 | if ($globalDebug) echo "Add to DB..."; |
1419 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
1419 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
1420 | 1420 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
1421 | 1421 | if ($error != '') { |
1422 | 1422 | return $error; |
1423 | 1423 | } elseif ($globalDebug) echo "Done\n"; |
1424 | 1424 | if ($globalDebug) echo "Owner Australia: Download..."; |
1425 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
1425 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
1426 | 1426 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1427 | 1427 | if ($globalDebug) echo "Add to DB..."; |
1428 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
1428 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
1429 | 1429 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
1430 | 1430 | if ($error != '') { |
1431 | 1431 | return $error; |
1432 | 1432 | } elseif ($globalDebug) echo "Done\n"; |
1433 | 1433 | if ($globalDebug) echo "Owner Austria: Download..."; |
1434 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
1434 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
1435 | 1435 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1436 | 1436 | if ($globalDebug) echo "Add to DB..."; |
1437 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
1437 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
1438 | 1438 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
1439 | 1439 | if ($error != '') { |
1440 | 1440 | return $error; |
1441 | 1441 | } elseif ($globalDebug) echo "Done\n"; |
1442 | 1442 | if ($globalDebug) echo "Owner Chile: Download..."; |
1443 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
1443 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
1444 | 1444 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1445 | 1445 | if ($globalDebug) echo "Add to DB..."; |
1446 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
1446 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
1447 | 1447 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
1448 | 1448 | if ($error != '') { |
1449 | 1449 | return $error; |
1450 | 1450 | } elseif ($globalDebug) echo "Done\n"; |
1451 | 1451 | if ($globalDebug) echo "Owner Colombia: Download..."; |
1452 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
1452 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
1453 | 1453 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1454 | 1454 | if ($globalDebug) echo "Add to DB..."; |
1455 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
1455 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
1456 | 1456 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
1457 | 1457 | if ($error != '') { |
1458 | 1458 | return $error; |
1459 | 1459 | } elseif ($globalDebug) echo "Done\n"; |
1460 | 1460 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
1461 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
1461 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
1462 | 1462 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1463 | 1463 | if ($globalDebug) echo "Add to DB..."; |
1464 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
1464 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
1465 | 1465 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
1466 | 1466 | if ($error != '') { |
1467 | 1467 | return $error; |
1468 | 1468 | } elseif ($globalDebug) echo "Done\n"; |
1469 | 1469 | if ($globalDebug) echo "Owner Brazil: Download..."; |
1470 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
1470 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
1471 | 1471 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1472 | 1472 | if ($globalDebug) echo "Add to DB..."; |
1473 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
1473 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
1474 | 1474 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
1475 | 1475 | if ($error != '') { |
1476 | 1476 | return $error; |
1477 | 1477 | } elseif ($globalDebug) echo "Done\n"; |
1478 | 1478 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
1479 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
1479 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
1480 | 1480 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1481 | 1481 | if ($globalDebug) echo "Add to DB..."; |
1482 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
1482 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
1483 | 1483 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
1484 | 1484 | if ($error != '') { |
1485 | 1485 | return $error; |
1486 | 1486 | } elseif ($globalDebug) echo "Done\n"; |
1487 | 1487 | if ($globalDebug) echo "Owner Croatia: Download..."; |
1488 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
1488 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
1489 | 1489 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1490 | 1490 | if ($globalDebug) echo "Add to DB..."; |
1491 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
1491 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
1492 | 1492 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
1493 | 1493 | if ($error != '') { |
1494 | 1494 | return $error; |
1495 | 1495 | } elseif ($globalDebug) echo "Done\n"; |
1496 | 1496 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
1497 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
1497 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
1498 | 1498 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1499 | 1499 | if ($globalDebug) echo "Add to DB..."; |
1500 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
1500 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
1501 | 1501 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
1502 | 1502 | if ($error != '') { |
1503 | 1503 | return $error; |
1504 | 1504 | } elseif ($globalDebug) echo "Done\n"; |
1505 | 1505 | if ($globalDebug) echo "Owner Maldives: Download..."; |
1506 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
1506 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
1507 | 1507 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1508 | 1508 | if ($globalDebug) echo "Add to DB..."; |
1509 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
1509 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
1510 | 1510 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
1511 | 1511 | if ($error != '') { |
1512 | 1512 | return $error; |
1513 | 1513 | } elseif ($globalDebug) echo "Done\n"; |
1514 | 1514 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
1515 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
1515 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
1516 | 1516 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1517 | 1517 | if ($globalDebug) echo "Add to DB..."; |
1518 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
1518 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
1519 | 1519 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
1520 | 1520 | if ($error != '') { |
1521 | 1521 | return $error; |
1522 | 1522 | } elseif ($globalDebug) echo "Done\n"; |
1523 | 1523 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
1524 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
1524 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
1525 | 1525 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1526 | 1526 | if ($globalDebug) echo "Add to DB..."; |
1527 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
1527 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
1528 | 1528 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
1529 | 1529 | if ($error != '') { |
1530 | 1530 | return $error; |
1531 | 1531 | } elseif ($globalDebug) echo "Done\n"; |
1532 | 1532 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
1533 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
1533 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
1534 | 1534 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1535 | 1535 | if ($globalDebug) echo "Add to DB..."; |
1536 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
1536 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
1537 | 1537 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
1538 | 1538 | if ($error != '') { |
1539 | 1539 | return $error; |
1540 | 1540 | } elseif ($globalDebug) echo "Done\n"; |
1541 | 1541 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
1542 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
1542 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
1543 | 1543 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1544 | 1544 | if ($globalDebug) echo "Add to DB..."; |
1545 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
1545 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
1546 | 1546 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
1547 | 1547 | if ($error != '') { |
1548 | 1548 | return $error; |
1549 | 1549 | } elseif ($globalDebug) echo "Done\n"; |
1550 | 1550 | if ($globalDebug) echo "Owner Iceland: Download..."; |
1551 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
1551 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
1552 | 1552 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1553 | 1553 | if ($globalDebug) echo "Add to DB..."; |
1554 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
1554 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
1555 | 1555 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
1556 | 1556 | if ($error != '') { |
1557 | 1557 | return $error; |
@@ -1563,7 +1563,7 @@ discard block |
||
1563 | 1563 | global $tmp_dir, $globalDebug; |
1564 | 1564 | $error = ''; |
1565 | 1565 | if ($globalDebug) echo "Translation : Download..."; |
1566 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
1566 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
1567 | 1567 | if (file_exists($tmp_dir.'translation.zip')) { |
1568 | 1568 | if ($globalDebug) echo "Unzip..."; |
1569 | 1569 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | public static function update_translation_fam() { |
1580 | 1580 | global $tmp_dir, $globalDebug; |
1581 | 1581 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
1582 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
1582 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
1583 | 1583 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1584 | 1584 | if ($globalDebug) echo "Gunzip..."; |
1585 | 1585 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1598,18 +1598,18 @@ discard block |
||
1598 | 1598 | $error = ''; |
1599 | 1599 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
1600 | 1600 | if ($globalDBdriver == 'mysql') { |
1601 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
1601 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
1602 | 1602 | } else { |
1603 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
1603 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
1604 | 1604 | } |
1605 | 1605 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
1606 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
1606 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
1607 | 1607 | $airspace_md5 = $airspace_md5_file[0]; |
1608 | 1608 | if (!update_db::check_airspace_version($airspace_md5)) { |
1609 | 1609 | if ($globalDBdriver == 'mysql') { |
1610 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
1610 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
1611 | 1611 | } else { |
1612 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
1612 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
1613 | 1613 | } |
1614 | 1614 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
1615 | 1615 | if ($globalDebug) echo "Gunzip..."; |
@@ -1621,7 +1621,7 @@ discard block |
||
1621 | 1621 | try { |
1622 | 1622 | $sth = $Connection->db->prepare($query); |
1623 | 1623 | $sth->execute(); |
1624 | - } catch(PDOException $e) { |
|
1624 | + } catch (PDOException $e) { |
|
1625 | 1625 | return "error : ".$e->getMessage(); |
1626 | 1626 | } |
1627 | 1627 | } |
@@ -1639,15 +1639,15 @@ discard block |
||
1639 | 1639 | public static function update_tle() { |
1640 | 1640 | global $tmp_dir, $globalDebug; |
1641 | 1641 | if ($globalDebug) echo "Download TLE : Download..."; |
1642 | - $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
|
1643 | - 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
|
1644 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
1642 | + $alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt', |
|
1643 | + 'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt', |
|
1644 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
1645 | 1645 | foreach ($alltle as $filename) { |
1646 | 1646 | if ($globalDebug) echo "downloading ".$filename.'...'; |
1647 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
1647 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
1648 | 1648 | if (file_exists($tmp_dir.$filename)) { |
1649 | 1649 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
1650 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
1650 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
1651 | 1651 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
1652 | 1652 | if ($error != '') { |
1653 | 1653 | echo $error."\n"; |
@@ -1660,32 +1660,32 @@ discard block |
||
1660 | 1660 | global $tmp_dir, $globalDebug; |
1661 | 1661 | $error = ''; |
1662 | 1662 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
1663 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
1663 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
1664 | 1664 | if (file_exists($tmp_dir.'models.md5sum')) { |
1665 | 1665 | if ($globalDebug) echo "Check files...\n"; |
1666 | 1666 | $newmodelsdb = array(); |
1667 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
1668 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1667 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
1668 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1669 | 1669 | $model = trim($row[2]); |
1670 | 1670 | $newmodelsdb[$model] = trim($row[0]); |
1671 | 1671 | } |
1672 | 1672 | } |
1673 | 1673 | $modelsdb = array(); |
1674 | 1674 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
1675 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
1676 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1675 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
1676 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1677 | 1677 | $model = trim($row[2]); |
1678 | 1678 | $modelsdb[$model] = trim($row[0]); |
1679 | 1679 | } |
1680 | 1680 | } |
1681 | 1681 | } |
1682 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
1682 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
1683 | 1683 | foreach ($diff as $key => $value) { |
1684 | 1684 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
1685 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
1685 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
1686 | 1686 | |
1687 | 1687 | } |
1688 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
1688 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
1689 | 1689 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
1690 | 1690 | if ($error != '') { |
1691 | 1691 | return $error; |
@@ -1697,32 +1697,32 @@ discard block |
||
1697 | 1697 | global $tmp_dir, $globalDebug; |
1698 | 1698 | $error = ''; |
1699 | 1699 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
1700 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
1700 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
1701 | 1701 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
1702 | 1702 | if ($globalDebug) echo "Check files...\n"; |
1703 | 1703 | $newmodelsdb = array(); |
1704 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
1705 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1704 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
1705 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1706 | 1706 | $model = trim($row[2]); |
1707 | 1707 | $newmodelsdb[$model] = trim($row[0]); |
1708 | 1708 | } |
1709 | 1709 | } |
1710 | 1710 | $modelsdb = array(); |
1711 | 1711 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
1712 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
1713 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1712 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
1713 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1714 | 1714 | $model = trim($row[2]); |
1715 | 1715 | $modelsdb[$model] = trim($row[0]); |
1716 | 1716 | } |
1717 | 1717 | } |
1718 | 1718 | } |
1719 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
1719 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
1720 | 1720 | foreach ($diff as $key => $value) { |
1721 | 1721 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
1722 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
1722 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
1723 | 1723 | |
1724 | 1724 | } |
1725 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
1725 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
1726 | 1726 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
1727 | 1727 | if ($error != '') { |
1728 | 1728 | return $error; |
@@ -1745,8 +1745,8 @@ discard block |
||
1745 | 1745 | */ |
1746 | 1746 | if (file_exists($tmp_dir.'aircrafts.html')) { |
1747 | 1747 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
1748 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
1749 | - $result = fread($fh,100000000); |
|
1748 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
1749 | + $result = fread($fh, 100000000); |
|
1750 | 1750 | //echo $result; |
1751 | 1751 | //var_dump(str_get_html($result)); |
1752 | 1752 | //print_r(self::table2array($result)); |
@@ -1764,23 +1764,23 @@ discard block |
||
1764 | 1764 | $Connection = new Connection(); |
1765 | 1765 | $sth = $Connection->db->prepare($query); |
1766 | 1766 | $sth->execute(); |
1767 | - } catch(PDOException $e) { |
|
1767 | + } catch (PDOException $e) { |
|
1768 | 1768 | return "error : ".$e->getMessage(); |
1769 | 1769 | } |
1770 | 1770 | |
1771 | 1771 | $error = ''; |
1772 | 1772 | if ($globalDebug) echo "Notam : Download..."; |
1773 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
1773 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
1774 | 1774 | if (file_exists($tmp_dir.'notam.rss')) { |
1775 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
1775 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
1776 | 1776 | foreach ($notams['channel']['item'] as $notam) { |
1777 | - $title = explode(':',$notam['title']); |
|
1777 | + $title = explode(':', $notam['title']); |
|
1778 | 1778 | $data['ref'] = trim($title[0]); |
1779 | 1779 | unset($title[0]); |
1780 | - $data['title'] = trim(implode(':',$title)); |
|
1781 | - $description = strip_tags($notam['description'],'<pre>'); |
|
1782 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
1783 | - $q = explode('/',$match[1]); |
|
1780 | + $data['title'] = trim(implode(':', $title)); |
|
1781 | + $description = strip_tags($notam['description'], '<pre>'); |
|
1782 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
1783 | + $q = explode('/', $match[1]); |
|
1784 | 1784 | $data['fir'] = $q[0]; |
1785 | 1785 | $data['code'] = $q[1]; |
1786 | 1786 | $ifrvfr = $q[2]; |
@@ -1796,30 +1796,30 @@ discard block |
||
1796 | 1796 | $data['lower_limit'] = $q[5]; |
1797 | 1797 | $data['upper_limit'] = $q[6]; |
1798 | 1798 | $latlonrad = $q[7]; |
1799 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
1800 | - $latitude = $Common->convertDec($las,'latitude'); |
|
1801 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
1799 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
1800 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
1801 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
1802 | 1802 | if ($lac == 'S') $latitude = '-'.$latitude; |
1803 | 1803 | if ($lnc == 'W') $longitude = '-'.$longitude; |
1804 | 1804 | $data['center_latitude'] = $latitude; |
1805 | 1805 | $data['center_longitude'] = $longitude; |
1806 | 1806 | $data['radius'] = intval($radius); |
1807 | 1807 | |
1808 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
1808 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
1809 | 1809 | $data['text'] = $match[1]; |
1810 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
1810 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
1811 | 1811 | $fromto = $match[1]; |
1812 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
1812 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
1813 | 1813 | $fromall = trim($match[1]); |
1814 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
1814 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
1815 | 1815 | $from = trim($match[1]); |
1816 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
1817 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
1816 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
1817 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
1818 | 1818 | $toall = trim($match[1]); |
1819 | - if (!preg_match(':Permanent:',$toall)) { |
|
1820 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
1819 | + if (!preg_match(':Permanent:', $toall)) { |
|
1820 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
1821 | 1821 | $to = trim($match[1]); |
1822 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
1822 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
1823 | 1823 | $data['permanent'] = 0; |
1824 | 1824 | } else { |
1825 | 1825 | $data['date_end'] = NULL; |
@@ -1827,7 +1827,7 @@ discard block |
||
1827 | 1827 | } |
1828 | 1828 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
1829 | 1829 | $NOTAM = new NOTAM(); |
1830 | - $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1830 | + $NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
1831 | 1831 | unset($data); |
1832 | 1832 | } |
1833 | 1833 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -1850,16 +1850,16 @@ discard block |
||
1850 | 1850 | $Connection = new Connection(); |
1851 | 1851 | $sth = $Connection->db->prepare($query); |
1852 | 1852 | $sth->execute(); |
1853 | - } catch(PDOException $e) { |
|
1853 | + } catch (PDOException $e) { |
|
1854 | 1854 | return "error : ".$e->getMessage(); |
1855 | 1855 | } |
1856 | 1856 | } |
1857 | 1857 | $Common = new Common(); |
1858 | 1858 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
1859 | - $airspace_json = json_decode($airspace_lst,true); |
|
1859 | + $airspace_json = json_decode($airspace_lst, true); |
|
1860 | 1860 | foreach ($airspace_json['records'] as $airspace) { |
1861 | 1861 | if ($globalDebug) echo $airspace['name']."...\n"; |
1862 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
1862 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
1863 | 1863 | if (file_exists($tmp_dir.$airspace['name'])) { |
1864 | 1864 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
1865 | 1865 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -1883,7 +1883,7 @@ discard block |
||
1883 | 1883 | $Connection = new Connection(); |
1884 | 1884 | $sth = $Connection->db->prepare($query); |
1885 | 1885 | $sth->execute(); |
1886 | - } catch(PDOException $e) { |
|
1886 | + } catch (PDOException $e) { |
|
1887 | 1887 | return "error : ".$e->getMessage(); |
1888 | 1888 | } |
1889 | 1889 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1898,7 +1898,7 @@ discard block |
||
1898 | 1898 | $Connection = new Connection(); |
1899 | 1899 | $sth = $Connection->db->prepare($query); |
1900 | 1900 | $sth->execute(); |
1901 | - } catch(PDOException $e) { |
|
1901 | + } catch (PDOException $e) { |
|
1902 | 1902 | return "error : ".$e->getMessage(); |
1903 | 1903 | } |
1904 | 1904 | } |
@@ -1909,7 +1909,7 @@ discard block |
||
1909 | 1909 | $Connection = new Connection(); |
1910 | 1910 | $sth = $Connection->db->prepare($query); |
1911 | 1911 | $sth->execute(array(':version' => $version)); |
1912 | - } catch(PDOException $e) { |
|
1912 | + } catch (PDOException $e) { |
|
1913 | 1913 | return "error : ".$e->getMessage(); |
1914 | 1914 | } |
1915 | 1915 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1925,7 +1925,7 @@ discard block |
||
1925 | 1925 | $Connection = new Connection(); |
1926 | 1926 | $sth = $Connection->db->prepare($query); |
1927 | 1927 | $sth->execute(array(':version' => $version)); |
1928 | - } catch(PDOException $e) { |
|
1928 | + } catch (PDOException $e) { |
|
1929 | 1929 | return "error : ".$e->getMessage(); |
1930 | 1930 | } |
1931 | 1931 | } |
@@ -1941,7 +1941,7 @@ discard block |
||
1941 | 1941 | $Connection = new Connection(); |
1942 | 1942 | $sth = $Connection->db->prepare($query); |
1943 | 1943 | $sth->execute(); |
1944 | - } catch(PDOException $e) { |
|
1944 | + } catch (PDOException $e) { |
|
1945 | 1945 | return "error : ".$e->getMessage(); |
1946 | 1946 | } |
1947 | 1947 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1956,7 +1956,7 @@ discard block |
||
1956 | 1956 | $Connection = new Connection(); |
1957 | 1957 | $sth = $Connection->db->prepare($query); |
1958 | 1958 | $sth->execute(); |
1959 | - } catch(PDOException $e) { |
|
1959 | + } catch (PDOException $e) { |
|
1960 | 1960 | return "error : ".$e->getMessage(); |
1961 | 1961 | } |
1962 | 1962 | } |
@@ -1971,7 +1971,7 @@ discard block |
||
1971 | 1971 | $Connection = new Connection(); |
1972 | 1972 | $sth = $Connection->db->prepare($query); |
1973 | 1973 | $sth->execute(); |
1974 | - } catch(PDOException $e) { |
|
1974 | + } catch (PDOException $e) { |
|
1975 | 1975 | return "error : ".$e->getMessage(); |
1976 | 1976 | } |
1977 | 1977 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1986,7 +1986,7 @@ discard block |
||
1986 | 1986 | $Connection = new Connection(); |
1987 | 1987 | $sth = $Connection->db->prepare($query); |
1988 | 1988 | $sth->execute(); |
1989 | - } catch(PDOException $e) { |
|
1989 | + } catch (PDOException $e) { |
|
1990 | 1990 | return "error : ".$e->getMessage(); |
1991 | 1991 | } |
1992 | 1992 | } |
@@ -2002,7 +2002,7 @@ discard block |
||
2002 | 2002 | $Connection = new Connection(); |
2003 | 2003 | $sth = $Connection->db->prepare($query); |
2004 | 2004 | $sth->execute(); |
2005 | - } catch(PDOException $e) { |
|
2005 | + } catch (PDOException $e) { |
|
2006 | 2006 | return "error : ".$e->getMessage(); |
2007 | 2007 | } |
2008 | 2008 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2017,7 +2017,7 @@ discard block |
||
2017 | 2017 | $Connection = new Connection(); |
2018 | 2018 | $sth = $Connection->db->prepare($query); |
2019 | 2019 | $sth->execute(); |
2020 | - } catch(PDOException $e) { |
|
2020 | + } catch (PDOException $e) { |
|
2021 | 2021 | return "error : ".$e->getMessage(); |
2022 | 2022 | } |
2023 | 2023 | } |
@@ -2032,7 +2032,7 @@ discard block |
||
2032 | 2032 | $Connection = new Connection(); |
2033 | 2033 | $sth = $Connection->db->prepare($query); |
2034 | 2034 | $sth->execute(); |
2035 | - } catch(PDOException $e) { |
|
2035 | + } catch (PDOException $e) { |
|
2036 | 2036 | return "error : ".$e->getMessage(); |
2037 | 2037 | } |
2038 | 2038 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2047,7 +2047,7 @@ discard block |
||
2047 | 2047 | $Connection = new Connection(); |
2048 | 2048 | $sth = $Connection->db->prepare($query); |
2049 | 2049 | $sth->execute(); |
2050 | - } catch(PDOException $e) { |
|
2050 | + } catch (PDOException $e) { |
|
2051 | 2051 | return "error : ".$e->getMessage(); |
2052 | 2052 | } |
2053 | 2053 | } |
@@ -2062,7 +2062,7 @@ discard block |
||
2062 | 2062 | $Connection = new Connection(); |
2063 | 2063 | $sth = $Connection->db->prepare($query); |
2064 | 2064 | $sth->execute(); |
2065 | - } catch(PDOException $e) { |
|
2065 | + } catch (PDOException $e) { |
|
2066 | 2066 | return "error : ".$e->getMessage(); |
2067 | 2067 | } |
2068 | 2068 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2077,7 +2077,7 @@ discard block |
||
2077 | 2077 | $Connection = new Connection(); |
2078 | 2078 | $sth = $Connection->db->prepare($query); |
2079 | 2079 | $sth->execute(); |
2080 | - } catch(PDOException $e) { |
|
2080 | + } catch (PDOException $e) { |
|
2081 | 2081 | return "error : ".$e->getMessage(); |
2082 | 2082 | } |
2083 | 2083 | } |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | class update_schema { |
9 | 9 | |
10 | 10 | public static function update_schedule() { |
11 | - $Connection = new Connection(); |
|
12 | - $Schedule = new Schedule(); |
|
13 | - $query = "SELECT * FROM schedule"; |
|
14 | - try { |
|
15 | - $sth = $Connection->db->prepare($query); |
|
11 | + $Connection = new Connection(); |
|
12 | + $Schedule = new Schedule(); |
|
13 | + $query = "SELECT * FROM schedule"; |
|
14 | + try { |
|
15 | + $sth = $Connection->db->prepare($query); |
|
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch(PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | - } |
|
20 | - while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | - } |
|
19 | + } |
|
20 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | + $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | /* |
@@ -43,198 +43,198 @@ discard block |
||
43 | 43 | } |
44 | 44 | */ |
45 | 45 | private static function update_from_1() { |
46 | - $Connection = new Connection(); |
|
47 | - // Add new column to routes table |
|
48 | - //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
46 | + $Connection = new Connection(); |
|
47 | + // Add new column to routes table |
|
48 | + //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
49 | 49 | $query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL"; |
50 | - try { |
|
51 | - $sth = $Connection->db->prepare($query); |
|
52 | - $sth->execute(); |
|
53 | - } catch(PDOException $e) { |
|
54 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | - } |
|
56 | - // Copy schedules data to routes table |
|
57 | - self::update_schedule(); |
|
58 | - // Delete schedule table |
|
50 | + try { |
|
51 | + $sth = $Connection->db->prepare($query); |
|
52 | + $sth->execute(); |
|
53 | + } catch(PDOException $e) { |
|
54 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | + } |
|
56 | + // Copy schedules data to routes table |
|
57 | + self::update_schedule(); |
|
58 | + // Delete schedule table |
|
59 | 59 | $query = "DROP TABLE `schedule`"; |
60 | - try { |
|
61 | - $sth = $Connection->db->prepare($query); |
|
62 | - $sth->execute(); |
|
63 | - } catch(PDOException $e) { |
|
64 | - return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | - } |
|
66 | - // Add source column |
|
67 | - $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | - try { |
|
69 | - $sth = $Connection->db->prepare($query); |
|
70 | - $sth->execute(); |
|
71 | - } catch(PDOException $e) { |
|
72 | - return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | - } |
|
60 | + try { |
|
61 | + $sth = $Connection->db->prepare($query); |
|
62 | + $sth->execute(); |
|
63 | + } catch(PDOException $e) { |
|
64 | + return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | + } |
|
66 | + // Add source column |
|
67 | + $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | + try { |
|
69 | + $sth = $Connection->db->prepare($query); |
|
70 | + $sth->execute(); |
|
71 | + } catch(PDOException $e) { |
|
72 | + return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | + } |
|
74 | 74 | // Delete unused column |
75 | 75 | $query = "ALTER TABLE `aircraft_modes` DROP `SerialNo`, DROP `OperatorFlagCode`, DROP `Manufacturer`, DROP `Type`, DROP `FirstRegDate`, DROP `CurrentRegDate`, DROP `Country`, DROP `PreviousID`, DROP `DeRegDate`, DROP `Status`, DROP `PopularName`, DROP `GenericName`, DROP `AircraftClass`, DROP `Engines`, DROP `OwnershipStatus`, DROP `RegisteredOwners`, DROP `MTOW`, DROP `TotalHours`, DROP `YearBuilt`, DROP `CofACategory`, DROP `CofAExpiry`, DROP `UserNotes`, DROP `Interested`, DROP `UserTag`, DROP `InfoUrl`, DROP `PictureUrl1`, DROP `PictureUrl2`, DROP `PictureUrl3`, DROP `UserBool1`, DROP `UserBool2`, DROP `UserBool3`, DROP `UserBool4`, DROP `UserBool5`, DROP `UserString1`, DROP `UserString2`, DROP `UserString3`, DROP `UserString4`, DROP `UserString5`, DROP `UserInt1`, DROP `UserInt2`, DROP `UserInt3`, DROP `UserInt4`, DROP `UserInt5`"; |
76 | - try { |
|
77 | - $sth = $Connection->db->prepare($query); |
|
78 | - $sth->execute(); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | - } |
|
76 | + try { |
|
77 | + $sth = $Connection->db->prepare($query); |
|
78 | + $sth->execute(); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | + } |
|
82 | 82 | // Add ModeS column |
83 | 83 | $query = "ALTER TABLE `spotter_output` ADD `ModeS` VARCHAR(255) NULL"; |
84 | - try { |
|
85 | - $sth = $Connection->db->prepare($query); |
|
86 | - $sth->execute(); |
|
87 | - } catch(PDOException $e) { |
|
88 | - return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | - } |
|
84 | + try { |
|
85 | + $sth = $Connection->db->prepare($query); |
|
86 | + $sth->execute(); |
|
87 | + } catch(PDOException $e) { |
|
88 | + return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | + } |
|
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | - try { |
|
92 | - $sth = $Connection->db->prepare($query); |
|
93 | - $sth->execute(); |
|
94 | - } catch(PDOException $e) { |
|
95 | - return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | - } |
|
97 | - // Add auto_increment for aircraft_modes |
|
98 | - $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | - try { |
|
100 | - $sth = $Connection->db->prepare($query); |
|
101 | - $sth->execute(); |
|
102 | - } catch(PDOException $e) { |
|
103 | - return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | - } |
|
105 | - $error = ''; |
|
91 | + try { |
|
92 | + $sth = $Connection->db->prepare($query); |
|
93 | + $sth->execute(); |
|
94 | + } catch(PDOException $e) { |
|
95 | + return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | + } |
|
97 | + // Add auto_increment for aircraft_modes |
|
98 | + $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | + try { |
|
100 | + $sth = $Connection->db->prepare($query); |
|
101 | + $sth->execute(); |
|
102 | + } catch(PDOException $e) { |
|
103 | + return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | + } |
|
105 | + $error = ''; |
|
106 | 106 | $error .= create_db::import_file('../db/acars_live.sql'); |
107 | 107 | $error .= create_db::import_file('../db/config.sql'); |
108 | 108 | // Update schema_version to 2 |
109 | 109 | $query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'"; |
110 | - try { |
|
111 | - $sth = $Connection->db->prepare($query); |
|
112 | - $sth->execute(); |
|
113 | - } catch(PDOException $e) { |
|
114 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | - } |
|
110 | + try { |
|
111 | + $sth = $Connection->db->prepare($query); |
|
112 | + $sth->execute(); |
|
113 | + } catch(PDOException $e) { |
|
114 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | + } |
|
116 | 116 | return $error; |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | 119 | private static function update_from_2() { |
120 | - $Connection = new Connection(); |
|
121 | - // Add new column decode to acars_live table |
|
120 | + $Connection = new Connection(); |
|
121 | + // Add new column decode to acars_live table |
|
122 | 122 | $query = "ALTER TABLE `acars_live` ADD `decode` TEXT"; |
123 | - try { |
|
124 | - $sth = $Connection->db->prepare($query); |
|
125 | - $sth->execute(); |
|
126 | - } catch(PDOException $e) { |
|
127 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | - } |
|
129 | - $error = ''; |
|
130 | - // Create table acars_archive |
|
123 | + try { |
|
124 | + $sth = $Connection->db->prepare($query); |
|
125 | + $sth->execute(); |
|
126 | + } catch(PDOException $e) { |
|
127 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | + } |
|
129 | + $error = ''; |
|
130 | + // Create table acars_archive |
|
131 | 131 | $error .= create_db::import_file('../db/acars_archive.sql'); |
132 | 132 | // Update schema_version to 3 |
133 | 133 | $query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'"; |
134 | - try { |
|
135 | - $sth = $Connection->db->prepare($query); |
|
136 | - $sth->execute(); |
|
137 | - } catch(PDOException $e) { |
|
138 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | - } |
|
134 | + try { |
|
135 | + $sth = $Connection->db->prepare($query); |
|
136 | + $sth->execute(); |
|
137 | + } catch(PDOException $e) { |
|
138 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | + } |
|
140 | 140 | return $error; |
141 | 141 | } |
142 | 142 | |
143 | 143 | private static function update_from_3() { |
144 | - $Connection = new Connection(); |
|
145 | - // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
144 | + $Connection = new Connection(); |
|
145 | + // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
146 | 146 | $query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP"; |
147 | - try { |
|
148 | - $sth = $Connection->db->prepare($query); |
|
149 | - $sth->execute(); |
|
150 | - } catch(PDOException $e) { |
|
151 | - return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | - } |
|
153 | - // Add image_source_website column to spotter_image |
|
147 | + try { |
|
148 | + $sth = $Connection->db->prepare($query); |
|
149 | + $sth->execute(); |
|
150 | + } catch(PDOException $e) { |
|
151 | + return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | + } |
|
153 | + // Add image_source_website column to spotter_image |
|
154 | 154 | $query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL"; |
155 | - try { |
|
156 | - $sth = $Connection->db->prepare($query); |
|
157 | - $sth->execute(); |
|
158 | - } catch(PDOException $e) { |
|
159 | - return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | - } |
|
161 | - $error = ''; |
|
155 | + try { |
|
156 | + $sth = $Connection->db->prepare($query); |
|
157 | + $sth->execute(); |
|
158 | + } catch(PDOException $e) { |
|
159 | + return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | + } |
|
161 | + $error = ''; |
|
162 | 162 | // Update schema_version to 4 |
163 | 163 | $query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'"; |
164 | - try { |
|
165 | - $sth = $Connection->db->prepare($query); |
|
166 | - $sth->execute(); |
|
167 | - } catch(PDOException $e) { |
|
168 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | - } |
|
164 | + try { |
|
165 | + $sth = $Connection->db->prepare($query); |
|
166 | + $sth->execute(); |
|
167 | + } catch(PDOException $e) { |
|
168 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | + } |
|
170 | 170 | return $error; |
171 | 171 | } |
172 | 172 | |
173 | 173 | private static function update_from_4() { |
174 | - $Connection = new Connection(); |
|
174 | + $Connection = new Connection(); |
|
175 | 175 | |
176 | - $error = ''; |
|
177 | - // Create table acars_label |
|
176 | + $error = ''; |
|
177 | + // Create table acars_label |
|
178 | 178 | $error .= create_db::import_file('../db/acars_label.sql'); |
179 | 179 | if ($error == '') { |
180 | - // Update schema_version to 5 |
|
181 | - $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | - try { |
|
183 | - $sth = $Connection->db->prepare($query); |
|
180 | + // Update schema_version to 5 |
|
181 | + $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | + try { |
|
183 | + $sth = $Connection->db->prepare($query); |
|
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch(PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | - } |
|
188 | - } |
|
187 | + } |
|
188 | + } |
|
189 | 189 | return $error; |
190 | 190 | } |
191 | 191 | |
192 | 192 | private static function update_from_5() { |
193 | - $Connection = new Connection(); |
|
194 | - // Add columns to translation |
|
193 | + $Connection = new Connection(); |
|
194 | + // Add columns to translation |
|
195 | 195 | $query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;"; |
196 | - try { |
|
197 | - $sth = $Connection->db->prepare($query); |
|
198 | - $sth->execute(); |
|
199 | - } catch(PDOException $e) { |
|
200 | - return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | - } |
|
202 | - // Add aircraft_shadow column to aircraft |
|
203 | - $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | - try { |
|
205 | - $sth = $Connection->db->prepare($query); |
|
206 | - $sth->execute(); |
|
207 | - } catch(PDOException $e) { |
|
208 | - return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | - } |
|
210 | - // Add aircraft_shadow column to spotter_live |
|
211 | - $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | - try { |
|
213 | - $sth = $Connection->db->prepare($query); |
|
214 | - $sth->execute(); |
|
215 | - } catch(PDOException $e) { |
|
216 | - return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | - } |
|
218 | - $error = ''; |
|
219 | - // Update table aircraft |
|
196 | + try { |
|
197 | + $sth = $Connection->db->prepare($query); |
|
198 | + $sth->execute(); |
|
199 | + } catch(PDOException $e) { |
|
200 | + return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | + } |
|
202 | + // Add aircraft_shadow column to aircraft |
|
203 | + $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | + try { |
|
205 | + $sth = $Connection->db->prepare($query); |
|
206 | + $sth->execute(); |
|
207 | + } catch(PDOException $e) { |
|
208 | + return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | + } |
|
210 | + // Add aircraft_shadow column to spotter_live |
|
211 | + $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | + try { |
|
213 | + $sth = $Connection->db->prepare($query); |
|
214 | + $sth->execute(); |
|
215 | + } catch(PDOException $e) { |
|
216 | + return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | + } |
|
218 | + $error = ''; |
|
219 | + // Update table aircraft |
|
220 | 220 | $error .= create_db::import_file('../db/aircraft.sql'); |
221 | 221 | $error .= create_db::import_file('../db/spotter_archive.sql'); |
222 | 222 | |
223 | 223 | // Update schema_version to 6 |
224 | 224 | $query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'"; |
225 | - try { |
|
226 | - $sth = $Connection->db->prepare($query); |
|
227 | - $sth->execute(); |
|
228 | - } catch(PDOException $e) { |
|
229 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | - } |
|
225 | + try { |
|
226 | + $sth = $Connection->db->prepare($query); |
|
227 | + $sth->execute(); |
|
228 | + } catch(PDOException $e) { |
|
229 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | + } |
|
231 | 231 | return $error; |
232 | 232 | } |
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | - $Connection = new Connection(); |
|
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | - $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
235 | + $Connection = new Connection(); |
|
236 | + if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | + $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
240 | 240 | ALTER TABLE spotter_live ADD INDEX(flightaware_id); |
@@ -247,147 +247,147 @@ discard block |
||
247 | 247 | ALTER TABLE aircraft ADD INDEX(icao); |
248 | 248 | ALTER TABLE airport ADD INDEX(icao); |
249 | 249 | ALTER TABLE translation ADD INDEX(Operator);"; |
250 | - try { |
|
251 | - $sth = $Connection->db->prepare($query); |
|
250 | + try { |
|
251 | + $sth = $Connection->db->prepare($query); |
|
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch(PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | - } |
|
256 | - } |
|
257 | - $error = ''; |
|
258 | - // Update table countries |
|
259 | - if ($Connection->tableExists('airspace')) { |
|
260 | - $error .= update_db::update_countries(); |
|
261 | - if ($error != '') return $error; |
|
255 | + } |
|
256 | + } |
|
257 | + $error = ''; |
|
258 | + // Update table countries |
|
259 | + if ($Connection->tableExists('airspace')) { |
|
260 | + $error .= update_db::update_countries(); |
|
261 | + if ($error != '') return $error; |
|
262 | 262 | } |
263 | 263 | // Update schema_version to 7 |
264 | 264 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
265 | - try { |
|
266 | - $sth = $Connection->db->prepare($query); |
|
267 | - $sth->execute(); |
|
268 | - } catch(PDOException $e) { |
|
269 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | - } |
|
265 | + try { |
|
266 | + $sth = $Connection->db->prepare($query); |
|
267 | + $sth->execute(); |
|
268 | + } catch(PDOException $e) { |
|
269 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | + } |
|
271 | 271 | return $error; |
272 | - } |
|
272 | + } |
|
273 | 273 | |
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | - $Connection = new Connection(); |
|
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
276 | + $Connection = new Connection(); |
|
277 | + $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | - try { |
|
280 | - $sth = $Connection->db->prepare($query); |
|
281 | - $sth->execute(); |
|
282 | - } catch(PDOException $e) { |
|
283 | - return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | - } |
|
285 | - if ($globalDBdriver == 'mysql') { |
|
286 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | - try { |
|
288 | - $sth = $Connection->db->prepare($query); |
|
279 | + try { |
|
280 | + $sth = $Connection->db->prepare($query); |
|
281 | + $sth->execute(); |
|
282 | + } catch(PDOException $e) { |
|
283 | + return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | + } |
|
285 | + if ($globalDBdriver == 'mysql') { |
|
286 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | + try { |
|
288 | + $sth = $Connection->db->prepare($query); |
|
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch(PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | - } |
|
293 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | - if ($row['engine'] == 'ARCHIVE') { |
|
292 | + } |
|
293 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | + if ($row['engine'] == 'ARCHIVE') { |
|
295 | 295 | $query = "CREATE TABLE copy LIKE spotter_archive; |
296 | 296 | ALTER TABLE copy ENGINE=ARCHIVE; |
297 | 297 | ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
298 | 298 | INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`; |
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | - } else { |
|
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | - } |
|
304 | - } else { |
|
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | - } |
|
307 | - try { |
|
308 | - $sth = $Connection->db->prepare($query); |
|
309 | - $sth->execute(); |
|
310 | - } catch(PDOException $e) { |
|
311 | - return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | - } |
|
301 | + } else { |
|
302 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | + } |
|
304 | + } else { |
|
305 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | + } |
|
307 | + try { |
|
308 | + $sth = $Connection->db->prepare($query); |
|
309 | + $sth->execute(); |
|
310 | + } catch(PDOException $e) { |
|
311 | + return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | + } |
|
313 | 313 | |
314 | - $error = ''; |
|
315 | - // Update table aircraft |
|
314 | + $error = ''; |
|
315 | + // Update table aircraft |
|
316 | 316 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | 317 | if ($error != '') return $error; |
318 | 318 | // Update schema_version to 6 |
319 | 319 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | - try { |
|
321 | - $sth = $Connection->db->prepare($query); |
|
322 | - $sth->execute(); |
|
323 | - } catch(PDOException $e) { |
|
324 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | - } |
|
320 | + try { |
|
321 | + $sth = $Connection->db->prepare($query); |
|
322 | + $sth->execute(); |
|
323 | + } catch(PDOException $e) { |
|
324 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | + } |
|
326 | 326 | return $error; |
327 | 327 | } |
328 | 328 | |
329 | 329 | private static function update_from_8() { |
330 | - $Connection = new Connection(); |
|
331 | - $error = ''; |
|
332 | - // Update table aircraft |
|
330 | + $Connection = new Connection(); |
|
331 | + $error = ''; |
|
332 | + // Update table aircraft |
|
333 | 333 | $error .= create_db::import_file('../db/notam.sql'); |
334 | 334 | if ($error != '') return $error; |
335 | 335 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 336 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 337 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
338 | 338 | INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; |
339 | - try { |
|
340 | - $sth = $Connection->db->prepare($query); |
|
341 | - $sth->execute(); |
|
342 | - } catch(PDOException $e) { |
|
343 | - return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | - } |
|
339 | + try { |
|
340 | + $sth = $Connection->db->prepare($query); |
|
341 | + $sth->execute(); |
|
342 | + } catch(PDOException $e) { |
|
343 | + return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | + } |
|
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | - try { |
|
347 | - $sth = $Connection->db->prepare($query); |
|
348 | - $sth->execute(); |
|
349 | - } catch(PDOException $e) { |
|
350 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | - } |
|
346 | + try { |
|
347 | + $sth = $Connection->db->prepare($query); |
|
348 | + $sth->execute(); |
|
349 | + } catch(PDOException $e) { |
|
350 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | + } |
|
352 | 352 | return $error; |
353 | 353 | } |
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | - $Connection = new Connection(); |
|
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
356 | + $Connection = new Connection(); |
|
357 | + $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | - try { |
|
360 | - $sth = $Connection->db->prepare($query); |
|
361 | - $sth->execute(); |
|
362 | - } catch(PDOException $e) { |
|
363 | - return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | - } |
|
359 | + try { |
|
360 | + $sth = $Connection->db->prepare($query); |
|
361 | + $sth->execute(); |
|
362 | + } catch(PDOException $e) { |
|
363 | + return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | + } |
|
365 | 365 | $error = ''; |
366 | - // Update table atc |
|
366 | + // Update table atc |
|
367 | 367 | $error .= create_db::import_file('../db/atc.sql'); |
368 | 368 | if ($error != '') return $error; |
369 | 369 | |
370 | 370 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | - try { |
|
372 | - $sth = $Connection->db->prepare($query); |
|
373 | - $sth->execute(); |
|
374 | - } catch(PDOException $e) { |
|
375 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | - } |
|
371 | + try { |
|
372 | + $sth = $Connection->db->prepare($query); |
|
373 | + $sth->execute(); |
|
374 | + } catch(PDOException $e) { |
|
375 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | + } |
|
377 | 377 | return $error; |
378 | 378 | } |
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | - $Connection = new Connection(); |
|
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | - try { |
|
384 | - $sth = $Connection->db->prepare($query); |
|
385 | - $sth->execute(); |
|
386 | - } catch(PDOException $e) { |
|
387 | - return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | - } |
|
381 | + $Connection = new Connection(); |
|
382 | + $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | + try { |
|
384 | + $sth = $Connection->db->prepare($query); |
|
385 | + $sth->execute(); |
|
386 | + } catch(PDOException $e) { |
|
387 | + return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | + } |
|
389 | 389 | $error = ''; |
390 | - // Add tables |
|
390 | + // Add tables |
|
391 | 391 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | 392 | if ($error != '') return $error; |
393 | 393 | $error .= create_db::import_file('../db/metar.sql'); |
@@ -398,76 +398,76 @@ discard block |
||
398 | 398 | if ($error != '') return $error; |
399 | 399 | |
400 | 400 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | - try { |
|
402 | - $sth = $Connection->db->prepare($query); |
|
403 | - $sth->execute(); |
|
404 | - } catch(PDOException $e) { |
|
405 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | - } |
|
401 | + try { |
|
402 | + $sth = $Connection->db->prepare($query); |
|
403 | + $sth->execute(); |
|
404 | + } catch(PDOException $e) { |
|
405 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | + } |
|
407 | 407 | return $error; |
408 | 408 | } |
409 | 409 | |
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | - $Connection = new Connection(); |
|
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | - try { |
|
415 | - $sth = $Connection->db->prepare($query); |
|
416 | - $sth->execute(); |
|
417 | - } catch(PDOException $e) { |
|
418 | - return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | - } |
|
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | - try { |
|
422 | - $sth = $Connection->db->prepare($query); |
|
423 | - $sth->execute(); |
|
424 | - } catch(PDOException $e) { |
|
425 | - return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | - } |
|
427 | - if ($globalDBdriver == 'mysql') { |
|
428 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | - try { |
|
430 | - $sth = $Connection->db->prepare($query); |
|
412 | + $Connection = new Connection(); |
|
413 | + $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | + try { |
|
415 | + $sth = $Connection->db->prepare($query); |
|
416 | + $sth->execute(); |
|
417 | + } catch(PDOException $e) { |
|
418 | + return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | + } |
|
420 | + $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | + try { |
|
422 | + $sth = $Connection->db->prepare($query); |
|
423 | + $sth->execute(); |
|
424 | + } catch(PDOException $e) { |
|
425 | + return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | + } |
|
427 | + if ($globalDBdriver == 'mysql') { |
|
428 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | + try { |
|
430 | + $sth = $Connection->db->prepare($query); |
|
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch(PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | - } |
|
435 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | - if ($row['engine'] == 'ARCHIVE') { |
|
434 | + } |
|
435 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | + if ($row['engine'] == 'ARCHIVE') { |
|
437 | 437 | $query = "CREATE TABLE copy LIKE spotter_archive; |
438 | 438 | ALTER TABLE copy ENGINE=ARCHIVE; |
439 | 439 | ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE; |
440 | 440 | INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`; |
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | - } else { |
|
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | - } |
|
446 | - } else { |
|
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | - } |
|
449 | - try { |
|
450 | - $sth = $Connection->db->prepare($query); |
|
451 | - $sth->execute(); |
|
452 | - } catch(PDOException $e) { |
|
453 | - return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | - } |
|
443 | + } else { |
|
444 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | + } |
|
446 | + } else { |
|
447 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | + } |
|
449 | + try { |
|
450 | + $sth = $Connection->db->prepare($query); |
|
451 | + $sth->execute(); |
|
452 | + } catch(PDOException $e) { |
|
453 | + return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | + } |
|
455 | 455 | |
456 | 456 | $error = ''; |
457 | 457 | |
458 | 458 | $query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'"; |
459 | - try { |
|
460 | - $sth = $Connection->db->prepare($query); |
|
461 | - $sth->execute(); |
|
462 | - } catch(PDOException $e) { |
|
463 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | - } |
|
459 | + try { |
|
460 | + $sth = $Connection->db->prepare($query); |
|
461 | + $sth->execute(); |
|
462 | + } catch(PDOException $e) { |
|
463 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | + } |
|
465 | 465 | return $error; |
466 | 466 | } |
467 | 467 | private static function update_from_12() { |
468 | - $Connection = new Connection(); |
|
468 | + $Connection = new Connection(); |
|
469 | 469 | $error = ''; |
470 | - // Add tables |
|
470 | + // Add tables |
|
471 | 471 | $error .= create_db::import_file('../db/stats.sql'); |
472 | 472 | if ($error != '') return $error; |
473 | 473 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
@@ -484,166 +484,166 @@ discard block |
||
484 | 484 | if ($error != '') return $error; |
485 | 485 | |
486 | 486 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | - try { |
|
488 | - $sth = $Connection->db->prepare($query); |
|
489 | - $sth->execute(); |
|
490 | - } catch(PDOException $e) { |
|
491 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | - } |
|
487 | + try { |
|
488 | + $sth = $Connection->db->prepare($query); |
|
489 | + $sth->execute(); |
|
490 | + } catch(PDOException $e) { |
|
491 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | + } |
|
493 | 493 | return $error; |
494 | 494 | } |
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | - $Connection = new Connection(); |
|
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
497 | + $Connection = new Connection(); |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | + $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch(PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | - } |
|
505 | + } |
|
506 | 506 | } |
507 | - $error = ''; |
|
507 | + $error = ''; |
|
508 | 508 | $query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'"; |
509 | - try { |
|
510 | - $sth = $Connection->db->prepare($query); |
|
511 | - $sth->execute(); |
|
512 | - } catch(PDOException $e) { |
|
513 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | - } |
|
509 | + try { |
|
510 | + $sth = $Connection->db->prepare($query); |
|
511 | + $sth->execute(); |
|
512 | + } catch(PDOException $e) { |
|
513 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | + } |
|
515 | 515 | return $error; |
516 | 516 | } |
517 | 517 | |
518 | 518 | private static function update_from_14() { |
519 | - $Connection = new Connection(); |
|
519 | + $Connection = new Connection(); |
|
520 | 520 | $error = ''; |
521 | - // Add tables |
|
522 | - if (!$Connection->tableExists('stats_flight')) { |
|
521 | + // Add tables |
|
522 | + if (!$Connection->tableExists('stats_flight')) { |
|
523 | 523 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | 524 | if ($error != '') return $error; |
525 | 525 | } |
526 | 526 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | - try { |
|
528 | - $sth = $Connection->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | - } |
|
527 | + try { |
|
528 | + $sth = $Connection->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | + } |
|
533 | 533 | return $error; |
534 | 534 | } |
535 | 535 | |
536 | 536 | |
537 | 537 | private static function update_from_15() { |
538 | - $Connection = new Connection(); |
|
538 | + $Connection = new Connection(); |
|
539 | 539 | $error = ''; |
540 | - // Add tables |
|
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | - try { |
|
543 | - $sth = $Connection->db->prepare($query); |
|
544 | - $sth->execute(); |
|
545 | - } catch(PDOException $e) { |
|
546 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | - } |
|
540 | + // Add tables |
|
541 | + $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | + try { |
|
543 | + $sth = $Connection->db->prepare($query); |
|
544 | + $sth->execute(); |
|
545 | + } catch(PDOException $e) { |
|
546 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | + } |
|
548 | 548 | if ($error != '') return $error; |
549 | 549 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | - try { |
|
551 | - $sth = $Connection->db->prepare($query); |
|
552 | - $sth->execute(); |
|
553 | - } catch(PDOException $e) { |
|
554 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | - } |
|
550 | + try { |
|
551 | + $sth = $Connection->db->prepare($query); |
|
552 | + $sth->execute(); |
|
553 | + } catch(PDOException $e) { |
|
554 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | + } |
|
556 | 556 | return $error; |
557 | 557 | } |
558 | 558 | |
559 | 559 | private static function update_from_16() { |
560 | - $Connection = new Connection(); |
|
560 | + $Connection = new Connection(); |
|
561 | 561 | $error = ''; |
562 | - // Add tables |
|
563 | - if (!$Connection->tableExists('stats_registration')) { |
|
562 | + // Add tables |
|
563 | + if (!$Connection->tableExists('stats_registration')) { |
|
564 | 564 | $error .= create_db::import_file('../db/stats_registration.sql'); |
565 | 565 | } |
566 | - if (!$Connection->tableExists('stats_callsign')) { |
|
566 | + if (!$Connection->tableExists('stats_callsign')) { |
|
567 | 567 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 568 | } |
569 | 569 | if ($error != '') return $error; |
570 | 570 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | - try { |
|
572 | - $sth = $Connection->db->prepare($query); |
|
573 | - $sth->execute(); |
|
574 | - } catch(PDOException $e) { |
|
575 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | - } |
|
571 | + try { |
|
572 | + $sth = $Connection->db->prepare($query); |
|
573 | + $sth->execute(); |
|
574 | + } catch(PDOException $e) { |
|
575 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | + } |
|
577 | 577 | return $error; |
578 | 578 | } |
579 | 579 | |
580 | 580 | private static function update_from_17() { |
581 | - $Connection = new Connection(); |
|
581 | + $Connection = new Connection(); |
|
582 | 582 | $error = ''; |
583 | - // Add tables |
|
584 | - if (!$Connection->tableExists('stats_country')) { |
|
583 | + // Add tables |
|
584 | + if (!$Connection->tableExists('stats_country')) { |
|
585 | 585 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 586 | } |
587 | 587 | if ($error != '') return $error; |
588 | 588 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | - try { |
|
590 | - $sth = $Connection->db->prepare($query); |
|
591 | - $sth->execute(); |
|
592 | - } catch(PDOException $e) { |
|
593 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | - } |
|
589 | + try { |
|
590 | + $sth = $Connection->db->prepare($query); |
|
591 | + $sth->execute(); |
|
592 | + } catch(PDOException $e) { |
|
593 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | + } |
|
595 | 595 | return $error; |
596 | 596 | } |
597 | 597 | private static function update_from_18() { |
598 | - $Connection = new Connection(); |
|
598 | + $Connection = new Connection(); |
|
599 | 599 | $error = ''; |
600 | - // Modify stats_airport table |
|
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | - $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | - try { |
|
604 | - $sth = $Connection->db->prepare($query); |
|
605 | - $sth->execute(); |
|
606 | - } catch(PDOException $e) { |
|
607 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | - } |
|
609 | - } |
|
600 | + // Modify stats_airport table |
|
601 | + if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | + $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | + try { |
|
604 | + $sth = $Connection->db->prepare($query); |
|
605 | + $sth->execute(); |
|
606 | + } catch(PDOException $e) { |
|
607 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | + } |
|
609 | + } |
|
610 | 610 | if ($error != '') return $error; |
611 | 611 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | - try { |
|
613 | - $sth = $Connection->db->prepare($query); |
|
614 | - $sth->execute(); |
|
615 | - } catch(PDOException $e) { |
|
616 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | - } |
|
612 | + try { |
|
613 | + $sth = $Connection->db->prepare($query); |
|
614 | + $sth->execute(); |
|
615 | + } catch(PDOException $e) { |
|
616 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | + } |
|
618 | 618 | return $error; |
619 | 619 | } |
620 | 620 | |
621 | 621 | private static function update_from_19() { |
622 | - $Connection = new Connection(); |
|
622 | + $Connection = new Connection(); |
|
623 | 623 | $error = ''; |
624 | - // Update airport table |
|
624 | + // Update airport table |
|
625 | 625 | $error .= create_db::import_file('../db/airport.sql'); |
626 | 626 | if ($error != '') return 'Import airport.sql : '.$error; |
627 | 627 | // Remove primary key on Spotter_Archive |
628 | 628 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | - try { |
|
630 | - $sth = $Connection->db->prepare($query); |
|
631 | - $sth->execute(); |
|
632 | - } catch(PDOException $e) { |
|
633 | - return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | - } |
|
629 | + try { |
|
630 | + $sth = $Connection->db->prepare($query); |
|
631 | + $sth->execute(); |
|
632 | + } catch(PDOException $e) { |
|
633 | + return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | + } |
|
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | - try { |
|
637 | - $sth = $Connection->db->prepare($query); |
|
638 | - $sth->execute(); |
|
639 | - } catch(PDOException $e) { |
|
640 | - return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | - } |
|
636 | + try { |
|
637 | + $sth = $Connection->db->prepare($query); |
|
638 | + $sth->execute(); |
|
639 | + } catch(PDOException $e) { |
|
640 | + return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | + } |
|
642 | 642 | if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
643 | 643 | // Add column over_country |
644 | - $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
644 | + $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
645 | 645 | try { |
646 | - $sth = $Connection->db->prepare($query); |
|
646 | + $sth = $Connection->db->prepare($query); |
|
647 | 647 | $sth->execute(); |
648 | 648 | } catch(PDOException $e) { |
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | } |
652 | 652 | if (!$Connection->checkColumnName('spotter_live','over_country')) { |
653 | 653 | // Add column over_country |
654 | - $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
654 | + $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
655 | 655 | try { |
656 | - $sth = $Connection->db->prepare($query); |
|
656 | + $sth = $Connection->db->prepare($query); |
|
657 | 657 | $sth->execute(); |
658 | 658 | } catch(PDOException $e) { |
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -661,74 +661,74 @@ discard block |
||
661 | 661 | } |
662 | 662 | if (!$Connection->checkColumnName('spotter_output','source_name')) { |
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | - $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
664 | + $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | 668 | } catch(PDOException $e) { |
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | - } |
|
671 | - } |
|
670 | + } |
|
671 | + } |
|
672 | 672 | if (!$Connection->checkColumnName('spotter_live','source_name')) { |
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | - $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
674 | + $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | 678 | } catch(PDOException $e) { |
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | - } |
|
681 | - } |
|
680 | + } |
|
681 | + } |
|
682 | 682 | if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | - $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
684 | + $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | 688 | } catch(PDOException $e) { |
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | - } |
|
691 | - } |
|
690 | + } |
|
691 | + } |
|
692 | 692 | if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | - $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
694 | + $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | 698 | } catch(PDOException $e) { |
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | - } |
|
701 | - } |
|
700 | + } |
|
701 | + } |
|
702 | 702 | if ($error != '') return $error; |
703 | 703 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | - try { |
|
705 | - $sth = $Connection->db->prepare($query); |
|
706 | - $sth->execute(); |
|
707 | - } catch(PDOException $e) { |
|
708 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | - } |
|
704 | + try { |
|
705 | + $sth = $Connection->db->prepare($query); |
|
706 | + $sth->execute(); |
|
707 | + } catch(PDOException $e) { |
|
708 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | + } |
|
710 | 710 | return $error; |
711 | 711 | } |
712 | 712 | |
713 | 713 | private static function update_from_20() { |
714 | 714 | global $globalIVAO, $globalVATSIM, $globalphpVMS; |
715 | - $Connection = new Connection(); |
|
715 | + $Connection = new Connection(); |
|
716 | 716 | $error = ''; |
717 | - // Update airline table |
|
718 | - if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
717 | + // Update airline table |
|
718 | + if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | 722 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 723 | // Add column over_country |
724 | - $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | - try { |
|
724 | + $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | + try { |
|
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | 728 | } catch(PDOException $e) { |
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | - } |
|
731 | - } |
|
730 | + } |
|
731 | + } |
|
732 | 732 | if ($error != '') return $error; |
733 | 733 | /* |
734 | 734 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
@@ -738,12 +738,12 @@ discard block |
||
738 | 738 | } |
739 | 739 | */ |
740 | 740 | $query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'"; |
741 | - try { |
|
742 | - $sth = $Connection->db->prepare($query); |
|
743 | - $sth->execute(); |
|
744 | - } catch(PDOException $e) { |
|
745 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | - } |
|
741 | + try { |
|
742 | + $sth = $Connection->db->prepare($query); |
|
743 | + $sth->execute(); |
|
744 | + } catch(PDOException $e) { |
|
745 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | + } |
|
747 | 747 | return $error; |
748 | 748 | } |
749 | 749 | |
@@ -762,35 +762,35 @@ discard block |
||
762 | 762 | if ($error != '') return $error; |
763 | 763 | } |
764 | 764 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | - try { |
|
766 | - $sth = $Connection->db->prepare($query); |
|
767 | - $sth->execute(); |
|
768 | - } catch(PDOException $e) { |
|
769 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | - } |
|
765 | + try { |
|
766 | + $sth = $Connection->db->prepare($query); |
|
767 | + $sth->execute(); |
|
768 | + } catch(PDOException $e) { |
|
769 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | + } |
|
771 | 771 | return $error; |
772 | 772 | } |
773 | 773 | |
774 | 774 | private static function update_from_22() { |
775 | 775 | global $globalDBdriver; |
776 | - $Connection = new Connection(); |
|
776 | + $Connection = new Connection(); |
|
777 | 777 | $error = ''; |
778 | 778 | // Add table stats polar |
779 | - if (!$Connection->tableExists('stats_source')) { |
|
779 | + if (!$Connection->tableExists('stats_source')) { |
|
780 | 780 | if ($globalDBdriver == 'mysql') { |
781 | - $error .= create_db::import_file('../db/stats_source.sql'); |
|
781 | + $error .= create_db::import_file('../db/stats_source.sql'); |
|
782 | 782 | } else { |
783 | 783 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 784 | } |
785 | 785 | if ($error != '') return $error; |
786 | 786 | } |
787 | 787 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | - try { |
|
789 | - $sth = $Connection->db->prepare($query); |
|
790 | - $sth->execute(); |
|
791 | - } catch(PDOException $e) { |
|
792 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | - } |
|
788 | + try { |
|
789 | + $sth = $Connection->db->prepare($query); |
|
790 | + $sth->execute(); |
|
791 | + } catch(PDOException $e) { |
|
792 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | + } |
|
794 | 794 | return $error; |
795 | 795 | } |
796 | 796 | |
@@ -821,14 +821,14 @@ discard block |
||
821 | 821 | } |
822 | 822 | if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | - $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
824 | + $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | 828 | } catch(PDOException $e) { |
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | - } |
|
831 | - } |
|
830 | + } |
|
831 | + } |
|
832 | 832 | |
833 | 833 | $query = "UPDATE config SET value = '24' WHERE name = 'schema_version'"; |
834 | 834 | try { |
@@ -1164,137 +1164,137 @@ discard block |
||
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | |
1167 | - public static function check_version($update = false) { |
|
1168 | - global $globalDBname; |
|
1169 | - $version = 0; |
|
1170 | - $Connection = new Connection(); |
|
1171 | - if ($Connection->tableExists('aircraft')) { |
|
1172 | - if (!$Connection->tableExists('config')) { |
|
1173 | - $version = '1'; |
|
1174 | - if ($update) return self::update_from_1(); |
|
1175 | - else return $version; |
|
1167 | + public static function check_version($update = false) { |
|
1168 | + global $globalDBname; |
|
1169 | + $version = 0; |
|
1170 | + $Connection = new Connection(); |
|
1171 | + if ($Connection->tableExists('aircraft')) { |
|
1172 | + if (!$Connection->tableExists('config')) { |
|
1173 | + $version = '1'; |
|
1174 | + if ($update) return self::update_from_1(); |
|
1175 | + else return $version; |
|
1176 | 1176 | } else { |
1177 | - $Connection = new Connection(); |
|
1178 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1179 | - try { |
|
1180 | - $sth = $Connection->db->prepare($query); |
|
1181 | - $sth->execute(); |
|
1182 | - } catch(PDOException $e) { |
|
1177 | + $Connection = new Connection(); |
|
1178 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1179 | + try { |
|
1180 | + $sth = $Connection->db->prepare($query); |
|
1181 | + $sth->execute(); |
|
1182 | + } catch(PDOException $e) { |
|
1183 | 1183 | return "error : ".$e->getMessage()."\n"; |
1184 | - } |
|
1185 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1186 | - if ($update) { |
|
1187 | - if ($result['value'] == '2') { |
|
1188 | - $error = self::update_from_2(); |
|
1189 | - if ($error != '') return $error; |
|
1190 | - else return self::check_version(true); |
|
1191 | - } elseif ($result['value'] == '3') { |
|
1192 | - $error = self::update_from_3(); |
|
1193 | - if ($error != '') return $error; |
|
1194 | - else return self::check_version(true); |
|
1195 | - } elseif ($result['value'] == '4') { |
|
1196 | - $error = self::update_from_4(); |
|
1197 | - if ($error != '') return $error; |
|
1198 | - else return self::check_version(true); |
|
1199 | - } elseif ($result['value'] == '5') { |
|
1200 | - $error = self::update_from_5(); |
|
1201 | - if ($error != '') return $error; |
|
1202 | - else return self::check_version(true); |
|
1203 | - } elseif ($result['value'] == '6') { |
|
1204 | - $error = self::update_from_6(); |
|
1205 | - if ($error != '') return $error; |
|
1206 | - else return self::check_version(true); |
|
1207 | - } elseif ($result['value'] == '7') { |
|
1208 | - $error = self::update_from_7(); |
|
1209 | - if ($error != '') return $error; |
|
1210 | - else return self::check_version(true); |
|
1211 | - } elseif ($result['value'] == '8') { |
|
1212 | - $error = self::update_from_8(); |
|
1213 | - if ($error != '') return $error; |
|
1214 | - else return self::check_version(true); |
|
1215 | - } elseif ($result['value'] == '9') { |
|
1216 | - $error = self::update_from_9(); |
|
1217 | - if ($error != '') return $error; |
|
1218 | - else return self::check_version(true); |
|
1219 | - } elseif ($result['value'] == '10') { |
|
1220 | - $error = self::update_from_10(); |
|
1221 | - if ($error != '') return $error; |
|
1222 | - else return self::check_version(true); |
|
1223 | - } elseif ($result['value'] == '11') { |
|
1224 | - $error = self::update_from_11(); |
|
1225 | - if ($error != '') return $error; |
|
1226 | - else return self::check_version(true); |
|
1227 | - } elseif ($result['value'] == '12') { |
|
1228 | - $error = self::update_from_12(); |
|
1229 | - if ($error != '') return $error; |
|
1230 | - else return self::check_version(true); |
|
1231 | - } elseif ($result['value'] == '13') { |
|
1232 | - $error = self::update_from_13(); |
|
1233 | - if ($error != '') return $error; |
|
1234 | - else return self::check_version(true); |
|
1235 | - } elseif ($result['value'] == '14') { |
|
1236 | - $error = self::update_from_14(); |
|
1237 | - if ($error != '') return $error; |
|
1238 | - else return self::check_version(true); |
|
1239 | - } elseif ($result['value'] == '15') { |
|
1240 | - $error = self::update_from_15(); |
|
1241 | - if ($error != '') return $error; |
|
1242 | - else return self::check_version(true); |
|
1243 | - } elseif ($result['value'] == '16') { |
|
1244 | - $error = self::update_from_16(); |
|
1245 | - if ($error != '') return $error; |
|
1246 | - else return self::check_version(true); |
|
1247 | - } elseif ($result['value'] == '17') { |
|
1248 | - $error = self::update_from_17(); |
|
1249 | - if ($error != '') return $error; |
|
1250 | - else return self::check_version(true); |
|
1251 | - } elseif ($result['value'] == '18') { |
|
1252 | - $error = self::update_from_18(); |
|
1253 | - if ($error != '') return $error; |
|
1254 | - else return self::check_version(true); |
|
1255 | - } elseif ($result['value'] == '19') { |
|
1256 | - $error = self::update_from_19(); |
|
1257 | - if ($error != '') return $error; |
|
1258 | - else return self::check_version(true); |
|
1259 | - } elseif ($result['value'] == '20') { |
|
1260 | - $error = self::update_from_20(); |
|
1261 | - if ($error != '') return $error; |
|
1262 | - else return self::check_version(true); |
|
1263 | - } elseif ($result['value'] == '21') { |
|
1264 | - $error = self::update_from_21(); |
|
1265 | - if ($error != '') return $error; |
|
1266 | - else return self::check_version(true); |
|
1267 | - } elseif ($result['value'] == '22') { |
|
1268 | - $error = self::update_from_22(); |
|
1269 | - if ($error != '') return $error; |
|
1270 | - else return self::check_version(true); |
|
1271 | - } elseif ($result['value'] == '23') { |
|
1272 | - $error = self::update_from_23(); |
|
1273 | - if ($error != '') return $error; |
|
1274 | - else return self::check_version(true); |
|
1275 | - } elseif ($result['value'] == '24') { |
|
1276 | - $error = self::update_from_24(); |
|
1277 | - if ($error != '') return $error; |
|
1278 | - else return self::check_version(true); |
|
1279 | - } elseif ($result['value'] == '25') { |
|
1280 | - $error = self::update_from_25(); |
|
1281 | - if ($error != '') return $error; |
|
1282 | - else return self::check_version(true); |
|
1283 | - } elseif ($result['value'] == '26') { |
|
1284 | - $error = self::update_from_26(); |
|
1285 | - if ($error != '') return $error; |
|
1286 | - else return self::check_version(true); |
|
1287 | - } elseif ($result['value'] == '27') { |
|
1288 | - $error = self::update_from_27(); |
|
1289 | - if ($error != '') return $error; |
|
1290 | - else return self::check_version(true); |
|
1291 | - } else return ''; |
|
1292 | - } |
|
1293 | - else return $result['value']; |
|
1184 | + } |
|
1185 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1186 | + if ($update) { |
|
1187 | + if ($result['value'] == '2') { |
|
1188 | + $error = self::update_from_2(); |
|
1189 | + if ($error != '') return $error; |
|
1190 | + else return self::check_version(true); |
|
1191 | + } elseif ($result['value'] == '3') { |
|
1192 | + $error = self::update_from_3(); |
|
1193 | + if ($error != '') return $error; |
|
1194 | + else return self::check_version(true); |
|
1195 | + } elseif ($result['value'] == '4') { |
|
1196 | + $error = self::update_from_4(); |
|
1197 | + if ($error != '') return $error; |
|
1198 | + else return self::check_version(true); |
|
1199 | + } elseif ($result['value'] == '5') { |
|
1200 | + $error = self::update_from_5(); |
|
1201 | + if ($error != '') return $error; |
|
1202 | + else return self::check_version(true); |
|
1203 | + } elseif ($result['value'] == '6') { |
|
1204 | + $error = self::update_from_6(); |
|
1205 | + if ($error != '') return $error; |
|
1206 | + else return self::check_version(true); |
|
1207 | + } elseif ($result['value'] == '7') { |
|
1208 | + $error = self::update_from_7(); |
|
1209 | + if ($error != '') return $error; |
|
1210 | + else return self::check_version(true); |
|
1211 | + } elseif ($result['value'] == '8') { |
|
1212 | + $error = self::update_from_8(); |
|
1213 | + if ($error != '') return $error; |
|
1214 | + else return self::check_version(true); |
|
1215 | + } elseif ($result['value'] == '9') { |
|
1216 | + $error = self::update_from_9(); |
|
1217 | + if ($error != '') return $error; |
|
1218 | + else return self::check_version(true); |
|
1219 | + } elseif ($result['value'] == '10') { |
|
1220 | + $error = self::update_from_10(); |
|
1221 | + if ($error != '') return $error; |
|
1222 | + else return self::check_version(true); |
|
1223 | + } elseif ($result['value'] == '11') { |
|
1224 | + $error = self::update_from_11(); |
|
1225 | + if ($error != '') return $error; |
|
1226 | + else return self::check_version(true); |
|
1227 | + } elseif ($result['value'] == '12') { |
|
1228 | + $error = self::update_from_12(); |
|
1229 | + if ($error != '') return $error; |
|
1230 | + else return self::check_version(true); |
|
1231 | + } elseif ($result['value'] == '13') { |
|
1232 | + $error = self::update_from_13(); |
|
1233 | + if ($error != '') return $error; |
|
1234 | + else return self::check_version(true); |
|
1235 | + } elseif ($result['value'] == '14') { |
|
1236 | + $error = self::update_from_14(); |
|
1237 | + if ($error != '') return $error; |
|
1238 | + else return self::check_version(true); |
|
1239 | + } elseif ($result['value'] == '15') { |
|
1240 | + $error = self::update_from_15(); |
|
1241 | + if ($error != '') return $error; |
|
1242 | + else return self::check_version(true); |
|
1243 | + } elseif ($result['value'] == '16') { |
|
1244 | + $error = self::update_from_16(); |
|
1245 | + if ($error != '') return $error; |
|
1246 | + else return self::check_version(true); |
|
1247 | + } elseif ($result['value'] == '17') { |
|
1248 | + $error = self::update_from_17(); |
|
1249 | + if ($error != '') return $error; |
|
1250 | + else return self::check_version(true); |
|
1251 | + } elseif ($result['value'] == '18') { |
|
1252 | + $error = self::update_from_18(); |
|
1253 | + if ($error != '') return $error; |
|
1254 | + else return self::check_version(true); |
|
1255 | + } elseif ($result['value'] == '19') { |
|
1256 | + $error = self::update_from_19(); |
|
1257 | + if ($error != '') return $error; |
|
1258 | + else return self::check_version(true); |
|
1259 | + } elseif ($result['value'] == '20') { |
|
1260 | + $error = self::update_from_20(); |
|
1261 | + if ($error != '') return $error; |
|
1262 | + else return self::check_version(true); |
|
1263 | + } elseif ($result['value'] == '21') { |
|
1264 | + $error = self::update_from_21(); |
|
1265 | + if ($error != '') return $error; |
|
1266 | + else return self::check_version(true); |
|
1267 | + } elseif ($result['value'] == '22') { |
|
1268 | + $error = self::update_from_22(); |
|
1269 | + if ($error != '') return $error; |
|
1270 | + else return self::check_version(true); |
|
1271 | + } elseif ($result['value'] == '23') { |
|
1272 | + $error = self::update_from_23(); |
|
1273 | + if ($error != '') return $error; |
|
1274 | + else return self::check_version(true); |
|
1275 | + } elseif ($result['value'] == '24') { |
|
1276 | + $error = self::update_from_24(); |
|
1277 | + if ($error != '') return $error; |
|
1278 | + else return self::check_version(true); |
|
1279 | + } elseif ($result['value'] == '25') { |
|
1280 | + $error = self::update_from_25(); |
|
1281 | + if ($error != '') return $error; |
|
1282 | + else return self::check_version(true); |
|
1283 | + } elseif ($result['value'] == '26') { |
|
1284 | + $error = self::update_from_26(); |
|
1285 | + if ($error != '') return $error; |
|
1286 | + else return self::check_version(true); |
|
1287 | + } elseif ($result['value'] == '27') { |
|
1288 | + $error = self::update_from_27(); |
|
1289 | + if ($error != '') return $error; |
|
1290 | + else return self::check_version(true); |
|
1291 | + } else return ''; |
|
1292 | + } |
|
1293 | + else return $result['value']; |
|
1294 | 1294 | } |
1295 | 1295 | |
1296 | - } else return $version; |
|
1297 | - } |
|
1296 | + } else return $version; |
|
1297 | + } |
|
1298 | 1298 | |
1299 | 1299 | } |
1300 | 1300 | //echo update_schema::check_version(); |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | try { |
15 | 15 | $sth = $Connection->db->prepare($query); |
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch (PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | 19 | } |
20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | $sth = $Connection->db->prepare($query); |
52 | 52 | $sth->execute(); |
53 | - } catch(PDOException $e) { |
|
53 | + } catch (PDOException $e) { |
|
54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
55 | 55 | } |
56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $Connection->db->prepare($query); |
62 | 62 | $sth->execute(); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
65 | 65 | } |
66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
73 | 73 | } |
74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
81 | 81 | } |
82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | try { |
85 | 85 | $sth = $Connection->db->prepare($query); |
86 | 86 | $sth->execute(); |
87 | - } catch(PDOException $e) { |
|
87 | + } catch (PDOException $e) { |
|
88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
89 | 89 | } |
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | 91 | try { |
92 | 92 | $sth = $Connection->db->prepare($query); |
93 | 93 | $sth->execute(); |
94 | - } catch(PDOException $e) { |
|
94 | + } catch (PDOException $e) { |
|
95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
96 | 96 | } |
97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | try { |
100 | 100 | $sth = $Connection->db->prepare($query); |
101 | 101 | $sth->execute(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
104 | 104 | } |
105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $sth = $Connection->db->prepare($query); |
112 | 112 | $sth->execute(); |
113 | - } catch(PDOException $e) { |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
115 | 115 | } |
116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $Connection->db->prepare($query); |
125 | 125 | $sth->execute(); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
128 | 128 | } |
129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try { |
135 | 135 | $sth = $Connection->db->prepare($query); |
136 | 136 | $sth->execute(); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
139 | 139 | } |
140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | try { |
148 | 148 | $sth = $Connection->db->prepare($query); |
149 | 149 | $sth->execute(); |
150 | - } catch(PDOException $e) { |
|
150 | + } catch (PDOException $e) { |
|
151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
152 | 152 | } |
153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | try { |
156 | 156 | $sth = $Connection->db->prepare($query); |
157 | 157 | $sth->execute(); |
158 | - } catch(PDOException $e) { |
|
158 | + } catch (PDOException $e) { |
|
159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
160 | 160 | } |
161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $Connection->db->prepare($query); |
166 | 166 | $sth->execute(); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
169 | 169 | } |
170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | try { |
183 | 183 | $sth = $Connection->db->prepare($query); |
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | 187 | } |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $Connection->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
201 | 201 | } |
202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | try { |
205 | 205 | $sth = $Connection->db->prepare($query); |
206 | 206 | $sth->execute(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
209 | 209 | } |
210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $Connection->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
217 | 217 | } |
218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $Connection->db->prepare($query); |
227 | 227 | $sth->execute(); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
230 | 230 | } |
231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | 235 | $Connection = new Connection(); |
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | 255 | } |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
270 | 270 | } |
271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | 276 | $Connection = new Connection(); |
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | 279 | try { |
280 | 280 | $sth = $Connection->db->prepare($query); |
281 | 281 | $sth->execute(); |
282 | - } catch(PDOException $e) { |
|
282 | + } catch (PDOException $e) { |
|
283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
284 | 284 | } |
285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | try { |
288 | 288 | $sth = $Connection->db->prepare($query); |
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch (PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | 292 | } |
293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | 301 | } else { |
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | 303 | } |
304 | 304 | } else { |
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | 306 | } |
307 | 307 | try { |
308 | 308 | $sth = $Connection->db->prepare($query); |
309 | 309 | $sth->execute(); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
312 | 312 | } |
313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
325 | 325 | } |
326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | try { |
340 | 340 | $sth = $Connection->db->prepare($query); |
341 | 341 | $sth->execute(); |
342 | - } catch(PDOException $e) { |
|
342 | + } catch (PDOException $e) { |
|
343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
344 | 344 | } |
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | 346 | try { |
347 | 347 | $sth = $Connection->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
351 | 351 | } |
352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | 356 | $Connection = new Connection(); |
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | 359 | try { |
360 | 360 | $sth = $Connection->db->prepare($query); |
361 | 361 | $sth->execute(); |
362 | - } catch(PDOException $e) { |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
364 | 364 | } |
365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
376 | 376 | } |
377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | 381 | $Connection = new Connection(); |
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | 383 | try { |
384 | 384 | $sth = $Connection->db->prepare($query); |
385 | 385 | $sth->execute(); |
386 | - } catch(PDOException $e) { |
|
386 | + } catch (PDOException $e) { |
|
387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
388 | 388 | } |
389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $sth = $Connection->db->prepare($query); |
403 | 403 | $sth->execute(); |
404 | - } catch(PDOException $e) { |
|
404 | + } catch (PDOException $e) { |
|
405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
406 | 406 | } |
407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | 412 | $Connection = new Connection(); |
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | 414 | try { |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | 416 | $sth->execute(); |
417 | - } catch(PDOException $e) { |
|
417 | + } catch (PDOException $e) { |
|
418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
419 | 419 | } |
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | 421 | try { |
422 | 422 | $sth = $Connection->db->prepare($query); |
423 | 423 | $sth->execute(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
426 | 426 | } |
427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | try { |
430 | 430 | $sth = $Connection->db->prepare($query); |
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | 434 | } |
435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | 443 | } else { |
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | 448 | } |
449 | 449 | try { |
450 | 450 | $sth = $Connection->db->prepare($query); |
451 | 451 | $sth->execute(); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
454 | 454 | } |
455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | try { |
460 | 460 | $sth = $Connection->db->prepare($query); |
461 | 461 | $sth->execute(); |
462 | - } catch(PDOException $e) { |
|
462 | + } catch (PDOException $e) { |
|
463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
464 | 464 | } |
465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $Connection->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
492 | 492 | } |
493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | 497 | $Connection = new Connection(); |
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch (PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | 505 | } |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | try { |
510 | 510 | $sth = $Connection->db->prepare($query); |
511 | 511 | $sth->execute(); |
512 | - } catch(PDOException $e) { |
|
512 | + } catch (PDOException $e) { |
|
513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
514 | 514 | } |
515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $Connection->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
532 | 532 | } |
533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | $Connection = new Connection(); |
539 | 539 | $error = ''; |
540 | 540 | // Add tables |
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | 542 | try { |
543 | 543 | $sth = $Connection->db->prepare($query); |
544 | 544 | $sth->execute(); |
545 | - } catch(PDOException $e) { |
|
545 | + } catch (PDOException $e) { |
|
546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 547 | } |
548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | try { |
551 | 551 | $sth = $Connection->db->prepare($query); |
552 | 552 | $sth->execute(); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
555 | 555 | } |
556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | try { |
572 | 572 | $sth = $Connection->db->prepare($query); |
573 | 573 | $sth->execute(); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
576 | 576 | } |
577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | try { |
590 | 590 | $sth = $Connection->db->prepare($query); |
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
594 | 594 | } |
595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | $Connection = new Connection(); |
599 | 599 | $error = ''; |
600 | 600 | // Modify stats_airport table |
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
603 | 603 | try { |
604 | 604 | $sth = $Connection->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 608 | } |
609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | try { |
613 | 613 | $sth = $Connection->db->prepare($query); |
614 | 614 | $sth->execute(); |
615 | - } catch(PDOException $e) { |
|
615 | + } catch (PDOException $e) { |
|
616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
617 | 617 | } |
618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
629 | 629 | try { |
630 | 630 | $sth = $Connection->db->prepare($query); |
631 | 631 | $sth->execute(); |
632 | - } catch(PDOException $e) { |
|
632 | + } catch (PDOException $e) { |
|
633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
634 | 634 | } |
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | 636 | try { |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
641 | 641 | } |
642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
643 | 643 | // Add column over_country |
644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
645 | 645 | try { |
646 | 646 | $sth = $Connection->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
650 | 650 | } |
651 | 651 | } |
652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
653 | 653 | // Add column over_country |
654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
655 | 655 | try { |
656 | 656 | $sth = $Connection->db->prepare($query); |
657 | 657 | $sth->execute(); |
658 | - } catch(PDOException $e) { |
|
658 | + } catch (PDOException $e) { |
|
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
660 | 660 | } |
661 | 661 | } |
662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | - } catch(PDOException $e) { |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | 670 | } |
671 | 671 | } |
672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | 680 | } |
681 | 681 | } |
682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | - } catch(PDOException $e) { |
|
688 | + } catch (PDOException $e) { |
|
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | 690 | } |
691 | 691 | } |
692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | - } catch(PDOException $e) { |
|
698 | + } catch (PDOException $e) { |
|
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 700 | } |
701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | try { |
705 | 705 | $sth = $Connection->db->prepare($query); |
706 | 706 | $sth->execute(); |
707 | - } catch(PDOException $e) { |
|
707 | + } catch (PDOException $e) { |
|
708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
709 | 709 | } |
710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
723 | 723 | // Add column over_country |
724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
725 | 725 | try { |
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | - } catch(PDOException $e) { |
|
728 | + } catch (PDOException $e) { |
|
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 730 | } |
731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | try { |
742 | 742 | $sth = $Connection->db->prepare($query); |
743 | 743 | $sth->execute(); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
746 | 746 | } |
747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | private static function update_from_21() { |
751 | 751 | $Connection = new Connection(); |
752 | 752 | $error = ''; |
753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
754 | 754 | // Rename type to stats_type |
755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
756 | 756 | try { |
757 | 757 | $sth = $Connection->db->prepare($query); |
758 | 758 | $sth->execute(); |
759 | - } catch(PDOException $e) { |
|
759 | + } catch (PDOException $e) { |
|
760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 761 | } |
762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | try { |
766 | 766 | $sth = $Connection->db->prepare($query); |
767 | 767 | $sth->execute(); |
768 | - } catch(PDOException $e) { |
|
768 | + } catch (PDOException $e) { |
|
769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
770 | 770 | } |
771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | try { |
789 | 789 | $sth = $Connection->db->prepare($query); |
790 | 790 | $sth->execute(); |
791 | - } catch(PDOException $e) { |
|
791 | + } catch (PDOException $e) { |
|
792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
793 | 793 | } |
794 | 794 | return $error; |
@@ -815,17 +815,17 @@ discard block |
||
815 | 815 | try { |
816 | 816 | $sth = $Connection->db->prepare($query); |
817 | 817 | $sth->execute(); |
818 | - } catch(PDOException $e) { |
|
818 | + } catch (PDOException $e) { |
|
819 | 819 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
820 | 820 | } |
821 | 821 | } |
822 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
822 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | 824 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | - } catch(PDOException $e) { |
|
828 | + } catch (PDOException $e) { |
|
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | 830 | } |
831 | 831 | } |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | try { |
835 | 835 | $sth = $Connection->db->prepare($query); |
836 | 836 | $sth->execute(); |
837 | - } catch(PDOException $e) { |
|
837 | + } catch (PDOException $e) { |
|
838 | 838 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
839 | 839 | } |
840 | 840 | return $error; |
@@ -850,23 +850,23 @@ discard block |
||
850 | 850 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 851 | } |
852 | 852 | if ($error != '') return 'Import airlines.sql : '.$error; |
853 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
853 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
854 | 854 | // Add forsource to airlines |
855 | 855 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
856 | 856 | try { |
857 | 857 | $sth = $Connection->db->prepare($query); |
858 | 858 | $sth->execute(); |
859 | - } catch(PDOException $e) { |
|
859 | + } catch (PDOException $e) { |
|
860 | 860 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
861 | 861 | } |
862 | 862 | } |
863 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
863 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
864 | 864 | // Add forsource to airlines |
865 | 865 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
866 | 866 | try { |
867 | 867 | $sth = $Connection->db->prepare($query); |
868 | 868 | $sth->execute(); |
869 | - } catch(PDOException $e) { |
|
869 | + } catch (PDOException $e) { |
|
870 | 870 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
871 | 871 | } |
872 | 872 | // Add unique key |
@@ -878,17 +878,17 @@ discard block |
||
878 | 878 | try { |
879 | 879 | $sth = $Connection->db->prepare($query); |
880 | 880 | $sth->execute(); |
881 | - } catch(PDOException $e) { |
|
881 | + } catch (PDOException $e) { |
|
882 | 882 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
883 | 883 | } |
884 | 884 | } |
885 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
885 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
886 | 886 | // Add forsource to airlines |
887 | 887 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
888 | 888 | try { |
889 | 889 | $sth = $Connection->db->prepare($query); |
890 | 890 | $sth->execute(); |
891 | - } catch(PDOException $e) { |
|
891 | + } catch (PDOException $e) { |
|
892 | 892 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
893 | 893 | } |
894 | 894 | // Add unique key |
@@ -900,17 +900,17 @@ discard block |
||
900 | 900 | try { |
901 | 901 | $sth = $Connection->db->prepare($query); |
902 | 902 | $sth->execute(); |
903 | - } catch(PDOException $e) { |
|
903 | + } catch (PDOException $e) { |
|
904 | 904 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
905 | 905 | } |
906 | 906 | } |
907 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
907 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
908 | 908 | // Add forsource to airlines |
909 | 909 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
910 | 910 | try { |
911 | 911 | $sth = $Connection->db->prepare($query); |
912 | 912 | $sth->execute(); |
913 | - } catch(PDOException $e) { |
|
913 | + } catch (PDOException $e) { |
|
914 | 914 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
915 | 915 | } |
916 | 916 | // Add unique key |
@@ -922,36 +922,36 @@ discard block |
||
922 | 922 | try { |
923 | 923 | $sth = $Connection->db->prepare($query); |
924 | 924 | $sth->execute(); |
925 | - } catch(PDOException $e) { |
|
925 | + } catch (PDOException $e) { |
|
926 | 926 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
927 | 927 | } |
928 | 928 | } |
929 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
929 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
930 | 930 | // Add forsource to airlines |
931 | 931 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
932 | 932 | try { |
933 | 933 | $sth = $Connection->db->prepare($query); |
934 | 934 | $sth->execute(); |
935 | - } catch(PDOException $e) { |
|
935 | + } catch (PDOException $e) { |
|
936 | 936 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
937 | 937 | } |
938 | 938 | } |
939 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
939 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
940 | 940 | // Add forsource to airlines |
941 | 941 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
942 | 942 | try { |
943 | 943 | $sth = $Connection->db->prepare($query); |
944 | 944 | $sth->execute(); |
945 | - } catch(PDOException $e) { |
|
945 | + } catch (PDOException $e) { |
|
946 | 946 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
947 | 947 | } |
948 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
948 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
949 | 949 | // Add unique key |
950 | 950 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
951 | 951 | try { |
952 | 952 | $sth = $Connection->db->prepare($query); |
953 | 953 | $sth->execute(); |
954 | - } catch(PDOException $e) { |
|
954 | + } catch (PDOException $e) { |
|
955 | 955 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
956 | 956 | } |
957 | 957 | } else { |
@@ -964,18 +964,18 @@ discard block |
||
964 | 964 | try { |
965 | 965 | $sth = $Connection->db->prepare($query); |
966 | 966 | $sth->execute(); |
967 | - } catch(PDOException $e) { |
|
967 | + } catch (PDOException $e) { |
|
968 | 968 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
969 | 969 | } |
970 | 970 | } |
971 | 971 | } |
972 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
972 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
973 | 973 | // Add forsource to airlines |
974 | 974 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
975 | 975 | try { |
976 | 976 | $sth = $Connection->db->prepare($query); |
977 | 977 | $sth->execute(); |
978 | - } catch(PDOException $e) { |
|
978 | + } catch (PDOException $e) { |
|
979 | 979 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
980 | 980 | } |
981 | 981 | // Add unique key |
@@ -987,17 +987,17 @@ discard block |
||
987 | 987 | try { |
988 | 988 | $sth = $Connection->db->prepare($query); |
989 | 989 | $sth->execute(); |
990 | - } catch(PDOException $e) { |
|
990 | + } catch (PDOException $e) { |
|
991 | 991 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
992 | 992 | } |
993 | 993 | } |
994 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
994 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
995 | 995 | // Add forsource to airlines |
996 | 996 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
997 | 997 | try { |
998 | 998 | $sth = $Connection->db->prepare($query); |
999 | 999 | $sth->execute(); |
1000 | - } catch(PDOException $e) { |
|
1000 | + } catch (PDOException $e) { |
|
1001 | 1001 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
1002 | 1002 | } |
1003 | 1003 | // Add unique key |
@@ -1009,17 +1009,17 @@ discard block |
||
1009 | 1009 | try { |
1010 | 1010 | $sth = $Connection->db->prepare($query); |
1011 | 1011 | $sth->execute(); |
1012 | - } catch(PDOException $e) { |
|
1012 | + } catch (PDOException $e) { |
|
1013 | 1013 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
1016 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
1017 | 1017 | // Add forsource to airlines |
1018 | 1018 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1019 | 1019 | try { |
1020 | 1020 | $sth = $Connection->db->prepare($query); |
1021 | 1021 | $sth->execute(); |
1022 | - } catch(PDOException $e) { |
|
1022 | + } catch (PDOException $e) { |
|
1023 | 1023 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
1024 | 1024 | } |
1025 | 1025 | // Add unique key |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | try { |
1032 | 1032 | $sth = $Connection->db->prepare($query); |
1033 | 1033 | $sth->execute(); |
1034 | - } catch(PDOException $e) { |
|
1034 | + } catch (PDOException $e) { |
|
1035 | 1035 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1036 | 1036 | } |
1037 | 1037 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | try { |
1041 | 1041 | $sth = $Connection->db->prepare($query); |
1042 | 1042 | $sth->execute(); |
1043 | - } catch(PDOException $e) { |
|
1043 | + } catch (PDOException $e) { |
|
1044 | 1044 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1045 | 1045 | } |
1046 | 1046 | return $error; |
@@ -1050,13 +1050,13 @@ discard block |
||
1050 | 1050 | global $globalDBdriver; |
1051 | 1051 | $Connection = new Connection(); |
1052 | 1052 | $error = ''; |
1053 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
1053 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
1054 | 1054 | // Add forsource to airlines |
1055 | 1055 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1056 | 1056 | try { |
1057 | 1057 | $sth = $Connection->db->prepare($query); |
1058 | 1058 | $sth->execute(); |
1059 | - } catch(PDOException $e) { |
|
1059 | + } catch (PDOException $e) { |
|
1060 | 1060 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
1061 | 1061 | } |
1062 | 1062 | // Add unique key |
@@ -1068,17 +1068,17 @@ discard block |
||
1068 | 1068 | try { |
1069 | 1069 | $sth = $Connection->db->prepare($query); |
1070 | 1070 | $sth->execute(); |
1071 | - } catch(PDOException $e) { |
|
1071 | + } catch (PDOException $e) { |
|
1072 | 1072 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
1073 | 1073 | } |
1074 | 1074 | } |
1075 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
1075 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
1076 | 1076 | // Add forsource to airlines |
1077 | 1077 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1078 | 1078 | try { |
1079 | 1079 | $sth = $Connection->db->prepare($query); |
1080 | 1080 | $sth->execute(); |
1081 | - } catch(PDOException $e) { |
|
1081 | + } catch (PDOException $e) { |
|
1082 | 1082 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
1083 | 1083 | } |
1084 | 1084 | // Add unique key |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | try { |
1091 | 1091 | $sth = $Connection->db->prepare($query); |
1092 | 1092 | $sth->execute(); |
1093 | - } catch(PDOException $e) { |
|
1093 | + } catch (PDOException $e) { |
|
1094 | 1094 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1095 | 1095 | } |
1096 | 1096 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | try { |
1099 | 1099 | $sth = $Connection->db->prepare($query); |
1100 | 1100 | $sth->execute(); |
1101 | - } catch(PDOException $e) { |
|
1101 | + } catch (PDOException $e) { |
|
1102 | 1102 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1103 | 1103 | } |
1104 | 1104 | return $error; |
@@ -1108,12 +1108,12 @@ discard block |
||
1108 | 1108 | global $globalDBdriver; |
1109 | 1109 | $Connection = new Connection(); |
1110 | 1110 | $error = ''; |
1111 | - if (!$Connection->checkColumnName('atc','format_source')) { |
|
1111 | + if (!$Connection->checkColumnName('atc', 'format_source')) { |
|
1112 | 1112 | $query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL"; |
1113 | 1113 | try { |
1114 | 1114 | $sth = $Connection->db->prepare($query); |
1115 | 1115 | $sth->execute(); |
1116 | - } catch(PDOException $e) { |
|
1116 | + } catch (PDOException $e) { |
|
1117 | 1117 | return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n"; |
1118 | 1118 | } |
1119 | 1119 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | try { |
1122 | 1122 | $sth = $Connection->db->prepare($query); |
1123 | 1123 | $sth->execute(); |
1124 | - } catch(PDOException $e) { |
|
1124 | + } catch (PDOException $e) { |
|
1125 | 1125 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1126 | 1126 | } |
1127 | 1127 | return $error; |
@@ -1131,13 +1131,13 @@ discard block |
||
1131 | 1131 | global $globalDBdriver; |
1132 | 1132 | $Connection = new Connection(); |
1133 | 1133 | $error = ''; |
1134 | - if (!$Connection->checkColumnName('stats_pilot','format_source')) { |
|
1134 | + if (!$Connection->checkColumnName('stats_pilot', 'format_source')) { |
|
1135 | 1135 | // Add forsource to airlines |
1136 | 1136 | $query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''"; |
1137 | 1137 | try { |
1138 | 1138 | $sth = $Connection->db->prepare($query); |
1139 | 1139 | $sth->execute(); |
1140 | - } catch(PDOException $e) { |
|
1140 | + } catch (PDOException $e) { |
|
1141 | 1141 | return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n"; |
1142 | 1142 | } |
1143 | 1143 | // Add unique key |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | try { |
1150 | 1150 | $sth = $Connection->db->prepare($query); |
1151 | 1151 | $sth->execute(); |
1152 | - } catch(PDOException $e) { |
|
1152 | + } catch (PDOException $e) { |
|
1153 | 1153 | return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1154 | 1154 | } |
1155 | 1155 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | try { |
1158 | 1158 | $sth = $Connection->db->prepare($query); |
1159 | 1159 | $sth->execute(); |
1160 | - } catch(PDOException $e) { |
|
1160 | + } catch (PDOException $e) { |
|
1161 | 1161 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1162 | 1162 | } |
1163 | 1163 | return $error; |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | try { |
1180 | 1180 | $sth = $Connection->db->prepare($query); |
1181 | 1181 | $sth->execute(); |
1182 | - } catch(PDOException $e) { |
|
1182 | + } catch (PDOException $e) { |
|
1183 | 1183 | return "error : ".$e->getMessage()."\n"; |
1184 | 1184 | } |
1185 | 1185 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -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 | } |