@@ -15,67 +15,67 @@ discard block |
||
15 | 15 | if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
16 | 16 | $Connection = new Connection($dbc); |
17 | 17 | $this->db = $Connection->db(); |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | 20 | public function addLastStatsUpdate($type,$stats_date) { |
21 | - $query = "DELETE FROM config WHERE name = :type; |
|
21 | + $query = "DELETE FROM config WHERE name = :type; |
|
22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | - try { |
|
25 | - $sth = $this->db->prepare($query); |
|
26 | - $sth->execute($query_values); |
|
27 | - } catch(PDOException $e) { |
|
28 | - return "error : ".$e->getMessage(); |
|
29 | - } |
|
30 | - } |
|
23 | + $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | + try { |
|
25 | + $sth = $this->db->prepare($query); |
|
26 | + $sth->execute($query_values); |
|
27 | + } catch(PDOException $e) { |
|
28 | + return "error : ".$e->getMessage(); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | 32 | public function getLastStatsUpdate($type = 'last_update_stats') { |
33 | - $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | - try { |
|
35 | - $sth = $this->db->prepare($query); |
|
36 | - $sth->execute(array(':type' => $type)); |
|
37 | - } catch(PDOException $e) { |
|
38 | - echo "error : ".$e->getMessage(); |
|
39 | - } |
|
40 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | - return $all; |
|
42 | - } |
|
33 | + $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | + try { |
|
35 | + $sth = $this->db->prepare($query); |
|
36 | + $sth->execute(array(':type' => $type)); |
|
37 | + } catch(PDOException $e) { |
|
38 | + echo "error : ".$e->getMessage(); |
|
39 | + } |
|
40 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | + return $all; |
|
42 | + } |
|
43 | 43 | public function getAllAirlineNames($filter_name = '') { |
44 | 44 | if ($filter_name == '') $filter_name = $this->filter_name; |
45 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
46 | - try { |
|
47 | - $sth = $this->db->prepare($query); |
|
48 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
49 | - } catch(PDOException $e) { |
|
50 | - echo "error : ".$e->getMessage(); |
|
51 | - } |
|
52 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
53 | - return $all; |
|
54 | - } |
|
45 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
46 | + try { |
|
47 | + $sth = $this->db->prepare($query); |
|
48 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
49 | + } catch(PDOException $e) { |
|
50 | + echo "error : ".$e->getMessage(); |
|
51 | + } |
|
52 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
53 | + return $all; |
|
54 | + } |
|
55 | 55 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
56 | 56 | if ($filter_name == '') $filter_name = $this->filter_name; |
57 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
58 | - try { |
|
59 | - $sth = $this->db->prepare($query); |
|
60 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
61 | - } catch(PDOException $e) { |
|
62 | - echo "error : ".$e->getMessage(); |
|
63 | - } |
|
64 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
65 | - return $all; |
|
66 | - } |
|
57 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
58 | + try { |
|
59 | + $sth = $this->db->prepare($query); |
|
60 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
61 | + } catch(PDOException $e) { |
|
62 | + echo "error : ".$e->getMessage(); |
|
63 | + } |
|
64 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
65 | + return $all; |
|
66 | + } |
|
67 | 67 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
68 | 68 | if ($filter_name == '') $filter_name = $this->filter_name; |
69 | - $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"; |
|
70 | - try { |
|
71 | - $sth = $this->db->prepare($query); |
|
72 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
73 | - } catch(PDOException $e) { |
|
74 | - echo "error : ".$e->getMessage(); |
|
75 | - } |
|
76 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
77 | - return $all; |
|
78 | - } |
|
69 | + $query = "SELECT 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"; |
|
70 | + try { |
|
71 | + $sth = $this->db->prepare($query); |
|
72 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
73 | + } catch(PDOException $e) { |
|
74 | + echo "error : ".$e->getMessage(); |
|
75 | + } |
|
76 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
77 | + return $all; |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | 81 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -83,66 +83,66 @@ discard block |
||
83 | 83 | if ($filter_name == '') $filter_name = $this->filter_name; |
84 | 84 | 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"; |
85 | 85 | 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"; |
86 | - try { |
|
87 | - $sth = $this->db->prepare($query); |
|
88 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
89 | - } catch(PDOException $e) { |
|
90 | - echo "error : ".$e->getMessage(); |
|
91 | - } |
|
92 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
93 | - if (empty($all)) { |
|
94 | - $filters = array('airlines' => array($stats_airline)); |
|
95 | - if ($filter_name != '') { |
|
96 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
97 | - } |
|
98 | - $Spotter = new Spotter($this->db); |
|
99 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
100 | - } |
|
101 | - return $all; |
|
86 | + try { |
|
87 | + $sth = $this->db->prepare($query); |
|
88 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
89 | + } catch(PDOException $e) { |
|
90 | + echo "error : ".$e->getMessage(); |
|
91 | + } |
|
92 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
93 | + if (empty($all)) { |
|
94 | + $filters = array('airlines' => array($stats_airline)); |
|
95 | + if ($filter_name != '') { |
|
96 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
97 | + } |
|
98 | + $Spotter = new Spotter($this->db); |
|
99 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
100 | + } |
|
101 | + return $all; |
|
102 | 102 | } |
103 | 103 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
104 | 104 | global $globalStatsFilters; |
105 | 105 | if ($filter_name == '') $filter_name = $this->filter_name; |
106 | 106 | 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"; |
107 | 107 | 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"; |
108 | - try { |
|
109 | - $sth = $this->db->prepare($query); |
|
110 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
111 | - } catch(PDOException $e) { |
|
112 | - echo "error : ".$e->getMessage(); |
|
113 | - } |
|
114 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
115 | - if (empty($all)) { |
|
116 | - $Spotter = new Spotter($this->db); |
|
117 | - $filters = array(); |
|
118 | - if ($filter_name != '') { |
|
119 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
120 | - } |
|
121 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
122 | - } |
|
123 | - return $all; |
|
108 | + try { |
|
109 | + $sth = $this->db->prepare($query); |
|
110 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
111 | + } catch(PDOException $e) { |
|
112 | + echo "error : ".$e->getMessage(); |
|
113 | + } |
|
114 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
115 | + if (empty($all)) { |
|
116 | + $Spotter = new Spotter($this->db); |
|
117 | + $filters = array(); |
|
118 | + if ($filter_name != '') { |
|
119 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
120 | + } |
|
121 | + $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
122 | + } |
|
123 | + return $all; |
|
124 | 124 | } |
125 | 125 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
126 | 126 | global $globalStatsFilters; |
127 | 127 | if ($filter_name == '') $filter_name = $this->filter_name; |
128 | 128 | 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"; |
129 | 129 | 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"; |
130 | - try { |
|
131 | - $sth = $this->db->prepare($query); |
|
132 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
133 | - } catch(PDOException $e) { |
|
134 | - echo "error : ".$e->getMessage(); |
|
135 | - } |
|
136 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
137 | - if (empty($all)) { |
|
138 | - $filters = array('airlines' => array($stats_airline)); |
|
139 | - if ($filter_name != '') { |
|
140 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
130 | + try { |
|
131 | + $sth = $this->db->prepare($query); |
|
132 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
133 | + } catch(PDOException $e) { |
|
134 | + echo "error : ".$e->getMessage(); |
|
135 | + } |
|
136 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
137 | + if (empty($all)) { |
|
138 | + $filters = array('airlines' => array($stats_airline)); |
|
139 | + if ($filter_name != '') { |
|
140 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
141 | 141 | } |
142 | - $Spotter = new Spotter($this->db); |
|
142 | + $Spotter = new Spotter($this->db); |
|
143 | 143 | $all = $Spotter->countAllAircraftManufacturers($filters); |
144 | - } |
|
145 | - return $all; |
|
144 | + } |
|
145 | + return $all; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -150,44 +150,44 @@ discard block |
||
150 | 150 | if ($filter_name == '') $filter_name = $this->filter_name; |
151 | 151 | 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"; |
152 | 152 | 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"; |
153 | - try { |
|
154 | - $sth = $this->db->prepare($query); |
|
155 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
156 | - } catch(PDOException $e) { |
|
157 | - echo "error : ".$e->getMessage(); |
|
158 | - } |
|
159 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
160 | - if (empty($all)) { |
|
153 | + try { |
|
154 | + $sth = $this->db->prepare($query); |
|
155 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
156 | + } catch(PDOException $e) { |
|
157 | + echo "error : ".$e->getMessage(); |
|
158 | + } |
|
159 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
160 | + if (empty($all)) { |
|
161 | 161 | $filters = array('airlines' => array($stats_airline)); |
162 | 162 | if ($filter_name != '') { |
163 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
163 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
164 | 164 | } |
165 | 165 | $Spotter = new Spotter($this->db); |
166 | 166 | $all = $Spotter->countAllArrivalCountries($limit,$filters); |
167 | - } |
|
168 | - return $all; |
|
167 | + } |
|
168 | + return $all; |
|
169 | 169 | } |
170 | 170 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
171 | 171 | global $globalStatsFilters; |
172 | 172 | if ($filter_name == '') $filter_name = $this->filter_name; |
173 | 173 | 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"; |
174 | 174 | 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"; |
175 | - try { |
|
176 | - $sth = $this->db->prepare($query); |
|
177 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
178 | - } catch(PDOException $e) { |
|
179 | - echo "error : ".$e->getMessage(); |
|
180 | - } |
|
181 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
182 | - if (empty($all)) { |
|
175 | + try { |
|
176 | + $sth = $this->db->prepare($query); |
|
177 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
178 | + } catch(PDOException $e) { |
|
179 | + echo "error : ".$e->getMessage(); |
|
180 | + } |
|
181 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
182 | + if (empty($all)) { |
|
183 | 183 | $filters = array('airlines' => array($stats_airline)); |
184 | 184 | if ($filter_name != '') { |
185 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
185 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
186 | 186 | } |
187 | 187 | $Spotter = new Spotter($this->db); |
188 | 188 | $all = $Spotter->countAllDepartureCountries($filters); |
189 | - } |
|
190 | - return $all; |
|
189 | + } |
|
190 | + return $all; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | public function countAllAirlines($limit = true,$filter_name = '') { |
@@ -195,45 +195,45 @@ discard block |
||
195 | 195 | if ($filter_name == '') $filter_name = $this->filter_name; |
196 | 196 | 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"; |
197 | 197 | 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"; |
198 | - try { |
|
199 | - $sth = $this->db->prepare($query); |
|
200 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
201 | - } catch(PDOException $e) { |
|
202 | - echo "error : ".$e->getMessage(); |
|
203 | - } |
|
204 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
205 | - if (empty($all)) { |
|
206 | - $Spotter = new Spotter($this->db); |
|
207 | - $filters = array(); |
|
208 | - if ($filter_name != '') { |
|
209 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
198 | + try { |
|
199 | + $sth = $this->db->prepare($query); |
|
200 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
201 | + } catch(PDOException $e) { |
|
202 | + echo "error : ".$e->getMessage(); |
|
203 | + } |
|
204 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
205 | + if (empty($all)) { |
|
206 | + $Spotter = new Spotter($this->db); |
|
207 | + $filters = array(); |
|
208 | + if ($filter_name != '') { |
|
209 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
210 | 210 | } |
211 | 211 | |
212 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
213 | - } |
|
214 | - return $all; |
|
212 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
213 | + } |
|
214 | + return $all; |
|
215 | 215 | } |
216 | 216 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
217 | 217 | global $globalStatsFilters; |
218 | 218 | if ($filter_name == '') $filter_name = $this->filter_name; |
219 | 219 | 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"; |
220 | 220 | 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"; |
221 | - try { |
|
222 | - $sth = $this->db->prepare($query); |
|
223 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
224 | - } catch(PDOException $e) { |
|
225 | - echo "error : ".$e->getMessage(); |
|
226 | - } |
|
227 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | - if (empty($all)) { |
|
221 | + try { |
|
222 | + $sth = $this->db->prepare($query); |
|
223 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
224 | + } catch(PDOException $e) { |
|
225 | + echo "error : ".$e->getMessage(); |
|
226 | + } |
|
227 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | + if (empty($all)) { |
|
229 | 229 | $filters = array('airlines' => array($stats_airline)); |
230 | 230 | if ($filter_name != '') { |
231 | 231 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
232 | 232 | } |
233 | - $Spotter = new Spotter($this->db); |
|
234 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
235 | - } |
|
236 | - return $all; |
|
233 | + $Spotter = new Spotter($this->db); |
|
234 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
235 | + } |
|
236 | + return $all; |
|
237 | 237 | } |
238 | 238 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
239 | 239 | global $globalStatsFilters; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | echo "error : ".$e->getMessage(); |
271 | 271 | } |
272 | 272 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
273 | - /* |
|
273 | + /* |
|
274 | 274 | if (empty($all)) { |
275 | 275 | $Spotter = new Spotter($this->db); |
276 | 276 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -286,84 +286,84 @@ discard block |
||
286 | 286 | if ($filter_name == '') $filter_name = $this->filter_name; |
287 | 287 | if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
288 | 288 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
289 | - try { |
|
290 | - $sth = $this->db->prepare($query); |
|
291 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
292 | - } catch(PDOException $e) { |
|
293 | - echo "error : ".$e->getMessage(); |
|
294 | - } |
|
295 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
296 | - if (empty($all)) { |
|
289 | + try { |
|
290 | + $sth = $this->db->prepare($query); |
|
291 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
292 | + } catch(PDOException $e) { |
|
293 | + echo "error : ".$e->getMessage(); |
|
294 | + } |
|
295 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
296 | + if (empty($all)) { |
|
297 | 297 | $filters = array('airlines' => array($stats_airline)); |
298 | 298 | if ($filter_name != '') { |
299 | 299 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
300 | 300 | } |
301 | - $Spotter = new Spotter($this->db); |
|
302 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
303 | - } |
|
304 | - return $all; |
|
301 | + $Spotter = new Spotter($this->db); |
|
302 | + $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
303 | + } |
|
304 | + return $all; |
|
305 | 305 | } |
306 | 306 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
307 | 307 | global $globalStatsFilters; |
308 | 308 | if ($filter_name == '') $filter_name = $this->filter_name; |
309 | 309 | 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"; |
310 | 310 | 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"; |
311 | - try { |
|
312 | - $sth = $this->db->prepare($query); |
|
313 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
314 | - } catch(PDOException $e) { |
|
315 | - echo "error : ".$e->getMessage(); |
|
316 | - } |
|
317 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
318 | - if (empty($all)) { |
|
311 | + try { |
|
312 | + $sth = $this->db->prepare($query); |
|
313 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
314 | + } catch(PDOException $e) { |
|
315 | + echo "error : ".$e->getMessage(); |
|
316 | + } |
|
317 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
318 | + if (empty($all)) { |
|
319 | 319 | $filters = array('airlines' => array($stats_airline)); |
320 | 320 | if ($filter_name != '') { |
321 | 321 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
322 | 322 | } |
323 | - $Spotter = new Spotter($this->db); |
|
324 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
325 | - } |
|
326 | - return $all; |
|
323 | + $Spotter = new Spotter($this->db); |
|
324 | + $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
325 | + } |
|
326 | + return $all; |
|
327 | 327 | } |
328 | 328 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
329 | 329 | global $globalStatsFilters; |
330 | 330 | if ($filter_name == '') $filter_name = $this->filter_name; |
331 | 331 | 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"; |
332 | 332 | 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"; |
333 | - try { |
|
334 | - $sth = $this->db->prepare($query); |
|
335 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
336 | - } catch(PDOException $e) { |
|
337 | - echo "error : ".$e->getMessage(); |
|
338 | - } |
|
339 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
340 | - if (empty($all)) { |
|
333 | + try { |
|
334 | + $sth = $this->db->prepare($query); |
|
335 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
336 | + } catch(PDOException $e) { |
|
337 | + echo "error : ".$e->getMessage(); |
|
338 | + } |
|
339 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
340 | + if (empty($all)) { |
|
341 | 341 | $filters = array('airlines' => array($stats_airline)); |
342 | - if ($filter_name != '') { |
|
343 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
344 | - } |
|
345 | - $Spotter = new Spotter($this->db); |
|
346 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
347 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
348 | - $all = array(); |
|
349 | - foreach ($pall as $value) { |
|
350 | - $icao = $value['airport_departure_icao']; |
|
351 | - $all[$icao] = $value; |
|
352 | - } |
|
342 | + if ($filter_name != '') { |
|
343 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
344 | + } |
|
345 | + $Spotter = new Spotter($this->db); |
|
346 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
347 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
348 | + $all = array(); |
|
349 | + foreach ($pall as $value) { |
|
350 | + $icao = $value['airport_departure_icao']; |
|
351 | + $all[$icao] = $value; |
|
352 | + } |
|
353 | 353 | |
354 | - foreach ($dall as $value) { |
|
355 | - $icao = $value['airport_departure_icao']; |
|
356 | - if (isset($all[$icao])) { |
|
357 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
358 | - } else $all[$icao] = $value; |
|
359 | - } |
|
360 | - $count = array(); |
|
361 | - foreach ($all as $key => $row) { |
|
362 | - $count[$key] = $row['airport_departure_icao_count']; |
|
363 | - } |
|
364 | - array_multisort($count,SORT_DESC,$all); |
|
365 | - } |
|
366 | - return $all; |
|
354 | + foreach ($dall as $value) { |
|
355 | + $icao = $value['airport_departure_icao']; |
|
356 | + if (isset($all[$icao])) { |
|
357 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
358 | + } else $all[$icao] = $value; |
|
359 | + } |
|
360 | + $count = array(); |
|
361 | + foreach ($all as $key => $row) { |
|
362 | + $count[$key] = $row['airport_departure_icao_count']; |
|
363 | + } |
|
364 | + array_multisort($count,SORT_DESC,$all); |
|
365 | + } |
|
366 | + return $all; |
|
367 | 367 | } |
368 | 368 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
369 | 369 | global $globalStatsFilters; |
@@ -385,26 +385,26 @@ discard block |
||
385 | 385 | $Spotter = new Spotter($this->db); |
386 | 386 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
387 | 387 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
388 | - $all = array(); |
|
389 | - foreach ($pall as $value) { |
|
390 | - $icao = $value['airport_arrival_icao']; |
|
391 | - $all[$icao] = $value; |
|
392 | - } |
|
388 | + $all = array(); |
|
389 | + foreach ($pall as $value) { |
|
390 | + $icao = $value['airport_arrival_icao']; |
|
391 | + $all[$icao] = $value; |
|
392 | + } |
|
393 | 393 | |
394 | - foreach ($dall as $value) { |
|
395 | - $icao = $value['airport_arrival_icao']; |
|
396 | - if (isset($all[$icao])) { |
|
397 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
398 | - } else $all[$icao] = $value; |
|
399 | - } |
|
400 | - $count = array(); |
|
401 | - foreach ($all as $key => $row) { |
|
402 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
403 | - } |
|
404 | - array_multisort($count,SORT_DESC,$all); |
|
405 | - } |
|
394 | + foreach ($dall as $value) { |
|
395 | + $icao = $value['airport_arrival_icao']; |
|
396 | + if (isset($all[$icao])) { |
|
397 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
398 | + } else $all[$icao] = $value; |
|
399 | + } |
|
400 | + $count = array(); |
|
401 | + foreach ($all as $key => $row) { |
|
402 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
403 | + } |
|
404 | + array_multisort($count,SORT_DESC,$all); |
|
405 | + } |
|
406 | 406 | |
407 | - return $all; |
|
407 | + return $all; |
|
408 | 408 | } |
409 | 409 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
410 | 410 | global $globalDBdriver, $globalStatsFilters; |
@@ -417,23 +417,23 @@ discard block |
||
417 | 417 | 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"; |
418 | 418 | } |
419 | 419 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
420 | - try { |
|
421 | - $sth = $this->db->prepare($query); |
|
422 | - $sth->execute($query_data); |
|
423 | - } catch(PDOException $e) { |
|
424 | - echo "error : ".$e->getMessage(); |
|
425 | - } |
|
426 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
427 | - if (empty($all)) { |
|
420 | + try { |
|
421 | + $sth = $this->db->prepare($query); |
|
422 | + $sth->execute($query_data); |
|
423 | + } catch(PDOException $e) { |
|
424 | + echo "error : ".$e->getMessage(); |
|
425 | + } |
|
426 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
427 | + if (empty($all)) { |
|
428 | 428 | $filters = array('airlines' => array($stats_airline)); |
429 | 429 | if ($filter_name != '') { |
430 | 430 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
431 | 431 | } |
432 | - $Spotter = new Spotter($this->db); |
|
433 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
434 | - } |
|
432 | + $Spotter = new Spotter($this->db); |
|
433 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
434 | + } |
|
435 | 435 | |
436 | - return $all; |
|
436 | + return $all; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
@@ -441,22 +441,22 @@ discard block |
||
441 | 441 | if ($filter_name == '') $filter_name = $this->filter_name; |
442 | 442 | $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"; |
443 | 443 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
444 | - try { |
|
445 | - $sth = $this->db->prepare($query); |
|
446 | - $sth->execute($query_data); |
|
447 | - } catch(PDOException $e) { |
|
448 | - echo "error : ".$e->getMessage(); |
|
449 | - } |
|
450 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
451 | - if (empty($all)) { |
|
444 | + try { |
|
445 | + $sth = $this->db->prepare($query); |
|
446 | + $sth->execute($query_data); |
|
447 | + } catch(PDOException $e) { |
|
448 | + echo "error : ".$e->getMessage(); |
|
449 | + } |
|
450 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
451 | + if (empty($all)) { |
|
452 | 452 | $filters = array('airlines' => array($stats_airline)); |
453 | 453 | if ($filter_name != '') { |
454 | 454 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
455 | 455 | } |
456 | - $Spotter = new Spotter($this->db); |
|
457 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
458 | - } |
|
459 | - return $all; |
|
456 | + $Spotter = new Spotter($this->db); |
|
457 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
458 | + } |
|
459 | + return $all; |
|
460 | 460 | } |
461 | 461 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
462 | 462 | global $globalDBdriver, $globalStatsFilters; |
@@ -467,108 +467,108 @@ discard block |
||
467 | 467 | $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"; |
468 | 468 | } |
469 | 469 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
470 | - try { |
|
471 | - $sth = $this->db->prepare($query); |
|
472 | - $sth->execute($query_data); |
|
473 | - } catch(PDOException $e) { |
|
474 | - echo "error : ".$e->getMessage(); |
|
475 | - } |
|
476 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
477 | - if (empty($all)) { |
|
470 | + try { |
|
471 | + $sth = $this->db->prepare($query); |
|
472 | + $sth->execute($query_data); |
|
473 | + } catch(PDOException $e) { |
|
474 | + echo "error : ".$e->getMessage(); |
|
475 | + } |
|
476 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
477 | + if (empty($all)) { |
|
478 | 478 | $filters = array('airlines' => array($stats_airline)); |
479 | 479 | if ($filter_name != '') { |
480 | 480 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
481 | 481 | } |
482 | - $Spotter = new Spotter($this->db); |
|
483 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
484 | - } |
|
485 | - return $all; |
|
482 | + $Spotter = new Spotter($this->db); |
|
483 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
484 | + } |
|
485 | + return $all; |
|
486 | 486 | } |
487 | 487 | public function countAllDates($stats_airline = '',$filter_name = '') { |
488 | 488 | global $globalStatsFilters; |
489 | 489 | if ($filter_name == '') $filter_name = $this->filter_name; |
490 | 490 | $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"; |
491 | 491 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
492 | - try { |
|
493 | - $sth = $this->db->prepare($query); |
|
494 | - $sth->execute($query_data); |
|
495 | - } catch(PDOException $e) { |
|
496 | - echo "error : ".$e->getMessage(); |
|
497 | - } |
|
498 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
499 | - if (empty($all)) { |
|
492 | + try { |
|
493 | + $sth = $this->db->prepare($query); |
|
494 | + $sth->execute($query_data); |
|
495 | + } catch(PDOException $e) { |
|
496 | + echo "error : ".$e->getMessage(); |
|
497 | + } |
|
498 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
499 | + if (empty($all)) { |
|
500 | 500 | $filters = array('airlines' => array($stats_airline)); |
501 | 501 | if ($filter_name != '') { |
502 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
502 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
503 | 503 | } |
504 | - $Spotter = new Spotter($this->db); |
|
505 | - $all = $Spotter->countAllDates($filters); |
|
506 | - } |
|
507 | - return $all; |
|
504 | + $Spotter = new Spotter($this->db); |
|
505 | + $all = $Spotter->countAllDates($filters); |
|
506 | + } |
|
507 | + return $all; |
|
508 | 508 | } |
509 | 509 | public function countAllDatesByAirlines($filter_name = '') { |
510 | 510 | global $globalStatsFilters; |
511 | 511 | if ($filter_name == '') $filter_name = $this->filter_name; |
512 | 512 | $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"; |
513 | 513 | $query_data = array('filter_name' => $filter_name); |
514 | - try { |
|
515 | - $sth = $this->db->prepare($query); |
|
516 | - $sth->execute($query_data); |
|
517 | - } catch(PDOException $e) { |
|
518 | - echo "error : ".$e->getMessage(); |
|
519 | - } |
|
520 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
521 | - if (empty($all)) { |
|
522 | - $filters = array(); |
|
523 | - if ($filter_name != '') { |
|
524 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
525 | - } |
|
526 | - $Spotter = new Spotter($this->db); |
|
527 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
528 | - } |
|
529 | - return $all; |
|
514 | + try { |
|
515 | + $sth = $this->db->prepare($query); |
|
516 | + $sth->execute($query_data); |
|
517 | + } catch(PDOException $e) { |
|
518 | + echo "error : ".$e->getMessage(); |
|
519 | + } |
|
520 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
521 | + if (empty($all)) { |
|
522 | + $filters = array(); |
|
523 | + if ($filter_name != '') { |
|
524 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
525 | + } |
|
526 | + $Spotter = new Spotter($this->db); |
|
527 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
528 | + } |
|
529 | + return $all; |
|
530 | 530 | } |
531 | 531 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
532 | 532 | global $globalStatsFilters; |
533 | 533 | if ($filter_name == '') $filter_name = $this->filter_name; |
534 | - $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"; |
|
535 | - try { |
|
536 | - $sth = $this->db->prepare($query); |
|
537 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
538 | - } catch(PDOException $e) { |
|
539 | - echo "error : ".$e->getMessage(); |
|
540 | - } |
|
541 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
542 | - if (empty($all)) { |
|
534 | + $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"; |
|
535 | + try { |
|
536 | + $sth = $this->db->prepare($query); |
|
537 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
538 | + } catch(PDOException $e) { |
|
539 | + echo "error : ".$e->getMessage(); |
|
540 | + } |
|
541 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
542 | + if (empty($all)) { |
|
543 | 543 | $filters = array('airlines' => array($stats_airline)); |
544 | 544 | if ($filter_name != '') { |
545 | 545 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
546 | 546 | } |
547 | - $Spotter = new Spotter($this->db); |
|
548 | - $all = $Spotter->countAllMonths($filters); |
|
549 | - } |
|
550 | - return $all; |
|
547 | + $Spotter = new Spotter($this->db); |
|
548 | + $all = $Spotter->countAllMonths($filters); |
|
549 | + } |
|
550 | + return $all; |
|
551 | 551 | } |
552 | 552 | public function countAllMilitaryMonths($filter_name = '') { |
553 | 553 | global $globalStatsFilters; |
554 | 554 | if ($filter_name == '') $filter_name = $this->filter_name; |
555 | - $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"; |
|
556 | - try { |
|
557 | - $sth = $this->db->prepare($query); |
|
558 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
559 | - } catch(PDOException $e) { |
|
560 | - echo "error : ".$e->getMessage(); |
|
561 | - } |
|
562 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
563 | - if (empty($all)) { |
|
564 | - $filters = array(); |
|
565 | - if ($filter_name != '') { |
|
566 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
567 | - } |
|
568 | - $Spotter = new Spotter($this->db); |
|
569 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
570 | - } |
|
571 | - return $all; |
|
555 | + $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"; |
|
556 | + try { |
|
557 | + $sth = $this->db->prepare($query); |
|
558 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
559 | + } catch(PDOException $e) { |
|
560 | + echo "error : ".$e->getMessage(); |
|
561 | + } |
|
562 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
563 | + if (empty($all)) { |
|
564 | + $filters = array(); |
|
565 | + if ($filter_name != '') { |
|
566 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
567 | + } |
|
568 | + $Spotter = new Spotter($this->db); |
|
569 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
570 | + } |
|
571 | + return $all; |
|
572 | 572 | } |
573 | 573 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
574 | 574 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -584,22 +584,22 @@ discard block |
||
584 | 584 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
585 | 585 | } |
586 | 586 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
587 | - try { |
|
588 | - $sth = $this->db->prepare($query); |
|
589 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
590 | - } catch(PDOException $e) { |
|
591 | - echo "error : ".$e->getMessage(); |
|
592 | - } |
|
593 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
594 | - if (empty($all)) { |
|
587 | + try { |
|
588 | + $sth = $this->db->prepare($query); |
|
589 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
590 | + } catch(PDOException $e) { |
|
591 | + echo "error : ".$e->getMessage(); |
|
592 | + } |
|
593 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
594 | + if (empty($all)) { |
|
595 | 595 | $filters = array('airlines' => array($stats_airline)); |
596 | 596 | if ($filter_name != '') { |
597 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
597 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
598 | 598 | } |
599 | - $Spotter = new Spotter($this->db); |
|
600 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
601 | - } |
|
602 | - return $all; |
|
599 | + $Spotter = new Spotter($this->db); |
|
600 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
601 | + } |
|
602 | + return $all; |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | if ($filter_name == '') $filter_name = $this->filter_name; |
622 | 622 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
623 | 623 | if (empty($all)) { |
624 | - $filters = array(); |
|
625 | - if ($filter_name != '') { |
|
626 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
624 | + $filters = array(); |
|
625 | + if ($filter_name != '') { |
|
626 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
627 | 627 | } |
628 | 628 | $Spotter = new Spotter($this->db); |
629 | 629 | $all = $Spotter->countOverallMilitaryFlights($filters); |
@@ -662,19 +662,19 @@ discard block |
||
662 | 662 | global $globalStatsFilters; |
663 | 663 | if ($filter_name == '') $filter_name = $this->filter_name; |
664 | 664 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
665 | - try { |
|
666 | - $sth = $this->db->prepare($query); |
|
667 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
668 | - } catch(PDOException $e) { |
|
669 | - echo "error : ".$e->getMessage(); |
|
670 | - } |
|
671 | - $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
672 | - $all = $result[0]['nb_airline']; |
|
665 | + try { |
|
666 | + $sth = $this->db->prepare($query); |
|
667 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
668 | + } catch(PDOException $e) { |
|
669 | + echo "error : ".$e->getMessage(); |
|
670 | + } |
|
671 | + $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
672 | + $all = $result[0]['nb_airline']; |
|
673 | 673 | //$all = $this->getSumStats('airlines_bymonth',date('Y')); |
674 | 674 | if (empty($all)) { |
675 | - $filters = array(); |
|
676 | - if ($filter_name != '') { |
|
677 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
675 | + $filters = array(); |
|
676 | + if ($filter_name != '') { |
|
677 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
678 | 678 | } |
679 | 679 | $Spotter = new Spotter($this->db); |
680 | 680 | $all = $Spotter->countOverallAirlines($filters); |
@@ -725,166 +725,166 @@ discard block |
||
725 | 725 | if ($filter_name == '') $filter_name = $this->filter_name; |
726 | 726 | $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"; |
727 | 727 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
728 | - try { |
|
729 | - $sth = $this->db->prepare($query); |
|
730 | - $sth->execute($query_values); |
|
731 | - } catch(PDOException $e) { |
|
732 | - echo "error : ".$e->getMessage(); |
|
733 | - } |
|
734 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
735 | - return $all; |
|
728 | + try { |
|
729 | + $sth = $this->db->prepare($query); |
|
730 | + $sth->execute($query_values); |
|
731 | + } catch(PDOException $e) { |
|
732 | + echo "error : ".$e->getMessage(); |
|
733 | + } |
|
734 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
735 | + return $all; |
|
736 | 736 | } |
737 | 737 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
738 | 738 | if ($filter_name == '') $filter_name = $this->filter_name; |
739 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
740 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
741 | - try { |
|
742 | - $sth = $this->db->prepare($query); |
|
743 | - $sth->execute($query_values); |
|
744 | - } catch(PDOException $e) { |
|
745 | - echo "error : ".$e->getMessage(); |
|
746 | - } |
|
747 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
748 | - return $all; |
|
749 | - } |
|
739 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
740 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
741 | + try { |
|
742 | + $sth = $this->db->prepare($query); |
|
743 | + $sth->execute($query_values); |
|
744 | + } catch(PDOException $e) { |
|
745 | + echo "error : ".$e->getMessage(); |
|
746 | + } |
|
747 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
748 | + return $all; |
|
749 | + } |
|
750 | 750 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
751 | 751 | if ($filter_name == '') $filter_name = $this->filter_name; |
752 | - global $globalArchiveMonths, $globalDBdriver; |
|
753 | - if ($globalDBdriver == 'mysql') { |
|
754 | - $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"; |
|
755 | - } else { |
|
756 | - $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"; |
|
757 | - } |
|
758 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
759 | - try { |
|
760 | - $sth = $this->db->prepare($query); |
|
761 | - $sth->execute($query_values); |
|
762 | - } catch(PDOException $e) { |
|
763 | - echo "error : ".$e->getMessage(); |
|
764 | - } |
|
765 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
766 | - return $all[0]['total']; |
|
767 | - } |
|
752 | + global $globalArchiveMonths, $globalDBdriver; |
|
753 | + if ($globalDBdriver == 'mysql') { |
|
754 | + $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"; |
|
755 | + } else { |
|
756 | + $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"; |
|
757 | + } |
|
758 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
759 | + try { |
|
760 | + $sth = $this->db->prepare($query); |
|
761 | + $sth->execute($query_values); |
|
762 | + } catch(PDOException $e) { |
|
763 | + echo "error : ".$e->getMessage(); |
|
764 | + } |
|
765 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
766 | + return $all[0]['total']; |
|
767 | + } |
|
768 | 768 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
769 | - global $globalArchiveMonths, $globalDBdriver; |
|
769 | + global $globalArchiveMonths, $globalDBdriver; |
|
770 | 770 | if ($filter_name == '') $filter_name = $this->filter_name; |
771 | - if ($globalDBdriver == 'mysql') { |
|
771 | + if ($globalDBdriver == 'mysql') { |
|
772 | 772 | $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"; |
773 | 773 | } else { |
774 | 774 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
775 | - } |
|
776 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
777 | - try { |
|
778 | - $sth = $this->db->prepare($query); |
|
779 | - $sth->execute($query_values); |
|
780 | - } catch(PDOException $e) { |
|
781 | - echo "error : ".$e->getMessage(); |
|
782 | - } |
|
783 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
784 | - return $all[0]['total']; |
|
785 | - } |
|
775 | + } |
|
776 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
777 | + try { |
|
778 | + $sth = $this->db->prepare($query); |
|
779 | + $sth->execute($query_values); |
|
780 | + } catch(PDOException $e) { |
|
781 | + echo "error : ".$e->getMessage(); |
|
782 | + } |
|
783 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
784 | + return $all[0]['total']; |
|
785 | + } |
|
786 | 786 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
787 | - global $globalArchiveMonths, $globalDBdriver; |
|
787 | + global $globalArchiveMonths, $globalDBdriver; |
|
788 | 788 | if ($filter_name == '') $filter_name = $this->filter_name; |
789 | - if ($globalDBdriver == 'mysql') { |
|
789 | + if ($globalDBdriver == 'mysql') { |
|
790 | 790 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
791 | - } else { |
|
791 | + } else { |
|
792 | 792 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
793 | - } |
|
794 | - try { |
|
795 | - $sth = $this->db->prepare($query); |
|
796 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
797 | - } catch(PDOException $e) { |
|
798 | - echo "error : ".$e->getMessage(); |
|
799 | - } |
|
800 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
801 | - return $all[0]['total']; |
|
802 | - } |
|
793 | + } |
|
794 | + try { |
|
795 | + $sth = $this->db->prepare($query); |
|
796 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
797 | + } catch(PDOException $e) { |
|
798 | + echo "error : ".$e->getMessage(); |
|
799 | + } |
|
800 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
801 | + return $all[0]['total']; |
|
802 | + } |
|
803 | 803 | public function getStatsAirlineTotal($filter_name = '') { |
804 | - global $globalArchiveMonths, $globalDBdriver; |
|
804 | + global $globalArchiveMonths, $globalDBdriver; |
|
805 | 805 | if ($filter_name == '') $filter_name = $this->filter_name; |
806 | - if ($globalDBdriver == 'mysql') { |
|
806 | + if ($globalDBdriver == 'mysql') { |
|
807 | 807 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
808 | - } else { |
|
808 | + } else { |
|
809 | 809 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
810 | - } |
|
811 | - try { |
|
812 | - $sth = $this->db->prepare($query); |
|
813 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
814 | - } catch(PDOException $e) { |
|
815 | - echo "error : ".$e->getMessage(); |
|
816 | - } |
|
817 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
818 | - return $all[0]['total']; |
|
819 | - } |
|
810 | + } |
|
811 | + try { |
|
812 | + $sth = $this->db->prepare($query); |
|
813 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
814 | + } catch(PDOException $e) { |
|
815 | + echo "error : ".$e->getMessage(); |
|
816 | + } |
|
817 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
818 | + return $all[0]['total']; |
|
819 | + } |
|
820 | 820 | public function getStatsOwnerTotal($filter_name = '') { |
821 | - global $globalArchiveMonths, $globalDBdriver; |
|
821 | + global $globalArchiveMonths, $globalDBdriver; |
|
822 | 822 | if ($filter_name == '') $filter_name = $this->filter_name; |
823 | - if ($globalDBdriver == 'mysql') { |
|
823 | + if ($globalDBdriver == 'mysql') { |
|
824 | 824 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
825 | 825 | } else { |
826 | 826 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
827 | - } |
|
828 | - try { |
|
829 | - $sth = $this->db->prepare($query); |
|
830 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
831 | - } catch(PDOException $e) { |
|
832 | - echo "error : ".$e->getMessage(); |
|
833 | - } |
|
834 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
835 | - return $all[0]['total']; |
|
836 | - } |
|
827 | + } |
|
828 | + try { |
|
829 | + $sth = $this->db->prepare($query); |
|
830 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
831 | + } catch(PDOException $e) { |
|
832 | + echo "error : ".$e->getMessage(); |
|
833 | + } |
|
834 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
835 | + return $all[0]['total']; |
|
836 | + } |
|
837 | 837 | public function getStatsPilotTotal($filter_name = '') { |
838 | - global $globalArchiveMonths, $globalDBdriver; |
|
838 | + global $globalArchiveMonths, $globalDBdriver; |
|
839 | 839 | if ($filter_name == '') $filter_name = $this->filter_name; |
840 | - if ($globalDBdriver == 'mysql') { |
|
841 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
842 | - } else { |
|
843 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
844 | - } |
|
845 | - try { |
|
846 | - $sth = $this->db->prepare($query); |
|
847 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
848 | - } catch(PDOException $e) { |
|
849 | - echo "error : ".$e->getMessage(); |
|
850 | - } |
|
851 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
852 | - return $all[0]['total']; |
|
853 | - } |
|
840 | + if ($globalDBdriver == 'mysql') { |
|
841 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
842 | + } else { |
|
843 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
844 | + } |
|
845 | + try { |
|
846 | + $sth = $this->db->prepare($query); |
|
847 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
848 | + } catch(PDOException $e) { |
|
849 | + echo "error : ".$e->getMessage(); |
|
850 | + } |
|
851 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
852 | + return $all[0]['total']; |
|
853 | + } |
|
854 | 854 | |
855 | 855 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
856 | 856 | global $globalDBdriver; |
857 | 857 | if ($filter_name == '') $filter_name = $this->filter_name; |
858 | 858 | if ($globalDBdriver == 'mysql') { |
859 | 859 | $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"; |
860 | - } else { |
|
860 | + } else { |
|
861 | 861 | $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);"; |
862 | 862 | } |
863 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
864 | - try { |
|
865 | - $sth = $this->db->prepare($query); |
|
866 | - $sth->execute($query_values); |
|
867 | - } catch(PDOException $e) { |
|
868 | - return "error : ".$e->getMessage(); |
|
869 | - } |
|
870 | - } |
|
863 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
864 | + try { |
|
865 | + $sth = $this->db->prepare($query); |
|
866 | + $sth->execute($query_values); |
|
867 | + } catch(PDOException $e) { |
|
868 | + return "error : ".$e->getMessage(); |
|
869 | + } |
|
870 | + } |
|
871 | 871 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
872 | 872 | global $globalDBdriver; |
873 | 873 | if ($filter_name == '') $filter_name = $this->filter_name; |
874 | 874 | if ($globalDBdriver == 'mysql') { |
875 | 875 | $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"; |
876 | 876 | } else { |
877 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
877 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
878 | 878 | $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);"; |
879 | - } |
|
880 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
881 | - try { |
|
882 | - $sth = $this->db->prepare($query); |
|
883 | - $sth->execute($query_values); |
|
884 | - } catch(PDOException $e) { |
|
885 | - return "error : ".$e->getMessage(); |
|
886 | - } |
|
887 | - } |
|
879 | + } |
|
880 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
881 | + try { |
|
882 | + $sth = $this->db->prepare($query); |
|
883 | + $sth->execute($query_values); |
|
884 | + } catch(PDOException $e) { |
|
885 | + return "error : ".$e->getMessage(); |
|
886 | + } |
|
887 | + } |
|
888 | 888 | public function getStatsSource($date,$stats_type = '') { |
889 | 889 | if ($stats_type == '') { |
890 | 890 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -893,15 +893,15 @@ discard block |
||
893 | 893 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
894 | 894 | $query_values = array(':date' => $date,':stats_type' => $stats_type); |
895 | 895 | } |
896 | - try { |
|
897 | - $sth = $this->db->prepare($query); |
|
898 | - $sth->execute($query_values); |
|
899 | - } catch(PDOException $e) { |
|
900 | - echo "error : ".$e->getMessage(); |
|
901 | - } |
|
902 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
903 | - return $all; |
|
904 | - } |
|
896 | + try { |
|
897 | + $sth = $this->db->prepare($query); |
|
898 | + $sth->execute($query_values); |
|
899 | + } catch(PDOException $e) { |
|
900 | + echo "error : ".$e->getMessage(); |
|
901 | + } |
|
902 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
903 | + return $all; |
|
904 | + } |
|
905 | 905 | |
906 | 906 | public function addStatSource($data,$source_name,$stats_type,$date) { |
907 | 907 | global $globalDBdriver; |
@@ -909,25 +909,25 @@ discard block |
||
909 | 909 | $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"; |
910 | 910 | } else { |
911 | 911 | $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);"; |
912 | - } |
|
913 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
914 | - try { |
|
915 | - $sth = $this->db->prepare($query); |
|
916 | - $sth->execute($query_values); |
|
917 | - } catch(PDOException $e) { |
|
918 | - return "error : ".$e->getMessage(); |
|
919 | - } |
|
920 | - } |
|
912 | + } |
|
913 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
914 | + try { |
|
915 | + $sth = $this->db->prepare($query); |
|
916 | + $sth->execute($query_values); |
|
917 | + } catch(PDOException $e) { |
|
918 | + return "error : ".$e->getMessage(); |
|
919 | + } |
|
920 | + } |
|
921 | 921 | public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
922 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
923 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
924 | - try { |
|
925 | - $sth = $this->db->prepare($query); |
|
926 | - $sth->execute($query_values); |
|
927 | - } catch(PDOException $e) { |
|
928 | - return "error : ".$e->getMessage(); |
|
929 | - } |
|
930 | - } |
|
922 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
923 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
924 | + try { |
|
925 | + $sth = $this->db->prepare($query); |
|
926 | + $sth->execute($query_values); |
|
927 | + } catch(PDOException $e) { |
|
928 | + return "error : ".$e->getMessage(); |
|
929 | + } |
|
930 | + } |
|
931 | 931 | public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
932 | 932 | global $globalDBdriver; |
933 | 933 | if ($globalDBdriver == 'mysql') { |
@@ -935,14 +935,14 @@ discard block |
||
935 | 935 | } else { |
936 | 936 | $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);"; |
937 | 937 | } |
938 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
939 | - try { |
|
940 | - $sth = $this->db->prepare($query); |
|
941 | - $sth->execute($query_values); |
|
942 | - } catch(PDOException $e) { |
|
943 | - return "error : ".$e->getMessage(); |
|
944 | - } |
|
945 | - } |
|
938 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
939 | + try { |
|
940 | + $sth = $this->db->prepare($query); |
|
941 | + $sth->execute($query_values); |
|
942 | + } catch(PDOException $e) { |
|
943 | + return "error : ".$e->getMessage(); |
|
944 | + } |
|
945 | + } |
|
946 | 946 | public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
947 | 947 | global $globalDBdriver; |
948 | 948 | if ($globalDBdriver == 'mysql') { |
@@ -950,14 +950,14 @@ discard block |
||
950 | 950 | } else { |
951 | 951 | $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);"; |
952 | 952 | } |
953 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
954 | - try { |
|
955 | - $sth = $this->db->prepare($query); |
|
956 | - $sth->execute($query_values); |
|
957 | - } catch(PDOException $e) { |
|
958 | - return "error : ".$e->getMessage(); |
|
959 | - } |
|
960 | - } |
|
953 | + $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
954 | + try { |
|
955 | + $sth = $this->db->prepare($query); |
|
956 | + $sth->execute($query_values); |
|
957 | + } catch(PDOException $e) { |
|
958 | + return "error : ".$e->getMessage(); |
|
959 | + } |
|
960 | + } |
|
961 | 961 | public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
962 | 962 | global $globalDBdriver; |
963 | 963 | if ($globalDBdriver == 'mysql') { |
@@ -965,14 +965,14 @@ discard block |
||
965 | 965 | } else { |
966 | 966 | $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);"; |
967 | 967 | } |
968 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
969 | - try { |
|
970 | - $sth = $this->db->prepare($query); |
|
971 | - $sth->execute($query_values); |
|
972 | - } catch(PDOException $e) { |
|
973 | - return "error : ".$e->getMessage(); |
|
974 | - } |
|
975 | - } |
|
968 | + $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
969 | + try { |
|
970 | + $sth = $this->db->prepare($query); |
|
971 | + $sth->execute($query_values); |
|
972 | + } catch(PDOException $e) { |
|
973 | + return "error : ".$e->getMessage(); |
|
974 | + } |
|
975 | + } |
|
976 | 976 | public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
977 | 977 | global $globalDBdriver; |
978 | 978 | if ($globalDBdriver == 'mysql') { |
@@ -980,14 +980,14 @@ discard block |
||
980 | 980 | } else { |
981 | 981 | $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);"; |
982 | 982 | } |
983 | - $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); |
|
984 | - try { |
|
985 | - $sth = $this->db->prepare($query); |
|
986 | - $sth->execute($query_values); |
|
987 | - } catch(PDOException $e) { |
|
988 | - return "error : ".$e->getMessage(); |
|
989 | - } |
|
990 | - } |
|
983 | + $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); |
|
984 | + try { |
|
985 | + $sth = $this->db->prepare($query); |
|
986 | + $sth->execute($query_values); |
|
987 | + } catch(PDOException $e) { |
|
988 | + return "error : ".$e->getMessage(); |
|
989 | + } |
|
990 | + } |
|
991 | 991 | public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
992 | 992 | global $globalDBdriver; |
993 | 993 | if ($globalDBdriver == 'mysql') { |
@@ -995,14 +995,14 @@ discard block |
||
995 | 995 | } else { |
996 | 996 | $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);"; |
997 | 997 | } |
998 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
999 | - try { |
|
1000 | - $sth = $this->db->prepare($query); |
|
1001 | - $sth->execute($query_values); |
|
1002 | - } catch(PDOException $e) { |
|
1003 | - return "error : ".$e->getMessage(); |
|
1004 | - } |
|
1005 | - } |
|
998 | + $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
999 | + try { |
|
1000 | + $sth = $this->db->prepare($query); |
|
1001 | + $sth->execute($query_values); |
|
1002 | + } catch(PDOException $e) { |
|
1003 | + return "error : ".$e->getMessage(); |
|
1004 | + } |
|
1005 | + } |
|
1006 | 1006 | public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
1007 | 1007 | global $globalDBdriver; |
1008 | 1008 | if ($globalDBdriver == 'mysql') { |
@@ -1010,14 +1010,14 @@ discard block |
||
1010 | 1010 | } else { |
1011 | 1011 | $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);"; |
1012 | 1012 | } |
1013 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1014 | - try { |
|
1015 | - $sth = $this->db->prepare($query); |
|
1016 | - $sth->execute($query_values); |
|
1017 | - } catch(PDOException $e) { |
|
1018 | - return "error : ".$e->getMessage(); |
|
1019 | - } |
|
1020 | - } |
|
1013 | + $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1014 | + try { |
|
1015 | + $sth = $this->db->prepare($query); |
|
1016 | + $sth->execute($query_values); |
|
1017 | + } catch(PDOException $e) { |
|
1018 | + return "error : ".$e->getMessage(); |
|
1019 | + } |
|
1020 | + } |
|
1021 | 1021 | public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '') { |
1022 | 1022 | global $globalDBdriver; |
1023 | 1023 | if ($globalDBdriver == 'mysql') { |
@@ -1025,14 +1025,14 @@ discard block |
||
1025 | 1025 | } else { |
1026 | 1026 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1027 | 1027 | } |
1028 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1029 | - try { |
|
1030 | - $sth = $this->db->prepare($query); |
|
1031 | - $sth->execute($query_values); |
|
1032 | - } catch(PDOException $e) { |
|
1033 | - return "error : ".$e->getMessage(); |
|
1034 | - } |
|
1035 | - } |
|
1028 | + $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1029 | + try { |
|
1030 | + $sth = $this->db->prepare($query); |
|
1031 | + $sth->execute($query_values); |
|
1032 | + } catch(PDOException $e) { |
|
1033 | + return "error : ".$e->getMessage(); |
|
1034 | + } |
|
1035 | + } |
|
1036 | 1036 | public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1037 | 1037 | global $globalDBdriver; |
1038 | 1038 | if ($globalDBdriver == 'mysql') { |
@@ -1040,14 +1040,14 @@ discard block |
||
1040 | 1040 | } else { |
1041 | 1041 | $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);"; |
1042 | 1042 | } |
1043 | - $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); |
|
1044 | - try { |
|
1045 | - $sth = $this->db->prepare($query); |
|
1046 | - $sth->execute($query_values); |
|
1047 | - } catch(PDOException $e) { |
|
1048 | - return "error : ".$e->getMessage(); |
|
1049 | - } |
|
1050 | - } |
|
1043 | + $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); |
|
1044 | + try { |
|
1045 | + $sth = $this->db->prepare($query); |
|
1046 | + $sth->execute($query_values); |
|
1047 | + } catch(PDOException $e) { |
|
1048 | + return "error : ".$e->getMessage(); |
|
1049 | + } |
|
1050 | + } |
|
1051 | 1051 | public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1052 | 1052 | global $globalDBdriver; |
1053 | 1053 | if ($globalDBdriver == 'mysql') { |
@@ -1055,14 +1055,14 @@ discard block |
||
1055 | 1055 | } else { |
1056 | 1056 | $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);"; |
1057 | 1057 | } |
1058 | - $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); |
|
1059 | - try { |
|
1060 | - $sth = $this->db->prepare($query); |
|
1061 | - $sth->execute($query_values); |
|
1062 | - } catch(PDOException $e) { |
|
1063 | - return "error : ".$e->getMessage(); |
|
1064 | - } |
|
1065 | - } |
|
1058 | + $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); |
|
1059 | + try { |
|
1060 | + $sth = $this->db->prepare($query); |
|
1061 | + $sth->execute($query_values); |
|
1062 | + } catch(PDOException $e) { |
|
1063 | + return "error : ".$e->getMessage(); |
|
1064 | + } |
|
1065 | + } |
|
1066 | 1066 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1067 | 1067 | global $globalDBdriver; |
1068 | 1068 | if ($globalDBdriver == 'mysql') { |
@@ -1070,14 +1070,14 @@ discard block |
||
1070 | 1070 | } else { |
1071 | 1071 | $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);"; |
1072 | 1072 | } |
1073 | - $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); |
|
1074 | - try { |
|
1075 | - $sth = $this->db->prepare($query); |
|
1076 | - $sth->execute($query_values); |
|
1077 | - } catch(PDOException $e) { |
|
1078 | - return "error : ".$e->getMessage(); |
|
1079 | - } |
|
1080 | - } |
|
1073 | + $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); |
|
1074 | + try { |
|
1075 | + $sth = $this->db->prepare($query); |
|
1076 | + $sth->execute($query_values); |
|
1077 | + } catch(PDOException $e) { |
|
1078 | + return "error : ".$e->getMessage(); |
|
1079 | + } |
|
1080 | + } |
|
1081 | 1081 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1082 | 1082 | global $globalDBdriver; |
1083 | 1083 | if ($globalDBdriver == 'mysql') { |
@@ -1085,52 +1085,52 @@ discard block |
||
1085 | 1085 | } else { |
1086 | 1086 | $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);"; |
1087 | 1087 | } |
1088 | - $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); |
|
1089 | - try { |
|
1090 | - $sth = $this->db->prepare($query); |
|
1091 | - $sth->execute($query_values); |
|
1092 | - } catch(PDOException $e) { |
|
1093 | - return "error : ".$e->getMessage(); |
|
1094 | - } |
|
1095 | - } |
|
1088 | + $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); |
|
1089 | + try { |
|
1090 | + $sth = $this->db->prepare($query); |
|
1091 | + $sth->execute($query_values); |
|
1092 | + } catch(PDOException $e) { |
|
1093 | + return "error : ".$e->getMessage(); |
|
1094 | + } |
|
1095 | + } |
|
1096 | 1096 | |
1097 | 1097 | public function deleteStat($id) { |
1098 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1099 | - $query_values = array(':id' => $id); |
|
1100 | - try { |
|
1101 | - $sth = $this->db->prepare($query); |
|
1102 | - $sth->execute($query_values); |
|
1103 | - } catch(PDOException $e) { |
|
1104 | - return "error : ".$e->getMessage(); |
|
1105 | - } |
|
1106 | - } |
|
1098 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1099 | + $query_values = array(':id' => $id); |
|
1100 | + try { |
|
1101 | + $sth = $this->db->prepare($query); |
|
1102 | + $sth->execute($query_values); |
|
1103 | + } catch(PDOException $e) { |
|
1104 | + return "error : ".$e->getMessage(); |
|
1105 | + } |
|
1106 | + } |
|
1107 | 1107 | public function deleteStatFlight($type) { |
1108 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1109 | - $query_values = array(':type' => $type); |
|
1110 | - try { |
|
1111 | - $sth = $this->db->prepare($query); |
|
1112 | - $sth->execute($query_values); |
|
1113 | - } catch(PDOException $e) { |
|
1114 | - return "error : ".$e->getMessage(); |
|
1115 | - } |
|
1116 | - } |
|
1108 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1109 | + $query_values = array(':type' => $type); |
|
1110 | + try { |
|
1111 | + $sth = $this->db->prepare($query); |
|
1112 | + $sth->execute($query_values); |
|
1113 | + } catch(PDOException $e) { |
|
1114 | + return "error : ".$e->getMessage(); |
|
1115 | + } |
|
1116 | + } |
|
1117 | 1117 | public function deleteStatAirport($type) { |
1118 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1119 | - $query_values = array(':type' => $type); |
|
1120 | - try { |
|
1121 | - $sth = $this->db->prepare($query); |
|
1122 | - $sth->execute($query_values); |
|
1123 | - } catch(PDOException $e) { |
|
1124 | - return "error : ".$e->getMessage(); |
|
1125 | - } |
|
1126 | - } |
|
1118 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1119 | + $query_values = array(':type' => $type); |
|
1120 | + try { |
|
1121 | + $sth = $this->db->prepare($query); |
|
1122 | + $sth->execute($query_values); |
|
1123 | + } catch(PDOException $e) { |
|
1124 | + return "error : ".$e->getMessage(); |
|
1125 | + } |
|
1126 | + } |
|
1127 | 1127 | |
1128 | - public function addOldStats() { |
|
1129 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters; |
|
1130 | - $Common = new Common(); |
|
1131 | - $Connection = new Connection(); |
|
1132 | - date_default_timezone_set('UTC'); |
|
1133 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1128 | + public function addOldStats() { |
|
1129 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters; |
|
1130 | + $Common = new Common(); |
|
1131 | + $Connection = new Connection(); |
|
1132 | + date_default_timezone_set('UTC'); |
|
1133 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1134 | 1134 | //print_r($last_update); |
1135 | 1135 | /* |
1136 | 1136 | $flightsbymonth = $this->getStats('flights_by_month'); |
@@ -1392,24 +1392,24 @@ discard block |
||
1392 | 1392 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1393 | 1393 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1394 | 1394 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1395 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1395 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1396 | 1396 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1397 | - $alldata = array(); |
|
1397 | + $alldata = array(); |
|
1398 | 1398 | |
1399 | - foreach ($pall as $value) { |
|
1400 | - $icao = $value['airport_departure_icao']; |
|
1401 | - $alldata[$icao] = $value; |
|
1402 | - } |
|
1403 | - foreach ($dall as $value) { |
|
1404 | - $icao = $value['airport_departure_icao']; |
|
1405 | - if (isset($alldata[$icao])) { |
|
1406 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1407 | - } else $alldata[$icao] = $value; |
|
1408 | - } |
|
1409 | - $count = array(); |
|
1410 | - foreach ($alldata as $key => $row) { |
|
1411 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1412 | - } |
|
1399 | + foreach ($pall as $value) { |
|
1400 | + $icao = $value['airport_departure_icao']; |
|
1401 | + $alldata[$icao] = $value; |
|
1402 | + } |
|
1403 | + foreach ($dall as $value) { |
|
1404 | + $icao = $value['airport_departure_icao']; |
|
1405 | + if (isset($alldata[$icao])) { |
|
1406 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1407 | + } else $alldata[$icao] = $value; |
|
1408 | + } |
|
1409 | + $count = array(); |
|
1410 | + foreach ($alldata as $key => $row) { |
|
1411 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1412 | + } |
|
1413 | 1413 | array_multisort($count,SORT_DESC,$alldata); |
1414 | 1414 | foreach ($alldata as $number) { |
1415 | 1415 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
@@ -1417,25 +1417,25 @@ discard block |
||
1417 | 1417 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1418 | 1418 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1419 | 1419 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1420 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1420 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1421 | 1421 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1422 | - $alldata = array(); |
|
1423 | - foreach ($pall as $value) { |
|
1424 | - $icao = $value['airport_arrival_icao']; |
|
1425 | - $alldata[$icao] = $value; |
|
1426 | - } |
|
1427 | - foreach ($dall as $value) { |
|
1428 | - $icao = $value['airport_arrival_icao']; |
|
1429 | - if (isset($alldata[$icao])) { |
|
1430 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1431 | - } else $alldata[$icao] = $value; |
|
1432 | - } |
|
1433 | - $count = array(); |
|
1434 | - foreach ($alldata as $key => $row) { |
|
1435 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1436 | - } |
|
1437 | - array_multisort($count,SORT_DESC,$alldata); |
|
1438 | - foreach ($alldata as $number) { |
|
1422 | + $alldata = array(); |
|
1423 | + foreach ($pall as $value) { |
|
1424 | + $icao = $value['airport_arrival_icao']; |
|
1425 | + $alldata[$icao] = $value; |
|
1426 | + } |
|
1427 | + foreach ($dall as $value) { |
|
1428 | + $icao = $value['airport_arrival_icao']; |
|
1429 | + if (isset($alldata[$icao])) { |
|
1430 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1431 | + } else $alldata[$icao] = $value; |
|
1432 | + } |
|
1433 | + $count = array(); |
|
1434 | + foreach ($alldata as $key => $row) { |
|
1435 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1436 | + } |
|
1437 | + array_multisort($count,SORT_DESC,$alldata); |
|
1438 | + foreach ($alldata as $number) { |
|
1439 | 1439 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1440 | 1440 | } |
1441 | 1441 | if ($Connection->tableExists('countries')) { |
@@ -1495,8 +1495,8 @@ discard block |
||
1495 | 1495 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1496 | 1496 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
1497 | 1497 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1498 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1499 | - /* |
|
1498 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1499 | + /* |
|
1500 | 1500 | $alldata = array(); |
1501 | 1501 | foreach ($pall as $value) { |
1502 | 1502 | $icao = $value['departure_airport_icao']; |
@@ -1515,29 +1515,29 @@ discard block |
||
1515 | 1515 | } |
1516 | 1516 | array_multisort($count,SORT_DESC,$alldata); |
1517 | 1517 | */ |
1518 | - foreach ($dall as $value) { |
|
1519 | - $icao = $value['departure_airport_icao']; |
|
1520 | - $ddate = $value['date']; |
|
1521 | - $find = false; |
|
1522 | - foreach ($pall as $pvalue) { |
|
1523 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1524 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1525 | - $find = true; |
|
1526 | - break; |
|
1527 | - } |
|
1528 | - } |
|
1529 | - if ($find === false) { |
|
1530 | - $pall[] = $value; |
|
1531 | - } |
|
1532 | - } |
|
1533 | - $alldata = $pall; |
|
1518 | + foreach ($dall as $value) { |
|
1519 | + $icao = $value['departure_airport_icao']; |
|
1520 | + $ddate = $value['date']; |
|
1521 | + $find = false; |
|
1522 | + foreach ($pall as $pvalue) { |
|
1523 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1524 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1525 | + $find = true; |
|
1526 | + break; |
|
1527 | + } |
|
1528 | + } |
|
1529 | + if ($find === false) { |
|
1530 | + $pall[] = $value; |
|
1531 | + } |
|
1532 | + } |
|
1533 | + $alldata = $pall; |
|
1534 | 1534 | foreach ($alldata as $number) { |
1535 | 1535 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
1536 | 1536 | } |
1537 | 1537 | echo '...Arrival'."\n"; |
1538 | 1538 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
1539 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1540 | - /* |
|
1539 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1540 | + /* |
|
1541 | 1541 | $alldata = array(); |
1542 | 1542 | foreach ($pall as $value) { |
1543 | 1543 | $icao = $value['arrival_airport_icao']; |
@@ -1557,22 +1557,22 @@ discard block |
||
1557 | 1557 | */ |
1558 | 1558 | |
1559 | 1559 | |
1560 | - foreach ($dall as $value) { |
|
1561 | - $icao = $value['arrival_airport_icao']; |
|
1562 | - $ddate = $value['date']; |
|
1563 | - $find = false; |
|
1564 | - foreach ($pall as $pvalue) { |
|
1565 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1566 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1567 | - $find = true; |
|
1568 | - break; |
|
1569 | - } |
|
1570 | - } |
|
1571 | - if ($find === false) { |
|
1572 | - $pall[] = $value; |
|
1573 | - } |
|
1574 | - } |
|
1575 | - $alldata = $pall; |
|
1560 | + foreach ($dall as $value) { |
|
1561 | + $icao = $value['arrival_airport_icao']; |
|
1562 | + $ddate = $value['date']; |
|
1563 | + $find = false; |
|
1564 | + foreach ($pall as $pvalue) { |
|
1565 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1566 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1567 | + $find = true; |
|
1568 | + break; |
|
1569 | + } |
|
1570 | + } |
|
1571 | + if ($find === false) { |
|
1572 | + $pall[] = $value; |
|
1573 | + } |
|
1574 | + } |
|
1575 | + $alldata = $pall; |
|
1576 | 1576 | foreach ($alldata as $number) { |
1577 | 1577 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
1578 | 1578 | } |
@@ -1639,51 +1639,51 @@ discard block |
||
1639 | 1639 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1640 | 1640 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1641 | 1641 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1642 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1642 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1643 | 1643 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1644 | - //$alldata = array(); |
|
1645 | - foreach ($dall as $value) { |
|
1646 | - $icao = $value['airport_departure_icao']; |
|
1647 | - $dicao = $value['airline_icao']; |
|
1648 | - $find = false; |
|
1649 | - foreach ($pall as $pvalue) { |
|
1650 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1651 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1652 | - $find = true; |
|
1653 | - break; |
|
1654 | - } |
|
1655 | - } |
|
1656 | - if ($find === false) { |
|
1657 | - $pall[] = $value; |
|
1658 | - } |
|
1659 | - } |
|
1660 | - $alldata = $pall; |
|
1644 | + //$alldata = array(); |
|
1645 | + foreach ($dall as $value) { |
|
1646 | + $icao = $value['airport_departure_icao']; |
|
1647 | + $dicao = $value['airline_icao']; |
|
1648 | + $find = false; |
|
1649 | + foreach ($pall as $pvalue) { |
|
1650 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1651 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1652 | + $find = true; |
|
1653 | + break; |
|
1654 | + } |
|
1655 | + } |
|
1656 | + if ($find === false) { |
|
1657 | + $pall[] = $value; |
|
1658 | + } |
|
1659 | + } |
|
1660 | + $alldata = $pall; |
|
1661 | 1661 | foreach ($alldata as $number) { |
1662 | 1662 | 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']); |
1663 | 1663 | } |
1664 | 1664 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1665 | 1665 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1666 | 1666 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1667 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1667 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1668 | 1668 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1669 | - //$alldata = array(); |
|
1670 | - foreach ($dall as $value) { |
|
1671 | - $icao = $value['airport_arrival_icao']; |
|
1672 | - $dicao = $value['airline_icao']; |
|
1673 | - $find = false; |
|
1674 | - foreach ($pall as $pvalue) { |
|
1675 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1676 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1677 | - $find = true; |
|
1678 | - break; |
|
1679 | - } |
|
1680 | - } |
|
1681 | - if ($find === false) { |
|
1682 | - $pall[] = $value; |
|
1683 | - } |
|
1684 | - } |
|
1685 | - $alldata = $pall; |
|
1686 | - foreach ($alldata as $number) { |
|
1669 | + //$alldata = array(); |
|
1670 | + foreach ($dall as $value) { |
|
1671 | + $icao = $value['airport_arrival_icao']; |
|
1672 | + $dicao = $value['airline_icao']; |
|
1673 | + $find = false; |
|
1674 | + foreach ($pall as $pvalue) { |
|
1675 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1676 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1677 | + $find = true; |
|
1678 | + break; |
|
1679 | + } |
|
1680 | + } |
|
1681 | + if ($find === false) { |
|
1682 | + $pall[] = $value; |
|
1683 | + } |
|
1684 | + } |
|
1685 | + $alldata = $pall; |
|
1686 | + foreach ($alldata as $number) { |
|
1687 | 1687 | 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']); |
1688 | 1688 | } |
1689 | 1689 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
@@ -1716,47 +1716,47 @@ discard block |
||
1716 | 1716 | } |
1717 | 1717 | if ($globalDebug) echo '...Departure'."\n"; |
1718 | 1718 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1719 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1720 | - foreach ($dall as $value) { |
|
1721 | - $icao = $value['departure_airport_icao']; |
|
1722 | - $airline = $value['airline_icao']; |
|
1723 | - $ddate = $value['date']; |
|
1724 | - $find = false; |
|
1725 | - foreach ($pall as $pvalue) { |
|
1726 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1727 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1728 | - $find = true; |
|
1729 | - break; |
|
1730 | - } |
|
1731 | - } |
|
1732 | - if ($find === false) { |
|
1733 | - $pall[] = $value; |
|
1734 | - } |
|
1735 | - } |
|
1736 | - $alldata = $pall; |
|
1719 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1720 | + foreach ($dall as $value) { |
|
1721 | + $icao = $value['departure_airport_icao']; |
|
1722 | + $airline = $value['airline_icao']; |
|
1723 | + $ddate = $value['date']; |
|
1724 | + $find = false; |
|
1725 | + foreach ($pall as $pvalue) { |
|
1726 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1727 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1728 | + $find = true; |
|
1729 | + break; |
|
1730 | + } |
|
1731 | + } |
|
1732 | + if ($find === false) { |
|
1733 | + $pall[] = $value; |
|
1734 | + } |
|
1735 | + } |
|
1736 | + $alldata = $pall; |
|
1737 | 1737 | foreach ($alldata as $number) { |
1738 | 1738 | $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']); |
1739 | 1739 | } |
1740 | 1740 | if ($globalDebug) echo '...Arrival'."\n"; |
1741 | 1741 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1742 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1743 | - foreach ($dall as $value) { |
|
1744 | - $icao = $value['arrival_airport_icao']; |
|
1745 | - $airline = $value['airline_icao']; |
|
1746 | - $ddate = $value['date']; |
|
1747 | - $find = false; |
|
1748 | - foreach ($pall as $pvalue) { |
|
1749 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1750 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1751 | - $find = true; |
|
1752 | - break; |
|
1753 | - } |
|
1754 | - } |
|
1755 | - if ($find === false) { |
|
1756 | - $pall[] = $value; |
|
1757 | - } |
|
1758 | - } |
|
1759 | - $alldata = $pall; |
|
1742 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1743 | + foreach ($dall as $value) { |
|
1744 | + $icao = $value['arrival_airport_icao']; |
|
1745 | + $airline = $value['airline_icao']; |
|
1746 | + $ddate = $value['date']; |
|
1747 | + $find = false; |
|
1748 | + foreach ($pall as $pvalue) { |
|
1749 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1750 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1751 | + $find = true; |
|
1752 | + break; |
|
1753 | + } |
|
1754 | + } |
|
1755 | + if ($find === false) { |
|
1756 | + $pall[] = $value; |
|
1757 | + } |
|
1758 | + } |
|
1759 | + $alldata = $pall; |
|
1760 | 1760 | foreach ($alldata as $number) { |
1761 | 1761 | $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']); |
1762 | 1762 | } |
@@ -1820,44 +1820,44 @@ discard block |
||
1820 | 1820 | } |
1821 | 1821 | |
1822 | 1822 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
1823 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1824 | - $alldata = array(); |
|
1825 | - foreach ($pall as $value) { |
|
1826 | - $icao = $value['airport_departure_icao']; |
|
1827 | - $alldata[$icao] = $value; |
|
1828 | - } |
|
1829 | - foreach ($dall as $value) { |
|
1830 | - $icao = $value['airport_departure_icao']; |
|
1831 | - if (isset($alldata[$icao])) { |
|
1832 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1833 | - } else $alldata[$icao] = $value; |
|
1834 | - } |
|
1835 | - $count = array(); |
|
1836 | - foreach ($alldata as $key => $row) { |
|
1837 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1838 | - } |
|
1823 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1824 | + $alldata = array(); |
|
1825 | + foreach ($pall as $value) { |
|
1826 | + $icao = $value['airport_departure_icao']; |
|
1827 | + $alldata[$icao] = $value; |
|
1828 | + } |
|
1829 | + foreach ($dall as $value) { |
|
1830 | + $icao = $value['airport_departure_icao']; |
|
1831 | + if (isset($alldata[$icao])) { |
|
1832 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1833 | + } else $alldata[$icao] = $value; |
|
1834 | + } |
|
1835 | + $count = array(); |
|
1836 | + foreach ($alldata as $key => $row) { |
|
1837 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1838 | + } |
|
1839 | 1839 | array_multisort($count,SORT_DESC,$alldata); |
1840 | 1840 | foreach ($alldata as $number) { |
1841 | - 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); |
|
1841 | + 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); |
|
1842 | 1842 | } |
1843 | 1843 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter); |
1844 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1844 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1845 | 1845 | $alldata = array(); |
1846 | - foreach ($pall as $value) { |
|
1847 | - $icao = $value['airport_arrival_icao']; |
|
1848 | - $alldata[$icao] = $value; |
|
1849 | - } |
|
1850 | - foreach ($dall as $value) { |
|
1851 | - $icao = $value['airport_arrival_icao']; |
|
1852 | - if (isset($alldata[$icao])) { |
|
1853 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1854 | - } else $alldata[$icao] = $value; |
|
1855 | - } |
|
1856 | - $count = array(); |
|
1857 | - foreach ($alldata as $key => $row) { |
|
1858 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1859 | - } |
|
1860 | - array_multisort($count,SORT_DESC,$alldata); |
|
1846 | + foreach ($pall as $value) { |
|
1847 | + $icao = $value['airport_arrival_icao']; |
|
1848 | + $alldata[$icao] = $value; |
|
1849 | + } |
|
1850 | + foreach ($dall as $value) { |
|
1851 | + $icao = $value['airport_arrival_icao']; |
|
1852 | + if (isset($alldata[$icao])) { |
|
1853 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1854 | + } else $alldata[$icao] = $value; |
|
1855 | + } |
|
1856 | + $count = array(); |
|
1857 | + foreach ($alldata as $key => $row) { |
|
1858 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1859 | + } |
|
1860 | + array_multisort($count,SORT_DESC,$alldata); |
|
1861 | 1861 | foreach ($alldata as $number) { |
1862 | 1862 | 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); |
1863 | 1863 | } |
@@ -1886,45 +1886,45 @@ discard block |
||
1886 | 1886 | } |
1887 | 1887 | echo '...Departure'."\n"; |
1888 | 1888 | $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
1889 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1889 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1890 | 1890 | foreach ($dall as $value) { |
1891 | - $icao = $value['departure_airport_icao']; |
|
1892 | - $ddate = $value['date']; |
|
1893 | - $find = false; |
|
1894 | - foreach ($pall as $pvalue) { |
|
1895 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1896 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1897 | - $find = true; |
|
1898 | - break; |
|
1899 | - } |
|
1900 | - } |
|
1901 | - if ($find === false) { |
|
1902 | - $pall[] = $value; |
|
1903 | - } |
|
1904 | - } |
|
1905 | - $alldata = $pall; |
|
1891 | + $icao = $value['departure_airport_icao']; |
|
1892 | + $ddate = $value['date']; |
|
1893 | + $find = false; |
|
1894 | + foreach ($pall as $pvalue) { |
|
1895 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1896 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1897 | + $find = true; |
|
1898 | + break; |
|
1899 | + } |
|
1900 | + } |
|
1901 | + if ($find === false) { |
|
1902 | + $pall[] = $value; |
|
1903 | + } |
|
1904 | + } |
|
1905 | + $alldata = $pall; |
|
1906 | 1906 | foreach ($alldata as $number) { |
1907 | 1907 | $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); |
1908 | 1908 | } |
1909 | 1909 | echo '...Arrival'."\n"; |
1910 | 1910 | $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
1911 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1911 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1912 | 1912 | foreach ($dall as $value) { |
1913 | 1913 | $icao = $value['arrival_airport_icao']; |
1914 | 1914 | $ddate = $value['date']; |
1915 | - $find = false; |
|
1915 | + $find = false; |
|
1916 | 1916 | foreach ($pall as $pvalue) { |
1917 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1918 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1919 | - $find = true; |
|
1920 | - break; |
|
1921 | - } |
|
1922 | - } |
|
1923 | - if ($find === false) { |
|
1924 | - $pall[] = $value; |
|
1925 | - } |
|
1926 | - } |
|
1927 | - $alldata = $pall; |
|
1917 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1918 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1919 | + $find = true; |
|
1920 | + break; |
|
1921 | + } |
|
1922 | + } |
|
1923 | + if ($find === false) { |
|
1924 | + $pall[] = $value; |
|
1925 | + } |
|
1926 | + } |
|
1927 | + $alldata = $pall; |
|
1928 | 1928 | foreach ($alldata as $number) { |
1929 | 1929 | $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); |
1930 | 1930 | } |
@@ -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,31 +46,31 @@ 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 getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
67 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
68 | 68 | if ($filter_name == '') $filter_name = $this->filter_name; |
69 | 69 | $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"; |
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); |
@@ -85,22 +85,22 @@ discard block |
||
85 | 85 | 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"; |
86 | 86 | try { |
87 | 87 | $sth = $this->db->prepare($query); |
88 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
89 | - } catch(PDOException $e) { |
|
88 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
89 | + } catch (PDOException $e) { |
|
90 | 90 | echo "error : ".$e->getMessage(); |
91 | 91 | } |
92 | 92 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
93 | 93 | if (empty($all)) { |
94 | 94 | $filters = array('airlines' => array($stats_airline)); |
95 | 95 | if ($filter_name != '') { |
96 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
96 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
97 | 97 | } |
98 | 98 | $Spotter = new Spotter($this->db); |
99 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
99 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
100 | 100 | } |
101 | 101 | return $all; |
102 | 102 | } |
103 | - public function countAllAirlineCountries($limit = true,$filter_name = '') { |
|
103 | + public function countAllAirlineCountries($limit = true, $filter_name = '') { |
|
104 | 104 | global $globalStatsFilters; |
105 | 105 | if ($filter_name == '') $filter_name = $this->filter_name; |
106 | 106 | 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"; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | try { |
109 | 109 | $sth = $this->db->prepare($query); |
110 | 110 | $sth->execute(array(':filter_name' => $filter_name)); |
111 | - } catch(PDOException $e) { |
|
111 | + } catch (PDOException $e) { |
|
112 | 112 | echo "error : ".$e->getMessage(); |
113 | 113 | } |
114 | 114 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -116,28 +116,28 @@ discard block |
||
116 | 116 | $Spotter = new Spotter($this->db); |
117 | 117 | $filters = array(); |
118 | 118 | if ($filter_name != '') { |
119 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
119 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
120 | 120 | } |
121 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
121 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
122 | 122 | } |
123 | 123 | return $all; |
124 | 124 | } |
125 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
|
125 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '') { |
|
126 | 126 | global $globalStatsFilters; |
127 | 127 | if ($filter_name == '') $filter_name = $this->filter_name; |
128 | 128 | 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"; |
129 | 129 | 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"; |
130 | 130 | try { |
131 | 131 | $sth = $this->db->prepare($query); |
132 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
133 | - } catch(PDOException $e) { |
|
132 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
133 | + } catch (PDOException $e) { |
|
134 | 134 | echo "error : ".$e->getMessage(); |
135 | 135 | } |
136 | 136 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
137 | 137 | if (empty($all)) { |
138 | 138 | $filters = array('airlines' => array($stats_airline)); |
139 | 139 | if ($filter_name != '') { |
140 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
140 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
141 | 141 | } |
142 | 142 | $Spotter = new Spotter($this->db); |
143 | 143 | $all = $Spotter->countAllAircraftManufacturers($filters); |
@@ -152,18 +152,18 @@ discard block |
||
152 | 152 | 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"; |
153 | 153 | try { |
154 | 154 | $sth = $this->db->prepare($query); |
155 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
156 | - } catch(PDOException $e) { |
|
155 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
156 | + } catch (PDOException $e) { |
|
157 | 157 | echo "error : ".$e->getMessage(); |
158 | 158 | } |
159 | 159 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
160 | 160 | if (empty($all)) { |
161 | 161 | $filters = array('airlines' => array($stats_airline)); |
162 | 162 | if ($filter_name != '') { |
163 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
163 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
164 | 164 | } |
165 | 165 | $Spotter = new Spotter($this->db); |
166 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
166 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
167 | 167 | } |
168 | 168 | return $all; |
169 | 169 | } |
@@ -174,15 +174,15 @@ discard block |
||
174 | 174 | 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"; |
175 | 175 | try { |
176 | 176 | $sth = $this->db->prepare($query); |
177 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
178 | - } catch(PDOException $e) { |
|
177 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
178 | + } catch (PDOException $e) { |
|
179 | 179 | echo "error : ".$e->getMessage(); |
180 | 180 | } |
181 | 181 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
182 | 182 | if (empty($all)) { |
183 | 183 | $filters = array('airlines' => array($stats_airline)); |
184 | 184 | if ($filter_name != '') { |
185 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
185 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
186 | 186 | } |
187 | 187 | $Spotter = new Spotter($this->db); |
188 | 188 | $all = $Spotter->countAllDepartureCountries($filters); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return $all; |
191 | 191 | } |
192 | 192 | |
193 | - public function countAllAirlines($limit = true,$filter_name = '') { |
|
193 | + public function countAllAirlines($limit = true, $filter_name = '') { |
|
194 | 194 | global $globalStatsFilters; |
195 | 195 | if ($filter_name == '') $filter_name = $this->filter_name; |
196 | 196 | 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"; |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | try { |
199 | 199 | $sth = $this->db->prepare($query); |
200 | 200 | $sth->execute(array(':filter_name' => $filter_name)); |
201 | - } catch(PDOException $e) { |
|
201 | + } catch (PDOException $e) { |
|
202 | 202 | echo "error : ".$e->getMessage(); |
203 | 203 | } |
204 | 204 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -206,58 +206,58 @@ discard block |
||
206 | 206 | $Spotter = new Spotter($this->db); |
207 | 207 | $filters = array(); |
208 | 208 | if ($filter_name != '') { |
209 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
209 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
210 | 210 | } |
211 | 211 | |
212 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
212 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
213 | 213 | } |
214 | 214 | return $all; |
215 | 215 | } |
216 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
|
216 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '') { |
|
217 | 217 | global $globalStatsFilters; |
218 | 218 | if ($filter_name == '') $filter_name = $this->filter_name; |
219 | 219 | 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"; |
220 | 220 | 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"; |
221 | 221 | try { |
222 | 222 | $sth = $this->db->prepare($query); |
223 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
224 | - } catch(PDOException $e) { |
|
223 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
224 | + } catch (PDOException $e) { |
|
225 | 225 | echo "error : ".$e->getMessage(); |
226 | 226 | } |
227 | 227 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
228 | 228 | if (empty($all)) { |
229 | 229 | $filters = array('airlines' => array($stats_airline)); |
230 | 230 | if ($filter_name != '') { |
231 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
231 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
232 | 232 | } |
233 | 233 | $Spotter = new Spotter($this->db); |
234 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
234 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
235 | 235 | } |
236 | 236 | return $all; |
237 | 237 | } |
238 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
|
238 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '') { |
|
239 | 239 | global $globalStatsFilters; |
240 | 240 | if ($filter_name == '') $filter_name = $this->filter_name; |
241 | 241 | 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"; |
242 | 242 | 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"; |
243 | 243 | try { |
244 | 244 | $sth = $this->db->prepare($query); |
245 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
246 | - } catch(PDOException $e) { |
|
245 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
246 | + } catch (PDOException $e) { |
|
247 | 247 | echo "error : ".$e->getMessage(); |
248 | 248 | } |
249 | 249 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
250 | 250 | if (empty($all)) { |
251 | 251 | $filters = array('airlines' => array($stats_airline)); |
252 | 252 | if ($filter_name != '') { |
253 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
253 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
254 | 254 | } |
255 | 255 | $Spotter = new Spotter($this->db); |
256 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
256 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
257 | 257 | } |
258 | 258 | return $all; |
259 | 259 | } |
260 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
|
260 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '') { |
|
261 | 261 | $Connection = new Connection(); |
262 | 262 | if ($filter_name == '') $filter_name = $this->filter_name; |
263 | 263 | if ($Connection->tableExists('countries')) { |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | 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"; |
266 | 266 | try { |
267 | 267 | $sth = $this->db->prepare($query); |
268 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
269 | - } catch(PDOException $e) { |
|
268 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
269 | + } catch (PDOException $e) { |
|
270 | 270 | echo "error : ".$e->getMessage(); |
271 | 271 | } |
272 | 272 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -281,70 +281,70 @@ discard block |
||
281 | 281 | return array(); |
282 | 282 | } |
283 | 283 | } |
284 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
|
284 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '') { |
|
285 | 285 | global $globalStatsFilters; |
286 | 286 | if ($filter_name == '') $filter_name = $this->filter_name; |
287 | 287 | if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
288 | 288 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
289 | 289 | try { |
290 | 290 | $sth = $this->db->prepare($query); |
291 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
292 | - } catch(PDOException $e) { |
|
291 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
292 | + } catch (PDOException $e) { |
|
293 | 293 | echo "error : ".$e->getMessage(); |
294 | 294 | } |
295 | 295 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
296 | 296 | if (empty($all)) { |
297 | 297 | $filters = array('airlines' => array($stats_airline)); |
298 | 298 | if ($filter_name != '') { |
299 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
299 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
300 | 300 | } |
301 | 301 | $Spotter = new Spotter($this->db); |
302 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
302 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
303 | 303 | } |
304 | 304 | return $all; |
305 | 305 | } |
306 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
|
306 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '') { |
|
307 | 307 | global $globalStatsFilters; |
308 | 308 | if ($filter_name == '') $filter_name = $this->filter_name; |
309 | 309 | 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"; |
310 | 310 | 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"; |
311 | 311 | try { |
312 | 312 | $sth = $this->db->prepare($query); |
313 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
314 | - } catch(PDOException $e) { |
|
313 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
314 | + } catch (PDOException $e) { |
|
315 | 315 | echo "error : ".$e->getMessage(); |
316 | 316 | } |
317 | 317 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
318 | 318 | if (empty($all)) { |
319 | 319 | $filters = array('airlines' => array($stats_airline)); |
320 | 320 | if ($filter_name != '') { |
321 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
321 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
322 | 322 | } |
323 | 323 | $Spotter = new Spotter($this->db); |
324 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
324 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
325 | 325 | } |
326 | 326 | return $all; |
327 | 327 | } |
328 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
|
328 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '') { |
|
329 | 329 | global $globalStatsFilters; |
330 | 330 | if ($filter_name == '') $filter_name = $this->filter_name; |
331 | 331 | 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"; |
332 | 332 | 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"; |
333 | 333 | try { |
334 | 334 | $sth = $this->db->prepare($query); |
335 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
336 | - } catch(PDOException $e) { |
|
335 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
336 | + } catch (PDOException $e) { |
|
337 | 337 | echo "error : ".$e->getMessage(); |
338 | 338 | } |
339 | 339 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
340 | 340 | if (empty($all)) { |
341 | 341 | $filters = array('airlines' => array($stats_airline)); |
342 | 342 | if ($filter_name != '') { |
343 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
343 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
344 | 344 | } |
345 | 345 | $Spotter = new Spotter($this->db); |
346 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
347 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
346 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
347 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
348 | 348 | $all = array(); |
349 | 349 | foreach ($pall as $value) { |
350 | 350 | $icao = $value['airport_departure_icao']; |
@@ -361,30 +361,30 @@ discard block |
||
361 | 361 | foreach ($all as $key => $row) { |
362 | 362 | $count[$key] = $row['airport_departure_icao_count']; |
363 | 363 | } |
364 | - array_multisort($count,SORT_DESC,$all); |
|
364 | + array_multisort($count, SORT_DESC, $all); |
|
365 | 365 | } |
366 | 366 | return $all; |
367 | 367 | } |
368 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
|
368 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '') { |
|
369 | 369 | global $globalStatsFilters; |
370 | 370 | if ($filter_name == '') $filter_name = $this->filter_name; |
371 | 371 | 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"; |
372 | 372 | 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"; |
373 | 373 | try { |
374 | 374 | $sth = $this->db->prepare($query); |
375 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
376 | - } catch(PDOException $e) { |
|
375 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
376 | + } catch (PDOException $e) { |
|
377 | 377 | echo "error : ".$e->getMessage(); |
378 | 378 | } |
379 | 379 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
380 | 380 | if (empty($all)) { |
381 | 381 | $filters = array('airlines' => array($stats_airline)); |
382 | 382 | if ($filter_name != '') { |
383 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
383 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
384 | 384 | } |
385 | 385 | $Spotter = new Spotter($this->db); |
386 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
387 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
386 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
387 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
388 | 388 | $all = array(); |
389 | 389 | foreach ($pall as $value) { |
390 | 390 | $icao = $value['airport_arrival_icao']; |
@@ -401,12 +401,12 @@ discard block |
||
401 | 401 | foreach ($all as $key => $row) { |
402 | 402 | $count[$key] = $row['airport_arrival_icao_count']; |
403 | 403 | } |
404 | - array_multisort($count,SORT_DESC,$all); |
|
404 | + array_multisort($count, SORT_DESC, $all); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | return $all; |
408 | 408 | } |
409 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
409 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
410 | 410 | global $globalDBdriver, $globalStatsFilters; |
411 | 411 | if ($filter_name == '') $filter_name = $this->filter_name; |
412 | 412 | if ($globalDBdriver == 'mysql') { |
@@ -416,18 +416,18 @@ discard block |
||
416 | 416 | 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"; |
417 | 417 | 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"; |
418 | 418 | } |
419 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
419 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
420 | 420 | try { |
421 | 421 | $sth = $this->db->prepare($query); |
422 | 422 | $sth->execute($query_data); |
423 | - } catch(PDOException $e) { |
|
423 | + } catch (PDOException $e) { |
|
424 | 424 | echo "error : ".$e->getMessage(); |
425 | 425 | } |
426 | 426 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
427 | 427 | if (empty($all)) { |
428 | 428 | $filters = array('airlines' => array($stats_airline)); |
429 | 429 | if ($filter_name != '') { |
430 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
430 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
431 | 431 | } |
432 | 432 | $Spotter = new Spotter($this->db); |
433 | 433 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -436,29 +436,29 @@ discard block |
||
436 | 436 | return $all; |
437 | 437 | } |
438 | 438 | |
439 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
439 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
440 | 440 | global $globalStatsFilters; |
441 | 441 | if ($filter_name == '') $filter_name = $this->filter_name; |
442 | 442 | $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"; |
443 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
443 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
444 | 444 | try { |
445 | 445 | $sth = $this->db->prepare($query); |
446 | 446 | $sth->execute($query_data); |
447 | - } catch(PDOException $e) { |
|
447 | + } catch (PDOException $e) { |
|
448 | 448 | echo "error : ".$e->getMessage(); |
449 | 449 | } |
450 | 450 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
451 | 451 | if (empty($all)) { |
452 | 452 | $filters = array('airlines' => array($stats_airline)); |
453 | 453 | if ($filter_name != '') { |
454 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
454 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
455 | 455 | } |
456 | 456 | $Spotter = new Spotter($this->db); |
457 | 457 | $all = $Spotter->countAllDatesLastMonth($filters); |
458 | 458 | } |
459 | 459 | return $all; |
460 | 460 | } |
461 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
461 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
462 | 462 | global $globalDBdriver, $globalStatsFilters; |
463 | 463 | if ($filter_name == '') $filter_name = $this->filter_name; |
464 | 464 | if ($globalDBdriver == 'mysql') { |
@@ -466,40 +466,40 @@ discard block |
||
466 | 466 | } else { |
467 | 467 | $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"; |
468 | 468 | } |
469 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
469 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
470 | 470 | try { |
471 | 471 | $sth = $this->db->prepare($query); |
472 | 472 | $sth->execute($query_data); |
473 | - } catch(PDOException $e) { |
|
473 | + } catch (PDOException $e) { |
|
474 | 474 | echo "error : ".$e->getMessage(); |
475 | 475 | } |
476 | 476 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
477 | 477 | if (empty($all)) { |
478 | 478 | $filters = array('airlines' => array($stats_airline)); |
479 | 479 | if ($filter_name != '') { |
480 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
480 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
481 | 481 | } |
482 | 482 | $Spotter = new Spotter($this->db); |
483 | 483 | $all = $Spotter->countAllDatesLast7Days($filters); |
484 | 484 | } |
485 | 485 | return $all; |
486 | 486 | } |
487 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
487 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
488 | 488 | global $globalStatsFilters; |
489 | 489 | if ($filter_name == '') $filter_name = $this->filter_name; |
490 | 490 | $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"; |
491 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
491 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
492 | 492 | try { |
493 | 493 | $sth = $this->db->prepare($query); |
494 | 494 | $sth->execute($query_data); |
495 | - } catch(PDOException $e) { |
|
495 | + } catch (PDOException $e) { |
|
496 | 496 | echo "error : ".$e->getMessage(); |
497 | 497 | } |
498 | 498 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
499 | 499 | if (empty($all)) { |
500 | 500 | $filters = array('airlines' => array($stats_airline)); |
501 | 501 | if ($filter_name != '') { |
502 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
502 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
503 | 503 | } |
504 | 504 | $Spotter = new Spotter($this->db); |
505 | 505 | $all = $Spotter->countAllDates($filters); |
@@ -514,35 +514,35 @@ discard block |
||
514 | 514 | try { |
515 | 515 | $sth = $this->db->prepare($query); |
516 | 516 | $sth->execute($query_data); |
517 | - } catch(PDOException $e) { |
|
517 | + } catch (PDOException $e) { |
|
518 | 518 | echo "error : ".$e->getMessage(); |
519 | 519 | } |
520 | 520 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
521 | 521 | if (empty($all)) { |
522 | 522 | $filters = array(); |
523 | 523 | if ($filter_name != '') { |
524 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
524 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
525 | 525 | } |
526 | 526 | $Spotter = new Spotter($this->db); |
527 | 527 | $all = $Spotter->countAllDatesByAirlines($filters); |
528 | 528 | } |
529 | 529 | return $all; |
530 | 530 | } |
531 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
531 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
532 | 532 | global $globalStatsFilters; |
533 | 533 | if ($filter_name == '') $filter_name = $this->filter_name; |
534 | 534 | $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"; |
535 | 535 | try { |
536 | 536 | $sth = $this->db->prepare($query); |
537 | 537 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
538 | - } catch(PDOException $e) { |
|
538 | + } catch (PDOException $e) { |
|
539 | 539 | echo "error : ".$e->getMessage(); |
540 | 540 | } |
541 | 541 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
542 | 542 | if (empty($all)) { |
543 | 543 | $filters = array('airlines' => array($stats_airline)); |
544 | 544 | if ($filter_name != '') { |
545 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
545 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
546 | 546 | } |
547 | 547 | $Spotter = new Spotter($this->db); |
548 | 548 | $all = $Spotter->countAllMonths($filters); |
@@ -556,21 +556,21 @@ discard block |
||
556 | 556 | try { |
557 | 557 | $sth = $this->db->prepare($query); |
558 | 558 | $sth->execute(array(':filter_name' => $filter_name)); |
559 | - } catch(PDOException $e) { |
|
559 | + } catch (PDOException $e) { |
|
560 | 560 | echo "error : ".$e->getMessage(); |
561 | 561 | } |
562 | 562 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
563 | 563 | if (empty($all)) { |
564 | 564 | $filters = array(); |
565 | 565 | if ($filter_name != '') { |
566 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
566 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
567 | 567 | } |
568 | 568 | $Spotter = new Spotter($this->db); |
569 | 569 | $all = $Spotter->countAllMilitaryMonths($filters); |
570 | 570 | } |
571 | 571 | return $all; |
572 | 572 | } |
573 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
573 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
574 | 574 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
575 | 575 | if ($filter_name == '') $filter_name = $this->filter_name; |
576 | 576 | 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"; |
@@ -587,17 +587,17 @@ discard block |
||
587 | 587 | try { |
588 | 588 | $sth = $this->db->prepare($query); |
589 | 589 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
590 | - } catch(PDOException $e) { |
|
590 | + } catch (PDOException $e) { |
|
591 | 591 | echo "error : ".$e->getMessage(); |
592 | 592 | } |
593 | 593 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
594 | 594 | if (empty($all)) { |
595 | 595 | $filters = array('airlines' => array($stats_airline)); |
596 | 596 | if ($filter_name != '') { |
597 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
597 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
598 | 598 | } |
599 | 599 | $Spotter = new Spotter($this->db); |
600 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
600 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
601 | 601 | } |
602 | 602 | return $all; |
603 | 603 | } |
@@ -605,11 +605,11 @@ discard block |
||
605 | 605 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
606 | 606 | global $globalStatsFilters; |
607 | 607 | if ($filter_name == '') $filter_name = $this->filter_name; |
608 | - $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
|
608 | + $all = $this->getSumStats('flights_bymonth', date('Y'), $stats_airline, $filter_name); |
|
609 | 609 | if (empty($all)) { |
610 | 610 | $filters = array('airlines' => array($stats_airline)); |
611 | 611 | if ($filter_name != '') { |
612 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
612 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
613 | 613 | } |
614 | 614 | $Spotter = new Spotter($this->db); |
615 | 615 | $all = $Spotter->countOverallFlights($filters); |
@@ -619,39 +619,39 @@ discard block |
||
619 | 619 | public function countOverallMilitaryFlights($filter_name = '') { |
620 | 620 | global $globalStatsFilters; |
621 | 621 | if ($filter_name == '') $filter_name = $this->filter_name; |
622 | - $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
|
622 | + $all = $this->getSumStats('military_flights_bymonth', date('Y'), '', $filter_name); |
|
623 | 623 | if (empty($all)) { |
624 | 624 | $filters = array(); |
625 | 625 | if ($filter_name != '') { |
626 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
626 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
627 | 627 | } |
628 | 628 | $Spotter = new Spotter($this->db); |
629 | 629 | $all = $Spotter->countOverallMilitaryFlights($filters); |
630 | 630 | } |
631 | 631 | return $all; |
632 | 632 | } |
633 | - public function countOverallArrival($stats_airline = '',$filter_name = '') { |
|
633 | + public function countOverallArrival($stats_airline = '', $filter_name = '') { |
|
634 | 634 | global $globalStatsFilters; |
635 | 635 | if ($filter_name == '') $filter_name = $this->filter_name; |
636 | - $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
|
636 | + $all = $this->getSumStats('realarrivals_bymonth', date('Y'), $stats_airline, $filter_name); |
|
637 | 637 | if (empty($all)) { |
638 | 638 | $filters = array('airlines' => array($stats_airline)); |
639 | 639 | if ($filter_name != '') { |
640 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
640 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
641 | 641 | } |
642 | 642 | $Spotter = new Spotter($this->db); |
643 | 643 | $all = $Spotter->countOverallArrival($filters); |
644 | 644 | } |
645 | 645 | return $all; |
646 | 646 | } |
647 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
|
647 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '') { |
|
648 | 648 | global $globalStatsFilters; |
649 | 649 | if ($filter_name == '') $filter_name = $this->filter_name; |
650 | - $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
|
650 | + $all = $this->getSumStats('aircrafts_bymonth', date('Y'), $stats_airline, $filter_name); |
|
651 | 651 | if (empty($all)) { |
652 | 652 | $filters = array('airlines' => array($stats_airline)); |
653 | 653 | if ($filter_name != '') { |
654 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
654 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
655 | 655 | } |
656 | 656 | $Spotter = new Spotter($this->db); |
657 | 657 | $all = $Spotter->countOverallAircrafts($filters); |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | try { |
666 | 666 | $sth = $this->db->prepare($query); |
667 | 667 | $sth->execute(array(':filter_name' => $filter_name)); |
668 | - } catch(PDOException $e) { |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | echo "error : ".$e->getMessage(); |
670 | 670 | } |
671 | 671 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -674,14 +674,14 @@ discard block |
||
674 | 674 | if (empty($all)) { |
675 | 675 | $filters = array(); |
676 | 676 | if ($filter_name != '') { |
677 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
677 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
678 | 678 | } |
679 | 679 | $Spotter = new Spotter($this->db); |
680 | 680 | $all = $Spotter->countOverallAirlines($filters); |
681 | 681 | } |
682 | 682 | return $all; |
683 | 683 | } |
684 | - public function countOverallOwners($stats_airline = '',$filter_name = '') { |
|
684 | + public function countOverallOwners($stats_airline = '', $filter_name = '') { |
|
685 | 685 | global $globalStatsFilters; |
686 | 686 | if ($filter_name == '') $filter_name = $this->filter_name; |
687 | 687 | /* |
@@ -695,25 +695,25 @@ discard block |
||
695 | 695 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
696 | 696 | $all = $result[0]['nb_owner']; |
697 | 697 | */ |
698 | - $all = $this->getSumStats('owners_bymonth',date('Y'),$stats_airline,$filter_name); |
|
698 | + $all = $this->getSumStats('owners_bymonth', date('Y'), $stats_airline, $filter_name); |
|
699 | 699 | if (empty($all)) { |
700 | 700 | $filters = array('airlines' => array($stats_airline)); |
701 | 701 | if ($filter_name != '') { |
702 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
702 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
703 | 703 | } |
704 | 704 | $Spotter = new Spotter($this->db); |
705 | 705 | $all = $Spotter->countOverallOwners($filters); |
706 | 706 | } |
707 | 707 | return $all; |
708 | 708 | } |
709 | - public function countOverallPilots($stats_airline = '',$filter_name = '') { |
|
709 | + public function countOverallPilots($stats_airline = '', $filter_name = '') { |
|
710 | 710 | global $globalStatsFilters; |
711 | 711 | if ($filter_name == '') $filter_name = $this->filter_name; |
712 | - $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
|
712 | + $all = $this->getSumStats('pilots_bymonth', date('Y'), $stats_airline, $filter_name); |
|
713 | 713 | if (empty($all)) { |
714 | 714 | $filters = array('airlines' => array($stats_airline)); |
715 | 715 | if ($filter_name != '') { |
716 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
716 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
717 | 717 | } |
718 | 718 | $Spotter = new Spotter($this->db); |
719 | 719 | $all = $Spotter->countOverallPilots($filters); |
@@ -721,33 +721,33 @@ discard block |
||
721 | 721 | return $all; |
722 | 722 | } |
723 | 723 | |
724 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
724 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
725 | 725 | if ($filter_name == '') $filter_name = $this->filter_name; |
726 | 726 | $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"; |
727 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
727 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
728 | 728 | try { |
729 | 729 | $sth = $this->db->prepare($query); |
730 | 730 | $sth->execute($query_values); |
731 | - } catch(PDOException $e) { |
|
731 | + } catch (PDOException $e) { |
|
732 | 732 | echo "error : ".$e->getMessage(); |
733 | 733 | } |
734 | 734 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
735 | 735 | return $all; |
736 | 736 | } |
737 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
737 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
738 | 738 | if ($filter_name == '') $filter_name = $this->filter_name; |
739 | 739 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
740 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
740 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
741 | 741 | try { |
742 | 742 | $sth = $this->db->prepare($query); |
743 | 743 | $sth->execute($query_values); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | echo "error : ".$e->getMessage(); |
746 | 746 | } |
747 | 747 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
748 | 748 | return $all; |
749 | 749 | } |
750 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
|
750 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '') { |
|
751 | 751 | if ($filter_name == '') $filter_name = $this->filter_name; |
752 | 752 | global $globalArchiveMonths, $globalDBdriver; |
753 | 753 | if ($globalDBdriver == 'mysql') { |
@@ -755,11 +755,11 @@ discard block |
||
755 | 755 | } else { |
756 | 756 | $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"; |
757 | 757 | } |
758 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
758 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
759 | 759 | try { |
760 | 760 | $sth = $this->db->prepare($query); |
761 | 761 | $sth->execute($query_values); |
762 | - } catch(PDOException $e) { |
|
762 | + } catch (PDOException $e) { |
|
763 | 763 | echo "error : ".$e->getMessage(); |
764 | 764 | } |
765 | 765 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | try { |
778 | 778 | $sth = $this->db->prepare($query); |
779 | 779 | $sth->execute($query_values); |
780 | - } catch(PDOException $e) { |
|
780 | + } catch (PDOException $e) { |
|
781 | 781 | echo "error : ".$e->getMessage(); |
782 | 782 | } |
783 | 783 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | try { |
795 | 795 | $sth = $this->db->prepare($query); |
796 | 796 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
797 | - } catch(PDOException $e) { |
|
797 | + } catch (PDOException $e) { |
|
798 | 798 | echo "error : ".$e->getMessage(); |
799 | 799 | } |
800 | 800 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | try { |
812 | 812 | $sth = $this->db->prepare($query); |
813 | 813 | $sth->execute(array(':filter_name' => $filter_name)); |
814 | - } catch(PDOException $e) { |
|
814 | + } catch (PDOException $e) { |
|
815 | 815 | echo "error : ".$e->getMessage(); |
816 | 816 | } |
817 | 817 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | try { |
829 | 829 | $sth = $this->db->prepare($query); |
830 | 830 | $sth->execute(array(':filter_name' => $filter_name)); |
831 | - } catch(PDOException $e) { |
|
831 | + } catch (PDOException $e) { |
|
832 | 832 | echo "error : ".$e->getMessage(); |
833 | 833 | } |
834 | 834 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -845,14 +845,14 @@ discard block |
||
845 | 845 | try { |
846 | 846 | $sth = $this->db->prepare($query); |
847 | 847 | $sth->execute(array(':filter_name' => $filter_name)); |
848 | - } catch(PDOException $e) { |
|
848 | + } catch (PDOException $e) { |
|
849 | 849 | echo "error : ".$e->getMessage(); |
850 | 850 | } |
851 | 851 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
852 | 852 | return $all[0]['total']; |
853 | 853 | } |
854 | 854 | |
855 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
855 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
856 | 856 | global $globalDBdriver; |
857 | 857 | if ($filter_name == '') $filter_name = $this->filter_name; |
858 | 858 | if ($globalDBdriver == 'mysql') { |
@@ -860,15 +860,15 @@ discard block |
||
860 | 860 | } else { |
861 | 861 | $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);"; |
862 | 862 | } |
863 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
863 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
864 | 864 | try { |
865 | 865 | $sth = $this->db->prepare($query); |
866 | 866 | $sth->execute($query_values); |
867 | - } catch(PDOException $e) { |
|
867 | + } catch (PDOException $e) { |
|
868 | 868 | return "error : ".$e->getMessage(); |
869 | 869 | } |
870 | 870 | } |
871 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
871 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
872 | 872 | global $globalDBdriver; |
873 | 873 | if ($filter_name == '') $filter_name = $this->filter_name; |
874 | 874 | if ($globalDBdriver == 'mysql') { |
@@ -877,219 +877,219 @@ discard block |
||
877 | 877 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
878 | 878 | $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);"; |
879 | 879 | } |
880 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
880 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
881 | 881 | try { |
882 | 882 | $sth = $this->db->prepare($query); |
883 | 883 | $sth->execute($query_values); |
884 | - } catch(PDOException $e) { |
|
884 | + } catch (PDOException $e) { |
|
885 | 885 | return "error : ".$e->getMessage(); |
886 | 886 | } |
887 | 887 | } |
888 | - public function getStatsSource($date,$stats_type = '') { |
|
888 | + public function getStatsSource($date, $stats_type = '') { |
|
889 | 889 | if ($stats_type == '') { |
890 | 890 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
891 | 891 | $query_values = array(':date' => $date); |
892 | 892 | } else { |
893 | 893 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
894 | - $query_values = array(':date' => $date,':stats_type' => $stats_type); |
|
894 | + $query_values = array(':date' => $date, ':stats_type' => $stats_type); |
|
895 | 895 | } |
896 | 896 | try { |
897 | 897 | $sth = $this->db->prepare($query); |
898 | 898 | $sth->execute($query_values); |
899 | - } catch(PDOException $e) { |
|
899 | + } catch (PDOException $e) { |
|
900 | 900 | echo "error : ".$e->getMessage(); |
901 | 901 | } |
902 | 902 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
903 | 903 | return $all; |
904 | 904 | } |
905 | 905 | |
906 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
906 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
907 | 907 | global $globalDBdriver; |
908 | 908 | if ($globalDBdriver == 'mysql') { |
909 | 909 | $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"; |
910 | 910 | } else { |
911 | 911 | $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);"; |
912 | 912 | } |
913 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
913 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
914 | 914 | try { |
915 | 915 | $sth = $this->db->prepare($query); |
916 | 916 | $sth->execute($query_values); |
917 | - } catch(PDOException $e) { |
|
917 | + } catch (PDOException $e) { |
|
918 | 918 | return "error : ".$e->getMessage(); |
919 | 919 | } |
920 | 920 | } |
921 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
921 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
922 | 922 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
923 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
923 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
924 | 924 | try { |
925 | 925 | $sth = $this->db->prepare($query); |
926 | 926 | $sth->execute($query_values); |
927 | - } catch(PDOException $e) { |
|
927 | + } catch (PDOException $e) { |
|
928 | 928 | return "error : ".$e->getMessage(); |
929 | 929 | } |
930 | 930 | } |
931 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
|
931 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '') { |
|
932 | 932 | global $globalDBdriver; |
933 | 933 | if ($globalDBdriver == 'mysql') { |
934 | 934 | $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"; |
935 | 935 | } else { |
936 | 936 | $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);"; |
937 | 937 | } |
938 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
938 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
939 | 939 | try { |
940 | 940 | $sth = $this->db->prepare($query); |
941 | 941 | $sth->execute($query_values); |
942 | - } catch(PDOException $e) { |
|
942 | + } catch (PDOException $e) { |
|
943 | 943 | return "error : ".$e->getMessage(); |
944 | 944 | } |
945 | 945 | } |
946 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
|
946 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '') { |
|
947 | 947 | global $globalDBdriver; |
948 | 948 | if ($globalDBdriver == 'mysql') { |
949 | 949 | $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"; |
950 | 950 | } else { |
951 | 951 | $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);"; |
952 | 952 | } |
953 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
953 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
954 | 954 | try { |
955 | 955 | $sth = $this->db->prepare($query); |
956 | 956 | $sth->execute($query_values); |
957 | - } catch(PDOException $e) { |
|
957 | + } catch (PDOException $e) { |
|
958 | 958 | return "error : ".$e->getMessage(); |
959 | 959 | } |
960 | 960 | } |
961 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
|
961 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '') { |
|
962 | 962 | global $globalDBdriver; |
963 | 963 | if ($globalDBdriver == 'mysql') { |
964 | 964 | $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"; |
965 | 965 | } else { |
966 | 966 | $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);"; |
967 | 967 | } |
968 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
968 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
969 | 969 | try { |
970 | 970 | $sth = $this->db->prepare($query); |
971 | 971 | $sth->execute($query_values); |
972 | - } catch(PDOException $e) { |
|
972 | + } catch (PDOException $e) { |
|
973 | 973 | return "error : ".$e->getMessage(); |
974 | 974 | } |
975 | 975 | } |
976 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
|
976 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
|
977 | 977 | global $globalDBdriver; |
978 | 978 | if ($globalDBdriver == 'mysql') { |
979 | 979 | $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"; |
980 | 980 | } else { |
981 | 981 | $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);"; |
982 | 982 | } |
983 | - $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); |
|
983 | + $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); |
|
984 | 984 | try { |
985 | 985 | $sth = $this->db->prepare($query); |
986 | 986 | $sth->execute($query_values); |
987 | - } catch(PDOException $e) { |
|
987 | + } catch (PDOException $e) { |
|
988 | 988 | return "error : ".$e->getMessage(); |
989 | 989 | } |
990 | 990 | } |
991 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
|
991 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '') { |
|
992 | 992 | global $globalDBdriver; |
993 | 993 | if ($globalDBdriver == 'mysql') { |
994 | 994 | $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"; |
995 | 995 | } else { |
996 | 996 | $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);"; |
997 | 997 | } |
998 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
998 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
999 | 999 | try { |
1000 | 1000 | $sth = $this->db->prepare($query); |
1001 | 1001 | $sth->execute($query_values); |
1002 | - } catch(PDOException $e) { |
|
1002 | + } catch (PDOException $e) { |
|
1003 | 1003 | return "error : ".$e->getMessage(); |
1004 | 1004 | } |
1005 | 1005 | } |
1006 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
|
1006 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
1007 | 1007 | global $globalDBdriver; |
1008 | 1008 | if ($globalDBdriver == 'mysql') { |
1009 | 1009 | $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"; |
1010 | 1010 | } else { |
1011 | 1011 | $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);"; |
1012 | 1012 | } |
1013 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1013 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1014 | 1014 | try { |
1015 | 1015 | $sth = $this->db->prepare($query); |
1016 | 1016 | $sth->execute($query_values); |
1017 | - } catch(PDOException $e) { |
|
1017 | + } catch (PDOException $e) { |
|
1018 | 1018 | return "error : ".$e->getMessage(); |
1019 | 1019 | } |
1020 | 1020 | } |
1021 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '') { |
|
1021 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '') { |
|
1022 | 1022 | global $globalDBdriver; |
1023 | 1023 | if ($globalDBdriver == 'mysql') { |
1024 | 1024 | $query = "INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) VALUES (:pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, pilot_name = :pilot_name"; |
1025 | 1025 | } else { |
1026 | 1026 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1027 | 1027 | } |
1028 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1028 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1029 | 1029 | try { |
1030 | 1030 | $sth = $this->db->prepare($query); |
1031 | 1031 | $sth->execute($query_values); |
1032 | - } catch(PDOException $e) { |
|
1032 | + } catch (PDOException $e) { |
|
1033 | 1033 | return "error : ".$e->getMessage(); |
1034 | 1034 | } |
1035 | 1035 | } |
1036 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1036 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1037 | 1037 | global $globalDBdriver; |
1038 | 1038 | if ($globalDBdriver == 'mysql') { |
1039 | 1039 | $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"; |
1040 | 1040 | } else { |
1041 | 1041 | $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);"; |
1042 | 1042 | } |
1043 | - $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); |
|
1043 | + $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); |
|
1044 | 1044 | try { |
1045 | 1045 | $sth = $this->db->prepare($query); |
1046 | 1046 | $sth->execute($query_values); |
1047 | - } catch(PDOException $e) { |
|
1047 | + } catch (PDOException $e) { |
|
1048 | 1048 | return "error : ".$e->getMessage(); |
1049 | 1049 | } |
1050 | 1050 | } |
1051 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1051 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1052 | 1052 | global $globalDBdriver; |
1053 | 1053 | if ($globalDBdriver == 'mysql') { |
1054 | 1054 | $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"; |
1055 | 1055 | } else { |
1056 | 1056 | $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);"; |
1057 | 1057 | } |
1058 | - $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); |
|
1058 | + $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); |
|
1059 | 1059 | try { |
1060 | 1060 | $sth = $this->db->prepare($query); |
1061 | 1061 | $sth->execute($query_values); |
1062 | - } catch(PDOException $e) { |
|
1062 | + } catch (PDOException $e) { |
|
1063 | 1063 | return "error : ".$e->getMessage(); |
1064 | 1064 | } |
1065 | 1065 | } |
1066 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1066 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1067 | 1067 | global $globalDBdriver; |
1068 | 1068 | if ($globalDBdriver == 'mysql') { |
1069 | 1069 | $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"; |
1070 | 1070 | } else { |
1071 | 1071 | $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);"; |
1072 | 1072 | } |
1073 | - $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); |
|
1073 | + $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); |
|
1074 | 1074 | try { |
1075 | 1075 | $sth = $this->db->prepare($query); |
1076 | 1076 | $sth->execute($query_values); |
1077 | - } catch(PDOException $e) { |
|
1077 | + } catch (PDOException $e) { |
|
1078 | 1078 | return "error : ".$e->getMessage(); |
1079 | 1079 | } |
1080 | 1080 | } |
1081 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1081 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1082 | 1082 | global $globalDBdriver; |
1083 | 1083 | if ($globalDBdriver == 'mysql') { |
1084 | 1084 | $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"; |
1085 | 1085 | } else { |
1086 | 1086 | $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);"; |
1087 | 1087 | } |
1088 | - $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); |
|
1088 | + $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); |
|
1089 | 1089 | try { |
1090 | 1090 | $sth = $this->db->prepare($query); |
1091 | 1091 | $sth->execute($query_values); |
1092 | - } catch(PDOException $e) { |
|
1092 | + } catch (PDOException $e) { |
|
1093 | 1093 | return "error : ".$e->getMessage(); |
1094 | 1094 | } |
1095 | 1095 | } |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | try { |
1101 | 1101 | $sth = $this->db->prepare($query); |
1102 | 1102 | $sth->execute($query_values); |
1103 | - } catch(PDOException $e) { |
|
1103 | + } catch (PDOException $e) { |
|
1104 | 1104 | return "error : ".$e->getMessage(); |
1105 | 1105 | } |
1106 | 1106 | } |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | try { |
1111 | 1111 | $sth = $this->db->prepare($query); |
1112 | 1112 | $sth->execute($query_values); |
1113 | - } catch(PDOException $e) { |
|
1113 | + } catch (PDOException $e) { |
|
1114 | 1114 | return "error : ".$e->getMessage(); |
1115 | 1115 | } |
1116 | 1116 | } |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | try { |
1121 | 1121 | $sth = $this->db->prepare($query); |
1122 | 1122 | $sth->execute($query_values); |
1123 | - } catch(PDOException $e) { |
|
1123 | + } catch (PDOException $e) { |
|
1124 | 1124 | return "error : ".$e->getMessage(); |
1125 | 1125 | } |
1126 | 1126 | } |
@@ -1359,40 +1359,40 @@ discard block |
||
1359 | 1359 | $last_update_day = $last_update[0]['value']; |
1360 | 1360 | } else $last_update_day = '2012-12-12 12:12:12'; |
1361 | 1361 | $Spotter = new Spotter($this->db); |
1362 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
1362 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
1363 | 1363 | foreach ($alldata as $number) { |
1364 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
|
1364 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer']); |
|
1365 | 1365 | } |
1366 | 1366 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
1367 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
1367 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
1368 | 1368 | foreach ($alldata as $number) { |
1369 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
|
1369 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']); |
|
1370 | 1370 | } |
1371 | 1371 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
1372 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
1372 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
1373 | 1373 | foreach ($alldata as $number) { |
1374 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
|
1374 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']); |
|
1375 | 1375 | } |
1376 | 1376 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
1377 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
1377 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
1378 | 1378 | foreach ($alldata as $number) { |
1379 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
|
1379 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']); |
|
1380 | 1380 | } |
1381 | 1381 | if ($globalDebug) echo 'Count all owners...'."\n"; |
1382 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
1382 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
1383 | 1383 | foreach ($alldata as $number) { |
1384 | - $this->addStatOwner($number['owner_name'],$number['owner_count']); |
|
1384 | + $this->addStatOwner($number['owner_name'], $number['owner_count']); |
|
1385 | 1385 | } |
1386 | 1386 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
1387 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
1387 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
1388 | 1388 | foreach ($alldata as $number) { |
1389 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name']); |
|
1389 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name']); |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1393 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
1393 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
1394 | 1394 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1395 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1395 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
1396 | 1396 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1397 | 1397 | $alldata = array(); |
1398 | 1398 | |
@@ -1410,14 +1410,14 @@ discard block |
||
1410 | 1410 | foreach ($alldata as $key => $row) { |
1411 | 1411 | $count[$key] = $row['airport_departure_icao_count']; |
1412 | 1412 | } |
1413 | - array_multisort($count,SORT_DESC,$alldata); |
|
1413 | + array_multisort($count, SORT_DESC, $alldata); |
|
1414 | 1414 | foreach ($alldata as $number) { |
1415 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
|
1415 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']); |
|
1416 | 1416 | } |
1417 | 1417 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1418 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
1418 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
1419 | 1419 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1420 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1420 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
1421 | 1421 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1422 | 1422 | $alldata = array(); |
1423 | 1423 | foreach ($pall as $value) { |
@@ -1434,16 +1434,16 @@ discard block |
||
1434 | 1434 | foreach ($alldata as $key => $row) { |
1435 | 1435 | $count[$key] = $row['airport_arrival_icao_count']; |
1436 | 1436 | } |
1437 | - array_multisort($count,SORT_DESC,$alldata); |
|
1437 | + array_multisort($count, SORT_DESC, $alldata); |
|
1438 | 1438 | foreach ($alldata as $number) { |
1439 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
|
1439 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']); |
|
1440 | 1440 | } |
1441 | 1441 | if ($Connection->tableExists('countries')) { |
1442 | 1442 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
1443 | 1443 | $SpotterArchive = new SpotterArchive(); |
1444 | - $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
|
1444 | + $alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day); |
|
1445 | 1445 | foreach ($alldata as $number) { |
1446 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']); |
|
1446 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']); |
|
1447 | 1447 | } |
1448 | 1448 | } |
1449 | 1449 | |
@@ -1457,37 +1457,37 @@ discard block |
||
1457 | 1457 | $lastyear = false; |
1458 | 1458 | foreach ($alldata as $number) { |
1459 | 1459 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1460 | - $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']))); |
|
1460 | + $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']))); |
|
1461 | 1461 | } |
1462 | 1462 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
1463 | 1463 | $alldata = $Spotter->countAllMilitaryMonths(); |
1464 | 1464 | foreach ($alldata as $number) { |
1465 | - $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']))); |
|
1465 | + $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']))); |
|
1466 | 1466 | } |
1467 | 1467 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
1468 | 1468 | $alldata = $Spotter->countAllMonthsOwners(); |
1469 | 1469 | foreach ($alldata as $number) { |
1470 | - $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']))); |
|
1470 | + $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']))); |
|
1471 | 1471 | } |
1472 | 1472 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
1473 | 1473 | $alldata = $Spotter->countAllMonthsPilots(); |
1474 | 1474 | foreach ($alldata as $number) { |
1475 | - $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']))); |
|
1475 | + $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']))); |
|
1476 | 1476 | } |
1477 | 1477 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
1478 | 1478 | $alldata = $Spotter->countAllMonthsAirlines(); |
1479 | 1479 | foreach ($alldata as $number) { |
1480 | - $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']))); |
|
1480 | + $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']))); |
|
1481 | 1481 | } |
1482 | 1482 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
1483 | 1483 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1484 | 1484 | foreach ($alldata as $number) { |
1485 | - $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']))); |
|
1485 | + $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']))); |
|
1486 | 1486 | } |
1487 | 1487 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
1488 | 1488 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1489 | 1489 | foreach ($alldata as $number) { |
1490 | - $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']))); |
|
1490 | + $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']))); |
|
1491 | 1491 | } |
1492 | 1492 | if ($globalDebug) echo 'Airports data...'."\n"; |
1493 | 1493 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -1532,7 +1532,7 @@ discard block |
||
1532 | 1532 | } |
1533 | 1533 | $alldata = $pall; |
1534 | 1534 | foreach ($alldata as $number) { |
1535 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
1535 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
1536 | 1536 | } |
1537 | 1537 | echo '...Arrival'."\n"; |
1538 | 1538 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -1574,7 +1574,7 @@ discard block |
||
1574 | 1574 | } |
1575 | 1575 | $alldata = $pall; |
1576 | 1576 | foreach ($alldata as $number) { |
1577 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
1577 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
1578 | 1578 | } |
1579 | 1579 | |
1580 | 1580 | echo 'Flights data...'."\n"; |
@@ -1582,28 +1582,28 @@ discard block |
||
1582 | 1582 | echo '-> countAllDatesLastMonth...'."\n"; |
1583 | 1583 | $alldata = $Spotter->countAllDatesLastMonth(); |
1584 | 1584 | foreach ($alldata as $number) { |
1585 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
1585 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
1586 | 1586 | } |
1587 | 1587 | echo '-> countAllDates...'."\n"; |
1588 | 1588 | $previousdata = $this->countAllDates(); |
1589 | 1589 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
1590 | 1590 | $this->deleteStatFlight('date'); |
1591 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates()); |
|
1591 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates()); |
|
1592 | 1592 | $values = array(); |
1593 | 1593 | foreach ($alldata as $cnt) { |
1594 | 1594 | $values[] = $cnt['date_count']; |
1595 | 1595 | } |
1596 | - array_multisort($values,SORT_DESC,$alldata); |
|
1597 | - array_splice($alldata,11); |
|
1596 | + array_multisort($values, SORT_DESC, $alldata); |
|
1597 | + array_splice($alldata, 11); |
|
1598 | 1598 | foreach ($alldata as $number) { |
1599 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
1599 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
1600 | 1600 | } |
1601 | 1601 | |
1602 | 1602 | $this->deleteStatFlight('hour'); |
1603 | 1603 | echo '-> countAllHours...'."\n"; |
1604 | 1604 | $alldata = $Spotter->countAllHours('hour'); |
1605 | 1605 | foreach ($alldata as $number) { |
1606 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
1606 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
1607 | 1607 | } |
1608 | 1608 | |
1609 | 1609 | |
@@ -1612,34 +1612,34 @@ discard block |
||
1612 | 1612 | echo '--- Stats by airlines ---'."\n"; |
1613 | 1613 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
1614 | 1614 | $Spotter = new Spotter($this->db); |
1615 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
1615 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
1616 | 1616 | foreach ($alldata as $number) { |
1617 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
|
1617 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao']); |
|
1618 | 1618 | } |
1619 | 1619 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
1620 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
1620 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
1621 | 1621 | foreach ($alldata as $number) { |
1622 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
|
1622 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao']); |
|
1623 | 1623 | } |
1624 | 1624 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
1625 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
1625 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
1626 | 1626 | foreach ($alldata as $number) { |
1627 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
|
1627 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']); |
|
1628 | 1628 | } |
1629 | 1629 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
1630 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
1630 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
1631 | 1631 | foreach ($alldata as $number) { |
1632 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
|
1632 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao']); |
|
1633 | 1633 | } |
1634 | 1634 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
1635 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
1635 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
1636 | 1636 | foreach ($alldata as $number) { |
1637 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao']); |
|
1637 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao']); |
|
1638 | 1638 | } |
1639 | 1639 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1640 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1640 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1641 | 1641 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1642 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1642 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1643 | 1643 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1644 | 1644 | //$alldata = array(); |
1645 | 1645 | foreach ($dall as $value) { |
@@ -1659,12 +1659,12 @@ discard block |
||
1659 | 1659 | } |
1660 | 1660 | $alldata = $pall; |
1661 | 1661 | foreach ($alldata as $number) { |
1662 | - 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']); |
|
1662 | + 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']); |
|
1663 | 1663 | } |
1664 | 1664 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1665 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1665 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1666 | 1666 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1667 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1667 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1668 | 1668 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1669 | 1669 | //$alldata = array(); |
1670 | 1670 | foreach ($dall as $value) { |
@@ -1684,7 +1684,7 @@ discard block |
||
1684 | 1684 | } |
1685 | 1685 | $alldata = $pall; |
1686 | 1686 | foreach ($alldata as $number) { |
1687 | - 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']); |
|
1687 | + 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']); |
|
1688 | 1688 | } |
1689 | 1689 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
1690 | 1690 | $Spotter = new Spotter($this->db); |
@@ -1692,27 +1692,27 @@ discard block |
||
1692 | 1692 | $lastyear = false; |
1693 | 1693 | foreach ($alldata as $number) { |
1694 | 1694 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1695 | - $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']); |
|
1695 | + $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']); |
|
1696 | 1696 | } |
1697 | 1697 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
1698 | 1698 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1699 | 1699 | foreach ($alldata as $number) { |
1700 | - $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']); |
|
1700 | + $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']); |
|
1701 | 1701 | } |
1702 | 1702 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
1703 | 1703 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1704 | 1704 | foreach ($alldata as $number) { |
1705 | - $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']); |
|
1705 | + $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']); |
|
1706 | 1706 | } |
1707 | 1707 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
1708 | 1708 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1709 | 1709 | foreach ($alldata as $number) { |
1710 | - $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']); |
|
1710 | + $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']); |
|
1711 | 1711 | } |
1712 | 1712 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
1713 | 1713 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1714 | 1714 | foreach ($alldata as $number) { |
1715 | - $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']); |
|
1715 | + $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']); |
|
1716 | 1716 | } |
1717 | 1717 | if ($globalDebug) echo '...Departure'."\n"; |
1718 | 1718 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | } |
1736 | 1736 | $alldata = $pall; |
1737 | 1737 | foreach ($alldata as $number) { |
1738 | - $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']); |
|
1738 | + $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']); |
|
1739 | 1739 | } |
1740 | 1740 | if ($globalDebug) echo '...Arrival'."\n"; |
1741 | 1741 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -1758,32 +1758,32 @@ discard block |
||
1758 | 1758 | } |
1759 | 1759 | $alldata = $pall; |
1760 | 1760 | foreach ($alldata as $number) { |
1761 | - $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']); |
|
1761 | + $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']); |
|
1762 | 1762 | } |
1763 | 1763 | |
1764 | 1764 | if ($globalDebug) echo 'Flights data...'."\n"; |
1765 | 1765 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
1766 | 1766 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1767 | 1767 | foreach ($alldata as $number) { |
1768 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
1768 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1769 | 1769 | } |
1770 | 1770 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
1771 | 1771 | //$previousdata = $this->countAllDatesByAirlines(); |
1772 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
|
1772 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines()); |
|
1773 | 1773 | $values = array(); |
1774 | 1774 | foreach ($alldata as $cnt) { |
1775 | 1775 | $values[] = $cnt['date_count']; |
1776 | 1776 | } |
1777 | - array_multisort($values,SORT_DESC,$alldata); |
|
1778 | - array_splice($alldata,11); |
|
1777 | + array_multisort($values, SORT_DESC, $alldata); |
|
1778 | + array_splice($alldata, 11); |
|
1779 | 1779 | foreach ($alldata as $number) { |
1780 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
1780 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1781 | 1781 | } |
1782 | 1782 | |
1783 | 1783 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
1784 | 1784 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1785 | 1785 | foreach ($alldata as $number) { |
1786 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
1786 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
1787 | 1787 | } |
1788 | 1788 | |
1789 | 1789 | |
@@ -1794,33 +1794,33 @@ discard block |
||
1794 | 1794 | // Count by filter |
1795 | 1795 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
1796 | 1796 | $Spotter = new Spotter($this->db); |
1797 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
1797 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
1798 | 1798 | foreach ($alldata as $number) { |
1799 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name); |
|
1799 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name); |
|
1800 | 1800 | } |
1801 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
1801 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
1802 | 1802 | foreach ($alldata as $number) { |
1803 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name); |
|
1803 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name); |
|
1804 | 1804 | } |
1805 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
1805 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
1806 | 1806 | foreach ($alldata as $number) { |
1807 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name); |
|
1807 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name); |
|
1808 | 1808 | } |
1809 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
1809 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
1810 | 1810 | foreach ($alldata as $number) { |
1811 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name); |
|
1811 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name); |
|
1812 | 1812 | } |
1813 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
1813 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
1814 | 1814 | foreach ($alldata as $number) { |
1815 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name); |
|
1815 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name); |
|
1816 | 1816 | } |
1817 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
1817 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
1818 | 1818 | foreach ($alldata as $number) { |
1819 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name); |
|
1819 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name); |
|
1820 | 1820 | } |
1821 | 1821 | |
1822 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
1823 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1822 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
1823 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
1824 | 1824 | $alldata = array(); |
1825 | 1825 | foreach ($pall as $value) { |
1826 | 1826 | $icao = $value['airport_departure_icao']; |
@@ -1836,12 +1836,12 @@ discard block |
||
1836 | 1836 | foreach ($alldata as $key => $row) { |
1837 | 1837 | $count[$key] = $row['airport_departure_icao_count']; |
1838 | 1838 | } |
1839 | - array_multisort($count,SORT_DESC,$alldata); |
|
1839 | + array_multisort($count, SORT_DESC, $alldata); |
|
1840 | 1840 | foreach ($alldata as $number) { |
1841 | - 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); |
|
1841 | + 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); |
|
1842 | 1842 | } |
1843 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter); |
|
1844 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1843 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, $filter); |
|
1844 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, $filter); |
|
1845 | 1845 | $alldata = array(); |
1846 | 1846 | foreach ($pall as $value) { |
1847 | 1847 | $icao = $value['airport_arrival_icao']; |
@@ -1857,36 +1857,36 @@ discard block |
||
1857 | 1857 | foreach ($alldata as $key => $row) { |
1858 | 1858 | $count[$key] = $row['airport_arrival_icao_count']; |
1859 | 1859 | } |
1860 | - array_multisort($count,SORT_DESC,$alldata); |
|
1860 | + array_multisort($count, SORT_DESC, $alldata); |
|
1861 | 1861 | foreach ($alldata as $number) { |
1862 | - 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); |
|
1862 | + 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); |
|
1863 | 1863 | } |
1864 | 1864 | $Spotter = new Spotter($this->db); |
1865 | 1865 | $alldata = $Spotter->countAllMonths($filter); |
1866 | 1866 | $lastyear = false; |
1867 | 1867 | foreach ($alldata as $number) { |
1868 | 1868 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1869 | - $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); |
|
1869 | + $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); |
|
1870 | 1870 | } |
1871 | 1871 | $alldata = $Spotter->countAllMonthsOwners($filter); |
1872 | 1872 | foreach ($alldata as $number) { |
1873 | - $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); |
|
1873 | + $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); |
|
1874 | 1874 | } |
1875 | 1875 | $alldata = $Spotter->countAllMonthsPilots($filter); |
1876 | 1876 | foreach ($alldata as $number) { |
1877 | - $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); |
|
1877 | + $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); |
|
1878 | 1878 | } |
1879 | 1879 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
1880 | 1880 | foreach ($alldata as $number) { |
1881 | - $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); |
|
1881 | + $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); |
|
1882 | 1882 | } |
1883 | 1883 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
1884 | 1884 | foreach ($alldata as $number) { |
1885 | - $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); |
|
1885 | + $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); |
|
1886 | 1886 | } |
1887 | 1887 | echo '...Departure'."\n"; |
1888 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
1889 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1888 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
1889 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
1890 | 1890 | foreach ($dall as $value) { |
1891 | 1891 | $icao = $value['departure_airport_icao']; |
1892 | 1892 | $ddate = $value['date']; |
@@ -1904,11 +1904,11 @@ discard block |
||
1904 | 1904 | } |
1905 | 1905 | $alldata = $pall; |
1906 | 1906 | foreach ($alldata as $number) { |
1907 | - $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); |
|
1907 | + $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); |
|
1908 | 1908 | } |
1909 | 1909 | echo '...Arrival'."\n"; |
1910 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
1911 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1910 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
1911 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
1912 | 1912 | foreach ($dall as $value) { |
1913 | 1913 | $icao = $value['arrival_airport_icao']; |
1914 | 1914 | $ddate = $value['date']; |
@@ -1926,32 +1926,32 @@ discard block |
||
1926 | 1926 | } |
1927 | 1927 | $alldata = $pall; |
1928 | 1928 | foreach ($alldata as $number) { |
1929 | - $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); |
|
1929 | + $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); |
|
1930 | 1930 | } |
1931 | 1931 | |
1932 | 1932 | echo 'Flights data...'."\n"; |
1933 | 1933 | echo '-> countAllDatesLastMonth...'."\n"; |
1934 | 1934 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
1935 | 1935 | foreach ($alldata as $number) { |
1936 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
1936 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
1937 | 1937 | } |
1938 | 1938 | echo '-> countAllDates...'."\n"; |
1939 | - $previousdata = $this->countAllDates('',$filter_name); |
|
1940 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
1939 | + $previousdata = $this->countAllDates('', $filter_name); |
|
1940 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
1941 | 1941 | $values = array(); |
1942 | 1942 | foreach ($alldata as $cnt) { |
1943 | 1943 | $values[] = $cnt['date_count']; |
1944 | 1944 | } |
1945 | - array_multisort($values,SORT_DESC,$alldata); |
|
1946 | - array_splice($alldata,11); |
|
1945 | + array_multisort($values, SORT_DESC, $alldata); |
|
1946 | + array_splice($alldata, 11); |
|
1947 | 1947 | foreach ($alldata as $number) { |
1948 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
1948 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
1949 | 1949 | } |
1950 | 1950 | |
1951 | 1951 | echo '-> countAllHours...'."\n"; |
1952 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
1952 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
1953 | 1953 | foreach ($alldata as $number) { |
1954 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
1954 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
1955 | 1955 | } |
1956 | 1956 | } |
1957 | 1957 | |
@@ -1962,16 +1962,16 @@ discard block |
||
1962 | 1962 | // SUM all previous month to put as year |
1963 | 1963 | $previous_year = date('Y'); |
1964 | 1964 | $previous_year--; |
1965 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1966 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1967 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1968 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
1965 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1966 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1967 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1968 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
1969 | 1969 | $allairlines = $this->getAllAirlineNames(); |
1970 | 1970 | foreach ($allairlines as $data) { |
1971 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1972 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1973 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1974 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
1971 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1972 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1973 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1974 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
1975 | 1975 | } |
1976 | 1976 | |
1977 | 1977 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -1980,7 +1980,7 @@ discard block |
||
1980 | 1980 | try { |
1981 | 1981 | $sth = $this->db->prepare($query); |
1982 | 1982 | $sth->execute(); |
1983 | - } catch(PDOException $e) { |
|
1983 | + } catch (PDOException $e) { |
|
1984 | 1984 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
1985 | 1985 | } |
1986 | 1986 | } |
@@ -1989,7 +1989,7 @@ discard block |
||
1989 | 1989 | try { |
1990 | 1990 | $sth = $this->db->prepare($query); |
1991 | 1991 | $sth->execute(); |
1992 | - } catch(PDOException $e) { |
|
1992 | + } catch (PDOException $e) { |
|
1993 | 1993 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
1994 | 1994 | } |
1995 | 1995 | } |
@@ -2011,7 +2011,7 @@ discard block |
||
2011 | 2011 | try { |
2012 | 2012 | $sth = $this->db->prepare($query); |
2013 | 2013 | $sth->execute(); |
2014 | - } catch(PDOException $e) { |
|
2014 | + } catch (PDOException $e) { |
|
2015 | 2015 | return "error : ".$e->getMessage(); |
2016 | 2016 | } |
2017 | 2017 | } |
@@ -2025,13 +2025,13 @@ discard block |
||
2025 | 2025 | try { |
2026 | 2026 | $sth = $this->db->prepare($query); |
2027 | 2027 | $sth->execute(); |
2028 | - } catch(PDOException $e) { |
|
2028 | + } catch (PDOException $e) { |
|
2029 | 2029 | return "error : ".$e->getMessage(); |
2030 | 2030 | } |
2031 | 2031 | } |
2032 | 2032 | echo 'Insert last stats update date...'."\n"; |
2033 | 2033 | date_default_timezone_set('UTC'); |
2034 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
2034 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
2035 | 2035 | //} |
2036 | 2036 | } |
2037 | 2037 | } |
@@ -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 getAllAirportNames($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 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"; |
70 | 78 | try { |
71 | 79 | $sth = $this->db->prepare($query); |
@@ -80,9 +88,14 @@ discard block |
||
80 | 88 | |
81 | 89 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
82 | 90 | global $globalStatsFilters; |
83 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
84 | - 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"; |
|
85 | - 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"; |
|
91 | + if ($filter_name == '') { |
|
92 | + $filter_name = $this->filter_name; |
|
93 | + } |
|
94 | + if ($limit) { |
|
95 | + $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"; |
|
96 | + } else { |
|
97 | + $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 | + } |
|
86 | 99 | try { |
87 | 100 | $sth = $this->db->prepare($query); |
88 | 101 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -102,9 +115,14 @@ discard block |
||
102 | 115 | } |
103 | 116 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
104 | 117 | global $globalStatsFilters; |
105 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
106 | - 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"; |
|
107 | - 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"; |
|
118 | + if ($filter_name == '') { |
|
119 | + $filter_name = $this->filter_name; |
|
120 | + } |
|
121 | + if ($limit) { |
|
122 | + $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"; |
|
123 | + } else { |
|
124 | + $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"; |
|
125 | + } |
|
108 | 126 | try { |
109 | 127 | $sth = $this->db->prepare($query); |
110 | 128 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -124,9 +142,14 @@ discard block |
||
124 | 142 | } |
125 | 143 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
126 | 144 | global $globalStatsFilters; |
127 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
128 | - 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"; |
|
129 | - 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"; |
|
145 | + if ($filter_name == '') { |
|
146 | + $filter_name = $this->filter_name; |
|
147 | + } |
|
148 | + if ($limit) { |
|
149 | + $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"; |
|
150 | + } else { |
|
151 | + $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"; |
|
152 | + } |
|
130 | 153 | try { |
131 | 154 | $sth = $this->db->prepare($query); |
132 | 155 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -147,9 +170,14 @@ discard block |
||
147 | 170 | |
148 | 171 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
149 | 172 | global $globalStatsFilters; |
150 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
151 | - 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"; |
|
152 | - 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"; |
|
173 | + if ($filter_name == '') { |
|
174 | + $filter_name = $this->filter_name; |
|
175 | + } |
|
176 | + if ($limit) { |
|
177 | + $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"; |
|
178 | + } else { |
|
179 | + $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"; |
|
180 | + } |
|
153 | 181 | try { |
154 | 182 | $sth = $this->db->prepare($query); |
155 | 183 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -169,9 +197,14 @@ discard block |
||
169 | 197 | } |
170 | 198 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
171 | 199 | global $globalStatsFilters; |
172 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
173 | - 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"; |
|
174 | - 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"; |
|
200 | + if ($filter_name == '') { |
|
201 | + $filter_name = $this->filter_name; |
|
202 | + } |
|
203 | + if ($limit) { |
|
204 | + $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"; |
|
205 | + } else { |
|
206 | + $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"; |
|
207 | + } |
|
175 | 208 | try { |
176 | 209 | $sth = $this->db->prepare($query); |
177 | 210 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -192,9 +225,14 @@ discard block |
||
192 | 225 | |
193 | 226 | public function countAllAirlines($limit = true,$filter_name = '') { |
194 | 227 | global $globalStatsFilters; |
195 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
196 | - 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"; |
|
197 | - 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"; |
|
228 | + if ($filter_name == '') { |
|
229 | + $filter_name = $this->filter_name; |
|
230 | + } |
|
231 | + if ($limit) { |
|
232 | + $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"; |
|
233 | + } else { |
|
234 | + $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"; |
|
235 | + } |
|
198 | 236 | try { |
199 | 237 | $sth = $this->db->prepare($query); |
200 | 238 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -215,9 +253,14 @@ discard block |
||
215 | 253 | } |
216 | 254 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
217 | 255 | global $globalStatsFilters; |
218 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
219 | - 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"; |
|
220 | - 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"; |
|
256 | + if ($filter_name == '') { |
|
257 | + $filter_name = $this->filter_name; |
|
258 | + } |
|
259 | + if ($limit) { |
|
260 | + $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"; |
|
261 | + } else { |
|
262 | + $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"; |
|
263 | + } |
|
221 | 264 | try { |
222 | 265 | $sth = $this->db->prepare($query); |
223 | 266 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -237,9 +280,14 @@ discard block |
||
237 | 280 | } |
238 | 281 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
239 | 282 | global $globalStatsFilters; |
240 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
241 | - 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"; |
|
242 | - 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"; |
|
283 | + if ($filter_name == '') { |
|
284 | + $filter_name = $this->filter_name; |
|
285 | + } |
|
286 | + if ($limit) { |
|
287 | + $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"; |
|
288 | + } else { |
|
289 | + $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"; |
|
290 | + } |
|
243 | 291 | try { |
244 | 292 | $sth = $this->db->prepare($query); |
245 | 293 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -259,10 +307,15 @@ discard block |
||
259 | 307 | } |
260 | 308 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
261 | 309 | $Connection = new Connection(); |
262 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
310 | + if ($filter_name == '') { |
|
311 | + $filter_name = $this->filter_name; |
|
312 | + } |
|
263 | 313 | if ($Connection->tableExists('countries')) { |
264 | - 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"; |
|
265 | - 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"; |
|
314 | + if ($limit) { |
|
315 | + $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"; |
|
316 | + } else { |
|
317 | + $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"; |
|
318 | + } |
|
266 | 319 | try { |
267 | 320 | $sth = $this->db->prepare($query); |
268 | 321 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -283,9 +336,14 @@ discard block |
||
283 | 336 | } |
284 | 337 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
285 | 338 | global $globalStatsFilters; |
286 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
287 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
288 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
339 | + if ($filter_name == '') { |
|
340 | + $filter_name = $this->filter_name; |
|
341 | + } |
|
342 | + if ($limit) { |
|
343 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
344 | + } else { |
|
345 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
346 | + } |
|
289 | 347 | try { |
290 | 348 | $sth = $this->db->prepare($query); |
291 | 349 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -305,9 +363,14 @@ discard block |
||
305 | 363 | } |
306 | 364 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
307 | 365 | global $globalStatsFilters; |
308 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
309 | - 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"; |
|
310 | - 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"; |
|
366 | + if ($filter_name == '') { |
|
367 | + $filter_name = $this->filter_name; |
|
368 | + } |
|
369 | + if ($limit) { |
|
370 | + $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"; |
|
371 | + } else { |
|
372 | + $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"; |
|
373 | + } |
|
311 | 374 | try { |
312 | 375 | $sth = $this->db->prepare($query); |
313 | 376 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -327,9 +390,14 @@ discard block |
||
327 | 390 | } |
328 | 391 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
329 | 392 | global $globalStatsFilters; |
330 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
331 | - 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"; |
|
332 | - 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"; |
|
393 | + if ($filter_name == '') { |
|
394 | + $filter_name = $this->filter_name; |
|
395 | + } |
|
396 | + if ($limit) { |
|
397 | + $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"; |
|
398 | + } else { |
|
399 | + $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"; |
|
400 | + } |
|
333 | 401 | try { |
334 | 402 | $sth = $this->db->prepare($query); |
335 | 403 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -355,7 +423,9 @@ discard block |
||
355 | 423 | $icao = $value['airport_departure_icao']; |
356 | 424 | if (isset($all[$icao])) { |
357 | 425 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
358 | - } else $all[$icao] = $value; |
|
426 | + } else { |
|
427 | + $all[$icao] = $value; |
|
428 | + } |
|
359 | 429 | } |
360 | 430 | $count = array(); |
361 | 431 | foreach ($all as $key => $row) { |
@@ -367,9 +437,14 @@ discard block |
||
367 | 437 | } |
368 | 438 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
369 | 439 | global $globalStatsFilters; |
370 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
371 | - 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"; |
|
372 | - 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"; |
|
440 | + if ($filter_name == '') { |
|
441 | + $filter_name = $this->filter_name; |
|
442 | + } |
|
443 | + if ($limit) { |
|
444 | + $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"; |
|
445 | + } else { |
|
446 | + $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"; |
|
447 | + } |
|
373 | 448 | try { |
374 | 449 | $sth = $this->db->prepare($query); |
375 | 450 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -395,7 +470,9 @@ discard block |
||
395 | 470 | $icao = $value['airport_arrival_icao']; |
396 | 471 | if (isset($all[$icao])) { |
397 | 472 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
398 | - } else $all[$icao] = $value; |
|
473 | + } else { |
|
474 | + $all[$icao] = $value; |
|
475 | + } |
|
399 | 476 | } |
400 | 477 | $count = array(); |
401 | 478 | foreach ($all as $key => $row) { |
@@ -408,13 +485,21 @@ discard block |
||
408 | 485 | } |
409 | 486 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
410 | 487 | global $globalDBdriver, $globalStatsFilters; |
411 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
488 | + if ($filter_name == '') { |
|
489 | + $filter_name = $this->filter_name; |
|
490 | + } |
|
412 | 491 | if ($globalDBdriver == 'mysql') { |
413 | - 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"; |
|
414 | - 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"; |
|
492 | + if ($limit) { |
|
493 | + $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"; |
|
494 | + } else { |
|
495 | + $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"; |
|
496 | + } |
|
415 | 497 | } else { |
416 | - 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"; |
|
417 | - 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"; |
|
498 | + if ($limit) { |
|
499 | + $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"; |
|
500 | + } else { |
|
501 | + $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"; |
|
502 | + } |
|
418 | 503 | } |
419 | 504 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
420 | 505 | try { |
@@ -438,7 +523,9 @@ discard block |
||
438 | 523 | |
439 | 524 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
440 | 525 | global $globalStatsFilters; |
441 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
526 | + if ($filter_name == '') { |
|
527 | + $filter_name = $this->filter_name; |
|
528 | + } |
|
442 | 529 | $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"; |
443 | 530 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
444 | 531 | try { |
@@ -460,7 +547,9 @@ discard block |
||
460 | 547 | } |
461 | 548 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
462 | 549 | global $globalDBdriver, $globalStatsFilters; |
463 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
550 | + if ($filter_name == '') { |
|
551 | + $filter_name = $this->filter_name; |
|
552 | + } |
|
464 | 553 | if ($globalDBdriver == 'mysql') { |
465 | 554 | $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"; |
466 | 555 | } else { |
@@ -486,7 +575,9 @@ discard block |
||
486 | 575 | } |
487 | 576 | public function countAllDates($stats_airline = '',$filter_name = '') { |
488 | 577 | global $globalStatsFilters; |
489 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
578 | + if ($filter_name == '') { |
|
579 | + $filter_name = $this->filter_name; |
|
580 | + } |
|
490 | 581 | $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"; |
491 | 582 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
492 | 583 | try { |
@@ -508,7 +599,9 @@ discard block |
||
508 | 599 | } |
509 | 600 | public function countAllDatesByAirlines($filter_name = '') { |
510 | 601 | global $globalStatsFilters; |
511 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
602 | + if ($filter_name == '') { |
|
603 | + $filter_name = $this->filter_name; |
|
604 | + } |
|
512 | 605 | $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"; |
513 | 606 | $query_data = array('filter_name' => $filter_name); |
514 | 607 | try { |
@@ -530,7 +623,9 @@ discard block |
||
530 | 623 | } |
531 | 624 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
532 | 625 | global $globalStatsFilters; |
533 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
626 | + if ($filter_name == '') { |
|
627 | + $filter_name = $this->filter_name; |
|
628 | + } |
|
534 | 629 | $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"; |
535 | 630 | try { |
536 | 631 | $sth = $this->db->prepare($query); |
@@ -551,7 +646,9 @@ discard block |
||
551 | 646 | } |
552 | 647 | public function countAllMilitaryMonths($filter_name = '') { |
553 | 648 | global $globalStatsFilters; |
554 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
649 | + if ($filter_name == '') { |
|
650 | + $filter_name = $this->filter_name; |
|
651 | + } |
|
555 | 652 | $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"; |
556 | 653 | try { |
557 | 654 | $sth = $this->db->prepare($query); |
@@ -572,9 +669,14 @@ discard block |
||
572 | 669 | } |
573 | 670 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
574 | 671 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
575 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
576 | - 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"; |
|
577 | - 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"; |
|
672 | + if ($filter_name == '') { |
|
673 | + $filter_name = $this->filter_name; |
|
674 | + } |
|
675 | + if ($limit) { |
|
676 | + $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"; |
|
677 | + } else { |
|
678 | + $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"; |
|
679 | + } |
|
578 | 680 | if ($orderby == 'hour') { |
579 | 681 | /* |
580 | 682 | if ($globalDBdriver == 'mysql') { |
@@ -583,7 +685,9 @@ discard block |
||
583 | 685 | */ |
584 | 686 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
585 | 687 | } |
586 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
688 | + if ($orderby == 'count') { |
|
689 | + $query .= " ORDER BY hour_count DESC"; |
|
690 | + } |
|
587 | 691 | try { |
588 | 692 | $sth = $this->db->prepare($query); |
589 | 693 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -604,7 +708,9 @@ discard block |
||
604 | 708 | |
605 | 709 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
606 | 710 | global $globalStatsFilters; |
607 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
711 | + if ($filter_name == '') { |
|
712 | + $filter_name = $this->filter_name; |
|
713 | + } |
|
608 | 714 | $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
609 | 715 | if (empty($all)) { |
610 | 716 | $filters = array('airlines' => array($stats_airline)); |
@@ -618,7 +724,9 @@ discard block |
||
618 | 724 | } |
619 | 725 | public function countOverallMilitaryFlights($filter_name = '') { |
620 | 726 | global $globalStatsFilters; |
621 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
727 | + if ($filter_name == '') { |
|
728 | + $filter_name = $this->filter_name; |
|
729 | + } |
|
622 | 730 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
623 | 731 | if (empty($all)) { |
624 | 732 | $filters = array(); |
@@ -632,7 +740,9 @@ discard block |
||
632 | 740 | } |
633 | 741 | public function countOverallArrival($stats_airline = '',$filter_name = '') { |
634 | 742 | global $globalStatsFilters; |
635 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
743 | + if ($filter_name == '') { |
|
744 | + $filter_name = $this->filter_name; |
|
745 | + } |
|
636 | 746 | $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
637 | 747 | if (empty($all)) { |
638 | 748 | $filters = array('airlines' => array($stats_airline)); |
@@ -646,7 +756,9 @@ discard block |
||
646 | 756 | } |
647 | 757 | public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
648 | 758 | global $globalStatsFilters; |
649 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
759 | + if ($filter_name == '') { |
|
760 | + $filter_name = $this->filter_name; |
|
761 | + } |
|
650 | 762 | $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
651 | 763 | if (empty($all)) { |
652 | 764 | $filters = array('airlines' => array($stats_airline)); |
@@ -660,7 +772,9 @@ discard block |
||
660 | 772 | } |
661 | 773 | public function countOverallAirlines($filter_name = '') { |
662 | 774 | global $globalStatsFilters; |
663 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
775 | + if ($filter_name == '') { |
|
776 | + $filter_name = $this->filter_name; |
|
777 | + } |
|
664 | 778 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
665 | 779 | try { |
666 | 780 | $sth = $this->db->prepare($query); |
@@ -683,7 +797,9 @@ discard block |
||
683 | 797 | } |
684 | 798 | public function countOverallOwners($stats_airline = '',$filter_name = '') { |
685 | 799 | global $globalStatsFilters; |
686 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
800 | + if ($filter_name == '') { |
|
801 | + $filter_name = $this->filter_name; |
|
802 | + } |
|
687 | 803 | /* |
688 | 804 | $query = "SELECT COUNT(*) AS nb_owner FROM stats_owner"; |
689 | 805 | try { |
@@ -708,7 +824,9 @@ discard block |
||
708 | 824 | } |
709 | 825 | public function countOverallPilots($stats_airline = '',$filter_name = '') { |
710 | 826 | global $globalStatsFilters; |
711 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
827 | + if ($filter_name == '') { |
|
828 | + $filter_name = $this->filter_name; |
|
829 | + } |
|
712 | 830 | $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
713 | 831 | if (empty($all)) { |
714 | 832 | $filters = array('airlines' => array($stats_airline)); |
@@ -722,7 +840,9 @@ discard block |
||
722 | 840 | } |
723 | 841 | |
724 | 842 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
725 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
843 | + if ($filter_name == '') { |
|
844 | + $filter_name = $this->filter_name; |
|
845 | + } |
|
726 | 846 | $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"; |
727 | 847 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
728 | 848 | try { |
@@ -735,7 +855,9 @@ discard block |
||
735 | 855 | return $all; |
736 | 856 | } |
737 | 857 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
738 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
858 | + if ($filter_name == '') { |
|
859 | + $filter_name = $this->filter_name; |
|
860 | + } |
|
739 | 861 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
740 | 862 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
741 | 863 | try { |
@@ -748,7 +870,9 @@ discard block |
||
748 | 870 | return $all; |
749 | 871 | } |
750 | 872 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
751 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
873 | + if ($filter_name == '') { |
|
874 | + $filter_name = $this->filter_name; |
|
875 | + } |
|
752 | 876 | global $globalArchiveMonths, $globalDBdriver; |
753 | 877 | if ($globalDBdriver == 'mysql') { |
754 | 878 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -767,7 +891,9 @@ discard block |
||
767 | 891 | } |
768 | 892 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
769 | 893 | global $globalArchiveMonths, $globalDBdriver; |
770 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
894 | + if ($filter_name == '') { |
|
895 | + $filter_name = $this->filter_name; |
|
896 | + } |
|
771 | 897 | if ($globalDBdriver == 'mysql') { |
772 | 898 | $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"; |
773 | 899 | } else { |
@@ -785,7 +911,9 @@ discard block |
||
785 | 911 | } |
786 | 912 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
787 | 913 | global $globalArchiveMonths, $globalDBdriver; |
788 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
914 | + if ($filter_name == '') { |
|
915 | + $filter_name = $this->filter_name; |
|
916 | + } |
|
789 | 917 | if ($globalDBdriver == 'mysql') { |
790 | 918 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
791 | 919 | } else { |
@@ -802,7 +930,9 @@ discard block |
||
802 | 930 | } |
803 | 931 | public function getStatsAirlineTotal($filter_name = '') { |
804 | 932 | global $globalArchiveMonths, $globalDBdriver; |
805 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
933 | + if ($filter_name == '') { |
|
934 | + $filter_name = $this->filter_name; |
|
935 | + } |
|
806 | 936 | if ($globalDBdriver == 'mysql') { |
807 | 937 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
808 | 938 | } else { |
@@ -819,7 +949,9 @@ discard block |
||
819 | 949 | } |
820 | 950 | public function getStatsOwnerTotal($filter_name = '') { |
821 | 951 | global $globalArchiveMonths, $globalDBdriver; |
822 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
952 | + if ($filter_name == '') { |
|
953 | + $filter_name = $this->filter_name; |
|
954 | + } |
|
823 | 955 | if ($globalDBdriver == 'mysql') { |
824 | 956 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
825 | 957 | } else { |
@@ -836,7 +968,9 @@ discard block |
||
836 | 968 | } |
837 | 969 | public function getStatsPilotTotal($filter_name = '') { |
838 | 970 | global $globalArchiveMonths, $globalDBdriver; |
839 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
971 | + if ($filter_name == '') { |
|
972 | + $filter_name = $this->filter_name; |
|
973 | + } |
|
840 | 974 | if ($globalDBdriver == 'mysql') { |
841 | 975 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
842 | 976 | } else { |
@@ -854,7 +988,9 @@ discard block |
||
854 | 988 | |
855 | 989 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
856 | 990 | global $globalDBdriver; |
857 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
991 | + if ($filter_name == '') { |
|
992 | + $filter_name = $this->filter_name; |
|
993 | + } |
|
858 | 994 | if ($globalDBdriver == 'mysql') { |
859 | 995 | $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"; |
860 | 996 | } else { |
@@ -870,7 +1006,9 @@ discard block |
||
870 | 1006 | } |
871 | 1007 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
872 | 1008 | global $globalDBdriver; |
873 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1009 | + if ($filter_name == '') { |
|
1010 | + $filter_name = $this->filter_name; |
|
1011 | + } |
|
874 | 1012 | if ($globalDBdriver == 'mysql') { |
875 | 1013 | $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"; |
876 | 1014 | } else { |
@@ -1353,47 +1491,69 @@ discard block |
||
1353 | 1491 | $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
1354 | 1492 | } else { |
1355 | 1493 | */ |
1356 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1357 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1494 | + if ($globalDebug) { |
|
1495 | + echo 'Update stats !'."\n"; |
|
1496 | + } |
|
1497 | + if ($globalDebug) { |
|
1498 | + echo 'Count all aircraft types...'."\n"; |
|
1499 | + } |
|
1358 | 1500 | if (isset($last_update[0]['value'])) { |
1359 | 1501 | $last_update_day = $last_update[0]['value']; |
1360 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1502 | + } else { |
|
1503 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1504 | + } |
|
1361 | 1505 | $Spotter = new Spotter($this->db); |
1362 | 1506 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1363 | 1507 | foreach ($alldata as $number) { |
1364 | 1508 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
1365 | 1509 | } |
1366 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1510 | + if ($globalDebug) { |
|
1511 | + echo 'Count all airlines...'."\n"; |
|
1512 | + } |
|
1367 | 1513 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1368 | 1514 | foreach ($alldata as $number) { |
1369 | 1515 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
1370 | 1516 | } |
1371 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1517 | + if ($globalDebug) { |
|
1518 | + echo 'Count all registrations...'."\n"; |
|
1519 | + } |
|
1372 | 1520 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1373 | 1521 | foreach ($alldata as $number) { |
1374 | 1522 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
1375 | 1523 | } |
1376 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1524 | + if ($globalDebug) { |
|
1525 | + echo 'Count all callsigns...'."\n"; |
|
1526 | + } |
|
1377 | 1527 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1378 | 1528 | foreach ($alldata as $number) { |
1379 | 1529 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1380 | 1530 | } |
1381 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1531 | + if ($globalDebug) { |
|
1532 | + echo 'Count all owners...'."\n"; |
|
1533 | + } |
|
1382 | 1534 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1383 | 1535 | foreach ($alldata as $number) { |
1384 | 1536 | $this->addStatOwner($number['owner_name'],$number['owner_count']); |
1385 | 1537 | } |
1386 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1538 | + if ($globalDebug) { |
|
1539 | + echo 'Count all pilots...'."\n"; |
|
1540 | + } |
|
1387 | 1541 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1388 | 1542 | foreach ($alldata as $number) { |
1389 | 1543 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name']); |
1390 | 1544 | } |
1391 | 1545 | |
1392 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1546 | + if ($globalDebug) { |
|
1547 | + echo 'Count all departure airports...'."\n"; |
|
1548 | + } |
|
1393 | 1549 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1394 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1550 | + if ($globalDebug) { |
|
1551 | + echo 'Count all detected departure airports...'."\n"; |
|
1552 | + } |
|
1395 | 1553 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1396 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1554 | + if ($globalDebug) { |
|
1555 | + echo 'Order departure airports...'."\n"; |
|
1556 | + } |
|
1397 | 1557 | $alldata = array(); |
1398 | 1558 | |
1399 | 1559 | foreach ($pall as $value) { |
@@ -1404,7 +1564,9 @@ discard block |
||
1404 | 1564 | $icao = $value['airport_departure_icao']; |
1405 | 1565 | if (isset($alldata[$icao])) { |
1406 | 1566 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1407 | - } else $alldata[$icao] = $value; |
|
1567 | + } else { |
|
1568 | + $alldata[$icao] = $value; |
|
1569 | + } |
|
1408 | 1570 | } |
1409 | 1571 | $count = array(); |
1410 | 1572 | foreach ($alldata as $key => $row) { |
@@ -1414,11 +1576,17 @@ discard block |
||
1414 | 1576 | foreach ($alldata as $number) { |
1415 | 1577 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
1416 | 1578 | } |
1417 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1579 | + if ($globalDebug) { |
|
1580 | + echo 'Count all arrival airports...'."\n"; |
|
1581 | + } |
|
1418 | 1582 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1419 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1583 | + if ($globalDebug) { |
|
1584 | + echo 'Count all detected arrival airports...'."\n"; |
|
1585 | + } |
|
1420 | 1586 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1421 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1587 | + if ($globalDebug) { |
|
1588 | + echo 'Order arrival airports...'."\n"; |
|
1589 | + } |
|
1422 | 1590 | $alldata = array(); |
1423 | 1591 | foreach ($pall as $value) { |
1424 | 1592 | $icao = $value['airport_arrival_icao']; |
@@ -1428,7 +1596,9 @@ discard block |
||
1428 | 1596 | $icao = $value['airport_arrival_icao']; |
1429 | 1597 | if (isset($alldata[$icao])) { |
1430 | 1598 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1431 | - } else $alldata[$icao] = $value; |
|
1599 | + } else { |
|
1600 | + $alldata[$icao] = $value; |
|
1601 | + } |
|
1432 | 1602 | } |
1433 | 1603 | $count = array(); |
1434 | 1604 | foreach ($alldata as $key => $row) { |
@@ -1439,7 +1609,9 @@ discard block |
||
1439 | 1609 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1440 | 1610 | } |
1441 | 1611 | if ($Connection->tableExists('countries')) { |
1442 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1612 | + if ($globalDebug) { |
|
1613 | + echo 'Count all flights by countries...'."\n"; |
|
1614 | + } |
|
1443 | 1615 | $SpotterArchive = new SpotterArchive(); |
1444 | 1616 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1445 | 1617 | foreach ($alldata as $number) { |
@@ -1451,46 +1623,66 @@ discard block |
||
1451 | 1623 | // Add by month using getstat if month finish... |
1452 | 1624 | |
1453 | 1625 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1454 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1626 | + if ($globalDebug) { |
|
1627 | + echo 'Count all flights by months...'."\n"; |
|
1628 | + } |
|
1455 | 1629 | $Spotter = new Spotter($this->db); |
1456 | 1630 | $alldata = $Spotter->countAllMonths(); |
1457 | 1631 | $lastyear = false; |
1458 | 1632 | foreach ($alldata as $number) { |
1459 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1633 | + if ($number['year_name'] != date('Y')) { |
|
1634 | + $lastyear = true; |
|
1635 | + } |
|
1460 | 1636 | $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']))); |
1461 | 1637 | } |
1462 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1638 | + if ($globalDebug) { |
|
1639 | + echo 'Count all military flights by months...'."\n"; |
|
1640 | + } |
|
1463 | 1641 | $alldata = $Spotter->countAllMilitaryMonths(); |
1464 | 1642 | foreach ($alldata as $number) { |
1465 | 1643 | $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']))); |
1466 | 1644 | } |
1467 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1645 | + if ($globalDebug) { |
|
1646 | + echo 'Count all owners by months...'."\n"; |
|
1647 | + } |
|
1468 | 1648 | $alldata = $Spotter->countAllMonthsOwners(); |
1469 | 1649 | foreach ($alldata as $number) { |
1470 | 1650 | $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']))); |
1471 | 1651 | } |
1472 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1652 | + if ($globalDebug) { |
|
1653 | + echo 'Count all pilots by months...'."\n"; |
|
1654 | + } |
|
1473 | 1655 | $alldata = $Spotter->countAllMonthsPilots(); |
1474 | 1656 | foreach ($alldata as $number) { |
1475 | 1657 | $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']))); |
1476 | 1658 | } |
1477 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1659 | + if ($globalDebug) { |
|
1660 | + echo 'Count all airlines by months...'."\n"; |
|
1661 | + } |
|
1478 | 1662 | $alldata = $Spotter->countAllMonthsAirlines(); |
1479 | 1663 | foreach ($alldata as $number) { |
1480 | 1664 | $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']))); |
1481 | 1665 | } |
1482 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1666 | + if ($globalDebug) { |
|
1667 | + echo 'Count all aircrafts by months...'."\n"; |
|
1668 | + } |
|
1483 | 1669 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1484 | 1670 | foreach ($alldata as $number) { |
1485 | 1671 | $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']))); |
1486 | 1672 | } |
1487 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1673 | + if ($globalDebug) { |
|
1674 | + echo 'Count all real arrivals by months...'."\n"; |
|
1675 | + } |
|
1488 | 1676 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1489 | 1677 | foreach ($alldata as $number) { |
1490 | 1678 | $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']))); |
1491 | 1679 | } |
1492 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1493 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1680 | + if ($globalDebug) { |
|
1681 | + echo 'Airports data...'."\n"; |
|
1682 | + } |
|
1683 | + if ($globalDebug) { |
|
1684 | + echo '...Departure'."\n"; |
|
1685 | + } |
|
1494 | 1686 | $this->deleteStatAirport('daily'); |
1495 | 1687 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1496 | 1688 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1610,37 +1802,53 @@ discard block |
||
1610 | 1802 | |
1611 | 1803 | // Count by airlines |
1612 | 1804 | echo '--- Stats by airlines ---'."\n"; |
1613 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
1805 | + if ($globalDebug) { |
|
1806 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
1807 | + } |
|
1614 | 1808 | $Spotter = new Spotter($this->db); |
1615 | 1809 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1616 | 1810 | foreach ($alldata as $number) { |
1617 | 1811 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
1618 | 1812 | } |
1619 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1813 | + if ($globalDebug) { |
|
1814 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1815 | + } |
|
1620 | 1816 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1621 | 1817 | foreach ($alldata as $number) { |
1622 | 1818 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
1623 | 1819 | } |
1624 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
1820 | + if ($globalDebug) { |
|
1821 | + echo 'Count all callsigns by airlines...'."\n"; |
|
1822 | + } |
|
1625 | 1823 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1626 | 1824 | foreach ($alldata as $number) { |
1627 | 1825 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1628 | 1826 | } |
1629 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
1827 | + if ($globalDebug) { |
|
1828 | + echo 'Count all owners by airlines...'."\n"; |
|
1829 | + } |
|
1630 | 1830 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1631 | 1831 | foreach ($alldata as $number) { |
1632 | 1832 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
1633 | 1833 | } |
1634 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
1834 | + if ($globalDebug) { |
|
1835 | + echo 'Count all pilots by airlines...'."\n"; |
|
1836 | + } |
|
1635 | 1837 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1636 | 1838 | foreach ($alldata as $number) { |
1637 | 1839 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao']); |
1638 | 1840 | } |
1639 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
1841 | + if ($globalDebug) { |
|
1842 | + echo 'Count all departure airports by airlines...'."\n"; |
|
1843 | + } |
|
1640 | 1844 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1641 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
1845 | + if ($globalDebug) { |
|
1846 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
1847 | + } |
|
1642 | 1848 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1643 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
1849 | + if ($globalDebug) { |
|
1850 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
1851 | + } |
|
1644 | 1852 | //$alldata = array(); |
1645 | 1853 | foreach ($dall as $value) { |
1646 | 1854 | $icao = $value['airport_departure_icao']; |
@@ -1661,11 +1869,17 @@ discard block |
||
1661 | 1869 | foreach ($alldata as $number) { |
1662 | 1870 | 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']); |
1663 | 1871 | } |
1664 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
1872 | + if ($globalDebug) { |
|
1873 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
1874 | + } |
|
1665 | 1875 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1666 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1876 | + if ($globalDebug) { |
|
1877 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1878 | + } |
|
1667 | 1879 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1668 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
1880 | + if ($globalDebug) { |
|
1881 | + echo 'Order arrival airports by airlines...'."\n"; |
|
1882 | + } |
|
1669 | 1883 | //$alldata = array(); |
1670 | 1884 | foreach ($dall as $value) { |
1671 | 1885 | $icao = $value['airport_arrival_icao']; |
@@ -1686,35 +1900,49 @@ discard block |
||
1686 | 1900 | foreach ($alldata as $number) { |
1687 | 1901 | 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']); |
1688 | 1902 | } |
1689 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1903 | + if ($globalDebug) { |
|
1904 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1905 | + } |
|
1690 | 1906 | $Spotter = new Spotter($this->db); |
1691 | 1907 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1692 | 1908 | $lastyear = false; |
1693 | 1909 | foreach ($alldata as $number) { |
1694 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1910 | + if ($number['year_name'] != date('Y')) { |
|
1911 | + $lastyear = true; |
|
1912 | + } |
|
1695 | 1913 | $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']); |
1696 | 1914 | } |
1697 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
1915 | + if ($globalDebug) { |
|
1916 | + echo 'Count all owners by months by airlines...'."\n"; |
|
1917 | + } |
|
1698 | 1918 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1699 | 1919 | foreach ($alldata as $number) { |
1700 | 1920 | $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']); |
1701 | 1921 | } |
1702 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
1922 | + if ($globalDebug) { |
|
1923 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
1924 | + } |
|
1703 | 1925 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1704 | 1926 | foreach ($alldata as $number) { |
1705 | 1927 | $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']); |
1706 | 1928 | } |
1707 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1929 | + if ($globalDebug) { |
|
1930 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1931 | + } |
|
1708 | 1932 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1709 | 1933 | foreach ($alldata as $number) { |
1710 | 1934 | $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']); |
1711 | 1935 | } |
1712 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1936 | + if ($globalDebug) { |
|
1937 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1938 | + } |
|
1713 | 1939 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1714 | 1940 | foreach ($alldata as $number) { |
1715 | 1941 | $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']); |
1716 | 1942 | } |
1717 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1943 | + if ($globalDebug) { |
|
1944 | + echo '...Departure'."\n"; |
|
1945 | + } |
|
1718 | 1946 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1719 | 1947 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1720 | 1948 | foreach ($dall as $value) { |
@@ -1737,7 +1965,9 @@ discard block |
||
1737 | 1965 | foreach ($alldata as $number) { |
1738 | 1966 | $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']); |
1739 | 1967 | } |
1740 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
1968 | + if ($globalDebug) { |
|
1969 | + echo '...Arrival'."\n"; |
|
1970 | + } |
|
1741 | 1971 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1742 | 1972 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1743 | 1973 | foreach ($dall as $value) { |
@@ -1761,13 +1991,19 @@ discard block |
||
1761 | 1991 | $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']); |
1762 | 1992 | } |
1763 | 1993 | |
1764 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1765 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
1994 | + if ($globalDebug) { |
|
1995 | + echo 'Flights data...'."\n"; |
|
1996 | + } |
|
1997 | + if ($globalDebug) { |
|
1998 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
1999 | + } |
|
1766 | 2000 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1767 | 2001 | foreach ($alldata as $number) { |
1768 | 2002 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1769 | 2003 | } |
1770 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2004 | + if ($globalDebug) { |
|
2005 | + echo '-> countAllDates...'."\n"; |
|
2006 | + } |
|
1771 | 2007 | //$previousdata = $this->countAllDatesByAirlines(); |
1772 | 2008 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1773 | 2009 | $values = array(); |
@@ -1780,19 +2016,25 @@ discard block |
||
1780 | 2016 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1781 | 2017 | } |
1782 | 2018 | |
1783 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2019 | + if ($globalDebug) { |
|
2020 | + echo '-> countAllHours...'."\n"; |
|
2021 | + } |
|
1784 | 2022 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1785 | 2023 | foreach ($alldata as $number) { |
1786 | 2024 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
1787 | 2025 | } |
1788 | 2026 | |
1789 | 2027 | |
1790 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2028 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2029 | + $globalStatsFilters = array(); |
|
2030 | + } |
|
1791 | 2031 | foreach ($globalStatsFilters as $name => $filter) { |
1792 | 2032 | //$filter_name = $filter['name']; |
1793 | 2033 | $filter_name = $name; |
1794 | 2034 | // Count by filter |
1795 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2035 | + if ($globalDebug) { |
|
2036 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2037 | + } |
|
1796 | 2038 | $Spotter = new Spotter($this->db); |
1797 | 2039 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
1798 | 2040 | foreach ($alldata as $number) { |
@@ -1830,7 +2072,9 @@ discard block |
||
1830 | 2072 | $icao = $value['airport_departure_icao']; |
1831 | 2073 | if (isset($alldata[$icao])) { |
1832 | 2074 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1833 | - } else $alldata[$icao] = $value; |
|
2075 | + } else { |
|
2076 | + $alldata[$icao] = $value; |
|
2077 | + } |
|
1834 | 2078 | } |
1835 | 2079 | $count = array(); |
1836 | 2080 | foreach ($alldata as $key => $row) { |
@@ -1851,7 +2095,9 @@ discard block |
||
1851 | 2095 | $icao = $value['airport_arrival_icao']; |
1852 | 2096 | if (isset($alldata[$icao])) { |
1853 | 2097 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1854 | - } else $alldata[$icao] = $value; |
|
2098 | + } else { |
|
2099 | + $alldata[$icao] = $value; |
|
2100 | + } |
|
1855 | 2101 | } |
1856 | 2102 | $count = array(); |
1857 | 2103 | foreach ($alldata as $key => $row) { |
@@ -1865,7 +2111,9 @@ discard block |
||
1865 | 2111 | $alldata = $Spotter->countAllMonths($filter); |
1866 | 2112 | $lastyear = false; |
1867 | 2113 | foreach ($alldata as $number) { |
1868 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2114 | + if ($number['year_name'] != date('Y')) { |
|
2115 | + $lastyear = true; |
|
2116 | + } |
|
1869 | 2117 | $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); |
1870 | 2118 | } |
1871 | 2119 | $alldata = $Spotter->countAllMonthsOwners($filter); |