@@ -44,7 +44,9 @@ discard block |
||
44 | 44 | |
45 | 45 | public function checkAll() { |
46 | 46 | global $globalDebug; |
47 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
47 | + if ($globalDebug) { |
|
48 | + echo "Update last seen tracked data...\n"; |
|
49 | + } |
|
48 | 50 | foreach ($this->all_tracked as $key => $flight) { |
49 | 51 | if (isset($this->all_tracked[$key]['id'])) { |
50 | 52 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -57,12 +59,16 @@ discard block |
||
57 | 59 | public function del() { |
58 | 60 | global $globalDebug; |
59 | 61 | // Delete old infos |
60 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
62 | + if ($globalDebug) { |
|
63 | + echo 'Delete old values and update latest data...'."\n"; |
|
64 | + } |
|
61 | 65 | foreach ($this->all_tracked as $key => $flight) { |
62 | 66 | if (isset($flight['lastupdate'])) { |
63 | 67 | if ($flight['lastupdate'] < (time()-3000)) { |
64 | 68 | if (isset($this->all_tracked[$key]['id'])) { |
65 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
69 | + if ($globalDebug) { |
|
70 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
71 | + } |
|
66 | 72 | /* |
67 | 73 | $TrackerLive = new TrackerLive(); |
68 | 74 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -72,7 +78,9 @@ discard block |
||
72 | 78 | $Tracker = new Tracker($this->db); |
73 | 79 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
74 | 80 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
75 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
81 | + if ($globalDebug && $result != 'success') { |
|
82 | + echo '!!! ERROR : '.$result."\n"; |
|
83 | + } |
|
76 | 84 | } |
77 | 85 | // Put in archive |
78 | 86 | // $Tracker->db = null; |
@@ -85,7 +93,9 @@ discard block |
||
85 | 93 | |
86 | 94 | public function add($line) { |
87 | 95 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
88 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
96 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
97 | + $globalCoordMinChange = '0.02'; |
|
98 | + } |
|
89 | 99 | date_default_timezone_set('UTC'); |
90 | 100 | $dataFound = false; |
91 | 101 | $send = false; |
@@ -109,8 +119,11 @@ discard block |
||
109 | 119 | */ |
110 | 120 | |
111 | 121 | $Common = new Common(); |
112 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
113 | - else $id = trim($line['id']); |
|
122 | + if (!isset($line['id'])) { |
|
123 | + $id = trim($line['ident']); |
|
124 | + } else { |
|
125 | + $id = trim($line['id']); |
|
126 | + } |
|
114 | 127 | |
115 | 128 | if (!isset($this->all_tracked[$id])) { |
116 | 129 | $this->all_tracked[$id] = array(); |
@@ -118,18 +131,27 @@ discard block |
||
118 | 131 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
119 | 132 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
120 | 133 | if (!isset($line['id'])) { |
121 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
134 | + if (!isset($globalDaemon)) { |
|
135 | + $globalDaemon = TRUE; |
|
136 | + } |
|
122 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
138 | + } else { |
|
139 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
140 | + } |
|
141 | + if ($globalAllTracked !== FALSE) { |
|
142 | + $dataFound = true; |
|
143 | + } |
|
125 | 144 | } |
126 | 145 | |
127 | 146 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
128 | 147 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
129 | 148 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
130 | 149 | } else { |
131 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
132 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
150 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
151 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
152 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
153 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
154 | + } |
|
133 | 155 | return ''; |
134 | 156 | } |
135 | 157 | } else { |
@@ -145,11 +167,17 @@ discard block |
||
145 | 167 | $Tracker = new Tracker($this->db); |
146 | 168 | $fromsource = NULL; |
147 | 169 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
148 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
170 | + if ($globalDebug && $result != 'success') { |
|
171 | + echo '!!! ERROR : '.$result."\n"; |
|
172 | + } |
|
149 | 173 | $Tracker->db = null; |
150 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
174 | + if ($globalDebugTimeElapsed) { |
|
175 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
176 | + } |
|
177 | + } |
|
178 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
179 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
151 | 180 | } |
152 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
153 | 181 | } |
154 | 182 | |
155 | 183 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -160,14 +188,21 @@ discard block |
||
160 | 188 | if ($distance > 1000 && $distance < 10000) { |
161 | 189 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
162 | 190 | $speed = $speed*3.6; |
163 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
164 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
191 | + if ($speed < 1000) { |
|
192 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
193 | + } |
|
194 | + if ($globalDebug) { |
|
195 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
196 | + } |
|
165 | 197 | } |
166 | 198 | } |
167 | 199 | |
168 | 200 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
169 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
170 | - else unset($timediff); |
|
201 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
202 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
203 | + } else { |
|
204 | + unset($timediff); |
|
205 | + } |
|
171 | 206 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
172 | 207 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
173 | 208 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -175,20 +210,30 @@ discard block |
||
175 | 210 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
176 | 211 | $this->all_tracked[$id]['putinarchive'] = true; |
177 | 212 | |
178 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
213 | + if ($globalDebug) { |
|
214 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
215 | + } |
|
179 | 216 | $timeelapsed = microtime(true); |
180 | 217 | $Tracker = new Tracker($this->db); |
181 | 218 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
182 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
219 | + if (!empty($all_country)) { |
|
220 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
221 | + } |
|
183 | 222 | $Tracker->db = null; |
184 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
223 | + if ($globalDebugTimeElapsed) { |
|
224 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
225 | + } |
|
185 | 226 | $this->tmd = 0; |
186 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
227 | + if ($globalDebug) { |
|
228 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
229 | + } |
|
187 | 230 | } |
188 | 231 | } |
189 | 232 | |
190 | 233 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
191 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
234 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
235 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
236 | + } |
|
192 | 237 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
193 | 238 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
194 | 239 | $dataFound = true; |
@@ -197,8 +242,12 @@ discard block |
||
197 | 242 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
198 | 243 | } |
199 | 244 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
200 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
201 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
245 | + if ($line['longitude'] > 180) { |
|
246 | + $line['longitude'] = $line['longitude'] - 360; |
|
247 | + } |
|
248 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
249 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
250 | + } |
|
202 | 251 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
203 | 252 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
204 | 253 | $dataFound = true; |
@@ -216,7 +265,9 @@ discard block |
||
216 | 265 | } |
217 | 266 | } |
218 | 267 | if (isset($line['last_update']) && $line['last_update'] != '') { |
219 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
268 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
269 | + $dataFound = true; |
|
270 | + } |
|
220 | 271 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
221 | 272 | } |
222 | 273 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -236,7 +287,9 @@ discard block |
||
236 | 287 | |
237 | 288 | if (isset($line['altitude']) && $line['altitude'] != '') { |
238 | 289 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
239 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
290 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
291 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
292 | + } |
|
240 | 293 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
241 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
242 | 295 | //$dataFound = true; |
@@ -248,15 +301,21 @@ discard block |
||
248 | 301 | } |
249 | 302 | |
250 | 303 | if (isset($line['heading']) && $line['heading'] != '') { |
251 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
304 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
305 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
306 | + } |
|
252 | 307 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
253 | 308 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
254 | 309 | //$dataFound = true; |
255 | 310 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
256 | 311 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
257 | 312 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
258 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
313 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
314 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
315 | + } |
|
316 | + if ($globalDebug) { |
|
317 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
318 | + } |
|
260 | 319 | } |
261 | 320 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
262 | 321 | |
@@ -265,20 +324,31 @@ discard block |
||
265 | 324 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
266 | 325 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
267 | 326 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
268 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
327 | + if ($globalDebug) { |
|
328 | + echo "Check if aircraft is already in DB..."; |
|
329 | + } |
|
269 | 330 | $timeelapsed = microtime(true); |
270 | 331 | $TrackerLive = new TrackerLive($this->db); |
271 | 332 | if (isset($line['id'])) { |
272 | 333 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
273 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
334 | + if ($globalDebugTimeElapsed) { |
|
335 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
336 | + } |
|
274 | 337 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
275 | 338 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
276 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
277 | - } else $recent_ident = ''; |
|
339 | + if ($globalDebugTimeElapsed) { |
|
340 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
341 | + } |
|
342 | + } else { |
|
343 | + $recent_ident = ''; |
|
344 | + } |
|
278 | 345 | $TrackerLive->db=null; |
279 | 346 | |
280 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
281 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
347 | + if ($globalDebug && $recent_ident == '') { |
|
348 | + echo " Not in DB.\n"; |
|
349 | + } elseif ($globalDebug && $recent_ident != '') { |
|
350 | + echo " Already in DB.\n"; |
|
351 | + } |
|
282 | 352 | } else { |
283 | 353 | $recent_ident = ''; |
284 | 354 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -286,16 +356,24 @@ discard block |
||
286 | 356 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
287 | 357 | if($recent_ident == "") |
288 | 358 | { |
289 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
359 | + if ($globalDebug) { |
|
360 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
361 | + } |
|
290 | 362 | //adds the spotter data for the archive |
291 | 363 | $highlight = ''; |
292 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
364 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
365 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
366 | + } |
|
293 | 367 | $timeelapsed = microtime(true); |
294 | 368 | $Tracker = new Tracker($this->db); |
295 | 369 | $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
296 | 370 | $Tracker->db = null; |
297 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
298 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
371 | + if ($globalDebug && isset($result)) { |
|
372 | + echo $result."\n"; |
|
373 | + } |
|
374 | + if ($globalDebugTimeElapsed) { |
|
375 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
376 | + } |
|
299 | 377 | |
300 | 378 | /* |
301 | 379 | // Add source stat in DB |
@@ -329,12 +407,16 @@ discard block |
||
329 | 407 | $this->all_tracked[$id]['addedTracker'] = 1; |
330 | 408 | //print_r($this->all_tracked[$id]); |
331 | 409 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
332 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
410 | + if ($globalDebug) { |
|
411 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
412 | + } |
|
333 | 413 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
334 | 414 | $TrackerLive = new TrackerLive($this->db); |
335 | 415 | $TrackerLive->deleteLiveTrackerData(); |
336 | 416 | $TrackerLive->db=null; |
337 | - if ($globalDebug) echo " Done\n"; |
|
417 | + if ($globalDebug) { |
|
418 | + echo " Done\n"; |
|
419 | + } |
|
338 | 420 | $this->last_delete = time(); |
339 | 421 | } |
340 | 422 | } else { |
@@ -357,13 +439,17 @@ discard block |
||
357 | 439 | |
358 | 440 | if (!$ignoreImport) { |
359 | 441 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
360 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
442 | + if ($globalDebug) { |
|
443 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
444 | + } |
|
361 | 445 | $timeelapsed = microtime(true); |
362 | 446 | $TrackerLive = new TrackerLive($this->db); |
363 | 447 | $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
364 | 448 | $TrackerLive->db = null; |
365 | 449 | $this->all_tracked[$id]['putinarchive'] = false; |
366 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
450 | + if ($globalDebugTimeElapsed) { |
|
451 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
452 | + } |
|
367 | 453 | |
368 | 454 | // Put statistics in $this->stats variable |
369 | 455 | /* |
@@ -420,19 +506,29 @@ discard block |
||
420 | 506 | */ |
421 | 507 | |
422 | 508 | $this->all_tracked[$id]['lastupdate'] = time(); |
423 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
424 | - if ($globalDebug) echo $result."\n"; |
|
425 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
509 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
510 | + $send = true; |
|
511 | + } |
|
512 | + if ($globalDebug) { |
|
513 | + echo $result."\n"; |
|
514 | + } |
|
515 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
516 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
517 | + } |
|
426 | 518 | //$this->del(); |
427 | 519 | |
428 | 520 | |
429 | 521 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
430 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
522 | + if ($globalDebug) { |
|
523 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
524 | + } |
|
431 | 525 | $TrackerLive = new TrackerLive($this->db); |
432 | 526 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
433 | 527 | $TrackerLive->db = null; |
434 | 528 | //TrackerLive->deleteLiveTrackerData(); |
435 | - if ($globalDebug) echo " Done\n"; |
|
529 | + if ($globalDebug) { |
|
530 | + echo " Done\n"; |
|
531 | + } |
|
436 | 532 | $this->last_delete_hourly = time(); |
437 | 533 | } |
438 | 534 | |
@@ -440,7 +536,9 @@ discard block |
||
440 | 536 | //$ignoreImport = false; |
441 | 537 | } |
442 | 538 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
443 | - if ($send) return $this->all_tracked[$id]; |
|
539 | + if ($send) { |
|
540 | + return $this->all_tracked[$id]; |
|
541 | + } |
|
444 | 542 | } |
445 | 543 | } |
446 | 544 | } |
@@ -63,7 +63,9 @@ |
||
63 | 63 | { |
64 | 64 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
65 | 65 | $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
66 | - } else $image = $spotter_item['image_thumbnail']; |
|
66 | + } else { |
|
67 | + $image = $spotter_item['image_thumbnail']; |
|
68 | + } |
|
67 | 69 | |
68 | 70 | } |
69 | 71 | /* else { |
@@ -37,8 +37,11 @@ discard block |
||
37 | 37 | } else { |
38 | 38 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
39 | 39 | } |
40 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
41 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
40 | + if ($timeout == '') { |
|
41 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
42 | + } else { |
|
43 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
44 | + } |
|
42 | 45 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
43 | 46 | if ($type == 'post') { |
44 | 47 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -85,8 +88,9 @@ discard block |
||
85 | 88 | private function curlResponseHeaderCallback($ch, $headerLine) { |
86 | 89 | //global $cookies; |
87 | 90 | $cookies = array(); |
88 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
89 | - $cookies[] = $cookie; |
|
91 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
92 | + $cookies[] = $cookie; |
|
93 | + } |
|
90 | 94 | return strlen($headerLine); // Needed by curl |
91 | 95 | } |
92 | 96 | |
@@ -97,11 +101,15 @@ discard block |
||
97 | 101 | curl_setopt($ch, CURLOPT_URL, $url); |
98 | 102 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
99 | 103 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
100 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
104 | + if ($referer != '') { |
|
105 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
106 | + } |
|
101 | 107 | 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'); |
102 | 108 | curl_setopt($ch, CURLOPT_FILE, $fp); |
103 | 109 | curl_exec($ch); |
104 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
110 | + if (curl_errno($ch) && $globalDebug) { |
|
111 | + echo 'Download error: '.curl_error($ch); |
|
112 | + } |
|
105 | 113 | curl_close($ch); |
106 | 114 | fclose($fp); |
107 | 115 | } |
@@ -112,10 +120,16 @@ discard block |
||
112 | 120 | * @return Array array of the tables in HTML page |
113 | 121 | */ |
114 | 122 | public function table2array($data) { |
115 | - if (!is_string($data)) return array(); |
|
116 | - if ($data == '') return array(); |
|
123 | + if (!is_string($data)) { |
|
124 | + return array(); |
|
125 | + } |
|
126 | + if ($data == '') { |
|
127 | + return array(); |
|
128 | + } |
|
117 | 129 | $html = str_get_html($data); |
118 | - if ($html === false) return array(); |
|
130 | + if ($html === false) { |
|
131 | + return array(); |
|
132 | + } |
|
119 | 133 | $tabledata=array(); |
120 | 134 | foreach($html->find('tr') as $element) |
121 | 135 | { |
@@ -150,7 +164,9 @@ discard block |
||
150 | 164 | */ |
151 | 165 | public function text2array($data) { |
152 | 166 | $html = str_get_html($data); |
153 | - if ($html === false) return array(); |
|
167 | + if ($html === false) { |
|
168 | + return array(); |
|
169 | + } |
|
154 | 170 | $tabledata=array(); |
155 | 171 | foreach($html->find('p') as $element) |
156 | 172 | { |
@@ -171,7 +187,9 @@ discard block |
||
171 | 187 | * @return Float Distance in $unit |
172 | 188 | */ |
173 | 189 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
174 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
190 | + if ($lat == $latc && $lon == $lonc) { |
|
191 | + return 0; |
|
192 | + } |
|
175 | 193 | $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; |
176 | 194 | if ($unit == "km") { |
177 | 195 | return round($dist * 1.609344); |
@@ -195,10 +213,16 @@ discard block |
||
195 | 213 | public function withinThreshold ($timeDifference, $distance) { |
196 | 214 | $x = abs($timeDifference); |
197 | 215 | $d = abs($distance); |
198 | - if ($x == 0 || $d == 0) return true; |
|
216 | + if ($x == 0 || $d == 0) { |
|
217 | + return true; |
|
218 | + } |
|
199 | 219 | // may be due to Internet jitter; distance is realistic |
200 | - if ($x < 0.7 && $d < 2000) return true; |
|
201 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
220 | + if ($x < 0.7 && $d < 2000) { |
|
221 | + return true; |
|
222 | + } else { |
|
223 | + return $d/$x < 1500*0.27778; |
|
224 | + } |
|
225 | + // 1500 km/h max |
|
202 | 226 | } |
203 | 227 | |
204 | 228 | |
@@ -226,11 +250,17 @@ discard block |
||
226 | 250 | |
227 | 251 | public function convertDM($coord,$latlong) { |
228 | 252 | if ($latlong == 'latitude') { |
229 | - if ($coord < 0) $NSEW = 'S'; |
|
230 | - else $NSEW = 'N'; |
|
253 | + if ($coord < 0) { |
|
254 | + $NSEW = 'S'; |
|
255 | + } else { |
|
256 | + $NSEW = 'N'; |
|
257 | + } |
|
231 | 258 | } elseif ($latlong == 'longitude') { |
232 | - if ($coord < 0) $NSEW = 'W'; |
|
233 | - else $NSEW = 'E'; |
|
259 | + if ($coord < 0) { |
|
260 | + $NSEW = 'W'; |
|
261 | + } else { |
|
262 | + $NSEW = 'E'; |
|
263 | + } |
|
234 | 264 | } |
235 | 265 | $coord = abs($coord); |
236 | 266 | $deg = floor($coord); |
@@ -273,7 +303,9 @@ discard block |
||
273 | 303 | public function hex2str($hex) { |
274 | 304 | $str = ''; |
275 | 305 | $hexln = strlen($hex); |
276 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
306 | + for($i=0;$i<$hexln;$i+=2) { |
|
307 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
308 | + } |
|
277 | 309 | return $str; |
278 | 310 | } |
279 | 311 | |
@@ -301,8 +333,11 @@ discard block |
||
301 | 333 | $b = $lat2 - $lat1; |
302 | 334 | $c = -($a*$lat1+$b*$lon1); |
303 | 335 | $d = $a*$lat3+$b*$lon3+$c; |
304 | - if ($d > -$approx && $d < $approx) return true; |
|
305 | - else return false; |
|
336 | + if ($d > -$approx && $d < $approx) { |
|
337 | + return true; |
|
338 | + } else { |
|
339 | + return false; |
|
340 | + } |
|
306 | 341 | } |
307 | 342 | |
308 | 343 | public function array_merge_noappend() { |
@@ -361,7 +396,9 @@ discard block |
||
361 | 396 | return $result; |
362 | 397 | } |
363 | 398 | $handle = @opendir('./locale'); |
364 | - if ($handle === false) return $result; |
|
399 | + if ($handle === false) { |
|
400 | + return $result; |
|
401 | + } |
|
365 | 402 | while (false !== ($file = readdir($handle))) { |
366 | 403 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
367 | 404 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -428,8 +465,9 @@ discard block |
||
428 | 465 | $error = false; |
429 | 466 | if ($fp_out = gzopen($dest, $mode)) { |
430 | 467 | if ($fp_in = fopen($source,'rb')) { |
431 | - while (!feof($fp_in)) |
|
432 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
468 | + while (!feof($fp_in)) { |
|
469 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
470 | + } |
|
433 | 471 | fclose($fp_in); |
434 | 472 | } else { |
435 | 473 | $error = true; |
@@ -438,14 +476,17 @@ discard block |
||
438 | 476 | } else { |
439 | 477 | $error = true; |
440 | 478 | } |
441 | - if ($error) |
|
442 | - return false; |
|
443 | - else |
|
444 | - return $dest; |
|
479 | + if ($error) { |
|
480 | + return false; |
|
481 | + } else { |
|
482 | + return $dest; |
|
483 | + } |
|
445 | 484 | } |
446 | 485 | |
447 | 486 | public function remove_accents($string) { |
448 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
487 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
488 | + return $string; |
|
489 | + } |
|
449 | 490 | $chars = array( |
450 | 491 | // Decompositions for Latin-1 Supplement |
451 | 492 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -569,7 +610,9 @@ discard block |
||
569 | 610 | $ip = gethostbyname($host); |
570 | 611 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
571 | 612 | $r = @socket_connect($s, $ip, $port); |
572 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
613 | + if (!socket_set_nonblock($s)) { |
|
614 | + echo "Unable to set nonblock on socket\n"; |
|
615 | + } |
|
573 | 616 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
574 | 617 | return $s; |
575 | 618 | } |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
4 | -if ($date == '') $date = date('Y-m-d'); |
|
4 | +if ($date == '') { |
|
5 | + $date = date('Y-m-d'); |
|
6 | +} |
|
5 | 7 | header('Location: '.$globalURL.'/date/'.$date); |
6 | 8 | ?> |
7 | 9 | \ No newline at end of file |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
4 | -if ($date == '') $date = date('Y-m-d'); |
|
4 | +if ($date == '') { |
|
5 | + $date = date('Y-m-d'); |
|
6 | +} |
|
5 | 7 | header('Location: '.$globalURL.'/accident/'.$date); |
6 | 8 | ?> |
7 | 9 | \ No newline at end of file |
@@ -5,7 +5,9 @@ |
||
5 | 5 | $Spotter = new Spotter(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Route by Waypoint"); |
7 | 7 | require_once('header.php'); |
8 | -if (!isset($filter_name)) $filter_name = ''; |
|
8 | +if (!isset($filter_name)) { |
|
9 | + $filter_name = ''; |
|
10 | +} |
|
9 | 11 | include('statistics-sub-menu.php'); |
10 | 12 | |
11 | 13 | print '<div class="info"> |
@@ -5,7 +5,9 @@ |
||
5 | 5 | $Spotter = new Spotter(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Route by Airport"); |
7 | 7 | require_once('header.php'); |
8 | -if (!isset($filter_name)) $filter_name = ''; |
|
8 | +if (!isset($filter_name)) { |
|
9 | + $filter_name = ''; |
|
10 | +} |
|
9 | 11 | include('statistics-sub-menu.php'); |
10 | 12 | |
11 | 13 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -6,11 +6,15 @@ discard block |
||
6 | 6 | $beginpage = microtime(true); |
7 | 7 | $Stats = new Stats(); |
8 | 8 | |
9 | -if (!isset($filter_name)) $filter_name = ''; |
|
9 | +if (!isset($filter_name)) { |
|
10 | + $filter_name = ''; |
|
11 | +} |
|
10 | 12 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
11 | 13 | if ($airline_icao == '' && isset($globalFilter)) { |
12 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
13 | -} |
|
14 | + if (isset($globalFilter['airline'])) { |
|
15 | + $airline_icao = $globalFilter['airline'][0]; |
|
16 | + } |
|
17 | + } |
|
14 | 18 | if ($airline_icao != '' && $airline_icao != 'all') { |
15 | 19 | $Spotter = new Spotter(); |
16 | 20 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
@@ -41,14 +45,21 @@ discard block |
||
41 | 45 | <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script> |
42 | 46 | <div class="column"> |
43 | 47 | <div class="info"> |
44 | - <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1> |
|
48 | + <h1><?php if (isset($airline_name)) { |
|
49 | + echo _("Statistics for ").$airline_name; |
|
50 | +} else { |
|
51 | + echo _("Statistics"); |
|
52 | +} |
|
53 | +?></h1> |
|
45 | 54 | <?php |
46 | 55 | $last_update = $Stats->getLastStatsUpdate(); |
47 | 56 | //if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->'; |
48 | 57 | if (isset($last_update[0]['value'])) { |
49 | 58 | date_default_timezone_set('UTC'); |
50 | 59 | $lastupdate = strtotime($last_update[0]['value']); |
51 | - if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
|
60 | + if (isset($globalTimezone) && $globalTimezone != '') { |
|
61 | + date_default_timezone_set($globalTimezone); |
|
62 | + } |
|
52 | 63 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
53 | 64 | } |
54 | 65 | ?> |
@@ -100,8 +111,9 @@ discard block |
||
100 | 111 | <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2> |
101 | 112 | <?php |
102 | 113 | $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month); |
103 | - if (count($aircraft_array) == 0) print _("No data available"); |
|
104 | - else { |
|
114 | + if (count($aircraft_array) == 0) { |
|
115 | + print _("No data available"); |
|
116 | + } else { |
|
105 | 117 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
106 | 118 | $aircraft_data = ''; |
107 | 119 | foreach($aircraft_array as $aircraft_item) |
@@ -123,11 +135,17 @@ discard block |
||
123 | 135 | <?php |
124 | 136 | if ($year != '' && $month != '') { |
125 | 137 | ?> |
126 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
138 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
139 | + echo '/'.$airline_icao; |
|
140 | +} |
|
141 | +?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
127 | 142 | <?php |
128 | 143 | } else { |
129 | 144 | ?> |
130 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
145 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
146 | + echo '/'.$airline_icao; |
|
147 | +} |
|
148 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
131 | 149 | <?php |
132 | 150 | } |
133 | 151 | ?> |
@@ -158,11 +176,15 @@ discard block |
||
158 | 176 | print '</script>'; |
159 | 177 | if ($year != '' && $month != '') { |
160 | 178 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
161 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
179 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
180 | + echo '/'.$airline_icao; |
|
181 | + } |
|
162 | 182 | print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
163 | 183 | } else { |
164 | 184 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
165 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
185 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
186 | + echo '/'.$airline_icao; |
|
187 | + } |
|
166 | 188 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
167 | 189 | } |
168 | 190 | print '</div>'; |
@@ -186,8 +208,9 @@ discard block |
||
186 | 208 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
187 | 209 | <?php |
188 | 210 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
189 | - if (count($pilot_array) == 0) print _("No data available"); |
|
190 | - else { |
|
211 | + if (count($pilot_array) == 0) { |
|
212 | + print _("No data available"); |
|
213 | + } else { |
|
191 | 214 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
192 | 215 | $pilot_data = ''; |
193 | 216 | foreach($pilot_array as $pilot_item) |
@@ -206,7 +229,9 @@ discard block |
||
206 | 229 | } |
207 | 230 | print '<div class="more">'; |
208 | 231 | print '<a href="'.$globalURL.'/statistics/pilot'; |
209 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
232 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
233 | + echo '/'.$airline_icao; |
|
234 | + } |
|
210 | 235 | print'" class="btn btn-default btn" role="button">'._("See full statistic").'»</a>'; |
211 | 236 | print '</div>'; |
212 | 237 | ?> |
@@ -220,8 +245,9 @@ discard block |
||
220 | 245 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
221 | 246 | <?php |
222 | 247 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
223 | - if (count($owner_array) == 0) print _("No data available"); |
|
224 | - else { |
|
248 | + if (count($owner_array) == 0) { |
|
249 | + print _("No data available"); |
|
250 | + } else { |
|
225 | 251 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
226 | 252 | $owner_data = ''; |
227 | 253 | foreach($owner_array as $owner_item) |
@@ -240,7 +266,10 @@ discard block |
||
240 | 266 | } |
241 | 267 | ?> |
242 | 268 | <div class="more"> |
243 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
269 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
270 | + echo '/'.$airline_icao; |
|
271 | +} |
|
272 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
244 | 273 | </div> |
245 | 274 | </div> |
246 | 275 | |
@@ -253,8 +282,9 @@ discard block |
||
253 | 282 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
254 | 283 | <?php |
255 | 284 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
256 | - if (count($flightover_array) == 0) print _("No data available"); |
|
257 | - else { |
|
285 | + if (count($flightover_array) == 0) { |
|
286 | + print _("No data available"); |
|
287 | + } else { |
|
258 | 288 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
259 | 289 | print 'var series = ['; |
260 | 290 | $flightover_data = ''; |
@@ -297,7 +327,10 @@ discard block |
||
297 | 327 | } |
298 | 328 | ?> |
299 | 329 | <div class="more"> |
300 | - <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
330 | + <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
331 | + echo '/'.$airline_icao; |
|
332 | +} |
|
333 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
301 | 334 | </div> |
302 | 335 | </div> |
303 | 336 | <?php |
@@ -364,7 +397,9 @@ discard block |
||
364 | 397 | print '</script>'; |
365 | 398 | |
366 | 399 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; |
367 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
400 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
401 | + echo '/'.$airline_icao; |
|
402 | + } |
|
368 | 403 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
369 | 404 | } |
370 | 405 | ?> |
@@ -427,7 +462,9 @@ discard block |
||
427 | 462 | |
428 | 463 | |
429 | 464 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival'; |
430 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
465 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
466 | + echo '/'.$airline_icao; |
|
467 | + } |
|
431 | 468 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
432 | 469 | } |
433 | 470 | ?> |
@@ -442,8 +479,9 @@ discard block |
||
442 | 479 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
443 | 480 | <?php |
444 | 481 | $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
445 | - if (count($year_array) == 0) print _("No data available"); |
|
446 | - else { |
|
482 | + if (count($year_array) == 0) { |
|
483 | + print _("No data available"); |
|
484 | + } else { |
|
447 | 485 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
448 | 486 | $year_data = ''; |
449 | 487 | $year_cnt = ''; |
@@ -463,7 +501,10 @@ discard block |
||
463 | 501 | } |
464 | 502 | ?> |
465 | 503 | <div class="more"> |
466 | - <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
504 | + <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
505 | + echo '/'.$airline_icao; |
|
506 | +} |
|
507 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
467 | 508 | </div> |
468 | 509 | </div> |
469 | 510 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -471,8 +512,9 @@ discard block |
||
471 | 512 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
472 | 513 | <?php |
473 | 514 | $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
474 | - if (count($month_array) == 0) print _("No data available"); |
|
475 | - else { |
|
515 | + if (count($month_array) == 0) { |
|
516 | + print _("No data available"); |
|
517 | + } else { |
|
476 | 518 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
477 | 519 | $month_data = ''; |
478 | 520 | $month_cnt = ''; |
@@ -493,7 +535,10 @@ discard block |
||
493 | 535 | } |
494 | 536 | ?> |
495 | 537 | <div class="more"> |
496 | - <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
538 | + <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
539 | + echo '/'.$airline_icao; |
|
540 | +} |
|
541 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
497 | 542 | </div> |
498 | 543 | </div> |
499 | 544 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -502,8 +547,9 @@ discard block |
||
502 | 547 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
503 | 548 | <?php |
504 | 549 | $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
505 | - if (empty($date_array)) print _("No data available"); |
|
506 | - else { |
|
550 | + if (empty($date_array)) { |
|
551 | + print _("No data available"); |
|
552 | + } else { |
|
507 | 553 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
508 | 554 | $date_data = ''; |
509 | 555 | $date_cnt = ''; |
@@ -524,7 +570,10 @@ discard block |
||
524 | 570 | } |
525 | 571 | ?> |
526 | 572 | <div class="more"> |
527 | - <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
573 | + <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
574 | + echo '/'.$airline_icao; |
|
575 | +} |
|
576 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
528 | 577 | </div> |
529 | 578 | </div> |
530 | 579 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -532,8 +581,9 @@ discard block |
||
532 | 581 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
533 | 582 | <?php |
534 | 583 | $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
535 | - if (empty($hour_array)) print _("No data available"); |
|
536 | - else { |
|
584 | + if (empty($hour_array)) { |
|
585 | + print _("No data available"); |
|
586 | + } else { |
|
537 | 587 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
538 | 588 | $hour_data = ''; |
539 | 589 | $hour_cnt = ''; |
@@ -554,7 +604,10 @@ discard block |
||
554 | 604 | } |
555 | 605 | ?> |
556 | 606 | <div class="more"> |
557 | - <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
607 | + <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
608 | + echo '/'.$airline_icao; |
|
609 | +} |
|
610 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
558 | 611 | </div> |
559 | 612 | </div> |
560 | 613 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -571,8 +624,9 @@ discard block |
||
571 | 624 | <h2><?php echo _("Fatalities by Years"); ?></h2> |
572 | 625 | <?php |
573 | 626 | $year_array = $Stats->countFatalitiesByYear(); |
574 | - if (count($year_array) == 0) print _("No data available"); |
|
575 | - else { |
|
627 | + if (count($year_array) == 0) { |
|
628 | + print _("No data available"); |
|
629 | + } else { |
|
576 | 630 | print '<div id="chart32" class="chart" width="100%"></div><script>'; |
577 | 631 | $year_data = ''; |
578 | 632 | $year_cnt = ''; |
@@ -603,8 +657,9 @@ discard block |
||
603 | 657 | <h2><?php echo _("Fatalities last 12 Months"); ?></h2> |
604 | 658 | <?php |
605 | 659 | $year_array = $Stats->countFatalitiesLast12Months(); |
606 | - if (count($year_array) == 0) print _("No data available"); |
|
607 | - else { |
|
660 | + if (count($year_array) == 0) { |
|
661 | + print _("No data available"); |
|
662 | + } else { |
|
608 | 663 | print '<div id="chart33" class="chart" width="100%"></div><script>'; |
609 | 664 | $year_data = ''; |
610 | 665 | $year_cnt = ''; |
@@ -664,8 +719,11 @@ discard block |
||
664 | 719 | $distance = $distance; |
665 | 720 | $unit = 'km'; |
666 | 721 | } |
667 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
668 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
722 | + if (!isset($polar_data)) { |
|
723 | + $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
724 | + } else { |
|
725 | + $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
726 | + } |
|
669 | 727 | } |
670 | 728 | ?> |
671 | 729 | <div class="col-md-6"> |
@@ -717,8 +775,11 @@ discard block |
||
717 | 775 | foreach ($msg as $eachmsg) { |
718 | 776 | //$eachmsg = $msg[0]; |
719 | 777 | $data = $eachmsg['source_data']; |
720 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
721 | - else $max = 500; |
|
778 | + if ($data > 500) { |
|
779 | + $max = (round(($data+100)/100))*100; |
|
780 | + } else { |
|
781 | + $max = 500; |
|
782 | + } |
|
722 | 783 | ?> |
723 | 784 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
724 | 785 | <script> |
@@ -13,7 +13,9 @@ discard block |
||
13 | 13 | |
14 | 14 | public function __construct($dbc = null) { |
15 | 15 | global $globalFilterName; |
16 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
16 | + if (isset($globalFilterName)) { |
|
17 | + $this->filter_name = $globalFilterName; |
|
18 | + } |
|
17 | 19 | $Connection = new Connection($dbc); |
18 | 20 | $this->db = $Connection->db(); |
19 | 21 | } |
@@ -81,7 +83,9 @@ discard block |
||
81 | 83 | } |
82 | 84 | } |
83 | 85 | public function getAllAirlineNames($filter_name = '') { |
84 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
86 | + if ($filter_name == '') { |
|
87 | + $filter_name = $this->filter_name; |
|
88 | + } |
|
85 | 89 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
86 | 90 | try { |
87 | 91 | $sth = $this->db->prepare($query); |
@@ -93,7 +97,9 @@ discard block |
||
93 | 97 | return $all; |
94 | 98 | } |
95 | 99 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
96 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
100 | + if ($filter_name == '') { |
|
101 | + $filter_name = $this->filter_name; |
|
102 | + } |
|
97 | 103 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
98 | 104 | try { |
99 | 105 | $sth = $this->db->prepare($query); |
@@ -105,7 +111,9 @@ discard block |
||
105 | 111 | return $all; |
106 | 112 | } |
107 | 113 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
108 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
114 | + if ($filter_name == '') { |
|
115 | + $filter_name = $this->filter_name; |
|
116 | + } |
|
109 | 117 | $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"; |
110 | 118 | try { |
111 | 119 | $sth = $this->db->prepare($query); |
@@ -117,7 +125,9 @@ discard block |
||
117 | 125 | return $all; |
118 | 126 | } |
119 | 127 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
120 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
128 | + if ($filter_name == '') { |
|
129 | + $filter_name = $this->filter_name; |
|
130 | + } |
|
121 | 131 | $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"; |
122 | 132 | try { |
123 | 133 | $sth = $this->db->prepare($query); |
@@ -130,7 +140,9 @@ discard block |
||
130 | 140 | } |
131 | 141 | |
132 | 142 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
133 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
143 | + if ($filter_name == '') { |
|
144 | + $filter_name = $this->filter_name; |
|
145 | + } |
|
134 | 146 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
135 | 147 | try { |
136 | 148 | $sth = $this->db->prepare($query); |
@@ -143,7 +155,9 @@ discard block |
||
143 | 155 | } |
144 | 156 | |
145 | 157 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
146 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
158 | + if ($filter_name == '') { |
|
159 | + $filter_name = $this->filter_name; |
|
160 | + } |
|
147 | 161 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
148 | 162 | try { |
149 | 163 | $sth = $this->db->prepare($query); |
@@ -158,10 +172,15 @@ discard block |
||
158 | 172 | |
159 | 173 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
160 | 174 | global $globalStatsFilters; |
161 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
175 | + if ($filter_name == '') { |
|
176 | + $filter_name = $this->filter_name; |
|
177 | + } |
|
162 | 178 | if ($year == '' && $month == '') { |
163 | - 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"; |
|
164 | - 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"; |
|
179 | + if ($limit) { |
|
180 | + $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"; |
|
181 | + } else { |
|
182 | + $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"; |
|
183 | + } |
|
165 | 184 | try { |
166 | 185 | $sth = $this->db->prepare($query); |
167 | 186 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -169,7 +188,9 @@ discard block |
||
169 | 188 | echo "error : ".$e->getMessage(); |
170 | 189 | } |
171 | 190 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
172 | - } else $all = array(); |
|
191 | + } else { |
|
192 | + $all = array(); |
|
193 | + } |
|
173 | 194 | if (empty($all)) { |
174 | 195 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
175 | 196 | if ($filter_name != '') { |
@@ -183,10 +204,15 @@ discard block |
||
183 | 204 | } |
184 | 205 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
185 | 206 | global $globalStatsFilters; |
186 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
207 | + if ($filter_name == '') { |
|
208 | + $filter_name = $this->filter_name; |
|
209 | + } |
|
187 | 210 | if ($year == '' && $month == '') { |
188 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
189 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
211 | + if ($limit) { |
|
212 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
213 | + } else { |
|
214 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
215 | + } |
|
190 | 216 | try { |
191 | 217 | $sth = $this->db->prepare($query); |
192 | 218 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -194,7 +220,9 @@ discard block |
||
194 | 220 | echo "error : ".$e->getMessage(); |
195 | 221 | } |
196 | 222 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
197 | - } else $all = array(); |
|
223 | + } else { |
|
224 | + $all = array(); |
|
225 | + } |
|
198 | 226 | if (empty($all)) { |
199 | 227 | $Spotter = new Spotter($this->db); |
200 | 228 | $filters = array(); |
@@ -209,10 +237,15 @@ discard block |
||
209 | 237 | } |
210 | 238 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
211 | 239 | global $globalStatsFilters; |
212 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
240 | + if ($filter_name == '') { |
|
241 | + $filter_name = $this->filter_name; |
|
242 | + } |
|
213 | 243 | if ($year == '' && $month == '') { |
214 | - 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"; |
|
215 | - 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"; |
|
244 | + if ($limit) { |
|
245 | + $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"; |
|
246 | + } else { |
|
247 | + $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"; |
|
248 | + } |
|
216 | 249 | try { |
217 | 250 | $sth = $this->db->prepare($query); |
218 | 251 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -220,7 +253,9 @@ discard block |
||
220 | 253 | echo "error : ".$e->getMessage(); |
221 | 254 | } |
222 | 255 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
223 | - } else $all = array(); |
|
256 | + } else { |
|
257 | + $all = array(); |
|
258 | + } |
|
224 | 259 | if (empty($all)) { |
225 | 260 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
226 | 261 | if ($filter_name != '') { |
@@ -235,10 +270,15 @@ discard block |
||
235 | 270 | |
236 | 271 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
237 | 272 | global $globalStatsFilters; |
238 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
273 | + if ($filter_name == '') { |
|
274 | + $filter_name = $this->filter_name; |
|
275 | + } |
|
239 | 276 | if ($year == '' && $month == '') { |
240 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
241 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
277 | + if ($limit) { |
|
278 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
279 | + } else { |
|
280 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
281 | + } |
|
242 | 282 | try { |
243 | 283 | $sth = $this->db->prepare($query); |
244 | 284 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -246,7 +286,9 @@ discard block |
||
246 | 286 | echo "error : ".$e->getMessage(); |
247 | 287 | } |
248 | 288 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
249 | - } else $all = array(); |
|
289 | + } else { |
|
290 | + $all = array(); |
|
291 | + } |
|
250 | 292 | if (empty($all)) { |
251 | 293 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
252 | 294 | if ($filter_name != '') { |
@@ -260,9 +302,14 @@ discard block |
||
260 | 302 | } |
261 | 303 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
262 | 304 | global $globalStatsFilters; |
263 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
264 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
265 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
305 | + if ($filter_name == '') { |
|
306 | + $filter_name = $this->filter_name; |
|
307 | + } |
|
308 | + if ($limit) { |
|
309 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
310 | + } else { |
|
311 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
312 | + } |
|
266 | 313 | try { |
267 | 314 | $sth = $this->db->prepare($query); |
268 | 315 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -284,17 +331,29 @@ discard block |
||
284 | 331 | |
285 | 332 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
286 | 333 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
287 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
334 | + if ($filter_name == '') { |
|
335 | + $filter_name = $this->filter_name; |
|
336 | + } |
|
288 | 337 | if ($year == '' && $month == '') { |
289 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
290 | - if ($globalIVAO) $forsource = 'ivao'; |
|
338 | + if ($globalVATSIM) { |
|
339 | + $forsource = 'vatsim'; |
|
340 | + } |
|
341 | + if ($globalIVAO) { |
|
342 | + $forsource = 'ivao'; |
|
343 | + } |
|
291 | 344 | if (isset($forsource)) { |
292 | - 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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
293 | - 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 AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
345 | + if ($limit) { |
|
346 | + $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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
347 | + } else { |
|
348 | + $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 AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
349 | + } |
|
294 | 350 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
295 | 351 | } else { |
296 | - 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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
297 | - 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 AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
352 | + if ($limit) { |
|
353 | + $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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
354 | + } else { |
|
355 | + $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 AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
356 | + } |
|
298 | 357 | $query_values = array(':filter_name' => $filter_name); |
299 | 358 | } |
300 | 359 | try { |
@@ -304,7 +363,9 @@ discard block |
||
304 | 363 | echo "error : ".$e->getMessage(); |
305 | 364 | } |
306 | 365 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
307 | - } else $all = array(); |
|
366 | + } else { |
|
367 | + $all = array(); |
|
368 | + } |
|
308 | 369 | if (empty($all)) { |
309 | 370 | $Spotter = new Spotter($this->db); |
310 | 371 | $filters = array(); |
@@ -319,10 +380,15 @@ discard block |
||
319 | 380 | } |
320 | 381 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
321 | 382 | global $globalStatsFilters; |
322 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
383 | + if ($filter_name == '') { |
|
384 | + $filter_name = $this->filter_name; |
|
385 | + } |
|
323 | 386 | if ($year == '' && $month == '') { |
324 | - 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"; |
|
325 | - 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"; |
|
387 | + if ($limit) { |
|
388 | + $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"; |
|
389 | + } else { |
|
390 | + $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"; |
|
391 | + } |
|
326 | 392 | try { |
327 | 393 | $sth = $this->db->prepare($query); |
328 | 394 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -330,7 +396,9 @@ discard block |
||
330 | 396 | echo "error : ".$e->getMessage(); |
331 | 397 | } |
332 | 398 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
333 | - } else $all = array(); |
|
399 | + } else { |
|
400 | + $all = array(); |
|
401 | + } |
|
334 | 402 | if (empty($all)) { |
335 | 403 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
336 | 404 | if ($filter_name != '') { |
@@ -344,10 +412,15 @@ discard block |
||
344 | 412 | } |
345 | 413 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
346 | 414 | global $globalStatsFilters; |
347 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
415 | + if ($filter_name == '') { |
|
416 | + $filter_name = $this->filter_name; |
|
417 | + } |
|
348 | 418 | if ($year == '' && $month == '') { |
349 | - 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"; |
|
350 | - 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"; |
|
419 | + if ($limit) { |
|
420 | + $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"; |
|
421 | + } else { |
|
422 | + $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"; |
|
423 | + } |
|
351 | 424 | try { |
352 | 425 | $sth = $this->db->prepare($query); |
353 | 426 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -355,7 +428,9 @@ discard block |
||
355 | 428 | echo "error : ".$e->getMessage(); |
356 | 429 | } |
357 | 430 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
358 | - } else $all = array(); |
|
431 | + } else { |
|
432 | + $all = array(); |
|
433 | + } |
|
359 | 434 | if (empty($all)) { |
360 | 435 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
361 | 436 | if ($filter_name != '') { |
@@ -369,11 +444,16 @@ discard block |
||
369 | 444 | } |
370 | 445 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
371 | 446 | $Connection = new Connection(); |
372 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
447 | + if ($filter_name == '') { |
|
448 | + $filter_name = $this->filter_name; |
|
449 | + } |
|
373 | 450 | if ($Connection->tableExists('countries')) { |
374 | 451 | if ($year == '' && $month == '') { |
375 | - 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"; |
|
376 | - 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"; |
|
452 | + if ($limit) { |
|
453 | + $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"; |
|
454 | + } else { |
|
455 | + $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"; |
|
456 | + } |
|
377 | 457 | try { |
378 | 458 | $sth = $this->db->prepare($query); |
379 | 459 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -388,17 +468,24 @@ discard block |
||
388 | 468 | } |
389 | 469 | */ |
390 | 470 | return $all; |
391 | - } else return array(); |
|
471 | + } else { |
|
472 | + return array(); |
|
473 | + } |
|
392 | 474 | } else { |
393 | 475 | return array(); |
394 | 476 | } |
395 | 477 | } |
396 | 478 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
397 | 479 | global $globalStatsFilters; |
398 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
480 | + if ($filter_name == '') { |
|
481 | + $filter_name = $this->filter_name; |
|
482 | + } |
|
399 | 483 | if ($year == '' && $month == '') { |
400 | - 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"; |
|
401 | - 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"; |
|
484 | + if ($limit) { |
|
485 | + $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"; |
|
486 | + } else { |
|
487 | + $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"; |
|
488 | + } |
|
402 | 489 | try { |
403 | 490 | $sth = $this->db->prepare($query); |
404 | 491 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -406,7 +493,9 @@ discard block |
||
406 | 493 | echo "error : ".$e->getMessage(); |
407 | 494 | } |
408 | 495 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
409 | - } else $all = array(); |
|
496 | + } else { |
|
497 | + $all = array(); |
|
498 | + } |
|
410 | 499 | if (empty($all)) { |
411 | 500 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
412 | 501 | if ($filter_name != '') { |
@@ -421,10 +510,15 @@ discard block |
||
421 | 510 | |
422 | 511 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
423 | 512 | global $globalStatsFilters; |
424 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
513 | + if ($filter_name == '') { |
|
514 | + $filter_name = $this->filter_name; |
|
515 | + } |
|
425 | 516 | if ($year == '' && $month == '') { |
426 | - 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"; |
|
427 | - 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"; |
|
517 | + if ($limit) { |
|
518 | + $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"; |
|
519 | + } else { |
|
520 | + $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"; |
|
521 | + } |
|
428 | 522 | try { |
429 | 523 | $sth = $this->db->prepare($query); |
430 | 524 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -432,7 +526,9 @@ discard block |
||
432 | 526 | echo "error : ".$e->getMessage(); |
433 | 527 | } |
434 | 528 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
435 | - } else $all = array(); |
|
529 | + } else { |
|
530 | + $all = array(); |
|
531 | + } |
|
436 | 532 | if (empty($all)) { |
437 | 533 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
438 | 534 | if ($filter_name != '') { |
@@ -446,10 +542,15 @@ discard block |
||
446 | 542 | } |
447 | 543 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
448 | 544 | global $globalStatsFilters; |
449 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
545 | + if ($filter_name == '') { |
|
546 | + $filter_name = $this->filter_name; |
|
547 | + } |
|
450 | 548 | if ($year == '' && $month == '') { |
451 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
452 | - 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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
549 | + if ($limit) { |
|
550 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
551 | + } else { |
|
552 | + $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, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
553 | + } |
|
453 | 554 | try { |
454 | 555 | $sth = $this->db->prepare($query); |
455 | 556 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -457,7 +558,9 @@ discard block |
||
457 | 558 | echo "error : ".$e->getMessage(); |
458 | 559 | } |
459 | 560 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
460 | - } else $all = array(); |
|
561 | + } else { |
|
562 | + $all = array(); |
|
563 | + } |
|
461 | 564 | if (empty($all)) { |
462 | 565 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
463 | 566 | if ($filter_name != '') { |
@@ -478,7 +581,9 @@ discard block |
||
478 | 581 | $icao = $value['airport_departure_icao']; |
479 | 582 | if (isset($all[$icao])) { |
480 | 583 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
481 | - } else $all[$icao] = $value; |
|
584 | + } else { |
|
585 | + $all[$icao] = $value; |
|
586 | + } |
|
482 | 587 | } |
483 | 588 | $count = array(); |
484 | 589 | foreach ($all as $key => $row) { |
@@ -490,10 +595,15 @@ discard block |
||
490 | 595 | } |
491 | 596 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
492 | 597 | global $globalStatsFilters; |
493 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
598 | + if ($filter_name == '') { |
|
599 | + $filter_name = $this->filter_name; |
|
600 | + } |
|
494 | 601 | if ($year == '' && $month == '') { |
495 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
496 | - 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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
602 | + if ($limit) { |
|
603 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND 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"; |
|
604 | + } else { |
|
605 | + $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, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
606 | + } |
|
497 | 607 | try { |
498 | 608 | $sth = $this->db->prepare($query); |
499 | 609 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -501,7 +611,9 @@ discard block |
||
501 | 611 | echo "error : ".$e->getMessage(); |
502 | 612 | } |
503 | 613 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
504 | - } else $all = array(); |
|
614 | + } else { |
|
615 | + $all = array(); |
|
616 | + } |
|
505 | 617 | if (empty($all)) { |
506 | 618 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
507 | 619 | if ($filter_name != '') { |
@@ -522,7 +634,9 @@ discard block |
||
522 | 634 | $icao = $value['airport_arrival_icao']; |
523 | 635 | if (isset($all[$icao])) { |
524 | 636 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
525 | - } else $all[$icao] = $value; |
|
637 | + } else { |
|
638 | + $all[$icao] = $value; |
|
639 | + } |
|
526 | 640 | } |
527 | 641 | $count = array(); |
528 | 642 | foreach ($all as $key => $row) { |
@@ -535,13 +649,21 @@ discard block |
||
535 | 649 | } |
536 | 650 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
537 | 651 | global $globalDBdriver, $globalStatsFilters; |
538 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
652 | + if ($filter_name == '') { |
|
653 | + $filter_name = $this->filter_name; |
|
654 | + } |
|
539 | 655 | if ($globalDBdriver == 'mysql') { |
540 | - 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"; |
|
541 | - 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"; |
|
656 | + if ($limit) { |
|
657 | + $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"; |
|
658 | + } else { |
|
659 | + $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"; |
|
660 | + } |
|
542 | 661 | } else { |
543 | - 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"; |
|
544 | - 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"; |
|
662 | + if ($limit) { |
|
663 | + $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"; |
|
664 | + } else { |
|
665 | + $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"; |
|
666 | + } |
|
545 | 667 | } |
546 | 668 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
547 | 669 | try { |
@@ -565,7 +687,9 @@ discard block |
||
565 | 687 | |
566 | 688 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
567 | 689 | global $globalStatsFilters; |
568 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
690 | + if ($filter_name == '') { |
|
691 | + $filter_name = $this->filter_name; |
|
692 | + } |
|
569 | 693 | $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"; |
570 | 694 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
571 | 695 | try { |
@@ -587,7 +711,9 @@ discard block |
||
587 | 711 | } |
588 | 712 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
589 | 713 | global $globalDBdriver, $globalStatsFilters; |
590 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
714 | + if ($filter_name == '') { |
|
715 | + $filter_name = $this->filter_name; |
|
716 | + } |
|
591 | 717 | if ($globalDBdriver == 'mysql') { |
592 | 718 | $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"; |
593 | 719 | } else { |
@@ -613,7 +739,9 @@ discard block |
||
613 | 739 | } |
614 | 740 | public function countAllDates($stats_airline = '',$filter_name = '') { |
615 | 741 | global $globalStatsFilters; |
616 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
742 | + if ($filter_name == '') { |
|
743 | + $filter_name = $this->filter_name; |
|
744 | + } |
|
617 | 745 | $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"; |
618 | 746 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
619 | 747 | try { |
@@ -635,7 +763,9 @@ discard block |
||
635 | 763 | } |
636 | 764 | public function countAllDatesByAirlines($filter_name = '') { |
637 | 765 | global $globalStatsFilters; |
638 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
766 | + if ($filter_name == '') { |
|
767 | + $filter_name = $this->filter_name; |
|
768 | + } |
|
639 | 769 | $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"; |
640 | 770 | $query_data = array('filter_name' => $filter_name); |
641 | 771 | try { |
@@ -657,7 +787,9 @@ discard block |
||
657 | 787 | } |
658 | 788 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
659 | 789 | global $globalStatsFilters, $globalDBdriver; |
660 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
790 | + if ($filter_name == '') { |
|
791 | + $filter_name = $this->filter_name; |
|
792 | + } |
|
661 | 793 | if ($globalDBdriver == 'mysql') { |
662 | 794 | $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"; |
663 | 795 | } else { |
@@ -726,7 +858,9 @@ discard block |
||
726 | 858 | } |
727 | 859 | public function countAllMilitaryMonths($filter_name = '') { |
728 | 860 | global $globalStatsFilters; |
729 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
861 | + if ($filter_name == '') { |
|
862 | + $filter_name = $this->filter_name; |
|
863 | + } |
|
730 | 864 | $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"; |
731 | 865 | try { |
732 | 866 | $sth = $this->db->prepare($query); |
@@ -747,9 +881,14 @@ discard block |
||
747 | 881 | } |
748 | 882 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
749 | 883 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
750 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
751 | - 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"; |
|
752 | - 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"; |
|
884 | + if ($filter_name == '') { |
|
885 | + $filter_name = $this->filter_name; |
|
886 | + } |
|
887 | + if ($limit) { |
|
888 | + $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"; |
|
889 | + } else { |
|
890 | + $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"; |
|
891 | + } |
|
753 | 892 | if ($orderby == 'hour') { |
754 | 893 | if ($globalDBdriver == 'mysql') { |
755 | 894 | //$query .= " ORDER BY flight_date ASC"; |
@@ -758,7 +897,9 @@ discard block |
||
758 | 897 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
759 | 898 | } |
760 | 899 | } |
761 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
900 | + if ($orderby == 'count') { |
|
901 | + $query .= " ORDER BY hour_count DESC"; |
|
902 | + } |
|
762 | 903 | try { |
763 | 904 | $sth = $this->db->prepare($query); |
764 | 905 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -779,8 +920,12 @@ discard block |
||
779 | 920 | |
780 | 921 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
781 | 922 | global $globalStatsFilters; |
782 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
783 | - if ($year == '') $year = date('Y'); |
|
923 | + if ($filter_name == '') { |
|
924 | + $filter_name = $this->filter_name; |
|
925 | + } |
|
926 | + if ($year == '') { |
|
927 | + $year = date('Y'); |
|
928 | + } |
|
784 | 929 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
785 | 930 | if (empty($all)) { |
786 | 931 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
@@ -795,8 +940,12 @@ discard block |
||
795 | 940 | } |
796 | 941 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
797 | 942 | global $globalStatsFilters; |
798 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
799 | - if ($year == '') $year = date('Y'); |
|
943 | + if ($filter_name == '') { |
|
944 | + $filter_name = $this->filter_name; |
|
945 | + } |
|
946 | + if ($year == '') { |
|
947 | + $year = date('Y'); |
|
948 | + } |
|
800 | 949 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
801 | 950 | if (empty($all)) { |
802 | 951 | $filters = array(); |
@@ -812,8 +961,12 @@ discard block |
||
812 | 961 | } |
813 | 962 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
814 | 963 | global $globalStatsFilters; |
815 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
816 | - if ($year == '') $year = date('Y'); |
|
964 | + if ($filter_name == '') { |
|
965 | + $filter_name = $this->filter_name; |
|
966 | + } |
|
967 | + if ($year == '') { |
|
968 | + $year = date('Y'); |
|
969 | + } |
|
817 | 970 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
818 | 971 | if (empty($all)) { |
819 | 972 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
@@ -828,7 +981,9 @@ discard block |
||
828 | 981 | } |
829 | 982 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
830 | 983 | global $globalStatsFilters; |
831 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
984 | + if ($filter_name == '') { |
|
985 | + $filter_name = $this->filter_name; |
|
986 | + } |
|
832 | 987 | if ($year == '' && $month == '') { |
833 | 988 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
834 | 989 | try { |
@@ -839,7 +994,9 @@ discard block |
||
839 | 994 | } |
840 | 995 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
841 | 996 | $all = $result[0]['nb']; |
842 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
997 | + } else { |
|
998 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
999 | + } |
|
843 | 1000 | if (empty($all)) { |
844 | 1001 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
845 | 1002 | if ($filter_name != '') { |
@@ -853,7 +1010,9 @@ discard block |
||
853 | 1010 | } |
854 | 1011 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
855 | 1012 | global $globalStatsFilters; |
856 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1013 | + if ($filter_name == '') { |
|
1014 | + $filter_name = $this->filter_name; |
|
1015 | + } |
|
857 | 1016 | if ($year == '' && $month == '') { |
858 | 1017 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
859 | 1018 | try { |
@@ -864,7 +1023,9 @@ discard block |
||
864 | 1023 | } |
865 | 1024 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
866 | 1025 | $all = $result[0]['nb_airline']; |
867 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1026 | + } else { |
|
1027 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1028 | + } |
|
868 | 1029 | if (empty($all)) { |
869 | 1030 | $filters = array(); |
870 | 1031 | $filters = array('year' => $year,'month' => $month); |
@@ -879,7 +1040,9 @@ discard block |
||
879 | 1040 | } |
880 | 1041 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
881 | 1042 | global $globalStatsFilters; |
882 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1043 | + if ($filter_name == '') { |
|
1044 | + $filter_name = $this->filter_name; |
|
1045 | + } |
|
883 | 1046 | if ($year == '' && $month == '') { |
884 | 1047 | $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
885 | 1048 | $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
@@ -907,7 +1070,9 @@ discard block |
||
907 | 1070 | } |
908 | 1071 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
909 | 1072 | global $globalStatsFilters; |
910 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1073 | + if ($filter_name == '') { |
|
1074 | + $filter_name = $this->filter_name; |
|
1075 | + } |
|
911 | 1076 | //if ($year == '') $year = date('Y'); |
912 | 1077 | if ($year == '' && $month == '') { |
913 | 1078 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -936,7 +1101,9 @@ discard block |
||
936 | 1101 | } |
937 | 1102 | |
938 | 1103 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
939 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1104 | + if ($filter_name == '') { |
|
1105 | + $filter_name = $this->filter_name; |
|
1106 | + } |
|
940 | 1107 | $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"; |
941 | 1108 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
942 | 1109 | try { |
@@ -949,7 +1116,9 @@ discard block |
||
949 | 1116 | return $all; |
950 | 1117 | } |
951 | 1118 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
952 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1119 | + if ($filter_name == '') { |
|
1120 | + $filter_name = $this->filter_name; |
|
1121 | + } |
|
953 | 1122 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
954 | 1123 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
955 | 1124 | try { |
@@ -962,7 +1131,9 @@ discard block |
||
962 | 1131 | return $all; |
963 | 1132 | } |
964 | 1133 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
965 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1134 | + if ($filter_name == '') { |
|
1135 | + $filter_name = $this->filter_name; |
|
1136 | + } |
|
966 | 1137 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
967 | 1138 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
968 | 1139 | try { |
@@ -973,7 +1144,9 @@ discard block |
||
973 | 1144 | } |
974 | 1145 | } |
975 | 1146 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
976 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1147 | + if ($filter_name == '') { |
|
1148 | + $filter_name = $this->filter_name; |
|
1149 | + } |
|
977 | 1150 | global $globalArchiveMonths, $globalDBdriver; |
978 | 1151 | if ($globalDBdriver == 'mysql') { |
979 | 1152 | if ($month == '') { |
@@ -1003,7 +1176,9 @@ discard block |
||
1003 | 1176 | } |
1004 | 1177 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
1005 | 1178 | global $globalArchiveMonths, $globalDBdriver; |
1006 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1179 | + if ($filter_name == '') { |
|
1180 | + $filter_name = $this->filter_name; |
|
1181 | + } |
|
1007 | 1182 | if ($globalDBdriver == 'mysql') { |
1008 | 1183 | $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"; |
1009 | 1184 | } else { |
@@ -1021,7 +1196,9 @@ discard block |
||
1021 | 1196 | } |
1022 | 1197 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
1023 | 1198 | global $globalArchiveMonths, $globalDBdriver; |
1024 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1199 | + if ($filter_name == '') { |
|
1200 | + $filter_name = $this->filter_name; |
|
1201 | + } |
|
1025 | 1202 | if ($globalDBdriver == 'mysql') { |
1026 | 1203 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
1027 | 1204 | } else { |
@@ -1038,7 +1215,9 @@ discard block |
||
1038 | 1215 | } |
1039 | 1216 | public function getStatsAirlineTotal($filter_name = '') { |
1040 | 1217 | global $globalArchiveMonths, $globalDBdriver; |
1041 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1218 | + if ($filter_name == '') { |
|
1219 | + $filter_name = $this->filter_name; |
|
1220 | + } |
|
1042 | 1221 | if ($globalDBdriver == 'mysql') { |
1043 | 1222 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
1044 | 1223 | } else { |
@@ -1055,7 +1234,9 @@ discard block |
||
1055 | 1234 | } |
1056 | 1235 | public function getStatsOwnerTotal($filter_name = '') { |
1057 | 1236 | global $globalArchiveMonths, $globalDBdriver; |
1058 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1237 | + if ($filter_name == '') { |
|
1238 | + $filter_name = $this->filter_name; |
|
1239 | + } |
|
1059 | 1240 | if ($globalDBdriver == 'mysql') { |
1060 | 1241 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1061 | 1242 | } else { |
@@ -1072,7 +1253,9 @@ discard block |
||
1072 | 1253 | } |
1073 | 1254 | public function getStatsOwner($owner_name,$filter_name = '') { |
1074 | 1255 | global $globalArchiveMonths, $globalDBdriver; |
1075 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1256 | + if ($filter_name == '') { |
|
1257 | + $filter_name = $this->filter_name; |
|
1258 | + } |
|
1076 | 1259 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1077 | 1260 | try { |
1078 | 1261 | $sth = $this->db->prepare($query); |
@@ -1081,12 +1264,17 @@ discard block |
||
1081 | 1264 | echo "error : ".$e->getMessage(); |
1082 | 1265 | } |
1083 | 1266 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1084 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1085 | - else return 0; |
|
1267 | + if (isset($all[0]['cnt'])) { |
|
1268 | + return $all[0]['cnt']; |
|
1269 | + } else { |
|
1270 | + return 0; |
|
1271 | + } |
|
1086 | 1272 | } |
1087 | 1273 | public function getStatsPilotTotal($filter_name = '') { |
1088 | 1274 | global $globalArchiveMonths, $globalDBdriver; |
1089 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1275 | + if ($filter_name == '') { |
|
1276 | + $filter_name = $this->filter_name; |
|
1277 | + } |
|
1090 | 1278 | if ($globalDBdriver == 'mysql') { |
1091 | 1279 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
1092 | 1280 | } else { |
@@ -1103,7 +1291,9 @@ discard block |
||
1103 | 1291 | } |
1104 | 1292 | public function getStatsPilot($pilot,$filter_name = '') { |
1105 | 1293 | global $globalArchiveMonths, $globalDBdriver; |
1106 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1294 | + if ($filter_name == '') { |
|
1295 | + $filter_name = $this->filter_name; |
|
1296 | + } |
|
1107 | 1297 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1108 | 1298 | try { |
1109 | 1299 | $sth = $this->db->prepare($query); |
@@ -1112,13 +1302,18 @@ discard block |
||
1112 | 1302 | echo "error : ".$e->getMessage(); |
1113 | 1303 | } |
1114 | 1304 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1115 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1116 | - else return 0; |
|
1305 | + if (isset($all[0]['cnt'])) { |
|
1306 | + return $all[0]['cnt']; |
|
1307 | + } else { |
|
1308 | + return 0; |
|
1309 | + } |
|
1117 | 1310 | } |
1118 | 1311 | |
1119 | 1312 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1120 | 1313 | global $globalDBdriver; |
1121 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1314 | + if ($filter_name == '') { |
|
1315 | + $filter_name = $this->filter_name; |
|
1316 | + } |
|
1122 | 1317 | if ($globalDBdriver == 'mysql') { |
1123 | 1318 | $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"; |
1124 | 1319 | } else { |
@@ -1134,7 +1329,9 @@ discard block |
||
1134 | 1329 | } |
1135 | 1330 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1136 | 1331 | global $globalDBdriver; |
1137 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1332 | + if ($filter_name == '') { |
|
1333 | + $filter_name = $this->filter_name; |
|
1334 | + } |
|
1138 | 1335 | if ($globalDBdriver == 'mysql') { |
1139 | 1336 | $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"; |
1140 | 1337 | } else { |
@@ -1520,10 +1717,14 @@ discard block |
||
1520 | 1717 | $Connection = new Connection(); |
1521 | 1718 | date_default_timezone_set('UTC'); |
1522 | 1719 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
1523 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1720 | + if ($globalDebug) { |
|
1721 | + echo 'Update stats !'."\n"; |
|
1722 | + } |
|
1524 | 1723 | if (isset($last_update[0]['value'])) { |
1525 | 1724 | $last_update_day = $last_update[0]['value']; |
1526 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1725 | + } else { |
|
1726 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1727 | + } |
|
1527 | 1728 | $reset = false; |
1528 | 1729 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
1529 | 1730 | if ($globalStatsResetYear) { |
@@ -1532,42 +1733,60 @@ discard block |
||
1532 | 1733 | } |
1533 | 1734 | $Spotter = new Spotter($this->db); |
1534 | 1735 | |
1535 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1736 | + if ($globalDebug) { |
|
1737 | + echo 'Count all aircraft types...'."\n"; |
|
1738 | + } |
|
1536 | 1739 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1537 | 1740 | foreach ($alldata as $number) { |
1538 | 1741 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
1539 | 1742 | } |
1540 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1743 | + if ($globalDebug) { |
|
1744 | + echo 'Count all airlines...'."\n"; |
|
1745 | + } |
|
1541 | 1746 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1542 | 1747 | foreach ($alldata as $number) { |
1543 | 1748 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
1544 | 1749 | } |
1545 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1750 | + if ($globalDebug) { |
|
1751 | + echo 'Count all registrations...'."\n"; |
|
1752 | + } |
|
1546 | 1753 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1547 | 1754 | foreach ($alldata as $number) { |
1548 | 1755 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
1549 | 1756 | } |
1550 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1757 | + if ($globalDebug) { |
|
1758 | + echo 'Count all callsigns...'."\n"; |
|
1759 | + } |
|
1551 | 1760 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1552 | 1761 | foreach ($alldata as $number) { |
1553 | 1762 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1554 | 1763 | } |
1555 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1764 | + if ($globalDebug) { |
|
1765 | + echo 'Count all owners...'."\n"; |
|
1766 | + } |
|
1556 | 1767 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1557 | 1768 | foreach ($alldata as $number) { |
1558 | 1769 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
1559 | 1770 | } |
1560 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1771 | + if ($globalDebug) { |
|
1772 | + echo 'Count all pilots...'."\n"; |
|
1773 | + } |
|
1561 | 1774 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1562 | 1775 | foreach ($alldata as $number) { |
1563 | 1776 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
1564 | 1777 | } |
1565 | 1778 | |
1566 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1779 | + if ($globalDebug) { |
|
1780 | + echo 'Count all departure airports...'."\n"; |
|
1781 | + } |
|
1567 | 1782 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1568 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1783 | + if ($globalDebug) { |
|
1784 | + echo 'Count all detected departure airports...'."\n"; |
|
1785 | + } |
|
1569 | 1786 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1570 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1787 | + if ($globalDebug) { |
|
1788 | + echo 'Order departure airports...'."\n"; |
|
1789 | + } |
|
1571 | 1790 | $alldata = array(); |
1572 | 1791 | |
1573 | 1792 | foreach ($pall as $value) { |
@@ -1578,7 +1797,9 @@ discard block |
||
1578 | 1797 | $icao = $value['airport_departure_icao']; |
1579 | 1798 | if (isset($alldata[$icao])) { |
1580 | 1799 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1581 | - } else $alldata[$icao] = $value; |
|
1800 | + } else { |
|
1801 | + $alldata[$icao] = $value; |
|
1802 | + } |
|
1582 | 1803 | } |
1583 | 1804 | $count = array(); |
1584 | 1805 | foreach ($alldata as $key => $row) { |
@@ -1588,11 +1809,17 @@ discard block |
||
1588 | 1809 | foreach ($alldata as $number) { |
1589 | 1810 | 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); |
1590 | 1811 | } |
1591 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1812 | + if ($globalDebug) { |
|
1813 | + echo 'Count all arrival airports...'."\n"; |
|
1814 | + } |
|
1592 | 1815 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1593 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1816 | + if ($globalDebug) { |
|
1817 | + echo 'Count all detected arrival airports...'."\n"; |
|
1818 | + } |
|
1594 | 1819 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1595 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1820 | + if ($globalDebug) { |
|
1821 | + echo 'Order arrival airports...'."\n"; |
|
1822 | + } |
|
1596 | 1823 | $alldata = array(); |
1597 | 1824 | foreach ($pall as $value) { |
1598 | 1825 | $icao = $value['airport_arrival_icao']; |
@@ -1602,7 +1829,9 @@ discard block |
||
1602 | 1829 | $icao = $value['airport_arrival_icao']; |
1603 | 1830 | if (isset($alldata[$icao])) { |
1604 | 1831 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1605 | - } else $alldata[$icao] = $value; |
|
1832 | + } else { |
|
1833 | + $alldata[$icao] = $value; |
|
1834 | + } |
|
1606 | 1835 | } |
1607 | 1836 | $count = array(); |
1608 | 1837 | foreach ($alldata as $key => $row) { |
@@ -1613,7 +1842,9 @@ discard block |
||
1613 | 1842 | 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); |
1614 | 1843 | } |
1615 | 1844 | if ($Connection->tableExists('countries')) { |
1616 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1845 | + if ($globalDebug) { |
|
1846 | + echo 'Count all flights by countries...'."\n"; |
|
1847 | + } |
|
1617 | 1848 | $SpotterArchive = new SpotterArchive(); |
1618 | 1849 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1619 | 1850 | foreach ($alldata as $number) { |
@@ -1621,7 +1852,9 @@ discard block |
||
1621 | 1852 | } |
1622 | 1853 | } |
1623 | 1854 | |
1624 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
1855 | + if ($globalDebug) { |
|
1856 | + echo 'Count fatalities stats...'."\n"; |
|
1857 | + } |
|
1625 | 1858 | $Accident = new Accident(); |
1626 | 1859 | $this->deleteStatsByType('fatalities_byyear'); |
1627 | 1860 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -1638,46 +1871,66 @@ discard block |
||
1638 | 1871 | // Add by month using getstat if month finish... |
1639 | 1872 | |
1640 | 1873 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1641 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1874 | + if ($globalDebug) { |
|
1875 | + echo 'Count all flights by months...'."\n"; |
|
1876 | + } |
|
1642 | 1877 | $Spotter = new Spotter($this->db); |
1643 | 1878 | $alldata = $Spotter->countAllMonths(); |
1644 | 1879 | $lastyear = false; |
1645 | 1880 | foreach ($alldata as $number) { |
1646 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1881 | + if ($number['year_name'] != date('Y')) { |
|
1882 | + $lastyear = true; |
|
1883 | + } |
|
1647 | 1884 | $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']))); |
1648 | 1885 | } |
1649 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1886 | + if ($globalDebug) { |
|
1887 | + echo 'Count all military flights by months...'."\n"; |
|
1888 | + } |
|
1650 | 1889 | $alldata = $Spotter->countAllMilitaryMonths(); |
1651 | 1890 | foreach ($alldata as $number) { |
1652 | 1891 | $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']))); |
1653 | 1892 | } |
1654 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1893 | + if ($globalDebug) { |
|
1894 | + echo 'Count all owners by months...'."\n"; |
|
1895 | + } |
|
1655 | 1896 | $alldata = $Spotter->countAllMonthsOwners(); |
1656 | 1897 | foreach ($alldata as $number) { |
1657 | 1898 | $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']))); |
1658 | 1899 | } |
1659 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1900 | + if ($globalDebug) { |
|
1901 | + echo 'Count all pilots by months...'."\n"; |
|
1902 | + } |
|
1660 | 1903 | $alldata = $Spotter->countAllMonthsPilots(); |
1661 | 1904 | foreach ($alldata as $number) { |
1662 | 1905 | $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']))); |
1663 | 1906 | } |
1664 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1907 | + if ($globalDebug) { |
|
1908 | + echo 'Count all airlines by months...'."\n"; |
|
1909 | + } |
|
1665 | 1910 | $alldata = $Spotter->countAllMonthsAirlines(); |
1666 | 1911 | foreach ($alldata as $number) { |
1667 | 1912 | $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']))); |
1668 | 1913 | } |
1669 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1914 | + if ($globalDebug) { |
|
1915 | + echo 'Count all aircrafts by months...'."\n"; |
|
1916 | + } |
|
1670 | 1917 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1671 | 1918 | foreach ($alldata as $number) { |
1672 | 1919 | $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']))); |
1673 | 1920 | } |
1674 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1921 | + if ($globalDebug) { |
|
1922 | + echo 'Count all real arrivals by months...'."\n"; |
|
1923 | + } |
|
1675 | 1924 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1676 | 1925 | foreach ($alldata as $number) { |
1677 | 1926 | $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']))); |
1678 | 1927 | } |
1679 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1680 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1928 | + if ($globalDebug) { |
|
1929 | + echo 'Airports data...'."\n"; |
|
1930 | + } |
|
1931 | + if ($globalDebug) { |
|
1932 | + echo '...Departure'."\n"; |
|
1933 | + } |
|
1681 | 1934 | $this->deleteStatAirport('daily'); |
1682 | 1935 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1683 | 1936 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1798,44 +2051,62 @@ discard block |
||
1798 | 2051 | // Count by airlines |
1799 | 2052 | echo '--- Stats by airlines ---'."\n"; |
1800 | 2053 | if ($Connection->tableExists('countries')) { |
1801 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
2054 | + if ($globalDebug) { |
|
2055 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
2056 | + } |
|
1802 | 2057 | $SpotterArchive = new SpotterArchive(); |
1803 | 2058 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
1804 | 2059 | foreach ($alldata as $number) { |
1805 | 2060 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
1806 | 2061 | } |
1807 | 2062 | } |
1808 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
2063 | + if ($globalDebug) { |
|
2064 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
2065 | + } |
|
1809 | 2066 | $Spotter = new Spotter($this->db); |
1810 | 2067 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1811 | 2068 | foreach ($alldata as $number) { |
1812 | 2069 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
1813 | 2070 | } |
1814 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
2071 | + if ($globalDebug) { |
|
2072 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
2073 | + } |
|
1815 | 2074 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1816 | 2075 | foreach ($alldata as $number) { |
1817 | 2076 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
1818 | 2077 | } |
1819 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
2078 | + if ($globalDebug) { |
|
2079 | + echo 'Count all callsigns by airlines...'."\n"; |
|
2080 | + } |
|
1820 | 2081 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1821 | 2082 | foreach ($alldata as $number) { |
1822 | 2083 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1823 | 2084 | } |
1824 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
2085 | + if ($globalDebug) { |
|
2086 | + echo 'Count all owners by airlines...'."\n"; |
|
2087 | + } |
|
1825 | 2088 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1826 | 2089 | foreach ($alldata as $number) { |
1827 | 2090 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
1828 | 2091 | } |
1829 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
2092 | + if ($globalDebug) { |
|
2093 | + echo 'Count all pilots by airlines...'."\n"; |
|
2094 | + } |
|
1830 | 2095 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1831 | 2096 | foreach ($alldata as $number) { |
1832 | 2097 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
1833 | 2098 | } |
1834 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
2099 | + if ($globalDebug) { |
|
2100 | + echo 'Count all departure airports by airlines...'."\n"; |
|
2101 | + } |
|
1835 | 2102 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1836 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
2103 | + if ($globalDebug) { |
|
2104 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
2105 | + } |
|
1837 | 2106 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1838 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
2107 | + if ($globalDebug) { |
|
2108 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
2109 | + } |
|
1839 | 2110 | //$alldata = array(); |
1840 | 2111 | foreach ($dall as $value) { |
1841 | 2112 | $icao = $value['airport_departure_icao']; |
@@ -1856,11 +2127,17 @@ discard block |
||
1856 | 2127 | foreach ($alldata as $number) { |
1857 | 2128 | 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); |
1858 | 2129 | } |
1859 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
2130 | + if ($globalDebug) { |
|
2131 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
2132 | + } |
|
1860 | 2133 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1861 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2134 | + if ($globalDebug) { |
|
2135 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2136 | + } |
|
1862 | 2137 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1863 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
2138 | + if ($globalDebug) { |
|
2139 | + echo 'Order arrival airports by airlines...'."\n"; |
|
2140 | + } |
|
1864 | 2141 | //$alldata = array(); |
1865 | 2142 | foreach ($dall as $value) { |
1866 | 2143 | $icao = $value['airport_arrival_icao']; |
@@ -1879,37 +2156,53 @@ discard block |
||
1879 | 2156 | } |
1880 | 2157 | $alldata = $pall; |
1881 | 2158 | foreach ($alldata as $number) { |
1882 | - 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); |
|
2159 | + if ($number['airline_icao'] != '') { |
|
2160 | + 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); |
|
2161 | + } |
|
2162 | + } |
|
2163 | + if ($globalDebug) { |
|
2164 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1883 | 2165 | } |
1884 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1885 | 2166 | $Spotter = new Spotter($this->db); |
1886 | 2167 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1887 | 2168 | $lastyear = false; |
1888 | 2169 | foreach ($alldata as $number) { |
1889 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2170 | + if ($number['year_name'] != date('Y')) { |
|
2171 | + $lastyear = true; |
|
2172 | + } |
|
1890 | 2173 | $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']); |
1891 | 2174 | } |
1892 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
2175 | + if ($globalDebug) { |
|
2176 | + echo 'Count all owners by months by airlines...'."\n"; |
|
2177 | + } |
|
1893 | 2178 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1894 | 2179 | foreach ($alldata as $number) { |
1895 | 2180 | $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']); |
1896 | 2181 | } |
1897 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
2182 | + if ($globalDebug) { |
|
2183 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
2184 | + } |
|
1898 | 2185 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1899 | 2186 | foreach ($alldata as $number) { |
1900 | 2187 | $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']); |
1901 | 2188 | } |
1902 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2189 | + if ($globalDebug) { |
|
2190 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2191 | + } |
|
1903 | 2192 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1904 | 2193 | foreach ($alldata as $number) { |
1905 | 2194 | $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']); |
1906 | 2195 | } |
1907 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2196 | + if ($globalDebug) { |
|
2197 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2198 | + } |
|
1908 | 2199 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1909 | 2200 | foreach ($alldata as $number) { |
1910 | 2201 | $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']); |
1911 | 2202 | } |
1912 | - if ($globalDebug) echo '...Departure'."\n"; |
|
2203 | + if ($globalDebug) { |
|
2204 | + echo '...Departure'."\n"; |
|
2205 | + } |
|
1913 | 2206 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1914 | 2207 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1915 | 2208 | foreach ($dall as $value) { |
@@ -1932,7 +2225,9 @@ discard block |
||
1932 | 2225 | foreach ($alldata as $number) { |
1933 | 2226 | $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']); |
1934 | 2227 | } |
1935 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
2228 | + if ($globalDebug) { |
|
2229 | + echo '...Arrival'."\n"; |
|
2230 | + } |
|
1936 | 2231 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1937 | 2232 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1938 | 2233 | foreach ($dall as $value) { |
@@ -1956,13 +2251,19 @@ discard block |
||
1956 | 2251 | $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']); |
1957 | 2252 | } |
1958 | 2253 | |
1959 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1960 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2254 | + if ($globalDebug) { |
|
2255 | + echo 'Flights data...'."\n"; |
|
2256 | + } |
|
2257 | + if ($globalDebug) { |
|
2258 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2259 | + } |
|
1961 | 2260 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1962 | 2261 | foreach ($alldata as $number) { |
1963 | 2262 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1964 | 2263 | } |
1965 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2264 | + if ($globalDebug) { |
|
2265 | + echo '-> countAllDates...'."\n"; |
|
2266 | + } |
|
1966 | 2267 | //$previousdata = $this->countAllDatesByAirlines(); |
1967 | 2268 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1968 | 2269 | $values = array(); |
@@ -1975,7 +2276,9 @@ discard block |
||
1975 | 2276 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1976 | 2277 | } |
1977 | 2278 | |
1978 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2279 | + if ($globalDebug) { |
|
2280 | + echo '-> countAllHours...'."\n"; |
|
2281 | + } |
|
1979 | 2282 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1980 | 2283 | foreach ($alldata as $number) { |
1981 | 2284 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
@@ -1983,14 +2286,18 @@ discard block |
||
1983 | 2286 | |
1984 | 2287 | |
1985 | 2288 | // Stats by filters |
1986 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2289 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2290 | + $globalStatsFilters = array(); |
|
2291 | + } |
|
1987 | 2292 | foreach ($globalStatsFilters as $name => $filter) { |
1988 | 2293 | //$filter_name = $filter['name']; |
1989 | 2294 | $filter_name = $name; |
1990 | 2295 | $reset = false; |
1991 | 2296 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
1992 | 2297 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
1993 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
2298 | + if ($globalDebug) { |
|
2299 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
2300 | + } |
|
1994 | 2301 | $this->deleteOldStats($filter_name); |
1995 | 2302 | unset($last_update); |
1996 | 2303 | } |
@@ -2009,7 +2316,9 @@ discard block |
||
2009 | 2316 | |
2010 | 2317 | |
2011 | 2318 | // Count by filter |
2012 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2319 | + if ($globalDebug) { |
|
2320 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2321 | + } |
|
2013 | 2322 | $Spotter = new Spotter($this->db); |
2014 | 2323 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
2015 | 2324 | foreach ($alldata as $number) { |
@@ -2046,7 +2355,9 @@ discard block |
||
2046 | 2355 | $icao = $value['airport_departure_icao']; |
2047 | 2356 | if (isset($alldata[$icao])) { |
2048 | 2357 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
2049 | - } else $alldata[$icao] = $value; |
|
2358 | + } else { |
|
2359 | + $alldata[$icao] = $value; |
|
2360 | + } |
|
2050 | 2361 | } |
2051 | 2362 | $count = array(); |
2052 | 2363 | foreach ($alldata as $key => $row) { |
@@ -2067,7 +2378,9 @@ discard block |
||
2067 | 2378 | $icao = $value['airport_arrival_icao']; |
2068 | 2379 | if (isset($alldata[$icao])) { |
2069 | 2380 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
2070 | - } else $alldata[$icao] = $value; |
|
2381 | + } else { |
|
2382 | + $alldata[$icao] = $value; |
|
2383 | + } |
|
2071 | 2384 | } |
2072 | 2385 | $count = array(); |
2073 | 2386 | foreach ($alldata as $key => $row) { |
@@ -2081,7 +2394,9 @@ discard block |
||
2081 | 2394 | $alldata = $Spotter->countAllMonths($filter); |
2082 | 2395 | $lastyear = false; |
2083 | 2396 | foreach ($alldata as $number) { |
2084 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2397 | + if ($number['year_name'] != date('Y')) { |
|
2398 | + $lastyear = true; |
|
2399 | + } |
|
2085 | 2400 | $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); |
2086 | 2401 | } |
2087 | 2402 | $alldata = $Spotter->countAllMonthsOwners($filter); |