@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug; |
56 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
56 | + if ($globalDebug) { |
|
57 | + echo "Update last seen tracked data...\n"; |
|
58 | + } |
|
57 | 59 | foreach ($this->all_tracked as $key => $flight) { |
58 | 60 | if (isset($this->all_tracked[$key]['id'])) { |
59 | 61 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -66,13 +68,17 @@ discard block |
||
66 | 68 | public function del() { |
67 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
68 | 70 | // Delete old infos |
69 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
71 | + if ($globalDebug) { |
|
72 | + echo 'Delete old values and update latest data...'."\n"; |
|
73 | + } |
|
70 | 74 | foreach ($this->all_tracked as $key => $flight) { |
71 | 75 | if (isset($flight['lastupdate'])) { |
72 | 76 | if ($flight['lastupdate'] < (time()-3000)) { |
73 | 77 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
74 | 78 | if (isset($this->all_tracked[$key]['id'])) { |
75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
79 | + if ($globalDebug) { |
|
80 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + } |
|
76 | 82 | /* |
77 | 83 | $MarineLive = new MarineLive(); |
78 | 84 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -82,7 +88,9 @@ discard block |
||
82 | 88 | $Marine = new Marine($this->db); |
83 | 89 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
84 | 90 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
85 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
91 | + if ($globalDebug && $result != 'success') { |
|
92 | + echo '!!! ERROR : '.$result."\n"; |
|
93 | + } |
|
86 | 94 | } |
87 | 95 | // Put in archive |
88 | 96 | // $Marine->db = null; |
@@ -96,7 +104,9 @@ discard block |
||
96 | 104 | |
97 | 105 | public function add($line) { |
98 | 106 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
99 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
107 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
108 | + $globalCoordMinChange = '0.02'; |
|
109 | + } |
|
100 | 110 | date_default_timezone_set('UTC'); |
101 | 111 | $dataFound = false; |
102 | 112 | $send = false; |
@@ -110,20 +120,30 @@ discard block |
||
110 | 120 | // Increment message number |
111 | 121 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
112 | 122 | $current_date = date('Y-m-d'); |
113 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
114 | - else $source = ''; |
|
115 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
123 | + if (isset($line['source_name'])) { |
|
124 | + $source = $line['source_name']; |
|
125 | + } else { |
|
126 | + $source = ''; |
|
127 | + } |
|
128 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
129 | + $source = $line['format_source']; |
|
130 | + } |
|
116 | 131 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
117 | 132 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
118 | 133 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
119 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
134 | + } else { |
|
135 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } |
|
120 | 137 | } |
121 | 138 | |
122 | 139 | |
123 | 140 | $Common = new Common(); |
124 | 141 | $AIS = new AIS(); |
125 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
126 | - else $id = trim($line['id']); |
|
142 | + if (!isset($line['id'])) { |
|
143 | + $id = trim($line['mmsi']); |
|
144 | + } else { |
|
145 | + $id = trim($line['id']); |
|
146 | + } |
|
127 | 147 | |
128 | 148 | if (!isset($this->all_tracked[$id])) { |
129 | 149 | $this->all_tracked[$id] = array(); |
@@ -131,10 +151,16 @@ discard block |
||
131 | 151 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
132 | 152 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
133 | 153 | if (!isset($line['id'])) { |
134 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
154 | + if (!isset($globalDaemon)) { |
|
155 | + $globalDaemon = TRUE; |
|
156 | + } |
|
135 | 157 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
136 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
158 | + } else { |
|
159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
160 | + } |
|
161 | + if ($globalAllTracked !== FALSE) { |
|
162 | + $dataFound = true; |
|
163 | + } |
|
138 | 164 | } |
139 | 165 | |
140 | 166 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -184,34 +210,49 @@ discard block |
||
184 | 210 | $Marine = new Marine($this->db); |
185 | 211 | $fromsource = NULL; |
186 | 212 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
187 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
213 | + if ($globalDebug && $result != 'success') { |
|
214 | + echo '!!! ERROR : '.$result."\n"; |
|
215 | + } |
|
188 | 216 | $Marine->db = null; |
189 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
217 | + if ($globalDebugTimeElapsed) { |
|
218 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
219 | + } |
|
190 | 220 | } |
191 | 221 | } |
192 | 222 | } |
193 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
223 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
225 | + } |
|
194 | 226 | } |
195 | 227 | |
196 | 228 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
197 | 229 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
198 | 230 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
199 | 231 | } else { |
200 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
201 | - 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"; |
|
232 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
233 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
234 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
235 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
236 | + } |
|
202 | 237 | return ''; |
203 | 238 | } |
204 | 239 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
205 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
240 | + if ($globalDebug) { |
|
241 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
242 | + } |
|
206 | 243 | return ''; |
207 | 244 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
208 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
245 | + if ($globalDebug) { |
|
246 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
247 | + } |
|
209 | 248 | return ''; |
210 | 249 | } elseif (!isset($line['datetime'])) { |
211 | 250 | date_default_timezone_set('UTC'); |
212 | 251 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
213 | 252 | } else { |
214 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
253 | + if ($globalDebug) { |
|
254 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
255 | + } |
|
215 | 256 | return ''; |
216 | 257 | } |
217 | 258 | |
@@ -224,14 +265,21 @@ discard block |
||
224 | 265 | if ($distance > 1000 && $distance < 10000) { |
225 | 266 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
226 | 267 | $speed = $speed*3.6; |
227 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
228 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
268 | + if ($speed < 1000) { |
|
269 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
270 | + } |
|
271 | + if ($globalDebug) { |
|
272 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
273 | + } |
|
229 | 274 | } |
230 | 275 | } |
231 | 276 | |
232 | 277 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
233 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
234 | - else unset($timediff); |
|
278 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
279 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
280 | + } else { |
|
281 | + unset($timediff); |
|
282 | + } |
|
235 | 283 | 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')))) { |
236 | 284 | 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'])) { |
237 | 285 | 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'])) { |
@@ -239,22 +287,32 @@ discard block |
||
239 | 287 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
240 | 288 | $this->all_tracked[$id]['putinarchive'] = true; |
241 | 289 | |
242 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
290 | + if ($globalDebug) { |
|
291 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
292 | + } |
|
243 | 293 | $timeelapsed = microtime(true); |
244 | 294 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
245 | 295 | $Marine = new Marine($this->db); |
246 | 296 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
247 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
297 | + if (!empty($all_country)) { |
|
298 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
299 | + } |
|
248 | 300 | $Marine->db = null; |
249 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
301 | + if ($globalDebugTimeElapsed) { |
|
302 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
303 | + } |
|
250 | 304 | } |
251 | 305 | $this->tmd = 0; |
252 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
306 | + if ($globalDebug) { |
|
307 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
308 | + } |
|
253 | 309 | } |
254 | 310 | } |
255 | 311 | |
256 | 312 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
257 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
313 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
314 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
315 | + } |
|
258 | 316 | 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') { |
259 | 317 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
260 | 318 | $dataFound = true; |
@@ -263,8 +321,12 @@ discard block |
||
263 | 321 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
264 | 322 | } |
265 | 323 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
266 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
267 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
324 | + if ($line['longitude'] > 180) { |
|
325 | + $line['longitude'] = $line['longitude'] - 360; |
|
326 | + } |
|
327 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
328 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
329 | + } |
|
268 | 330 | 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') { |
269 | 331 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
270 | 332 | $dataFound = true; |
@@ -282,7 +344,9 @@ discard block |
||
282 | 344 | } |
283 | 345 | } |
284 | 346 | if (isset($line['last_update']) && $line['last_update'] != '') { |
285 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
347 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
348 | + $dataFound = true; |
|
349 | + } |
|
286 | 350 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
287 | 351 | } |
288 | 352 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -312,15 +376,21 @@ discard block |
||
312 | 376 | } |
313 | 377 | |
314 | 378 | if (isset($line['heading']) && $line['heading'] != '') { |
315 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
379 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
380 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
381 | + } |
|
316 | 382 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
317 | 383 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
318 | 384 | //$dataFound = true; |
319 | 385 | } 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']) { |
320 | 386 | $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']); |
321 | 387 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
322 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
323 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
388 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
389 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
390 | + } |
|
391 | + if ($globalDebug) { |
|
392 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
393 | + } |
|
324 | 394 | } |
325 | 395 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
326 | 396 | |
@@ -332,23 +402,38 @@ discard block |
||
332 | 402 | 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'])) { |
333 | 403 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
334 | 404 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
335 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
405 | + if ($globalDebug) { |
|
406 | + echo "Check if aircraft is already in DB..."; |
|
407 | + } |
|
336 | 408 | $timeelapsed = microtime(true); |
337 | 409 | $MarineLive = new MarineLive($this->db); |
338 | 410 | if (isset($line['id'])) { |
339 | 411 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
340 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
412 | + if ($globalDebugTimeElapsed) { |
|
413 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
414 | + } |
|
341 | 415 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
342 | 416 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
343 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
417 | + if ($globalDebugTimeElapsed) { |
|
418 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
419 | + } |
|
344 | 420 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
345 | 421 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
347 | - } else $recent_ident = ''; |
|
422 | + if ($globalDebugTimeElapsed) { |
|
423 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
424 | + } |
|
425 | + } else { |
|
426 | + $recent_ident = ''; |
|
427 | + } |
|
348 | 428 | $MarineLive->db=null; |
349 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
350 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
351 | - } else $recent_ident = ''; |
|
429 | + if ($globalDebug && $recent_ident == '') { |
|
430 | + echo " Not in DB.\n"; |
|
431 | + } elseif ($globalDebug && $recent_ident != '') { |
|
432 | + echo " Already in DB.\n"; |
|
433 | + } |
|
434 | + } else { |
|
435 | + $recent_ident = ''; |
|
436 | + } |
|
352 | 437 | } else { |
353 | 438 | $recent_ident = ''; |
354 | 439 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -356,30 +441,44 @@ discard block |
||
356 | 441 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
357 | 442 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
358 | 443 | { |
359 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
444 | + if ($globalDebug) { |
|
445 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
446 | + } |
|
360 | 447 | //adds the spotter data for the archive |
361 | 448 | $highlight = ''; |
362 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
449 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
450 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
451 | + } |
|
363 | 452 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
364 | 453 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
365 | 454 | $timeelapsed = microtime(true); |
366 | 455 | $Marine = new Marine($this->db); |
367 | 456 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
368 | 457 | $Marine->db = null; |
369 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
370 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
458 | + if ($globalDebug && isset($result)) { |
|
459 | + echo $result."\n"; |
|
460 | + } |
|
461 | + if ($globalDebugTimeElapsed) { |
|
462 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
463 | + } |
|
371 | 464 | } |
372 | 465 | } |
373 | 466 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
374 | 467 | // Add source stat in DB |
375 | 468 | $Stats = new Stats($this->db); |
376 | 469 | if (!empty($this->stats)) { |
377 | - if ($globalDebug) echo 'Add source stats : '; |
|
470 | + if ($globalDebug) { |
|
471 | + echo 'Add source stats : '; |
|
472 | + } |
|
378 | 473 | foreach($this->stats as $date => $data) { |
379 | 474 | foreach($data as $source => $sourced) { |
380 | 475 | //print_r($sourced); |
381 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
382 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
476 | + if (isset($sourced['polar'])) { |
|
477 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
478 | + } |
|
479 | + if (isset($sourced['hist'])) { |
|
480 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
481 | + } |
|
383 | 482 | if (isset($sourced['msg'])) { |
384 | 483 | if (time() - $sourced['msg']['date'] > 10) { |
385 | 484 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -392,7 +491,9 @@ discard block |
||
392 | 491 | unset($this->stats[$date]); |
393 | 492 | } |
394 | 493 | } |
395 | - if ($globalDebug) echo 'Done'."\n"; |
|
494 | + if ($globalDebug) { |
|
495 | + echo 'Done'."\n"; |
|
496 | + } |
|
396 | 497 | } |
397 | 498 | $Stats->db = null; |
398 | 499 | } |
@@ -402,13 +503,17 @@ discard block |
||
402 | 503 | $this->all_tracked[$id]['addedMarine'] = 1; |
403 | 504 | //print_r($this->all_tracked[$id]); |
404 | 505 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
405 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
506 | + if ($globalDebug) { |
|
507 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
508 | + } |
|
406 | 509 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
407 | 510 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
408 | 511 | $MarineLive = new MarineLive($this->db); |
409 | 512 | $MarineLive->deleteLiveMarineData(); |
410 | 513 | $MarineLive->db=null; |
411 | - if ($globalDebug) echo " Done\n"; |
|
514 | + if ($globalDebug) { |
|
515 | + echo " Done\n"; |
|
516 | + } |
|
412 | 517 | } |
413 | 518 | $this->last_delete = time(); |
414 | 519 | } |
@@ -434,15 +539,21 @@ discard block |
||
434 | 539 | |
435 | 540 | if (!$ignoreImport) { |
436 | 541 | 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'])) { |
437 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
542 | + if ($globalDebug) { |
|
543 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
544 | + } |
|
438 | 545 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
439 | 546 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
440 | 547 | $timeelapsed = microtime(true); |
441 | 548 | $MarineLive = new MarineLive($this->db); |
442 | 549 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
443 | 550 | $MarineLive->db = null; |
444 | - if ($globalDebug) echo $result."\n"; |
|
445 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
551 | + if ($globalDebug) { |
|
552 | + echo $result."\n"; |
|
553 | + } |
|
554 | + if ($globalDebugTimeElapsed) { |
|
555 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
556 | + } |
|
446 | 557 | } |
447 | 558 | } |
448 | 559 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -454,7 +565,9 @@ discard block |
||
454 | 565 | |
455 | 566 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
456 | 567 | $source = $this->all_tracked[$id]['source_name']; |
457 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
568 | + if ($source == '') { |
|
569 | + $source = $this->all_tracked[$id]['format_source']; |
|
570 | + } |
|
458 | 571 | if (!isset($this->source_location[$source])) { |
459 | 572 | $Location = new Source(); |
460 | 573 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -475,7 +588,9 @@ discard block |
||
475 | 588 | $stats_heading = round($stats_heading/22.5); |
476 | 589 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
477 | 590 | $current_date = date('Y-m-d'); |
478 | - if ($stats_heading == 16) $stats_heading = 0; |
|
591 | + if ($stats_heading == 16) { |
|
592 | + $stats_heading = 0; |
|
593 | + } |
|
479 | 594 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
480 | 595 | for ($i=0;$i<=15;$i++) { |
481 | 596 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -493,7 +608,9 @@ discard block |
||
493 | 608 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
494 | 609 | end($this->stats[$current_date][$source]['hist']); |
495 | 610 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
496 | - } else $mini = 0; |
|
611 | + } else { |
|
612 | + $mini = 0; |
|
613 | + } |
|
497 | 614 | for ($i=$mini;$i<=$distance;$i+=10) { |
498 | 615 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
499 | 616 | } |
@@ -505,19 +622,27 @@ discard block |
||
505 | 622 | |
506 | 623 | |
507 | 624 | $this->all_tracked[$id]['lastupdate'] = time(); |
508 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
509 | - } 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"; |
|
625 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
626 | + $send = true; |
|
627 | + } |
|
628 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
629 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
630 | + } |
|
510 | 631 | //$this->del(); |
511 | 632 | |
512 | 633 | |
513 | 634 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
514 | 635 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
515 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
636 | + if ($globalDebug) { |
|
637 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
638 | + } |
|
516 | 639 | $MarineLive = new MarineLive($this->db); |
517 | 640 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
518 | 641 | $MarineLive->db = null; |
519 | 642 | //MarineLive->deleteLiveMarineData(); |
520 | - if ($globalDebug) echo " Done\n"; |
|
643 | + if ($globalDebug) { |
|
644 | + echo " Done\n"; |
|
645 | + } |
|
521 | 646 | } |
522 | 647 | $this->last_delete_hourly = time(); |
523 | 648 | } |
@@ -526,7 +651,9 @@ discard block |
||
526 | 651 | //$ignoreImport = false; |
527 | 652 | } |
528 | 653 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
529 | - if ($send) return $this->all_tracked[$id]; |
|
654 | + if ($send) { |
|
655 | + return $this->all_tracked[$id]; |
|
656 | + } |
|
530 | 657 | } |
531 | 658 | } |
532 | 659 | } |
@@ -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 ORDER BY date_count DESC"; |
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 ORDER BY date_count DESC"; |
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,43 +1733,63 @@ 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 | - if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
|
1776 | + if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') { |
|
1777 | + $number['pilot_id'] = $number['pilot_name']; |
|
1778 | + } |
|
1564 | 1779 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
1565 | 1780 | } |
1566 | 1781 | |
1567 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1782 | + if ($globalDebug) { |
|
1783 | + echo 'Count all departure airports...'."\n"; |
|
1784 | + } |
|
1568 | 1785 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1569 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1786 | + if ($globalDebug) { |
|
1787 | + echo 'Count all detected departure airports...'."\n"; |
|
1788 | + } |
|
1570 | 1789 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1571 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1790 | + if ($globalDebug) { |
|
1791 | + echo 'Order departure airports...'."\n"; |
|
1792 | + } |
|
1572 | 1793 | $alldata = array(); |
1573 | 1794 | |
1574 | 1795 | foreach ($pall as $value) { |
@@ -1579,7 +1800,9 @@ discard block |
||
1579 | 1800 | $icao = $value['airport_departure_icao']; |
1580 | 1801 | if (isset($alldata[$icao])) { |
1581 | 1802 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1582 | - } else $alldata[$icao] = $value; |
|
1803 | + } else { |
|
1804 | + $alldata[$icao] = $value; |
|
1805 | + } |
|
1583 | 1806 | } |
1584 | 1807 | $count = array(); |
1585 | 1808 | foreach ($alldata as $key => $row) { |
@@ -1589,11 +1812,17 @@ discard block |
||
1589 | 1812 | foreach ($alldata as $number) { |
1590 | 1813 | 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); |
1591 | 1814 | } |
1592 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1815 | + if ($globalDebug) { |
|
1816 | + echo 'Count all arrival airports...'."\n"; |
|
1817 | + } |
|
1593 | 1818 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1594 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1819 | + if ($globalDebug) { |
|
1820 | + echo 'Count all detected arrival airports...'."\n"; |
|
1821 | + } |
|
1595 | 1822 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1596 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1823 | + if ($globalDebug) { |
|
1824 | + echo 'Order arrival airports...'."\n"; |
|
1825 | + } |
|
1597 | 1826 | $alldata = array(); |
1598 | 1827 | foreach ($pall as $value) { |
1599 | 1828 | $icao = $value['airport_arrival_icao']; |
@@ -1603,7 +1832,9 @@ discard block |
||
1603 | 1832 | $icao = $value['airport_arrival_icao']; |
1604 | 1833 | if (isset($alldata[$icao])) { |
1605 | 1834 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1606 | - } else $alldata[$icao] = $value; |
|
1835 | + } else { |
|
1836 | + $alldata[$icao] = $value; |
|
1837 | + } |
|
1607 | 1838 | } |
1608 | 1839 | $count = array(); |
1609 | 1840 | foreach ($alldata as $key => $row) { |
@@ -1614,7 +1845,9 @@ discard block |
||
1614 | 1845 | 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); |
1615 | 1846 | } |
1616 | 1847 | if ($Connection->tableExists('countries')) { |
1617 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1848 | + if ($globalDebug) { |
|
1849 | + echo 'Count all flights by countries...'."\n"; |
|
1850 | + } |
|
1618 | 1851 | //$SpotterArchive = new SpotterArchive(); |
1619 | 1852 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1620 | 1853 | $Spotter = new Spotter($this->db); |
@@ -1624,7 +1857,9 @@ discard block |
||
1624 | 1857 | } |
1625 | 1858 | } |
1626 | 1859 | |
1627 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
1860 | + if ($globalDebug) { |
|
1861 | + echo 'Count fatalities stats...'."\n"; |
|
1862 | + } |
|
1628 | 1863 | $Accident = new Accident(); |
1629 | 1864 | $this->deleteStatsByType('fatalities_byyear'); |
1630 | 1865 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -1641,46 +1876,66 @@ discard block |
||
1641 | 1876 | // Add by month using getstat if month finish... |
1642 | 1877 | |
1643 | 1878 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1644 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1879 | + if ($globalDebug) { |
|
1880 | + echo 'Count all flights by months...'."\n"; |
|
1881 | + } |
|
1645 | 1882 | $Spotter = new Spotter($this->db); |
1646 | 1883 | $alldata = $Spotter->countAllMonths(); |
1647 | 1884 | $lastyear = false; |
1648 | 1885 | foreach ($alldata as $number) { |
1649 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1886 | + if ($number['year_name'] != date('Y')) { |
|
1887 | + $lastyear = true; |
|
1888 | + } |
|
1650 | 1889 | $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']))); |
1651 | 1890 | } |
1652 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1891 | + if ($globalDebug) { |
|
1892 | + echo 'Count all military flights by months...'."\n"; |
|
1893 | + } |
|
1653 | 1894 | $alldata = $Spotter->countAllMilitaryMonths(); |
1654 | 1895 | foreach ($alldata as $number) { |
1655 | 1896 | $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']))); |
1656 | 1897 | } |
1657 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1898 | + if ($globalDebug) { |
|
1899 | + echo 'Count all owners by months...'."\n"; |
|
1900 | + } |
|
1658 | 1901 | $alldata = $Spotter->countAllMonthsOwners(); |
1659 | 1902 | foreach ($alldata as $number) { |
1660 | 1903 | $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']))); |
1661 | 1904 | } |
1662 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1905 | + if ($globalDebug) { |
|
1906 | + echo 'Count all pilots by months...'."\n"; |
|
1907 | + } |
|
1663 | 1908 | $alldata = $Spotter->countAllMonthsPilots(); |
1664 | 1909 | foreach ($alldata as $number) { |
1665 | 1910 | $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']))); |
1666 | 1911 | } |
1667 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1912 | + if ($globalDebug) { |
|
1913 | + echo 'Count all airlines by months...'."\n"; |
|
1914 | + } |
|
1668 | 1915 | $alldata = $Spotter->countAllMonthsAirlines(); |
1669 | 1916 | foreach ($alldata as $number) { |
1670 | 1917 | $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']))); |
1671 | 1918 | } |
1672 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1919 | + if ($globalDebug) { |
|
1920 | + echo 'Count all aircrafts by months...'."\n"; |
|
1921 | + } |
|
1673 | 1922 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1674 | 1923 | foreach ($alldata as $number) { |
1675 | 1924 | $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']))); |
1676 | 1925 | } |
1677 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1926 | + if ($globalDebug) { |
|
1927 | + echo 'Count all real arrivals by months...'."\n"; |
|
1928 | + } |
|
1678 | 1929 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1679 | 1930 | foreach ($alldata as $number) { |
1680 | 1931 | $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']))); |
1681 | 1932 | } |
1682 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1683 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1933 | + if ($globalDebug) { |
|
1934 | + echo 'Airports data...'."\n"; |
|
1935 | + } |
|
1936 | + if ($globalDebug) { |
|
1937 | + echo '...Departure'."\n"; |
|
1938 | + } |
|
1684 | 1939 | $this->deleteStatAirport('daily'); |
1685 | 1940 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1686 | 1941 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1801,7 +2056,9 @@ discard block |
||
1801 | 2056 | // Count by airlines |
1802 | 2057 | echo '--- Stats by airlines ---'."\n"; |
1803 | 2058 | if ($Connection->tableExists('countries')) { |
1804 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
2059 | + if ($globalDebug) { |
|
2060 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
2061 | + } |
|
1805 | 2062 | $SpotterArchive = new SpotterArchive(); |
1806 | 2063 | //$Spotter = new Spotter($this->db); |
1807 | 2064 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
@@ -1810,37 +2067,53 @@ discard block |
||
1810 | 2067 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
1811 | 2068 | } |
1812 | 2069 | } |
1813 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
2070 | + if ($globalDebug) { |
|
2071 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
2072 | + } |
|
1814 | 2073 | $Spotter = new Spotter($this->db); |
1815 | 2074 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1816 | 2075 | foreach ($alldata as $number) { |
1817 | 2076 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
1818 | 2077 | } |
1819 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
2078 | + if ($globalDebug) { |
|
2079 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
2080 | + } |
|
1820 | 2081 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1821 | 2082 | foreach ($alldata as $number) { |
1822 | 2083 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
1823 | 2084 | } |
1824 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
2085 | + if ($globalDebug) { |
|
2086 | + echo 'Count all callsigns by airlines...'."\n"; |
|
2087 | + } |
|
1825 | 2088 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1826 | 2089 | foreach ($alldata as $number) { |
1827 | 2090 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1828 | 2091 | } |
1829 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
2092 | + if ($globalDebug) { |
|
2093 | + echo 'Count all owners by airlines...'."\n"; |
|
2094 | + } |
|
1830 | 2095 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1831 | 2096 | foreach ($alldata as $number) { |
1832 | 2097 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
1833 | 2098 | } |
1834 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
2099 | + if ($globalDebug) { |
|
2100 | + echo 'Count all pilots by airlines...'."\n"; |
|
2101 | + } |
|
1835 | 2102 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1836 | 2103 | foreach ($alldata as $number) { |
1837 | 2104 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
1838 | 2105 | } |
1839 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
2106 | + if ($globalDebug) { |
|
2107 | + echo 'Count all departure airports by airlines...'."\n"; |
|
2108 | + } |
|
1840 | 2109 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1841 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
2110 | + if ($globalDebug) { |
|
2111 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
2112 | + } |
|
1842 | 2113 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1843 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
2114 | + if ($globalDebug) { |
|
2115 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
2116 | + } |
|
1844 | 2117 | //$alldata = array(); |
1845 | 2118 | foreach ($dall as $value) { |
1846 | 2119 | $icao = $value['airport_departure_icao']; |
@@ -1861,11 +2134,17 @@ discard block |
||
1861 | 2134 | foreach ($alldata as $number) { |
1862 | 2135 | 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); |
1863 | 2136 | } |
1864 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
2137 | + if ($globalDebug) { |
|
2138 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
2139 | + } |
|
1865 | 2140 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1866 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2141 | + if ($globalDebug) { |
|
2142 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2143 | + } |
|
1867 | 2144 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1868 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
2145 | + if ($globalDebug) { |
|
2146 | + echo 'Order arrival airports by airlines...'."\n"; |
|
2147 | + } |
|
1869 | 2148 | //$alldata = array(); |
1870 | 2149 | foreach ($dall as $value) { |
1871 | 2150 | $icao = $value['airport_arrival_icao']; |
@@ -1884,37 +2163,53 @@ discard block |
||
1884 | 2163 | } |
1885 | 2164 | $alldata = $pall; |
1886 | 2165 | foreach ($alldata as $number) { |
1887 | - 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); |
|
2166 | + if ($number['airline_icao'] != '') { |
|
2167 | + 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); |
|
2168 | + } |
|
2169 | + } |
|
2170 | + if ($globalDebug) { |
|
2171 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1888 | 2172 | } |
1889 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1890 | 2173 | $Spotter = new Spotter($this->db); |
1891 | 2174 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1892 | 2175 | $lastyear = false; |
1893 | 2176 | foreach ($alldata as $number) { |
1894 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2177 | + if ($number['year_name'] != date('Y')) { |
|
2178 | + $lastyear = true; |
|
2179 | + } |
|
1895 | 2180 | $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']); |
1896 | 2181 | } |
1897 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
2182 | + if ($globalDebug) { |
|
2183 | + echo 'Count all owners by months by airlines...'."\n"; |
|
2184 | + } |
|
1898 | 2185 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1899 | 2186 | foreach ($alldata as $number) { |
1900 | 2187 | $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']); |
1901 | 2188 | } |
1902 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
2189 | + if ($globalDebug) { |
|
2190 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
2191 | + } |
|
1903 | 2192 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1904 | 2193 | foreach ($alldata as $number) { |
1905 | 2194 | $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']); |
1906 | 2195 | } |
1907 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2196 | + if ($globalDebug) { |
|
2197 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2198 | + } |
|
1908 | 2199 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1909 | 2200 | foreach ($alldata as $number) { |
1910 | 2201 | $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']); |
1911 | 2202 | } |
1912 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2203 | + if ($globalDebug) { |
|
2204 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2205 | + } |
|
1913 | 2206 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1914 | 2207 | foreach ($alldata as $number) { |
1915 | 2208 | $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']); |
1916 | 2209 | } |
1917 | - if ($globalDebug) echo '...Departure'."\n"; |
|
2210 | + if ($globalDebug) { |
|
2211 | + echo '...Departure'."\n"; |
|
2212 | + } |
|
1918 | 2213 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1919 | 2214 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1920 | 2215 | foreach ($dall as $value) { |
@@ -1937,7 +2232,9 @@ discard block |
||
1937 | 2232 | foreach ($alldata as $number) { |
1938 | 2233 | $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']); |
1939 | 2234 | } |
1940 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
2235 | + if ($globalDebug) { |
|
2236 | + echo '...Arrival'."\n"; |
|
2237 | + } |
|
1941 | 2238 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1942 | 2239 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1943 | 2240 | foreach ($dall as $value) { |
@@ -1961,13 +2258,19 @@ discard block |
||
1961 | 2258 | $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']); |
1962 | 2259 | } |
1963 | 2260 | |
1964 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1965 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2261 | + if ($globalDebug) { |
|
2262 | + echo 'Flights data...'."\n"; |
|
2263 | + } |
|
2264 | + if ($globalDebug) { |
|
2265 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2266 | + } |
|
1966 | 2267 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1967 | 2268 | foreach ($alldata as $number) { |
1968 | 2269 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1969 | 2270 | } |
1970 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2271 | + if ($globalDebug) { |
|
2272 | + echo '-> countAllDates...'."\n"; |
|
2273 | + } |
|
1971 | 2274 | //$previousdata = $this->countAllDatesByAirlines(); |
1972 | 2275 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1973 | 2276 | $values = array(); |
@@ -1980,7 +2283,9 @@ discard block |
||
1980 | 2283 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1981 | 2284 | } |
1982 | 2285 | |
1983 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2286 | + if ($globalDebug) { |
|
2287 | + echo '-> countAllHours...'."\n"; |
|
2288 | + } |
|
1984 | 2289 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1985 | 2290 | foreach ($alldata as $number) { |
1986 | 2291 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
@@ -1988,14 +2293,18 @@ discard block |
||
1988 | 2293 | |
1989 | 2294 | |
1990 | 2295 | // Stats by filters |
1991 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2296 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2297 | + $globalStatsFilters = array(); |
|
2298 | + } |
|
1992 | 2299 | foreach ($globalStatsFilters as $name => $filter) { |
1993 | 2300 | //$filter_name = $filter['name']; |
1994 | 2301 | $filter_name = $name; |
1995 | 2302 | $reset = false; |
1996 | 2303 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
1997 | 2304 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
1998 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
2305 | + if ($globalDebug) { |
|
2306 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
2307 | + } |
|
1999 | 2308 | $this->deleteOldStats($filter_name); |
2000 | 2309 | unset($last_update); |
2001 | 2310 | } |
@@ -2014,7 +2323,9 @@ discard block |
||
2014 | 2323 | |
2015 | 2324 | |
2016 | 2325 | // Count by filter |
2017 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2326 | + if ($globalDebug) { |
|
2327 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2328 | + } |
|
2018 | 2329 | $Spotter = new Spotter($this->db); |
2019 | 2330 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
2020 | 2331 | foreach ($alldata as $number) { |
@@ -2051,7 +2362,9 @@ discard block |
||
2051 | 2362 | $icao = $value['airport_departure_icao']; |
2052 | 2363 | if (isset($alldata[$icao])) { |
2053 | 2364 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
2054 | - } else $alldata[$icao] = $value; |
|
2365 | + } else { |
|
2366 | + $alldata[$icao] = $value; |
|
2367 | + } |
|
2055 | 2368 | } |
2056 | 2369 | $count = array(); |
2057 | 2370 | foreach ($alldata as $key => $row) { |
@@ -2072,7 +2385,9 @@ discard block |
||
2072 | 2385 | $icao = $value['airport_arrival_icao']; |
2073 | 2386 | if (isset($alldata[$icao])) { |
2074 | 2387 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
2075 | - } else $alldata[$icao] = $value; |
|
2388 | + } else { |
|
2389 | + $alldata[$icao] = $value; |
|
2390 | + } |
|
2076 | 2391 | } |
2077 | 2392 | $count = array(); |
2078 | 2393 | foreach ($alldata as $key => $row) { |
@@ -2086,7 +2401,9 @@ discard block |
||
2086 | 2401 | $alldata = $Spotter->countAllMonths($filter); |
2087 | 2402 | $lastyear = false; |
2088 | 2403 | foreach ($alldata as $number) { |
2089 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2404 | + if ($number['year_name'] != date('Y')) { |
|
2405 | + $lastyear = true; |
|
2406 | + } |
|
2090 | 2407 | $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); |
2091 | 2408 | } |
2092 | 2409 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -804,12 +856,16 @@ discard block |
||
804 | 856 | if ($globalDBdriver == 'mysql') { |
805 | 857 | if (!$Connection->tableExists('tle')) { |
806 | 858 | $error .= create_db::import_file('../db/tle.sql'); |
807 | - if ($error != '') return $error; |
|
859 | + if ($error != '') { |
|
860 | + return $error; |
|
861 | + } |
|
808 | 862 | } |
809 | 863 | } else { |
810 | 864 | if (!$Connection->tableExists('tle')) { |
811 | 865 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
812 | - if ($error != '') return $error; |
|
866 | + if ($error != '') { |
|
867 | + return $error; |
|
868 | + } |
|
813 | 869 | } |
814 | 870 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
815 | 871 | try { |
@@ -849,7 +905,9 @@ discard block |
||
849 | 905 | } else { |
850 | 906 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 907 | } |
852 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
908 | + if ($error != '') { |
|
909 | + return 'Import airlines.sql : '.$error; |
|
910 | + } |
|
853 | 911 | if (!$Connection->checkColumnName('airlines','forsource')) { |
854 | 912 | // Add forsource to airlines |
855 | 913 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1332,20 +1390,28 @@ discard block |
||
1332 | 1390 | } |
1333 | 1391 | if ($globalDBdriver == 'mysql') { |
1334 | 1392 | $error .= create_db::import_file('../db/airlines.sql'); |
1335 | - if ($error != '') return $error; |
|
1393 | + if ($error != '') { |
|
1394 | + return $error; |
|
1395 | + } |
|
1336 | 1396 | } else { |
1337 | 1397 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
1338 | - if ($error != '') return $error; |
|
1398 | + if ($error != '') { |
|
1399 | + return $error; |
|
1400 | + } |
|
1339 | 1401 | } |
1340 | 1402 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
1341 | 1403 | include_once(dirname(__FILE__).'/class.update_db.php'); |
1342 | 1404 | if (isset($globalVATSIM) && $globalVATSIM) { |
1343 | 1405 | $error .= update_db::update_vatsim(); |
1344 | - if ($error != '') return $error; |
|
1406 | + if ($error != '') { |
|
1407 | + return $error; |
|
1408 | + } |
|
1345 | 1409 | } |
1346 | 1410 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
1347 | 1411 | $error .= update_db::update_IVAO(); |
1348 | - if ($error != '') return $error; |
|
1412 | + if ($error != '') { |
|
1413 | + return $error; |
|
1414 | + } |
|
1349 | 1415 | } |
1350 | 1416 | } |
1351 | 1417 | |
@@ -1608,41 +1674,65 @@ discard block |
||
1608 | 1674 | if ($globalDBdriver == 'mysql') { |
1609 | 1675 | if (!$Connection->tableExists('tracker_output')) { |
1610 | 1676 | $error .= create_db::import_file('../db/tracker_output.sql'); |
1611 | - if ($error != '') return $error; |
|
1677 | + if ($error != '') { |
|
1678 | + return $error; |
|
1679 | + } |
|
1612 | 1680 | } |
1613 | 1681 | if (!$Connection->tableExists('tracker_live')) { |
1614 | 1682 | $error .= create_db::import_file('../db/tracker_live.sql'); |
1615 | - if ($error != '') return $error; |
|
1683 | + if ($error != '') { |
|
1684 | + return $error; |
|
1685 | + } |
|
1616 | 1686 | } |
1617 | 1687 | if (!$Connection->tableExists('marine_output')) { |
1618 | 1688 | $error .= create_db::import_file('../db/marine_output.sql'); |
1619 | - if ($error != '') return $error; |
|
1689 | + if ($error != '') { |
|
1690 | + return $error; |
|
1691 | + } |
|
1620 | 1692 | } |
1621 | 1693 | if (!$Connection->tableExists('marine_live')) { |
1622 | 1694 | $error .= create_db::import_file('../db/marine_live.sql'); |
1623 | - if ($error != '') return $error; |
|
1695 | + if ($error != '') { |
|
1696 | + return $error; |
|
1697 | + } |
|
1624 | 1698 | } |
1625 | 1699 | if (!$Connection->tableExists('marine_identity')) { |
1626 | 1700 | $error .= create_db::import_file('../db/marine_identity.sql'); |
1627 | - if ($error != '') return $error; |
|
1701 | + if ($error != '') { |
|
1702 | + return $error; |
|
1703 | + } |
|
1628 | 1704 | } |
1629 | 1705 | if (!$Connection->tableExists('marine_mid')) { |
1630 | 1706 | $error .= create_db::import_file('../db/marine_mid.sql'); |
1631 | - if ($error != '') return $error; |
|
1707 | + if ($error != '') { |
|
1708 | + return $error; |
|
1709 | + } |
|
1632 | 1710 | } |
1633 | 1711 | } else { |
1634 | 1712 | $error .= create_db::import_file('../db/pgsql/tracker_output.sql'); |
1635 | - if ($error != '') return $error; |
|
1713 | + if ($error != '') { |
|
1714 | + return $error; |
|
1715 | + } |
|
1636 | 1716 | $error .= create_db::import_file('../db/pgsql/tracker_live.sql'); |
1637 | - if ($error != '') return $error; |
|
1717 | + if ($error != '') { |
|
1718 | + return $error; |
|
1719 | + } |
|
1638 | 1720 | $error .= create_db::import_file('../db/pgsql/marine_output.sql'); |
1639 | - if ($error != '') return $error; |
|
1721 | + if ($error != '') { |
|
1722 | + return $error; |
|
1723 | + } |
|
1640 | 1724 | $error .= create_db::import_file('../db/pgsql/marine_live.sql'); |
1641 | - if ($error != '') return $error; |
|
1725 | + if ($error != '') { |
|
1726 | + return $error; |
|
1727 | + } |
|
1642 | 1728 | $error .= create_db::import_file('../db/pgsql/marine_identity.sql'); |
1643 | - if ($error != '') return $error; |
|
1729 | + if ($error != '') { |
|
1730 | + return $error; |
|
1731 | + } |
|
1644 | 1732 | $error .= create_db::import_file('../db/pgsql/marine_mid.sql'); |
1645 | - if ($error != '') return $error; |
|
1733 | + if ($error != '') { |
|
1734 | + return $error; |
|
1735 | + } |
|
1646 | 1736 | } |
1647 | 1737 | $query = "UPDATE config SET value = '37' WHERE name = 'schema_version'"; |
1648 | 1738 | try { |
@@ -1661,35 +1751,55 @@ discard block |
||
1661 | 1751 | if ($globalDBdriver == 'mysql') { |
1662 | 1752 | if (!$Connection->tableExists('marine_image')) { |
1663 | 1753 | $error .= create_db::import_file('../db/marine_image.sql'); |
1664 | - if ($error != '') return $error; |
|
1754 | + if ($error != '') { |
|
1755 | + return $error; |
|
1756 | + } |
|
1665 | 1757 | } |
1666 | 1758 | if (!$Connection->tableExists('marine_archive')) { |
1667 | 1759 | $error .= create_db::import_file('../db/marine_archive.sql'); |
1668 | - if ($error != '') return $error; |
|
1760 | + if ($error != '') { |
|
1761 | + return $error; |
|
1762 | + } |
|
1669 | 1763 | } |
1670 | 1764 | if (!$Connection->tableExists('marine_archive_output')) { |
1671 | 1765 | $error .= create_db::import_file('../db/marine_archive_output.sql'); |
1672 | - if ($error != '') return $error; |
|
1766 | + if ($error != '') { |
|
1767 | + return $error; |
|
1768 | + } |
|
1673 | 1769 | } |
1674 | 1770 | if (!$Connection->tableExists('tracker_archive')) { |
1675 | 1771 | $error .= create_db::import_file('../db/tracker_archive.sql'); |
1676 | - if ($error != '') return $error; |
|
1772 | + if ($error != '') { |
|
1773 | + return $error; |
|
1774 | + } |
|
1677 | 1775 | } |
1678 | 1776 | if (!$Connection->tableExists('marine_archive_output')) { |
1679 | 1777 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1680 | - if ($error != '') return $error; |
|
1778 | + if ($error != '') { |
|
1779 | + return $error; |
|
1780 | + } |
|
1681 | 1781 | } |
1682 | 1782 | } else { |
1683 | 1783 | $error .= create_db::import_file('../db/pgsql/marine_image.sql'); |
1684 | - if ($error != '') return $error; |
|
1784 | + if ($error != '') { |
|
1785 | + return $error; |
|
1786 | + } |
|
1685 | 1787 | $error .= create_db::import_file('../db/pgsql/marine_archive.sql'); |
1686 | - if ($error != '') return $error; |
|
1788 | + if ($error != '') { |
|
1789 | + return $error; |
|
1790 | + } |
|
1687 | 1791 | $error .= create_db::import_file('../db/pgsql/marine_archive_output.sql'); |
1688 | - if ($error != '') return $error; |
|
1792 | + if ($error != '') { |
|
1793 | + return $error; |
|
1794 | + } |
|
1689 | 1795 | $error .= create_db::import_file('../db/pgsql/tracker_archive.sql'); |
1690 | - if ($error != '') return $error; |
|
1796 | + if ($error != '') { |
|
1797 | + return $error; |
|
1798 | + } |
|
1691 | 1799 | $error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql'); |
1692 | - if ($error != '') return $error; |
|
1800 | + if ($error != '') { |
|
1801 | + return $error; |
|
1802 | + } |
|
1693 | 1803 | } |
1694 | 1804 | if ($globalDBdriver == 'mysql') { |
1695 | 1805 | $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
@@ -1944,8 +2054,11 @@ discard block |
||
1944 | 2054 | if ($Connection->tableExists('aircraft')) { |
1945 | 2055 | if (!$Connection->tableExists('config')) { |
1946 | 2056 | $version = '1'; |
1947 | - if ($update) return self::update_from_1(); |
|
1948 | - else return $version; |
|
2057 | + if ($update) { |
|
2058 | + return self::update_from_1(); |
|
2059 | + } else { |
|
2060 | + return $version; |
|
2061 | + } |
|
1949 | 2062 | } else { |
1950 | 2063 | $Connection = new Connection(); |
1951 | 2064 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1959,162 +2072,281 @@ discard block |
||
1959 | 2072 | if ($update) { |
1960 | 2073 | if ($result['value'] == '2') { |
1961 | 2074 | $error = self::update_from_2(); |
1962 | - if ($error != '') return $error; |
|
1963 | - else return self::check_version(true); |
|
2075 | + if ($error != '') { |
|
2076 | + return $error; |
|
2077 | + } else { |
|
2078 | + return self::check_version(true); |
|
2079 | + } |
|
1964 | 2080 | } elseif ($result['value'] == '3') { |
1965 | 2081 | $error = self::update_from_3(); |
1966 | - if ($error != '') return $error; |
|
1967 | - else return self::check_version(true); |
|
2082 | + if ($error != '') { |
|
2083 | + return $error; |
|
2084 | + } else { |
|
2085 | + return self::check_version(true); |
|
2086 | + } |
|
1968 | 2087 | } elseif ($result['value'] == '4') { |
1969 | 2088 | $error = self::update_from_4(); |
1970 | - if ($error != '') return $error; |
|
1971 | - else return self::check_version(true); |
|
2089 | + if ($error != '') { |
|
2090 | + return $error; |
|
2091 | + } else { |
|
2092 | + return self::check_version(true); |
|
2093 | + } |
|
1972 | 2094 | } elseif ($result['value'] == '5') { |
1973 | 2095 | $error = self::update_from_5(); |
1974 | - if ($error != '') return $error; |
|
1975 | - else return self::check_version(true); |
|
2096 | + if ($error != '') { |
|
2097 | + return $error; |
|
2098 | + } else { |
|
2099 | + return self::check_version(true); |
|
2100 | + } |
|
1976 | 2101 | } elseif ($result['value'] == '6') { |
1977 | 2102 | $error = self::update_from_6(); |
1978 | - if ($error != '') return $error; |
|
1979 | - else return self::check_version(true); |
|
2103 | + if ($error != '') { |
|
2104 | + return $error; |
|
2105 | + } else { |
|
2106 | + return self::check_version(true); |
|
2107 | + } |
|
1980 | 2108 | } elseif ($result['value'] == '7') { |
1981 | 2109 | $error = self::update_from_7(); |
1982 | - if ($error != '') return $error; |
|
1983 | - else return self::check_version(true); |
|
2110 | + if ($error != '') { |
|
2111 | + return $error; |
|
2112 | + } else { |
|
2113 | + return self::check_version(true); |
|
2114 | + } |
|
1984 | 2115 | } elseif ($result['value'] == '8') { |
1985 | 2116 | $error = self::update_from_8(); |
1986 | - if ($error != '') return $error; |
|
1987 | - else return self::check_version(true); |
|
2117 | + if ($error != '') { |
|
2118 | + return $error; |
|
2119 | + } else { |
|
2120 | + return self::check_version(true); |
|
2121 | + } |
|
1988 | 2122 | } elseif ($result['value'] == '9') { |
1989 | 2123 | $error = self::update_from_9(); |
1990 | - if ($error != '') return $error; |
|
1991 | - else return self::check_version(true); |
|
2124 | + if ($error != '') { |
|
2125 | + return $error; |
|
2126 | + } else { |
|
2127 | + return self::check_version(true); |
|
2128 | + } |
|
1992 | 2129 | } elseif ($result['value'] == '10') { |
1993 | 2130 | $error = self::update_from_10(); |
1994 | - if ($error != '') return $error; |
|
1995 | - else return self::check_version(true); |
|
2131 | + if ($error != '') { |
|
2132 | + return $error; |
|
2133 | + } else { |
|
2134 | + return self::check_version(true); |
|
2135 | + } |
|
1996 | 2136 | } elseif ($result['value'] == '11') { |
1997 | 2137 | $error = self::update_from_11(); |
1998 | - if ($error != '') return $error; |
|
1999 | - else return self::check_version(true); |
|
2138 | + if ($error != '') { |
|
2139 | + return $error; |
|
2140 | + } else { |
|
2141 | + return self::check_version(true); |
|
2142 | + } |
|
2000 | 2143 | } elseif ($result['value'] == '12') { |
2001 | 2144 | $error = self::update_from_12(); |
2002 | - if ($error != '') return $error; |
|
2003 | - else return self::check_version(true); |
|
2145 | + if ($error != '') { |
|
2146 | + return $error; |
|
2147 | + } else { |
|
2148 | + return self::check_version(true); |
|
2149 | + } |
|
2004 | 2150 | } elseif ($result['value'] == '13') { |
2005 | 2151 | $error = self::update_from_13(); |
2006 | - if ($error != '') return $error; |
|
2007 | - else return self::check_version(true); |
|
2152 | + if ($error != '') { |
|
2153 | + return $error; |
|
2154 | + } else { |
|
2155 | + return self::check_version(true); |
|
2156 | + } |
|
2008 | 2157 | } elseif ($result['value'] == '14') { |
2009 | 2158 | $error = self::update_from_14(); |
2010 | - if ($error != '') return $error; |
|
2011 | - else return self::check_version(true); |
|
2159 | + if ($error != '') { |
|
2160 | + return $error; |
|
2161 | + } else { |
|
2162 | + return self::check_version(true); |
|
2163 | + } |
|
2012 | 2164 | } elseif ($result['value'] == '15') { |
2013 | 2165 | $error = self::update_from_15(); |
2014 | - if ($error != '') return $error; |
|
2015 | - else return self::check_version(true); |
|
2166 | + if ($error != '') { |
|
2167 | + return $error; |
|
2168 | + } else { |
|
2169 | + return self::check_version(true); |
|
2170 | + } |
|
2016 | 2171 | } elseif ($result['value'] == '16') { |
2017 | 2172 | $error = self::update_from_16(); |
2018 | - if ($error != '') return $error; |
|
2019 | - else return self::check_version(true); |
|
2173 | + if ($error != '') { |
|
2174 | + return $error; |
|
2175 | + } else { |
|
2176 | + return self::check_version(true); |
|
2177 | + } |
|
2020 | 2178 | } elseif ($result['value'] == '17') { |
2021 | 2179 | $error = self::update_from_17(); |
2022 | - if ($error != '') return $error; |
|
2023 | - else return self::check_version(true); |
|
2180 | + if ($error != '') { |
|
2181 | + return $error; |
|
2182 | + } else { |
|
2183 | + return self::check_version(true); |
|
2184 | + } |
|
2024 | 2185 | } elseif ($result['value'] == '18') { |
2025 | 2186 | $error = self::update_from_18(); |
2026 | - if ($error != '') return $error; |
|
2027 | - else return self::check_version(true); |
|
2187 | + if ($error != '') { |
|
2188 | + return $error; |
|
2189 | + } else { |
|
2190 | + return self::check_version(true); |
|
2191 | + } |
|
2028 | 2192 | } elseif ($result['value'] == '19') { |
2029 | 2193 | $error = self::update_from_19(); |
2030 | - if ($error != '') return $error; |
|
2031 | - else return self::check_version(true); |
|
2194 | + if ($error != '') { |
|
2195 | + return $error; |
|
2196 | + } else { |
|
2197 | + return self::check_version(true); |
|
2198 | + } |
|
2032 | 2199 | } elseif ($result['value'] == '20') { |
2033 | 2200 | $error = self::update_from_20(); |
2034 | - if ($error != '') return $error; |
|
2035 | - else return self::check_version(true); |
|
2201 | + if ($error != '') { |
|
2202 | + return $error; |
|
2203 | + } else { |
|
2204 | + return self::check_version(true); |
|
2205 | + } |
|
2036 | 2206 | } elseif ($result['value'] == '21') { |
2037 | 2207 | $error = self::update_from_21(); |
2038 | - if ($error != '') return $error; |
|
2039 | - else return self::check_version(true); |
|
2208 | + if ($error != '') { |
|
2209 | + return $error; |
|
2210 | + } else { |
|
2211 | + return self::check_version(true); |
|
2212 | + } |
|
2040 | 2213 | } elseif ($result['value'] == '22') { |
2041 | 2214 | $error = self::update_from_22(); |
2042 | - if ($error != '') return $error; |
|
2043 | - else return self::check_version(true); |
|
2215 | + if ($error != '') { |
|
2216 | + return $error; |
|
2217 | + } else { |
|
2218 | + return self::check_version(true); |
|
2219 | + } |
|
2044 | 2220 | } elseif ($result['value'] == '23') { |
2045 | 2221 | $error = self::update_from_23(); |
2046 | - if ($error != '') return $error; |
|
2047 | - else return self::check_version(true); |
|
2222 | + if ($error != '') { |
|
2223 | + return $error; |
|
2224 | + } else { |
|
2225 | + return self::check_version(true); |
|
2226 | + } |
|
2048 | 2227 | } elseif ($result['value'] == '24') { |
2049 | 2228 | $error = self::update_from_24(); |
2050 | - if ($error != '') return $error; |
|
2051 | - else return self::check_version(true); |
|
2229 | + if ($error != '') { |
|
2230 | + return $error; |
|
2231 | + } else { |
|
2232 | + return self::check_version(true); |
|
2233 | + } |
|
2052 | 2234 | } elseif ($result['value'] == '25') { |
2053 | 2235 | $error = self::update_from_25(); |
2054 | - if ($error != '') return $error; |
|
2055 | - else return self::check_version(true); |
|
2236 | + if ($error != '') { |
|
2237 | + return $error; |
|
2238 | + } else { |
|
2239 | + return self::check_version(true); |
|
2240 | + } |
|
2056 | 2241 | } elseif ($result['value'] == '26') { |
2057 | 2242 | $error = self::update_from_26(); |
2058 | - if ($error != '') return $error; |
|
2059 | - else return self::check_version(true); |
|
2243 | + if ($error != '') { |
|
2244 | + return $error; |
|
2245 | + } else { |
|
2246 | + return self::check_version(true); |
|
2247 | + } |
|
2060 | 2248 | } elseif ($result['value'] == '27') { |
2061 | 2249 | $error = self::update_from_27(); |
2062 | - if ($error != '') return $error; |
|
2063 | - else return self::check_version(true); |
|
2250 | + if ($error != '') { |
|
2251 | + return $error; |
|
2252 | + } else { |
|
2253 | + return self::check_version(true); |
|
2254 | + } |
|
2064 | 2255 | } elseif ($result['value'] == '28') { |
2065 | 2256 | $error = self::update_from_28(); |
2066 | - if ($error != '') return $error; |
|
2067 | - else return self::check_version(true); |
|
2257 | + if ($error != '') { |
|
2258 | + return $error; |
|
2259 | + } else { |
|
2260 | + return self::check_version(true); |
|
2261 | + } |
|
2068 | 2262 | } elseif ($result['value'] == '29') { |
2069 | 2263 | $error = self::update_from_29(); |
2070 | - if ($error != '') return $error; |
|
2071 | - else return self::check_version(true); |
|
2264 | + if ($error != '') { |
|
2265 | + return $error; |
|
2266 | + } else { |
|
2267 | + return self::check_version(true); |
|
2268 | + } |
|
2072 | 2269 | } elseif ($result['value'] == '30') { |
2073 | 2270 | $error = self::update_from_30(); |
2074 | - if ($error != '') return $error; |
|
2075 | - else return self::check_version(true); |
|
2271 | + if ($error != '') { |
|
2272 | + return $error; |
|
2273 | + } else { |
|
2274 | + return self::check_version(true); |
|
2275 | + } |
|
2076 | 2276 | } elseif ($result['value'] == '31') { |
2077 | 2277 | $error = self::update_from_31(); |
2078 | - if ($error != '') return $error; |
|
2079 | - else return self::check_version(true); |
|
2278 | + if ($error != '') { |
|
2279 | + return $error; |
|
2280 | + } else { |
|
2281 | + return self::check_version(true); |
|
2282 | + } |
|
2080 | 2283 | } elseif ($result['value'] == '32') { |
2081 | 2284 | $error = self::update_from_32(); |
2082 | - if ($error != '') return $error; |
|
2083 | - else return self::check_version(true); |
|
2285 | + if ($error != '') { |
|
2286 | + return $error; |
|
2287 | + } else { |
|
2288 | + return self::check_version(true); |
|
2289 | + } |
|
2084 | 2290 | } elseif ($result['value'] == '33') { |
2085 | 2291 | $error = self::update_from_33(); |
2086 | - if ($error != '') return $error; |
|
2087 | - else return self::check_version(true); |
|
2292 | + if ($error != '') { |
|
2293 | + return $error; |
|
2294 | + } else { |
|
2295 | + return self::check_version(true); |
|
2296 | + } |
|
2088 | 2297 | } elseif ($result['value'] == '34') { |
2089 | 2298 | $error = self::update_from_34(); |
2090 | - if ($error != '') return $error; |
|
2091 | - else return self::check_version(true); |
|
2299 | + if ($error != '') { |
|
2300 | + return $error; |
|
2301 | + } else { |
|
2302 | + return self::check_version(true); |
|
2303 | + } |
|
2092 | 2304 | } elseif ($result['value'] == '35') { |
2093 | 2305 | $error = self::update_from_35(); |
2094 | - if ($error != '') return $error; |
|
2095 | - else return self::check_version(true); |
|
2306 | + if ($error != '') { |
|
2307 | + return $error; |
|
2308 | + } else { |
|
2309 | + return self::check_version(true); |
|
2310 | + } |
|
2096 | 2311 | } elseif ($result['value'] == '36') { |
2097 | 2312 | $error = self::update_from_36(); |
2098 | - if ($error != '') return $error; |
|
2099 | - else return self::check_version(true); |
|
2313 | + if ($error != '') { |
|
2314 | + return $error; |
|
2315 | + } else { |
|
2316 | + return self::check_version(true); |
|
2317 | + } |
|
2100 | 2318 | } elseif ($result['value'] == '37') { |
2101 | 2319 | $error = self::update_from_37(); |
2102 | - if ($error != '') return $error; |
|
2103 | - else return self::check_version(true); |
|
2320 | + if ($error != '') { |
|
2321 | + return $error; |
|
2322 | + } else { |
|
2323 | + return self::check_version(true); |
|
2324 | + } |
|
2104 | 2325 | } elseif ($result['value'] == '38') { |
2105 | 2326 | $error = self::update_from_38(); |
2106 | - if ($error != '') return $error; |
|
2107 | - else return self::check_version(true); |
|
2327 | + if ($error != '') { |
|
2328 | + return $error; |
|
2329 | + } else { |
|
2330 | + return self::check_version(true); |
|
2331 | + } |
|
2108 | 2332 | } elseif ($result['value'] == '39') { |
2109 | 2333 | $error = self::update_from_39(); |
2110 | - if ($error != '') return $error; |
|
2111 | - else return self::check_version(true); |
|
2112 | - } else return ''; |
|
2334 | + if ($error != '') { |
|
2335 | + return $error; |
|
2336 | + } else { |
|
2337 | + return self::check_version(true); |
|
2338 | + } |
|
2339 | + } else { |
|
2340 | + return ''; |
|
2341 | + } |
|
2342 | + } else { |
|
2343 | + return $result['value']; |
|
2113 | 2344 | } |
2114 | - else return $result['value']; |
|
2115 | 2345 | } |
2116 | 2346 | |
2117 | - } else return $version; |
|
2347 | + } else { |
|
2348 | + return $version; |
|
2349 | + } |
|
2118 | 2350 | } |
2119 | 2351 | |
2120 | 2352 | } |
@@ -48,27 +48,52 @@ discard block |
||
48 | 48 | } |
49 | 49 | header('Content-Type: text/javascript'); |
50 | 50 | |
51 | -if (!isset($globalJsonCompress)) $compress = true; |
|
52 | -else $compress = $globalJsonCompress; |
|
51 | +if (!isset($globalJsonCompress)) { |
|
52 | + $compress = true; |
|
53 | +} else { |
|
54 | + $compress = $globalJsonCompress; |
|
55 | +} |
|
53 | 56 | |
54 | 57 | $from_archive = false; |
55 | 58 | $min = true; |
56 | 59 | $allhistory = false; |
57 | 60 | $filter['source'] = array(); |
58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
61 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
62 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
63 | +} |
|
64 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
65 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
66 | +} |
|
67 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
68 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
69 | +} |
|
70 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
71 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
72 | +} |
|
73 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
74 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
75 | +} |
|
76 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
77 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
78 | +} |
|
79 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
80 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
81 | +} |
|
82 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
83 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
84 | +} |
|
85 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
86 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
87 | +} |
|
88 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
89 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
90 | +} |
|
68 | 91 | |
69 | 92 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
70 | 93 | $min = true; |
71 | -} else $min = false; |
|
94 | +} else { |
|
95 | + $min = false; |
|
96 | +} |
|
72 | 97 | |
73 | 98 | if (isset($_GET['ident'])) { |
74 | 99 | $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
@@ -157,21 +182,33 @@ discard block |
||
157 | 182 | } else { |
158 | 183 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
159 | 184 | } |
160 | - } else $flightcnt = count($spotter_array); |
|
161 | - if ($flightcnt == '') $flightcnt = 0; |
|
162 | -} else $flightcnt = 0; |
|
185 | + } else { |
|
186 | + $flightcnt = count($spotter_array); |
|
187 | + } |
|
188 | + if ($flightcnt == '') { |
|
189 | + $flightcnt = 0; |
|
190 | + } |
|
191 | + } else { |
|
192 | + $flightcnt = 0; |
|
193 | +} |
|
163 | 194 | |
164 | 195 | $sqltime = round(microtime(true)-$begintime,2); |
165 | 196 | |
166 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
|
167 | -else $usenextlatlon = true; |
|
197 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { |
|
198 | + $usenextlatlon = false; |
|
199 | +} else { |
|
200 | + $usenextlatlon = true; |
|
201 | +} |
|
168 | 202 | $j = 0; |
169 | 203 | $prev_flightaware_id = ''; |
170 | 204 | $aircrafts_shadow = array(); |
171 | 205 | $output = '{'; |
172 | 206 | $output .= '"type": "FeatureCollection",'; |
173 | - if ($min) $output .= '"minimal": "true",'; |
|
174 | - else $output .= '"minimal": "false",'; |
|
207 | + if ($min) { |
|
208 | + $output .= '"minimal": "true",'; |
|
209 | + } else { |
|
210 | + $output .= '"minimal": "false",'; |
|
211 | + } |
|
175 | 212 | //$output .= '"fc": "'.$flightcnt.'",'; |
176 | 213 | $output .= '"sqt": "'.$sqltime.'",'; |
177 | 214 | |
@@ -215,18 +252,29 @@ discard block |
||
215 | 252 | } |
216 | 253 | $output .= '"properties": {'; |
217 | 254 | if (isset($spotter_item['flightaware_id'])) { |
218 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
219 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
255 | + if ($compress) { |
|
256 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
257 | + } else { |
|
258 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
259 | + } |
|
220 | 260 | } elseif (isset($spotter_item['famtrackid'])) { |
221 | - if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
222 | - else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
261 | + if ($compress) { |
|
262 | + $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
263 | + } else { |
|
264 | + $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
265 | + } |
|
223 | 266 | } elseif (isset($spotter_item['fammarine_id'])) { |
224 | - if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
225 | - else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
267 | + if ($compress) { |
|
268 | + $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
269 | + } else { |
|
270 | + $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
271 | + } |
|
226 | 272 | } |
227 | 273 | $output .= '"fc": "'.$flightcnt.'",'; |
228 | 274 | $output .= '"sqt": "'.$sqltime.'",'; |
229 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
275 | + if (isset($begindate)) { |
|
276 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
277 | + } |
|
230 | 278 | |
231 | 279 | /* |
232 | 280 | if ($min) $output .= '"minimal": "true",'; |
@@ -234,14 +282,22 @@ discard block |
||
234 | 282 | */ |
235 | 283 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
236 | 284 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
237 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
238 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
285 | + if ($compress) { |
|
286 | + $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
287 | + } else { |
|
288 | + $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
289 | + } |
|
239 | 290 | //" |
240 | 291 | } else { |
241 | - if ($compress) $output .= '"c": "NA",'; |
|
242 | - else $output .= '"callsign": "NA",'; |
|
292 | + if ($compress) { |
|
293 | + $output .= '"c": "NA",'; |
|
294 | + } else { |
|
295 | + $output .= '"callsign": "NA",'; |
|
296 | + } |
|
297 | + } |
|
298 | + if (isset($spotter_item['registration'])) { |
|
299 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
243 | 300 | } |
244 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
245 | 301 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
246 | 302 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
247 | 303 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -254,15 +310,21 @@ discard block |
||
254 | 310 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
255 | 311 | } |
256 | 312 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker) { |
257 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
258 | - else { |
|
313 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
314 | + $spotter_item['aircraft_shadow'] = ''; |
|
315 | + } else { |
|
259 | 316 | $aircraft_icao = $spotter_item['aircraft_icao']; |
260 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
261 | - else { |
|
317 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
318 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
319 | + } else { |
|
262 | 320 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
263 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
264 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
265 | - else $spotter_item['aircraft_shadow'] = ''; |
|
321 | + if (count($aircraft_info) > 0) { |
|
322 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
323 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
324 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
325 | + } else { |
|
326 | + $spotter_item['aircraft_shadow'] = ''; |
|
327 | + } |
|
266 | 328 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
267 | 329 | } |
268 | 330 | } |
@@ -270,73 +332,139 @@ discard block |
||
270 | 332 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
271 | 333 | if ($tracker) { |
272 | 334 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
273 | - if ($compress) $output .= '"as": "ambulance.png",'; |
|
274 | - else $output .= '"aircraft_shadow": "ambulance.png",'; |
|
335 | + if ($compress) { |
|
336 | + $output .= '"as": "ambulance.png",'; |
|
337 | + } else { |
|
338 | + $output .= '"aircraft_shadow": "ambulance.png",'; |
|
339 | + } |
|
275 | 340 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
276 | - if ($compress) $output .= '"as": "police.png",'; |
|
277 | - else $output .= '"aircraft_shadow": "police.png",'; |
|
341 | + if ($compress) { |
|
342 | + $output .= '"as": "police.png",'; |
|
343 | + } else { |
|
344 | + $output .= '"aircraft_shadow": "police.png",'; |
|
345 | + } |
|
278 | 346 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
279 | - if ($compress) $output .= '"as": "ship.png",'; |
|
280 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
347 | + if ($compress) { |
|
348 | + $output .= '"as": "ship.png",'; |
|
349 | + } else { |
|
350 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
351 | + } |
|
281 | 352 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
282 | - if ($compress) $output .= '"as": "ship.png",'; |
|
283 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
353 | + if ($compress) { |
|
354 | + $output .= '"as": "ship.png",'; |
|
355 | + } else { |
|
356 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
357 | + } |
|
284 | 358 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
285 | - if ($compress) $output .= '"as": "ship.png",'; |
|
286 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
359 | + if ($compress) { |
|
360 | + $output .= '"as": "ship.png",'; |
|
361 | + } else { |
|
362 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
363 | + } |
|
287 | 364 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
288 | - if ($compress) $output .= '"as": "truck.png",'; |
|
289 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
365 | + if ($compress) { |
|
366 | + $output .= '"as": "truck.png",'; |
|
367 | + } else { |
|
368 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
369 | + } |
|
290 | 370 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
291 | - if ($compress) $output .= '"as": "truck.png",'; |
|
292 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
371 | + if ($compress) { |
|
372 | + $output .= '"as": "truck.png",'; |
|
373 | + } else { |
|
374 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
375 | + } |
|
293 | 376 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
294 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
295 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
377 | + if ($compress) { |
|
378 | + $output .= '"as": "aircraft.png",'; |
|
379 | + } else { |
|
380 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
381 | + } |
|
296 | 382 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
297 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
298 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
383 | + if ($compress) { |
|
384 | + $output .= '"as": "aircraft.png",'; |
|
385 | + } else { |
|
386 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
387 | + } |
|
299 | 388 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
300 | - if ($compress) $output .= '"as": "helico.png",'; |
|
301 | - else $output .= '"aircraft_shadow": "helico.png",'; |
|
389 | + if ($compress) { |
|
390 | + $output .= '"as": "helico.png",'; |
|
391 | + } else { |
|
392 | + $output .= '"aircraft_shadow": "helico.png",'; |
|
393 | + } |
|
302 | 394 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
303 | - if ($compress) $output .= '"as": "rail.png",'; |
|
304 | - else $output .= '"aircraft_shadow": "rail.png",'; |
|
395 | + if ($compress) { |
|
396 | + $output .= '"as": "rail.png",'; |
|
397 | + } else { |
|
398 | + $output .= '"aircraft_shadow": "rail.png",'; |
|
399 | + } |
|
305 | 400 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
306 | - if ($compress) $output .= '"as": "firetruck.png",'; |
|
307 | - else $output .= '"aircraft_shadow": "firetruck.png",'; |
|
401 | + if ($compress) { |
|
402 | + $output .= '"as": "firetruck.png",'; |
|
403 | + } else { |
|
404 | + $output .= '"aircraft_shadow": "firetruck.png",'; |
|
405 | + } |
|
308 | 406 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
309 | - if ($compress) $output .= '"as": "bus.png",'; |
|
310 | - else $output .= '"aircraft_shadow": "bus.png",'; |
|
407 | + if ($compress) { |
|
408 | + $output .= '"as": "bus.png",'; |
|
409 | + } else { |
|
410 | + $output .= '"aircraft_shadow": "bus.png",'; |
|
411 | + } |
|
311 | 412 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
312 | - if ($compress) $output .= '"as": "phone.png",'; |
|
313 | - else $output .= '"aircraft_shadow": "phone.png",'; |
|
413 | + if ($compress) { |
|
414 | + $output .= '"as": "phone.png",'; |
|
415 | + } else { |
|
416 | + $output .= '"aircraft_shadow": "phone.png",'; |
|
417 | + } |
|
314 | 418 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
315 | - if ($compress) $output .= '"as": "jogger.png",'; |
|
316 | - else $output .= '"aircraft_shadow": "jogger.png",'; |
|
419 | + if ($compress) { |
|
420 | + $output .= '"as": "jogger.png",'; |
|
421 | + } else { |
|
422 | + $output .= '"aircraft_shadow": "jogger.png",'; |
|
423 | + } |
|
317 | 424 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
318 | - if ($compress) $output .= '"as": "bike.png",'; |
|
319 | - else $output .= '"aircraft_shadow": "bike.png",'; |
|
425 | + if ($compress) { |
|
426 | + $output .= '"as": "bike.png",'; |
|
427 | + } else { |
|
428 | + $output .= '"aircraft_shadow": "bike.png",'; |
|
429 | + } |
|
320 | 430 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
321 | - if ($compress) $output .= '"as": "motorcycle.png",'; |
|
322 | - else $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
431 | + if ($compress) { |
|
432 | + $output .= '"as": "motorcycle.png",'; |
|
433 | + } else { |
|
434 | + $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
435 | + } |
|
323 | 436 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
324 | - if ($compress) $output .= '"as": "balloon.png",'; |
|
325 | - else $output .= '"aircraft_shadow": "balloon.png",'; |
|
437 | + if ($compress) { |
|
438 | + $output .= '"as": "balloon.png",'; |
|
439 | + } else { |
|
440 | + $output .= '"aircraft_shadow": "balloon.png",'; |
|
441 | + } |
|
326 | 442 | } else { |
327 | - if ($compress) $output .= '"as": "car.png",'; |
|
328 | - else $output .= '"aircraft_shadow": "car.png",'; |
|
443 | + if ($compress) { |
|
444 | + $output .= '"as": "car.png",'; |
|
445 | + } else { |
|
446 | + $output .= '"aircraft_shadow": "car.png",'; |
|
447 | + } |
|
329 | 448 | } |
330 | 449 | } elseif ($marine) { |
331 | - if ($compress) $output .= '"as": "ship.png",'; |
|
332 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
450 | + if ($compress) { |
|
451 | + $output .= '"as": "ship.png",'; |
|
452 | + } else { |
|
453 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
454 | + } |
|
333 | 455 | } else { |
334 | - if ($compress) $output .= '"as": "default.png",'; |
|
335 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
456 | + if ($compress) { |
|
457 | + $output .= '"as": "default.png",'; |
|
458 | + } else { |
|
459 | + $output .= '"aircraft_shadow": "default.png",'; |
|
460 | + } |
|
336 | 461 | } |
337 | 462 | } else { |
338 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
339 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
463 | + if ($compress) { |
|
464 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
465 | + } else { |
|
466 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
467 | + } |
|
340 | 468 | } |
341 | 469 | if (isset($spotter_item['airline_name'])) { |
342 | 470 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -344,8 +472,11 @@ discard block |
||
344 | 472 | $output .= '"airline_name": "NA",'; |
345 | 473 | } |
346 | 474 | if (isset($spotter_item['departure_airport'])) { |
347 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
348 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
475 | + if ($compress) { |
|
476 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
477 | + } else { |
|
478 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
479 | + } |
|
349 | 480 | } |
350 | 481 | if (isset($spotter_item['departure_airport_city'])) { |
351 | 482 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -357,8 +488,11 @@ discard block |
||
357 | 488 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
358 | 489 | } |
359 | 490 | if (isset($spotter_item['arrival_airport'])) { |
360 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
361 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
491 | + if ($compress) { |
|
492 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
493 | + } else { |
|
494 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
495 | + } |
|
362 | 496 | } |
363 | 497 | if (isset($spotter_item['arrival_airport_city'])) { |
364 | 498 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -377,11 +511,17 @@ discard block |
||
377 | 511 | } |
378 | 512 | |
379 | 513 | if (isset($spotter_item['altitude'])) { |
380 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
381 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
514 | + if ($compress) { |
|
515 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
516 | + } else { |
|
517 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
518 | + } |
|
519 | + } |
|
520 | + if ($compress) { |
|
521 | + $output .= '"h": "'.$spotter_item['heading'].'",'; |
|
522 | + } else { |
|
523 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
382 | 524 | } |
383 | - if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",'; |
|
384 | - else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
385 | 525 | |
386 | 526 | if (isset($archivespeed)) { |
387 | 527 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
@@ -391,7 +531,9 @@ discard block |
||
391 | 531 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
392 | 532 | } |
393 | 533 | |
394 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
534 | + if (!$min) { |
|
535 | + $output .= '"image": "'.$image.'",'; |
|
536 | + } |
|
395 | 537 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
396 | 538 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
397 | 539 | } |
@@ -399,8 +541,11 @@ discard block |
||
399 | 541 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
400 | 542 | } |
401 | 543 | if (isset($spotter_item['squawk'])) { |
402 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
403 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
544 | + if ($compress) { |
|
545 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
546 | + } else { |
|
547 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
548 | + } |
|
404 | 549 | } |
405 | 550 | if (isset($spotter_item['squawk_usage'])) { |
406 | 551 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -419,14 +564,23 @@ discard block |
||
419 | 564 | } |
420 | 565 | // type when not aircraft ? |
421 | 566 | if (isset($spotter_item['type'])) { |
422 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
|
423 | - else $output .= '"type": "'.$spotter_item['type'].'"'; |
|
567 | + if ($compress) { |
|
568 | + $output .= '"t": "'.$spotter_item['type'].'"'; |
|
569 | + } else { |
|
570 | + $output .= '"type": "'.$spotter_item['type'].'"'; |
|
571 | + } |
|
424 | 572 | } elseif ($marine) { |
425 | - if ($compress) $output .= '"t": "ship"'; |
|
426 | - else $output .= '"type": "ship"'; |
|
573 | + if ($compress) { |
|
574 | + $output .= '"t": "ship"'; |
|
575 | + } else { |
|
576 | + $output .= '"type": "ship"'; |
|
577 | + } |
|
427 | 578 | } else { |
428 | - if ($compress) $output .= '"t": "aircraft"'; |
|
429 | - else $output .= '"type": "aircraft"'; |
|
579 | + if ($compress) { |
|
580 | + $output .= '"t": "aircraft"'; |
|
581 | + } else { |
|
582 | + $output .= '"type": "aircraft"'; |
|
583 | + } |
|
430 | 584 | } |
431 | 585 | $output .= '},'; |
432 | 586 | $output .= '"geometry": {'; |
@@ -494,7 +648,9 @@ discard block |
||
494 | 648 | } |
495 | 649 | */ |
496 | 650 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
497 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
651 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
652 | + $history = $_COOKIE['history']; |
|
653 | + } |
|
498 | 654 | |
499 | 655 | if ( |
500 | 656 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
@@ -538,8 +694,11 @@ discard block |
||
538 | 694 | $output_history .= ']}},'; |
539 | 695 | $output .= $output_history; |
540 | 696 | } |
541 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
542 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
697 | + if ($compress) { |
|
698 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
699 | + } else { |
|
700 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
701 | + } |
|
543 | 702 | } |
544 | 703 | $output_history .= '['; |
545 | 704 | $output_history .= $spotter_history['longitude'].', '; |
@@ -558,9 +717,14 @@ discard block |
||
558 | 717 | $prev_alt = $alt; |
559 | 718 | } else { |
560 | 719 | if ($d == false) { |
561 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
562 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
563 | - } else $d = true; |
|
720 | + if ($compress) { |
|
721 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
722 | + } else { |
|
723 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
724 | + } |
|
725 | + } else { |
|
726 | + $d = true; |
|
727 | + } |
|
564 | 728 | $output_history .= '['; |
565 | 729 | $output_history .= $spotter_history['longitude'].', '; |
566 | 730 | $output_history .= $spotter_history['latitude']; |
@@ -581,7 +745,9 @@ discard block |
||
581 | 745 | $output_historyd = '['; |
582 | 746 | $output_historyd .= $spotter_item['longitude'].', '; |
583 | 747 | $output_historyd .= $spotter_item['latitude']; |
584 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
748 | + if (isset($spotter_history['altitude'])) { |
|
749 | + $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
750 | + } |
|
585 | 751 | $output_historyd .= '],'; |
586 | 752 | //$output_history = $output_historyd.$output_history; |
587 | 753 | $output_history = $output_history.$output_historyd; |
@@ -604,8 +770,11 @@ discard block |
||
604 | 770 | && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
605 | 771 | || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) |
606 | 772 | || (isset($globalMapRoute) && $globalMapRoute)))))) { |
607 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
608 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
773 | + if ($compress) { |
|
774 | + $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
775 | + } else { |
|
776 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
777 | + } |
|
609 | 778 | if (isset($spotter_item['departure_airport_latitude'])) { |
610 | 779 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
611 | 780 | } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
@@ -638,8 +807,11 @@ discard block |
||
638 | 807 | || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) |
639 | 808 | || (isset($globalMapRoute) && $globalMapRoute)))))) { |
640 | 809 | $havedata = false; |
641 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
642 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
810 | + if ($compress) { |
|
811 | + $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
812 | + } else { |
|
813 | + $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
814 | + } |
|
643 | 815 | $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
644 | 816 | |
645 | 817 | if (isset($spotter_item['arrival_airport_latitude'])) { |
@@ -654,7 +826,9 @@ discard block |
||
654 | 826 | } |
655 | 827 | //$output_dest = substr($output_dest, 0, -1); |
656 | 828 | $output_dest .= ']}},'; |
657 | - if ($havedata) $output .= $output_dest; |
|
829 | + if ($havedata) { |
|
830 | + $output .= $output_dest; |
|
831 | + } |
|
658 | 832 | unset($output_dest); |
659 | 833 | } |
660 | 834 | } |
@@ -662,7 +836,9 @@ discard block |
||
662 | 836 | $output .= ']'; |
663 | 837 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
664 | 838 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
665 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
839 | + if (isset($begindate)) { |
|
840 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
841 | + } |
|
666 | 842 | $output .= '"fc": "'.$j.'"'; |
667 | 843 | } else { |
668 | 844 | $output .= '"features": '; |
@@ -8,8 +8,12 @@ discard block |
||
8 | 8 | } |
9 | 9 | $tracker = false; |
10 | 10 | $marine = false; |
11 | -if (isset($_GET['tracker'])) $tracker = true; |
|
12 | -if (isset($_GET['marine'])) $marine = true; |
|
11 | +if (isset($_GET['tracker'])) { |
|
12 | + $tracker = true; |
|
13 | +} |
|
14 | +if (isset($_GET['marine'])) { |
|
15 | + $marine = true; |
|
16 | +} |
|
13 | 17 | if ($tracker) { |
14 | 18 | require_once('require/class.Tracker.php'); |
15 | 19 | require_once('require/class.TrackerLive.php'); |
@@ -66,23 +70,46 @@ discard block |
||
66 | 70 | } |
67 | 71 | header('Content-Type: text/javascript'); |
68 | 72 | |
69 | -if (!isset($globalJsonCompress)) $compress = true; |
|
70 | -else $compress = $globalJsonCompress; |
|
73 | +if (!isset($globalJsonCompress)) { |
|
74 | + $compress = true; |
|
75 | +} else { |
|
76 | + $compress = $globalJsonCompress; |
|
77 | +} |
|
71 | 78 | |
72 | 79 | $from_archive = false; |
73 | 80 | $min = false; |
74 | 81 | $allhistory = false; |
75 | 82 | $filter['source'] = array(); |
76 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
77 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
78 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
79 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
80 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
81 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
82 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
83 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
84 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
85 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
83 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
84 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
85 | +} |
|
86 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
87 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
88 | +} |
|
89 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
90 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
91 | +} |
|
92 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
93 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
94 | +} |
|
95 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
96 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
97 | +} |
|
98 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
99 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
100 | +} |
|
101 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
102 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
103 | +} |
|
104 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
105 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
106 | +} |
|
107 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
108 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
109 | +} |
|
110 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
111 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
112 | +} |
|
86 | 113 | /* |
87 | 114 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
88 | 115 | $min = true; |
@@ -167,8 +194,12 @@ discard block |
||
167 | 194 | } else { |
168 | 195 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
169 | 196 | } |
170 | - if ($flightcnt == '') $flightcnt = 0; |
|
171 | -} else $flightcnt = 0; |
|
197 | + if ($flightcnt == '') { |
|
198 | + $flightcnt = 0; |
|
199 | + } |
|
200 | + } else { |
|
201 | + $flightcnt = 0; |
|
202 | +} |
|
172 | 203 | |
173 | 204 | $sqltime = round(microtime(true)-$begintime,2); |
174 | 205 | $minitime = time(); |
@@ -191,7 +222,9 @@ discard block |
||
191 | 222 | $j = 0; |
192 | 223 | $prev_flightaware_id = ''; |
193 | 224 | $speed = 1; |
194 | -if (isset($archivespeed)) $speed = $archivespeed; |
|
225 | +if (isset($archivespeed)) { |
|
226 | + $speed = $archivespeed; |
|
227 | +} |
|
195 | 228 | $output = '['; |
196 | 229 | if ($tracker) { |
197 | 230 | $output .= '{"id" : "document", "name" : "tracker","version" : "1.0"'; |
@@ -229,9 +262,13 @@ discard block |
||
229 | 262 | $image = "images/placeholder_thumb.png"; |
230 | 263 | } |
231 | 264 | |
232 | - if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
233 | - elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
234 | - elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
265 | + if (isset($spotter_item['flightaware_id'])) { |
|
266 | + $id = $spotter_item['flightaware_id']; |
|
267 | + } elseif (isset($spotter_item['famtrackid'])) { |
|
268 | + $id = $spotter_item['famtrackid']; |
|
269 | + } elseif (isset($spotter_item['fammarine_id'])) { |
|
270 | + $id = $spotter_item['fammarine_id']; |
|
271 | + } |
|
235 | 272 | if ($prev_flightaware_id != $id) { |
236 | 273 | if ($prev_flightaware_id != '') { |
237 | 274 | $output .= ']'; |
@@ -270,7 +307,9 @@ discard block |
||
270 | 307 | $spotter_item['engine_type'] = $aircraft_info[0]['engine_type']; |
271 | 308 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
272 | 309 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
273 | - } else $aircraft_shadow = ''; |
|
310 | + } else { |
|
311 | + $aircraft_shadow = ''; |
|
312 | + } |
|
274 | 313 | $output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5'; |
275 | 314 | if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] && isset($_COOKIE['IconColor'])) { |
276 | 315 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
@@ -278,7 +317,9 @@ discard block |
||
278 | 317 | } |
279 | 318 | $output .= '},'; |
280 | 319 | } |
281 | - } else $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},'; |
|
320 | + } else { |
|
321 | + $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},'; |
|
322 | + } |
|
282 | 323 | } elseif ($one3dmodel) { |
283 | 324 | if (isset($globalMap3DForceModel) && $globalMap3DForceModel != '') { |
284 | 325 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$globalMap3DForceModel.'","scale" : 1.0,"minimumPixelSize": 20'; |
@@ -309,7 +350,9 @@ discard block |
||
309 | 350 | $spotter_item['engine_type'] = $aircraft_info[0]['engine_type']; |
310 | 351 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
311 | 352 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
312 | - } else $aircraft_shadow = ''; |
|
353 | + } else { |
|
354 | + $aircraft_shadow = ''; |
|
355 | + } |
|
313 | 356 | if ($aircraft_shadow != '') { |
314 | 357 | if (isset($modelsdb[$aircraft_shadow])) { |
315 | 358 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20'; |
@@ -446,7 +489,9 @@ discard block |
||
446 | 489 | } |
447 | 490 | $output .= '},'; |
448 | 491 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
449 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
492 | + if ($spotter_item['aircraft_icao'] != '') { |
|
493 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
494 | + } |
|
450 | 495 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
451 | 496 | } |
452 | 497 | } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
@@ -468,7 +513,9 @@ discard block |
||
468 | 513 | } |
469 | 514 | $output .= '},'; |
470 | 515 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
471 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
516 | + if ($spotter_item['aircraft_icao'] != '') { |
|
517 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
518 | + } |
|
472 | 519 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
473 | 520 | } |
474 | 521 | } else { |
@@ -481,7 +528,9 @@ discard block |
||
481 | 528 | } |
482 | 529 | $output .= '},'; |
483 | 530 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
484 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
531 | + if ($spotter_item['aircraft_icao'] != '') { |
|
532 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
533 | + } |
|
485 | 534 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
486 | 535 | } |
487 | 536 | } elseif ($tracker && isset($spotter_item['type'])) { |
@@ -536,8 +585,12 @@ discard block |
||
536 | 585 | // $output .= '"interpolationDegree" : 5,'; |
537 | 586 | // $output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", '; |
538 | 587 | $output .= '"cartographicDegrees": ['; |
539 | - if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
|
540 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
588 | + if ($minitime > strtotime($spotter_item['date'])) { |
|
589 | + $minitime = strtotime($spotter_item['date']); |
|
590 | + } |
|
591 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
592 | + $maxitime = strtotime($spotter_item['date']); |
|
593 | + } |
|
541 | 594 | $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
542 | 595 | $output .= $spotter_item['longitude'].', '; |
543 | 596 | $output .= $spotter_item['latitude']; |
@@ -546,19 +599,26 @@ discard block |
||
546 | 599 | if (!$tracker && !$marine) { |
547 | 600 | $output .= ', '.round($spotter_item['altitude']*30.48); |
548 | 601 | $prevalt = round($spotter_item['altitude']*30.48); |
549 | - } else $output .= ', 0'; |
|
602 | + } else { |
|
603 | + $output .= ', 0'; |
|
604 | + } |
|
550 | 605 | //$orientation = '"orientation" : { '; |
551 | 606 | //$orientation .= '"unitQuaternion": ['; |
552 | 607 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
553 | 608 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
554 | 609 | } else { |
555 | 610 | $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
556 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
611 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
612 | + $maxitime = strtotime($spotter_item['date']); |
|
613 | + } |
|
557 | 614 | if ($spotter_item['ground_speed'] == 0) { |
558 | 615 | $output .= $prevlong.', '; |
559 | 616 | $output .= $prevlat; |
560 | - if (!$tracker && !$marine) $output .= ', '.$prevalt; |
|
561 | - else $output .= ', 0'; |
|
617 | + if (!$tracker && !$marine) { |
|
618 | + $output .= ', '.$prevalt; |
|
619 | + } else { |
|
620 | + $output .= ', 0'; |
|
621 | + } |
|
562 | 622 | } else { |
563 | 623 | $output .= $spotter_item['longitude'].', '; |
564 | 624 | $output .= $spotter_item['latitude']; |
@@ -572,7 +632,9 @@ discard block |
||
572 | 632 | } else { |
573 | 633 | $output .= ', '.round($spotter_item['altitude']*30.48); |
574 | 634 | } |
575 | - } else $output .= ', 0'; |
|
635 | + } else { |
|
636 | + $output .= ', 0'; |
|
637 | + } |
|
576 | 638 | } |
577 | 639 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
578 | 640 | //$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
@@ -1033,8 +1033,11 @@ discard block |
||
1033 | 1033 | $data = file_get_contents($filename); |
1034 | 1034 | preg_match_all("/%%(.+?)%%/is", $data, $matches); |
1035 | 1035 | //print_r($matches); |
1036 | - if (isset($matches[1])) return $matches[1]; |
|
1037 | - else return array(); |
|
1036 | + if (isset($matches[1])) { |
|
1037 | + return $matches[1]; |
|
1038 | + } else { |
|
1039 | + return array(); |
|
1040 | + } |
|
1038 | 1041 | } |
1039 | 1042 | public function getAllNOTAMbyScope($scope) { |
1040 | 1043 | global $globalDBdriver; |
@@ -1071,7 +1074,9 @@ discard block |
||
1071 | 1074 | $minlong = $maxlong; |
1072 | 1075 | $maxlong = $tmplong; |
1073 | 1076 | } |
1074 | - } else return array(); |
|
1077 | + } else { |
|
1078 | + return array(); |
|
1079 | + } |
|
1075 | 1080 | if ($globalDBdriver == 'mysql') { |
1076 | 1081 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()'; |
1077 | 1082 | } else { |
@@ -1095,7 +1100,9 @@ discard block |
||
1095 | 1100 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1096 | 1101 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1097 | 1102 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1098 | - } else return array(); |
|
1103 | + } else { |
|
1104 | + return array(); |
|
1105 | + } |
|
1099 | 1106 | if ($globalDBdriver == 'mysql') { |
1100 | 1107 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
1101 | 1108 | } else { |
@@ -1122,8 +1129,11 @@ discard block |
||
1122 | 1129 | return "error : ".$e->getMessage(); |
1123 | 1130 | } |
1124 | 1131 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1125 | - if (isset($all[0])) return $all[0]; |
|
1126 | - else return array(); |
|
1132 | + if (isset($all[0])) { |
|
1133 | + return $all[0]; |
|
1134 | + } else { |
|
1135 | + return array(); |
|
1136 | + } |
|
1127 | 1137 | } |
1128 | 1138 | |
1129 | 1139 | public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
@@ -1201,7 +1211,9 @@ discard block |
||
1201 | 1211 | foreach ($alldata as $initial_data) { |
1202 | 1212 | $data = $this->parse($initial_data); |
1203 | 1213 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1204 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1214 | + if (count($notamref) == 0) { |
|
1215 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1216 | + } |
|
1205 | 1217 | } |
1206 | 1218 | } |
1207 | 1219 | } |
@@ -1214,7 +1226,9 @@ discard block |
||
1214 | 1226 | foreach ($alldata as $initial_data) { |
1215 | 1227 | $data = $this->parse($initial_data); |
1216 | 1228 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1217 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1229 | + if (!isset($notamref['notam_id'])) { |
|
1230 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1231 | + } |
|
1218 | 1232 | } |
1219 | 1233 | } |
1220 | 1234 | } |
@@ -1226,11 +1240,15 @@ discard block |
||
1226 | 1240 | foreach (array_chunk($allairports,20) as $airport) { |
1227 | 1241 | $airports_icao = array(); |
1228 | 1242 | foreach($airport as $icao) { |
1229 | - if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
|
1243 | + if (isset($icao['icao'])) { |
|
1244 | + $airports_icao[] = $icao['icao']; |
|
1245 | + } |
|
1230 | 1246 | } |
1231 | 1247 | $airport_icao = implode(',',$airports_icao); |
1232 | 1248 | $alldata = $this->downloadNOTAM($airport_icao); |
1233 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
1249 | + if ($globalTransaction) { |
|
1250 | + $this->db->beginTransaction(); |
|
1251 | + } |
|
1234 | 1252 | if (count($alldata) > 0) { |
1235 | 1253 | foreach ($alldata as $initial_data) { |
1236 | 1254 | //print_r($initial_data); |
@@ -1239,14 +1257,23 @@ discard block |
||
1239 | 1257 | if (isset($data['ref'])) { |
1240 | 1258 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1241 | 1259 | if (count($notamref) == 0) { |
1242 | - if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
1243 | - if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
1244 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1260 | + if (isset($data['ref_replaced'])) { |
|
1261 | + $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
1262 | + } |
|
1263 | + if (isset($data['ref_cancelled'])) { |
|
1264 | + $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
1265 | + } elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) { |
|
1266 | + echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1267 | + } |
|
1245 | 1268 | } |
1246 | 1269 | } |
1247 | 1270 | } |
1248 | - } else echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
1249 | - if ($globalTransaction) $this->db->commit(); |
|
1271 | + } else { |
|
1272 | + echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
1273 | + } |
|
1274 | + if ($globalTransaction) { |
|
1275 | + $this->db->commit(); |
|
1276 | + } |
|
1250 | 1277 | sleep(5); |
1251 | 1278 | } |
1252 | 1279 | } |
@@ -1259,8 +1286,11 @@ discard block |
||
1259 | 1286 | $data = $Common->getData($url); |
1260 | 1287 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
1261 | 1288 | //print_r($matches); |
1262 | - if (isset($matches[1])) return $matches[1]; |
|
1263 | - else return array(); |
|
1289 | + if (isset($matches[1])) { |
|
1290 | + return $matches[1]; |
|
1291 | + } else { |
|
1292 | + return array(); |
|
1293 | + } |
|
1264 | 1294 | } |
1265 | 1295 | |
1266 | 1296 | public function parse($data) { |
@@ -1283,90 +1313,149 @@ discard block |
||
1283 | 1313 | $rules = str_split($matches[3]); |
1284 | 1314 | foreach ($rules as $rule) { |
1285 | 1315 | if ($rule == 'I') { |
1286 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR'; |
|
1287 | - else $result['rules'] = 'IFR'; |
|
1316 | + if (isset($result['rules'])) { |
|
1317 | + $result['rules'] = $result['rules'].'/IFR'; |
|
1318 | + } else { |
|
1319 | + $result['rules'] = 'IFR'; |
|
1320 | + } |
|
1288 | 1321 | } elseif ($rule == 'V') { |
1289 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR'; |
|
1290 | - else $result['rules'] = 'VFR'; |
|
1322 | + if (isset($result['rules'])) { |
|
1323 | + $result['rules'] = $result['rules'].'/VFR'; |
|
1324 | + } else { |
|
1325 | + $result['rules'] = 'VFR'; |
|
1326 | + } |
|
1291 | 1327 | } elseif ($rule == 'K') { |
1292 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist'; |
|
1293 | - else $result['rules'] = 'Checklist'; |
|
1328 | + if (isset($result['rules'])) { |
|
1329 | + $result['rules'] = $result['rules'].'/Checklist'; |
|
1330 | + } else { |
|
1331 | + $result['rules'] = 'Checklist'; |
|
1332 | + } |
|
1294 | 1333 | } |
1295 | 1334 | } |
1296 | 1335 | $attentions = str_split($matches[4]); |
1297 | 1336 | foreach ($attentions as $attention) { |
1298 | 1337 | if ($attention == 'N') { |
1299 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention'; |
|
1300 | - else $result['rules'] = 'Immediate attention'; |
|
1338 | + if (isset($result['attention'])) { |
|
1339 | + $result['attention'] = $result['attention'].' / Immediate attention'; |
|
1340 | + } else { |
|
1341 | + $result['rules'] = 'Immediate attention'; |
|
1342 | + } |
|
1301 | 1343 | } elseif ($attention == 'B') { |
1302 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance'; |
|
1303 | - else $result['rules'] = 'Operational significance'; |
|
1344 | + if (isset($result['attention'])) { |
|
1345 | + $result['attention'] = $result['attention'].' / Operational significance'; |
|
1346 | + } else { |
|
1347 | + $result['rules'] = 'Operational significance'; |
|
1348 | + } |
|
1304 | 1349 | } elseif ($attention == 'O') { |
1305 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations'; |
|
1306 | - else $result['rules'] = 'Flight operations'; |
|
1350 | + if (isset($result['attention'])) { |
|
1351 | + $result['attention'] = $result['attention'].' / Flight operations'; |
|
1352 | + } else { |
|
1353 | + $result['rules'] = 'Flight operations'; |
|
1354 | + } |
|
1307 | 1355 | } elseif ($attention == 'M') { |
1308 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc'; |
|
1309 | - else $result['rules'] = 'Misc'; |
|
1356 | + if (isset($result['attention'])) { |
|
1357 | + $result['attention'] = $result['attention'].' / Misc'; |
|
1358 | + } else { |
|
1359 | + $result['rules'] = 'Misc'; |
|
1360 | + } |
|
1310 | 1361 | } elseif ($attention == 'K') { |
1311 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist'; |
|
1312 | - else $result['rules'] = 'Checklist'; |
|
1362 | + if (isset($result['attention'])) { |
|
1363 | + $result['attention'] = $result['attention'].' / Checklist'; |
|
1364 | + } else { |
|
1365 | + $result['rules'] = 'Checklist'; |
|
1366 | + } |
|
1313 | 1367 | } |
1314 | 1368 | } |
1315 | - if ($matches[5] == 'A') $result['scope'] = 'Airport warning'; |
|
1316 | - elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning'; |
|
1317 | - elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning'; |
|
1318 | - elseif ($matches[5] == 'K') $result['scope'] = 'Checklist'; |
|
1319 | - elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning'; |
|
1320 | - elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
|
1369 | + if ($matches[5] == 'A') { |
|
1370 | + $result['scope'] = 'Airport warning'; |
|
1371 | + } elseif ($matches[5] == 'E') { |
|
1372 | + $result['scope'] = 'Enroute warning'; |
|
1373 | + } elseif ($matches[5] == 'W') { |
|
1374 | + $result['scope'] = 'Navigation warning'; |
|
1375 | + } elseif ($matches[5] == 'K') { |
|
1376 | + $result['scope'] = 'Checklist'; |
|
1377 | + } elseif ($matches[5] == 'AE') { |
|
1378 | + $result['scope'] = 'Airport/Enroute warning'; |
|
1379 | + } elseif ($matches[5] == 'AW') { |
|
1380 | + $result['scope'] = 'Airport/Navigation warning'; |
|
1381 | + } |
|
1321 | 1382 | $result['lower_limit'] = $matches[6]; |
1322 | 1383 | $result['upper_limit'] = $matches[7]; |
1323 | 1384 | $latitude = $Common->convertDec($matches[8],'latitude'); |
1324 | - if ($matches[9] == 'S') $latitude = -$latitude; |
|
1385 | + if ($matches[9] == 'S') { |
|
1386 | + $latitude = -$latitude; |
|
1387 | + } |
|
1325 | 1388 | $longitude = $Common->convertDec($matches[10],'longitude'); |
1326 | - if ($matches[11] == 'W') $longitude = -$longitude; |
|
1389 | + if ($matches[11] == 'W') { |
|
1390 | + $longitude = -$longitude; |
|
1391 | + } |
|
1327 | 1392 | $result['latitude'] = $latitude; |
1328 | 1393 | $result['longitude'] = $longitude; |
1329 | - if ($matches[12] != '') $result['radius'] = intval($matches[12]); |
|
1330 | - else $result['radius'] = 0; |
|
1331 | - } else echo 'ERROR : '.$line."\n"; |
|
1332 | - } |
|
1333 | - elseif (preg_match('#A\) (.*)#',$line,$matches)) { |
|
1394 | + if ($matches[12] != '') { |
|
1395 | + $result['radius'] = intval($matches[12]); |
|
1396 | + } else { |
|
1397 | + $result['radius'] = 0; |
|
1398 | + } |
|
1399 | + } else { |
|
1400 | + echo 'ERROR : '.$line."\n"; |
|
1401 | + } |
|
1402 | + } elseif (preg_match('#A\) (.*)#',$line,$matches)) { |
|
1334 | 1403 | $result['icao'] = $matches[1]; |
1335 | - } |
|
1336 | - elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { |
|
1337 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
1338 | - else $year = '20'.$matches[1]; |
|
1404 | + } elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { |
|
1405 | + if ($matches[1] > 50) { |
|
1406 | + $year = '19'.$matches[1]; |
|
1407 | + } else { |
|
1408 | + $year = '20'.$matches[1]; |
|
1409 | + } |
|
1339 | 1410 | $result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
1340 | - } |
|
1341 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { |
|
1342 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
1343 | - else $year = '20'.$matches[1]; |
|
1411 | + } elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { |
|
1412 | + if ($matches[1] > 50) { |
|
1413 | + $year = '19'.$matches[1]; |
|
1414 | + } else { |
|
1415 | + $year = '20'.$matches[1]; |
|
1416 | + } |
|
1344 | 1417 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
1345 | 1418 | $result['permanent'] = 0; |
1346 | - } |
|
1347 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { |
|
1348 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
1349 | - else $year = '20'.$matches[1]; |
|
1419 | + } elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { |
|
1420 | + if ($matches[1] > 50) { |
|
1421 | + $year = '19'.$matches[1]; |
|
1422 | + } else { |
|
1423 | + $year = '20'.$matches[1]; |
|
1424 | + } |
|
1350 | 1425 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
1351 | - if ($matches[6] == 'EST') $result['estimated'] = 1; |
|
1352 | - else $result['estimated'] = 0; |
|
1353 | - if ($matches[6] == 'PERM') $result['permanent'] = 1; |
|
1354 | - else $result['permanent'] = 0; |
|
1355 | - } |
|
1356 | - elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { |
|
1426 | + if ($matches[6] == 'EST') { |
|
1427 | + $result['estimated'] = 1; |
|
1428 | + } else { |
|
1429 | + $result['estimated'] = 0; |
|
1430 | + } |
|
1431 | + if ($matches[6] == 'PERM') { |
|
1432 | + $result['permanent'] = 1; |
|
1433 | + } else { |
|
1434 | + $result['permanent'] = 0; |
|
1435 | + } |
|
1436 | + } elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { |
|
1357 | 1437 | $result['date_end'] = '2030/12/20 12:00'; |
1358 | - if ($matches[1] == 'EST') $result['estimated'] = 1; |
|
1359 | - else $result['estimated'] = 0; |
|
1360 | - if ($matches[1] == 'PERM') $result['permanent'] = 1; |
|
1361 | - else $result['permanent'] = 0; |
|
1362 | - } |
|
1363 | - elseif (preg_match('#E\) (.*)#',$line,$matches)) { |
|
1438 | + if ($matches[1] == 'EST') { |
|
1439 | + $result['estimated'] = 1; |
|
1440 | + } else { |
|
1441 | + $result['estimated'] = 0; |
|
1442 | + } |
|
1443 | + if ($matches[1] == 'PERM') { |
|
1444 | + $result['permanent'] = 1; |
|
1445 | + } else { |
|
1446 | + $result['permanent'] = 0; |
|
1447 | + } |
|
1448 | + } elseif (preg_match('#E\) (.*)#',$line,$matches)) { |
|
1364 | 1449 | $rtext = array(); |
1365 | 1450 | $text = explode(' ',$matches[1]); |
1366 | 1451 | foreach ($text as $word) { |
1367 | - if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
|
1368 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
1369 | - else $rtext[] = $word; |
|
1452 | + if (isset($this->abbr[$word])) { |
|
1453 | + $rtext[] = strtoupper($this->abbr[$word]); |
|
1454 | + } elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) { |
|
1455 | + $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
1456 | + } else { |
|
1457 | + $rtext[] = $word; |
|
1458 | + } |
|
1370 | 1459 | } |
1371 | 1460 | $result['text'] = implode(' ',$rtext); |
1372 | 1461 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
@@ -1374,7 +1463,9 @@ discard block |
||
1374 | 1463 | } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
1375 | 1464 | $text = explode(' ',$line); |
1376 | 1465 | $result['ref'] = $text[0]; |
1377 | - if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
|
1466 | + if ($matches[1] == 'NOTAMN') { |
|
1467 | + $result['type'] = 'new'; |
|
1468 | + } |
|
1378 | 1469 | if ($matches[1] == 'NOTAMC') { |
1379 | 1470 | $result['type'] = 'cancel'; |
1380 | 1471 | $result['ref_cancelled'] = $text[2]; |
@@ -1396,69 +1487,101 @@ discard block |
||
1396 | 1487 | switch ($code[1]) { |
1397 | 1488 | case 'A': |
1398 | 1489 | $result = 'Airspace organization '; |
1399 | - if (isset($this->code_airspace[$code_fp])) $result .= $this->code_airspace[$code_fp]; |
|
1490 | + if (isset($this->code_airspace[$code_fp])) { |
|
1491 | + $result .= $this->code_airspace[$code_fp]; |
|
1492 | + } |
|
1400 | 1493 | break; |
1401 | 1494 | case 'C': |
1402 | 1495 | $result = 'Communications and radar facilities '; |
1403 | - if (isset($this->code_comradar[$code_fp])) $result .= $this->code_comradar[$code_fp]; |
|
1496 | + if (isset($this->code_comradar[$code_fp])) { |
|
1497 | + $result .= $this->code_comradar[$code_fp]; |
|
1498 | + } |
|
1404 | 1499 | break; |
1405 | 1500 | case 'F': |
1406 | 1501 | $result = 'Facilities and services '; |
1407 | - if (isset($this->code_facilities[$code_fp])) $result .= $this->code_facilities[$code_fp]; |
|
1502 | + if (isset($this->code_facilities[$code_fp])) { |
|
1503 | + $result .= $this->code_facilities[$code_fp]; |
|
1504 | + } |
|
1408 | 1505 | break; |
1409 | 1506 | case 'I': |
1410 | 1507 | $result = 'Instrument and Microwave Landing System '; |
1411 | - if (isset($this->code_instrumentlanding[$code_fp])) $result .= $this->code_instrumentlanding[$code_fp]; |
|
1508 | + if (isset($this->code_instrumentlanding[$code_fp])) { |
|
1509 | + $result .= $this->code_instrumentlanding[$code_fp]; |
|
1510 | + } |
|
1412 | 1511 | break; |
1413 | 1512 | case 'L': |
1414 | 1513 | $result = 'Lighting facilities '; |
1415 | - if (isset($this->code_lightingfacilities[$code_fp])) $result .= $this->code_lightingfacilities[$code_fp]; |
|
1514 | + if (isset($this->code_lightingfacilities[$code_fp])) { |
|
1515 | + $result .= $this->code_lightingfacilities[$code_fp]; |
|
1516 | + } |
|
1416 | 1517 | break; |
1417 | 1518 | case 'M': |
1418 | 1519 | $result = 'Movement and landing areas '; |
1419 | - if (isset($this->code_movementareas[$code_fp])) $result .= $this->code_movementareas[$code_fp]; |
|
1520 | + if (isset($this->code_movementareas[$code_fp])) { |
|
1521 | + $result .= $this->code_movementareas[$code_fp]; |
|
1522 | + } |
|
1420 | 1523 | break; |
1421 | 1524 | case 'N': |
1422 | 1525 | $result = 'Terminal and En Route Navigation Facilities '; |
1423 | - if (isset($this->code_terminalfacilities[$code_fp])) $result .= $this->code_terminalfacilities[$code_fp]; |
|
1526 | + if (isset($this->code_terminalfacilities[$code_fp])) { |
|
1527 | + $result .= $this->code_terminalfacilities[$code_fp]; |
|
1528 | + } |
|
1424 | 1529 | break; |
1425 | 1530 | case 'O': |
1426 | 1531 | $result = 'Other information '; |
1427 | - if (isset($this->code_information[$code_fp])) $result .= $this->code_information[$code_fp]; |
|
1532 | + if (isset($this->code_information[$code_fp])) { |
|
1533 | + $result .= $this->code_information[$code_fp]; |
|
1534 | + } |
|
1428 | 1535 | break; |
1429 | 1536 | case 'P': |
1430 | 1537 | $result = 'Air Traffic procedures '; |
1431 | - if (isset($this->code_airtraffic[$code_fp])) $result .= $this->code_airtraffic[$code_fp]; |
|
1538 | + if (isset($this->code_airtraffic[$code_fp])) { |
|
1539 | + $result .= $this->code_airtraffic[$code_fp]; |
|
1540 | + } |
|
1432 | 1541 | break; |
1433 | 1542 | case 'R': |
1434 | 1543 | $result = 'Navigation Warnings: Airspace Restrictions '; |
1435 | - if (isset($this->code_navigationw[$code_fp])) $result .= $this->code_navigationw[$code_fp]; |
|
1544 | + if (isset($this->code_navigationw[$code_fp])) { |
|
1545 | + $result .= $this->code_navigationw[$code_fp]; |
|
1546 | + } |
|
1436 | 1547 | break; |
1437 | 1548 | case 'S': |
1438 | 1549 | $result = 'Air Traffic and VOLMET Services '; |
1439 | - if (isset($this->code_volmet[$code_fp])) $result .= $this->code_volmet[$code_fp]; |
|
1550 | + if (isset($this->code_volmet[$code_fp])) { |
|
1551 | + $result .= $this->code_volmet[$code_fp]; |
|
1552 | + } |
|
1440 | 1553 | break; |
1441 | 1554 | case 'W': |
1442 | 1555 | $result = 'Navigation Warnings: Warnings '; |
1443 | - if (isset($this->code_warnings[$code_fp])) $result .= $this->code_warnings[$code_fp]; |
|
1556 | + if (isset($this->code_warnings[$code_fp])) { |
|
1557 | + $result .= $this->code_warnings[$code_fp]; |
|
1558 | + } |
|
1444 | 1559 | break; |
1445 | 1560 | } |
1446 | 1561 | switch ($code[3]) { |
1447 | 1562 | case 'A': |
1448 | 1563 | // Availability |
1449 | - if (isset($this->code_sp_availabity[$code_sp])) $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
1564 | + if (isset($this->code_sp_availabity[$code_sp])) { |
|
1565 | + $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
1566 | + } |
|
1450 | 1567 | break; |
1451 | 1568 | case 'C': |
1452 | 1569 | // Changes |
1453 | - if (isset($this->code_sp_changes[$code_sp])) $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
1570 | + if (isset($this->code_sp_changes[$code_sp])) { |
|
1571 | + $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
1572 | + } |
|
1454 | 1573 | break; |
1455 | 1574 | case 'H': |
1456 | 1575 | // Hazardous conditions |
1457 | - if (isset($this->code_sp_hazardous[$code_sp])) $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
1576 | + if (isset($this->code_sp_hazardous[$code_sp])) { |
|
1577 | + $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
1578 | + } |
|
1458 | 1579 | break; |
1459 | 1580 | case 'L': |
1460 | 1581 | // Limitations |
1461 | - if (isset($this->code_sp_limitations[$code_sp])) $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
1582 | + if (isset($this->code_sp_limitations[$code_sp])) { |
|
1583 | + $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
1584 | + } |
|
1462 | 1585 | break; |
1463 | 1586 | case 'X': |
1464 | 1587 | // Other Information |
@@ -20,20 +20,27 @@ discard block |
||
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 22 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
23 | - if (isset($source['source'])) $filter['source'][] = $source['source']; |
|
23 | + if (isset($source['source'])) { |
|
24 | + $filter['source'][] = $source['source']; |
|
25 | + } |
|
24 | 26 | } |
25 | 27 | } else { |
26 | 28 | $filter = $globalStatsFilters[$globalFilterName]; |
27 | 29 | } |
28 | 30 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
31 | + if (is_array($globalFilter)) { |
|
32 | + $filter = array_merge($filter,$globalFilter); |
|
33 | + } |
|
30 | 34 | $filter_query_join = ''; |
31 | 35 | $filter_query_where = ''; |
32 | 36 | if (isset($filter['source']) && !empty($filter['source'])) { |
33 | 37 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
34 | 38 | } |
35 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
36 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
39 | + if ($filter_query_where == '' && $where) { |
|
40 | + $filter_query_where = ' WHERE'; |
|
41 | + } elseif ($filter_query_where != '' && $and) { |
|
42 | + $filter_query_where .= ' AND'; |
|
43 | + } |
|
37 | 44 | $filter_query = $filter_query_join.$filter_query_where; |
38 | 45 | return $filter_query; |
39 | 46 | } |
@@ -90,7 +97,9 @@ discard block |
||
90 | 97 | $info = str_replace('^','<br />',$info); |
91 | 98 | $info = str_replace('&sect;','',$info); |
92 | 99 | $info = str_replace('"','',$info); |
93 | - if ($type == '') $type = NULL; |
|
100 | + if ($type == '') { |
|
101 | + $type = NULL; |
|
102 | + } |
|
94 | 103 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
95 | 104 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
96 | 105 | try { |
@@ -106,7 +115,9 @@ discard block |
||
106 | 115 | $info = str_replace('^','<br />',$info); |
107 | 116 | $info = str_replace('&sect;','',$info); |
108 | 117 | $info = str_replace('"','',$info); |
109 | - if ($type == '') $type = NULL; |
|
118 | + if ($type == '') { |
|
119 | + $type = NULL; |
|
120 | + } |
|
110 | 121 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
111 | 122 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
112 | 123 | try { |
@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | $dbc = $this->db; |
64 | 64 | $this->all_flights[$id]['schedule_check'] = true; |
65 | 65 | if ($globalSchedulesFetch) { |
66 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
66 | + if ($globalDebug) { |
|
67 | + echo 'Getting schedule info...'."\n"; |
|
68 | + } |
|
67 | 69 | $Spotter = new Spotter($dbc); |
68 | 70 | $Schedule = new Schedule($dbc); |
69 | 71 | $Translation = new Translation($dbc); |
@@ -74,7 +76,9 @@ discard block |
||
74 | 76 | if ($Schedule->checkSchedule($operator) == 0) { |
75 | 77 | $schedule = $Schedule->fetchSchedule($operator); |
76 | 78 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
77 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
79 | + if ($globalDebug) { |
|
80 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
81 | + } |
|
78 | 82 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
79 | 83 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
80 | 84 | // Should also check if route schedule = route from DB |
@@ -83,7 +87,9 @@ discard block |
||
83 | 87 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
84 | 88 | if (trim($airport_icao) != '') { |
85 | 89 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
86 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
90 | + if ($globalDebug) { |
|
91 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
92 | + } |
|
87 | 93 | } |
88 | 94 | } |
89 | 95 | } |
@@ -92,17 +98,25 @@ discard block |
||
92 | 98 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
93 | 99 | if (trim($airport_icao) != '') { |
94 | 100 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
95 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
101 | + if ($globalDebug) { |
|
102 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
103 | + } |
|
96 | 104 | } |
97 | 105 | } |
98 | 106 | } |
99 | 107 | $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
100 | 108 | } |
101 | - } else $scheduleexist = true; |
|
102 | - } else $scheduleexist = true; |
|
109 | + } else { |
|
110 | + $scheduleexist = true; |
|
111 | + } |
|
112 | + } else { |
|
113 | + $scheduleexist = true; |
|
114 | + } |
|
103 | 115 | // close connection, at least one way will work ? |
104 | 116 | if ($scheduleexist) { |
105 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
117 | + if ($globalDebug) { |
|
118 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
119 | + } |
|
106 | 120 | $sch = $Schedule->getSchedule($operator); |
107 | 121 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
108 | 122 | } |
@@ -124,14 +138,18 @@ discard block |
||
124 | 138 | |
125 | 139 | public function checkAll() { |
126 | 140 | global $globalDebug, $globalNoImport; |
127 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
141 | + if ($globalDebug) { |
|
142 | + echo "Update last seen flights data...\n"; |
|
143 | + } |
|
128 | 144 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
129 | 145 | foreach ($this->all_flights as $key => $flight) { |
130 | 146 | if (isset($this->all_flights[$key]['id'])) { |
131 | 147 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
132 | 148 | $Spotter = new Spotter($this->db); |
133 | 149 | $real_arrival = $this->arrival($key); |
134 | - if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
150 | + if (isset($this->all_flights[$key]['altitude'])) { |
|
151 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
152 | + } |
|
135 | 153 | } |
136 | 154 | } |
137 | 155 | } |
@@ -139,24 +157,32 @@ discard block |
||
139 | 157 | |
140 | 158 | public function arrival($key) { |
141 | 159 | global $globalClosestMinDist, $globalDebug; |
142 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
160 | + if ($globalDebug) { |
|
161 | + echo 'Update arrival...'."\n"; |
|
162 | + } |
|
143 | 163 | $Spotter = new Spotter($this->db); |
144 | 164 | $airport_icao = ''; |
145 | 165 | $airport_time = ''; |
146 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
166 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
167 | + $globalClosestMinDist = 50; |
|
168 | + } |
|
147 | 169 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
148 | 170 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
149 | 171 | if (isset($closestAirports[0])) { |
150 | 172 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
151 | 173 | $airport_icao = $closestAirports[0]['icao']; |
152 | 174 | $airport_time = $this->all_flights[$key]['datetime']; |
153 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
175 | + if ($globalDebug) { |
|
176 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
177 | + } |
|
154 | 178 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
155 | 179 | foreach ($closestAirports as $airport) { |
156 | 180 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
157 | 181 | $airport_icao = $airport['icao']; |
158 | 182 | $airport_time = $this->all_flights[$key]['datetime']; |
159 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
183 | + if ($globalDebug) { |
|
184 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
185 | + } |
|
160 | 186 | break; |
161 | 187 | } |
162 | 188 | } |
@@ -164,14 +190,20 @@ discard block |
||
164 | 190 | $airport_icao = $closestAirports[0]['icao']; |
165 | 191 | $airport_time = $this->all_flights[$key]['datetime']; |
166 | 192 | } else { |
167 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
195 | + } |
|
168 | 196 | } |
169 | 197 | } else { |
170 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
198 | + if ($globalDebug) { |
|
199 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
200 | + } |
|
171 | 201 | } |
172 | 202 | |
173 | 203 | } else { |
174 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
204 | + if ($globalDebug) { |
|
205 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
206 | + } |
|
175 | 207 | } |
176 | 208 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
177 | 209 | } |
@@ -181,7 +213,9 @@ discard block |
||
181 | 213 | public function del() { |
182 | 214 | global $globalDebug, $globalNoImport, $globalNoDB; |
183 | 215 | // Delete old infos |
184 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
216 | + if ($globalDebug) { |
|
217 | + echo 'Delete old values and update latest data...'."\n"; |
|
218 | + } |
|
185 | 219 | foreach ($this->all_flights as $key => $flight) { |
186 | 220 | if (isset($flight['lastupdate'])) { |
187 | 221 | if ($flight['lastupdate'] < (time()-5900)) { |
@@ -195,13 +229,17 @@ discard block |
||
195 | 229 | global $globalDebug, $globalNoImport, $globalNoDB; |
196 | 230 | // Delete old infos |
197 | 231 | if (isset($this->all_flights[$key]['id'])) { |
198 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
232 | + if ($globalDebug) { |
|
233 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
234 | + } |
|
199 | 235 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
200 | 236 | $real_arrival = $this->arrival($key); |
201 | 237 | $Spotter = new Spotter($this->db); |
202 | 238 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
203 | 239 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
204 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
240 | + if ($globalDebug && $result != 'success') { |
|
241 | + echo '!!! ERROR : '.$result."\n"; |
|
242 | + } |
|
205 | 243 | } |
206 | 244 | } |
207 | 245 | } |
@@ -211,9 +249,13 @@ discard block |
||
211 | 249 | public function add($line) { |
212 | 250 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate; |
213 | 251 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
214 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
215 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 2300; |
|
216 | -/* |
|
252 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
253 | + $globalCoordMinChange = '0.02'; |
|
254 | + } |
|
255 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
256 | + $globalAircraftMaxUpdate = 2300; |
|
257 | + } |
|
258 | + /* |
|
217 | 259 | $Spotter = new Spotter(); |
218 | 260 | $dbc = $Spotter->db; |
219 | 261 | $SpotterLive = new SpotterLive($dbc); |
@@ -235,19 +277,28 @@ discard block |
||
235 | 277 | // SBS format is CSV format |
236 | 278 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
237 | 279 | //print_r($line); |
238 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
280 | + if (isset($line['hex'])) { |
|
281 | + $line['hex'] = strtoupper($line['hex']); |
|
282 | + } |
|
239 | 283 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
240 | 284 | |
241 | 285 | // Increment message number |
242 | 286 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
243 | 287 | $current_date = date('Y-m-d'); |
244 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
245 | - else $source = ''; |
|
246 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
288 | + if (isset($line['source_name'])) { |
|
289 | + $source = $line['source_name']; |
|
290 | + } else { |
|
291 | + $source = ''; |
|
292 | + } |
|
293 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
294 | + $source = $line['format_source']; |
|
295 | + } |
|
247 | 296 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
248 | 297 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
249 | 298 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
250 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
299 | + } else { |
|
300 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
301 | + } |
|
251 | 302 | } |
252 | 303 | |
253 | 304 | /* |
@@ -263,22 +314,35 @@ discard block |
||
263 | 314 | //$this->db = $dbc; |
264 | 315 | |
265 | 316 | //$hex = trim($line['hex']); |
266 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
267 | - else $id = trim($line['id']); |
|
317 | + if (!isset($line['id'])) { |
|
318 | + $id = trim($line['hex']); |
|
319 | + } else { |
|
320 | + $id = trim($line['id']); |
|
321 | + } |
|
268 | 322 | |
269 | 323 | if (!isset($this->all_flights[$id])) { |
270 | 324 | $this->all_flights[$id] = array(); |
271 | 325 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
272 | 326 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
273 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
327 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
328 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
329 | + } |
|
274 | 330 | if (!isset($line['id'])) { |
275 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
276 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
331 | + if (!isset($globalDaemon)) { |
|
332 | + $globalDaemon = TRUE; |
|
333 | + } |
|
334 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
277 | 335 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
278 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
336 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
337 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
338 | + } |
|
279 | 339 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
280 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
281 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
340 | + } else { |
|
341 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
342 | + } |
|
343 | + if ($globalAllFlights !== FALSE) { |
|
344 | + $dataFound = true; |
|
345 | + } |
|
282 | 346 | } |
283 | 347 | if (isset($line['source_type']) && $line['source_type'] != '') { |
284 | 348 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -300,17 +364,27 @@ discard block |
||
300 | 364 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
301 | 365 | } |
302 | 366 | $Spotter->db = null; |
303 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
304 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
367 | + if ($globalDebugTimeElapsed) { |
|
368 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
369 | + } |
|
370 | + if ($aircraft_icao != '') { |
|
371 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
372 | + } |
|
305 | 373 | } |
306 | 374 | } |
307 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
308 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
375 | + if ($globalAllFlights !== FALSE) { |
|
376 | + $dataFound = true; |
|
377 | + } |
|
378 | + if ($globalDebug) { |
|
379 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
380 | + } |
|
309 | 381 | } |
310 | 382 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
311 | 383 | $icao = $line['aircraft_icao']; |
312 | 384 | $Spotter = new Spotter($this->db); |
313 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
385 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
386 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
387 | + } |
|
314 | 388 | $Spotter->db = null; |
315 | 389 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
316 | 390 | } |
@@ -320,15 +394,24 @@ discard block |
||
320 | 394 | $Spotter = new Spotter($this->db); |
321 | 395 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
322 | 396 | $Spotter->db = null; |
323 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
397 | + if ($aircraft_icao != '') { |
|
398 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
399 | + } |
|
324 | 400 | } |
325 | 401 | } |
326 | 402 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
327 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
328 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
329 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
330 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
331 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
403 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
404 | + $aircraft_icao = 'GLID'; |
|
405 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
406 | + $aircraft_icao = 'UHEL'; |
|
407 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
408 | + $aircraft_icao = 'TOWPLANE'; |
|
409 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
410 | + $aircraft_icao = 'POWAIRC'; |
|
411 | + } |
|
412 | + if (isset($aircraft_icao)) { |
|
413 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
414 | + } |
|
332 | 415 | } |
333 | 416 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
334 | 417 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -338,8 +421,11 @@ discard block |
||
338 | 421 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
339 | 422 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
340 | 423 | } else { |
341 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
342 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
424 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
425 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
426 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
427 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
428 | + } |
|
343 | 429 | /* |
344 | 430 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
345 | 431 | print_r($this->all_flights[$id]); |
@@ -348,16 +434,22 @@ discard block |
||
348 | 434 | return ''; |
349 | 435 | } |
350 | 436 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
351 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
437 | + if ($globalDebug) { |
|
438 | + echo "!!! Date is too old ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
439 | + } |
|
352 | 440 | return ''; |
353 | 441 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
354 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
442 | + if ($globalDebug) { |
|
443 | + echo "!!! Date is in the future ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
444 | + } |
|
355 | 445 | return ''; |
356 | 446 | } elseif (!isset($line['datetime'])) { |
357 | 447 | date_default_timezone_set('UTC'); |
358 | 448 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
359 | 449 | } else { |
360 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
450 | + if ($globalDebug) { |
|
451 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
452 | + } |
|
361 | 453 | return ''; |
362 | 454 | } |
363 | 455 | |
@@ -378,30 +470,48 @@ discard block |
||
378 | 470 | |
379 | 471 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
380 | 472 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 2300) { |
381 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
473 | + if ($globalDebug) { |
|
474 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
475 | + } |
|
382 | 476 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
383 | 477 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
384 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
385 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
386 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
478 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
479 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
480 | + } elseif (isset($line['id'])) { |
|
481 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
482 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
483 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
484 | + } |
|
387 | 485 | } else { |
388 | 486 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
389 | 487 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
390 | 488 | $timeelapsed = microtime(true); |
391 | 489 | $Spotter = new Spotter($this->db); |
392 | 490 | $fromsource = NULL; |
393 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
394 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
395 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
396 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
397 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
491 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
492 | + $fromsource = $globalAirlinesSource; |
|
493 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
494 | + $fromsource = 'vatsim'; |
|
495 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
496 | + $fromsource = 'ivao'; |
|
497 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
498 | + $fromsource = 'vatsim'; |
|
499 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
500 | + $fromsource = 'ivao'; |
|
501 | + } |
|
398 | 502 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
399 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
503 | + if ($globalDebug && $result != 'success') { |
|
504 | + echo '!!! ERROR : '.$result."\n"; |
|
505 | + } |
|
400 | 506 | $Spotter->db = null; |
401 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
507 | + if ($globalDebugTimeElapsed) { |
|
508 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
509 | + } |
|
402 | 510 | } |
403 | 511 | } |
404 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
512 | + } else { |
|
513 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
514 | + } |
|
405 | 515 | |
406 | 516 | /* |
407 | 517 | if (!isset($line['id'])) { |
@@ -411,7 +521,9 @@ discard block |
||
411 | 521 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
412 | 522 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
413 | 523 | */ |
414 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
524 | + if (!isset($this->all_flights[$id]['id'])) { |
|
525 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
526 | + } |
|
415 | 527 | |
416 | 528 | //$putinarchive = true; |
417 | 529 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -429,7 +541,9 @@ discard block |
||
429 | 541 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
430 | 542 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
431 | 543 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
432 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
544 | + if ($globalDebugTimeElapsed) { |
|
545 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
546 | + } |
|
433 | 547 | } |
434 | 548 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
435 | 549 | $timeelapsed = microtime(true); |
@@ -443,7 +557,9 @@ discard block |
||
443 | 557 | $Translation->db = null; |
444 | 558 | } |
445 | 559 | $Spotter->db = null; |
446 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
560 | + if ($globalDebugTimeElapsed) { |
|
561 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
562 | + } |
|
447 | 563 | } |
448 | 564 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
449 | 565 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -452,9 +568,13 @@ discard block |
||
452 | 568 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
453 | 569 | } |
454 | 570 | } |
455 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
571 | + if (!isset($globalFork)) { |
|
572 | + $globalFork = TRUE; |
|
573 | + } |
|
456 | 574 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
457 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
575 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
576 | + $this->get_Schedule($id,trim($line['ident'])); |
|
577 | + } |
|
458 | 578 | } |
459 | 579 | } |
460 | 580 | } |
@@ -470,16 +590,23 @@ discard block |
||
470 | 590 | // use datetime |
471 | 591 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
472 | 592 | $speed = $speed*3.6; |
473 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
474 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
593 | + if ($speed < 1000) { |
|
594 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
595 | + } |
|
596 | + if ($globalDebug) { |
|
597 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
598 | + } |
|
475 | 599 | } |
476 | 600 | } |
477 | 601 | |
478 | 602 | |
479 | 603 | |
480 | 604 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude']) && !is_int($line['latitude']) && !is_int($line['longitude'])) { |
481 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
482 | - else unset($timediff); |
|
605 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
606 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
607 | + } else { |
|
608 | + unset($timediff); |
|
609 | + } |
|
483 | 610 | if ($this->tmd > 5 || (isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
484 | 611 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
485 | 612 | if ((isset($timediff) && $timediff > $globalAircraftMaxUpdate) || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -488,16 +615,25 @@ discard block |
||
488 | 615 | $this->all_flights[$id]['putinarchive'] = true; |
489 | 616 | $this->tmd = 0; |
490 | 617 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
491 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
618 | + if ($globalDebug) { |
|
619 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
620 | + } |
|
492 | 621 | $timeelapsed = microtime(true); |
493 | 622 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
494 | 623 | $Spotter = new Spotter($this->db); |
495 | 624 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
496 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
497 | - else $this->all_flights[$id]['over_country'] = ''; |
|
625 | + if (!empty($all_country)) { |
|
626 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
627 | + } else { |
|
628 | + $this->all_flights[$id]['over_country'] = ''; |
|
629 | + } |
|
498 | 630 | $Spotter->db = null; |
499 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
500 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
631 | + if ($globalDebugTimeElapsed) { |
|
632 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
633 | + } |
|
634 | + if ($globalDebug) { |
|
635 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
636 | + } |
|
501 | 637 | } |
502 | 638 | } |
503 | 639 | } |
@@ -505,7 +641,9 @@ discard block |
||
505 | 641 | |
506 | 642 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
507 | 643 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
508 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
644 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
645 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
646 | + } |
|
509 | 647 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
510 | 648 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
511 | 649 | $dataFound = true; |
@@ -527,9 +665,13 @@ discard block |
||
527 | 665 | */ |
528 | 666 | } |
529 | 667 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
530 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
668 | + if ($line['longitude'] > 180) { |
|
669 | + $line['longitude'] = $line['longitude'] - 360; |
|
670 | + } |
|
531 | 671 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
532 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
672 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
673 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
674 | + } |
|
533 | 675 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
534 | 676 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
535 | 677 | $dataFound = true; |
@@ -560,7 +702,9 @@ discard block |
||
560 | 702 | } |
561 | 703 | } |
562 | 704 | if (isset($line['last_update']) && $line['last_update'] != '') { |
563 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
705 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
706 | + $dataFound = true; |
|
707 | + } |
|
564 | 708 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
565 | 709 | } |
566 | 710 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -582,53 +726,79 @@ discard block |
||
582 | 726 | // Here we force archive of flight because after ground it's a new one (or should be) |
583 | 727 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
584 | 728 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
585 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
586 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
587 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
729 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
730 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
731 | + } elseif (isset($line['id'])) { |
|
732 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
733 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
734 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
735 | + } |
|
736 | + } |
|
737 | + if ($line['ground'] != 1) { |
|
738 | + $line['ground'] = 0; |
|
588 | 739 | } |
589 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
590 | 740 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
591 | 741 | //$dataFound = true; |
592 | 742 | } |
593 | 743 | if (isset($line['squawk']) && $line['squawk'] != '') { |
594 | 744 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
595 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
745 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
746 | + $this->all_flights[$id]['putinarchive'] = true; |
|
747 | + } |
|
596 | 748 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
597 | 749 | $highlight = ''; |
598 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
599 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
600 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
750 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
751 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
752 | + } |
|
753 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
754 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
755 | + } |
|
756 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
757 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
758 | + } |
|
601 | 759 | if ($highlight != '') { |
602 | 760 | $timeelapsed = microtime(true); |
603 | 761 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
604 | 762 | $Spotter = new Spotter($this->db); |
605 | 763 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
606 | 764 | $Spotter->db = null; |
607 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
765 | + if ($globalDebugTimeElapsed) { |
|
766 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
767 | + } |
|
608 | 768 | } |
609 | 769 | //$putinarchive = true; |
610 | 770 | //$highlight = ''; |
611 | 771 | } |
612 | 772 | |
613 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
773 | + } else { |
|
774 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
775 | + } |
|
614 | 776 | //$dataFound = true; |
615 | 777 | } |
616 | 778 | |
617 | 779 | if (isset($line['altitude']) && $line['altitude'] != '') { |
618 | 780 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
619 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
781 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
782 | + $this->all_flights[$id]['putinarchive'] = true; |
|
783 | + } |
|
620 | 784 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
621 | 785 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
622 | 786 | //$dataFound = true; |
623 | 787 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
624 | 788 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
625 | 789 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 2300) { |
626 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
790 | + if ($globalDebug) { |
|
791 | + echo '--- Reset because of altitude'."\n"; |
|
792 | + } |
|
627 | 793 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
628 | 794 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
629 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
630 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
631 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
795 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
796 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
797 | + } elseif (isset($line['id'])) { |
|
798 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
799 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
800 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
801 | + } |
|
632 | 802 | } |
633 | 803 | } |
634 | 804 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -639,22 +809,32 @@ discard block |
||
639 | 809 | } |
640 | 810 | |
641 | 811 | if (isset($line['heading']) && $line['heading'] != '') { |
642 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
812 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
813 | + $this->all_flights[$id]['putinarchive'] = true; |
|
814 | + } |
|
643 | 815 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
644 | 816 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
645 | 817 | //$dataFound = true; |
646 | 818 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
647 | 819 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
648 | 820 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
649 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
650 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
821 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
822 | + $this->all_flights[$id]['putinarchive'] = true; |
|
823 | + } |
|
824 | + if ($globalDebug) { |
|
825 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
826 | + } |
|
651 | 827 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
652 | 828 | // If not enough messages and ACARS set heading to 0 |
653 | 829 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
654 | 830 | } |
655 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
656 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
657 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
831 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
832 | + $dataFound = false; |
|
833 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
834 | + $dataFound = false; |
|
835 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) { |
|
836 | + $dataFound = false; |
|
837 | + } |
|
658 | 838 | |
659 | 839 | // print_r($this->all_flights[$id]); |
660 | 840 | //gets the callsign from the last hour |
@@ -670,23 +850,38 @@ discard block |
||
670 | 850 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
671 | 851 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
672 | 852 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
673 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
853 | + if ($globalDebug) { |
|
854 | + echo "Check if aircraft is already in DB..."; |
|
855 | + } |
|
674 | 856 | $timeelapsed = microtime(true); |
675 | 857 | $SpotterLive = new SpotterLive($this->db); |
676 | 858 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
677 | 859 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
860 | + if ($globalDebugTimeElapsed) { |
|
861 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
862 | + } |
|
679 | 863 | } elseif (isset($line['id'])) { |
680 | 864 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
681 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
865 | + if ($globalDebugTimeElapsed) { |
|
866 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
867 | + } |
|
682 | 868 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
683 | 869 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
684 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
685 | - } else $recent_ident = ''; |
|
870 | + if ($globalDebugTimeElapsed) { |
|
871 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
872 | + } |
|
873 | + } else { |
|
874 | + $recent_ident = ''; |
|
875 | + } |
|
686 | 876 | $SpotterLive->db=null; |
687 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
688 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
689 | - } else $recent_ident = ''; |
|
877 | + if ($globalDebug && $recent_ident == '') { |
|
878 | + echo " Not in DB.\n"; |
|
879 | + } elseif ($globalDebug && $recent_ident != '') { |
|
880 | + echo " Already in DB.\n"; |
|
881 | + } |
|
882 | + } else { |
|
883 | + $recent_ident = ''; |
|
884 | + } |
|
690 | 885 | } else { |
691 | 886 | $recent_ident = ''; |
692 | 887 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -694,7 +889,9 @@ discard block |
||
694 | 889 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
695 | 890 | if($recent_ident == "") |
696 | 891 | { |
697 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
892 | + if ($globalDebug) { |
|
893 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
894 | + } |
|
698 | 895 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
699 | 896 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
700 | 897 | //adds the spotter data for the archive |
@@ -738,31 +935,49 @@ discard block |
||
738 | 935 | |
739 | 936 | if (!$ignoreImport) { |
740 | 937 | $highlight = ''; |
741 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
742 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
743 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
744 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
938 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
939 | + $highlight = 'Squawk 7500 : Hijack'; |
|
940 | + } |
|
941 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
942 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
943 | + } |
|
944 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
945 | + $highlight = 'Squawk 7700 : Emergency'; |
|
946 | + } |
|
947 | + if (!isset($this->all_flights[$id]['id'])) { |
|
948 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
949 | + } |
|
745 | 950 | $timeelapsed = microtime(true); |
746 | 951 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
747 | 952 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
748 | 953 | $Spotter = new Spotter($this->db); |
749 | 954 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
750 | 955 | $Spotter->db = null; |
751 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
956 | + if ($globalDebug && isset($result)) { |
|
957 | + echo $result."\n"; |
|
958 | + } |
|
752 | 959 | } |
753 | 960 | } |
754 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
961 | + if ($globalDebugTimeElapsed) { |
|
962 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
963 | + } |
|
755 | 964 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
756 | 965 | |
757 | 966 | // Add source stat in DB |
758 | 967 | $Stats = new Stats($this->db); |
759 | 968 | if (!empty($this->stats)) { |
760 | - if ($globalDebug) echo 'Add source stats : '; |
|
969 | + if ($globalDebug) { |
|
970 | + echo 'Add source stats : '; |
|
971 | + } |
|
761 | 972 | foreach($this->stats as $date => $data) { |
762 | 973 | foreach($data as $source => $sourced) { |
763 | 974 | //print_r($sourced); |
764 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
765 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
975 | + if (isset($sourced['polar'])) { |
|
976 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
977 | + } |
|
978 | + if (isset($sourced['hist'])) { |
|
979 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
980 | + } |
|
766 | 981 | if (isset($sourced['msg'])) { |
767 | 982 | if (time() - $sourced['msg']['date'] > 10) { |
768 | 983 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -775,13 +990,17 @@ discard block |
||
775 | 990 | unset($this->stats[$date]); |
776 | 991 | } |
777 | 992 | } |
778 | - if ($globalDebug) echo 'Done'."\n"; |
|
993 | + if ($globalDebug) { |
|
994 | + echo 'Done'."\n"; |
|
995 | + } |
|
779 | 996 | |
780 | 997 | } |
781 | 998 | $Stats->db = null; |
782 | 999 | } |
783 | 1000 | $this->del(); |
784 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
1001 | + } elseif ($globalDebug) { |
|
1002 | + echo 'Ignore data'."\n"; |
|
1003 | + } |
|
785 | 1004 | //$ignoreImport = false; |
786 | 1005 | $this->all_flights[$id]['addedSpotter'] = 1; |
787 | 1006 | //print_r($this->all_flights[$id]); |
@@ -798,7 +1017,9 @@ discard block |
||
798 | 1017 | */ |
799 | 1018 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
800 | 1019 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
801 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1020 | + if ($globalDebug) { |
|
1021 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1022 | + } |
|
802 | 1023 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
803 | 1024 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
804 | 1025 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -807,7 +1028,9 @@ discard block |
||
807 | 1028 | $SpotterLive->db=null; |
808 | 1029 | } |
809 | 1030 | } |
810 | - if ($globalDebug) echo " Done\n"; |
|
1031 | + if ($globalDebug) { |
|
1032 | + echo " Done\n"; |
|
1033 | + } |
|
811 | 1034 | $this->last_delete = time(); |
812 | 1035 | } |
813 | 1036 | } else { |
@@ -834,11 +1057,17 @@ discard block |
||
834 | 1057 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
835 | 1058 | if ($globalDebug) { |
836 | 1059 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
837 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
838 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
1060 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1061 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
1062 | + } else { |
|
1063 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
1064 | + } |
|
839 | 1065 | } else { |
840 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
841 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
1066 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1067 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
1068 | + } else { |
|
1069 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
1070 | + } |
|
842 | 1071 | } |
843 | 1072 | } |
844 | 1073 | $ignoreImport = false; |
@@ -884,22 +1113,30 @@ discard block |
||
884 | 1113 | |
885 | 1114 | if (!$ignoreImport) { |
886 | 1115 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
887 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1116 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1117 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1118 | + } |
|
888 | 1119 | $timeelapsed = microtime(true); |
889 | 1120 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
890 | 1121 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
891 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1122 | + if ($globalDebug) { |
|
1123 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1124 | + } |
|
892 | 1125 | $SpotterLive = new SpotterLive($this->db); |
893 | 1126 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
894 | 1127 | $SpotterLive->db = null; |
895 | - if ($globalDebug) echo $result."\n"; |
|
1128 | + if ($globalDebug) { |
|
1129 | + echo $result."\n"; |
|
1130 | + } |
|
896 | 1131 | } |
897 | 1132 | } |
898 | 1133 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
899 | 1134 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
900 | 1135 | } |
901 | 1136 | $this->all_flights[$id]['putinarchive'] = false; |
902 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1137 | + if ($globalDebugTimeElapsed) { |
|
1138 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1139 | + } |
|
903 | 1140 | |
904 | 1141 | // Put statistics in $this->stats variable |
905 | 1142 | //if ($line['format_source'] != 'aprs') { |
@@ -907,7 +1144,9 @@ discard block |
||
907 | 1144 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
908 | 1145 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
909 | 1146 | $source = $this->all_flights[$id]['source_name']; |
910 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
1147 | + if ($source == '') { |
|
1148 | + $source = $this->all_flights[$id]['format_source']; |
|
1149 | + } |
|
911 | 1150 | if (!isset($this->source_location[$source])) { |
912 | 1151 | $Location = new Source(); |
913 | 1152 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -928,7 +1167,9 @@ discard block |
||
928 | 1167 | $stats_heading = round($stats_heading/22.5); |
929 | 1168 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
930 | 1169 | $current_date = date('Y-m-d'); |
931 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1170 | + if ($stats_heading == 16) { |
|
1171 | + $stats_heading = 0; |
|
1172 | + } |
|
932 | 1173 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
933 | 1174 | for ($i=0;$i<=15;$i++) { |
934 | 1175 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -946,7 +1187,9 @@ discard block |
||
946 | 1187 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
947 | 1188 | end($this->stats[$current_date][$source]['hist']); |
948 | 1189 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
949 | - } else $mini = 0; |
|
1190 | + } else { |
|
1191 | + $mini = 0; |
|
1192 | + } |
|
950 | 1193 | for ($i=$mini;$i<=$distance;$i+=10) { |
951 | 1194 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
952 | 1195 | } |
@@ -958,19 +1201,27 @@ discard block |
||
958 | 1201 | } |
959 | 1202 | |
960 | 1203 | $this->all_flights[$id]['lastupdate'] = time(); |
961 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1204 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1205 | + $send = true; |
|
1206 | + } |
|
962 | 1207 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
963 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1208 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1209 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1210 | + } |
|
964 | 1211 | //$this->del(); |
965 | 1212 | |
966 | 1213 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
967 | 1214 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
968 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1215 | + if ($globalDebug) { |
|
1216 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1217 | + } |
|
969 | 1218 | $SpotterLive = new SpotterLive($this->db); |
970 | 1219 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
971 | 1220 | $SpotterLive->db = null; |
972 | 1221 | //SpotterLive->deleteLiveSpotterData(); |
973 | - if ($globalDebug) echo " Done\n"; |
|
1222 | + if ($globalDebug) { |
|
1223 | + echo " Done\n"; |
|
1224 | + } |
|
974 | 1225 | $this->last_delete_hourly = time(); |
975 | 1226 | } else { |
976 | 1227 | $this->del(); |
@@ -982,7 +1233,9 @@ discard block |
||
982 | 1233 | //$ignoreImport = false; |
983 | 1234 | } |
984 | 1235 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
985 | - if ($send) return $this->all_flights[$id]; |
|
1236 | + if ($send) { |
|
1237 | + return $this->all_flights[$id]; |
|
1238 | + } |
|
986 | 1239 | } |
987 | 1240 | } |
988 | 1241 | } |
@@ -202,7 +202,12 @@ discard block |
||
202 | 202 | // viewer.dataSources.get(dsn).entities.remove(entity); |
203 | 203 | // } |
204 | 204 | //console.log(entity.lastupdate); |
205 | - if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
|
205 | + if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { |
|
206 | + print $globalMapRefresh*2000; |
|
207 | +} else { |
|
208 | + print '60000'; |
|
209 | +} |
|
210 | +?>)) { |
|
206 | 211 | // console.log('Remove an entity date'); |
207 | 212 | viewer.dataSources.get(dsn).entities.remove(entity); |
208 | 213 | } else { |
@@ -276,7 +281,12 @@ discard block |
||
276 | 281 | } else { |
277 | 282 | for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) { |
278 | 283 | var entity = viewer.dataSources.get(dsn).entities.values[i]; |
279 | - if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
|
284 | + if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) { |
|
285 | + print $globalMapRefresh*2000; |
|
286 | +} else { |
|
287 | + print '60000'; |
|
288 | +} |
|
289 | +?>)) { |
|
280 | 290 | viewer.dataSources.get(dsn).entities.remove(entity); |
281 | 291 | } |
282 | 292 | } |
@@ -606,7 +616,12 @@ discard block |
||
606 | 616 | if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
607 | 617 | ?> |
608 | 618 | update_polarLayer(); |
609 | -setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
619 | +setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) { |
|
620 | + print $globalMapRefresh*1000*2; |
|
621 | +} else { |
|
622 | + print '60000'; |
|
623 | +} |
|
624 | +?>); |
|
610 | 625 | <?php |
611 | 626 | } |
612 | 627 | ?> |
@@ -704,7 +719,12 @@ discard block |
||
704 | 719 | } |
705 | 720 | } |
706 | 721 | } |
707 | - ,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
722 | + ,<?php if (isset($globalMapRefresh)) { |
|
723 | + print $globalMapRefresh*1000; |
|
724 | +} else { |
|
725 | + print '30000'; |
|
726 | +} |
|
727 | +?>); |
|
708 | 728 | } else { |
709 | 729 | //var widget = new Cesium.CesiumWidget('archivebox'); |
710 | 730 | // var timeline = new Cesium.Timeline(viewer); |
@@ -723,7 +743,12 @@ discard block |
||
723 | 743 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
724 | 744 | ?> |
725 | 745 | update_atcLayer(); |
726 | -setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
746 | +setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) { |
|
747 | + print $globalMapRefresh*1000*2; |
|
748 | +} else { |
|
749 | + print '60000'; |
|
750 | +} |
|
751 | +?>); |
|
727 | 752 | <?php |
728 | 753 | } |
729 | 754 | ?> |