@@ -53,8 +53,12 @@ discard block |
||
53 | 53 | { |
54 | 54 | $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']); |
55 | 55 | $ident = $spotter_array[0]['ident']; |
56 | - if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
|
57 | - if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
|
56 | + if (isset($spotter_array[0]['latitude'])) { |
|
57 | + $latitude = $spotter_array[0]['latitude']; |
|
58 | + } |
|
59 | + if (isset($spotter_array[0]['longitude'])) { |
|
60 | + $longitude = $spotter_array[0]['longitude']; |
|
61 | + } |
|
58 | 62 | require_once('header.php'); |
59 | 63 | /* |
60 | 64 | if (isset($globalArchive) && $globalArchive) { |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | */ |
108 | 112 | print '<div class="info column">'; |
109 | 113 | print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>'; |
110 | - if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>'; |
|
114 | + if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') { |
|
115 | + print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>'; |
|
116 | + } |
|
111 | 117 | print '</div>'; |
112 | 118 | |
113 | 119 | include('owner-sub-menu.php'); |
@@ -31,7 +31,9 @@ discard block |
||
31 | 31 | } |
32 | 32 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
33 | 33 | } |
34 | - if ($firstLetter != "'") $previous = $firstLetter; |
|
34 | + if ($firstLetter != "'") { |
|
35 | + $previous = $firstLetter; |
|
36 | + } |
|
35 | 37 | } |
36 | 38 | print '</div>'; |
37 | 39 | $previous = null; |
@@ -46,10 +48,15 @@ discard block |
||
46 | 48 | } |
47 | 49 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
48 | 50 | } |
49 | - if ($firstLetter != "'") $previous = $firstLetter; |
|
51 | + if ($firstLetter != "'") { |
|
52 | + $previous = $firstLetter; |
|
53 | + } |
|
50 | 54 | print '<div class="alphabet-item">'; |
51 | - if (isset($value['pilot_id']) && $value['pilot_id'] != '') print '<a href="'.$globalURL.'/pilot/'.$value['pilot_id'].'">'.$value['pilot_name'].' ('.$value['pilot_id'].')'; |
|
52 | - else print '<a href="'.$globalURL.'/pilot/'.$value['pilot_name'].'">'.$value['pilot_name']; |
|
55 | + if (isset($value['pilot_id']) && $value['pilot_id'] != '') { |
|
56 | + print '<a href="'.$globalURL.'/pilot/'.$value['pilot_id'].'">'.$value['pilot_name'].' ('.$value['pilot_id'].')'; |
|
57 | + } else { |
|
58 | + print '<a href="'.$globalURL.'/pilot/'.$value['pilot_name'].'">'.$value['pilot_name']; |
|
59 | + } |
|
53 | 60 | print '</a>'; |
54 | 61 | print '</div>'; |
55 | 62 | } |
@@ -53,8 +53,12 @@ |
||
53 | 53 | { |
54 | 54 | $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']); |
55 | 55 | //$ident = $spotter_array[0]['ident']; |
56 | - if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
|
57 | - if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
|
56 | + if (isset($spotter_array[0]['latitude'])) { |
|
57 | + $latitude = $spotter_array[0]['latitude']; |
|
58 | + } |
|
59 | + if (isset($spotter_array[0]['longitude'])) { |
|
60 | + $longitude = $spotter_array[0]['longitude']; |
|
61 | + } |
|
58 | 62 | require_once('header.php'); |
59 | 63 | /* |
60 | 64 | if (isset($globalArchive) && $globalArchive) { |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | } |
34 | 34 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
35 | 35 | } |
36 | - if ($firstLetter != "'" && $firstLetter != '"') $previous = $firstLetter; |
|
36 | + if ($firstLetter != "'" && $firstLetter != '"') { |
|
37 | + $previous = $firstLetter; |
|
38 | + } |
|
37 | 39 | } |
38 | 40 | print '</div>'; |
39 | 41 | $previous = null; |
@@ -48,7 +50,9 @@ discard block |
||
48 | 50 | } |
49 | 51 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
50 | 52 | } |
51 | - if ($firstLetter != "'" && $firstLetter != '"') $previous = $firstLetter; |
|
53 | + if ($firstLetter != "'" && $firstLetter != '"') { |
|
54 | + $previous = $firstLetter; |
|
55 | + } |
|
52 | 56 | print '<div class="alphabet-item">'; |
53 | 57 | print '<a href="'.$globalURL.'/owner/'.$value['owner_name'].'">'; |
54 | 58 | print $value['owner_name']; |
@@ -27,8 +27,11 @@ discard block |
||
27 | 27 | } else { |
28 | 28 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
29 | 29 | } |
30 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
31 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
30 | + if ($timeout == '') { |
|
31 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
32 | + } else { |
|
33 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
34 | + } |
|
32 | 35 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
33 | 36 | if ($type == 'post') { |
34 | 37 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -74,8 +77,9 @@ discard block |
||
74 | 77 | private function curlResponseHeaderCallback($ch, $headerLine) { |
75 | 78 | //global $cookies; |
76 | 79 | $cookies = array(); |
77 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
78 | - $cookies[] = $cookie; |
|
80 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
81 | + $cookies[] = $cookie; |
|
82 | + } |
|
79 | 83 | return strlen($headerLine); // Needed by curl |
80 | 84 | } |
81 | 85 | |
@@ -86,11 +90,15 @@ discard block |
||
86 | 90 | curl_setopt($ch, CURLOPT_URL, $url); |
87 | 91 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
88 | 92 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
89 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
93 | + if ($referer != '') { |
|
94 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
95 | + } |
|
90 | 96 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
91 | 97 | curl_setopt($ch, CURLOPT_FILE, $fp); |
92 | 98 | curl_exec($ch); |
93 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
99 | + if (curl_errno($ch) && $globalDebug) { |
|
100 | + echo 'Download error: '.curl_error($ch); |
|
101 | + } |
|
94 | 102 | curl_close($ch); |
95 | 103 | fclose($fp); |
96 | 104 | } |
@@ -101,10 +109,16 @@ discard block |
||
101 | 109 | * @return Array array of the tables in HTML page |
102 | 110 | */ |
103 | 111 | public function table2array($data) { |
104 | - if (!is_string($data)) return array(); |
|
105 | - if ($data == '') return array(); |
|
112 | + if (!is_string($data)) { |
|
113 | + return array(); |
|
114 | + } |
|
115 | + if ($data == '') { |
|
116 | + return array(); |
|
117 | + } |
|
106 | 118 | $html = str_get_html($data); |
107 | - if ($html === false) return array(); |
|
119 | + if ($html === false) { |
|
120 | + return array(); |
|
121 | + } |
|
108 | 122 | $tabledata=array(); |
109 | 123 | foreach($html->find('tr') as $element) |
110 | 124 | { |
@@ -139,7 +153,9 @@ discard block |
||
139 | 153 | */ |
140 | 154 | public function text2array($data) { |
141 | 155 | $html = str_get_html($data); |
142 | - if ($html === false) return array(); |
|
156 | + if ($html === false) { |
|
157 | + return array(); |
|
158 | + } |
|
143 | 159 | $tabledata=array(); |
144 | 160 | foreach($html->find('p') as $element) |
145 | 161 | { |
@@ -160,7 +176,9 @@ discard block |
||
160 | 176 | * @return Float Distance in $unit |
161 | 177 | */ |
162 | 178 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
163 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
179 | + if ($lat == $latc && $lon == $lonc) { |
|
180 | + return 0; |
|
181 | + } |
|
164 | 182 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
165 | 183 | if ($unit == "km") { |
166 | 184 | return round($dist * 1.609344); |
@@ -184,10 +202,16 @@ discard block |
||
184 | 202 | public function withinThreshold ($timeDifference, $distance) { |
185 | 203 | $x = abs($timeDifference); |
186 | 204 | $d = abs($distance); |
187 | - if ($x == 0 || $d == 0) return true; |
|
205 | + if ($x == 0 || $d == 0) { |
|
206 | + return true; |
|
207 | + } |
|
188 | 208 | // may be due to Internet jitter; distance is realistic |
189 | - if ($x < 0.7 && $d < 2000) return true; |
|
190 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
209 | + if ($x < 0.7 && $d < 2000) { |
|
210 | + return true; |
|
211 | + } else { |
|
212 | + return $d/$x < 1500*0.27778; |
|
213 | + } |
|
214 | + // 1500 km/h max |
|
191 | 215 | } |
192 | 216 | |
193 | 217 | |
@@ -247,7 +271,9 @@ discard block |
||
247 | 271 | public function hex2str($hex) { |
248 | 272 | $str = ''; |
249 | 273 | $hexln = strlen($hex); |
250 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
274 | + for($i=0;$i<$hexln;$i+=2) { |
|
275 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
276 | + } |
|
251 | 277 | return $str; |
252 | 278 | } |
253 | 279 | |
@@ -275,8 +301,11 @@ discard block |
||
275 | 301 | $b = $lat2 - $lat1; |
276 | 302 | $c = -($a*$lat1+$b*$lon1); |
277 | 303 | $d = $a*$lat3+$b*$lon3+$c; |
278 | - if ($d > -$approx && $d < $approx) return true; |
|
279 | - else return false; |
|
304 | + if ($d > -$approx && $d < $approx) { |
|
305 | + return true; |
|
306 | + } else { |
|
307 | + return false; |
|
308 | + } |
|
280 | 309 | } |
281 | 310 | |
282 | 311 | public function array_merge_noappend() { |
@@ -312,7 +341,9 @@ discard block |
||
312 | 341 | return $result; |
313 | 342 | } |
314 | 343 | $handle = @opendir('./locale'); |
315 | - if ($handle === false) return $result; |
|
344 | + if ($handle === false) { |
|
345 | + return $result; |
|
346 | + } |
|
316 | 347 | while (false !== ($file = readdir($handle))) { |
317 | 348 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
318 | 349 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -379,8 +410,9 @@ discard block |
||
379 | 410 | $error = false; |
380 | 411 | if ($fp_out = gzopen($dest, $mode)) { |
381 | 412 | if ($fp_in = fopen($source,'rb')) { |
382 | - while (!feof($fp_in)) |
|
383 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
413 | + while (!feof($fp_in)) { |
|
414 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
415 | + } |
|
384 | 416 | fclose($fp_in); |
385 | 417 | } else { |
386 | 418 | $error = true; |
@@ -389,14 +421,17 @@ discard block |
||
389 | 421 | } else { |
390 | 422 | $error = true; |
391 | 423 | } |
392 | - if ($error) |
|
393 | - return false; |
|
394 | - else |
|
395 | - return $dest; |
|
424 | + if ($error) { |
|
425 | + return false; |
|
426 | + } else { |
|
427 | + return $dest; |
|
428 | + } |
|
396 | 429 | } |
397 | 430 | |
398 | 431 | function remove_accents($string) { |
399 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
432 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
433 | + return $string; |
|
434 | + } |
|
400 | 435 | $chars = array( |
401 | 436 | // Decompositions for Latin-1 Supplement |
402 | 437 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct($dbc = null) { |
14 | 14 | global $globalFilterName; |
15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
15 | + if (isset($globalFilterName)) { |
|
16 | + $this->filter_name = $globalFilterName; |
|
17 | + } |
|
16 | 18 | $Connection = new Connection($dbc); |
17 | 19 | $this->db = $Connection->db(); |
18 | 20 | } |
@@ -77,7 +79,9 @@ discard block |
||
77 | 79 | } |
78 | 80 | } |
79 | 81 | public function getAllAirlineNames($filter_name = '') { |
80 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
82 | + if ($filter_name == '') { |
|
83 | + $filter_name = $this->filter_name; |
|
84 | + } |
|
81 | 85 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
82 | 86 | try { |
83 | 87 | $sth = $this->db->prepare($query); |
@@ -89,7 +93,9 @@ discard block |
||
89 | 93 | return $all; |
90 | 94 | } |
91 | 95 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
92 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
96 | + if ($filter_name == '') { |
|
97 | + $filter_name = $this->filter_name; |
|
98 | + } |
|
93 | 99 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
94 | 100 | try { |
95 | 101 | $sth = $this->db->prepare($query); |
@@ -101,7 +107,9 @@ discard block |
||
101 | 107 | return $all; |
102 | 108 | } |
103 | 109 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
104 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
110 | + if ($filter_name == '') { |
|
111 | + $filter_name = $this->filter_name; |
|
112 | + } |
|
105 | 113 | $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 | 114 | try { |
107 | 115 | $sth = $this->db->prepare($query); |
@@ -113,7 +121,9 @@ discard block |
||
113 | 121 | return $all; |
114 | 122 | } |
115 | 123 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
116 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
124 | + if ($filter_name == '') { |
|
125 | + $filter_name = $this->filter_name; |
|
126 | + } |
|
117 | 127 | $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 | 128 | try { |
119 | 129 | $sth = $this->db->prepare($query); |
@@ -126,7 +136,9 @@ discard block |
||
126 | 136 | } |
127 | 137 | |
128 | 138 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
129 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
139 | + if ($filter_name == '') { |
|
140 | + $filter_name = $this->filter_name; |
|
141 | + } |
|
130 | 142 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
131 | 143 | try { |
132 | 144 | $sth = $this->db->prepare($query); |
@@ -139,7 +151,9 @@ discard block |
||
139 | 151 | } |
140 | 152 | |
141 | 153 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
142 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
154 | + if ($filter_name == '') { |
|
155 | + $filter_name = $this->filter_name; |
|
156 | + } |
|
143 | 157 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
144 | 158 | try { |
145 | 159 | $sth = $this->db->prepare($query); |
@@ -154,10 +168,15 @@ discard block |
||
154 | 168 | |
155 | 169 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
156 | 170 | global $globalStatsFilters; |
157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
171 | + if ($filter_name == '') { |
|
172 | + $filter_name = $this->filter_name; |
|
173 | + } |
|
158 | 174 | if ($year == '' && $month == '') { |
159 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
160 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
175 | + if ($limit) { |
|
176 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
177 | + } else { |
|
178 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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"; |
|
179 | + } |
|
161 | 180 | try { |
162 | 181 | $sth = $this->db->prepare($query); |
163 | 182 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -165,7 +184,9 @@ discard block |
||
165 | 184 | echo "error : ".$e->getMessage(); |
166 | 185 | } |
167 | 186 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
168 | - } else $all = array(); |
|
187 | + } else { |
|
188 | + $all = array(); |
|
189 | + } |
|
169 | 190 | if (empty($all)) { |
170 | 191 | $filters = array('airlines' => array($stats_airline)); |
171 | 192 | if ($filter_name != '') { |
@@ -178,10 +199,15 @@ discard block |
||
178 | 199 | } |
179 | 200 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
180 | 201 | global $globalStatsFilters; |
181 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
202 | + if ($filter_name == '') { |
|
203 | + $filter_name = $this->filter_name; |
|
204 | + } |
|
182 | 205 | if ($year == '' && $month == '') { |
183 | - 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"; |
|
184 | - 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"; |
|
206 | + if ($limit) { |
|
207 | + $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"; |
|
208 | + } else { |
|
209 | + $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"; |
|
210 | + } |
|
185 | 211 | try { |
186 | 212 | $sth = $this->db->prepare($query); |
187 | 213 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -189,7 +215,9 @@ discard block |
||
189 | 215 | echo "error : ".$e->getMessage(); |
190 | 216 | } |
191 | 217 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
192 | - } else $all = array(); |
|
218 | + } else { |
|
219 | + $all = array(); |
|
220 | + } |
|
193 | 221 | if (empty($all)) { |
194 | 222 | $Spotter = new Spotter($this->db); |
195 | 223 | $filters = array(); |
@@ -202,10 +230,15 @@ discard block |
||
202 | 230 | } |
203 | 231 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
204 | 232 | global $globalStatsFilters; |
205 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
233 | + if ($filter_name == '') { |
|
234 | + $filter_name = $this->filter_name; |
|
235 | + } |
|
206 | 236 | if ($year == '' && $month == '') { |
207 | - 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"; |
|
208 | - 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"; |
|
237 | + if ($limit) { |
|
238 | + $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"; |
|
239 | + } else { |
|
240 | + $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"; |
|
241 | + } |
|
209 | 242 | try { |
210 | 243 | $sth = $this->db->prepare($query); |
211 | 244 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -213,7 +246,9 @@ discard block |
||
213 | 246 | echo "error : ".$e->getMessage(); |
214 | 247 | } |
215 | 248 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
216 | - } else $all = array(); |
|
249 | + } else { |
|
250 | + $all = array(); |
|
251 | + } |
|
217 | 252 | if (empty($all)) { |
218 | 253 | $filters = array('airlines' => array($stats_airline)); |
219 | 254 | if ($filter_name != '') { |
@@ -227,10 +262,15 @@ discard block |
||
227 | 262 | |
228 | 263 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
229 | 264 | global $globalStatsFilters; |
230 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
265 | + if ($filter_name == '') { |
|
266 | + $filter_name = $this->filter_name; |
|
267 | + } |
|
231 | 268 | if ($year == '' && $month == '') { |
232 | - 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"; |
|
233 | - 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"; |
|
269 | + if ($limit) { |
|
270 | + $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"; |
|
271 | + } else { |
|
272 | + $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"; |
|
273 | + } |
|
234 | 274 | try { |
235 | 275 | $sth = $this->db->prepare($query); |
236 | 276 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -238,7 +278,9 @@ discard block |
||
238 | 278 | echo "error : ".$e->getMessage(); |
239 | 279 | } |
240 | 280 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
241 | - } else $all = array(); |
|
281 | + } else { |
|
282 | + $all = array(); |
|
283 | + } |
|
242 | 284 | if (empty($all)) { |
243 | 285 | $filters = array('airlines' => array($stats_airline)); |
244 | 286 | if ($filter_name != '') { |
@@ -251,9 +293,14 @@ discard block |
||
251 | 293 | } |
252 | 294 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
253 | 295 | global $globalStatsFilters; |
254 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
255 | - 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"; |
|
256 | - 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"; |
|
296 | + if ($filter_name == '') { |
|
297 | + $filter_name = $this->filter_name; |
|
298 | + } |
|
299 | + if ($limit) { |
|
300 | + $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"; |
|
301 | + } else { |
|
302 | + $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"; |
|
303 | + } |
|
257 | 304 | try { |
258 | 305 | $sth = $this->db->prepare($query); |
259 | 306 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -274,10 +321,15 @@ discard block |
||
274 | 321 | |
275 | 322 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
276 | 323 | global $globalStatsFilters; |
277 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
324 | + if ($filter_name == '') { |
|
325 | + $filter_name = $this->filter_name; |
|
326 | + } |
|
278 | 327 | if ($year == '' && $month == '') { |
279 | - 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"; |
|
280 | - 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"; |
|
328 | + if ($limit) { |
|
329 | + $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"; |
|
330 | + } else { |
|
331 | + $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"; |
|
332 | + } |
|
281 | 333 | try { |
282 | 334 | $sth = $this->db->prepare($query); |
283 | 335 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -285,7 +337,9 @@ discard block |
||
285 | 337 | echo "error : ".$e->getMessage(); |
286 | 338 | } |
287 | 339 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
288 | - } else $all = array(); |
|
340 | + } else { |
|
341 | + $all = array(); |
|
342 | + } |
|
289 | 343 | if (empty($all)) { |
290 | 344 | $Spotter = new Spotter($this->db); |
291 | 345 | $filters = array(); |
@@ -299,10 +353,15 @@ discard block |
||
299 | 353 | } |
300 | 354 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
301 | 355 | global $globalStatsFilters; |
302 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
356 | + if ($filter_name == '') { |
|
357 | + $filter_name = $this->filter_name; |
|
358 | + } |
|
303 | 359 | if ($year == '' && $month == '') { |
304 | - 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"; |
|
305 | - 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"; |
|
360 | + if ($limit) { |
|
361 | + $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"; |
|
362 | + } else { |
|
363 | + $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"; |
|
364 | + } |
|
306 | 365 | try { |
307 | 366 | $sth = $this->db->prepare($query); |
308 | 367 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -310,7 +369,9 @@ discard block |
||
310 | 369 | echo "error : ".$e->getMessage(); |
311 | 370 | } |
312 | 371 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
313 | - } else $all = array(); |
|
372 | + } else { |
|
373 | + $all = array(); |
|
374 | + } |
|
314 | 375 | if (empty($all)) { |
315 | 376 | $filters = array('airlines' => array($stats_airline)); |
316 | 377 | if ($filter_name != '') { |
@@ -323,10 +384,15 @@ discard block |
||
323 | 384 | } |
324 | 385 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
325 | 386 | global $globalStatsFilters; |
326 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
387 | + if ($filter_name == '') { |
|
388 | + $filter_name = $this->filter_name; |
|
389 | + } |
|
327 | 390 | if ($year == '' && $month == '') { |
328 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
329 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
391 | + if ($limit) { |
|
392 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
393 | + } else { |
|
394 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
395 | + } |
|
330 | 396 | try { |
331 | 397 | $sth = $this->db->prepare($query); |
332 | 398 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -334,7 +400,9 @@ discard block |
||
334 | 400 | echo "error : ".$e->getMessage(); |
335 | 401 | } |
336 | 402 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
337 | - } else $all = array(); |
|
403 | + } else { |
|
404 | + $all = array(); |
|
405 | + } |
|
338 | 406 | if (empty($all)) { |
339 | 407 | $filters = array('airlines' => array($stats_airline)); |
340 | 408 | if ($filter_name != '') { |
@@ -347,11 +415,16 @@ discard block |
||
347 | 415 | } |
348 | 416 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
349 | 417 | $Connection = new Connection(); |
350 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
418 | + if ($filter_name == '') { |
|
419 | + $filter_name = $this->filter_name; |
|
420 | + } |
|
351 | 421 | if ($Connection->tableExists('countries')) { |
352 | 422 | if ($year == '' && $month == '') { |
353 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
354 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
423 | + if ($limit) { |
|
424 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
425 | + } else { |
|
426 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
427 | + } |
|
355 | 428 | try { |
356 | 429 | $sth = $this->db->prepare($query); |
357 | 430 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -366,17 +439,24 @@ discard block |
||
366 | 439 | } |
367 | 440 | */ |
368 | 441 | return $all; |
369 | - } else return array(); |
|
442 | + } else { |
|
443 | + return array(); |
|
444 | + } |
|
370 | 445 | } else { |
371 | 446 | return array(); |
372 | 447 | } |
373 | 448 | } |
374 | 449 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
375 | 450 | global $globalStatsFilters; |
376 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
451 | + if ($filter_name == '') { |
|
452 | + $filter_name = $this->filter_name; |
|
453 | + } |
|
377 | 454 | if ($year == '' && $month == '') { |
378 | - 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"; |
|
379 | - 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"; |
|
455 | + if ($limit) { |
|
456 | + $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"; |
|
457 | + } else { |
|
458 | + $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"; |
|
459 | + } |
|
380 | 460 | try { |
381 | 461 | $sth = $this->db->prepare($query); |
382 | 462 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -384,7 +464,9 @@ discard block |
||
384 | 464 | echo "error : ".$e->getMessage(); |
385 | 465 | } |
386 | 466 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
387 | - } else $all = array(); |
|
467 | + } else { |
|
468 | + $all = array(); |
|
469 | + } |
|
388 | 470 | if (empty($all)) { |
389 | 471 | $filters = array('airlines' => array($stats_airline)); |
390 | 472 | if ($filter_name != '') { |
@@ -398,10 +480,15 @@ discard block |
||
398 | 480 | |
399 | 481 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
400 | 482 | global $globalStatsFilters; |
401 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
483 | + if ($filter_name == '') { |
|
484 | + $filter_name = $this->filter_name; |
|
485 | + } |
|
402 | 486 | if ($year == '' && $month == '') { |
403 | - 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"; |
|
404 | - 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"; |
|
487 | + if ($limit) { |
|
488 | + $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"; |
|
489 | + } else { |
|
490 | + $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"; |
|
491 | + } |
|
405 | 492 | try { |
406 | 493 | $sth = $this->db->prepare($query); |
407 | 494 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -409,7 +496,9 @@ discard block |
||
409 | 496 | echo "error : ".$e->getMessage(); |
410 | 497 | } |
411 | 498 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
412 | - } else $all = array(); |
|
499 | + } else { |
|
500 | + $all = array(); |
|
501 | + } |
|
413 | 502 | if (empty($all)) { |
414 | 503 | $filters = array('airlines' => array($stats_airline)); |
415 | 504 | if ($filter_name != '') { |
@@ -422,10 +511,15 @@ discard block |
||
422 | 511 | } |
423 | 512 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
424 | 513 | global $globalStatsFilters; |
425 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
514 | + if ($filter_name == '') { |
|
515 | + $filter_name = $this->filter_name; |
|
516 | + } |
|
426 | 517 | if ($year == '' && $month == '') { |
427 | - 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"; |
|
428 | - 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"; |
|
518 | + if ($limit) { |
|
519 | + $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"; |
|
520 | + } else { |
|
521 | + $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"; |
|
522 | + } |
|
429 | 523 | try { |
430 | 524 | $sth = $this->db->prepare($query); |
431 | 525 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -433,7 +527,9 @@ discard block |
||
433 | 527 | echo "error : ".$e->getMessage(); |
434 | 528 | } |
435 | 529 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
436 | - } else $all = array(); |
|
530 | + } else { |
|
531 | + $all = array(); |
|
532 | + } |
|
437 | 533 | if (empty($all)) { |
438 | 534 | $filters = array('airlines' => array($stats_airline)); |
439 | 535 | if ($filter_name != '') { |
@@ -452,7 +548,9 @@ discard block |
||
452 | 548 | $icao = $value['airport_departure_icao']; |
453 | 549 | if (isset($all[$icao])) { |
454 | 550 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
455 | - } else $all[$icao] = $value; |
|
551 | + } else { |
|
552 | + $all[$icao] = $value; |
|
553 | + } |
|
456 | 554 | } |
457 | 555 | $count = array(); |
458 | 556 | foreach ($all as $key => $row) { |
@@ -464,10 +562,15 @@ discard block |
||
464 | 562 | } |
465 | 563 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
466 | 564 | global $globalStatsFilters; |
467 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
565 | + if ($filter_name == '') { |
|
566 | + $filter_name = $this->filter_name; |
|
567 | + } |
|
468 | 568 | if ($year == '' && $month == '') { |
469 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
470 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
569 | + if ($limit) { |
|
570 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
571 | + } else { |
|
572 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
573 | + } |
|
471 | 574 | try { |
472 | 575 | $sth = $this->db->prepare($query); |
473 | 576 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -475,7 +578,9 @@ discard block |
||
475 | 578 | echo "error : ".$e->getMessage(); |
476 | 579 | } |
477 | 580 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
478 | - } else $all = array(); |
|
581 | + } else { |
|
582 | + $all = array(); |
|
583 | + } |
|
479 | 584 | if (empty($all)) { |
480 | 585 | $filters = array('airlines' => array($stats_airline)); |
481 | 586 | if ($filter_name != '') { |
@@ -494,7 +599,9 @@ discard block |
||
494 | 599 | $icao = $value['airport_arrival_icao']; |
495 | 600 | if (isset($all[$icao])) { |
496 | 601 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
497 | - } else $all[$icao] = $value; |
|
602 | + } else { |
|
603 | + $all[$icao] = $value; |
|
604 | + } |
|
498 | 605 | } |
499 | 606 | $count = array(); |
500 | 607 | foreach ($all as $key => $row) { |
@@ -507,13 +614,21 @@ discard block |
||
507 | 614 | } |
508 | 615 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
509 | 616 | global $globalDBdriver, $globalStatsFilters; |
510 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
617 | + if ($filter_name == '') { |
|
618 | + $filter_name = $this->filter_name; |
|
619 | + } |
|
511 | 620 | if ($globalDBdriver == 'mysql') { |
512 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
513 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
621 | + if ($limit) { |
|
622 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
623 | + } else { |
|
624 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
625 | + } |
|
514 | 626 | } else { |
515 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
516 | - 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"; |
|
627 | + if ($limit) { |
|
628 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
629 | + } else { |
|
630 | + $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"; |
|
631 | + } |
|
517 | 632 | } |
518 | 633 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
519 | 634 | try { |
@@ -537,7 +652,9 @@ discard block |
||
537 | 652 | |
538 | 653 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
539 | 654 | global $globalStatsFilters; |
540 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
655 | + if ($filter_name == '') { |
|
656 | + $filter_name = $this->filter_name; |
|
657 | + } |
|
541 | 658 | $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"; |
542 | 659 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
543 | 660 | try { |
@@ -559,7 +676,9 @@ discard block |
||
559 | 676 | } |
560 | 677 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
561 | 678 | global $globalDBdriver, $globalStatsFilters; |
562 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
679 | + if ($filter_name == '') { |
|
680 | + $filter_name = $this->filter_name; |
|
681 | + } |
|
563 | 682 | if ($globalDBdriver == 'mysql') { |
564 | 683 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
565 | 684 | } else { |
@@ -585,7 +704,9 @@ discard block |
||
585 | 704 | } |
586 | 705 | public function countAllDates($stats_airline = '',$filter_name = '') { |
587 | 706 | global $globalStatsFilters; |
588 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
707 | + if ($filter_name == '') { |
|
708 | + $filter_name = $this->filter_name; |
|
709 | + } |
|
589 | 710 | $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"; |
590 | 711 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
591 | 712 | try { |
@@ -607,7 +728,9 @@ discard block |
||
607 | 728 | } |
608 | 729 | public function countAllDatesByAirlines($filter_name = '') { |
609 | 730 | global $globalStatsFilters; |
610 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
731 | + if ($filter_name == '') { |
|
732 | + $filter_name = $this->filter_name; |
|
733 | + } |
|
611 | 734 | $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"; |
612 | 735 | $query_data = array('filter_name' => $filter_name); |
613 | 736 | try { |
@@ -629,7 +752,9 @@ discard block |
||
629 | 752 | } |
630 | 753 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
631 | 754 | global $globalStatsFilters; |
632 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
755 | + if ($filter_name == '') { |
|
756 | + $filter_name = $this->filter_name; |
|
757 | + } |
|
633 | 758 | $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"; |
634 | 759 | try { |
635 | 760 | $sth = $this->db->prepare($query); |
@@ -650,7 +775,9 @@ discard block |
||
650 | 775 | } |
651 | 776 | public function countAllMilitaryMonths($filter_name = '') { |
652 | 777 | global $globalStatsFilters; |
653 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
778 | + if ($filter_name == '') { |
|
779 | + $filter_name = $this->filter_name; |
|
780 | + } |
|
654 | 781 | $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"; |
655 | 782 | try { |
656 | 783 | $sth = $this->db->prepare($query); |
@@ -671,9 +798,14 @@ discard block |
||
671 | 798 | } |
672 | 799 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
673 | 800 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
674 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
675 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
676 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
801 | + if ($filter_name == '') { |
|
802 | + $filter_name = $this->filter_name; |
|
803 | + } |
|
804 | + if ($limit) { |
|
805 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
806 | + } else { |
|
807 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
808 | + } |
|
677 | 809 | if ($orderby == 'hour') { |
678 | 810 | /* |
679 | 811 | if ($globalDBdriver == 'mysql') { |
@@ -682,7 +814,9 @@ discard block |
||
682 | 814 | */ |
683 | 815 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
684 | 816 | } |
685 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
817 | + if ($orderby == 'count') { |
|
818 | + $query .= " ORDER BY hour_count DESC"; |
|
819 | + } |
|
686 | 820 | try { |
687 | 821 | $sth = $this->db->prepare($query); |
688 | 822 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -703,8 +837,12 @@ discard block |
||
703 | 837 | |
704 | 838 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
705 | 839 | global $globalStatsFilters; |
706 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
707 | - if ($year == '') $year = date('Y'); |
|
840 | + if ($filter_name == '') { |
|
841 | + $filter_name = $this->filter_name; |
|
842 | + } |
|
843 | + if ($year == '') { |
|
844 | + $year = date('Y'); |
|
845 | + } |
|
708 | 846 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
709 | 847 | if (empty($all)) { |
710 | 848 | $filters = array('airlines' => array($stats_airline)); |
@@ -718,8 +856,12 @@ discard block |
||
718 | 856 | } |
719 | 857 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
720 | 858 | global $globalStatsFilters; |
721 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
722 | - if ($year == '') $year = date('Y'); |
|
859 | + if ($filter_name == '') { |
|
860 | + $filter_name = $this->filter_name; |
|
861 | + } |
|
862 | + if ($year == '') { |
|
863 | + $year = date('Y'); |
|
864 | + } |
|
723 | 865 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
724 | 866 | if (empty($all)) { |
725 | 867 | $filters = array(); |
@@ -733,8 +875,12 @@ discard block |
||
733 | 875 | } |
734 | 876 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
735 | 877 | global $globalStatsFilters; |
736 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
737 | - if ($year == '') $year = date('Y'); |
|
878 | + if ($filter_name == '') { |
|
879 | + $filter_name = $this->filter_name; |
|
880 | + } |
|
881 | + if ($year == '') { |
|
882 | + $year = date('Y'); |
|
883 | + } |
|
738 | 884 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
739 | 885 | if (empty($all)) { |
740 | 886 | $filters = array('airlines' => array($stats_airline)); |
@@ -748,8 +894,12 @@ discard block |
||
748 | 894 | } |
749 | 895 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
750 | 896 | global $globalStatsFilters; |
751 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
752 | - if ($year == '') $year = date('Y'); |
|
897 | + if ($filter_name == '') { |
|
898 | + $filter_name = $this->filter_name; |
|
899 | + } |
|
900 | + if ($year == '') { |
|
901 | + $year = date('Y'); |
|
902 | + } |
|
753 | 903 | $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
754 | 904 | if (empty($all)) { |
755 | 905 | $filters = array('airlines' => array($stats_airline)); |
@@ -763,7 +913,9 @@ discard block |
||
763 | 913 | } |
764 | 914 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
765 | 915 | global $globalStatsFilters; |
766 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
916 | + if ($filter_name == '') { |
|
917 | + $filter_name = $this->filter_name; |
|
918 | + } |
|
767 | 919 | if ($year == '' && $month == '') { |
768 | 920 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
769 | 921 | try { |
@@ -774,7 +926,9 @@ discard block |
||
774 | 926 | } |
775 | 927 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
776 | 928 | $all = $result[0]['nb_airline']; |
777 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
929 | + } else { |
|
930 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
931 | + } |
|
778 | 932 | if (empty($all)) { |
779 | 933 | $filters = array(); |
780 | 934 | if ($filter_name != '') { |
@@ -787,8 +941,12 @@ discard block |
||
787 | 941 | } |
788 | 942 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
789 | 943 | global $globalStatsFilters; |
790 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
791 | - if ($year == '') $year = date('Y'); |
|
944 | + if ($filter_name == '') { |
|
945 | + $filter_name = $this->filter_name; |
|
946 | + } |
|
947 | + if ($year == '') { |
|
948 | + $year = date('Y'); |
|
949 | + } |
|
792 | 950 | /* |
793 | 951 | $query = "SELECT COUNT(*) AS nb_owner FROM stats_owner"; |
794 | 952 | try { |
@@ -813,8 +971,12 @@ discard block |
||
813 | 971 | } |
814 | 972 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
815 | 973 | global $globalStatsFilters; |
816 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
817 | - if ($year == '') $year = date('Y'); |
|
974 | + if ($filter_name == '') { |
|
975 | + $filter_name = $this->filter_name; |
|
976 | + } |
|
977 | + if ($year == '') { |
|
978 | + $year = date('Y'); |
|
979 | + } |
|
818 | 980 | $all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month); |
819 | 981 | if (empty($all)) { |
820 | 982 | $filters = array('airlines' => array($stats_airline)); |
@@ -828,7 +990,9 @@ discard block |
||
828 | 990 | } |
829 | 991 | |
830 | 992 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
831 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
993 | + if ($filter_name == '') { |
|
994 | + $filter_name = $this->filter_name; |
|
995 | + } |
|
832 | 996 | $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"; |
833 | 997 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
834 | 998 | try { |
@@ -841,7 +1005,9 @@ discard block |
||
841 | 1005 | return $all; |
842 | 1006 | } |
843 | 1007 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
844 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1008 | + if ($filter_name == '') { |
|
1009 | + $filter_name = $this->filter_name; |
|
1010 | + } |
|
845 | 1011 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
846 | 1012 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
847 | 1013 | try { |
@@ -854,7 +1020,9 @@ discard block |
||
854 | 1020 | return $all; |
855 | 1021 | } |
856 | 1022 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
857 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1023 | + if ($filter_name == '') { |
|
1024 | + $filter_name = $this->filter_name; |
|
1025 | + } |
|
858 | 1026 | global $globalArchiveMonths, $globalDBdriver; |
859 | 1027 | if ($globalDBdriver == 'mysql') { |
860 | 1028 | if ($month == '') { |
@@ -884,7 +1052,9 @@ discard block |
||
884 | 1052 | } |
885 | 1053 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
886 | 1054 | global $globalArchiveMonths, $globalDBdriver; |
887 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1055 | + if ($filter_name == '') { |
|
1056 | + $filter_name = $this->filter_name; |
|
1057 | + } |
|
888 | 1058 | if ($globalDBdriver == 'mysql') { |
889 | 1059 | $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"; |
890 | 1060 | } else { |
@@ -902,7 +1072,9 @@ discard block |
||
902 | 1072 | } |
903 | 1073 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
904 | 1074 | global $globalArchiveMonths, $globalDBdriver; |
905 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1075 | + if ($filter_name == '') { |
|
1076 | + $filter_name = $this->filter_name; |
|
1077 | + } |
|
906 | 1078 | if ($globalDBdriver == 'mysql') { |
907 | 1079 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
908 | 1080 | } else { |
@@ -919,7 +1091,9 @@ discard block |
||
919 | 1091 | } |
920 | 1092 | public function getStatsAirlineTotal($filter_name = '') { |
921 | 1093 | global $globalArchiveMonths, $globalDBdriver; |
922 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1094 | + if ($filter_name == '') { |
|
1095 | + $filter_name = $this->filter_name; |
|
1096 | + } |
|
923 | 1097 | if ($globalDBdriver == 'mysql') { |
924 | 1098 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
925 | 1099 | } else { |
@@ -936,7 +1110,9 @@ discard block |
||
936 | 1110 | } |
937 | 1111 | public function getStatsOwnerTotal($filter_name = '') { |
938 | 1112 | global $globalArchiveMonths, $globalDBdriver; |
939 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1113 | + if ($filter_name == '') { |
|
1114 | + $filter_name = $this->filter_name; |
|
1115 | + } |
|
940 | 1116 | if ($globalDBdriver == 'mysql') { |
941 | 1117 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
942 | 1118 | } else { |
@@ -953,7 +1129,9 @@ discard block |
||
953 | 1129 | } |
954 | 1130 | public function getStatsPilotTotal($filter_name = '') { |
955 | 1131 | global $globalArchiveMonths, $globalDBdriver; |
956 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1132 | + if ($filter_name == '') { |
|
1133 | + $filter_name = $this->filter_name; |
|
1134 | + } |
|
957 | 1135 | if ($globalDBdriver == 'mysql') { |
958 | 1136 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
959 | 1137 | } else { |
@@ -971,7 +1149,9 @@ discard block |
||
971 | 1149 | |
972 | 1150 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
973 | 1151 | global $globalDBdriver; |
974 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1152 | + if ($filter_name == '') { |
|
1153 | + $filter_name = $this->filter_name; |
|
1154 | + } |
|
975 | 1155 | if ($globalDBdriver == 'mysql') { |
976 | 1156 | $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"; |
977 | 1157 | } else { |
@@ -987,7 +1167,9 @@ discard block |
||
987 | 1167 | } |
988 | 1168 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
989 | 1169 | global $globalDBdriver; |
990 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1170 | + if ($filter_name == '') { |
|
1171 | + $filter_name = $this->filter_name; |
|
1172 | + } |
|
991 | 1173 | if ($globalDBdriver == 'mysql') { |
992 | 1174 | $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"; |
993 | 1175 | } else { |
@@ -1373,10 +1555,14 @@ discard block |
||
1373 | 1555 | $Connection = new Connection(); |
1374 | 1556 | date_default_timezone_set('UTC'); |
1375 | 1557 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
1376 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1558 | + if ($globalDebug) { |
|
1559 | + echo 'Update stats !'."\n"; |
|
1560 | + } |
|
1377 | 1561 | if (isset($last_update[0]['value'])) { |
1378 | 1562 | $last_update_day = $last_update[0]['value']; |
1379 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1563 | + } else { |
|
1564 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1565 | + } |
|
1380 | 1566 | $reset = false; |
1381 | 1567 | if ($globalStatsResetYear) { |
1382 | 1568 | $reset = true; |
@@ -1384,42 +1570,60 @@ discard block |
||
1384 | 1570 | } |
1385 | 1571 | $Spotter = new Spotter($this->db); |
1386 | 1572 | |
1387 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1573 | + if ($globalDebug) { |
|
1574 | + echo 'Count all aircraft types...'."\n"; |
|
1575 | + } |
|
1388 | 1576 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1389 | 1577 | foreach ($alldata as $number) { |
1390 | 1578 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
1391 | 1579 | } |
1392 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1580 | + if ($globalDebug) { |
|
1581 | + echo 'Count all airlines...'."\n"; |
|
1582 | + } |
|
1393 | 1583 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1394 | 1584 | foreach ($alldata as $number) { |
1395 | 1585 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
1396 | 1586 | } |
1397 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1587 | + if ($globalDebug) { |
|
1588 | + echo 'Count all registrations...'."\n"; |
|
1589 | + } |
|
1398 | 1590 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1399 | 1591 | foreach ($alldata as $number) { |
1400 | 1592 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
1401 | 1593 | } |
1402 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1594 | + if ($globalDebug) { |
|
1595 | + echo 'Count all callsigns...'."\n"; |
|
1596 | + } |
|
1403 | 1597 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1404 | 1598 | foreach ($alldata as $number) { |
1405 | 1599 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1406 | 1600 | } |
1407 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1601 | + if ($globalDebug) { |
|
1602 | + echo 'Count all owners...'."\n"; |
|
1603 | + } |
|
1408 | 1604 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1409 | 1605 | foreach ($alldata as $number) { |
1410 | 1606 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
1411 | 1607 | } |
1412 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1608 | + if ($globalDebug) { |
|
1609 | + echo 'Count all pilots...'."\n"; |
|
1610 | + } |
|
1413 | 1611 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1414 | 1612 | foreach ($alldata as $number) { |
1415 | 1613 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
1416 | 1614 | } |
1417 | 1615 | |
1418 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1616 | + if ($globalDebug) { |
|
1617 | + echo 'Count all departure airports...'."\n"; |
|
1618 | + } |
|
1419 | 1619 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1420 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1620 | + if ($globalDebug) { |
|
1621 | + echo 'Count all detected departure airports...'."\n"; |
|
1622 | + } |
|
1421 | 1623 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1422 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1624 | + if ($globalDebug) { |
|
1625 | + echo 'Order departure airports...'."\n"; |
|
1626 | + } |
|
1423 | 1627 | $alldata = array(); |
1424 | 1628 | |
1425 | 1629 | foreach ($pall as $value) { |
@@ -1430,7 +1634,9 @@ discard block |
||
1430 | 1634 | $icao = $value['airport_departure_icao']; |
1431 | 1635 | if (isset($alldata[$icao])) { |
1432 | 1636 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1433 | - } else $alldata[$icao] = $value; |
|
1637 | + } else { |
|
1638 | + $alldata[$icao] = $value; |
|
1639 | + } |
|
1434 | 1640 | } |
1435 | 1641 | $count = array(); |
1436 | 1642 | foreach ($alldata as $key => $row) { |
@@ -1440,11 +1646,17 @@ discard block |
||
1440 | 1646 | foreach ($alldata as $number) { |
1441 | 1647 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
1442 | 1648 | } |
1443 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1649 | + if ($globalDebug) { |
|
1650 | + echo 'Count all arrival airports...'."\n"; |
|
1651 | + } |
|
1444 | 1652 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1445 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1653 | + if ($globalDebug) { |
|
1654 | + echo 'Count all detected arrival airports...'."\n"; |
|
1655 | + } |
|
1446 | 1656 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1447 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1657 | + if ($globalDebug) { |
|
1658 | + echo 'Order arrival airports...'."\n"; |
|
1659 | + } |
|
1448 | 1660 | $alldata = array(); |
1449 | 1661 | foreach ($pall as $value) { |
1450 | 1662 | $icao = $value['airport_arrival_icao']; |
@@ -1454,7 +1666,9 @@ discard block |
||
1454 | 1666 | $icao = $value['airport_arrival_icao']; |
1455 | 1667 | if (isset($alldata[$icao])) { |
1456 | 1668 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1457 | - } else $alldata[$icao] = $value; |
|
1669 | + } else { |
|
1670 | + $alldata[$icao] = $value; |
|
1671 | + } |
|
1458 | 1672 | } |
1459 | 1673 | $count = array(); |
1460 | 1674 | foreach ($alldata as $key => $row) { |
@@ -1465,7 +1679,9 @@ discard block |
||
1465 | 1679 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
1466 | 1680 | } |
1467 | 1681 | if ($Connection->tableExists('countries')) { |
1468 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1682 | + if ($globalDebug) { |
|
1683 | + echo 'Count all flights by countries...'."\n"; |
|
1684 | + } |
|
1469 | 1685 | $SpotterArchive = new SpotterArchive(); |
1470 | 1686 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1471 | 1687 | foreach ($alldata as $number) { |
@@ -1477,46 +1693,66 @@ discard block |
||
1477 | 1693 | // Add by month using getstat if month finish... |
1478 | 1694 | |
1479 | 1695 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1480 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1696 | + if ($globalDebug) { |
|
1697 | + echo 'Count all flights by months...'."\n"; |
|
1698 | + } |
|
1481 | 1699 | $Spotter = new Spotter($this->db); |
1482 | 1700 | $alldata = $Spotter->countAllMonths(); |
1483 | 1701 | $lastyear = false; |
1484 | 1702 | foreach ($alldata as $number) { |
1485 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1703 | + if ($number['year_name'] != date('Y')) { |
|
1704 | + $lastyear = true; |
|
1705 | + } |
|
1486 | 1706 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1487 | 1707 | } |
1488 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1708 | + if ($globalDebug) { |
|
1709 | + echo 'Count all military flights by months...'."\n"; |
|
1710 | + } |
|
1489 | 1711 | $alldata = $Spotter->countAllMilitaryMonths(); |
1490 | 1712 | foreach ($alldata as $number) { |
1491 | 1713 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1492 | 1714 | } |
1493 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1715 | + if ($globalDebug) { |
|
1716 | + echo 'Count all owners by months...'."\n"; |
|
1717 | + } |
|
1494 | 1718 | $alldata = $Spotter->countAllMonthsOwners(); |
1495 | 1719 | foreach ($alldata as $number) { |
1496 | 1720 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1497 | 1721 | } |
1498 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1722 | + if ($globalDebug) { |
|
1723 | + echo 'Count all pilots by months...'."\n"; |
|
1724 | + } |
|
1499 | 1725 | $alldata = $Spotter->countAllMonthsPilots(); |
1500 | 1726 | foreach ($alldata as $number) { |
1501 | 1727 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1502 | 1728 | } |
1503 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1729 | + if ($globalDebug) { |
|
1730 | + echo 'Count all airlines by months...'."\n"; |
|
1731 | + } |
|
1504 | 1732 | $alldata = $Spotter->countAllMonthsAirlines(); |
1505 | 1733 | foreach ($alldata as $number) { |
1506 | 1734 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1507 | 1735 | } |
1508 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1736 | + if ($globalDebug) { |
|
1737 | + echo 'Count all aircrafts by months...'."\n"; |
|
1738 | + } |
|
1509 | 1739 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1510 | 1740 | foreach ($alldata as $number) { |
1511 | 1741 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1512 | 1742 | } |
1513 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1743 | + if ($globalDebug) { |
|
1744 | + echo 'Count all real arrivals by months...'."\n"; |
|
1745 | + } |
|
1514 | 1746 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1515 | 1747 | foreach ($alldata as $number) { |
1516 | 1748 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1517 | 1749 | } |
1518 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1519 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1750 | + if ($globalDebug) { |
|
1751 | + echo 'Airports data...'."\n"; |
|
1752 | + } |
|
1753 | + if ($globalDebug) { |
|
1754 | + echo '...Departure'."\n"; |
|
1755 | + } |
|
1520 | 1756 | $this->deleteStatAirport('daily'); |
1521 | 1757 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1522 | 1758 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1636,37 +1872,53 @@ discard block |
||
1636 | 1872 | |
1637 | 1873 | // Count by airlines |
1638 | 1874 | echo '--- Stats by airlines ---'."\n"; |
1639 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
1875 | + if ($globalDebug) { |
|
1876 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
1877 | + } |
|
1640 | 1878 | $Spotter = new Spotter($this->db); |
1641 | 1879 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1642 | 1880 | foreach ($alldata as $number) { |
1643 | 1881 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
1644 | 1882 | } |
1645 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1883 | + if ($globalDebug) { |
|
1884 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1885 | + } |
|
1646 | 1886 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1647 | 1887 | foreach ($alldata as $number) { |
1648 | 1888 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
1649 | 1889 | } |
1650 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
1890 | + if ($globalDebug) { |
|
1891 | + echo 'Count all callsigns by airlines...'."\n"; |
|
1892 | + } |
|
1651 | 1893 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1652 | 1894 | foreach ($alldata as $number) { |
1653 | 1895 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1654 | 1896 | } |
1655 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
1897 | + if ($globalDebug) { |
|
1898 | + echo 'Count all owners by airlines...'."\n"; |
|
1899 | + } |
|
1656 | 1900 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1657 | 1901 | foreach ($alldata as $number) { |
1658 | 1902 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
1659 | 1903 | } |
1660 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
1904 | + if ($globalDebug) { |
|
1905 | + echo 'Count all pilots by airlines...'."\n"; |
|
1906 | + } |
|
1661 | 1907 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1662 | 1908 | foreach ($alldata as $number) { |
1663 | 1909 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
1664 | 1910 | } |
1665 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
1911 | + if ($globalDebug) { |
|
1912 | + echo 'Count all departure airports by airlines...'."\n"; |
|
1913 | + } |
|
1666 | 1914 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1667 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
1915 | + if ($globalDebug) { |
|
1916 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
1917 | + } |
|
1668 | 1918 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1669 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
1919 | + if ($globalDebug) { |
|
1920 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
1921 | + } |
|
1670 | 1922 | //$alldata = array(); |
1671 | 1923 | foreach ($dall as $value) { |
1672 | 1924 | $icao = $value['airport_departure_icao']; |
@@ -1687,11 +1939,17 @@ discard block |
||
1687 | 1939 | foreach ($alldata as $number) { |
1688 | 1940 | 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'],'',$reset); |
1689 | 1941 | } |
1690 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
1942 | + if ($globalDebug) { |
|
1943 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
1944 | + } |
|
1691 | 1945 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1692 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1946 | + if ($globalDebug) { |
|
1947 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1948 | + } |
|
1693 | 1949 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1694 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
1950 | + if ($globalDebug) { |
|
1951 | + echo 'Order arrival airports by airlines...'."\n"; |
|
1952 | + } |
|
1695 | 1953 | //$alldata = array(); |
1696 | 1954 | foreach ($dall as $value) { |
1697 | 1955 | $icao = $value['airport_arrival_icao']; |
@@ -1710,37 +1968,53 @@ discard block |
||
1710 | 1968 | } |
1711 | 1969 | $alldata = $pall; |
1712 | 1970 | foreach ($alldata as $number) { |
1713 | - 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'],'',$reset); |
|
1971 | + if ($number['airline_icao'] != '') { |
|
1972 | + 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'],'',$reset); |
|
1973 | + } |
|
1974 | + } |
|
1975 | + if ($globalDebug) { |
|
1976 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1714 | 1977 | } |
1715 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1716 | 1978 | $Spotter = new Spotter($this->db); |
1717 | 1979 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1718 | 1980 | $lastyear = false; |
1719 | 1981 | foreach ($alldata as $number) { |
1720 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1982 | + if ($number['year_name'] != date('Y')) { |
|
1983 | + $lastyear = true; |
|
1984 | + } |
|
1721 | 1985 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1722 | 1986 | } |
1723 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
1987 | + if ($globalDebug) { |
|
1988 | + echo 'Count all owners by months by airlines...'."\n"; |
|
1989 | + } |
|
1724 | 1990 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1725 | 1991 | foreach ($alldata as $number) { |
1726 | 1992 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1727 | 1993 | } |
1728 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
1994 | + if ($globalDebug) { |
|
1995 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
1996 | + } |
|
1729 | 1997 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1730 | 1998 | foreach ($alldata as $number) { |
1731 | 1999 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1732 | 2000 | } |
1733 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2001 | + if ($globalDebug) { |
|
2002 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2003 | + } |
|
1734 | 2004 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1735 | 2005 | foreach ($alldata as $number) { |
1736 | 2006 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1737 | 2007 | } |
1738 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2008 | + if ($globalDebug) { |
|
2009 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2010 | + } |
|
1739 | 2011 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1740 | 2012 | foreach ($alldata as $number) { |
1741 | 2013 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1742 | 2014 | } |
1743 | - if ($globalDebug) echo '...Departure'."\n"; |
|
2015 | + if ($globalDebug) { |
|
2016 | + echo '...Departure'."\n"; |
|
2017 | + } |
|
1744 | 2018 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1745 | 2019 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1746 | 2020 | foreach ($dall as $value) { |
@@ -1763,7 +2037,9 @@ discard block |
||
1763 | 2037 | foreach ($alldata as $number) { |
1764 | 2038 | $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']); |
1765 | 2039 | } |
1766 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
2040 | + if ($globalDebug) { |
|
2041 | + echo '...Arrival'."\n"; |
|
2042 | + } |
|
1767 | 2043 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1768 | 2044 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1769 | 2045 | foreach ($dall as $value) { |
@@ -1787,13 +2063,19 @@ discard block |
||
1787 | 2063 | $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']); |
1788 | 2064 | } |
1789 | 2065 | |
1790 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1791 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2066 | + if ($globalDebug) { |
|
2067 | + echo 'Flights data...'."\n"; |
|
2068 | + } |
|
2069 | + if ($globalDebug) { |
|
2070 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2071 | + } |
|
1792 | 2072 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1793 | 2073 | foreach ($alldata as $number) { |
1794 | 2074 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1795 | 2075 | } |
1796 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2076 | + if ($globalDebug) { |
|
2077 | + echo '-> countAllDates...'."\n"; |
|
2078 | + } |
|
1797 | 2079 | //$previousdata = $this->countAllDatesByAirlines(); |
1798 | 2080 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1799 | 2081 | $values = array(); |
@@ -1806,7 +2088,9 @@ discard block |
||
1806 | 2088 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1807 | 2089 | } |
1808 | 2090 | |
1809 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2091 | + if ($globalDebug) { |
|
2092 | + echo '-> countAllHours...'."\n"; |
|
2093 | + } |
|
1810 | 2094 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1811 | 2095 | foreach ($alldata as $number) { |
1812 | 2096 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
@@ -1814,7 +2098,9 @@ discard block |
||
1814 | 2098 | |
1815 | 2099 | |
1816 | 2100 | // Stats by filters |
1817 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2101 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2102 | + $globalStatsFilters = array(); |
|
2103 | + } |
|
1818 | 2104 | foreach ($globalStatsFilters as $name => $filter) { |
1819 | 2105 | //$filter_name = $filter['name']; |
1820 | 2106 | $filter_name = $name; |
@@ -1822,11 +2108,15 @@ discard block |
||
1822 | 2108 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
1823 | 2109 | if (isset($last_update[0]['value'])) { |
1824 | 2110 | $last_update_day = $last_update[0]['value']; |
1825 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2111 | + } else { |
|
2112 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2113 | + } |
|
1826 | 2114 | $reset = false; |
1827 | 2115 | |
1828 | 2116 | // Count by filter |
1829 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2117 | + if ($globalDebug) { |
|
2118 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2119 | + } |
|
1830 | 2120 | $Spotter = new Spotter($this->db); |
1831 | 2121 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
1832 | 2122 | foreach ($alldata as $number) { |
@@ -1863,7 +2153,9 @@ discard block |
||
1863 | 2153 | $icao = $value['airport_departure_icao']; |
1864 | 2154 | if (isset($alldata[$icao])) { |
1865 | 2155 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1866 | - } else $alldata[$icao] = $value; |
|
2156 | + } else { |
|
2157 | + $alldata[$icao] = $value; |
|
2158 | + } |
|
1867 | 2159 | } |
1868 | 2160 | $count = array(); |
1869 | 2161 | foreach ($alldata as $key => $row) { |
@@ -1884,7 +2176,9 @@ discard block |
||
1884 | 2176 | $icao = $value['airport_arrival_icao']; |
1885 | 2177 | if (isset($alldata[$icao])) { |
1886 | 2178 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1887 | - } else $alldata[$icao] = $value; |
|
2179 | + } else { |
|
2180 | + $alldata[$icao] = $value; |
|
2181 | + } |
|
1888 | 2182 | } |
1889 | 2183 | $count = array(); |
1890 | 2184 | foreach ($alldata as $key => $row) { |
@@ -1898,7 +2192,9 @@ discard block |
||
1898 | 2192 | $alldata = $Spotter->countAllMonths($filter); |
1899 | 2193 | $lastyear = false; |
1900 | 2194 | foreach ($alldata as $number) { |
1901 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2195 | + if ($number['year_name'] != date('Y')) { |
|
2196 | + $lastyear = true; |
|
2197 | + } |
|
1902 | 2198 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
1903 | 2199 | } |
1904 | 2200 | $alldata = $Spotter->countAllMonthsOwners($filter); |