@@ -15,33 +15,33 @@ 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 | - } |
|
43 | - public function deleteStats($filter_name = '') { |
|
44 | - /* |
|
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 | + public function deleteStats($filter_name = '') { |
|
44 | + /* |
|
45 | 45 | $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
46 | 46 | try { |
47 | 47 | $sth = $this->db->prepare($query); |
@@ -50,62 +50,62 @@ discard block |
||
50 | 50 | return "error : ".$e->getMessage(); |
51 | 51 | } |
52 | 52 | */ |
53 | - $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
54 | - try { |
|
55 | - $sth = $this->db->prepare($query); |
|
56 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
57 | - } catch(PDOException $e) { |
|
58 | - return "error : ".$e->getMessage(); |
|
59 | - } |
|
60 | - } |
|
53 | + $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
54 | + try { |
|
55 | + $sth = $this->db->prepare($query); |
|
56 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
57 | + } catch(PDOException $e) { |
|
58 | + return "error : ".$e->getMessage(); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | public function getAllAirlineNames($filter_name = '') { |
62 | 62 | if ($filter_name == '') $filter_name = $this->filter_name; |
63 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
64 | - try { |
|
65 | - $sth = $this->db->prepare($query); |
|
66 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
67 | - } catch(PDOException $e) { |
|
68 | - echo "error : ".$e->getMessage(); |
|
69 | - } |
|
70 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
71 | - return $all; |
|
72 | - } |
|
63 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
64 | + try { |
|
65 | + $sth = $this->db->prepare($query); |
|
66 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
67 | + } catch(PDOException $e) { |
|
68 | + echo "error : ".$e->getMessage(); |
|
69 | + } |
|
70 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
71 | + return $all; |
|
72 | + } |
|
73 | 73 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
74 | 74 | if ($filter_name == '') $filter_name = $this->filter_name; |
75 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
76 | - try { |
|
77 | - $sth = $this->db->prepare($query); |
|
78 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
79 | - } catch(PDOException $e) { |
|
80 | - echo "error : ".$e->getMessage(); |
|
81 | - } |
|
82 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
83 | - return $all; |
|
84 | - } |
|
75 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
76 | + try { |
|
77 | + $sth = $this->db->prepare($query); |
|
78 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
79 | + } catch(PDOException $e) { |
|
80 | + echo "error : ".$e->getMessage(); |
|
81 | + } |
|
82 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
83 | + return $all; |
|
84 | + } |
|
85 | 85 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
86 | 86 | if ($filter_name == '') $filter_name = $this->filter_name; |
87 | - $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
|
88 | - try { |
|
89 | - $sth = $this->db->prepare($query); |
|
90 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
91 | - } catch(PDOException $e) { |
|
92 | - echo "error : ".$e->getMessage(); |
|
93 | - } |
|
94 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
95 | - return $all; |
|
96 | - } |
|
87 | + $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
|
88 | + try { |
|
89 | + $sth = $this->db->prepare($query); |
|
90 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
91 | + } catch(PDOException $e) { |
|
92 | + echo "error : ".$e->getMessage(); |
|
93 | + } |
|
94 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
95 | + return $all; |
|
96 | + } |
|
97 | 97 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
98 | 98 | if ($filter_name == '') $filter_name = $this->filter_name; |
99 | - $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"; |
|
100 | - try { |
|
101 | - $sth = $this->db->prepare($query); |
|
102 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
103 | - } catch(PDOException $e) { |
|
104 | - echo "error : ".$e->getMessage(); |
|
105 | - } |
|
106 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
107 | - return $all; |
|
108 | - } |
|
99 | + $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"; |
|
100 | + try { |
|
101 | + $sth = $this->db->prepare($query); |
|
102 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
103 | + } catch(PDOException $e) { |
|
104 | + echo "error : ".$e->getMessage(); |
|
105 | + } |
|
106 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
107 | + return $all; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | |
111 | 111 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -113,66 +113,66 @@ discard block |
||
113 | 113 | if ($filter_name == '') $filter_name = $this->filter_name; |
114 | 114 | 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"; |
115 | 115 | 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"; |
116 | - try { |
|
117 | - $sth = $this->db->prepare($query); |
|
118 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
119 | - } catch(PDOException $e) { |
|
120 | - echo "error : ".$e->getMessage(); |
|
121 | - } |
|
122 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
123 | - if (empty($all)) { |
|
124 | - $filters = array('airlines' => array($stats_airline)); |
|
125 | - if ($filter_name != '') { |
|
126 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
127 | - } |
|
128 | - $Spotter = new Spotter($this->db); |
|
129 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
130 | - } |
|
131 | - return $all; |
|
116 | + try { |
|
117 | + $sth = $this->db->prepare($query); |
|
118 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
119 | + } catch(PDOException $e) { |
|
120 | + echo "error : ".$e->getMessage(); |
|
121 | + } |
|
122 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
123 | + if (empty($all)) { |
|
124 | + $filters = array('airlines' => array($stats_airline)); |
|
125 | + if ($filter_name != '') { |
|
126 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
127 | + } |
|
128 | + $Spotter = new Spotter($this->db); |
|
129 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
130 | + } |
|
131 | + return $all; |
|
132 | 132 | } |
133 | 133 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
134 | 134 | global $globalStatsFilters; |
135 | 135 | if ($filter_name == '') $filter_name = $this->filter_name; |
136 | 136 | 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"; |
137 | 137 | 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"; |
138 | - try { |
|
139 | - $sth = $this->db->prepare($query); |
|
140 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
141 | - } catch(PDOException $e) { |
|
142 | - echo "error : ".$e->getMessage(); |
|
143 | - } |
|
144 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
145 | - if (empty($all)) { |
|
146 | - $Spotter = new Spotter($this->db); |
|
147 | - $filters = array(); |
|
148 | - if ($filter_name != '') { |
|
149 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
150 | - } |
|
151 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
152 | - } |
|
153 | - return $all; |
|
138 | + try { |
|
139 | + $sth = $this->db->prepare($query); |
|
140 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
141 | + } catch(PDOException $e) { |
|
142 | + echo "error : ".$e->getMessage(); |
|
143 | + } |
|
144 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
145 | + if (empty($all)) { |
|
146 | + $Spotter = new Spotter($this->db); |
|
147 | + $filters = array(); |
|
148 | + if ($filter_name != '') { |
|
149 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
150 | + } |
|
151 | + $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
152 | + } |
|
153 | + return $all; |
|
154 | 154 | } |
155 | 155 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
156 | 156 | global $globalStatsFilters; |
157 | 157 | if ($filter_name == '') $filter_name = $this->filter_name; |
158 | 158 | 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"; |
159 | 159 | 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"; |
160 | - try { |
|
161 | - $sth = $this->db->prepare($query); |
|
162 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
163 | - } catch(PDOException $e) { |
|
164 | - echo "error : ".$e->getMessage(); |
|
165 | - } |
|
166 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
167 | - if (empty($all)) { |
|
168 | - $filters = array('airlines' => array($stats_airline)); |
|
169 | - if ($filter_name != '') { |
|
170 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
160 | + try { |
|
161 | + $sth = $this->db->prepare($query); |
|
162 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
163 | + } catch(PDOException $e) { |
|
164 | + echo "error : ".$e->getMessage(); |
|
165 | + } |
|
166 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
167 | + if (empty($all)) { |
|
168 | + $filters = array('airlines' => array($stats_airline)); |
|
169 | + if ($filter_name != '') { |
|
170 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
171 | 171 | } |
172 | - $Spotter = new Spotter($this->db); |
|
172 | + $Spotter = new Spotter($this->db); |
|
173 | 173 | $all = $Spotter->countAllAircraftManufacturers($filters); |
174 | - } |
|
175 | - return $all; |
|
174 | + } |
|
175 | + return $all; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -180,44 +180,44 @@ discard block |
||
180 | 180 | if ($filter_name == '') $filter_name = $this->filter_name; |
181 | 181 | 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"; |
182 | 182 | 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"; |
183 | - try { |
|
184 | - $sth = $this->db->prepare($query); |
|
185 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
186 | - } catch(PDOException $e) { |
|
187 | - echo "error : ".$e->getMessage(); |
|
188 | - } |
|
189 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
190 | - if (empty($all)) { |
|
183 | + try { |
|
184 | + $sth = $this->db->prepare($query); |
|
185 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
186 | + } catch(PDOException $e) { |
|
187 | + echo "error : ".$e->getMessage(); |
|
188 | + } |
|
189 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
190 | + if (empty($all)) { |
|
191 | 191 | $filters = array('airlines' => array($stats_airline)); |
192 | 192 | if ($filter_name != '') { |
193 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
193 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
194 | 194 | } |
195 | 195 | $Spotter = new Spotter($this->db); |
196 | 196 | $all = $Spotter->countAllArrivalCountries($limit,$filters); |
197 | - } |
|
198 | - return $all; |
|
197 | + } |
|
198 | + return $all; |
|
199 | 199 | } |
200 | 200 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
201 | 201 | global $globalStatsFilters; |
202 | 202 | if ($filter_name == '') $filter_name = $this->filter_name; |
203 | 203 | 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"; |
204 | 204 | 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"; |
205 | - try { |
|
206 | - $sth = $this->db->prepare($query); |
|
207 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
208 | - } catch(PDOException $e) { |
|
209 | - echo "error : ".$e->getMessage(); |
|
210 | - } |
|
211 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
212 | - if (empty($all)) { |
|
205 | + try { |
|
206 | + $sth = $this->db->prepare($query); |
|
207 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
208 | + } catch(PDOException $e) { |
|
209 | + echo "error : ".$e->getMessage(); |
|
210 | + } |
|
211 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
212 | + if (empty($all)) { |
|
213 | 213 | $filters = array('airlines' => array($stats_airline)); |
214 | 214 | if ($filter_name != '') { |
215 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
215 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
216 | 216 | } |
217 | 217 | $Spotter = new Spotter($this->db); |
218 | 218 | $all = $Spotter->countAllDepartureCountries($filters); |
219 | - } |
|
220 | - return $all; |
|
219 | + } |
|
220 | + return $all; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | public function countAllAirlines($limit = true,$filter_name = '') { |
@@ -225,45 +225,45 @@ discard block |
||
225 | 225 | if ($filter_name == '') $filter_name = $this->filter_name; |
226 | 226 | 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"; |
227 | 227 | 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 | - try { |
|
229 | - $sth = $this->db->prepare($query); |
|
230 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
231 | - } catch(PDOException $e) { |
|
232 | - echo "error : ".$e->getMessage(); |
|
233 | - } |
|
234 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
235 | - if (empty($all)) { |
|
236 | - $Spotter = new Spotter($this->db); |
|
237 | - $filters = array(); |
|
238 | - if ($filter_name != '') { |
|
239 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
228 | + try { |
|
229 | + $sth = $this->db->prepare($query); |
|
230 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
231 | + } catch(PDOException $e) { |
|
232 | + echo "error : ".$e->getMessage(); |
|
233 | + } |
|
234 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
235 | + if (empty($all)) { |
|
236 | + $Spotter = new Spotter($this->db); |
|
237 | + $filters = array(); |
|
238 | + if ($filter_name != '') { |
|
239 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
240 | 240 | } |
241 | 241 | |
242 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
243 | - } |
|
244 | - return $all; |
|
242 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
243 | + } |
|
244 | + return $all; |
|
245 | 245 | } |
246 | 246 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
247 | 247 | global $globalStatsFilters; |
248 | 248 | if ($filter_name == '') $filter_name = $this->filter_name; |
249 | 249 | 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"; |
250 | 250 | 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"; |
251 | - try { |
|
252 | - $sth = $this->db->prepare($query); |
|
253 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
254 | - } catch(PDOException $e) { |
|
255 | - echo "error : ".$e->getMessage(); |
|
256 | - } |
|
257 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
258 | - if (empty($all)) { |
|
251 | + try { |
|
252 | + $sth = $this->db->prepare($query); |
|
253 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
254 | + } catch(PDOException $e) { |
|
255 | + echo "error : ".$e->getMessage(); |
|
256 | + } |
|
257 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
258 | + if (empty($all)) { |
|
259 | 259 | $filters = array('airlines' => array($stats_airline)); |
260 | 260 | if ($filter_name != '') { |
261 | 261 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
262 | 262 | } |
263 | - $Spotter = new Spotter($this->db); |
|
264 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
265 | - } |
|
266 | - return $all; |
|
263 | + $Spotter = new Spotter($this->db); |
|
264 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
265 | + } |
|
266 | + return $all; |
|
267 | 267 | } |
268 | 268 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
269 | 269 | global $globalStatsFilters; |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | echo "error : ".$e->getMessage(); |
301 | 301 | } |
302 | 302 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
303 | - /* |
|
303 | + /* |
|
304 | 304 | if (empty($all)) { |
305 | 305 | $Spotter = new Spotter($this->db); |
306 | 306 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -316,84 +316,84 @@ discard block |
||
316 | 316 | if ($filter_name == '') $filter_name = $this->filter_name; |
317 | 317 | if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
318 | 318 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
319 | - try { |
|
320 | - $sth = $this->db->prepare($query); |
|
321 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
322 | - } catch(PDOException $e) { |
|
323 | - echo "error : ".$e->getMessage(); |
|
324 | - } |
|
325 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
326 | - if (empty($all)) { |
|
319 | + try { |
|
320 | + $sth = $this->db->prepare($query); |
|
321 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
322 | + } catch(PDOException $e) { |
|
323 | + echo "error : ".$e->getMessage(); |
|
324 | + } |
|
325 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
326 | + if (empty($all)) { |
|
327 | 327 | $filters = array('airlines' => array($stats_airline)); |
328 | 328 | if ($filter_name != '') { |
329 | 329 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
330 | 330 | } |
331 | - $Spotter = new Spotter($this->db); |
|
332 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
333 | - } |
|
334 | - return $all; |
|
331 | + $Spotter = new Spotter($this->db); |
|
332 | + $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
333 | + } |
|
334 | + return $all; |
|
335 | 335 | } |
336 | 336 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
337 | 337 | global $globalStatsFilters; |
338 | 338 | if ($filter_name == '') $filter_name = $this->filter_name; |
339 | 339 | 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"; |
340 | 340 | 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"; |
341 | - try { |
|
342 | - $sth = $this->db->prepare($query); |
|
343 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
344 | - } catch(PDOException $e) { |
|
345 | - echo "error : ".$e->getMessage(); |
|
346 | - } |
|
347 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
348 | - if (empty($all)) { |
|
341 | + try { |
|
342 | + $sth = $this->db->prepare($query); |
|
343 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
344 | + } catch(PDOException $e) { |
|
345 | + echo "error : ".$e->getMessage(); |
|
346 | + } |
|
347 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
348 | + if (empty($all)) { |
|
349 | 349 | $filters = array('airlines' => array($stats_airline)); |
350 | 350 | if ($filter_name != '') { |
351 | 351 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
352 | 352 | } |
353 | - $Spotter = new Spotter($this->db); |
|
354 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
355 | - } |
|
356 | - return $all; |
|
353 | + $Spotter = new Spotter($this->db); |
|
354 | + $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
355 | + } |
|
356 | + return $all; |
|
357 | 357 | } |
358 | 358 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
359 | 359 | global $globalStatsFilters; |
360 | 360 | if ($filter_name == '') $filter_name = $this->filter_name; |
361 | 361 | 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"; |
362 | 362 | 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"; |
363 | - try { |
|
364 | - $sth = $this->db->prepare($query); |
|
365 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
366 | - } catch(PDOException $e) { |
|
367 | - echo "error : ".$e->getMessage(); |
|
368 | - } |
|
369 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
370 | - if (empty($all)) { |
|
363 | + try { |
|
364 | + $sth = $this->db->prepare($query); |
|
365 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
366 | + } catch(PDOException $e) { |
|
367 | + echo "error : ".$e->getMessage(); |
|
368 | + } |
|
369 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
370 | + if (empty($all)) { |
|
371 | 371 | $filters = array('airlines' => array($stats_airline)); |
372 | - if ($filter_name != '') { |
|
373 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
374 | - } |
|
375 | - $Spotter = new Spotter($this->db); |
|
376 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
377 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
378 | - $all = array(); |
|
379 | - foreach ($pall as $value) { |
|
380 | - $icao = $value['airport_departure_icao']; |
|
381 | - $all[$icao] = $value; |
|
382 | - } |
|
372 | + if ($filter_name != '') { |
|
373 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
374 | + } |
|
375 | + $Spotter = new Spotter($this->db); |
|
376 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
377 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
378 | + $all = array(); |
|
379 | + foreach ($pall as $value) { |
|
380 | + $icao = $value['airport_departure_icao']; |
|
381 | + $all[$icao] = $value; |
|
382 | + } |
|
383 | 383 | |
384 | - foreach ($dall as $value) { |
|
385 | - $icao = $value['airport_departure_icao']; |
|
386 | - if (isset($all[$icao])) { |
|
387 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
388 | - } else $all[$icao] = $value; |
|
389 | - } |
|
390 | - $count = array(); |
|
391 | - foreach ($all as $key => $row) { |
|
392 | - $count[$key] = $row['airport_departure_icao_count']; |
|
393 | - } |
|
394 | - array_multisort($count,SORT_DESC,$all); |
|
395 | - } |
|
396 | - return $all; |
|
384 | + foreach ($dall as $value) { |
|
385 | + $icao = $value['airport_departure_icao']; |
|
386 | + if (isset($all[$icao])) { |
|
387 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
388 | + } else $all[$icao] = $value; |
|
389 | + } |
|
390 | + $count = array(); |
|
391 | + foreach ($all as $key => $row) { |
|
392 | + $count[$key] = $row['airport_departure_icao_count']; |
|
393 | + } |
|
394 | + array_multisort($count,SORT_DESC,$all); |
|
395 | + } |
|
396 | + return $all; |
|
397 | 397 | } |
398 | 398 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
399 | 399 | global $globalStatsFilters; |
@@ -415,26 +415,26 @@ discard block |
||
415 | 415 | $Spotter = new Spotter($this->db); |
416 | 416 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
417 | 417 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
418 | - $all = array(); |
|
419 | - foreach ($pall as $value) { |
|
420 | - $icao = $value['airport_arrival_icao']; |
|
421 | - $all[$icao] = $value; |
|
422 | - } |
|
418 | + $all = array(); |
|
419 | + foreach ($pall as $value) { |
|
420 | + $icao = $value['airport_arrival_icao']; |
|
421 | + $all[$icao] = $value; |
|
422 | + } |
|
423 | 423 | |
424 | - foreach ($dall as $value) { |
|
425 | - $icao = $value['airport_arrival_icao']; |
|
426 | - if (isset($all[$icao])) { |
|
427 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
428 | - } else $all[$icao] = $value; |
|
429 | - } |
|
430 | - $count = array(); |
|
431 | - foreach ($all as $key => $row) { |
|
432 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
433 | - } |
|
434 | - array_multisort($count,SORT_DESC,$all); |
|
435 | - } |
|
424 | + foreach ($dall as $value) { |
|
425 | + $icao = $value['airport_arrival_icao']; |
|
426 | + if (isset($all[$icao])) { |
|
427 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
428 | + } else $all[$icao] = $value; |
|
429 | + } |
|
430 | + $count = array(); |
|
431 | + foreach ($all as $key => $row) { |
|
432 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
433 | + } |
|
434 | + array_multisort($count,SORT_DESC,$all); |
|
435 | + } |
|
436 | 436 | |
437 | - return $all; |
|
437 | + return $all; |
|
438 | 438 | } |
439 | 439 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
440 | 440 | global $globalDBdriver, $globalStatsFilters; |
@@ -447,23 +447,23 @@ discard block |
||
447 | 447 | 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"; |
448 | 448 | } |
449 | 449 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
450 | - try { |
|
451 | - $sth = $this->db->prepare($query); |
|
452 | - $sth->execute($query_data); |
|
453 | - } catch(PDOException $e) { |
|
454 | - echo "error : ".$e->getMessage(); |
|
455 | - } |
|
456 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
457 | - if (empty($all)) { |
|
450 | + try { |
|
451 | + $sth = $this->db->prepare($query); |
|
452 | + $sth->execute($query_data); |
|
453 | + } catch(PDOException $e) { |
|
454 | + echo "error : ".$e->getMessage(); |
|
455 | + } |
|
456 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
457 | + if (empty($all)) { |
|
458 | 458 | $filters = array('airlines' => array($stats_airline)); |
459 | 459 | if ($filter_name != '') { |
460 | 460 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
461 | 461 | } |
462 | - $Spotter = new Spotter($this->db); |
|
463 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
464 | - } |
|
462 | + $Spotter = new Spotter($this->db); |
|
463 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
464 | + } |
|
465 | 465 | |
466 | - return $all; |
|
466 | + return $all; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
@@ -471,22 +471,22 @@ discard block |
||
471 | 471 | if ($filter_name == '') $filter_name = $this->filter_name; |
472 | 472 | $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"; |
473 | 473 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
474 | - try { |
|
475 | - $sth = $this->db->prepare($query); |
|
476 | - $sth->execute($query_data); |
|
477 | - } catch(PDOException $e) { |
|
478 | - echo "error : ".$e->getMessage(); |
|
479 | - } |
|
480 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
481 | - if (empty($all)) { |
|
474 | + try { |
|
475 | + $sth = $this->db->prepare($query); |
|
476 | + $sth->execute($query_data); |
|
477 | + } catch(PDOException $e) { |
|
478 | + echo "error : ".$e->getMessage(); |
|
479 | + } |
|
480 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
481 | + if (empty($all)) { |
|
482 | 482 | $filters = array('airlines' => array($stats_airline)); |
483 | 483 | if ($filter_name != '') { |
484 | 484 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
485 | 485 | } |
486 | - $Spotter = new Spotter($this->db); |
|
487 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
488 | - } |
|
489 | - return $all; |
|
486 | + $Spotter = new Spotter($this->db); |
|
487 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
488 | + } |
|
489 | + return $all; |
|
490 | 490 | } |
491 | 491 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
492 | 492 | global $globalDBdriver, $globalStatsFilters; |
@@ -497,108 +497,108 @@ discard block |
||
497 | 497 | $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"; |
498 | 498 | } |
499 | 499 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
500 | - try { |
|
501 | - $sth = $this->db->prepare($query); |
|
502 | - $sth->execute($query_data); |
|
503 | - } catch(PDOException $e) { |
|
504 | - echo "error : ".$e->getMessage(); |
|
505 | - } |
|
506 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
507 | - if (empty($all)) { |
|
500 | + try { |
|
501 | + $sth = $this->db->prepare($query); |
|
502 | + $sth->execute($query_data); |
|
503 | + } catch(PDOException $e) { |
|
504 | + echo "error : ".$e->getMessage(); |
|
505 | + } |
|
506 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
507 | + if (empty($all)) { |
|
508 | 508 | $filters = array('airlines' => array($stats_airline)); |
509 | 509 | if ($filter_name != '') { |
510 | 510 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
511 | 511 | } |
512 | - $Spotter = new Spotter($this->db); |
|
513 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
514 | - } |
|
515 | - return $all; |
|
512 | + $Spotter = new Spotter($this->db); |
|
513 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
514 | + } |
|
515 | + return $all; |
|
516 | 516 | } |
517 | 517 | public function countAllDates($stats_airline = '',$filter_name = '') { |
518 | 518 | global $globalStatsFilters; |
519 | 519 | if ($filter_name == '') $filter_name = $this->filter_name; |
520 | 520 | $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"; |
521 | 521 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
522 | - try { |
|
523 | - $sth = $this->db->prepare($query); |
|
524 | - $sth->execute($query_data); |
|
525 | - } catch(PDOException $e) { |
|
526 | - echo "error : ".$e->getMessage(); |
|
527 | - } |
|
528 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
529 | - if (empty($all)) { |
|
522 | + try { |
|
523 | + $sth = $this->db->prepare($query); |
|
524 | + $sth->execute($query_data); |
|
525 | + } catch(PDOException $e) { |
|
526 | + echo "error : ".$e->getMessage(); |
|
527 | + } |
|
528 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
529 | + if (empty($all)) { |
|
530 | 530 | $filters = array('airlines' => array($stats_airline)); |
531 | 531 | if ($filter_name != '') { |
532 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
532 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
533 | 533 | } |
534 | - $Spotter = new Spotter($this->db); |
|
535 | - $all = $Spotter->countAllDates($filters); |
|
536 | - } |
|
537 | - return $all; |
|
534 | + $Spotter = new Spotter($this->db); |
|
535 | + $all = $Spotter->countAllDates($filters); |
|
536 | + } |
|
537 | + return $all; |
|
538 | 538 | } |
539 | 539 | public function countAllDatesByAirlines($filter_name = '') { |
540 | 540 | global $globalStatsFilters; |
541 | 541 | if ($filter_name == '') $filter_name = $this->filter_name; |
542 | 542 | $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"; |
543 | 543 | $query_data = array('filter_name' => $filter_name); |
544 | - try { |
|
545 | - $sth = $this->db->prepare($query); |
|
546 | - $sth->execute($query_data); |
|
547 | - } catch(PDOException $e) { |
|
548 | - echo "error : ".$e->getMessage(); |
|
549 | - } |
|
550 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
551 | - if (empty($all)) { |
|
552 | - $filters = array(); |
|
553 | - if ($filter_name != '') { |
|
554 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
555 | - } |
|
556 | - $Spotter = new Spotter($this->db); |
|
557 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
558 | - } |
|
559 | - return $all; |
|
544 | + try { |
|
545 | + $sth = $this->db->prepare($query); |
|
546 | + $sth->execute($query_data); |
|
547 | + } catch(PDOException $e) { |
|
548 | + echo "error : ".$e->getMessage(); |
|
549 | + } |
|
550 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
551 | + if (empty($all)) { |
|
552 | + $filters = array(); |
|
553 | + if ($filter_name != '') { |
|
554 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
555 | + } |
|
556 | + $Spotter = new Spotter($this->db); |
|
557 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
558 | + } |
|
559 | + return $all; |
|
560 | 560 | } |
561 | 561 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
562 | 562 | global $globalStatsFilters; |
563 | 563 | if ($filter_name == '') $filter_name = $this->filter_name; |
564 | - $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"; |
|
565 | - try { |
|
566 | - $sth = $this->db->prepare($query); |
|
567 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
568 | - } catch(PDOException $e) { |
|
569 | - echo "error : ".$e->getMessage(); |
|
570 | - } |
|
571 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
572 | - if (empty($all)) { |
|
564 | + $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"; |
|
565 | + try { |
|
566 | + $sth = $this->db->prepare($query); |
|
567 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
568 | + } catch(PDOException $e) { |
|
569 | + echo "error : ".$e->getMessage(); |
|
570 | + } |
|
571 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
572 | + if (empty($all)) { |
|
573 | 573 | $filters = array('airlines' => array($stats_airline)); |
574 | 574 | if ($filter_name != '') { |
575 | 575 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
576 | 576 | } |
577 | - $Spotter = new Spotter($this->db); |
|
578 | - $all = $Spotter->countAllMonths($filters); |
|
579 | - } |
|
580 | - return $all; |
|
577 | + $Spotter = new Spotter($this->db); |
|
578 | + $all = $Spotter->countAllMonths($filters); |
|
579 | + } |
|
580 | + return $all; |
|
581 | 581 | } |
582 | 582 | public function countAllMilitaryMonths($filter_name = '') { |
583 | 583 | global $globalStatsFilters; |
584 | 584 | if ($filter_name == '') $filter_name = $this->filter_name; |
585 | - $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"; |
|
586 | - try { |
|
587 | - $sth = $this->db->prepare($query); |
|
588 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
589 | - } catch(PDOException $e) { |
|
590 | - echo "error : ".$e->getMessage(); |
|
591 | - } |
|
592 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
593 | - if (empty($all)) { |
|
594 | - $filters = array(); |
|
595 | - if ($filter_name != '') { |
|
596 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
597 | - } |
|
598 | - $Spotter = new Spotter($this->db); |
|
599 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
600 | - } |
|
601 | - return $all; |
|
585 | + $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"; |
|
586 | + try { |
|
587 | + $sth = $this->db->prepare($query); |
|
588 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
589 | + } catch(PDOException $e) { |
|
590 | + echo "error : ".$e->getMessage(); |
|
591 | + } |
|
592 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
593 | + if (empty($all)) { |
|
594 | + $filters = array(); |
|
595 | + if ($filter_name != '') { |
|
596 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
597 | + } |
|
598 | + $Spotter = new Spotter($this->db); |
|
599 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
600 | + } |
|
601 | + return $all; |
|
602 | 602 | } |
603 | 603 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
604 | 604 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -614,22 +614,22 @@ discard block |
||
614 | 614 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
615 | 615 | } |
616 | 616 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
617 | - try { |
|
618 | - $sth = $this->db->prepare($query); |
|
619 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
620 | - } catch(PDOException $e) { |
|
621 | - echo "error : ".$e->getMessage(); |
|
622 | - } |
|
623 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
624 | - if (empty($all)) { |
|
617 | + try { |
|
618 | + $sth = $this->db->prepare($query); |
|
619 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
620 | + } catch(PDOException $e) { |
|
621 | + echo "error : ".$e->getMessage(); |
|
622 | + } |
|
623 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
624 | + if (empty($all)) { |
|
625 | 625 | $filters = array('airlines' => array($stats_airline)); |
626 | 626 | if ($filter_name != '') { |
627 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
627 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
628 | 628 | } |
629 | - $Spotter = new Spotter($this->db); |
|
630 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
631 | - } |
|
632 | - return $all; |
|
629 | + $Spotter = new Spotter($this->db); |
|
630 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
631 | + } |
|
632 | + return $all; |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | if ($filter_name == '') $filter_name = $this->filter_name; |
652 | 652 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
653 | 653 | if (empty($all)) { |
654 | - $filters = array(); |
|
655 | - if ($filter_name != '') { |
|
656 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
654 | + $filters = array(); |
|
655 | + if ($filter_name != '') { |
|
656 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
657 | 657 | } |
658 | 658 | $Spotter = new Spotter($this->db); |
659 | 659 | $all = $Spotter->countOverallMilitaryFlights($filters); |
@@ -692,19 +692,19 @@ discard block |
||
692 | 692 | global $globalStatsFilters; |
693 | 693 | if ($filter_name == '') $filter_name = $this->filter_name; |
694 | 694 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
695 | - try { |
|
696 | - $sth = $this->db->prepare($query); |
|
697 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
698 | - } catch(PDOException $e) { |
|
699 | - echo "error : ".$e->getMessage(); |
|
700 | - } |
|
701 | - $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
702 | - $all = $result[0]['nb_airline']; |
|
695 | + try { |
|
696 | + $sth = $this->db->prepare($query); |
|
697 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
698 | + } catch(PDOException $e) { |
|
699 | + echo "error : ".$e->getMessage(); |
|
700 | + } |
|
701 | + $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
702 | + $all = $result[0]['nb_airline']; |
|
703 | 703 | //$all = $this->getSumStats('airlines_bymonth',date('Y')); |
704 | 704 | if (empty($all)) { |
705 | - $filters = array(); |
|
706 | - if ($filter_name != '') { |
|
707 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
705 | + $filters = array(); |
|
706 | + if ($filter_name != '') { |
|
707 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
708 | 708 | } |
709 | 709 | $Spotter = new Spotter($this->db); |
710 | 710 | $all = $Spotter->countOverallAirlines($filters); |
@@ -755,166 +755,166 @@ discard block |
||
755 | 755 | if ($filter_name == '') $filter_name = $this->filter_name; |
756 | 756 | $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"; |
757 | 757 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
758 | - try { |
|
759 | - $sth = $this->db->prepare($query); |
|
760 | - $sth->execute($query_values); |
|
761 | - } catch(PDOException $e) { |
|
762 | - echo "error : ".$e->getMessage(); |
|
763 | - } |
|
764 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
765 | - return $all; |
|
758 | + try { |
|
759 | + $sth = $this->db->prepare($query); |
|
760 | + $sth->execute($query_values); |
|
761 | + } catch(PDOException $e) { |
|
762 | + echo "error : ".$e->getMessage(); |
|
763 | + } |
|
764 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
765 | + return $all; |
|
766 | 766 | } |
767 | 767 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
768 | 768 | if ($filter_name == '') $filter_name = $this->filter_name; |
769 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
770 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
771 | - try { |
|
772 | - $sth = $this->db->prepare($query); |
|
773 | - $sth->execute($query_values); |
|
774 | - } catch(PDOException $e) { |
|
775 | - echo "error : ".$e->getMessage(); |
|
776 | - } |
|
777 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
778 | - return $all; |
|
779 | - } |
|
769 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
770 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
771 | + try { |
|
772 | + $sth = $this->db->prepare($query); |
|
773 | + $sth->execute($query_values); |
|
774 | + } catch(PDOException $e) { |
|
775 | + echo "error : ".$e->getMessage(); |
|
776 | + } |
|
777 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
778 | + return $all; |
|
779 | + } |
|
780 | 780 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
781 | 781 | if ($filter_name == '') $filter_name = $this->filter_name; |
782 | - global $globalArchiveMonths, $globalDBdriver; |
|
783 | - if ($globalDBdriver == 'mysql') { |
|
784 | - $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"; |
|
785 | - } else { |
|
786 | - $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"; |
|
787 | - } |
|
788 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
789 | - try { |
|
790 | - $sth = $this->db->prepare($query); |
|
791 | - $sth->execute($query_values); |
|
792 | - } catch(PDOException $e) { |
|
793 | - echo "error : ".$e->getMessage(); |
|
794 | - } |
|
795 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
796 | - return $all[0]['total']; |
|
797 | - } |
|
782 | + global $globalArchiveMonths, $globalDBdriver; |
|
783 | + if ($globalDBdriver == 'mysql') { |
|
784 | + $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"; |
|
785 | + } else { |
|
786 | + $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"; |
|
787 | + } |
|
788 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
789 | + try { |
|
790 | + $sth = $this->db->prepare($query); |
|
791 | + $sth->execute($query_values); |
|
792 | + } catch(PDOException $e) { |
|
793 | + echo "error : ".$e->getMessage(); |
|
794 | + } |
|
795 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
796 | + return $all[0]['total']; |
|
797 | + } |
|
798 | 798 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
799 | - global $globalArchiveMonths, $globalDBdriver; |
|
799 | + global $globalArchiveMonths, $globalDBdriver; |
|
800 | 800 | if ($filter_name == '') $filter_name = $this->filter_name; |
801 | - if ($globalDBdriver == 'mysql') { |
|
801 | + if ($globalDBdriver == 'mysql') { |
|
802 | 802 | $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"; |
803 | 803 | } else { |
804 | 804 | $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"; |
805 | - } |
|
806 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
807 | - try { |
|
808 | - $sth = $this->db->prepare($query); |
|
809 | - $sth->execute($query_values); |
|
810 | - } catch(PDOException $e) { |
|
811 | - echo "error : ".$e->getMessage(); |
|
812 | - } |
|
813 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
814 | - return $all[0]['total']; |
|
815 | - } |
|
805 | + } |
|
806 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
807 | + try { |
|
808 | + $sth = $this->db->prepare($query); |
|
809 | + $sth->execute($query_values); |
|
810 | + } catch(PDOException $e) { |
|
811 | + echo "error : ".$e->getMessage(); |
|
812 | + } |
|
813 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
814 | + return $all[0]['total']; |
|
815 | + } |
|
816 | 816 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
817 | - global $globalArchiveMonths, $globalDBdriver; |
|
817 | + global $globalArchiveMonths, $globalDBdriver; |
|
818 | 818 | if ($filter_name == '') $filter_name = $this->filter_name; |
819 | - if ($globalDBdriver == 'mysql') { |
|
819 | + if ($globalDBdriver == 'mysql') { |
|
820 | 820 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
821 | - } else { |
|
821 | + } else { |
|
822 | 822 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
823 | - } |
|
824 | - try { |
|
825 | - $sth = $this->db->prepare($query); |
|
826 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
827 | - } catch(PDOException $e) { |
|
828 | - echo "error : ".$e->getMessage(); |
|
829 | - } |
|
830 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
831 | - return $all[0]['total']; |
|
832 | - } |
|
823 | + } |
|
824 | + try { |
|
825 | + $sth = $this->db->prepare($query); |
|
826 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
827 | + } catch(PDOException $e) { |
|
828 | + echo "error : ".$e->getMessage(); |
|
829 | + } |
|
830 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
831 | + return $all[0]['total']; |
|
832 | + } |
|
833 | 833 | public function getStatsAirlineTotal($filter_name = '') { |
834 | - global $globalArchiveMonths, $globalDBdriver; |
|
834 | + global $globalArchiveMonths, $globalDBdriver; |
|
835 | 835 | if ($filter_name == '') $filter_name = $this->filter_name; |
836 | - if ($globalDBdriver == 'mysql') { |
|
836 | + if ($globalDBdriver == 'mysql') { |
|
837 | 837 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
838 | - } else { |
|
838 | + } else { |
|
839 | 839 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
840 | - } |
|
841 | - try { |
|
842 | - $sth = $this->db->prepare($query); |
|
843 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
844 | - } catch(PDOException $e) { |
|
845 | - echo "error : ".$e->getMessage(); |
|
846 | - } |
|
847 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
848 | - return $all[0]['total']; |
|
849 | - } |
|
840 | + } |
|
841 | + try { |
|
842 | + $sth = $this->db->prepare($query); |
|
843 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
844 | + } catch(PDOException $e) { |
|
845 | + echo "error : ".$e->getMessage(); |
|
846 | + } |
|
847 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
848 | + return $all[0]['total']; |
|
849 | + } |
|
850 | 850 | public function getStatsOwnerTotal($filter_name = '') { |
851 | - global $globalArchiveMonths, $globalDBdriver; |
|
851 | + global $globalArchiveMonths, $globalDBdriver; |
|
852 | 852 | if ($filter_name == '') $filter_name = $this->filter_name; |
853 | - if ($globalDBdriver == 'mysql') { |
|
853 | + if ($globalDBdriver == 'mysql') { |
|
854 | 854 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
855 | 855 | } else { |
856 | 856 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
857 | - } |
|
858 | - try { |
|
859 | - $sth = $this->db->prepare($query); |
|
860 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
861 | - } catch(PDOException $e) { |
|
862 | - echo "error : ".$e->getMessage(); |
|
863 | - } |
|
864 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
865 | - return $all[0]['total']; |
|
866 | - } |
|
857 | + } |
|
858 | + try { |
|
859 | + $sth = $this->db->prepare($query); |
|
860 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
861 | + } catch(PDOException $e) { |
|
862 | + echo "error : ".$e->getMessage(); |
|
863 | + } |
|
864 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
865 | + return $all[0]['total']; |
|
866 | + } |
|
867 | 867 | public function getStatsPilotTotal($filter_name = '') { |
868 | - global $globalArchiveMonths, $globalDBdriver; |
|
868 | + global $globalArchiveMonths, $globalDBdriver; |
|
869 | 869 | if ($filter_name == '') $filter_name = $this->filter_name; |
870 | - if ($globalDBdriver == 'mysql') { |
|
871 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
872 | - } else { |
|
873 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
874 | - } |
|
875 | - try { |
|
876 | - $sth = $this->db->prepare($query); |
|
877 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
878 | - } catch(PDOException $e) { |
|
879 | - echo "error : ".$e->getMessage(); |
|
880 | - } |
|
881 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
882 | - return $all[0]['total']; |
|
883 | - } |
|
870 | + if ($globalDBdriver == 'mysql') { |
|
871 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
872 | + } else { |
|
873 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
874 | + } |
|
875 | + try { |
|
876 | + $sth = $this->db->prepare($query); |
|
877 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
878 | + } catch(PDOException $e) { |
|
879 | + echo "error : ".$e->getMessage(); |
|
880 | + } |
|
881 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
882 | + return $all[0]['total']; |
|
883 | + } |
|
884 | 884 | |
885 | 885 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
886 | 886 | global $globalDBdriver; |
887 | 887 | if ($filter_name == '') $filter_name = $this->filter_name; |
888 | 888 | if ($globalDBdriver == 'mysql') { |
889 | 889 | $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"; |
890 | - } else { |
|
890 | + } else { |
|
891 | 891 | $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);"; |
892 | 892 | } |
893 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
894 | - try { |
|
895 | - $sth = $this->db->prepare($query); |
|
896 | - $sth->execute($query_values); |
|
897 | - } catch(PDOException $e) { |
|
898 | - return "error : ".$e->getMessage(); |
|
899 | - } |
|
900 | - } |
|
893 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
894 | + try { |
|
895 | + $sth = $this->db->prepare($query); |
|
896 | + $sth->execute($query_values); |
|
897 | + } catch(PDOException $e) { |
|
898 | + return "error : ".$e->getMessage(); |
|
899 | + } |
|
900 | + } |
|
901 | 901 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
902 | 902 | global $globalDBdriver; |
903 | 903 | if ($filter_name == '') $filter_name = $this->filter_name; |
904 | 904 | if ($globalDBdriver == 'mysql') { |
905 | 905 | $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"; |
906 | 906 | } else { |
907 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
907 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
908 | 908 | $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);"; |
909 | - } |
|
910 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
911 | - try { |
|
912 | - $sth = $this->db->prepare($query); |
|
913 | - $sth->execute($query_values); |
|
914 | - } catch(PDOException $e) { |
|
915 | - return "error : ".$e->getMessage(); |
|
916 | - } |
|
917 | - } |
|
909 | + } |
|
910 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
911 | + try { |
|
912 | + $sth = $this->db->prepare($query); |
|
913 | + $sth->execute($query_values); |
|
914 | + } catch(PDOException $e) { |
|
915 | + return "error : ".$e->getMessage(); |
|
916 | + } |
|
917 | + } |
|
918 | 918 | public function getStatsSource($date,$stats_type = '') { |
919 | 919 | if ($stats_type == '') { |
920 | 920 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -923,15 +923,15 @@ discard block |
||
923 | 923 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
924 | 924 | $query_values = array(':date' => $date,':stats_type' => $stats_type); |
925 | 925 | } |
926 | - try { |
|
927 | - $sth = $this->db->prepare($query); |
|
928 | - $sth->execute($query_values); |
|
929 | - } catch(PDOException $e) { |
|
930 | - echo "error : ".$e->getMessage(); |
|
931 | - } |
|
932 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
933 | - return $all; |
|
934 | - } |
|
926 | + try { |
|
927 | + $sth = $this->db->prepare($query); |
|
928 | + $sth->execute($query_values); |
|
929 | + } catch(PDOException $e) { |
|
930 | + echo "error : ".$e->getMessage(); |
|
931 | + } |
|
932 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
933 | + return $all; |
|
934 | + } |
|
935 | 935 | |
936 | 936 | public function addStatSource($data,$source_name,$stats_type,$date) { |
937 | 937 | global $globalDBdriver; |
@@ -939,25 +939,25 @@ discard block |
||
939 | 939 | $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"; |
940 | 940 | } else { |
941 | 941 | $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);"; |
942 | - } |
|
943 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
944 | - try { |
|
945 | - $sth = $this->db->prepare($query); |
|
946 | - $sth->execute($query_values); |
|
947 | - } catch(PDOException $e) { |
|
948 | - return "error : ".$e->getMessage(); |
|
949 | - } |
|
950 | - } |
|
942 | + } |
|
943 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
944 | + try { |
|
945 | + $sth = $this->db->prepare($query); |
|
946 | + $sth->execute($query_values); |
|
947 | + } catch(PDOException $e) { |
|
948 | + return "error : ".$e->getMessage(); |
|
949 | + } |
|
950 | + } |
|
951 | 951 | public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
952 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
953 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':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 | - } |
|
952 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
953 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':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 addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$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_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);"; |
967 | 967 | } |
968 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':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(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':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 addStatCallsign($callsign_icao,$cnt,$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_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);"; |
982 | 982 | } |
983 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':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(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':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 addStatCountry($iso2,$iso3,$name,$cnt,$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_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);"; |
997 | 997 | } |
998 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $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(':iso2' => $iso2,':iso3' => $iso3,':name' => $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 addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $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_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);"; |
1012 | 1012 | } |
1013 | - $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); |
|
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(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':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 addStatAirline($airline_icao,$cnt,$airline_name = '',$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_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);"; |
1027 | 1027 | } |
1028 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':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(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':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 addStatOwner($owner_name,$cnt,$stats_airline = '', $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_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);"; |
1042 | 1042 | } |
1043 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':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(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':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 addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '') { |
1052 | 1052 | global $globalDBdriver; |
1053 | 1053 | if ($globalDBdriver == 'mysql') { |
@@ -1055,14 +1055,14 @@ discard block |
||
1055 | 1055 | } else { |
1056 | 1056 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1057 | 1057 | } |
1058 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
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(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
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 addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$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 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);"; |
1072 | 1072 | } |
1073 | - $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); |
|
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,':departure' => $departure,':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 addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1082 | 1082 | global $globalDBdriver; |
1083 | 1083 | if ($globalDBdriver == 'mysql') { |
@@ -1085,14 +1085,14 @@ discard block |
||
1085 | 1085 | } else { |
1086 | 1086 | $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);"; |
1087 | 1087 | } |
1088 | - $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); |
|
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,':departure' => $departure,':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 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1097 | 1097 | global $globalDBdriver; |
1098 | 1098 | if ($globalDBdriver == 'mysql') { |
@@ -1100,14 +1100,14 @@ discard block |
||
1100 | 1100 | } else { |
1101 | 1101 | $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);"; |
1102 | 1102 | } |
1103 | - $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); |
|
1104 | - try { |
|
1105 | - $sth = $this->db->prepare($query); |
|
1106 | - $sth->execute($query_values); |
|
1107 | - } catch(PDOException $e) { |
|
1108 | - return "error : ".$e->getMessage(); |
|
1109 | - } |
|
1110 | - } |
|
1103 | + $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); |
|
1104 | + try { |
|
1105 | + $sth = $this->db->prepare($query); |
|
1106 | + $sth->execute($query_values); |
|
1107 | + } catch(PDOException $e) { |
|
1108 | + return "error : ".$e->getMessage(); |
|
1109 | + } |
|
1110 | + } |
|
1111 | 1111 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1112 | 1112 | global $globalDBdriver; |
1113 | 1113 | if ($globalDBdriver == 'mysql') { |
@@ -1115,52 +1115,52 @@ discard block |
||
1115 | 1115 | } else { |
1116 | 1116 | $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);"; |
1117 | 1117 | } |
1118 | - $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); |
|
1119 | - try { |
|
1120 | - $sth = $this->db->prepare($query); |
|
1121 | - $sth->execute($query_values); |
|
1122 | - } catch(PDOException $e) { |
|
1123 | - return "error : ".$e->getMessage(); |
|
1124 | - } |
|
1125 | - } |
|
1118 | + $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); |
|
1119 | + try { |
|
1120 | + $sth = $this->db->prepare($query); |
|
1121 | + $sth->execute($query_values); |
|
1122 | + } catch(PDOException $e) { |
|
1123 | + return "error : ".$e->getMessage(); |
|
1124 | + } |
|
1125 | + } |
|
1126 | 1126 | |
1127 | 1127 | public function deleteStat($id) { |
1128 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1129 | - $query_values = array(':id' => $id); |
|
1130 | - try { |
|
1131 | - $sth = $this->db->prepare($query); |
|
1132 | - $sth->execute($query_values); |
|
1133 | - } catch(PDOException $e) { |
|
1134 | - return "error : ".$e->getMessage(); |
|
1135 | - } |
|
1136 | - } |
|
1128 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1129 | + $query_values = array(':id' => $id); |
|
1130 | + try { |
|
1131 | + $sth = $this->db->prepare($query); |
|
1132 | + $sth->execute($query_values); |
|
1133 | + } catch(PDOException $e) { |
|
1134 | + return "error : ".$e->getMessage(); |
|
1135 | + } |
|
1136 | + } |
|
1137 | 1137 | public function deleteStatFlight($type) { |
1138 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1139 | - $query_values = array(':type' => $type); |
|
1140 | - try { |
|
1141 | - $sth = $this->db->prepare($query); |
|
1142 | - $sth->execute($query_values); |
|
1143 | - } catch(PDOException $e) { |
|
1144 | - return "error : ".$e->getMessage(); |
|
1145 | - } |
|
1146 | - } |
|
1138 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1139 | + $query_values = array(':type' => $type); |
|
1140 | + try { |
|
1141 | + $sth = $this->db->prepare($query); |
|
1142 | + $sth->execute($query_values); |
|
1143 | + } catch(PDOException $e) { |
|
1144 | + return "error : ".$e->getMessage(); |
|
1145 | + } |
|
1146 | + } |
|
1147 | 1147 | public function deleteStatAirport($type) { |
1148 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1149 | - $query_values = array(':type' => $type); |
|
1150 | - try { |
|
1151 | - $sth = $this->db->prepare($query); |
|
1152 | - $sth->execute($query_values); |
|
1153 | - } catch(PDOException $e) { |
|
1154 | - return "error : ".$e->getMessage(); |
|
1155 | - } |
|
1156 | - } |
|
1148 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1149 | + $query_values = array(':type' => $type); |
|
1150 | + try { |
|
1151 | + $sth = $this->db->prepare($query); |
|
1152 | + $sth->execute($query_values); |
|
1153 | + } catch(PDOException $e) { |
|
1154 | + return "error : ".$e->getMessage(); |
|
1155 | + } |
|
1156 | + } |
|
1157 | 1157 | |
1158 | - public function addOldStats() { |
|
1159 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters; |
|
1160 | - $Common = new Common(); |
|
1161 | - $Connection = new Connection(); |
|
1162 | - date_default_timezone_set('UTC'); |
|
1163 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1158 | + public function addOldStats() { |
|
1159 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters; |
|
1160 | + $Common = new Common(); |
|
1161 | + $Connection = new Connection(); |
|
1162 | + date_default_timezone_set('UTC'); |
|
1163 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1164 | 1164 | //print_r($last_update); |
1165 | 1165 | /* |
1166 | 1166 | $flightsbymonth = $this->getStats('flights_by_month'); |
@@ -1422,24 +1422,24 @@ discard block |
||
1422 | 1422 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1423 | 1423 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1424 | 1424 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1425 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1425 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1426 | 1426 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1427 | - $alldata = array(); |
|
1427 | + $alldata = array(); |
|
1428 | 1428 | |
1429 | - foreach ($pall as $value) { |
|
1430 | - $icao = $value['airport_departure_icao']; |
|
1431 | - $alldata[$icao] = $value; |
|
1432 | - } |
|
1433 | - foreach ($dall as $value) { |
|
1434 | - $icao = $value['airport_departure_icao']; |
|
1435 | - if (isset($alldata[$icao])) { |
|
1436 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1437 | - } else $alldata[$icao] = $value; |
|
1438 | - } |
|
1439 | - $count = array(); |
|
1440 | - foreach ($alldata as $key => $row) { |
|
1441 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1442 | - } |
|
1429 | + foreach ($pall as $value) { |
|
1430 | + $icao = $value['airport_departure_icao']; |
|
1431 | + $alldata[$icao] = $value; |
|
1432 | + } |
|
1433 | + foreach ($dall as $value) { |
|
1434 | + $icao = $value['airport_departure_icao']; |
|
1435 | + if (isset($alldata[$icao])) { |
|
1436 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1437 | + } else $alldata[$icao] = $value; |
|
1438 | + } |
|
1439 | + $count = array(); |
|
1440 | + foreach ($alldata as $key => $row) { |
|
1441 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1442 | + } |
|
1443 | 1443 | array_multisort($count,SORT_DESC,$alldata); |
1444 | 1444 | foreach ($alldata as $number) { |
1445 | 1445 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
@@ -1447,25 +1447,25 @@ discard block |
||
1447 | 1447 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1448 | 1448 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1449 | 1449 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1450 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1450 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1451 | 1451 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1452 | - $alldata = array(); |
|
1453 | - foreach ($pall as $value) { |
|
1454 | - $icao = $value['airport_arrival_icao']; |
|
1455 | - $alldata[$icao] = $value; |
|
1456 | - } |
|
1457 | - foreach ($dall as $value) { |
|
1458 | - $icao = $value['airport_arrival_icao']; |
|
1459 | - if (isset($alldata[$icao])) { |
|
1460 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1461 | - } else $alldata[$icao] = $value; |
|
1462 | - } |
|
1463 | - $count = array(); |
|
1464 | - foreach ($alldata as $key => $row) { |
|
1465 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1466 | - } |
|
1467 | - array_multisort($count,SORT_DESC,$alldata); |
|
1468 | - foreach ($alldata as $number) { |
|
1452 | + $alldata = array(); |
|
1453 | + foreach ($pall as $value) { |
|
1454 | + $icao = $value['airport_arrival_icao']; |
|
1455 | + $alldata[$icao] = $value; |
|
1456 | + } |
|
1457 | + foreach ($dall as $value) { |
|
1458 | + $icao = $value['airport_arrival_icao']; |
|
1459 | + if (isset($alldata[$icao])) { |
|
1460 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1461 | + } else $alldata[$icao] = $value; |
|
1462 | + } |
|
1463 | + $count = array(); |
|
1464 | + foreach ($alldata as $key => $row) { |
|
1465 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1466 | + } |
|
1467 | + array_multisort($count,SORT_DESC,$alldata); |
|
1468 | + foreach ($alldata as $number) { |
|
1469 | 1469 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1470 | 1470 | } |
1471 | 1471 | if ($Connection->tableExists('countries')) { |
@@ -1525,8 +1525,8 @@ discard block |
||
1525 | 1525 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1526 | 1526 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
1527 | 1527 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1528 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1529 | - /* |
|
1528 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1529 | + /* |
|
1530 | 1530 | $alldata = array(); |
1531 | 1531 | foreach ($pall as $value) { |
1532 | 1532 | $icao = $value['departure_airport_icao']; |
@@ -1545,29 +1545,29 @@ discard block |
||
1545 | 1545 | } |
1546 | 1546 | array_multisort($count,SORT_DESC,$alldata); |
1547 | 1547 | */ |
1548 | - foreach ($dall as $value) { |
|
1549 | - $icao = $value['departure_airport_icao']; |
|
1550 | - $ddate = $value['date']; |
|
1551 | - $find = false; |
|
1552 | - foreach ($pall as $pvalue) { |
|
1553 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1554 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1555 | - $find = true; |
|
1556 | - break; |
|
1557 | - } |
|
1558 | - } |
|
1559 | - if ($find === false) { |
|
1560 | - $pall[] = $value; |
|
1561 | - } |
|
1562 | - } |
|
1563 | - $alldata = $pall; |
|
1548 | + foreach ($dall as $value) { |
|
1549 | + $icao = $value['departure_airport_icao']; |
|
1550 | + $ddate = $value['date']; |
|
1551 | + $find = false; |
|
1552 | + foreach ($pall as $pvalue) { |
|
1553 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1554 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1555 | + $find = true; |
|
1556 | + break; |
|
1557 | + } |
|
1558 | + } |
|
1559 | + if ($find === false) { |
|
1560 | + $pall[] = $value; |
|
1561 | + } |
|
1562 | + } |
|
1563 | + $alldata = $pall; |
|
1564 | 1564 | foreach ($alldata as $number) { |
1565 | 1565 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
1566 | 1566 | } |
1567 | 1567 | echo '...Arrival'."\n"; |
1568 | 1568 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
1569 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1570 | - /* |
|
1569 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1570 | + /* |
|
1571 | 1571 | $alldata = array(); |
1572 | 1572 | foreach ($pall as $value) { |
1573 | 1573 | $icao = $value['arrival_airport_icao']; |
@@ -1587,22 +1587,22 @@ discard block |
||
1587 | 1587 | */ |
1588 | 1588 | |
1589 | 1589 | |
1590 | - foreach ($dall as $value) { |
|
1591 | - $icao = $value['arrival_airport_icao']; |
|
1592 | - $ddate = $value['date']; |
|
1593 | - $find = false; |
|
1594 | - foreach ($pall as $pvalue) { |
|
1595 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1596 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1597 | - $find = true; |
|
1598 | - break; |
|
1599 | - } |
|
1600 | - } |
|
1601 | - if ($find === false) { |
|
1602 | - $pall[] = $value; |
|
1603 | - } |
|
1604 | - } |
|
1605 | - $alldata = $pall; |
|
1590 | + foreach ($dall as $value) { |
|
1591 | + $icao = $value['arrival_airport_icao']; |
|
1592 | + $ddate = $value['date']; |
|
1593 | + $find = false; |
|
1594 | + foreach ($pall as $pvalue) { |
|
1595 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1596 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1597 | + $find = true; |
|
1598 | + break; |
|
1599 | + } |
|
1600 | + } |
|
1601 | + if ($find === false) { |
|
1602 | + $pall[] = $value; |
|
1603 | + } |
|
1604 | + } |
|
1605 | + $alldata = $pall; |
|
1606 | 1606 | foreach ($alldata as $number) { |
1607 | 1607 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
1608 | 1608 | } |
@@ -1669,51 +1669,51 @@ discard block |
||
1669 | 1669 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1670 | 1670 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1671 | 1671 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1672 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1672 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1673 | 1673 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1674 | - //$alldata = array(); |
|
1675 | - foreach ($dall as $value) { |
|
1676 | - $icao = $value['airport_departure_icao']; |
|
1677 | - $dicao = $value['airline_icao']; |
|
1678 | - $find = false; |
|
1679 | - foreach ($pall as $pvalue) { |
|
1680 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1681 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1682 | - $find = true; |
|
1683 | - break; |
|
1684 | - } |
|
1685 | - } |
|
1686 | - if ($find === false) { |
|
1687 | - $pall[] = $value; |
|
1688 | - } |
|
1689 | - } |
|
1690 | - $alldata = $pall; |
|
1674 | + //$alldata = array(); |
|
1675 | + foreach ($dall as $value) { |
|
1676 | + $icao = $value['airport_departure_icao']; |
|
1677 | + $dicao = $value['airline_icao']; |
|
1678 | + $find = false; |
|
1679 | + foreach ($pall as $pvalue) { |
|
1680 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1681 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1682 | + $find = true; |
|
1683 | + break; |
|
1684 | + } |
|
1685 | + } |
|
1686 | + if ($find === false) { |
|
1687 | + $pall[] = $value; |
|
1688 | + } |
|
1689 | + } |
|
1690 | + $alldata = $pall; |
|
1691 | 1691 | foreach ($alldata as $number) { |
1692 | 1692 | 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']); |
1693 | 1693 | } |
1694 | 1694 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1695 | 1695 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1696 | 1696 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1697 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1697 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1698 | 1698 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1699 | - //$alldata = array(); |
|
1700 | - foreach ($dall as $value) { |
|
1701 | - $icao = $value['airport_arrival_icao']; |
|
1702 | - $dicao = $value['airline_icao']; |
|
1703 | - $find = false; |
|
1704 | - foreach ($pall as $pvalue) { |
|
1705 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1706 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1707 | - $find = true; |
|
1708 | - break; |
|
1709 | - } |
|
1710 | - } |
|
1711 | - if ($find === false) { |
|
1712 | - $pall[] = $value; |
|
1713 | - } |
|
1714 | - } |
|
1715 | - $alldata = $pall; |
|
1716 | - foreach ($alldata as $number) { |
|
1699 | + //$alldata = array(); |
|
1700 | + foreach ($dall as $value) { |
|
1701 | + $icao = $value['airport_arrival_icao']; |
|
1702 | + $dicao = $value['airline_icao']; |
|
1703 | + $find = false; |
|
1704 | + foreach ($pall as $pvalue) { |
|
1705 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1706 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1707 | + $find = true; |
|
1708 | + break; |
|
1709 | + } |
|
1710 | + } |
|
1711 | + if ($find === false) { |
|
1712 | + $pall[] = $value; |
|
1713 | + } |
|
1714 | + } |
|
1715 | + $alldata = $pall; |
|
1716 | + foreach ($alldata as $number) { |
|
1717 | 1717 | 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']); |
1718 | 1718 | } |
1719 | 1719 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
@@ -1746,47 +1746,47 @@ discard block |
||
1746 | 1746 | } |
1747 | 1747 | if ($globalDebug) echo '...Departure'."\n"; |
1748 | 1748 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1749 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1750 | - foreach ($dall as $value) { |
|
1751 | - $icao = $value['departure_airport_icao']; |
|
1752 | - $airline = $value['airline_icao']; |
|
1753 | - $ddate = $value['date']; |
|
1754 | - $find = false; |
|
1755 | - foreach ($pall as $pvalue) { |
|
1756 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1757 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1758 | - $find = true; |
|
1759 | - break; |
|
1760 | - } |
|
1761 | - } |
|
1762 | - if ($find === false) { |
|
1763 | - $pall[] = $value; |
|
1764 | - } |
|
1765 | - } |
|
1766 | - $alldata = $pall; |
|
1749 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1750 | + foreach ($dall as $value) { |
|
1751 | + $icao = $value['departure_airport_icao']; |
|
1752 | + $airline = $value['airline_icao']; |
|
1753 | + $ddate = $value['date']; |
|
1754 | + $find = false; |
|
1755 | + foreach ($pall as $pvalue) { |
|
1756 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1757 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1758 | + $find = true; |
|
1759 | + break; |
|
1760 | + } |
|
1761 | + } |
|
1762 | + if ($find === false) { |
|
1763 | + $pall[] = $value; |
|
1764 | + } |
|
1765 | + } |
|
1766 | + $alldata = $pall; |
|
1767 | 1767 | foreach ($alldata as $number) { |
1768 | 1768 | $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']); |
1769 | 1769 | } |
1770 | 1770 | if ($globalDebug) echo '...Arrival'."\n"; |
1771 | 1771 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1772 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1773 | - foreach ($dall as $value) { |
|
1774 | - $icao = $value['arrival_airport_icao']; |
|
1775 | - $airline = $value['airline_icao']; |
|
1776 | - $ddate = $value['date']; |
|
1777 | - $find = false; |
|
1778 | - foreach ($pall as $pvalue) { |
|
1779 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1780 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1781 | - $find = true; |
|
1782 | - break; |
|
1783 | - } |
|
1784 | - } |
|
1785 | - if ($find === false) { |
|
1786 | - $pall[] = $value; |
|
1787 | - } |
|
1788 | - } |
|
1789 | - $alldata = $pall; |
|
1772 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1773 | + foreach ($dall as $value) { |
|
1774 | + $icao = $value['arrival_airport_icao']; |
|
1775 | + $airline = $value['airline_icao']; |
|
1776 | + $ddate = $value['date']; |
|
1777 | + $find = false; |
|
1778 | + foreach ($pall as $pvalue) { |
|
1779 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1780 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1781 | + $find = true; |
|
1782 | + break; |
|
1783 | + } |
|
1784 | + } |
|
1785 | + if ($find === false) { |
|
1786 | + $pall[] = $value; |
|
1787 | + } |
|
1788 | + } |
|
1789 | + $alldata = $pall; |
|
1790 | 1790 | foreach ($alldata as $number) { |
1791 | 1791 | $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']); |
1792 | 1792 | } |
@@ -1856,44 +1856,44 @@ discard block |
||
1856 | 1856 | } |
1857 | 1857 | |
1858 | 1858 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
1859 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1860 | - $alldata = array(); |
|
1861 | - foreach ($pall as $value) { |
|
1862 | - $icao = $value['airport_departure_icao']; |
|
1863 | - $alldata[$icao] = $value; |
|
1864 | - } |
|
1865 | - foreach ($dall as $value) { |
|
1866 | - $icao = $value['airport_departure_icao']; |
|
1867 | - if (isset($alldata[$icao])) { |
|
1868 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1869 | - } else $alldata[$icao] = $value; |
|
1870 | - } |
|
1871 | - $count = array(); |
|
1872 | - foreach ($alldata as $key => $row) { |
|
1873 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1874 | - } |
|
1859 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1860 | + $alldata = array(); |
|
1861 | + foreach ($pall as $value) { |
|
1862 | + $icao = $value['airport_departure_icao']; |
|
1863 | + $alldata[$icao] = $value; |
|
1864 | + } |
|
1865 | + foreach ($dall as $value) { |
|
1866 | + $icao = $value['airport_departure_icao']; |
|
1867 | + if (isset($alldata[$icao])) { |
|
1868 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1869 | + } else $alldata[$icao] = $value; |
|
1870 | + } |
|
1871 | + $count = array(); |
|
1872 | + foreach ($alldata as $key => $row) { |
|
1873 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1874 | + } |
|
1875 | 1875 | array_multisort($count,SORT_DESC,$alldata); |
1876 | 1876 | foreach ($alldata as $number) { |
1877 | - 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); |
|
1877 | + 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); |
|
1878 | 1878 | } |
1879 | 1879 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter); |
1880 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1880 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1881 | 1881 | $alldata = array(); |
1882 | - foreach ($pall as $value) { |
|
1883 | - $icao = $value['airport_arrival_icao']; |
|
1884 | - $alldata[$icao] = $value; |
|
1885 | - } |
|
1886 | - foreach ($dall as $value) { |
|
1887 | - $icao = $value['airport_arrival_icao']; |
|
1888 | - if (isset($alldata[$icao])) { |
|
1889 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1890 | - } else $alldata[$icao] = $value; |
|
1891 | - } |
|
1892 | - $count = array(); |
|
1893 | - foreach ($alldata as $key => $row) { |
|
1894 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1895 | - } |
|
1896 | - array_multisort($count,SORT_DESC,$alldata); |
|
1882 | + foreach ($pall as $value) { |
|
1883 | + $icao = $value['airport_arrival_icao']; |
|
1884 | + $alldata[$icao] = $value; |
|
1885 | + } |
|
1886 | + foreach ($dall as $value) { |
|
1887 | + $icao = $value['airport_arrival_icao']; |
|
1888 | + if (isset($alldata[$icao])) { |
|
1889 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1890 | + } else $alldata[$icao] = $value; |
|
1891 | + } |
|
1892 | + $count = array(); |
|
1893 | + foreach ($alldata as $key => $row) { |
|
1894 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1895 | + } |
|
1896 | + array_multisort($count,SORT_DESC,$alldata); |
|
1897 | 1897 | foreach ($alldata as $number) { |
1898 | 1898 | 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); |
1899 | 1899 | } |
@@ -1922,45 +1922,45 @@ discard block |
||
1922 | 1922 | } |
1923 | 1923 | echo '...Departure'."\n"; |
1924 | 1924 | $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
1925 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1925 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1926 | 1926 | foreach ($dall as $value) { |
1927 | - $icao = $value['departure_airport_icao']; |
|
1928 | - $ddate = $value['date']; |
|
1929 | - $find = false; |
|
1930 | - foreach ($pall as $pvalue) { |
|
1931 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1932 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1933 | - $find = true; |
|
1934 | - break; |
|
1935 | - } |
|
1936 | - } |
|
1937 | - if ($find === false) { |
|
1938 | - $pall[] = $value; |
|
1939 | - } |
|
1940 | - } |
|
1941 | - $alldata = $pall; |
|
1927 | + $icao = $value['departure_airport_icao']; |
|
1928 | + $ddate = $value['date']; |
|
1929 | + $find = false; |
|
1930 | + foreach ($pall as $pvalue) { |
|
1931 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1932 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1933 | + $find = true; |
|
1934 | + break; |
|
1935 | + } |
|
1936 | + } |
|
1937 | + if ($find === false) { |
|
1938 | + $pall[] = $value; |
|
1939 | + } |
|
1940 | + } |
|
1941 | + $alldata = $pall; |
|
1942 | 1942 | foreach ($alldata as $number) { |
1943 | 1943 | $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); |
1944 | 1944 | } |
1945 | 1945 | echo '...Arrival'."\n"; |
1946 | 1946 | $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
1947 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1947 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1948 | 1948 | foreach ($dall as $value) { |
1949 | 1949 | $icao = $value['arrival_airport_icao']; |
1950 | 1950 | $ddate = $value['date']; |
1951 | - $find = false; |
|
1951 | + $find = false; |
|
1952 | 1952 | foreach ($pall as $pvalue) { |
1953 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1954 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1955 | - $find = true; |
|
1956 | - break; |
|
1957 | - } |
|
1958 | - } |
|
1959 | - if ($find === false) { |
|
1960 | - $pall[] = $value; |
|
1961 | - } |
|
1962 | - } |
|
1963 | - $alldata = $pall; |
|
1953 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1954 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1955 | + $find = true; |
|
1956 | + break; |
|
1957 | + } |
|
1958 | + } |
|
1959 | + if ($find === false) { |
|
1960 | + $pall[] = $value; |
|
1961 | + } |
|
1962 | + } |
|
1963 | + $alldata = $pall; |
|
1964 | 1964 | foreach ($alldata as $number) { |
1965 | 1965 | $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); |
1966 | 1966 | } |