@@ -15,67 +15,67 @@ discard block |
||
15 | 15 | if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
16 | 16 | $Connection = new Connection($dbc); |
17 | 17 | $this->db = $Connection->db(); |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | 20 | public function addLastStatsUpdate($type,$stats_date) { |
21 | - $query = "DELETE FROM config WHERE name = :type; |
|
21 | + $query = "DELETE FROM config WHERE name = :type; |
|
22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | - try { |
|
25 | - $sth = $this->db->prepare($query); |
|
26 | - $sth->execute($query_values); |
|
27 | - } catch(PDOException $e) { |
|
28 | - return "error : ".$e->getMessage(); |
|
29 | - } |
|
30 | - } |
|
23 | + $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | + try { |
|
25 | + $sth = $this->db->prepare($query); |
|
26 | + $sth->execute($query_values); |
|
27 | + } catch(PDOException $e) { |
|
28 | + return "error : ".$e->getMessage(); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | 32 | public function getLastStatsUpdate($type = 'last_update_stats') { |
33 | - $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | - try { |
|
35 | - $sth = $this->db->prepare($query); |
|
36 | - $sth->execute(array(':type' => $type)); |
|
37 | - } catch(PDOException $e) { |
|
38 | - echo "error : ".$e->getMessage(); |
|
39 | - } |
|
40 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | - return $all; |
|
42 | - } |
|
33 | + $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | + try { |
|
35 | + $sth = $this->db->prepare($query); |
|
36 | + $sth->execute(array(':type' => $type)); |
|
37 | + } catch(PDOException $e) { |
|
38 | + echo "error : ".$e->getMessage(); |
|
39 | + } |
|
40 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | + return $all; |
|
42 | + } |
|
43 | 43 | public function getAllAirlineNames($filter_name = '') { |
44 | 44 | if ($filter_name == '') $filter_name = $this->filter_name; |
45 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
46 | - try { |
|
47 | - $sth = $this->db->prepare($query); |
|
48 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
49 | - } catch(PDOException $e) { |
|
50 | - echo "error : ".$e->getMessage(); |
|
51 | - } |
|
52 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
53 | - return $all; |
|
54 | - } |
|
45 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
46 | + try { |
|
47 | + $sth = $this->db->prepare($query); |
|
48 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
49 | + } catch(PDOException $e) { |
|
50 | + echo "error : ".$e->getMessage(); |
|
51 | + } |
|
52 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
53 | + return $all; |
|
54 | + } |
|
55 | 55 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
56 | 56 | if ($filter_name == '') $filter_name = $this->filter_name; |
57 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
58 | - try { |
|
59 | - $sth = $this->db->prepare($query); |
|
60 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
61 | - } catch(PDOException $e) { |
|
62 | - echo "error : ".$e->getMessage(); |
|
63 | - } |
|
64 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
65 | - return $all; |
|
66 | - } |
|
57 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
58 | + try { |
|
59 | + $sth = $this->db->prepare($query); |
|
60 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
61 | + } catch(PDOException $e) { |
|
62 | + echo "error : ".$e->getMessage(); |
|
63 | + } |
|
64 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
65 | + return $all; |
|
66 | + } |
|
67 | 67 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
68 | 68 | if ($filter_name == '') $filter_name = $this->filter_name; |
69 | - $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
70 | - try { |
|
71 | - $sth = $this->db->prepare($query); |
|
72 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
73 | - } catch(PDOException $e) { |
|
74 | - echo "error : ".$e->getMessage(); |
|
75 | - } |
|
76 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
77 | - return $all; |
|
78 | - } |
|
69 | + $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
70 | + try { |
|
71 | + $sth = $this->db->prepare($query); |
|
72 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
73 | + } catch(PDOException $e) { |
|
74 | + echo "error : ".$e->getMessage(); |
|
75 | + } |
|
76 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
77 | + return $all; |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | 81 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -83,66 +83,66 @@ discard block |
||
83 | 83 | if ($filter_name == '') $filter_name = $this->filter_name; |
84 | 84 | if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
85 | 85 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
86 | - try { |
|
87 | - $sth = $this->db->prepare($query); |
|
88 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
89 | - } catch(PDOException $e) { |
|
90 | - echo "error : ".$e->getMessage(); |
|
91 | - } |
|
92 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
93 | - if (empty($all)) { |
|
94 | - $filters = array('airlines' => array($stats_airline)); |
|
95 | - if ($filter_name != '') { |
|
96 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
97 | - } |
|
98 | - $Spotter = new Spotter($this->db); |
|
99 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
100 | - } |
|
101 | - return $all; |
|
86 | + try { |
|
87 | + $sth = $this->db->prepare($query); |
|
88 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
89 | + } catch(PDOException $e) { |
|
90 | + echo "error : ".$e->getMessage(); |
|
91 | + } |
|
92 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
93 | + if (empty($all)) { |
|
94 | + $filters = array('airlines' => array($stats_airline)); |
|
95 | + if ($filter_name != '') { |
|
96 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
97 | + } |
|
98 | + $Spotter = new Spotter($this->db); |
|
99 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
100 | + } |
|
101 | + return $all; |
|
102 | 102 | } |
103 | 103 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
104 | 104 | global $globalStatsFilters; |
105 | 105 | if ($filter_name == '') $filter_name = $this->filter_name; |
106 | 106 | if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
107 | 107 | else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
108 | - try { |
|
109 | - $sth = $this->db->prepare($query); |
|
110 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
111 | - } catch(PDOException $e) { |
|
112 | - echo "error : ".$e->getMessage(); |
|
113 | - } |
|
114 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
115 | - if (empty($all)) { |
|
116 | - $Spotter = new Spotter($this->db); |
|
117 | - $filters = array(); |
|
118 | - if ($filter_name != '') { |
|
119 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
120 | - } |
|
121 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
122 | - } |
|
123 | - return $all; |
|
108 | + try { |
|
109 | + $sth = $this->db->prepare($query); |
|
110 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
111 | + } catch(PDOException $e) { |
|
112 | + echo "error : ".$e->getMessage(); |
|
113 | + } |
|
114 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
115 | + if (empty($all)) { |
|
116 | + $Spotter = new Spotter($this->db); |
|
117 | + $filters = array(); |
|
118 | + if ($filter_name != '') { |
|
119 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
120 | + } |
|
121 | + $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
122 | + } |
|
123 | + return $all; |
|
124 | 124 | } |
125 | 125 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
126 | 126 | global $globalStatsFilters; |
127 | 127 | if ($filter_name == '') $filter_name = $this->filter_name; |
128 | 128 | if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
129 | 129 | else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
130 | - try { |
|
131 | - $sth = $this->db->prepare($query); |
|
132 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
133 | - } catch(PDOException $e) { |
|
134 | - echo "error : ".$e->getMessage(); |
|
135 | - } |
|
136 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
137 | - if (empty($all)) { |
|
138 | - $filters = array('airlines' => array($stats_airline)); |
|
139 | - if ($filter_name != '') { |
|
140 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
130 | + try { |
|
131 | + $sth = $this->db->prepare($query); |
|
132 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
133 | + } catch(PDOException $e) { |
|
134 | + echo "error : ".$e->getMessage(); |
|
135 | + } |
|
136 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
137 | + if (empty($all)) { |
|
138 | + $filters = array('airlines' => array($stats_airline)); |
|
139 | + if ($filter_name != '') { |
|
140 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
141 | 141 | } |
142 | - $Spotter = new Spotter($this->db); |
|
142 | + $Spotter = new Spotter($this->db); |
|
143 | 143 | $all = $Spotter->countAllAircraftManufacturers($filters); |
144 | - } |
|
145 | - return $all; |
|
144 | + } |
|
145 | + return $all; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -150,44 +150,44 @@ discard block |
||
150 | 150 | if ($filter_name == '') $filter_name = $this->filter_name; |
151 | 151 | if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
152 | 152 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
153 | - try { |
|
154 | - $sth = $this->db->prepare($query); |
|
155 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
156 | - } catch(PDOException $e) { |
|
157 | - echo "error : ".$e->getMessage(); |
|
158 | - } |
|
159 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
160 | - if (empty($all)) { |
|
153 | + try { |
|
154 | + $sth = $this->db->prepare($query); |
|
155 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
156 | + } catch(PDOException $e) { |
|
157 | + echo "error : ".$e->getMessage(); |
|
158 | + } |
|
159 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
160 | + if (empty($all)) { |
|
161 | 161 | $filters = array('airlines' => array($stats_airline)); |
162 | 162 | if ($filter_name != '') { |
163 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
163 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
164 | 164 | } |
165 | 165 | $Spotter = new Spotter($this->db); |
166 | 166 | $all = $Spotter->countAllArrivalCountries($limit,$filters); |
167 | - } |
|
168 | - return $all; |
|
167 | + } |
|
168 | + return $all; |
|
169 | 169 | } |
170 | 170 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
171 | 171 | global $globalStatsFilters; |
172 | 172 | if ($filter_name == '') $filter_name = $this->filter_name; |
173 | 173 | if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
174 | 174 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
175 | - try { |
|
176 | - $sth = $this->db->prepare($query); |
|
177 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
178 | - } catch(PDOException $e) { |
|
179 | - echo "error : ".$e->getMessage(); |
|
180 | - } |
|
181 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
182 | - if (empty($all)) { |
|
175 | + try { |
|
176 | + $sth = $this->db->prepare($query); |
|
177 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
178 | + } catch(PDOException $e) { |
|
179 | + echo "error : ".$e->getMessage(); |
|
180 | + } |
|
181 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
182 | + if (empty($all)) { |
|
183 | 183 | $filters = array('airlines' => array($stats_airline)); |
184 | 184 | if ($filter_name != '') { |
185 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
185 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
186 | 186 | } |
187 | 187 | $Spotter = new Spotter($this->db); |
188 | 188 | $all = $Spotter->countAllDepartureCountries($filters); |
189 | - } |
|
190 | - return $all; |
|
189 | + } |
|
190 | + return $all; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | public function countAllAirlines($limit = true,$filter_name = '') { |
@@ -195,45 +195,45 @@ discard block |
||
195 | 195 | if ($filter_name == '') $filter_name = $this->filter_name; |
196 | 196 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
197 | 197 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
198 | - try { |
|
199 | - $sth = $this->db->prepare($query); |
|
200 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
201 | - } catch(PDOException $e) { |
|
202 | - echo "error : ".$e->getMessage(); |
|
203 | - } |
|
204 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
205 | - if (empty($all)) { |
|
206 | - $Spotter = new Spotter($this->db); |
|
207 | - $filters = array(); |
|
208 | - if ($filter_name != '') { |
|
209 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
198 | + try { |
|
199 | + $sth = $this->db->prepare($query); |
|
200 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
201 | + } catch(PDOException $e) { |
|
202 | + echo "error : ".$e->getMessage(); |
|
203 | + } |
|
204 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
205 | + if (empty($all)) { |
|
206 | + $Spotter = new Spotter($this->db); |
|
207 | + $filters = array(); |
|
208 | + if ($filter_name != '') { |
|
209 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
210 | 210 | } |
211 | 211 | |
212 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
213 | - } |
|
214 | - return $all; |
|
212 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
213 | + } |
|
214 | + return $all; |
|
215 | 215 | } |
216 | 216 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
217 | 217 | global $globalStatsFilters; |
218 | 218 | if ($filter_name == '') $filter_name = $this->filter_name; |
219 | 219 | if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
220 | 220 | else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
221 | - try { |
|
222 | - $sth = $this->db->prepare($query); |
|
223 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
224 | - } catch(PDOException $e) { |
|
225 | - echo "error : ".$e->getMessage(); |
|
226 | - } |
|
227 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | - if (empty($all)) { |
|
221 | + try { |
|
222 | + $sth = $this->db->prepare($query); |
|
223 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
224 | + } catch(PDOException $e) { |
|
225 | + echo "error : ".$e->getMessage(); |
|
226 | + } |
|
227 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | + if (empty($all)) { |
|
229 | 229 | $filters = array('airlines' => array($stats_airline)); |
230 | 230 | if ($filter_name != '') { |
231 | 231 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
232 | 232 | } |
233 | - $Spotter = new Spotter($this->db); |
|
234 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
235 | - } |
|
236 | - return $all; |
|
233 | + $Spotter = new Spotter($this->db); |
|
234 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
235 | + } |
|
236 | + return $all; |
|
237 | 237 | } |
238 | 238 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
239 | 239 | global $globalStatsFilters; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | echo "error : ".$e->getMessage(); |
271 | 271 | } |
272 | 272 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
273 | - /* |
|
273 | + /* |
|
274 | 274 | if (empty($all)) { |
275 | 275 | $Spotter = new Spotter($this->db); |
276 | 276 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -286,84 +286,84 @@ discard block |
||
286 | 286 | if ($filter_name == '') $filter_name = $this->filter_name; |
287 | 287 | if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
288 | 288 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
289 | - try { |
|
290 | - $sth = $this->db->prepare($query); |
|
291 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
292 | - } catch(PDOException $e) { |
|
293 | - echo "error : ".$e->getMessage(); |
|
294 | - } |
|
295 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
296 | - if (empty($all)) { |
|
289 | + try { |
|
290 | + $sth = $this->db->prepare($query); |
|
291 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
292 | + } catch(PDOException $e) { |
|
293 | + echo "error : ".$e->getMessage(); |
|
294 | + } |
|
295 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
296 | + if (empty($all)) { |
|
297 | 297 | $filters = array('airlines' => array($stats_airline)); |
298 | 298 | if ($filter_name != '') { |
299 | 299 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
300 | 300 | } |
301 | - $Spotter = new Spotter($this->db); |
|
302 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
303 | - } |
|
304 | - return $all; |
|
301 | + $Spotter = new Spotter($this->db); |
|
302 | + $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
303 | + } |
|
304 | + return $all; |
|
305 | 305 | } |
306 | 306 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
307 | 307 | global $globalStatsFilters; |
308 | 308 | if ($filter_name == '') $filter_name = $this->filter_name; |
309 | 309 | if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
310 | 310 | else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
311 | - try { |
|
312 | - $sth = $this->db->prepare($query); |
|
313 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
314 | - } catch(PDOException $e) { |
|
315 | - echo "error : ".$e->getMessage(); |
|
316 | - } |
|
317 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
318 | - if (empty($all)) { |
|
311 | + try { |
|
312 | + $sth = $this->db->prepare($query); |
|
313 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
314 | + } catch(PDOException $e) { |
|
315 | + echo "error : ".$e->getMessage(); |
|
316 | + } |
|
317 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
318 | + if (empty($all)) { |
|
319 | 319 | $filters = array('airlines' => array($stats_airline)); |
320 | 320 | if ($filter_name != '') { |
321 | 321 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
322 | 322 | } |
323 | - $Spotter = new Spotter($this->db); |
|
324 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
325 | - } |
|
326 | - return $all; |
|
323 | + $Spotter = new Spotter($this->db); |
|
324 | + $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
325 | + } |
|
326 | + return $all; |
|
327 | 327 | } |
328 | 328 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
329 | 329 | global $globalStatsFilters; |
330 | 330 | if ($filter_name == '') $filter_name = $this->filter_name; |
331 | 331 | if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
332 | 332 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
333 | - try { |
|
334 | - $sth = $this->db->prepare($query); |
|
335 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
336 | - } catch(PDOException $e) { |
|
337 | - echo "error : ".$e->getMessage(); |
|
338 | - } |
|
339 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
340 | - if (empty($all)) { |
|
333 | + try { |
|
334 | + $sth = $this->db->prepare($query); |
|
335 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
336 | + } catch(PDOException $e) { |
|
337 | + echo "error : ".$e->getMessage(); |
|
338 | + } |
|
339 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
340 | + if (empty($all)) { |
|
341 | 341 | $filters = array('airlines' => array($stats_airline)); |
342 | - if ($filter_name != '') { |
|
343 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
344 | - } |
|
345 | - $Spotter = new Spotter($this->db); |
|
346 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
347 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
348 | - $all = array(); |
|
349 | - foreach ($pall as $value) { |
|
350 | - $icao = $value['airport_departure_icao']; |
|
351 | - $all[$icao] = $value; |
|
352 | - } |
|
342 | + if ($filter_name != '') { |
|
343 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
344 | + } |
|
345 | + $Spotter = new Spotter($this->db); |
|
346 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
347 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
348 | + $all = array(); |
|
349 | + foreach ($pall as $value) { |
|
350 | + $icao = $value['airport_departure_icao']; |
|
351 | + $all[$icao] = $value; |
|
352 | + } |
|
353 | 353 | |
354 | - foreach ($dall as $value) { |
|
355 | - $icao = $value['airport_departure_icao']; |
|
356 | - if (isset($all[$icao])) { |
|
357 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
358 | - } else $all[$icao] = $value; |
|
359 | - } |
|
360 | - $count = array(); |
|
361 | - foreach ($all as $key => $row) { |
|
362 | - $count[$key] = $row['airport_departure_icao_count']; |
|
363 | - } |
|
364 | - array_multisort($count,SORT_DESC,$all); |
|
365 | - } |
|
366 | - return $all; |
|
354 | + foreach ($dall as $value) { |
|
355 | + $icao = $value['airport_departure_icao']; |
|
356 | + if (isset($all[$icao])) { |
|
357 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
358 | + } else $all[$icao] = $value; |
|
359 | + } |
|
360 | + $count = array(); |
|
361 | + foreach ($all as $key => $row) { |
|
362 | + $count[$key] = $row['airport_departure_icao_count']; |
|
363 | + } |
|
364 | + array_multisort($count,SORT_DESC,$all); |
|
365 | + } |
|
366 | + return $all; |
|
367 | 367 | } |
368 | 368 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
369 | 369 | global $globalStatsFilters; |
@@ -385,26 +385,26 @@ discard block |
||
385 | 385 | $Spotter = new Spotter($this->db); |
386 | 386 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
387 | 387 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
388 | - $all = array(); |
|
389 | - foreach ($pall as $value) { |
|
390 | - $icao = $value['airport_arrival_icao']; |
|
391 | - $all[$icao] = $value; |
|
392 | - } |
|
388 | + $all = array(); |
|
389 | + foreach ($pall as $value) { |
|
390 | + $icao = $value['airport_arrival_icao']; |
|
391 | + $all[$icao] = $value; |
|
392 | + } |
|
393 | 393 | |
394 | - foreach ($dall as $value) { |
|
395 | - $icao = $value['airport_arrival_icao']; |
|
396 | - if (isset($all[$icao])) { |
|
397 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
398 | - } else $all[$icao] = $value; |
|
399 | - } |
|
400 | - $count = array(); |
|
401 | - foreach ($all as $key => $row) { |
|
402 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
403 | - } |
|
404 | - array_multisort($count,SORT_DESC,$all); |
|
405 | - } |
|
394 | + foreach ($dall as $value) { |
|
395 | + $icao = $value['airport_arrival_icao']; |
|
396 | + if (isset($all[$icao])) { |
|
397 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
398 | + } else $all[$icao] = $value; |
|
399 | + } |
|
400 | + $count = array(); |
|
401 | + foreach ($all as $key => $row) { |
|
402 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
403 | + } |
|
404 | + array_multisort($count,SORT_DESC,$all); |
|
405 | + } |
|
406 | 406 | |
407 | - return $all; |
|
407 | + return $all; |
|
408 | 408 | } |
409 | 409 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
410 | 410 | global $globalDBdriver, $globalStatsFilters; |
@@ -417,23 +417,23 @@ discard block |
||
417 | 417 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
418 | 418 | } |
419 | 419 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
420 | - try { |
|
421 | - $sth = $this->db->prepare($query); |
|
422 | - $sth->execute($query_data); |
|
423 | - } catch(PDOException $e) { |
|
424 | - echo "error : ".$e->getMessage(); |
|
425 | - } |
|
426 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
427 | - if (empty($all)) { |
|
420 | + try { |
|
421 | + $sth = $this->db->prepare($query); |
|
422 | + $sth->execute($query_data); |
|
423 | + } catch(PDOException $e) { |
|
424 | + echo "error : ".$e->getMessage(); |
|
425 | + } |
|
426 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
427 | + if (empty($all)) { |
|
428 | 428 | $filters = array('airlines' => array($stats_airline)); |
429 | 429 | if ($filter_name != '') { |
430 | 430 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
431 | 431 | } |
432 | - $Spotter = new Spotter($this->db); |
|
433 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
434 | - } |
|
432 | + $Spotter = new Spotter($this->db); |
|
433 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
434 | + } |
|
435 | 435 | |
436 | - return $all; |
|
436 | + return $all; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
@@ -441,22 +441,22 @@ discard block |
||
441 | 441 | if ($filter_name == '') $filter_name = $this->filter_name; |
442 | 442 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
443 | 443 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
444 | - try { |
|
445 | - $sth = $this->db->prepare($query); |
|
446 | - $sth->execute($query_data); |
|
447 | - } catch(PDOException $e) { |
|
448 | - echo "error : ".$e->getMessage(); |
|
449 | - } |
|
450 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
451 | - if (empty($all)) { |
|
444 | + try { |
|
445 | + $sth = $this->db->prepare($query); |
|
446 | + $sth->execute($query_data); |
|
447 | + } catch(PDOException $e) { |
|
448 | + echo "error : ".$e->getMessage(); |
|
449 | + } |
|
450 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
451 | + if (empty($all)) { |
|
452 | 452 | $filters = array('airlines' => array($stats_airline)); |
453 | 453 | if ($filter_name != '') { |
454 | 454 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
455 | 455 | } |
456 | - $Spotter = new Spotter($this->db); |
|
457 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
458 | - } |
|
459 | - return $all; |
|
456 | + $Spotter = new Spotter($this->db); |
|
457 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
458 | + } |
|
459 | + return $all; |
|
460 | 460 | } |
461 | 461 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
462 | 462 | global $globalDBdriver, $globalStatsFilters; |
@@ -467,108 +467,108 @@ discard block |
||
467 | 467 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
468 | 468 | } |
469 | 469 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
470 | - try { |
|
471 | - $sth = $this->db->prepare($query); |
|
472 | - $sth->execute($query_data); |
|
473 | - } catch(PDOException $e) { |
|
474 | - echo "error : ".$e->getMessage(); |
|
475 | - } |
|
476 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
477 | - if (empty($all)) { |
|
470 | + try { |
|
471 | + $sth = $this->db->prepare($query); |
|
472 | + $sth->execute($query_data); |
|
473 | + } catch(PDOException $e) { |
|
474 | + echo "error : ".$e->getMessage(); |
|
475 | + } |
|
476 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
477 | + if (empty($all)) { |
|
478 | 478 | $filters = array('airlines' => array($stats_airline)); |
479 | 479 | if ($filter_name != '') { |
480 | 480 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
481 | 481 | } |
482 | - $Spotter = new Spotter($this->db); |
|
483 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
484 | - } |
|
485 | - return $all; |
|
482 | + $Spotter = new Spotter($this->db); |
|
483 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
484 | + } |
|
485 | + return $all; |
|
486 | 486 | } |
487 | 487 | public function countAllDates($stats_airline = '',$filter_name = '') { |
488 | 488 | global $globalStatsFilters; |
489 | 489 | if ($filter_name == '') $filter_name = $this->filter_name; |
490 | 490 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
491 | 491 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
492 | - try { |
|
493 | - $sth = $this->db->prepare($query); |
|
494 | - $sth->execute($query_data); |
|
495 | - } catch(PDOException $e) { |
|
496 | - echo "error : ".$e->getMessage(); |
|
497 | - } |
|
498 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
499 | - if (empty($all)) { |
|
492 | + try { |
|
493 | + $sth = $this->db->prepare($query); |
|
494 | + $sth->execute($query_data); |
|
495 | + } catch(PDOException $e) { |
|
496 | + echo "error : ".$e->getMessage(); |
|
497 | + } |
|
498 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
499 | + if (empty($all)) { |
|
500 | 500 | $filters = array('airlines' => array($stats_airline)); |
501 | 501 | if ($filter_name != '') { |
502 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
502 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
503 | 503 | } |
504 | - $Spotter = new Spotter($this->db); |
|
505 | - $all = $Spotter->countAllDates($filters); |
|
506 | - } |
|
507 | - return $all; |
|
504 | + $Spotter = new Spotter($this->db); |
|
505 | + $all = $Spotter->countAllDates($filters); |
|
506 | + } |
|
507 | + return $all; |
|
508 | 508 | } |
509 | 509 | public function countAllDatesByAirlines($filter_name = '') { |
510 | 510 | global $globalStatsFilters; |
511 | 511 | if ($filter_name == '') $filter_name = $this->filter_name; |
512 | 512 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
513 | 513 | $query_data = array('filter_name' => $filter_name); |
514 | - try { |
|
515 | - $sth = $this->db->prepare($query); |
|
516 | - $sth->execute($query_data); |
|
517 | - } catch(PDOException $e) { |
|
518 | - echo "error : ".$e->getMessage(); |
|
519 | - } |
|
520 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
521 | - if (empty($all)) { |
|
522 | - $filters = array(); |
|
523 | - if ($filter_name != '') { |
|
524 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
525 | - } |
|
526 | - $Spotter = new Spotter($this->db); |
|
527 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
528 | - } |
|
529 | - return $all; |
|
514 | + try { |
|
515 | + $sth = $this->db->prepare($query); |
|
516 | + $sth->execute($query_data); |
|
517 | + } catch(PDOException $e) { |
|
518 | + echo "error : ".$e->getMessage(); |
|
519 | + } |
|
520 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
521 | + if (empty($all)) { |
|
522 | + $filters = array(); |
|
523 | + if ($filter_name != '') { |
|
524 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
525 | + } |
|
526 | + $Spotter = new Spotter($this->db); |
|
527 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
528 | + } |
|
529 | + return $all; |
|
530 | 530 | } |
531 | 531 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
532 | 532 | global $globalStatsFilters; |
533 | 533 | if ($filter_name == '') $filter_name = $this->filter_name; |
534 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
535 | - try { |
|
536 | - $sth = $this->db->prepare($query); |
|
537 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
538 | - } catch(PDOException $e) { |
|
539 | - echo "error : ".$e->getMessage(); |
|
540 | - } |
|
541 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
542 | - if (empty($all)) { |
|
534 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
535 | + try { |
|
536 | + $sth = $this->db->prepare($query); |
|
537 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
538 | + } catch(PDOException $e) { |
|
539 | + echo "error : ".$e->getMessage(); |
|
540 | + } |
|
541 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
542 | + if (empty($all)) { |
|
543 | 543 | $filters = array('airlines' => array($stats_airline)); |
544 | 544 | if ($filter_name != '') { |
545 | 545 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
546 | 546 | } |
547 | - $Spotter = new Spotter($this->db); |
|
548 | - $all = $Spotter->countAllMonths($filters); |
|
549 | - } |
|
550 | - return $all; |
|
547 | + $Spotter = new Spotter($this->db); |
|
548 | + $all = $Spotter->countAllMonths($filters); |
|
549 | + } |
|
550 | + return $all; |
|
551 | 551 | } |
552 | 552 | public function countAllMilitaryMonths($filter_name = '') { |
553 | 553 | global $globalStatsFilters; |
554 | 554 | if ($filter_name == '') $filter_name = $this->filter_name; |
555 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
|
556 | - try { |
|
557 | - $sth = $this->db->prepare($query); |
|
558 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
559 | - } catch(PDOException $e) { |
|
560 | - echo "error : ".$e->getMessage(); |
|
561 | - } |
|
562 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
563 | - if (empty($all)) { |
|
564 | - $filters = array(); |
|
565 | - if ($filter_name != '') { |
|
566 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
567 | - } |
|
568 | - $Spotter = new Spotter($this->db); |
|
569 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
570 | - } |
|
571 | - return $all; |
|
555 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
|
556 | + try { |
|
557 | + $sth = $this->db->prepare($query); |
|
558 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
559 | + } catch(PDOException $e) { |
|
560 | + echo "error : ".$e->getMessage(); |
|
561 | + } |
|
562 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
563 | + if (empty($all)) { |
|
564 | + $filters = array(); |
|
565 | + if ($filter_name != '') { |
|
566 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
567 | + } |
|
568 | + $Spotter = new Spotter($this->db); |
|
569 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
570 | + } |
|
571 | + return $all; |
|
572 | 572 | } |
573 | 573 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
574 | 574 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -584,22 +584,22 @@ discard block |
||
584 | 584 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
585 | 585 | } |
586 | 586 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
587 | - try { |
|
588 | - $sth = $this->db->prepare($query); |
|
589 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
590 | - } catch(PDOException $e) { |
|
591 | - echo "error : ".$e->getMessage(); |
|
592 | - } |
|
593 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
594 | - if (empty($all)) { |
|
587 | + try { |
|
588 | + $sth = $this->db->prepare($query); |
|
589 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
590 | + } catch(PDOException $e) { |
|
591 | + echo "error : ".$e->getMessage(); |
|
592 | + } |
|
593 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
594 | + if (empty($all)) { |
|
595 | 595 | $filters = array('airlines' => array($stats_airline)); |
596 | 596 | if ($filter_name != '') { |
597 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
597 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
598 | 598 | } |
599 | - $Spotter = new Spotter($this->db); |
|
600 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
601 | - } |
|
602 | - return $all; |
|
599 | + $Spotter = new Spotter($this->db); |
|
600 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
601 | + } |
|
602 | + return $all; |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | if ($filter_name == '') $filter_name = $this->filter_name; |
622 | 622 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
623 | 623 | if (empty($all)) { |
624 | - $filters = array(); |
|
625 | - if ($filter_name != '') { |
|
626 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
624 | + $filters = array(); |
|
625 | + if ($filter_name != '') { |
|
626 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
627 | 627 | } |
628 | 628 | $Spotter = new Spotter($this->db); |
629 | 629 | $all = $Spotter->countOverallMilitaryFlights($filters); |
@@ -662,19 +662,19 @@ discard block |
||
662 | 662 | global $globalStatsFilters; |
663 | 663 | if ($filter_name == '') $filter_name = $this->filter_name; |
664 | 664 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
665 | - try { |
|
666 | - $sth = $this->db->prepare($query); |
|
667 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
668 | - } catch(PDOException $e) { |
|
669 | - echo "error : ".$e->getMessage(); |
|
670 | - } |
|
671 | - $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
672 | - $all = $result[0]['nb_airline']; |
|
665 | + try { |
|
666 | + $sth = $this->db->prepare($query); |
|
667 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
668 | + } catch(PDOException $e) { |
|
669 | + echo "error : ".$e->getMessage(); |
|
670 | + } |
|
671 | + $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
672 | + $all = $result[0]['nb_airline']; |
|
673 | 673 | //$all = $this->getSumStats('airlines_bymonth',date('Y')); |
674 | 674 | if (empty($all)) { |
675 | - $filters = array(); |
|
676 | - if ($filter_name != '') { |
|
677 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
675 | + $filters = array(); |
|
676 | + if ($filter_name != '') { |
|
677 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
678 | 678 | } |
679 | 679 | $Spotter = new Spotter($this->db); |
680 | 680 | $all = $Spotter->countOverallAirlines($filters); |
@@ -725,166 +725,166 @@ discard block |
||
725 | 725 | if ($filter_name == '') $filter_name = $this->filter_name; |
726 | 726 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
727 | 727 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
728 | - try { |
|
729 | - $sth = $this->db->prepare($query); |
|
730 | - $sth->execute($query_values); |
|
731 | - } catch(PDOException $e) { |
|
732 | - echo "error : ".$e->getMessage(); |
|
733 | - } |
|
734 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
735 | - return $all; |
|
728 | + try { |
|
729 | + $sth = $this->db->prepare($query); |
|
730 | + $sth->execute($query_values); |
|
731 | + } catch(PDOException $e) { |
|
732 | + echo "error : ".$e->getMessage(); |
|
733 | + } |
|
734 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
735 | + return $all; |
|
736 | 736 | } |
737 | 737 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
738 | 738 | if ($filter_name == '') $filter_name = $this->filter_name; |
739 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
740 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
741 | - try { |
|
742 | - $sth = $this->db->prepare($query); |
|
743 | - $sth->execute($query_values); |
|
744 | - } catch(PDOException $e) { |
|
745 | - echo "error : ".$e->getMessage(); |
|
746 | - } |
|
747 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
748 | - return $all; |
|
749 | - } |
|
739 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
740 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
741 | + try { |
|
742 | + $sth = $this->db->prepare($query); |
|
743 | + $sth->execute($query_values); |
|
744 | + } catch(PDOException $e) { |
|
745 | + echo "error : ".$e->getMessage(); |
|
746 | + } |
|
747 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
748 | + return $all; |
|
749 | + } |
|
750 | 750 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
751 | 751 | if ($filter_name == '') $filter_name = $this->filter_name; |
752 | - global $globalArchiveMonths, $globalDBdriver; |
|
753 | - if ($globalDBdriver == 'mysql') { |
|
754 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
755 | - } else { |
|
756 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
757 | - } |
|
758 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
759 | - try { |
|
760 | - $sth = $this->db->prepare($query); |
|
761 | - $sth->execute($query_values); |
|
762 | - } catch(PDOException $e) { |
|
763 | - echo "error : ".$e->getMessage(); |
|
764 | - } |
|
765 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
766 | - return $all[0]['total']; |
|
767 | - } |
|
752 | + global $globalArchiveMonths, $globalDBdriver; |
|
753 | + if ($globalDBdriver == 'mysql') { |
|
754 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
755 | + } else { |
|
756 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
757 | + } |
|
758 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
759 | + try { |
|
760 | + $sth = $this->db->prepare($query); |
|
761 | + $sth->execute($query_values); |
|
762 | + } catch(PDOException $e) { |
|
763 | + echo "error : ".$e->getMessage(); |
|
764 | + } |
|
765 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
766 | + return $all[0]['total']; |
|
767 | + } |
|
768 | 768 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
769 | - global $globalArchiveMonths, $globalDBdriver; |
|
769 | + global $globalArchiveMonths, $globalDBdriver; |
|
770 | 770 | if ($filter_name == '') $filter_name = $this->filter_name; |
771 | - if ($globalDBdriver == 'mysql') { |
|
771 | + if ($globalDBdriver == 'mysql') { |
|
772 | 772 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
773 | 773 | } else { |
774 | 774 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
775 | - } |
|
776 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
777 | - try { |
|
778 | - $sth = $this->db->prepare($query); |
|
779 | - $sth->execute($query_values); |
|
780 | - } catch(PDOException $e) { |
|
781 | - echo "error : ".$e->getMessage(); |
|
782 | - } |
|
783 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
784 | - return $all[0]['total']; |
|
785 | - } |
|
775 | + } |
|
776 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
777 | + try { |
|
778 | + $sth = $this->db->prepare($query); |
|
779 | + $sth->execute($query_values); |
|
780 | + } catch(PDOException $e) { |
|
781 | + echo "error : ".$e->getMessage(); |
|
782 | + } |
|
783 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
784 | + return $all[0]['total']; |
|
785 | + } |
|
786 | 786 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
787 | - global $globalArchiveMonths, $globalDBdriver; |
|
787 | + global $globalArchiveMonths, $globalDBdriver; |
|
788 | 788 | if ($filter_name == '') $filter_name = $this->filter_name; |
789 | - if ($globalDBdriver == 'mysql') { |
|
789 | + if ($globalDBdriver == 'mysql') { |
|
790 | 790 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
791 | - } else { |
|
791 | + } else { |
|
792 | 792 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
793 | - } |
|
794 | - try { |
|
795 | - $sth = $this->db->prepare($query); |
|
796 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
797 | - } catch(PDOException $e) { |
|
798 | - echo "error : ".$e->getMessage(); |
|
799 | - } |
|
800 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
801 | - return $all[0]['total']; |
|
802 | - } |
|
793 | + } |
|
794 | + try { |
|
795 | + $sth = $this->db->prepare($query); |
|
796 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
797 | + } catch(PDOException $e) { |
|
798 | + echo "error : ".$e->getMessage(); |
|
799 | + } |
|
800 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
801 | + return $all[0]['total']; |
|
802 | + } |
|
803 | 803 | public function getStatsAirlineTotal($filter_name = '') { |
804 | - global $globalArchiveMonths, $globalDBdriver; |
|
804 | + global $globalArchiveMonths, $globalDBdriver; |
|
805 | 805 | if ($filter_name == '') $filter_name = $this->filter_name; |
806 | - if ($globalDBdriver == 'mysql') { |
|
806 | + if ($globalDBdriver == 'mysql') { |
|
807 | 807 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
808 | - } else { |
|
808 | + } else { |
|
809 | 809 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
810 | - } |
|
811 | - try { |
|
812 | - $sth = $this->db->prepare($query); |
|
813 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
814 | - } catch(PDOException $e) { |
|
815 | - echo "error : ".$e->getMessage(); |
|
816 | - } |
|
817 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
818 | - return $all[0]['total']; |
|
819 | - } |
|
810 | + } |
|
811 | + try { |
|
812 | + $sth = $this->db->prepare($query); |
|
813 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
814 | + } catch(PDOException $e) { |
|
815 | + echo "error : ".$e->getMessage(); |
|
816 | + } |
|
817 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
818 | + return $all[0]['total']; |
|
819 | + } |
|
820 | 820 | public function getStatsOwnerTotal($filter_name = '') { |
821 | - global $globalArchiveMonths, $globalDBdriver; |
|
821 | + global $globalArchiveMonths, $globalDBdriver; |
|
822 | 822 | if ($filter_name == '') $filter_name = $this->filter_name; |
823 | - if ($globalDBdriver == 'mysql') { |
|
823 | + if ($globalDBdriver == 'mysql') { |
|
824 | 824 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
825 | 825 | } else { |
826 | 826 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
827 | - } |
|
828 | - try { |
|
829 | - $sth = $this->db->prepare($query); |
|
830 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
831 | - } catch(PDOException $e) { |
|
832 | - echo "error : ".$e->getMessage(); |
|
833 | - } |
|
834 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
835 | - return $all[0]['total']; |
|
836 | - } |
|
827 | + } |
|
828 | + try { |
|
829 | + $sth = $this->db->prepare($query); |
|
830 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
831 | + } catch(PDOException $e) { |
|
832 | + echo "error : ".$e->getMessage(); |
|
833 | + } |
|
834 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
835 | + return $all[0]['total']; |
|
836 | + } |
|
837 | 837 | public function getStatsPilotTotal($filter_name = '') { |
838 | - global $globalArchiveMonths, $globalDBdriver; |
|
838 | + global $globalArchiveMonths, $globalDBdriver; |
|
839 | 839 | if ($filter_name == '') $filter_name = $this->filter_name; |
840 | - if ($globalDBdriver == 'mysql') { |
|
841 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
842 | - } else { |
|
843 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
844 | - } |
|
845 | - try { |
|
846 | - $sth = $this->db->prepare($query); |
|
847 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
848 | - } catch(PDOException $e) { |
|
849 | - echo "error : ".$e->getMessage(); |
|
850 | - } |
|
851 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
852 | - return $all[0]['total']; |
|
853 | - } |
|
840 | + if ($globalDBdriver == 'mysql') { |
|
841 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
842 | + } else { |
|
843 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
844 | + } |
|
845 | + try { |
|
846 | + $sth = $this->db->prepare($query); |
|
847 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
848 | + } catch(PDOException $e) { |
|
849 | + echo "error : ".$e->getMessage(); |
|
850 | + } |
|
851 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
852 | + return $all[0]['total']; |
|
853 | + } |
|
854 | 854 | |
855 | 855 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
856 | 856 | global $globalDBdriver; |
857 | 857 | if ($filter_name == '') $filter_name = $this->filter_name; |
858 | 858 | if ($globalDBdriver == 'mysql') { |
859 | 859 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
860 | - } else { |
|
860 | + } else { |
|
861 | 861 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
862 | 862 | } |
863 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
864 | - try { |
|
865 | - $sth = $this->db->prepare($query); |
|
866 | - $sth->execute($query_values); |
|
867 | - } catch(PDOException $e) { |
|
868 | - return "error : ".$e->getMessage(); |
|
869 | - } |
|
870 | - } |
|
863 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
864 | + try { |
|
865 | + $sth = $this->db->prepare($query); |
|
866 | + $sth->execute($query_values); |
|
867 | + } catch(PDOException $e) { |
|
868 | + return "error : ".$e->getMessage(); |
|
869 | + } |
|
870 | + } |
|
871 | 871 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
872 | 872 | global $globalDBdriver; |
873 | 873 | if ($filter_name == '') $filter_name = $this->filter_name; |
874 | 874 | if ($globalDBdriver == 'mysql') { |
875 | 875 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
876 | 876 | } else { |
877 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
877 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
878 | 878 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
879 | - } |
|
880 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
881 | - try { |
|
882 | - $sth = $this->db->prepare($query); |
|
883 | - $sth->execute($query_values); |
|
884 | - } catch(PDOException $e) { |
|
885 | - return "error : ".$e->getMessage(); |
|
886 | - } |
|
887 | - } |
|
879 | + } |
|
880 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
881 | + try { |
|
882 | + $sth = $this->db->prepare($query); |
|
883 | + $sth->execute($query_values); |
|
884 | + } catch(PDOException $e) { |
|
885 | + return "error : ".$e->getMessage(); |
|
886 | + } |
|
887 | + } |
|
888 | 888 | public function getStatsSource($date,$stats_type = '') { |
889 | 889 | if ($stats_type == '') { |
890 | 890 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -893,15 +893,15 @@ discard block |
||
893 | 893 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
894 | 894 | $query_values = array(':date' => $date,':stats_type' => $stats_type); |
895 | 895 | } |
896 | - try { |
|
897 | - $sth = $this->db->prepare($query); |
|
898 | - $sth->execute($query_values); |
|
899 | - } catch(PDOException $e) { |
|
900 | - echo "error : ".$e->getMessage(); |
|
901 | - } |
|
902 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
903 | - return $all; |
|
904 | - } |
|
896 | + try { |
|
897 | + $sth = $this->db->prepare($query); |
|
898 | + $sth->execute($query_values); |
|
899 | + } catch(PDOException $e) { |
|
900 | + echo "error : ".$e->getMessage(); |
|
901 | + } |
|
902 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
903 | + return $all; |
|
904 | + } |
|
905 | 905 | |
906 | 906 | public function addStatSource($data,$source_name,$stats_type,$date) { |
907 | 907 | global $globalDBdriver; |
@@ -909,25 +909,25 @@ discard block |
||
909 | 909 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
910 | 910 | } else { |
911 | 911 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
912 | - } |
|
913 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
914 | - try { |
|
915 | - $sth = $this->db->prepare($query); |
|
916 | - $sth->execute($query_values); |
|
917 | - } catch(PDOException $e) { |
|
918 | - return "error : ".$e->getMessage(); |
|
919 | - } |
|
920 | - } |
|
912 | + } |
|
913 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
914 | + try { |
|
915 | + $sth = $this->db->prepare($query); |
|
916 | + $sth->execute($query_values); |
|
917 | + } catch(PDOException $e) { |
|
918 | + return "error : ".$e->getMessage(); |
|
919 | + } |
|
920 | + } |
|
921 | 921 | public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
922 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
923 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
924 | - try { |
|
925 | - $sth = $this->db->prepare($query); |
|
926 | - $sth->execute($query_values); |
|
927 | - } catch(PDOException $e) { |
|
928 | - return "error : ".$e->getMessage(); |
|
929 | - } |
|
930 | - } |
|
922 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
923 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
924 | + try { |
|
925 | + $sth = $this->db->prepare($query); |
|
926 | + $sth->execute($query_values); |
|
927 | + } catch(PDOException $e) { |
|
928 | + return "error : ".$e->getMessage(); |
|
929 | + } |
|
930 | + } |
|
931 | 931 | public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
932 | 932 | global $globalDBdriver; |
933 | 933 | if ($globalDBdriver == 'mysql') { |
@@ -935,14 +935,14 @@ discard block |
||
935 | 935 | } else { |
936 | 936 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
937 | 937 | } |
938 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
939 | - try { |
|
940 | - $sth = $this->db->prepare($query); |
|
941 | - $sth->execute($query_values); |
|
942 | - } catch(PDOException $e) { |
|
943 | - return "error : ".$e->getMessage(); |
|
944 | - } |
|
945 | - } |
|
938 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
939 | + try { |
|
940 | + $sth = $this->db->prepare($query); |
|
941 | + $sth->execute($query_values); |
|
942 | + } catch(PDOException $e) { |
|
943 | + return "error : ".$e->getMessage(); |
|
944 | + } |
|
945 | + } |
|
946 | 946 | public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
947 | 947 | global $globalDBdriver; |
948 | 948 | if ($globalDBdriver == 'mysql') { |
@@ -950,14 +950,14 @@ discard block |
||
950 | 950 | } else { |
951 | 951 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
952 | 952 | } |
953 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
954 | - try { |
|
955 | - $sth = $this->db->prepare($query); |
|
956 | - $sth->execute($query_values); |
|
957 | - } catch(PDOException $e) { |
|
958 | - return "error : ".$e->getMessage(); |
|
959 | - } |
|
960 | - } |
|
953 | + $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
954 | + try { |
|
955 | + $sth = $this->db->prepare($query); |
|
956 | + $sth->execute($query_values); |
|
957 | + } catch(PDOException $e) { |
|
958 | + return "error : ".$e->getMessage(); |
|
959 | + } |
|
960 | + } |
|
961 | 961 | public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
962 | 962 | global $globalDBdriver; |
963 | 963 | if ($globalDBdriver == 'mysql') { |
@@ -965,14 +965,14 @@ discard block |
||
965 | 965 | } else { |
966 | 966 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; |
967 | 967 | } |
968 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
969 | - try { |
|
970 | - $sth = $this->db->prepare($query); |
|
971 | - $sth->execute($query_values); |
|
972 | - } catch(PDOException $e) { |
|
973 | - return "error : ".$e->getMessage(); |
|
974 | - } |
|
975 | - } |
|
968 | + $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
969 | + try { |
|
970 | + $sth = $this->db->prepare($query); |
|
971 | + $sth->execute($query_values); |
|
972 | + } catch(PDOException $e) { |
|
973 | + return "error : ".$e->getMessage(); |
|
974 | + } |
|
975 | + } |
|
976 | 976 | public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
977 | 977 | global $globalDBdriver; |
978 | 978 | if ($globalDBdriver == 'mysql') { |
@@ -980,14 +980,14 @@ discard block |
||
980 | 980 | } else { |
981 | 981 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
982 | 982 | } |
983 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
984 | - try { |
|
985 | - $sth = $this->db->prepare($query); |
|
986 | - $sth->execute($query_values); |
|
987 | - } catch(PDOException $e) { |
|
988 | - return "error : ".$e->getMessage(); |
|
989 | - } |
|
990 | - } |
|
983 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
984 | + try { |
|
985 | + $sth = $this->db->prepare($query); |
|
986 | + $sth->execute($query_values); |
|
987 | + } catch(PDOException $e) { |
|
988 | + return "error : ".$e->getMessage(); |
|
989 | + } |
|
990 | + } |
|
991 | 991 | public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
992 | 992 | global $globalDBdriver; |
993 | 993 | if ($globalDBdriver == 'mysql') { |
@@ -995,14 +995,14 @@ discard block |
||
995 | 995 | } else { |
996 | 996 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
997 | 997 | } |
998 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
999 | - try { |
|
1000 | - $sth = $this->db->prepare($query); |
|
1001 | - $sth->execute($query_values); |
|
1002 | - } catch(PDOException $e) { |
|
1003 | - return "error : ".$e->getMessage(); |
|
1004 | - } |
|
1005 | - } |
|
998 | + $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
999 | + try { |
|
1000 | + $sth = $this->db->prepare($query); |
|
1001 | + $sth->execute($query_values); |
|
1002 | + } catch(PDOException $e) { |
|
1003 | + return "error : ".$e->getMessage(); |
|
1004 | + } |
|
1005 | + } |
|
1006 | 1006 | public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
1007 | 1007 | global $globalDBdriver; |
1008 | 1008 | if ($globalDBdriver == 'mysql') { |
@@ -1010,14 +1010,14 @@ discard block |
||
1010 | 1010 | } else { |
1011 | 1011 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1012 | 1012 | } |
1013 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1014 | - try { |
|
1015 | - $sth = $this->db->prepare($query); |
|
1016 | - $sth->execute($query_values); |
|
1017 | - } catch(PDOException $e) { |
|
1018 | - return "error : ".$e->getMessage(); |
|
1019 | - } |
|
1020 | - } |
|
1013 | + $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1014 | + try { |
|
1015 | + $sth = $this->db->prepare($query); |
|
1016 | + $sth->execute($query_values); |
|
1017 | + } catch(PDOException $e) { |
|
1018 | + return "error : ".$e->getMessage(); |
|
1019 | + } |
|
1020 | + } |
|
1021 | 1021 | public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '') { |
1022 | 1022 | global $globalDBdriver; |
1023 | 1023 | if ($globalDBdriver == 'mysql') { |
@@ -1025,14 +1025,14 @@ discard block |
||
1025 | 1025 | } else { |
1026 | 1026 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1027 | 1027 | } |
1028 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1029 | - try { |
|
1030 | - $sth = $this->db->prepare($query); |
|
1031 | - $sth->execute($query_values); |
|
1032 | - } catch(PDOException $e) { |
|
1033 | - return "error : ".$e->getMessage(); |
|
1034 | - } |
|
1035 | - } |
|
1028 | + $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1029 | + try { |
|
1030 | + $sth = $this->db->prepare($query); |
|
1031 | + $sth->execute($query_values); |
|
1032 | + } catch(PDOException $e) { |
|
1033 | + return "error : ".$e->getMessage(); |
|
1034 | + } |
|
1035 | + } |
|
1036 | 1036 | public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1037 | 1037 | global $globalDBdriver; |
1038 | 1038 | if ($globalDBdriver == 'mysql') { |
@@ -1040,14 +1040,14 @@ discard block |
||
1040 | 1040 | } else { |
1041 | 1041 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1042 | 1042 | } |
1043 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1044 | - try { |
|
1045 | - $sth = $this->db->prepare($query); |
|
1046 | - $sth->execute($query_values); |
|
1047 | - } catch(PDOException $e) { |
|
1048 | - return "error : ".$e->getMessage(); |
|
1049 | - } |
|
1050 | - } |
|
1043 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1044 | + try { |
|
1045 | + $sth = $this->db->prepare($query); |
|
1046 | + $sth->execute($query_values); |
|
1047 | + } catch(PDOException $e) { |
|
1048 | + return "error : ".$e->getMessage(); |
|
1049 | + } |
|
1050 | + } |
|
1051 | 1051 | public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1052 | 1052 | global $globalDBdriver; |
1053 | 1053 | if ($globalDBdriver == 'mysql') { |
@@ -1055,14 +1055,14 @@ discard block |
||
1055 | 1055 | } else { |
1056 | 1056 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1057 | 1057 | } |
1058 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1059 | - try { |
|
1060 | - $sth = $this->db->prepare($query); |
|
1061 | - $sth->execute($query_values); |
|
1062 | - } catch(PDOException $e) { |
|
1063 | - return "error : ".$e->getMessage(); |
|
1064 | - } |
|
1065 | - } |
|
1058 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1059 | + try { |
|
1060 | + $sth = $this->db->prepare($query); |
|
1061 | + $sth->execute($query_values); |
|
1062 | + } catch(PDOException $e) { |
|
1063 | + return "error : ".$e->getMessage(); |
|
1064 | + } |
|
1065 | + } |
|
1066 | 1066 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1067 | 1067 | global $globalDBdriver; |
1068 | 1068 | if ($globalDBdriver == 'mysql') { |
@@ -1070,14 +1070,14 @@ discard block |
||
1070 | 1070 | } else { |
1071 | 1071 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1072 | 1072 | } |
1073 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1074 | - try { |
|
1075 | - $sth = $this->db->prepare($query); |
|
1076 | - $sth->execute($query_values); |
|
1077 | - } catch(PDOException $e) { |
|
1078 | - return "error : ".$e->getMessage(); |
|
1079 | - } |
|
1080 | - } |
|
1073 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1074 | + try { |
|
1075 | + $sth = $this->db->prepare($query); |
|
1076 | + $sth->execute($query_values); |
|
1077 | + } catch(PDOException $e) { |
|
1078 | + return "error : ".$e->getMessage(); |
|
1079 | + } |
|
1080 | + } |
|
1081 | 1081 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1082 | 1082 | global $globalDBdriver; |
1083 | 1083 | if ($globalDBdriver == 'mysql') { |
@@ -1085,52 +1085,52 @@ discard block |
||
1085 | 1085 | } else { |
1086 | 1086 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1087 | 1087 | } |
1088 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1089 | - try { |
|
1090 | - $sth = $this->db->prepare($query); |
|
1091 | - $sth->execute($query_values); |
|
1092 | - } catch(PDOException $e) { |
|
1093 | - return "error : ".$e->getMessage(); |
|
1094 | - } |
|
1095 | - } |
|
1088 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1089 | + try { |
|
1090 | + $sth = $this->db->prepare($query); |
|
1091 | + $sth->execute($query_values); |
|
1092 | + } catch(PDOException $e) { |
|
1093 | + return "error : ".$e->getMessage(); |
|
1094 | + } |
|
1095 | + } |
|
1096 | 1096 | |
1097 | 1097 | public function deleteStat($id) { |
1098 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1099 | - $query_values = array(':id' => $id); |
|
1100 | - try { |
|
1101 | - $sth = $this->db->prepare($query); |
|
1102 | - $sth->execute($query_values); |
|
1103 | - } catch(PDOException $e) { |
|
1104 | - return "error : ".$e->getMessage(); |
|
1105 | - } |
|
1106 | - } |
|
1098 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1099 | + $query_values = array(':id' => $id); |
|
1100 | + try { |
|
1101 | + $sth = $this->db->prepare($query); |
|
1102 | + $sth->execute($query_values); |
|
1103 | + } catch(PDOException $e) { |
|
1104 | + return "error : ".$e->getMessage(); |
|
1105 | + } |
|
1106 | + } |
|
1107 | 1107 | public function deleteStatFlight($type) { |
1108 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1109 | - $query_values = array(':type' => $type); |
|
1110 | - try { |
|
1111 | - $sth = $this->db->prepare($query); |
|
1112 | - $sth->execute($query_values); |
|
1113 | - } catch(PDOException $e) { |
|
1114 | - return "error : ".$e->getMessage(); |
|
1115 | - } |
|
1116 | - } |
|
1108 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1109 | + $query_values = array(':type' => $type); |
|
1110 | + try { |
|
1111 | + $sth = $this->db->prepare($query); |
|
1112 | + $sth->execute($query_values); |
|
1113 | + } catch(PDOException $e) { |
|
1114 | + return "error : ".$e->getMessage(); |
|
1115 | + } |
|
1116 | + } |
|
1117 | 1117 | public function deleteStatAirport($type) { |
1118 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1119 | - $query_values = array(':type' => $type); |
|
1120 | - try { |
|
1121 | - $sth = $this->db->prepare($query); |
|
1122 | - $sth->execute($query_values); |
|
1123 | - } catch(PDOException $e) { |
|
1124 | - return "error : ".$e->getMessage(); |
|
1125 | - } |
|
1126 | - } |
|
1118 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1119 | + $query_values = array(':type' => $type); |
|
1120 | + try { |
|
1121 | + $sth = $this->db->prepare($query); |
|
1122 | + $sth->execute($query_values); |
|
1123 | + } catch(PDOException $e) { |
|
1124 | + return "error : ".$e->getMessage(); |
|
1125 | + } |
|
1126 | + } |
|
1127 | 1127 | |
1128 | - public function addOldStats() { |
|
1129 | - global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters; |
|
1130 | - $Common = new Common(); |
|
1131 | - $Connection = new Connection(); |
|
1132 | - date_default_timezone_set('UTC'); |
|
1133 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1128 | + public function addOldStats() { |
|
1129 | + global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters; |
|
1130 | + $Common = new Common(); |
|
1131 | + $Connection = new Connection(); |
|
1132 | + date_default_timezone_set('UTC'); |
|
1133 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1134 | 1134 | //print_r($last_update); |
1135 | 1135 | /* |
1136 | 1136 | $flightsbymonth = $this->getStats('flights_by_month'); |
@@ -1384,46 +1384,46 @@ discard block |
||
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1387 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1388 | - $alldata = array(); |
|
1387 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1388 | + $alldata = array(); |
|
1389 | 1389 | |
1390 | - foreach ($pall as $value) { |
|
1391 | - $icao = $value['airport_departure_icao']; |
|
1392 | - $alldata[$icao] = $value; |
|
1393 | - } |
|
1394 | - foreach ($dall as $value) { |
|
1395 | - $icao = $value['airport_departure_icao']; |
|
1396 | - if (isset($alldata[$icao])) { |
|
1397 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1398 | - } else $alldata[$icao] = $value; |
|
1399 | - } |
|
1400 | - $count = array(); |
|
1401 | - foreach ($alldata as $key => $row) { |
|
1402 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1403 | - } |
|
1390 | + foreach ($pall as $value) { |
|
1391 | + $icao = $value['airport_departure_icao']; |
|
1392 | + $alldata[$icao] = $value; |
|
1393 | + } |
|
1394 | + foreach ($dall as $value) { |
|
1395 | + $icao = $value['airport_departure_icao']; |
|
1396 | + if (isset($alldata[$icao])) { |
|
1397 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1398 | + } else $alldata[$icao] = $value; |
|
1399 | + } |
|
1400 | + $count = array(); |
|
1401 | + foreach ($alldata as $key => $row) { |
|
1402 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1403 | + } |
|
1404 | 1404 | array_multisort($count,SORT_DESC,$alldata); |
1405 | 1405 | foreach ($alldata as $number) { |
1406 | 1406 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
1407 | 1407 | } |
1408 | 1408 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1409 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1410 | - $alldata = array(); |
|
1411 | - foreach ($pall as $value) { |
|
1412 | - $icao = $value['airport_arrival_icao']; |
|
1413 | - $alldata[$icao] = $value; |
|
1414 | - } |
|
1415 | - foreach ($dall as $value) { |
|
1416 | - $icao = $value['airport_arrival_icao']; |
|
1417 | - if (isset($alldata[$icao])) { |
|
1418 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1419 | - } else $alldata[$icao] = $value; |
|
1420 | - } |
|
1421 | - $count = array(); |
|
1422 | - foreach ($alldata as $key => $row) { |
|
1423 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1424 | - } |
|
1425 | - array_multisort($count,SORT_DESC,$alldata); |
|
1426 | - foreach ($alldata as $number) { |
|
1409 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1410 | + $alldata = array(); |
|
1411 | + foreach ($pall as $value) { |
|
1412 | + $icao = $value['airport_arrival_icao']; |
|
1413 | + $alldata[$icao] = $value; |
|
1414 | + } |
|
1415 | + foreach ($dall as $value) { |
|
1416 | + $icao = $value['airport_arrival_icao']; |
|
1417 | + if (isset($alldata[$icao])) { |
|
1418 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1419 | + } else $alldata[$icao] = $value; |
|
1420 | + } |
|
1421 | + $count = array(); |
|
1422 | + foreach ($alldata as $key => $row) { |
|
1423 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1424 | + } |
|
1425 | + array_multisort($count,SORT_DESC,$alldata); |
|
1426 | + foreach ($alldata as $number) { |
|
1427 | 1427 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1428 | 1428 | } |
1429 | 1429 | if ($Connection->tableExists('countries')) { |
@@ -1475,8 +1475,8 @@ discard block |
||
1475 | 1475 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1476 | 1476 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
1477 | 1477 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1478 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1479 | - /* |
|
1478 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1479 | + /* |
|
1480 | 1480 | $alldata = array(); |
1481 | 1481 | foreach ($pall as $value) { |
1482 | 1482 | $icao = $value['departure_airport_icao']; |
@@ -1495,29 +1495,29 @@ discard block |
||
1495 | 1495 | } |
1496 | 1496 | array_multisort($count,SORT_DESC,$alldata); |
1497 | 1497 | */ |
1498 | - foreach ($dall as $value) { |
|
1499 | - $icao = $value['departure_airport_icao']; |
|
1500 | - $ddate = $value['date']; |
|
1501 | - $find = false; |
|
1502 | - foreach ($pall as $pvalue) { |
|
1503 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1504 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1505 | - $find = true; |
|
1506 | - break; |
|
1507 | - } |
|
1508 | - } |
|
1509 | - if ($find === false) { |
|
1510 | - $pall[] = $value; |
|
1511 | - } |
|
1512 | - } |
|
1513 | - $alldata = $pall; |
|
1498 | + foreach ($dall as $value) { |
|
1499 | + $icao = $value['departure_airport_icao']; |
|
1500 | + $ddate = $value['date']; |
|
1501 | + $find = false; |
|
1502 | + foreach ($pall as $pvalue) { |
|
1503 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1504 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1505 | + $find = true; |
|
1506 | + break; |
|
1507 | + } |
|
1508 | + } |
|
1509 | + if ($find === false) { |
|
1510 | + $pall[] = $value; |
|
1511 | + } |
|
1512 | + } |
|
1513 | + $alldata = $pall; |
|
1514 | 1514 | foreach ($alldata as $number) { |
1515 | 1515 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
1516 | 1516 | } |
1517 | 1517 | echo '...Arrival'."\n"; |
1518 | 1518 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
1519 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1520 | - /* |
|
1519 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1520 | + /* |
|
1521 | 1521 | $alldata = array(); |
1522 | 1522 | foreach ($pall as $value) { |
1523 | 1523 | $icao = $value['arrival_airport_icao']; |
@@ -1537,22 +1537,22 @@ discard block |
||
1537 | 1537 | */ |
1538 | 1538 | |
1539 | 1539 | |
1540 | - foreach ($dall as $value) { |
|
1541 | - $icao = $value['arrival_airport_icao']; |
|
1542 | - $ddate = $value['date']; |
|
1543 | - $find = false; |
|
1544 | - foreach ($pall as $pvalue) { |
|
1545 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1546 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1547 | - $find = true; |
|
1548 | - break; |
|
1549 | - } |
|
1550 | - } |
|
1551 | - if ($find === false) { |
|
1552 | - $pall[] = $value; |
|
1553 | - } |
|
1554 | - } |
|
1555 | - $alldata = $pall; |
|
1540 | + foreach ($dall as $value) { |
|
1541 | + $icao = $value['arrival_airport_icao']; |
|
1542 | + $ddate = $value['date']; |
|
1543 | + $find = false; |
|
1544 | + foreach ($pall as $pvalue) { |
|
1545 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1546 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1547 | + $find = true; |
|
1548 | + break; |
|
1549 | + } |
|
1550 | + } |
|
1551 | + if ($find === false) { |
|
1552 | + $pall[] = $value; |
|
1553 | + } |
|
1554 | + } |
|
1555 | + $alldata = $pall; |
|
1556 | 1556 | foreach ($alldata as $number) { |
1557 | 1557 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
1558 | 1558 | } |
@@ -1612,47 +1612,47 @@ discard block |
||
1612 | 1612 | } |
1613 | 1613 | |
1614 | 1614 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1615 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1616 | - //$alldata = array(); |
|
1617 | - foreach ($dall as $value) { |
|
1618 | - $icao = $value['airport_departure_icao']; |
|
1619 | - $dicao = $value['airline_icap']; |
|
1620 | - $find = false; |
|
1621 | - foreach ($pall as $pvalue) { |
|
1622 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1623 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1624 | - $find = true; |
|
1625 | - break; |
|
1626 | - } |
|
1627 | - } |
|
1628 | - if ($find === false) { |
|
1629 | - $pall[] = $value; |
|
1630 | - } |
|
1631 | - } |
|
1632 | - $alldata = $pall; |
|
1615 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1616 | + //$alldata = array(); |
|
1617 | + foreach ($dall as $value) { |
|
1618 | + $icao = $value['airport_departure_icao']; |
|
1619 | + $dicao = $value['airline_icap']; |
|
1620 | + $find = false; |
|
1621 | + foreach ($pall as $pvalue) { |
|
1622 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1623 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1624 | + $find = true; |
|
1625 | + break; |
|
1626 | + } |
|
1627 | + } |
|
1628 | + if ($find === false) { |
|
1629 | + $pall[] = $value; |
|
1630 | + } |
|
1631 | + } |
|
1632 | + $alldata = $pall; |
|
1633 | 1633 | foreach ($alldata as $number) { |
1634 | 1634 | 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']); |
1635 | 1635 | } |
1636 | 1636 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1637 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1638 | - //$alldata = array(); |
|
1639 | - foreach ($dall as $value) { |
|
1640 | - $icao = $value['airport_arrival_icao']; |
|
1641 | - $dicao = $value['airline_icao']; |
|
1642 | - $find = false; |
|
1643 | - foreach ($pall as $pvalue) { |
|
1644 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1645 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1646 | - $find = true; |
|
1647 | - break; |
|
1648 | - } |
|
1649 | - } |
|
1650 | - if ($find === false) { |
|
1651 | - $pall[] = $value; |
|
1652 | - } |
|
1653 | - } |
|
1654 | - $alldata = $pall; |
|
1655 | - foreach ($alldata as $number) { |
|
1637 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1638 | + //$alldata = array(); |
|
1639 | + foreach ($dall as $value) { |
|
1640 | + $icao = $value['airport_arrival_icao']; |
|
1641 | + $dicao = $value['airline_icao']; |
|
1642 | + $find = false; |
|
1643 | + foreach ($pall as $pvalue) { |
|
1644 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1645 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1646 | + $find = true; |
|
1647 | + break; |
|
1648 | + } |
|
1649 | + } |
|
1650 | + if ($find === false) { |
|
1651 | + $pall[] = $value; |
|
1652 | + } |
|
1653 | + } |
|
1654 | + $alldata = $pall; |
|
1655 | + foreach ($alldata as $number) { |
|
1656 | 1656 | 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']); |
1657 | 1657 | } |
1658 | 1658 | $Spotter = new Spotter($this->db); |
@@ -1680,47 +1680,47 @@ discard block |
||
1680 | 1680 | } |
1681 | 1681 | echo '...Departure'."\n"; |
1682 | 1682 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1683 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1684 | - foreach ($dall as $value) { |
|
1685 | - $icao = $value['departure_airport_icao']; |
|
1686 | - $airline = $value['airline_icao']; |
|
1687 | - $ddate = $value['date']; |
|
1688 | - $find = false; |
|
1689 | - foreach ($pall as $pvalue) { |
|
1690 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1691 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1692 | - $find = true; |
|
1693 | - break; |
|
1694 | - } |
|
1695 | - } |
|
1696 | - if ($find === false) { |
|
1697 | - $pall[] = $value; |
|
1698 | - } |
|
1699 | - } |
|
1700 | - $alldata = $pall; |
|
1683 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1684 | + foreach ($dall as $value) { |
|
1685 | + $icao = $value['departure_airport_icao']; |
|
1686 | + $airline = $value['airline_icao']; |
|
1687 | + $ddate = $value['date']; |
|
1688 | + $find = false; |
|
1689 | + foreach ($pall as $pvalue) { |
|
1690 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1691 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1692 | + $find = true; |
|
1693 | + break; |
|
1694 | + } |
|
1695 | + } |
|
1696 | + if ($find === false) { |
|
1697 | + $pall[] = $value; |
|
1698 | + } |
|
1699 | + } |
|
1700 | + $alldata = $pall; |
|
1701 | 1701 | foreach ($alldata as $number) { |
1702 | 1702 | $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']); |
1703 | 1703 | } |
1704 | 1704 | echo '...Arrival'."\n"; |
1705 | 1705 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1706 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1707 | - foreach ($dall as $value) { |
|
1708 | - $icao = $value['arrival_airport_icao']; |
|
1709 | - $airline = $value['airline_icao']; |
|
1710 | - $ddate = $value['date']; |
|
1711 | - $find = false; |
|
1712 | - foreach ($pall as $pvalue) { |
|
1713 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1714 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1715 | - $find = true; |
|
1716 | - break; |
|
1717 | - } |
|
1718 | - } |
|
1719 | - if ($find === false) { |
|
1720 | - $pall[] = $value; |
|
1721 | - } |
|
1722 | - } |
|
1723 | - $alldata = $pall; |
|
1706 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1707 | + foreach ($dall as $value) { |
|
1708 | + $icao = $value['arrival_airport_icao']; |
|
1709 | + $airline = $value['airline_icao']; |
|
1710 | + $ddate = $value['date']; |
|
1711 | + $find = false; |
|
1712 | + foreach ($pall as $pvalue) { |
|
1713 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1714 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1715 | + $find = true; |
|
1716 | + break; |
|
1717 | + } |
|
1718 | + } |
|
1719 | + if ($find === false) { |
|
1720 | + $pall[] = $value; |
|
1721 | + } |
|
1722 | + } |
|
1723 | + $alldata = $pall; |
|
1724 | 1724 | foreach ($alldata as $number) { |
1725 | 1725 | $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']); |
1726 | 1726 | } |
@@ -1780,45 +1780,45 @@ discard block |
||
1780 | 1780 | } |
1781 | 1781 | |
1782 | 1782 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
1783 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1784 | - //$alldata = array(); |
|
1785 | - foreach ($dall as $value) { |
|
1786 | - $icao = $value['airport_departure_icao']; |
|
1787 | - $dicao = $value['airline_icap']; |
|
1788 | - $find = false; |
|
1789 | - foreach ($pall as $pvalue) { |
|
1790 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1791 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1792 | - $find = true; |
|
1793 | - break; |
|
1794 | - } |
|
1795 | - } |
|
1796 | - if ($find === false) { |
|
1797 | - $pall[] = $value; |
|
1798 | - } |
|
1799 | - } |
|
1800 | - $alldata = $pall; |
|
1783 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1784 | + //$alldata = array(); |
|
1785 | + foreach ($dall as $value) { |
|
1786 | + $icao = $value['airport_departure_icao']; |
|
1787 | + $dicao = $value['airline_icap']; |
|
1788 | + $find = false; |
|
1789 | + foreach ($pall as $pvalue) { |
|
1790 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1791 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1792 | + $find = true; |
|
1793 | + break; |
|
1794 | + } |
|
1795 | + } |
|
1796 | + if ($find === false) { |
|
1797 | + $pall[] = $value; |
|
1798 | + } |
|
1799 | + } |
|
1800 | + $alldata = $pall; |
|
1801 | 1801 | foreach ($alldata as $number) { |
1802 | - 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); |
|
1802 | + 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); |
|
1803 | 1803 | } |
1804 | 1804 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter); |
1805 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1806 | - //$alldata = array(); |
|
1805 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1806 | + //$alldata = array(); |
|
1807 | 1807 | foreach ($dall as $value) { |
1808 | - $icao = $value['airport_arrival_icao']; |
|
1809 | - $dicao = $value['airline_icao']; |
|
1810 | - $find = false; |
|
1811 | - foreach ($pall as $pvalue) { |
|
1812 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1808 | + $icao = $value['airport_arrival_icao']; |
|
1809 | + $dicao = $value['airline_icao']; |
|
1810 | + $find = false; |
|
1811 | + foreach ($pall as $pvalue) { |
|
1812 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1813 | 1813 | $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1814 | 1814 | $find = true; |
1815 | 1815 | break; |
1816 | - } |
|
1816 | + } |
|
1817 | 1817 | } |
1818 | 1818 | if ($find === false) { |
1819 | 1819 | $pall[] = $value; |
1820 | 1820 | } |
1821 | - } |
|
1821 | + } |
|
1822 | 1822 | $alldata = $pall; |
1823 | 1823 | foreach ($alldata as $number) { |
1824 | 1824 | 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); |
@@ -1848,47 +1848,47 @@ discard block |
||
1848 | 1848 | } |
1849 | 1849 | echo '...Departure'."\n"; |
1850 | 1850 | $pall = $Spotter->getLast7DaysAirportsDeparture($filter); |
1851 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture($filter); |
|
1852 | - foreach ($dall as $value) { |
|
1853 | - $icao = $value['departure_airport_icao']; |
|
1854 | - $airline = $value['airline_icao']; |
|
1855 | - $ddate = $value['date']; |
|
1856 | - $find = false; |
|
1857 | - foreach ($pall as $pvalue) { |
|
1858 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1859 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1860 | - $find = true; |
|
1861 | - break; |
|
1862 | - } |
|
1863 | - } |
|
1851 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture($filter); |
|
1852 | + foreach ($dall as $value) { |
|
1853 | + $icao = $value['departure_airport_icao']; |
|
1854 | + $airline = $value['airline_icao']; |
|
1855 | + $ddate = $value['date']; |
|
1856 | + $find = false; |
|
1857 | + foreach ($pall as $pvalue) { |
|
1858 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1859 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1860 | + $find = true; |
|
1861 | + break; |
|
1862 | + } |
|
1863 | + } |
|
1864 | 1864 | if ($find === false) { |
1865 | - $pall[] = $value; |
|
1866 | - } |
|
1867 | - } |
|
1868 | - $alldata = $pall; |
|
1865 | + $pall[] = $value; |
|
1866 | + } |
|
1867 | + } |
|
1868 | + $alldata = $pall; |
|
1869 | 1869 | foreach ($alldata as $number) { |
1870 | 1870 | $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); |
1871 | 1871 | } |
1872 | 1872 | echo '...Arrival'."\n"; |
1873 | 1873 | $pall = $Spotter->getLast7DaysAirportsArrival($filter); |
1874 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival($filter); |
|
1874 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival($filter); |
|
1875 | 1875 | foreach ($dall as $value) { |
1876 | 1876 | $icao = $value['arrival_airport_icao']; |
1877 | 1877 | $airline = $value['airline_icao']; |
1878 | 1878 | $ddate = $value['date']; |
1879 | - $find = false; |
|
1879 | + $find = false; |
|
1880 | 1880 | foreach ($pall as $pvalue) { |
1881 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1882 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1883 | - $find = true; |
|
1884 | - break; |
|
1885 | - } |
|
1886 | - } |
|
1887 | - if ($find === false) { |
|
1888 | - $pall[] = $value; |
|
1889 | - } |
|
1890 | - } |
|
1891 | - $alldata = $pall; |
|
1881 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1882 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1883 | + $find = true; |
|
1884 | + break; |
|
1885 | + } |
|
1886 | + } |
|
1887 | + if ($find === false) { |
|
1888 | + $pall[] = $value; |
|
1889 | + } |
|
1890 | + } |
|
1891 | + $alldata = $pall; |
|
1892 | 1892 | foreach ($alldata as $number) { |
1893 | 1893 | $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); |
1894 | 1894 | } |