@@ -15,33 +15,33 @@ discard block |
||
15 | 15 | if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
16 | 16 | $Connection = new Connection($dbc); |
17 | 17 | $this->db = $Connection->db(); |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | 20 | public function addLastStatsUpdate($type,$stats_date) { |
21 | - $query = "DELETE FROM config WHERE name = :type; |
|
21 | + $query = "DELETE FROM config WHERE name = :type; |
|
22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | - try { |
|
25 | - $sth = $this->db->prepare($query); |
|
26 | - $sth->execute($query_values); |
|
27 | - } catch(PDOException $e) { |
|
28 | - return "error : ".$e->getMessage(); |
|
29 | - } |
|
30 | - } |
|
23 | + $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | + try { |
|
25 | + $sth = $this->db->prepare($query); |
|
26 | + $sth->execute($query_values); |
|
27 | + } catch(PDOException $e) { |
|
28 | + return "error : ".$e->getMessage(); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | 32 | public function getLastStatsUpdate($type = 'last_update_stats') { |
33 | - $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | - try { |
|
35 | - $sth = $this->db->prepare($query); |
|
36 | - $sth->execute(array(':type' => $type)); |
|
37 | - } catch(PDOException $e) { |
|
38 | - echo "error : ".$e->getMessage(); |
|
39 | - } |
|
40 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | - return $all; |
|
42 | - } |
|
43 | - public function deleteStats($filter_name = '') { |
|
44 | - /* |
|
33 | + $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | + try { |
|
35 | + $sth = $this->db->prepare($query); |
|
36 | + $sth->execute(array(':type' => $type)); |
|
37 | + } catch(PDOException $e) { |
|
38 | + echo "error : ".$e->getMessage(); |
|
39 | + } |
|
40 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | + return $all; |
|
42 | + } |
|
43 | + public function deleteStats($filter_name = '') { |
|
44 | + /* |
|
45 | 45 | $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
46 | 46 | try { |
47 | 47 | $sth = $this->db->prepare($query); |
@@ -50,80 +50,80 @@ discard block |
||
50 | 50 | return "error : ".$e->getMessage(); |
51 | 51 | } |
52 | 52 | */ |
53 | - $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
54 | - try { |
|
55 | - $sth = $this->db->prepare($query); |
|
56 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
57 | - } catch(PDOException $e) { |
|
58 | - return "error : ".$e->getMessage(); |
|
59 | - } |
|
60 | - } |
|
61 | - public function deleteOldStats($filter_name = '') { |
|
53 | + $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
54 | + try { |
|
55 | + $sth = $this->db->prepare($query); |
|
56 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
57 | + } catch(PDOException $e) { |
|
58 | + return "error : ".$e->getMessage(); |
|
59 | + } |
|
60 | + } |
|
61 | + public function deleteOldStats($filter_name = '') { |
|
62 | 62 | |
63 | - $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
64 | - try { |
|
65 | - $sth = $this->db->prepare($query); |
|
66 | - $sth->execute(); |
|
67 | - } catch(PDOException $e) { |
|
68 | - return "error : ".$e->getMessage(); |
|
69 | - } |
|
63 | + $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
64 | + try { |
|
65 | + $sth = $this->db->prepare($query); |
|
66 | + $sth->execute(); |
|
67 | + } catch(PDOException $e) { |
|
68 | + return "error : ".$e->getMessage(); |
|
69 | + } |
|
70 | 70 | |
71 | - $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
72 | - try { |
|
73 | - $sth = $this->db->prepare($query); |
|
74 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
75 | - } catch(PDOException $e) { |
|
76 | - return "error : ".$e->getMessage(); |
|
77 | - } |
|
78 | - } |
|
71 | + $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
72 | + try { |
|
73 | + $sth = $this->db->prepare($query); |
|
74 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
75 | + } catch(PDOException $e) { |
|
76 | + return "error : ".$e->getMessage(); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | public function getAllAirlineNames($filter_name = '') { |
80 | 80 | if ($filter_name == '') $filter_name = $this->filter_name; |
81 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
82 | - try { |
|
83 | - $sth = $this->db->prepare($query); |
|
84 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
85 | - } catch(PDOException $e) { |
|
86 | - echo "error : ".$e->getMessage(); |
|
87 | - } |
|
88 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
89 | - return $all; |
|
90 | - } |
|
81 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
82 | + try { |
|
83 | + $sth = $this->db->prepare($query); |
|
84 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
85 | + } catch(PDOException $e) { |
|
86 | + echo "error : ".$e->getMessage(); |
|
87 | + } |
|
88 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
89 | + return $all; |
|
90 | + } |
|
91 | 91 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
92 | 92 | if ($filter_name == '') $filter_name = $this->filter_name; |
93 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
94 | - try { |
|
95 | - $sth = $this->db->prepare($query); |
|
96 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
97 | - } catch(PDOException $e) { |
|
98 | - echo "error : ".$e->getMessage(); |
|
99 | - } |
|
100 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
101 | - return $all; |
|
102 | - } |
|
93 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
94 | + try { |
|
95 | + $sth = $this->db->prepare($query); |
|
96 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
97 | + } catch(PDOException $e) { |
|
98 | + echo "error : ".$e->getMessage(); |
|
99 | + } |
|
100 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
101 | + return $all; |
|
102 | + } |
|
103 | 103 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
104 | 104 | if ($filter_name == '') $filter_name = $this->filter_name; |
105 | - $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
|
106 | - try { |
|
107 | - $sth = $this->db->prepare($query); |
|
108 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
109 | - } catch(PDOException $e) { |
|
110 | - echo "error : ".$e->getMessage(); |
|
111 | - } |
|
112 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
113 | - return $all; |
|
114 | - } |
|
105 | + $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
|
106 | + try { |
|
107 | + $sth = $this->db->prepare($query); |
|
108 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
109 | + } catch(PDOException $e) { |
|
110 | + echo "error : ".$e->getMessage(); |
|
111 | + } |
|
112 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
113 | + return $all; |
|
114 | + } |
|
115 | 115 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
116 | 116 | if ($filter_name == '') $filter_name = $this->filter_name; |
117 | - $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
118 | - try { |
|
119 | - $sth = $this->db->prepare($query); |
|
120 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
121 | - } catch(PDOException $e) { |
|
122 | - echo "error : ".$e->getMessage(); |
|
123 | - } |
|
124 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
125 | - return $all; |
|
126 | - } |
|
117 | + $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
118 | + try { |
|
119 | + $sth = $this->db->prepare($query); |
|
120 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
121 | + } catch(PDOException $e) { |
|
122 | + echo "error : ".$e->getMessage(); |
|
123 | + } |
|
124 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
125 | + return $all; |
|
126 | + } |
|
127 | 127 | |
128 | 128 | |
129 | 129 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -131,66 +131,66 @@ discard block |
||
131 | 131 | if ($filter_name == '') $filter_name = $this->filter_name; |
132 | 132 | 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"; |
133 | 133 | 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"; |
134 | - try { |
|
135 | - $sth = $this->db->prepare($query); |
|
136 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
137 | - } catch(PDOException $e) { |
|
138 | - echo "error : ".$e->getMessage(); |
|
139 | - } |
|
140 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
141 | - if (empty($all)) { |
|
142 | - $filters = array('airlines' => array($stats_airline)); |
|
143 | - if ($filter_name != '') { |
|
144 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
145 | - } |
|
146 | - $Spotter = new Spotter($this->db); |
|
147 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
148 | - } |
|
149 | - return $all; |
|
134 | + try { |
|
135 | + $sth = $this->db->prepare($query); |
|
136 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
137 | + } catch(PDOException $e) { |
|
138 | + echo "error : ".$e->getMessage(); |
|
139 | + } |
|
140 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
141 | + if (empty($all)) { |
|
142 | + $filters = array('airlines' => array($stats_airline)); |
|
143 | + if ($filter_name != '') { |
|
144 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
145 | + } |
|
146 | + $Spotter = new Spotter($this->db); |
|
147 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
148 | + } |
|
149 | + return $all; |
|
150 | 150 | } |
151 | 151 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
152 | 152 | global $globalStatsFilters; |
153 | 153 | if ($filter_name == '') $filter_name = $this->filter_name; |
154 | 154 | 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"; |
155 | 155 | 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"; |
156 | - try { |
|
157 | - $sth = $this->db->prepare($query); |
|
158 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
159 | - } catch(PDOException $e) { |
|
160 | - echo "error : ".$e->getMessage(); |
|
161 | - } |
|
162 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
163 | - if (empty($all)) { |
|
164 | - $Spotter = new Spotter($this->db); |
|
165 | - $filters = array(); |
|
166 | - if ($filter_name != '') { |
|
167 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
168 | - } |
|
169 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
170 | - } |
|
171 | - return $all; |
|
156 | + try { |
|
157 | + $sth = $this->db->prepare($query); |
|
158 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
159 | + } catch(PDOException $e) { |
|
160 | + echo "error : ".$e->getMessage(); |
|
161 | + } |
|
162 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
163 | + if (empty($all)) { |
|
164 | + $Spotter = new Spotter($this->db); |
|
165 | + $filters = array(); |
|
166 | + if ($filter_name != '') { |
|
167 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
168 | + } |
|
169 | + $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
170 | + } |
|
171 | + return $all; |
|
172 | 172 | } |
173 | 173 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
174 | 174 | global $globalStatsFilters; |
175 | 175 | if ($filter_name == '') $filter_name = $this->filter_name; |
176 | 176 | 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"; |
177 | 177 | 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"; |
178 | - try { |
|
179 | - $sth = $this->db->prepare($query); |
|
180 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
181 | - } catch(PDOException $e) { |
|
182 | - echo "error : ".$e->getMessage(); |
|
183 | - } |
|
184 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
185 | - if (empty($all)) { |
|
186 | - $filters = array('airlines' => array($stats_airline)); |
|
187 | - if ($filter_name != '') { |
|
188 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
178 | + try { |
|
179 | + $sth = $this->db->prepare($query); |
|
180 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
181 | + } catch(PDOException $e) { |
|
182 | + echo "error : ".$e->getMessage(); |
|
183 | + } |
|
184 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
185 | + if (empty($all)) { |
|
186 | + $filters = array('airlines' => array($stats_airline)); |
|
187 | + if ($filter_name != '') { |
|
188 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
189 | 189 | } |
190 | - $Spotter = new Spotter($this->db); |
|
190 | + $Spotter = new Spotter($this->db); |
|
191 | 191 | $all = $Spotter->countAllAircraftManufacturers($filters); |
192 | - } |
|
193 | - return $all; |
|
192 | + } |
|
193 | + return $all; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -198,44 +198,44 @@ discard block |
||
198 | 198 | if ($filter_name == '') $filter_name = $this->filter_name; |
199 | 199 | 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"; |
200 | 200 | 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"; |
201 | - try { |
|
202 | - $sth = $this->db->prepare($query); |
|
203 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
204 | - } catch(PDOException $e) { |
|
205 | - echo "error : ".$e->getMessage(); |
|
206 | - } |
|
207 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
208 | - if (empty($all)) { |
|
201 | + try { |
|
202 | + $sth = $this->db->prepare($query); |
|
203 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
204 | + } catch(PDOException $e) { |
|
205 | + echo "error : ".$e->getMessage(); |
|
206 | + } |
|
207 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
208 | + if (empty($all)) { |
|
209 | 209 | $filters = array('airlines' => array($stats_airline)); |
210 | 210 | if ($filter_name != '') { |
211 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
211 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
212 | 212 | } |
213 | 213 | $Spotter = new Spotter($this->db); |
214 | 214 | $all = $Spotter->countAllArrivalCountries($limit,$filters); |
215 | - } |
|
216 | - return $all; |
|
215 | + } |
|
216 | + return $all; |
|
217 | 217 | } |
218 | 218 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
219 | 219 | global $globalStatsFilters; |
220 | 220 | if ($filter_name == '') $filter_name = $this->filter_name; |
221 | 221 | 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"; |
222 | 222 | 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"; |
223 | - try { |
|
224 | - $sth = $this->db->prepare($query); |
|
225 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
226 | - } catch(PDOException $e) { |
|
227 | - echo "error : ".$e->getMessage(); |
|
228 | - } |
|
229 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
230 | - if (empty($all)) { |
|
223 | + try { |
|
224 | + $sth = $this->db->prepare($query); |
|
225 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
226 | + } catch(PDOException $e) { |
|
227 | + echo "error : ".$e->getMessage(); |
|
228 | + } |
|
229 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
230 | + if (empty($all)) { |
|
231 | 231 | $filters = array('airlines' => array($stats_airline)); |
232 | 232 | if ($filter_name != '') { |
233 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
233 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
234 | 234 | } |
235 | 235 | $Spotter = new Spotter($this->db); |
236 | 236 | $all = $Spotter->countAllDepartureCountries($filters); |
237 | - } |
|
238 | - return $all; |
|
237 | + } |
|
238 | + return $all; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | public function countAllAirlines($limit = true,$filter_name = '') { |
@@ -243,45 +243,45 @@ discard block |
||
243 | 243 | if ($filter_name == '') $filter_name = $this->filter_name; |
244 | 244 | 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"; |
245 | 245 | 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"; |
246 | - try { |
|
247 | - $sth = $this->db->prepare($query); |
|
248 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
249 | - } catch(PDOException $e) { |
|
250 | - echo "error : ".$e->getMessage(); |
|
251 | - } |
|
252 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
253 | - if (empty($all)) { |
|
254 | - $Spotter = new Spotter($this->db); |
|
255 | - $filters = array(); |
|
256 | - if ($filter_name != '') { |
|
257 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
246 | + try { |
|
247 | + $sth = $this->db->prepare($query); |
|
248 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
249 | + } catch(PDOException $e) { |
|
250 | + echo "error : ".$e->getMessage(); |
|
251 | + } |
|
252 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
253 | + if (empty($all)) { |
|
254 | + $Spotter = new Spotter($this->db); |
|
255 | + $filters = array(); |
|
256 | + if ($filter_name != '') { |
|
257 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
258 | 258 | } |
259 | 259 | |
260 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
261 | - } |
|
262 | - return $all; |
|
260 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
261 | + } |
|
262 | + return $all; |
|
263 | 263 | } |
264 | 264 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
265 | 265 | global $globalStatsFilters; |
266 | 266 | if ($filter_name == '') $filter_name = $this->filter_name; |
267 | 267 | 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"; |
268 | 268 | 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"; |
269 | - try { |
|
270 | - $sth = $this->db->prepare($query); |
|
271 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
272 | - } catch(PDOException $e) { |
|
273 | - echo "error : ".$e->getMessage(); |
|
274 | - } |
|
275 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
276 | - if (empty($all)) { |
|
269 | + try { |
|
270 | + $sth = $this->db->prepare($query); |
|
271 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
272 | + } catch(PDOException $e) { |
|
273 | + echo "error : ".$e->getMessage(); |
|
274 | + } |
|
275 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
276 | + if (empty($all)) { |
|
277 | 277 | $filters = array('airlines' => array($stats_airline)); |
278 | 278 | if ($filter_name != '') { |
279 | 279 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
280 | 280 | } |
281 | - $Spotter = new Spotter($this->db); |
|
282 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
283 | - } |
|
284 | - return $all; |
|
281 | + $Spotter = new Spotter($this->db); |
|
282 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
283 | + } |
|
284 | + return $all; |
|
285 | 285 | } |
286 | 286 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
287 | 287 | global $globalStatsFilters; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | echo "error : ".$e->getMessage(); |
319 | 319 | } |
320 | 320 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
321 | - /* |
|
321 | + /* |
|
322 | 322 | if (empty($all)) { |
323 | 323 | $Spotter = new Spotter($this->db); |
324 | 324 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -334,84 +334,84 @@ discard block |
||
334 | 334 | if ($filter_name == '') $filter_name = $this->filter_name; |
335 | 335 | if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
336 | 336 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
337 | - try { |
|
338 | - $sth = $this->db->prepare($query); |
|
339 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
340 | - } catch(PDOException $e) { |
|
341 | - echo "error : ".$e->getMessage(); |
|
342 | - } |
|
343 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
344 | - if (empty($all)) { |
|
337 | + try { |
|
338 | + $sth = $this->db->prepare($query); |
|
339 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
340 | + } catch(PDOException $e) { |
|
341 | + echo "error : ".$e->getMessage(); |
|
342 | + } |
|
343 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
344 | + if (empty($all)) { |
|
345 | 345 | $filters = array('airlines' => array($stats_airline)); |
346 | 346 | if ($filter_name != '') { |
347 | 347 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
348 | 348 | } |
349 | - $Spotter = new Spotter($this->db); |
|
350 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
351 | - } |
|
352 | - return $all; |
|
349 | + $Spotter = new Spotter($this->db); |
|
350 | + $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
351 | + } |
|
352 | + return $all; |
|
353 | 353 | } |
354 | 354 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
355 | 355 | global $globalStatsFilters; |
356 | 356 | if ($filter_name == '') $filter_name = $this->filter_name; |
357 | 357 | 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"; |
358 | 358 | 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"; |
359 | - try { |
|
360 | - $sth = $this->db->prepare($query); |
|
361 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
362 | - } catch(PDOException $e) { |
|
363 | - echo "error : ".$e->getMessage(); |
|
364 | - } |
|
365 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
366 | - if (empty($all)) { |
|
359 | + try { |
|
360 | + $sth = $this->db->prepare($query); |
|
361 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
362 | + } catch(PDOException $e) { |
|
363 | + echo "error : ".$e->getMessage(); |
|
364 | + } |
|
365 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
366 | + if (empty($all)) { |
|
367 | 367 | $filters = array('airlines' => array($stats_airline)); |
368 | 368 | if ($filter_name != '') { |
369 | 369 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
370 | 370 | } |
371 | - $Spotter = new Spotter($this->db); |
|
372 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
373 | - } |
|
374 | - return $all; |
|
371 | + $Spotter = new Spotter($this->db); |
|
372 | + $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
373 | + } |
|
374 | + return $all; |
|
375 | 375 | } |
376 | 376 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
377 | 377 | global $globalStatsFilters; |
378 | 378 | if ($filter_name == '') $filter_name = $this->filter_name; |
379 | 379 | if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
380 | 380 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
381 | - try { |
|
382 | - $sth = $this->db->prepare($query); |
|
383 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
384 | - } catch(PDOException $e) { |
|
385 | - echo "error : ".$e->getMessage(); |
|
386 | - } |
|
387 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
388 | - if (empty($all)) { |
|
381 | + try { |
|
382 | + $sth = $this->db->prepare($query); |
|
383 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
384 | + } catch(PDOException $e) { |
|
385 | + echo "error : ".$e->getMessage(); |
|
386 | + } |
|
387 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
388 | + if (empty($all)) { |
|
389 | 389 | $filters = array('airlines' => array($stats_airline)); |
390 | - if ($filter_name != '') { |
|
391 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
392 | - } |
|
393 | - $Spotter = new Spotter($this->db); |
|
394 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
395 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
396 | - $all = array(); |
|
397 | - foreach ($pall as $value) { |
|
398 | - $icao = $value['airport_departure_icao']; |
|
399 | - $all[$icao] = $value; |
|
400 | - } |
|
390 | + if ($filter_name != '') { |
|
391 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
392 | + } |
|
393 | + $Spotter = new Spotter($this->db); |
|
394 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
395 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
396 | + $all = array(); |
|
397 | + foreach ($pall as $value) { |
|
398 | + $icao = $value['airport_departure_icao']; |
|
399 | + $all[$icao] = $value; |
|
400 | + } |
|
401 | 401 | |
402 | - foreach ($dall as $value) { |
|
403 | - $icao = $value['airport_departure_icao']; |
|
404 | - if (isset($all[$icao])) { |
|
405 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
406 | - } else $all[$icao] = $value; |
|
407 | - } |
|
408 | - $count = array(); |
|
409 | - foreach ($all as $key => $row) { |
|
410 | - $count[$key] = $row['airport_departure_icao_count']; |
|
411 | - } |
|
412 | - array_multisort($count,SORT_DESC,$all); |
|
413 | - } |
|
414 | - return $all; |
|
402 | + foreach ($dall as $value) { |
|
403 | + $icao = $value['airport_departure_icao']; |
|
404 | + if (isset($all[$icao])) { |
|
405 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
406 | + } else $all[$icao] = $value; |
|
407 | + } |
|
408 | + $count = array(); |
|
409 | + foreach ($all as $key => $row) { |
|
410 | + $count[$key] = $row['airport_departure_icao_count']; |
|
411 | + } |
|
412 | + array_multisort($count,SORT_DESC,$all); |
|
413 | + } |
|
414 | + return $all; |
|
415 | 415 | } |
416 | 416 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
417 | 417 | global $globalStatsFilters; |
@@ -433,26 +433,26 @@ discard block |
||
433 | 433 | $Spotter = new Spotter($this->db); |
434 | 434 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
435 | 435 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
436 | - $all = array(); |
|
437 | - foreach ($pall as $value) { |
|
438 | - $icao = $value['airport_arrival_icao']; |
|
439 | - $all[$icao] = $value; |
|
440 | - } |
|
436 | + $all = array(); |
|
437 | + foreach ($pall as $value) { |
|
438 | + $icao = $value['airport_arrival_icao']; |
|
439 | + $all[$icao] = $value; |
|
440 | + } |
|
441 | 441 | |
442 | - foreach ($dall as $value) { |
|
443 | - $icao = $value['airport_arrival_icao']; |
|
444 | - if (isset($all[$icao])) { |
|
445 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
446 | - } else $all[$icao] = $value; |
|
447 | - } |
|
448 | - $count = array(); |
|
449 | - foreach ($all as $key => $row) { |
|
450 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
451 | - } |
|
452 | - array_multisort($count,SORT_DESC,$all); |
|
453 | - } |
|
442 | + foreach ($dall as $value) { |
|
443 | + $icao = $value['airport_arrival_icao']; |
|
444 | + if (isset($all[$icao])) { |
|
445 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
446 | + } else $all[$icao] = $value; |
|
447 | + } |
|
448 | + $count = array(); |
|
449 | + foreach ($all as $key => $row) { |
|
450 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
451 | + } |
|
452 | + array_multisort($count,SORT_DESC,$all); |
|
453 | + } |
|
454 | 454 | |
455 | - return $all; |
|
455 | + return $all; |
|
456 | 456 | } |
457 | 457 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
458 | 458 | global $globalDBdriver, $globalStatsFilters; |
@@ -465,23 +465,23 @@ discard block |
||
465 | 465 | 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"; |
466 | 466 | } |
467 | 467 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
468 | - try { |
|
469 | - $sth = $this->db->prepare($query); |
|
470 | - $sth->execute($query_data); |
|
471 | - } catch(PDOException $e) { |
|
472 | - echo "error : ".$e->getMessage(); |
|
473 | - } |
|
474 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
475 | - if (empty($all)) { |
|
468 | + try { |
|
469 | + $sth = $this->db->prepare($query); |
|
470 | + $sth->execute($query_data); |
|
471 | + } catch(PDOException $e) { |
|
472 | + echo "error : ".$e->getMessage(); |
|
473 | + } |
|
474 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
475 | + if (empty($all)) { |
|
476 | 476 | $filters = array('airlines' => array($stats_airline)); |
477 | 477 | if ($filter_name != '') { |
478 | 478 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
479 | 479 | } |
480 | - $Spotter = new Spotter($this->db); |
|
481 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
482 | - } |
|
480 | + $Spotter = new Spotter($this->db); |
|
481 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
482 | + } |
|
483 | 483 | |
484 | - return $all; |
|
484 | + return $all; |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
@@ -489,22 +489,22 @@ discard block |
||
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 = 'month' 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 | 502 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
503 | 503 | } |
504 | - $Spotter = new Spotter($this->db); |
|
505 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
506 | - } |
|
507 | - return $all; |
|
504 | + $Spotter = new Spotter($this->db); |
|
505 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
506 | + } |
|
507 | + return $all; |
|
508 | 508 | } |
509 | 509 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
510 | 510 | global $globalDBdriver, $globalStatsFilters; |
@@ -515,108 +515,108 @@ discard block |
||
515 | 515 | $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"; |
516 | 516 | } |
517 | 517 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
518 | - try { |
|
519 | - $sth = $this->db->prepare($query); |
|
520 | - $sth->execute($query_data); |
|
521 | - } catch(PDOException $e) { |
|
522 | - echo "error : ".$e->getMessage(); |
|
523 | - } |
|
524 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
525 | - if (empty($all)) { |
|
518 | + try { |
|
519 | + $sth = $this->db->prepare($query); |
|
520 | + $sth->execute($query_data); |
|
521 | + } catch(PDOException $e) { |
|
522 | + echo "error : ".$e->getMessage(); |
|
523 | + } |
|
524 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
525 | + if (empty($all)) { |
|
526 | 526 | $filters = array('airlines' => array($stats_airline)); |
527 | 527 | if ($filter_name != '') { |
528 | 528 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
529 | 529 | } |
530 | - $Spotter = new Spotter($this->db); |
|
531 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
532 | - } |
|
533 | - return $all; |
|
530 | + $Spotter = new Spotter($this->db); |
|
531 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
532 | + } |
|
533 | + return $all; |
|
534 | 534 | } |
535 | 535 | public function countAllDates($stats_airline = '',$filter_name = '') { |
536 | 536 | global $globalStatsFilters; |
537 | 537 | if ($filter_name == '') $filter_name = $this->filter_name; |
538 | 538 | $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"; |
539 | 539 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
540 | - try { |
|
541 | - $sth = $this->db->prepare($query); |
|
542 | - $sth->execute($query_data); |
|
543 | - } catch(PDOException $e) { |
|
544 | - echo "error : ".$e->getMessage(); |
|
545 | - } |
|
546 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
547 | - if (empty($all)) { |
|
540 | + try { |
|
541 | + $sth = $this->db->prepare($query); |
|
542 | + $sth->execute($query_data); |
|
543 | + } catch(PDOException $e) { |
|
544 | + echo "error : ".$e->getMessage(); |
|
545 | + } |
|
546 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
547 | + if (empty($all)) { |
|
548 | 548 | $filters = array('airlines' => array($stats_airline)); |
549 | 549 | if ($filter_name != '') { |
550 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
550 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
551 | 551 | } |
552 | - $Spotter = new Spotter($this->db); |
|
553 | - $all = $Spotter->countAllDates($filters); |
|
554 | - } |
|
555 | - return $all; |
|
552 | + $Spotter = new Spotter($this->db); |
|
553 | + $all = $Spotter->countAllDates($filters); |
|
554 | + } |
|
555 | + return $all; |
|
556 | 556 | } |
557 | 557 | public function countAllDatesByAirlines($filter_name = '') { |
558 | 558 | global $globalStatsFilters; |
559 | 559 | if ($filter_name == '') $filter_name = $this->filter_name; |
560 | 560 | $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"; |
561 | 561 | $query_data = array('filter_name' => $filter_name); |
562 | - try { |
|
563 | - $sth = $this->db->prepare($query); |
|
564 | - $sth->execute($query_data); |
|
565 | - } catch(PDOException $e) { |
|
566 | - echo "error : ".$e->getMessage(); |
|
567 | - } |
|
568 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
569 | - if (empty($all)) { |
|
570 | - $filters = array(); |
|
571 | - if ($filter_name != '') { |
|
572 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
573 | - } |
|
574 | - $Spotter = new Spotter($this->db); |
|
575 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
576 | - } |
|
577 | - return $all; |
|
562 | + try { |
|
563 | + $sth = $this->db->prepare($query); |
|
564 | + $sth->execute($query_data); |
|
565 | + } catch(PDOException $e) { |
|
566 | + echo "error : ".$e->getMessage(); |
|
567 | + } |
|
568 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
569 | + if (empty($all)) { |
|
570 | + $filters = array(); |
|
571 | + if ($filter_name != '') { |
|
572 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
573 | + } |
|
574 | + $Spotter = new Spotter($this->db); |
|
575 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
576 | + } |
|
577 | + return $all; |
|
578 | 578 | } |
579 | 579 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
580 | 580 | global $globalStatsFilters; |
581 | 581 | if ($filter_name == '') $filter_name = $this->filter_name; |
582 | - $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"; |
|
583 | - try { |
|
584 | - $sth = $this->db->prepare($query); |
|
585 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
586 | - } catch(PDOException $e) { |
|
587 | - echo "error : ".$e->getMessage(); |
|
588 | - } |
|
589 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
590 | - if (empty($all)) { |
|
582 | + $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"; |
|
583 | + try { |
|
584 | + $sth = $this->db->prepare($query); |
|
585 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
586 | + } catch(PDOException $e) { |
|
587 | + echo "error : ".$e->getMessage(); |
|
588 | + } |
|
589 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
590 | + if (empty($all)) { |
|
591 | 591 | $filters = array('airlines' => array($stats_airline)); |
592 | 592 | if ($filter_name != '') { |
593 | 593 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
594 | 594 | } |
595 | - $Spotter = new Spotter($this->db); |
|
596 | - $all = $Spotter->countAllMonths($filters); |
|
597 | - } |
|
598 | - return $all; |
|
595 | + $Spotter = new Spotter($this->db); |
|
596 | + $all = $Spotter->countAllMonths($filters); |
|
597 | + } |
|
598 | + return $all; |
|
599 | 599 | } |
600 | 600 | public function countAllMilitaryMonths($filter_name = '') { |
601 | 601 | global $globalStatsFilters; |
602 | 602 | if ($filter_name == '') $filter_name = $this->filter_name; |
603 | - $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"; |
|
604 | - try { |
|
605 | - $sth = $this->db->prepare($query); |
|
606 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
607 | - } catch(PDOException $e) { |
|
608 | - echo "error : ".$e->getMessage(); |
|
609 | - } |
|
610 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
611 | - if (empty($all)) { |
|
612 | - $filters = array(); |
|
613 | - if ($filter_name != '') { |
|
614 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
615 | - } |
|
616 | - $Spotter = new Spotter($this->db); |
|
617 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
618 | - } |
|
619 | - return $all; |
|
603 | + $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"; |
|
604 | + try { |
|
605 | + $sth = $this->db->prepare($query); |
|
606 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
607 | + } catch(PDOException $e) { |
|
608 | + echo "error : ".$e->getMessage(); |
|
609 | + } |
|
610 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
611 | + if (empty($all)) { |
|
612 | + $filters = array(); |
|
613 | + if ($filter_name != '') { |
|
614 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
615 | + } |
|
616 | + $Spotter = new Spotter($this->db); |
|
617 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
618 | + } |
|
619 | + return $all; |
|
620 | 620 | } |
621 | 621 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
622 | 622 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -632,22 +632,22 @@ discard block |
||
632 | 632 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
633 | 633 | } |
634 | 634 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
635 | - try { |
|
636 | - $sth = $this->db->prepare($query); |
|
637 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
638 | - } catch(PDOException $e) { |
|
639 | - echo "error : ".$e->getMessage(); |
|
640 | - } |
|
641 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
642 | - if (empty($all)) { |
|
635 | + try { |
|
636 | + $sth = $this->db->prepare($query); |
|
637 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
638 | + } catch(PDOException $e) { |
|
639 | + echo "error : ".$e->getMessage(); |
|
640 | + } |
|
641 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
642 | + if (empty($all)) { |
|
643 | 643 | $filters = array('airlines' => array($stats_airline)); |
644 | 644 | if ($filter_name != '') { |
645 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
645 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
646 | 646 | } |
647 | - $Spotter = new Spotter($this->db); |
|
648 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
649 | - } |
|
650 | - return $all; |
|
647 | + $Spotter = new Spotter($this->db); |
|
648 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
649 | + } |
|
650 | + return $all; |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
@@ -669,9 +669,9 @@ discard block |
||
669 | 669 | if ($filter_name == '') $filter_name = $this->filter_name; |
670 | 670 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
671 | 671 | if (empty($all)) { |
672 | - $filters = array(); |
|
673 | - if ($filter_name != '') { |
|
674 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
672 | + $filters = array(); |
|
673 | + if ($filter_name != '') { |
|
674 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
675 | 675 | } |
676 | 676 | $Spotter = new Spotter($this->db); |
677 | 677 | $all = $Spotter->countOverallMilitaryFlights($filters); |
@@ -710,19 +710,19 @@ discard block |
||
710 | 710 | global $globalStatsFilters; |
711 | 711 | if ($filter_name == '') $filter_name = $this->filter_name; |
712 | 712 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
713 | - try { |
|
714 | - $sth = $this->db->prepare($query); |
|
715 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
716 | - } catch(PDOException $e) { |
|
717 | - echo "error : ".$e->getMessage(); |
|
718 | - } |
|
719 | - $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
720 | - $all = $result[0]['nb_airline']; |
|
713 | + try { |
|
714 | + $sth = $this->db->prepare($query); |
|
715 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
716 | + } catch(PDOException $e) { |
|
717 | + echo "error : ".$e->getMessage(); |
|
718 | + } |
|
719 | + $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
720 | + $all = $result[0]['nb_airline']; |
|
721 | 721 | //$all = $this->getSumStats('airlines_bymonth',date('Y')); |
722 | 722 | if (empty($all)) { |
723 | - $filters = array(); |
|
724 | - if ($filter_name != '') { |
|
725 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
723 | + $filters = array(); |
|
724 | + if ($filter_name != '') { |
|
725 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
726 | 726 | } |
727 | 727 | $Spotter = new Spotter($this->db); |
728 | 728 | $all = $Spotter->countOverallAirlines($filters); |
@@ -773,166 +773,166 @@ discard block |
||
773 | 773 | if ($filter_name == '') $filter_name = $this->filter_name; |
774 | 774 | $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"; |
775 | 775 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
776 | - try { |
|
777 | - $sth = $this->db->prepare($query); |
|
778 | - $sth->execute($query_values); |
|
779 | - } catch(PDOException $e) { |
|
780 | - echo "error : ".$e->getMessage(); |
|
781 | - } |
|
782 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
783 | - return $all; |
|
776 | + try { |
|
777 | + $sth = $this->db->prepare($query); |
|
778 | + $sth->execute($query_values); |
|
779 | + } catch(PDOException $e) { |
|
780 | + echo "error : ".$e->getMessage(); |
|
781 | + } |
|
782 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
783 | + return $all; |
|
784 | 784 | } |
785 | 785 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
786 | 786 | if ($filter_name == '') $filter_name = $this->filter_name; |
787 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
788 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
789 | - try { |
|
790 | - $sth = $this->db->prepare($query); |
|
791 | - $sth->execute($query_values); |
|
792 | - } catch(PDOException $e) { |
|
793 | - echo "error : ".$e->getMessage(); |
|
794 | - } |
|
795 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
796 | - return $all; |
|
797 | - } |
|
787 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
788 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
789 | + try { |
|
790 | + $sth = $this->db->prepare($query); |
|
791 | + $sth->execute($query_values); |
|
792 | + } catch(PDOException $e) { |
|
793 | + echo "error : ".$e->getMessage(); |
|
794 | + } |
|
795 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
796 | + return $all; |
|
797 | + } |
|
798 | 798 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
799 | 799 | if ($filter_name == '') $filter_name = $this->filter_name; |
800 | - global $globalArchiveMonths, $globalDBdriver; |
|
801 | - if ($globalDBdriver == 'mysql') { |
|
802 | - $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"; |
|
803 | - } else { |
|
804 | - $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"; |
|
805 | - } |
|
806 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
807 | - try { |
|
808 | - $sth = $this->db->prepare($query); |
|
809 | - $sth->execute($query_values); |
|
810 | - } catch(PDOException $e) { |
|
811 | - echo "error : ".$e->getMessage(); |
|
812 | - } |
|
813 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
814 | - return $all[0]['total']; |
|
815 | - } |
|
800 | + global $globalArchiveMonths, $globalDBdriver; |
|
801 | + if ($globalDBdriver == 'mysql') { |
|
802 | + $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"; |
|
803 | + } else { |
|
804 | + $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"; |
|
805 | + } |
|
806 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
807 | + try { |
|
808 | + $sth = $this->db->prepare($query); |
|
809 | + $sth->execute($query_values); |
|
810 | + } catch(PDOException $e) { |
|
811 | + echo "error : ".$e->getMessage(); |
|
812 | + } |
|
813 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
814 | + return $all[0]['total']; |
|
815 | + } |
|
816 | 816 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
817 | - global $globalArchiveMonths, $globalDBdriver; |
|
817 | + global $globalArchiveMonths, $globalDBdriver; |
|
818 | 818 | if ($filter_name == '') $filter_name = $this->filter_name; |
819 | - if ($globalDBdriver == 'mysql') { |
|
819 | + if ($globalDBdriver == 'mysql') { |
|
820 | 820 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
821 | 821 | } else { |
822 | 822 | $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"; |
823 | - } |
|
824 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
825 | - try { |
|
826 | - $sth = $this->db->prepare($query); |
|
827 | - $sth->execute($query_values); |
|
828 | - } catch(PDOException $e) { |
|
829 | - echo "error : ".$e->getMessage(); |
|
830 | - } |
|
831 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
832 | - return $all[0]['total']; |
|
833 | - } |
|
823 | + } |
|
824 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
825 | + try { |
|
826 | + $sth = $this->db->prepare($query); |
|
827 | + $sth->execute($query_values); |
|
828 | + } catch(PDOException $e) { |
|
829 | + echo "error : ".$e->getMessage(); |
|
830 | + } |
|
831 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
832 | + return $all[0]['total']; |
|
833 | + } |
|
834 | 834 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
835 | - global $globalArchiveMonths, $globalDBdriver; |
|
835 | + global $globalArchiveMonths, $globalDBdriver; |
|
836 | 836 | if ($filter_name == '') $filter_name = $this->filter_name; |
837 | - if ($globalDBdriver == 'mysql') { |
|
837 | + if ($globalDBdriver == 'mysql') { |
|
838 | 838 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
839 | - } else { |
|
839 | + } else { |
|
840 | 840 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
841 | - } |
|
842 | - try { |
|
843 | - $sth = $this->db->prepare($query); |
|
844 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
845 | - } catch(PDOException $e) { |
|
846 | - echo "error : ".$e->getMessage(); |
|
847 | - } |
|
848 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
849 | - return $all[0]['total']; |
|
850 | - } |
|
841 | + } |
|
842 | + try { |
|
843 | + $sth = $this->db->prepare($query); |
|
844 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
845 | + } catch(PDOException $e) { |
|
846 | + echo "error : ".$e->getMessage(); |
|
847 | + } |
|
848 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
849 | + return $all[0]['total']; |
|
850 | + } |
|
851 | 851 | public function getStatsAirlineTotal($filter_name = '') { |
852 | - global $globalArchiveMonths, $globalDBdriver; |
|
852 | + global $globalArchiveMonths, $globalDBdriver; |
|
853 | 853 | if ($filter_name == '') $filter_name = $this->filter_name; |
854 | - if ($globalDBdriver == 'mysql') { |
|
854 | + if ($globalDBdriver == 'mysql') { |
|
855 | 855 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
856 | - } else { |
|
856 | + } else { |
|
857 | 857 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
858 | - } |
|
859 | - try { |
|
860 | - $sth = $this->db->prepare($query); |
|
861 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
862 | - } catch(PDOException $e) { |
|
863 | - echo "error : ".$e->getMessage(); |
|
864 | - } |
|
865 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
866 | - return $all[0]['total']; |
|
867 | - } |
|
858 | + } |
|
859 | + try { |
|
860 | + $sth = $this->db->prepare($query); |
|
861 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
862 | + } catch(PDOException $e) { |
|
863 | + echo "error : ".$e->getMessage(); |
|
864 | + } |
|
865 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
866 | + return $all[0]['total']; |
|
867 | + } |
|
868 | 868 | public function getStatsOwnerTotal($filter_name = '') { |
869 | - global $globalArchiveMonths, $globalDBdriver; |
|
869 | + global $globalArchiveMonths, $globalDBdriver; |
|
870 | 870 | if ($filter_name == '') $filter_name = $this->filter_name; |
871 | - if ($globalDBdriver == 'mysql') { |
|
871 | + if ($globalDBdriver == 'mysql') { |
|
872 | 872 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
873 | 873 | } else { |
874 | 874 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
875 | - } |
|
876 | - try { |
|
877 | - $sth = $this->db->prepare($query); |
|
878 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
879 | - } catch(PDOException $e) { |
|
880 | - echo "error : ".$e->getMessage(); |
|
881 | - } |
|
882 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
883 | - return $all[0]['total']; |
|
884 | - } |
|
875 | + } |
|
876 | + try { |
|
877 | + $sth = $this->db->prepare($query); |
|
878 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
879 | + } catch(PDOException $e) { |
|
880 | + echo "error : ".$e->getMessage(); |
|
881 | + } |
|
882 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
883 | + return $all[0]['total']; |
|
884 | + } |
|
885 | 885 | public function getStatsPilotTotal($filter_name = '') { |
886 | - global $globalArchiveMonths, $globalDBdriver; |
|
886 | + global $globalArchiveMonths, $globalDBdriver; |
|
887 | 887 | if ($filter_name == '') $filter_name = $this->filter_name; |
888 | - if ($globalDBdriver == 'mysql') { |
|
889 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
890 | - } else { |
|
891 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
892 | - } |
|
893 | - try { |
|
894 | - $sth = $this->db->prepare($query); |
|
895 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
896 | - } catch(PDOException $e) { |
|
897 | - echo "error : ".$e->getMessage(); |
|
898 | - } |
|
899 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
900 | - return $all[0]['total']; |
|
901 | - } |
|
888 | + if ($globalDBdriver == 'mysql') { |
|
889 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
890 | + } else { |
|
891 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
892 | + } |
|
893 | + try { |
|
894 | + $sth = $this->db->prepare($query); |
|
895 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
896 | + } catch(PDOException $e) { |
|
897 | + echo "error : ".$e->getMessage(); |
|
898 | + } |
|
899 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
900 | + return $all[0]['total']; |
|
901 | + } |
|
902 | 902 | |
903 | 903 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
904 | 904 | global $globalDBdriver; |
905 | 905 | if ($filter_name == '') $filter_name = $this->filter_name; |
906 | 906 | if ($globalDBdriver == 'mysql') { |
907 | 907 | $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"; |
908 | - } else { |
|
908 | + } else { |
|
909 | 909 | $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);"; |
910 | 910 | } |
911 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
912 | - try { |
|
913 | - $sth = $this->db->prepare($query); |
|
914 | - $sth->execute($query_values); |
|
915 | - } catch(PDOException $e) { |
|
916 | - return "error : ".$e->getMessage(); |
|
917 | - } |
|
918 | - } |
|
911 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
912 | + try { |
|
913 | + $sth = $this->db->prepare($query); |
|
914 | + $sth->execute($query_values); |
|
915 | + } catch(PDOException $e) { |
|
916 | + return "error : ".$e->getMessage(); |
|
917 | + } |
|
918 | + } |
|
919 | 919 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
920 | 920 | global $globalDBdriver; |
921 | 921 | if ($filter_name == '') $filter_name = $this->filter_name; |
922 | 922 | if ($globalDBdriver == 'mysql') { |
923 | 923 | $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"; |
924 | 924 | } else { |
925 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
925 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
926 | 926 | $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);"; |
927 | - } |
|
928 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
929 | - try { |
|
930 | - $sth = $this->db->prepare($query); |
|
931 | - $sth->execute($query_values); |
|
932 | - } catch(PDOException $e) { |
|
933 | - return "error : ".$e->getMessage(); |
|
934 | - } |
|
935 | - } |
|
927 | + } |
|
928 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
929 | + try { |
|
930 | + $sth = $this->db->prepare($query); |
|
931 | + $sth->execute($query_values); |
|
932 | + } catch(PDOException $e) { |
|
933 | + return "error : ".$e->getMessage(); |
|
934 | + } |
|
935 | + } |
|
936 | 936 | public function getStatsSource($date,$stats_type = '') { |
937 | 937 | if ($stats_type == '') { |
938 | 938 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -941,15 +941,15 @@ discard block |
||
941 | 941 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
942 | 942 | $query_values = array(':date' => $date,':stats_type' => $stats_type); |
943 | 943 | } |
944 | - try { |
|
945 | - $sth = $this->db->prepare($query); |
|
946 | - $sth->execute($query_values); |
|
947 | - } catch(PDOException $e) { |
|
948 | - echo "error : ".$e->getMessage(); |
|
949 | - } |
|
950 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
951 | - return $all; |
|
952 | - } |
|
944 | + try { |
|
945 | + $sth = $this->db->prepare($query); |
|
946 | + $sth->execute($query_values); |
|
947 | + } catch(PDOException $e) { |
|
948 | + echo "error : ".$e->getMessage(); |
|
949 | + } |
|
950 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
951 | + return $all; |
|
952 | + } |
|
953 | 953 | |
954 | 954 | public function addStatSource($data,$source_name,$stats_type,$date) { |
955 | 955 | global $globalDBdriver; |
@@ -957,25 +957,25 @@ discard block |
||
957 | 957 | $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"; |
958 | 958 | } else { |
959 | 959 | $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);"; |
960 | - } |
|
961 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
962 | - try { |
|
963 | - $sth = $this->db->prepare($query); |
|
964 | - $sth->execute($query_values); |
|
965 | - } catch(PDOException $e) { |
|
966 | - return "error : ".$e->getMessage(); |
|
967 | - } |
|
968 | - } |
|
960 | + } |
|
961 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
962 | + try { |
|
963 | + $sth = $this->db->prepare($query); |
|
964 | + $sth->execute($query_values); |
|
965 | + } catch(PDOException $e) { |
|
966 | + return "error : ".$e->getMessage(); |
|
967 | + } |
|
968 | + } |
|
969 | 969 | public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
970 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
971 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
972 | - try { |
|
973 | - $sth = $this->db->prepare($query); |
|
974 | - $sth->execute($query_values); |
|
975 | - } catch(PDOException $e) { |
|
976 | - return "error : ".$e->getMessage(); |
|
977 | - } |
|
978 | - } |
|
970 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
971 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
972 | + try { |
|
973 | + $sth = $this->db->prepare($query); |
|
974 | + $sth->execute($query_values); |
|
975 | + } catch(PDOException $e) { |
|
976 | + return "error : ".$e->getMessage(); |
|
977 | + } |
|
978 | + } |
|
979 | 979 | public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
980 | 980 | global $globalDBdriver; |
981 | 981 | if ($globalDBdriver == 'mysql') { |
@@ -983,14 +983,14 @@ discard block |
||
983 | 983 | } else { |
984 | 984 | $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);"; |
985 | 985 | } |
986 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
987 | - try { |
|
988 | - $sth = $this->db->prepare($query); |
|
989 | - $sth->execute($query_values); |
|
990 | - } catch(PDOException $e) { |
|
991 | - return "error : ".$e->getMessage(); |
|
992 | - } |
|
993 | - } |
|
986 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
987 | + try { |
|
988 | + $sth = $this->db->prepare($query); |
|
989 | + $sth->execute($query_values); |
|
990 | + } catch(PDOException $e) { |
|
991 | + return "error : ".$e->getMessage(); |
|
992 | + } |
|
993 | + } |
|
994 | 994 | public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
995 | 995 | global $globalDBdriver; |
996 | 996 | if ($globalDBdriver == 'mysql') { |
@@ -998,14 +998,14 @@ discard block |
||
998 | 998 | } else { |
999 | 999 | $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);"; |
1000 | 1000 | } |
1001 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1002 | - try { |
|
1003 | - $sth = $this->db->prepare($query); |
|
1004 | - $sth->execute($query_values); |
|
1005 | - } catch(PDOException $e) { |
|
1006 | - return "error : ".$e->getMessage(); |
|
1007 | - } |
|
1008 | - } |
|
1001 | + $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1002 | + try { |
|
1003 | + $sth = $this->db->prepare($query); |
|
1004 | + $sth->execute($query_values); |
|
1005 | + } catch(PDOException $e) { |
|
1006 | + return "error : ".$e->getMessage(); |
|
1007 | + } |
|
1008 | + } |
|
1009 | 1009 | public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
1010 | 1010 | global $globalDBdriver; |
1011 | 1011 | if ($globalDBdriver == 'mysql') { |
@@ -1013,14 +1013,14 @@ discard block |
||
1013 | 1013 | } else { |
1014 | 1014 | $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);"; |
1015 | 1015 | } |
1016 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1017 | - try { |
|
1018 | - $sth = $this->db->prepare($query); |
|
1019 | - $sth->execute($query_values); |
|
1020 | - } catch(PDOException $e) { |
|
1021 | - return "error : ".$e->getMessage(); |
|
1022 | - } |
|
1023 | - } |
|
1016 | + $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1017 | + try { |
|
1018 | + $sth = $this->db->prepare($query); |
|
1019 | + $sth->execute($query_values); |
|
1020 | + } catch(PDOException $e) { |
|
1021 | + return "error : ".$e->getMessage(); |
|
1022 | + } |
|
1023 | + } |
|
1024 | 1024 | public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
1025 | 1025 | global $globalDBdriver; |
1026 | 1026 | if ($globalDBdriver == 'mysql') { |
@@ -1028,14 +1028,14 @@ discard block |
||
1028 | 1028 | } else { |
1029 | 1029 | $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);"; |
1030 | 1030 | } |
1031 | - $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); |
|
1032 | - try { |
|
1033 | - $sth = $this->db->prepare($query); |
|
1034 | - $sth->execute($query_values); |
|
1035 | - } catch(PDOException $e) { |
|
1036 | - return "error : ".$e->getMessage(); |
|
1037 | - } |
|
1038 | - } |
|
1031 | + $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); |
|
1032 | + try { |
|
1033 | + $sth = $this->db->prepare($query); |
|
1034 | + $sth->execute($query_values); |
|
1035 | + } catch(PDOException $e) { |
|
1036 | + return "error : ".$e->getMessage(); |
|
1037 | + } |
|
1038 | + } |
|
1039 | 1039 | public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
1040 | 1040 | global $globalDBdriver; |
1041 | 1041 | if ($globalDBdriver == 'mysql') { |
@@ -1043,14 +1043,14 @@ discard block |
||
1043 | 1043 | } else { |
1044 | 1044 | $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);"; |
1045 | 1045 | } |
1046 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1047 | - try { |
|
1048 | - $sth = $this->db->prepare($query); |
|
1049 | - $sth->execute($query_values); |
|
1050 | - } catch(PDOException $e) { |
|
1051 | - return "error : ".$e->getMessage(); |
|
1052 | - } |
|
1053 | - } |
|
1046 | + $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1047 | + try { |
|
1048 | + $sth = $this->db->prepare($query); |
|
1049 | + $sth->execute($query_values); |
|
1050 | + } catch(PDOException $e) { |
|
1051 | + return "error : ".$e->getMessage(); |
|
1052 | + } |
|
1053 | + } |
|
1054 | 1054 | public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
1055 | 1055 | global $globalDBdriver; |
1056 | 1056 | if ($globalDBdriver == 'mysql') { |
@@ -1058,14 +1058,14 @@ discard block |
||
1058 | 1058 | } else { |
1059 | 1059 | $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);"; |
1060 | 1060 | } |
1061 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1062 | - try { |
|
1063 | - $sth = $this->db->prepare($query); |
|
1064 | - $sth->execute($query_values); |
|
1065 | - } catch(PDOException $e) { |
|
1066 | - return "error : ".$e->getMessage(); |
|
1067 | - } |
|
1068 | - } |
|
1061 | + $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1062 | + try { |
|
1063 | + $sth = $this->db->prepare($query); |
|
1064 | + $sth->execute($query_values); |
|
1065 | + } catch(PDOException $e) { |
|
1066 | + return "error : ".$e->getMessage(); |
|
1067 | + } |
|
1068 | + } |
|
1069 | 1069 | public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '') { |
1070 | 1070 | global $globalDBdriver; |
1071 | 1071 | if ($globalDBdriver == 'mysql') { |
@@ -1073,14 +1073,14 @@ discard block |
||
1073 | 1073 | } else { |
1074 | 1074 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1075 | 1075 | } |
1076 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1077 | - try { |
|
1078 | - $sth = $this->db->prepare($query); |
|
1079 | - $sth->execute($query_values); |
|
1080 | - } catch(PDOException $e) { |
|
1081 | - return "error : ".$e->getMessage(); |
|
1082 | - } |
|
1083 | - } |
|
1076 | + $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1077 | + try { |
|
1078 | + $sth = $this->db->prepare($query); |
|
1079 | + $sth->execute($query_values); |
|
1080 | + } catch(PDOException $e) { |
|
1081 | + return "error : ".$e->getMessage(); |
|
1082 | + } |
|
1083 | + } |
|
1084 | 1084 | public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1085 | 1085 | global $globalDBdriver; |
1086 | 1086 | if ($airport_icao != '') { |
@@ -1096,8 +1096,8 @@ discard block |
||
1096 | 1096 | } catch(PDOException $e) { |
1097 | 1097 | return "error : ".$e->getMessage(); |
1098 | 1098 | } |
1099 | - } |
|
1100 | - } |
|
1099 | + } |
|
1100 | + } |
|
1101 | 1101 | public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1102 | 1102 | global $globalDBdriver; |
1103 | 1103 | if ($airport_icao != '') { |
@@ -1113,8 +1113,8 @@ discard block |
||
1113 | 1113 | } catch(PDOException $e) { |
1114 | 1114 | return "error : ".$e->getMessage(); |
1115 | 1115 | } |
1116 | - } |
|
1117 | - } |
|
1116 | + } |
|
1117 | + } |
|
1118 | 1118 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | if ($airport_icao != '') { |
@@ -1123,15 +1123,15 @@ discard block |
||
1123 | 1123 | } else { |
1124 | 1124 | $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);"; |
1125 | 1125 | } |
1126 | - $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); |
|
1126 | + $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); |
|
1127 | 1127 | try { |
1128 | - $sth = $this->db->prepare($query); |
|
1129 | - $sth->execute($query_values); |
|
1130 | - } catch(PDOException $e) { |
|
1131 | - return "error : ".$e->getMessage(); |
|
1132 | - } |
|
1133 | - } |
|
1134 | - } |
|
1128 | + $sth = $this->db->prepare($query); |
|
1129 | + $sth->execute($query_values); |
|
1130 | + } catch(PDOException $e) { |
|
1131 | + return "error : ".$e->getMessage(); |
|
1132 | + } |
|
1133 | + } |
|
1134 | + } |
|
1135 | 1135 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1136 | 1136 | global $globalDBdriver; |
1137 | 1137 | if ($airport_icao != '') { |
@@ -1147,46 +1147,46 @@ discard block |
||
1147 | 1147 | } catch(PDOException $e) { |
1148 | 1148 | return "error : ".$e->getMessage(); |
1149 | 1149 | } |
1150 | - } |
|
1151 | - } |
|
1150 | + } |
|
1151 | + } |
|
1152 | 1152 | |
1153 | 1153 | public function deleteStat($id) { |
1154 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1155 | - $query_values = array(':id' => $id); |
|
1156 | - try { |
|
1157 | - $sth = $this->db->prepare($query); |
|
1158 | - $sth->execute($query_values); |
|
1159 | - } catch(PDOException $e) { |
|
1160 | - return "error : ".$e->getMessage(); |
|
1161 | - } |
|
1162 | - } |
|
1154 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1155 | + $query_values = array(':id' => $id); |
|
1156 | + try { |
|
1157 | + $sth = $this->db->prepare($query); |
|
1158 | + $sth->execute($query_values); |
|
1159 | + } catch(PDOException $e) { |
|
1160 | + return "error : ".$e->getMessage(); |
|
1161 | + } |
|
1162 | + } |
|
1163 | 1163 | public function deleteStatFlight($type) { |
1164 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1165 | - $query_values = array(':type' => $type); |
|
1166 | - try { |
|
1167 | - $sth = $this->db->prepare($query); |
|
1168 | - $sth->execute($query_values); |
|
1169 | - } catch(PDOException $e) { |
|
1170 | - return "error : ".$e->getMessage(); |
|
1171 | - } |
|
1172 | - } |
|
1164 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1165 | + $query_values = array(':type' => $type); |
|
1166 | + try { |
|
1167 | + $sth = $this->db->prepare($query); |
|
1168 | + $sth->execute($query_values); |
|
1169 | + } catch(PDOException $e) { |
|
1170 | + return "error : ".$e->getMessage(); |
|
1171 | + } |
|
1172 | + } |
|
1173 | 1173 | public function deleteStatAirport($type) { |
1174 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1175 | - $query_values = array(':type' => $type); |
|
1176 | - try { |
|
1177 | - $sth = $this->db->prepare($query); |
|
1178 | - $sth->execute($query_values); |
|
1179 | - } catch(PDOException $e) { |
|
1180 | - return "error : ".$e->getMessage(); |
|
1181 | - } |
|
1182 | - } |
|
1174 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1175 | + $query_values = array(':type' => $type); |
|
1176 | + try { |
|
1177 | + $sth = $this->db->prepare($query); |
|
1178 | + $sth->execute($query_values); |
|
1179 | + } catch(PDOException $e) { |
|
1180 | + return "error : ".$e->getMessage(); |
|
1181 | + } |
|
1182 | + } |
|
1183 | 1183 | |
1184 | - public function addOldStats() { |
|
1185 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats; |
|
1186 | - $Common = new Common(); |
|
1187 | - $Connection = new Connection(); |
|
1188 | - date_default_timezone_set('UTC'); |
|
1189 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1184 | + public function addOldStats() { |
|
1185 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats; |
|
1186 | + $Common = new Common(); |
|
1187 | + $Connection = new Connection(); |
|
1188 | + date_default_timezone_set('UTC'); |
|
1189 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1190 | 1190 | //print_r($last_update); |
1191 | 1191 | /* |
1192 | 1192 | $flightsbymonth = $this->getStats('flights_by_month'); |
@@ -1448,24 +1448,24 @@ discard block |
||
1448 | 1448 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1449 | 1449 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1450 | 1450 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1451 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1451 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1452 | 1452 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1453 | - $alldata = array(); |
|
1453 | + $alldata = array(); |
|
1454 | 1454 | |
1455 | - foreach ($pall as $value) { |
|
1456 | - $icao = $value['airport_departure_icao']; |
|
1457 | - $alldata[$icao] = $value; |
|
1458 | - } |
|
1459 | - foreach ($dall as $value) { |
|
1460 | - $icao = $value['airport_departure_icao']; |
|
1461 | - if (isset($alldata[$icao])) { |
|
1462 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1463 | - } else $alldata[$icao] = $value; |
|
1464 | - } |
|
1465 | - $count = array(); |
|
1466 | - foreach ($alldata as $key => $row) { |
|
1467 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1468 | - } |
|
1455 | + foreach ($pall as $value) { |
|
1456 | + $icao = $value['airport_departure_icao']; |
|
1457 | + $alldata[$icao] = $value; |
|
1458 | + } |
|
1459 | + foreach ($dall as $value) { |
|
1460 | + $icao = $value['airport_departure_icao']; |
|
1461 | + if (isset($alldata[$icao])) { |
|
1462 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1463 | + } else $alldata[$icao] = $value; |
|
1464 | + } |
|
1465 | + $count = array(); |
|
1466 | + foreach ($alldata as $key => $row) { |
|
1467 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1468 | + } |
|
1469 | 1469 | array_multisort($count,SORT_DESC,$alldata); |
1470 | 1470 | foreach ($alldata as $number) { |
1471 | 1471 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
@@ -1473,25 +1473,25 @@ discard block |
||
1473 | 1473 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1474 | 1474 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1475 | 1475 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1476 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1476 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1477 | 1477 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1478 | - $alldata = array(); |
|
1479 | - foreach ($pall as $value) { |
|
1480 | - $icao = $value['airport_arrival_icao']; |
|
1481 | - $alldata[$icao] = $value; |
|
1482 | - } |
|
1483 | - foreach ($dall as $value) { |
|
1484 | - $icao = $value['airport_arrival_icao']; |
|
1485 | - if (isset($alldata[$icao])) { |
|
1486 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1487 | - } else $alldata[$icao] = $value; |
|
1488 | - } |
|
1489 | - $count = array(); |
|
1490 | - foreach ($alldata as $key => $row) { |
|
1491 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1492 | - } |
|
1493 | - array_multisort($count,SORT_DESC,$alldata); |
|
1494 | - foreach ($alldata as $number) { |
|
1478 | + $alldata = array(); |
|
1479 | + foreach ($pall as $value) { |
|
1480 | + $icao = $value['airport_arrival_icao']; |
|
1481 | + $alldata[$icao] = $value; |
|
1482 | + } |
|
1483 | + foreach ($dall as $value) { |
|
1484 | + $icao = $value['airport_arrival_icao']; |
|
1485 | + if (isset($alldata[$icao])) { |
|
1486 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1487 | + } else $alldata[$icao] = $value; |
|
1488 | + } |
|
1489 | + $count = array(); |
|
1490 | + foreach ($alldata as $key => $row) { |
|
1491 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1492 | + } |
|
1493 | + array_multisort($count,SORT_DESC,$alldata); |
|
1494 | + foreach ($alldata as $number) { |
|
1495 | 1495 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1496 | 1496 | } |
1497 | 1497 | if ($Connection->tableExists('countries')) { |
@@ -1551,8 +1551,8 @@ discard block |
||
1551 | 1551 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1552 | 1552 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
1553 | 1553 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1554 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1555 | - /* |
|
1554 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1555 | + /* |
|
1556 | 1556 | $alldata = array(); |
1557 | 1557 | foreach ($pall as $value) { |
1558 | 1558 | $icao = $value['departure_airport_icao']; |
@@ -1571,29 +1571,29 @@ discard block |
||
1571 | 1571 | } |
1572 | 1572 | array_multisort($count,SORT_DESC,$alldata); |
1573 | 1573 | */ |
1574 | - foreach ($dall as $value) { |
|
1575 | - $icao = $value['departure_airport_icao']; |
|
1576 | - $ddate = $value['date']; |
|
1577 | - $find = false; |
|
1578 | - foreach ($pall as $pvalue) { |
|
1579 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1580 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1581 | - $find = true; |
|
1582 | - break; |
|
1583 | - } |
|
1584 | - } |
|
1585 | - if ($find === false) { |
|
1586 | - $pall[] = $value; |
|
1587 | - } |
|
1588 | - } |
|
1589 | - $alldata = $pall; |
|
1574 | + foreach ($dall as $value) { |
|
1575 | + $icao = $value['departure_airport_icao']; |
|
1576 | + $ddate = $value['date']; |
|
1577 | + $find = false; |
|
1578 | + foreach ($pall as $pvalue) { |
|
1579 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1580 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1581 | + $find = true; |
|
1582 | + break; |
|
1583 | + } |
|
1584 | + } |
|
1585 | + if ($find === false) { |
|
1586 | + $pall[] = $value; |
|
1587 | + } |
|
1588 | + } |
|
1589 | + $alldata = $pall; |
|
1590 | 1590 | foreach ($alldata as $number) { |
1591 | 1591 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
1592 | 1592 | } |
1593 | 1593 | echo '...Arrival'."\n"; |
1594 | 1594 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
1595 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1596 | - /* |
|
1595 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1596 | + /* |
|
1597 | 1597 | $alldata = array(); |
1598 | 1598 | foreach ($pall as $value) { |
1599 | 1599 | $icao = $value['arrival_airport_icao']; |
@@ -1613,22 +1613,22 @@ discard block |
||
1613 | 1613 | */ |
1614 | 1614 | |
1615 | 1615 | |
1616 | - foreach ($dall as $value) { |
|
1617 | - $icao = $value['arrival_airport_icao']; |
|
1618 | - $ddate = $value['date']; |
|
1619 | - $find = false; |
|
1620 | - foreach ($pall as $pvalue) { |
|
1621 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1622 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1623 | - $find = true; |
|
1624 | - break; |
|
1625 | - } |
|
1626 | - } |
|
1627 | - if ($find === false) { |
|
1628 | - $pall[] = $value; |
|
1629 | - } |
|
1630 | - } |
|
1631 | - $alldata = $pall; |
|
1616 | + foreach ($dall as $value) { |
|
1617 | + $icao = $value['arrival_airport_icao']; |
|
1618 | + $ddate = $value['date']; |
|
1619 | + $find = false; |
|
1620 | + foreach ($pall as $pvalue) { |
|
1621 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1622 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1623 | + $find = true; |
|
1624 | + break; |
|
1625 | + } |
|
1626 | + } |
|
1627 | + if ($find === false) { |
|
1628 | + $pall[] = $value; |
|
1629 | + } |
|
1630 | + } |
|
1631 | + $alldata = $pall; |
|
1632 | 1632 | foreach ($alldata as $number) { |
1633 | 1633 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
1634 | 1634 | } |
@@ -1695,51 +1695,51 @@ discard block |
||
1695 | 1695 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1696 | 1696 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1697 | 1697 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1698 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1698 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1699 | 1699 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1700 | - //$alldata = array(); |
|
1701 | - foreach ($dall as $value) { |
|
1702 | - $icao = $value['airport_departure_icao']; |
|
1703 | - $dicao = $value['airline_icao']; |
|
1704 | - $find = false; |
|
1705 | - foreach ($pall as $pvalue) { |
|
1706 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1707 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1708 | - $find = true; |
|
1709 | - break; |
|
1710 | - } |
|
1711 | - } |
|
1712 | - if ($find === false) { |
|
1713 | - $pall[] = $value; |
|
1714 | - } |
|
1715 | - } |
|
1716 | - $alldata = $pall; |
|
1700 | + //$alldata = array(); |
|
1701 | + foreach ($dall as $value) { |
|
1702 | + $icao = $value['airport_departure_icao']; |
|
1703 | + $dicao = $value['airline_icao']; |
|
1704 | + $find = false; |
|
1705 | + foreach ($pall as $pvalue) { |
|
1706 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1707 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1708 | + $find = true; |
|
1709 | + break; |
|
1710 | + } |
|
1711 | + } |
|
1712 | + if ($find === false) { |
|
1713 | + $pall[] = $value; |
|
1714 | + } |
|
1715 | + } |
|
1716 | + $alldata = $pall; |
|
1717 | 1717 | foreach ($alldata as $number) { |
1718 | 1718 | 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']); |
1719 | 1719 | } |
1720 | 1720 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1721 | 1721 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1722 | 1722 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1723 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1723 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1724 | 1724 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1725 | - //$alldata = array(); |
|
1726 | - foreach ($dall as $value) { |
|
1727 | - $icao = $value['airport_arrival_icao']; |
|
1728 | - $dicao = $value['airline_icao']; |
|
1729 | - $find = false; |
|
1730 | - foreach ($pall as $pvalue) { |
|
1731 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1732 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1733 | - $find = true; |
|
1734 | - break; |
|
1735 | - } |
|
1736 | - } |
|
1737 | - if ($find === false) { |
|
1738 | - $pall[] = $value; |
|
1739 | - } |
|
1740 | - } |
|
1741 | - $alldata = $pall; |
|
1742 | - foreach ($alldata as $number) { |
|
1725 | + //$alldata = array(); |
|
1726 | + foreach ($dall as $value) { |
|
1727 | + $icao = $value['airport_arrival_icao']; |
|
1728 | + $dicao = $value['airline_icao']; |
|
1729 | + $find = false; |
|
1730 | + foreach ($pall as $pvalue) { |
|
1731 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1732 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1733 | + $find = true; |
|
1734 | + break; |
|
1735 | + } |
|
1736 | + } |
|
1737 | + if ($find === false) { |
|
1738 | + $pall[] = $value; |
|
1739 | + } |
|
1740 | + } |
|
1741 | + $alldata = $pall; |
|
1742 | + foreach ($alldata as $number) { |
|
1743 | 1743 | if ($number['airline_icao'] != '') 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']); |
1744 | 1744 | } |
1745 | 1745 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
@@ -1772,47 +1772,47 @@ discard block |
||
1772 | 1772 | } |
1773 | 1773 | if ($globalDebug) echo '...Departure'."\n"; |
1774 | 1774 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1775 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1776 | - foreach ($dall as $value) { |
|
1777 | - $icao = $value['departure_airport_icao']; |
|
1778 | - $airline = $value['airline_icao']; |
|
1779 | - $ddate = $value['date']; |
|
1780 | - $find = false; |
|
1781 | - foreach ($pall as $pvalue) { |
|
1782 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1783 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1784 | - $find = true; |
|
1785 | - break; |
|
1786 | - } |
|
1787 | - } |
|
1788 | - if ($find === false) { |
|
1789 | - $pall[] = $value; |
|
1790 | - } |
|
1791 | - } |
|
1792 | - $alldata = $pall; |
|
1775 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1776 | + foreach ($dall as $value) { |
|
1777 | + $icao = $value['departure_airport_icao']; |
|
1778 | + $airline = $value['airline_icao']; |
|
1779 | + $ddate = $value['date']; |
|
1780 | + $find = false; |
|
1781 | + foreach ($pall as $pvalue) { |
|
1782 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1783 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1784 | + $find = true; |
|
1785 | + break; |
|
1786 | + } |
|
1787 | + } |
|
1788 | + if ($find === false) { |
|
1789 | + $pall[] = $value; |
|
1790 | + } |
|
1791 | + } |
|
1792 | + $alldata = $pall; |
|
1793 | 1793 | foreach ($alldata as $number) { |
1794 | 1794 | $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']); |
1795 | 1795 | } |
1796 | 1796 | if ($globalDebug) echo '...Arrival'."\n"; |
1797 | 1797 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1798 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1799 | - foreach ($dall as $value) { |
|
1800 | - $icao = $value['arrival_airport_icao']; |
|
1801 | - $airline = $value['airline_icao']; |
|
1802 | - $ddate = $value['date']; |
|
1803 | - $find = false; |
|
1804 | - foreach ($pall as $pvalue) { |
|
1805 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1806 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1807 | - $find = true; |
|
1808 | - break; |
|
1809 | - } |
|
1810 | - } |
|
1811 | - if ($find === false) { |
|
1812 | - $pall[] = $value; |
|
1813 | - } |
|
1814 | - } |
|
1815 | - $alldata = $pall; |
|
1798 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1799 | + foreach ($dall as $value) { |
|
1800 | + $icao = $value['arrival_airport_icao']; |
|
1801 | + $airline = $value['airline_icao']; |
|
1802 | + $ddate = $value['date']; |
|
1803 | + $find = false; |
|
1804 | + foreach ($pall as $pvalue) { |
|
1805 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1806 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1807 | + $find = true; |
|
1808 | + break; |
|
1809 | + } |
|
1810 | + } |
|
1811 | + if ($find === false) { |
|
1812 | + $pall[] = $value; |
|
1813 | + } |
|
1814 | + } |
|
1815 | + $alldata = $pall; |
|
1816 | 1816 | foreach ($alldata as $number) { |
1817 | 1817 | $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']); |
1818 | 1818 | } |
@@ -1881,44 +1881,44 @@ discard block |
||
1881 | 1881 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source']); |
1882 | 1882 | } |
1883 | 1883 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
1884 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1885 | - $alldata = array(); |
|
1886 | - foreach ($pall as $value) { |
|
1887 | - $icao = $value['airport_departure_icao']; |
|
1888 | - $alldata[$icao] = $value; |
|
1889 | - } |
|
1890 | - foreach ($dall as $value) { |
|
1891 | - $icao = $value['airport_departure_icao']; |
|
1892 | - if (isset($alldata[$icao])) { |
|
1893 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1894 | - } else $alldata[$icao] = $value; |
|
1895 | - } |
|
1896 | - $count = array(); |
|
1897 | - foreach ($alldata as $key => $row) { |
|
1898 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1899 | - } |
|
1884 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1885 | + $alldata = array(); |
|
1886 | + foreach ($pall as $value) { |
|
1887 | + $icao = $value['airport_departure_icao']; |
|
1888 | + $alldata[$icao] = $value; |
|
1889 | + } |
|
1890 | + foreach ($dall as $value) { |
|
1891 | + $icao = $value['airport_departure_icao']; |
|
1892 | + if (isset($alldata[$icao])) { |
|
1893 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1894 | + } else $alldata[$icao] = $value; |
|
1895 | + } |
|
1896 | + $count = array(); |
|
1897 | + foreach ($alldata as $key => $row) { |
|
1898 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1899 | + } |
|
1900 | 1900 | array_multisort($count,SORT_DESC,$alldata); |
1901 | 1901 | foreach ($alldata as $number) { |
1902 | - 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); |
|
1902 | + 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); |
|
1903 | 1903 | } |
1904 | 1904 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
1905 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
1905 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
1906 | 1906 | $alldata = array(); |
1907 | - foreach ($pall as $value) { |
|
1908 | - $icao = $value['airport_arrival_icao']; |
|
1909 | - $alldata[$icao] = $value; |
|
1910 | - } |
|
1911 | - foreach ($dall as $value) { |
|
1912 | - $icao = $value['airport_arrival_icao']; |
|
1913 | - if (isset($alldata[$icao])) { |
|
1914 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1915 | - } else $alldata[$icao] = $value; |
|
1916 | - } |
|
1917 | - $count = array(); |
|
1918 | - foreach ($alldata as $key => $row) { |
|
1919 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1920 | - } |
|
1921 | - array_multisort($count,SORT_DESC,$alldata); |
|
1907 | + foreach ($pall as $value) { |
|
1908 | + $icao = $value['airport_arrival_icao']; |
|
1909 | + $alldata[$icao] = $value; |
|
1910 | + } |
|
1911 | + foreach ($dall as $value) { |
|
1912 | + $icao = $value['airport_arrival_icao']; |
|
1913 | + if (isset($alldata[$icao])) { |
|
1914 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1915 | + } else $alldata[$icao] = $value; |
|
1916 | + } |
|
1917 | + $count = array(); |
|
1918 | + foreach ($alldata as $key => $row) { |
|
1919 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1920 | + } |
|
1921 | + array_multisort($count,SORT_DESC,$alldata); |
|
1922 | 1922 | foreach ($alldata as $number) { |
1923 | 1923 | 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); |
1924 | 1924 | } |
@@ -1951,45 +1951,45 @@ discard block |
||
1951 | 1951 | } |
1952 | 1952 | echo '...Departure'."\n"; |
1953 | 1953 | $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
1954 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1954 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1955 | 1955 | foreach ($dall as $value) { |
1956 | - $icao = $value['departure_airport_icao']; |
|
1957 | - $ddate = $value['date']; |
|
1958 | - $find = false; |
|
1959 | - foreach ($pall as $pvalue) { |
|
1960 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1961 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1962 | - $find = true; |
|
1963 | - break; |
|
1964 | - } |
|
1965 | - } |
|
1966 | - if ($find === false) { |
|
1967 | - $pall[] = $value; |
|
1968 | - } |
|
1969 | - } |
|
1970 | - $alldata = $pall; |
|
1956 | + $icao = $value['departure_airport_icao']; |
|
1957 | + $ddate = $value['date']; |
|
1958 | + $find = false; |
|
1959 | + foreach ($pall as $pvalue) { |
|
1960 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1961 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1962 | + $find = true; |
|
1963 | + break; |
|
1964 | + } |
|
1965 | + } |
|
1966 | + if ($find === false) { |
|
1967 | + $pall[] = $value; |
|
1968 | + } |
|
1969 | + } |
|
1970 | + $alldata = $pall; |
|
1971 | 1971 | foreach ($alldata as $number) { |
1972 | 1972 | $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); |
1973 | 1973 | } |
1974 | 1974 | echo '...Arrival'."\n"; |
1975 | 1975 | $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
1976 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1976 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1977 | 1977 | foreach ($dall as $value) { |
1978 | 1978 | $icao = $value['arrival_airport_icao']; |
1979 | 1979 | $ddate = $value['date']; |
1980 | - $find = false; |
|
1980 | + $find = false; |
|
1981 | 1981 | foreach ($pall as $pvalue) { |
1982 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1983 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1984 | - $find = true; |
|
1985 | - break; |
|
1986 | - } |
|
1987 | - } |
|
1988 | - if ($find === false) { |
|
1989 | - $pall[] = $value; |
|
1990 | - } |
|
1991 | - } |
|
1992 | - $alldata = $pall; |
|
1982 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1983 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1984 | + $find = true; |
|
1985 | + break; |
|
1986 | + } |
|
1987 | + } |
|
1988 | + if ($find === false) { |
|
1989 | + $pall[] = $value; |
|
1990 | + } |
|
1991 | + } |
|
1992 | + $alldata = $pall; |
|
1993 | 1993 | foreach ($alldata as $number) { |
1994 | 1994 | $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); |
1995 | 1995 | } |