@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
57 | + if ($globalDebug) { |
|
58 | + echo "Update last seen tracked data...\n"; |
|
59 | + } |
|
58 | 60 | foreach ($this->all_tracked as $key => $flight) { |
59 | 61 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 62 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -68,13 +70,17 @@ discard block |
||
68 | 70 | public function del() { |
69 | 71 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 72 | // Delete old infos |
71 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
73 | + if ($globalDebug) { |
|
74 | + echo 'Delete old values and update latest data...'."\n"; |
|
75 | + } |
|
72 | 76 | foreach ($this->all_tracked as $key => $flight) { |
73 | 77 | if (isset($flight['lastupdate'])) { |
74 | 78 | if ($flight['lastupdate'] < (time()-3000)) { |
75 | 79 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 80 | if (isset($this->all_tracked[$key]['id'])) { |
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + if ($globalDebug) { |
|
82 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
83 | + } |
|
78 | 84 | /* |
79 | 85 | $MarineLive = new MarineLive(); |
80 | 86 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -84,7 +90,9 @@ discard block |
||
84 | 90 | $Marine = new Marine($this->db); |
85 | 91 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | 92 | $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']); |
87 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
93 | + if ($globalDebug && $result != 'success') { |
|
94 | + echo '!!! ERROR : '.$result."\n"; |
|
95 | + } |
|
88 | 96 | } |
89 | 97 | // Put in archive |
90 | 98 | // $Marine->db = null; |
@@ -98,7 +106,9 @@ discard block |
||
98 | 106 | |
99 | 107 | public function add($line) { |
100 | 108 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
101 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
109 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
110 | + $globalCoordMinChange = '0.02'; |
|
111 | + } |
|
102 | 112 | date_default_timezone_set('UTC'); |
103 | 113 | $dataFound = false; |
104 | 114 | $send = false; |
@@ -112,20 +122,30 @@ discard block |
||
112 | 122 | // Increment message number |
113 | 123 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | 124 | $current_date = date('Y-m-d'); |
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
125 | + if (isset($line['source_name'])) { |
|
126 | + $source = $line['source_name']; |
|
127 | + } else { |
|
128 | + $source = ''; |
|
129 | + } |
|
130 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
131 | + $source = $line['format_source']; |
|
132 | + } |
|
118 | 133 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
119 | 134 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
120 | 135 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } else { |
|
137 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
138 | + } |
|
122 | 139 | } |
123 | 140 | |
124 | 141 | |
125 | 142 | $Common = new Common(); |
126 | 143 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
144 | + if (!isset($line['id'])) { |
|
145 | + $id = trim($line['mmsi']); |
|
146 | + } else { |
|
147 | + $id = trim($line['id']); |
|
148 | + } |
|
129 | 149 | |
130 | 150 | if (!isset($this->all_tracked[$id])) { |
131 | 151 | $this->all_tracked[$id] = array(); |
@@ -133,10 +153,16 @@ discard block |
||
133 | 153 | $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' => '')); |
134 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
135 | 155 | if (!isset($line['id'])) { |
136 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
156 | + if (!isset($globalDaemon)) { |
|
157 | + $globalDaemon = TRUE; |
|
158 | + } |
|
137 | 159 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
160 | + } else { |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
162 | + } |
|
163 | + if ($globalAllTracked !== FALSE) { |
|
164 | + $dataFound = true; |
|
165 | + } |
|
140 | 166 | } |
141 | 167 | |
142 | 168 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -186,34 +212,49 @@ discard block |
||
186 | 212 | $Marine = new Marine($this->db); |
187 | 213 | $fromsource = NULL; |
188 | 214 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
189 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
215 | + if ($globalDebug && $result != 'success') { |
|
216 | + echo '!!! ERROR : '.$result."\n"; |
|
217 | + } |
|
190 | 218 | $Marine->db = null; |
191 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
219 | + if ($globalDebugTimeElapsed) { |
|
220 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
221 | + } |
|
192 | 222 | } |
193 | 223 | } |
194 | 224 | } |
195 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
225 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
226 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
227 | + } |
|
196 | 228 | } |
197 | 229 | |
198 | 230 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
199 | 231 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
200 | 232 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
201 | 233 | } else { |
202 | - 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"; |
|
203 | - 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"; |
|
234 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
235 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
236 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
237 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
238 | + } |
|
204 | 239 | return ''; |
205 | 240 | } |
206 | 241 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
207 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
244 | + } |
|
208 | 245 | return ''; |
209 | 246 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
210 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
247 | + if ($globalDebug) { |
|
248 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
249 | + } |
|
211 | 250 | return ''; |
212 | 251 | } elseif (!isset($line['datetime'])) { |
213 | 252 | date_default_timezone_set('UTC'); |
214 | 253 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
215 | 254 | } else { |
216 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
255 | + if ($globalDebug) { |
|
256 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
257 | + } |
|
217 | 258 | return ''; |
218 | 259 | } |
219 | 260 | |
@@ -226,14 +267,21 @@ discard block |
||
226 | 267 | if ($distance > 1000 && $distance < 10000) { |
227 | 268 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
228 | 269 | $speed = $speed*3.6; |
229 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
230 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
270 | + if ($speed < 1000) { |
|
271 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
272 | + } |
|
273 | + if ($globalDebug) { |
|
274 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
275 | + } |
|
231 | 276 | } |
232 | 277 | } |
233 | 278 | |
234 | 279 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
235 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
236 | - else unset($timediff); |
|
280 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
281 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
282 | + } else { |
|
283 | + unset($timediff); |
|
284 | + } |
|
237 | 285 | 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')))) { |
238 | 286 | 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'])) { |
239 | 287 | 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'])) { |
@@ -241,22 +289,32 @@ discard block |
||
241 | 289 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
242 | 290 | $this->all_tracked[$id]['putinarchive'] = true; |
243 | 291 | |
244 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
292 | + if ($globalDebug) { |
|
293 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
294 | + } |
|
245 | 295 | $timeelapsed = microtime(true); |
246 | 296 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
247 | 297 | $Marine = new Marine($this->db); |
248 | 298 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
249 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
299 | + if (!empty($all_country)) { |
|
300 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
301 | + } |
|
250 | 302 | $Marine->db = null; |
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
303 | + if ($globalDebugTimeElapsed) { |
|
304 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
305 | + } |
|
252 | 306 | } |
253 | 307 | $this->tmd = 0; |
254 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
308 | + if ($globalDebug) { |
|
309 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
310 | + } |
|
255 | 311 | } |
256 | 312 | } |
257 | 313 | |
258 | 314 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
259 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
315 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
316 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
317 | + } |
|
260 | 318 | 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') { |
261 | 319 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
262 | 320 | $dataFound = true; |
@@ -265,8 +323,12 @@ discard block |
||
265 | 323 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
266 | 324 | } |
267 | 325 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
268 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
269 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
326 | + if ($line['longitude'] > 180) { |
|
327 | + $line['longitude'] = $line['longitude'] - 360; |
|
328 | + } |
|
329 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
330 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
331 | + } |
|
270 | 332 | 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') { |
271 | 333 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
272 | 334 | $dataFound = true; |
@@ -284,7 +346,9 @@ discard block |
||
284 | 346 | } |
285 | 347 | } |
286 | 348 | if (isset($line['last_update']) && $line['last_update'] != '') { |
287 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
349 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
350 | + $dataFound = true; |
|
351 | + } |
|
288 | 352 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
289 | 353 | } |
290 | 354 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -314,15 +378,21 @@ discard block |
||
314 | 378 | } |
315 | 379 | |
316 | 380 | if (isset($line['heading']) && $line['heading'] != '') { |
317 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
381 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
382 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
383 | + } |
|
318 | 384 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
319 | 385 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
320 | 386 | //$dataFound = true; |
321 | 387 | } 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']) { |
322 | 388 | $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']); |
323 | 389 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
324 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
390 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
391 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
392 | + } |
|
393 | + if ($globalDebug) { |
|
394 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
395 | + } |
|
326 | 396 | } |
327 | 397 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
328 | 398 | |
@@ -334,23 +404,38 @@ discard block |
||
334 | 404 | 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'])) { |
335 | 405 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
336 | 406 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
337 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
407 | + if ($globalDebug) { |
|
408 | + echo "Check if aircraft is already in DB..."; |
|
409 | + } |
|
338 | 410 | $timeelapsed = microtime(true); |
339 | 411 | $MarineLive = new MarineLive($this->db); |
340 | 412 | if (isset($line['id'])) { |
341 | 413 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
342 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
414 | + if ($globalDebugTimeElapsed) { |
|
415 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
416 | + } |
|
343 | 417 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
344 | 418 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
345 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
419 | + if ($globalDebugTimeElapsed) { |
|
420 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
421 | + } |
|
346 | 422 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
347 | 423 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
348 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
349 | - } else $recent_ident = ''; |
|
424 | + if ($globalDebugTimeElapsed) { |
|
425 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
426 | + } |
|
427 | + } else { |
|
428 | + $recent_ident = ''; |
|
429 | + } |
|
350 | 430 | $MarineLive->db=null; |
351 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
352 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
353 | - } else $recent_ident = ''; |
|
431 | + if ($globalDebug && $recent_ident == '') { |
|
432 | + echo " Not in DB.\n"; |
|
433 | + } elseif ($globalDebug && $recent_ident != '') { |
|
434 | + echo " Already in DB.\n"; |
|
435 | + } |
|
436 | + } else { |
|
437 | + $recent_ident = ''; |
|
438 | + } |
|
354 | 439 | } else { |
355 | 440 | $recent_ident = ''; |
356 | 441 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -358,30 +443,44 @@ discard block |
||
358 | 443 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
359 | 444 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
360 | 445 | { |
361 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
446 | + if ($globalDebug) { |
|
447 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
448 | + } |
|
362 | 449 | //adds the spotter data for the archive |
363 | 450 | $highlight = ''; |
364 | - 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'))); |
|
451 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
452 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
453 | + } |
|
365 | 454 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
366 | 455 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
367 | 456 | $timeelapsed = microtime(true); |
368 | 457 | $Marine = new Marine($this->db); |
369 | 458 | $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']); |
370 | 459 | $Marine->db = null; |
371 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
372 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
460 | + if ($globalDebug && isset($result)) { |
|
461 | + echo $result."\n"; |
|
462 | + } |
|
463 | + if ($globalDebugTimeElapsed) { |
|
464 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
465 | + } |
|
373 | 466 | } |
374 | 467 | } |
375 | 468 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
376 | 469 | // Add source stat in DB |
377 | 470 | $Stats = new Stats($this->db); |
378 | 471 | if (!empty($this->stats)) { |
379 | - if ($globalDebug) echo 'Add source stats : '; |
|
472 | + if ($globalDebug) { |
|
473 | + echo 'Add source stats : '; |
|
474 | + } |
|
380 | 475 | foreach($this->stats as $date => $data) { |
381 | 476 | foreach($data as $source => $sourced) { |
382 | 477 | //print_r($sourced); |
383 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
384 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
478 | + if (isset($sourced['polar'])) { |
|
479 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
480 | + } |
|
481 | + if (isset($sourced['hist'])) { |
|
482 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
483 | + } |
|
385 | 484 | if (isset($sourced['msg'])) { |
386 | 485 | if (time() - $sourced['msg']['date'] > 10) { |
387 | 486 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -394,7 +493,9 @@ discard block |
||
394 | 493 | unset($this->stats[$date]); |
395 | 494 | } |
396 | 495 | } |
397 | - if ($globalDebug) echo 'Done'."\n"; |
|
496 | + if ($globalDebug) { |
|
497 | + echo 'Done'."\n"; |
|
498 | + } |
|
398 | 499 | } |
399 | 500 | $Stats->db = null; |
400 | 501 | } |
@@ -404,13 +505,17 @@ discard block |
||
404 | 505 | $this->all_tracked[$id]['addedMarine'] = 1; |
405 | 506 | //print_r($this->all_tracked[$id]); |
406 | 507 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
407 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
508 | + if ($globalDebug) { |
|
509 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
510 | + } |
|
408 | 511 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
409 | 512 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
410 | 513 | $MarineLive = new MarineLive($this->db); |
411 | 514 | $MarineLive->deleteLiveMarineData(); |
412 | 515 | $MarineLive->db=null; |
413 | - if ($globalDebug) echo " Done\n"; |
|
516 | + if ($globalDebug) { |
|
517 | + echo " Done\n"; |
|
518 | + } |
|
414 | 519 | } |
415 | 520 | $this->last_delete = time(); |
416 | 521 | } |
@@ -436,15 +541,21 @@ discard block |
||
436 | 541 | |
437 | 542 | if (!$ignoreImport) { |
438 | 543 | 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'])) { |
439 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
544 | + if ($globalDebug) { |
|
545 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
546 | + } |
|
440 | 547 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
441 | 548 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 549 | $timeelapsed = microtime(true); |
443 | 550 | $MarineLive = new MarineLive($this->db); |
444 | 551 | $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']); |
445 | 552 | $MarineLive->db = null; |
446 | - if ($globalDebug) echo $result."\n"; |
|
447 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
553 | + if ($globalDebug) { |
|
554 | + echo $result."\n"; |
|
555 | + } |
|
556 | + if ($globalDebugTimeElapsed) { |
|
557 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
558 | + } |
|
448 | 559 | } |
449 | 560 | } |
450 | 561 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -456,7 +567,9 @@ discard block |
||
456 | 567 | |
457 | 568 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
458 | 569 | $source = $this->all_tracked[$id]['source_name']; |
459 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
570 | + if ($source == '') { |
|
571 | + $source = $this->all_tracked[$id]['format_source']; |
|
572 | + } |
|
460 | 573 | if (!isset($this->source_location[$source])) { |
461 | 574 | $Location = new Source($this->db); |
462 | 575 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -477,7 +590,9 @@ discard block |
||
477 | 590 | $stats_heading = round($stats_heading/22.5); |
478 | 591 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
479 | 592 | $current_date = date('Y-m-d'); |
480 | - if ($stats_heading == 16) $stats_heading = 0; |
|
593 | + if ($stats_heading == 16) { |
|
594 | + $stats_heading = 0; |
|
595 | + } |
|
481 | 596 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
482 | 597 | for ($i=0;$i<=15;$i++) { |
483 | 598 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -495,7 +610,9 @@ discard block |
||
495 | 610 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
496 | 611 | end($this->stats[$current_date][$source]['hist']); |
497 | 612 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
498 | - } else $mini = 0; |
|
613 | + } else { |
|
614 | + $mini = 0; |
|
615 | + } |
|
499 | 616 | for ($i=$mini;$i<=$distance;$i+=10) { |
500 | 617 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
501 | 618 | } |
@@ -507,19 +624,27 @@ discard block |
||
507 | 624 | |
508 | 625 | |
509 | 626 | $this->all_tracked[$id]['lastupdate'] = time(); |
510 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
511 | - } 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"; |
|
627 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
628 | + $send = true; |
|
629 | + } |
|
630 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
631 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
632 | + } |
|
512 | 633 | //$this->del(); |
513 | 634 | |
514 | 635 | |
515 | 636 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
516 | 637 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
517 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
638 | + if ($globalDebug) { |
|
639 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
640 | + } |
|
518 | 641 | $MarineLive = new MarineLive($this->db); |
519 | 642 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
520 | 643 | $MarineLive->db = null; |
521 | 644 | //MarineLive->deleteLiveMarineData(); |
522 | - if ($globalDebug) echo " Done\n"; |
|
645 | + if ($globalDebug) { |
|
646 | + echo " Done\n"; |
|
647 | + } |
|
523 | 648 | } |
524 | 649 | $this->last_delete_hourly = time(); |
525 | 650 | } |
@@ -528,7 +653,9 @@ discard block |
||
528 | 653 | //$ignoreImport = false; |
529 | 654 | } |
530 | 655 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
531 | - if ($send) return $this->all_tracked[$id]; |
|
656 | + if ($send) { |
|
657 | + return $this->all_tracked[$id]; |
|
658 | + } |
|
532 | 659 | } |
533 | 660 | } |
534 | 661 | } |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | $temp += 1; |
36 | 36 | $flat = (float)($temp / (60.0 * 10000.0)); |
37 | 37 | $flat *= -1.0; |
38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
38 | + } else { |
|
39 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
40 | + } |
|
39 | 41 | return $flat; // float |
40 | 42 | } |
41 | 43 | |
@@ -47,7 +49,9 @@ discard block |
||
47 | 49 | $temp += 1; |
48 | 50 | $flon = (float)($temp / (60.0 * 10000.0)); |
49 | 51 | $flon *= -1.0; |
50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
52 | + } else { |
|
53 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
54 | + } |
|
51 | 55 | return $flon; |
52 | 56 | } |
53 | 57 | |
@@ -70,10 +74,8 @@ discard block |
||
70 | 74 | */ |
71 | 75 | private function asciidec_2_8bit($ascii) { |
72 | 76 | //only process in the following range: 48-87, 96-119 |
73 | - if ($ascii < 48) { } |
|
74 | - else { |
|
75 | - if($ascii>119) { } |
|
76 | - else { |
|
77 | + if ($ascii < 48) { } else { |
|
78 | + if($ascii>119) { } else { |
|
77 | 79 | if ($ascii>87 && $ascii<96) ; |
78 | 80 | else { |
79 | 81 | $ascii=$ascii+40; |
@@ -175,7 +177,9 @@ discard block |
||
175 | 177 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
176 | 178 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
177 | 179 | $ro->heading = bindec(substr($_aisdata,124,9)); |
178 | - if ($ro->heading == 511) $ro->heading = ''; |
|
180 | + if ($ro->heading == 511) { |
|
181 | + $ro->heading = ''; |
|
182 | + } |
|
179 | 183 | $ro->cls = 2; // class B |
180 | 184 | } else if ($ro->id == 19) { |
181 | 185 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -185,7 +189,9 @@ discard block |
||
185 | 189 | $ro->name = $this->binchar($_aisdata,143,120); |
186 | 190 | $ro->cls = 2; // class B |
187 | 191 | $ro->heading = bindec(substr($_aisdata,124,9)); |
188 | - if ($ro->heading == 511) $ro->heading = ''; |
|
192 | + if ($ro->heading == 511) { |
|
193 | + $ro->heading = ''; |
|
194 | + } |
|
189 | 195 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
190 | 196 | $ro->type = $this->getShipType($ro->typeid); |
191 | 197 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -216,9 +222,13 @@ discard block |
||
216 | 222 | $ro->cls = 2; // class B |
217 | 223 | } else if ($ro->id == 27) { |
218 | 224 | $ro->cog = bindec(substr($_aisdata,85,9)); |
219 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
225 | + if ($ro->cog == 511) { |
|
226 | + $ro->cog = 0.0; |
|
227 | + } |
|
220 | 228 | $ro->sog = bindec(substr($_aisdata,79,6)); |
221 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
229 | + if ($ro->sog == 63) { |
|
230 | + $ro->sog = 0.0; |
|
231 | + } |
|
222 | 232 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
223 | 233 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
224 | 234 | $ro->cls = 1; // class A |
@@ -267,88 +277,171 @@ discard block |
||
267 | 277 | } |
268 | 278 | |
269 | 279 | public function getShipType($code) { |
270 | - if ($code == 0) return 'Not available (default)'; |
|
271 | - elseif ($code >= 1 && $code <= 19) return 'Reserved for future use'; |
|
272 | - elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type'; |
|
273 | - elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A'; |
|
274 | - elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B'; |
|
275 | - elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C'; |
|
276 | - elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D'; |
|
277 | - elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use'; |
|
278 | - elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use'; |
|
279 | - elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use'; |
|
280 | - elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use'; |
|
281 | - elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use'; |
|
282 | - elseif ($code == 30) return 'Fishing'; |
|
283 | - elseif ($code == 31) return 'Towing'; |
|
284 | - elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
285 | - elseif ($code == 33) return 'Dredging or underwater ops'; |
|
286 | - elseif ($code == 34) return 'Diving ops'; |
|
287 | - elseif ($code == 35) return 'Military ops'; |
|
288 | - elseif ($code == 36) return 'Sailing'; |
|
289 | - elseif ($code == 37) return 'Pleasure Craft'; |
|
290 | - elseif ($code == 38) return 'Reserved'; |
|
291 | - elseif ($code == 39) return 'Reserved'; |
|
292 | - elseif ($code == 40) return 'High speed craft (HSC), all ships of this type'; |
|
293 | - elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A'; |
|
294 | - elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B'; |
|
295 | - elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C'; |
|
296 | - elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D'; |
|
297 | - elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use'; |
|
298 | - elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use'; |
|
299 | - elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use'; |
|
300 | - elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use'; |
|
301 | - elseif ($code == 49) return 'High speed craft (HSC), No additional information'; |
|
302 | - elseif ($code == 50) return 'Pilot Vessel'; |
|
303 | - elseif ($code == 51) return 'Search and Rescue vessel'; |
|
304 | - elseif ($code == 52) return 'Tug'; |
|
305 | - elseif ($code == 53) return 'Port Tender'; |
|
306 | - elseif ($code == 54) return 'Anti-pollution equipment'; |
|
307 | - elseif ($code == 55) return 'Law Enforcement'; |
|
308 | - elseif ($code == 56) return 'Spare - Local Vessel'; |
|
309 | - elseif ($code == 57) return 'Spare - Local Vessel'; |
|
310 | - elseif ($code == 58) return 'Medical Transport'; |
|
311 | - elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18'; |
|
312 | - elseif ($code == 60) return 'Passenger, all ships of this type'; |
|
313 | - elseif ($code == 61) return 'Passenger, Hazardous category A'; |
|
314 | - elseif ($code == 62) return 'Passenger, Hazardous category B'; |
|
315 | - elseif ($code == 63) return 'Passenger, Hazardous category C'; |
|
316 | - elseif ($code == 64) return 'Passenger, Hazardous category D'; |
|
317 | - elseif ($code == 65) return 'Passenger, Reserved for future use'; |
|
318 | - elseif ($code == 66) return 'Passenger, Reserved for future use'; |
|
319 | - elseif ($code == 67) return 'Passenger, Reserved for future use'; |
|
320 | - elseif ($code == 68) return 'Passenger, Reserved for future use'; |
|
321 | - elseif ($code == 69) return 'Passenger, No additional information'; |
|
322 | - elseif ($code == 70) return 'Cargo, all ships of this type'; |
|
323 | - elseif ($code == 71) return 'Cargo, Hazardous category A'; |
|
324 | - elseif ($code == 72) return 'Cargo, Hazardous category B'; |
|
325 | - elseif ($code == 73) return 'Cargo, Hazardous category C'; |
|
326 | - elseif ($code == 74) return 'Cargo, Hazardous category D'; |
|
327 | - elseif ($code == 75) return 'Cargo, Reserved for future use'; |
|
328 | - elseif ($code == 76) return 'Cargo, Reserved for future use'; |
|
329 | - elseif ($code == 77) return 'Cargo, Reserved for future use'; |
|
330 | - elseif ($code == 78) return 'Cargo, Reserved for future use'; |
|
331 | - elseif ($code == 79) return 'Cargo, No additional information'; |
|
332 | - elseif ($code == 80) return 'Tanker, all ships of this type'; |
|
333 | - elseif ($code == 81) return 'Tanker, Hazardous category A'; |
|
334 | - elseif ($code == 82) return 'Tanker, Hazardous category B'; |
|
335 | - elseif ($code == 83) return 'Tanker, Hazardous category C'; |
|
336 | - elseif ($code == 84) return 'Tanker, Hazardous category D'; |
|
337 | - elseif ($code == 85) return 'Tanker, Reserved for future use'; |
|
338 | - elseif ($code == 86) return 'Tanker, Reserved for future use'; |
|
339 | - elseif ($code == 87) return 'Tanker, Reserved for future use'; |
|
340 | - elseif ($code == 88) return 'Tanker, Reserved for future use'; |
|
341 | - elseif ($code == 89) return 'Tanker, No additional information'; |
|
342 | - elseif ($code == 90) return 'Other Type, all ships of this type'; |
|
343 | - elseif ($code == 91) return 'Other Type, Hazardous category A'; |
|
344 | - elseif ($code == 92) return 'Other Type, Hazardous category B'; |
|
345 | - elseif ($code == 93) return 'Other Type, Hazardous category C'; |
|
346 | - elseif ($code == 94) return 'Other Type, Hazardous category D'; |
|
347 | - elseif ($code == 95) return 'Other Type, Reserved for future use'; |
|
348 | - elseif ($code == 96) return 'Other Type, Reserved for future use'; |
|
349 | - elseif ($code == 97) return 'Other Type, Reserved for future use'; |
|
350 | - elseif ($code == 98) return 'Other Type, Reserved for future use'; |
|
351 | - elseif ($code == 99) return 'Other Type, no additional information'; |
|
280 | + if ($code == 0) { |
|
281 | + return 'Not available (default)'; |
|
282 | + } elseif ($code >= 1 && $code <= 19) { |
|
283 | + return 'Reserved for future use'; |
|
284 | + } elseif ($code == 20) { |
|
285 | + return 'Wing in ground (WIG), all ships of this type'; |
|
286 | + } elseif ($code == 21) { |
|
287 | + return 'Wing in ground (WIG), Hazardous category A'; |
|
288 | + } elseif ($code == 22) { |
|
289 | + return 'Wing in ground (WIG), Hazardous category B'; |
|
290 | + } elseif ($code == 23) { |
|
291 | + return 'Wing in ground (WIG), Hazardous category C'; |
|
292 | + } elseif ($code == 24) { |
|
293 | + return 'Wing in ground (WIG), Hazardous category D'; |
|
294 | + } elseif ($code == 25) { |
|
295 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
296 | + } elseif ($code == 26) { |
|
297 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
298 | + } elseif ($code == 27) { |
|
299 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
300 | + } elseif ($code == 28) { |
|
301 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
302 | + } elseif ($code == 29) { |
|
303 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
304 | + } elseif ($code == 30) { |
|
305 | + return 'Fishing'; |
|
306 | + } elseif ($code == 31) { |
|
307 | + return 'Towing'; |
|
308 | + } elseif ($code == 32) { |
|
309 | + return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
310 | + } elseif ($code == 33) { |
|
311 | + return 'Dredging or underwater ops'; |
|
312 | + } elseif ($code == 34) { |
|
313 | + return 'Diving ops'; |
|
314 | + } elseif ($code == 35) { |
|
315 | + return 'Military ops'; |
|
316 | + } elseif ($code == 36) { |
|
317 | + return 'Sailing'; |
|
318 | + } elseif ($code == 37) { |
|
319 | + return 'Pleasure Craft'; |
|
320 | + } elseif ($code == 38) { |
|
321 | + return 'Reserved'; |
|
322 | + } elseif ($code == 39) { |
|
323 | + return 'Reserved'; |
|
324 | + } elseif ($code == 40) { |
|
325 | + return 'High speed craft (HSC), all ships of this type'; |
|
326 | + } elseif ($code == 41) { |
|
327 | + return 'High speed craft (HSC), Hazardous category A'; |
|
328 | + } elseif ($code == 42) { |
|
329 | + return 'High speed craft (HSC), Hazardous category B'; |
|
330 | + } elseif ($code == 43) { |
|
331 | + return 'High speed craft (HSC), Hazardous category C'; |
|
332 | + } elseif ($code == 44) { |
|
333 | + return 'High speed craft (HSC), Hazardous category D'; |
|
334 | + } elseif ($code == 45) { |
|
335 | + return 'High speed craft (HSC), Reserved for future use'; |
|
336 | + } elseif ($code == 46) { |
|
337 | + return 'High speed craft (HSC), Reserved for future use'; |
|
338 | + } elseif ($code == 47) { |
|
339 | + return 'High speed craft (HSC), Reserved for future use'; |
|
340 | + } elseif ($code == 48) { |
|
341 | + return 'High speed craft (HSC), Reserved for future use'; |
|
342 | + } elseif ($code == 49) { |
|
343 | + return 'High speed craft (HSC), No additional information'; |
|
344 | + } elseif ($code == 50) { |
|
345 | + return 'Pilot Vessel'; |
|
346 | + } elseif ($code == 51) { |
|
347 | + return 'Search and Rescue vessel'; |
|
348 | + } elseif ($code == 52) { |
|
349 | + return 'Tug'; |
|
350 | + } elseif ($code == 53) { |
|
351 | + return 'Port Tender'; |
|
352 | + } elseif ($code == 54) { |
|
353 | + return 'Anti-pollution equipment'; |
|
354 | + } elseif ($code == 55) { |
|
355 | + return 'Law Enforcement'; |
|
356 | + } elseif ($code == 56) { |
|
357 | + return 'Spare - Local Vessel'; |
|
358 | + } elseif ($code == 57) { |
|
359 | + return 'Spare - Local Vessel'; |
|
360 | + } elseif ($code == 58) { |
|
361 | + return 'Medical Transport'; |
|
362 | + } elseif ($code == 59) { |
|
363 | + return 'Noncombatant ship according to RR Resolution No. 18'; |
|
364 | + } elseif ($code == 60) { |
|
365 | + return 'Passenger, all ships of this type'; |
|
366 | + } elseif ($code == 61) { |
|
367 | + return 'Passenger, Hazardous category A'; |
|
368 | + } elseif ($code == 62) { |
|
369 | + return 'Passenger, Hazardous category B'; |
|
370 | + } elseif ($code == 63) { |
|
371 | + return 'Passenger, Hazardous category C'; |
|
372 | + } elseif ($code == 64) { |
|
373 | + return 'Passenger, Hazardous category D'; |
|
374 | + } elseif ($code == 65) { |
|
375 | + return 'Passenger, Reserved for future use'; |
|
376 | + } elseif ($code == 66) { |
|
377 | + return 'Passenger, Reserved for future use'; |
|
378 | + } elseif ($code == 67) { |
|
379 | + return 'Passenger, Reserved for future use'; |
|
380 | + } elseif ($code == 68) { |
|
381 | + return 'Passenger, Reserved for future use'; |
|
382 | + } elseif ($code == 69) { |
|
383 | + return 'Passenger, No additional information'; |
|
384 | + } elseif ($code == 70) { |
|
385 | + return 'Cargo, all ships of this type'; |
|
386 | + } elseif ($code == 71) { |
|
387 | + return 'Cargo, Hazardous category A'; |
|
388 | + } elseif ($code == 72) { |
|
389 | + return 'Cargo, Hazardous category B'; |
|
390 | + } elseif ($code == 73) { |
|
391 | + return 'Cargo, Hazardous category C'; |
|
392 | + } elseif ($code == 74) { |
|
393 | + return 'Cargo, Hazardous category D'; |
|
394 | + } elseif ($code == 75) { |
|
395 | + return 'Cargo, Reserved for future use'; |
|
396 | + } elseif ($code == 76) { |
|
397 | + return 'Cargo, Reserved for future use'; |
|
398 | + } elseif ($code == 77) { |
|
399 | + return 'Cargo, Reserved for future use'; |
|
400 | + } elseif ($code == 78) { |
|
401 | + return 'Cargo, Reserved for future use'; |
|
402 | + } elseif ($code == 79) { |
|
403 | + return 'Cargo, No additional information'; |
|
404 | + } elseif ($code == 80) { |
|
405 | + return 'Tanker, all ships of this type'; |
|
406 | + } elseif ($code == 81) { |
|
407 | + return 'Tanker, Hazardous category A'; |
|
408 | + } elseif ($code == 82) { |
|
409 | + return 'Tanker, Hazardous category B'; |
|
410 | + } elseif ($code == 83) { |
|
411 | + return 'Tanker, Hazardous category C'; |
|
412 | + } elseif ($code == 84) { |
|
413 | + return 'Tanker, Hazardous category D'; |
|
414 | + } elseif ($code == 85) { |
|
415 | + return 'Tanker, Reserved for future use'; |
|
416 | + } elseif ($code == 86) { |
|
417 | + return 'Tanker, Reserved for future use'; |
|
418 | + } elseif ($code == 87) { |
|
419 | + return 'Tanker, Reserved for future use'; |
|
420 | + } elseif ($code == 88) { |
|
421 | + return 'Tanker, Reserved for future use'; |
|
422 | + } elseif ($code == 89) { |
|
423 | + return 'Tanker, No additional information'; |
|
424 | + } elseif ($code == 90) { |
|
425 | + return 'Other Type, all ships of this type'; |
|
426 | + } elseif ($code == 91) { |
|
427 | + return 'Other Type, Hazardous category A'; |
|
428 | + } elseif ($code == 92) { |
|
429 | + return 'Other Type, Hazardous category B'; |
|
430 | + } elseif ($code == 93) { |
|
431 | + return 'Other Type, Hazardous category C'; |
|
432 | + } elseif ($code == 94) { |
|
433 | + return 'Other Type, Hazardous category D'; |
|
434 | + } elseif ($code == 95) { |
|
435 | + return 'Other Type, Reserved for future use'; |
|
436 | + } elseif ($code == 96) { |
|
437 | + return 'Other Type, Reserved for future use'; |
|
438 | + } elseif ($code == 97) { |
|
439 | + return 'Other Type, Reserved for future use'; |
|
440 | + } elseif ($code == 98) { |
|
441 | + return 'Other Type, Reserved for future use'; |
|
442 | + } elseif ($code == 99) { |
|
443 | + return 'Other Type, no additional information'; |
|
444 | + } |
|
352 | 445 | } |
353 | 446 | |
354 | 447 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -386,11 +479,20 @@ discard block |
||
386 | 479 | // assume 1st ! is valid |
387 | 480 | // find * ensure that it is at correct position |
388 | 481 | $end = strrpos ( $rawdata , '*' ); |
389 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
482 | + if ($end === FALSE) { |
|
483 | + return -1; |
|
484 | + } |
|
485 | + // check for NULLS!!! |
|
390 | 486 | $cs = substr( $rawdata, $end + 1 ); |
391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
487 | + if ( strlen($cs) != 2 ) { |
|
488 | + return -1; |
|
489 | + } |
|
490 | + // correct cs length |
|
392 | 491 | $dcs = (int)hexdec( $cs ); |
393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
492 | + for ( $alias=1; $alias<$end; $alias++) { |
|
493 | + $chksum ^= ord( $rawdata[$alias] ); |
|
494 | + } |
|
495 | + // perform XOR for NMEA checksum |
|
394 | 496 | if ( $chksum == $dcs ) { // NMEA checksum pass |
395 | 497 | $pcs = explode(',', $rawdata); |
396 | 498 | // !AI??? identifier |
@@ -401,8 +503,14 @@ discard block |
||
401 | 503 | $num_seq = (int)$pcs[1]; // number of sequences |
402 | 504 | $seq = (int)$pcs[2]; // get sequence |
403 | 505 | // get msg sequence id |
404 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
405 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
506 | + if ($pcs[3] == '') { |
|
507 | + $msg_sid = -1; |
|
508 | + } |
|
509 | + // non-multipart message, set to -1 |
|
510 | + else { |
|
511 | + $msg_sid = (int)$pcs[3]; |
|
512 | + } |
|
513 | + // multipart message |
|
406 | 514 | $ais_ch = $pcs[4]; // get AIS channel |
407 | 515 | // message sequence checking |
408 | 516 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -463,10 +571,18 @@ discard block |
||
463 | 571 | //DEBUG echo "[$start $end $tst]\n"; |
464 | 572 | $result = $this->process_ais_raw( $tst, "" ); |
465 | 573 | $last_pos = $end + 1; |
466 | - } else break; |
|
574 | + } else { |
|
575 | + break; |
|
576 | + } |
|
467 | 577 | } |
468 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
469 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
578 | + if ($last_pos > 0) { |
|
579 | + $cbuf = substr($cbuf, $last_pos); |
|
580 | + } |
|
581 | + // move... |
|
582 | + if (strlen($cbuf) > 1024) { |
|
583 | + $cbuf = ""; |
|
584 | + } |
|
585 | + // prevent overflow simple mode... |
|
470 | 586 | return $result; |
471 | 587 | } |
472 | 588 | |
@@ -486,7 +602,9 @@ discard block |
||
486 | 602 | if ($lat<0.0) { |
487 | 603 | $lat = -$lat; |
488 | 604 | $neg=true; |
489 | - } else $neg=false; |
|
605 | + } else { |
|
606 | + $neg=false; |
|
607 | + } |
|
490 | 608 | $latd = 0x00000000; |
491 | 609 | $latd = intval ($lat * 600000.0); |
492 | 610 | if ($neg==true) { |
@@ -502,7 +620,9 @@ discard block |
||
502 | 620 | if ($lon<0.0) { |
503 | 621 | $lon = -$lon; |
504 | 622 | $neg=true; |
505 | - } else $neg=false; |
|
623 | + } else { |
|
624 | + $neg=false; |
|
625 | + } |
|
506 | 626 | $lond = 0x00000000; |
507 | 627 | $lond = intval ($lon * 600000.0); |
508 | 628 | if ($neg==true) { |
@@ -515,9 +635,14 @@ discard block |
||
515 | 635 | |
516 | 636 | private function char2bin($name, $max_len) { |
517 | 637 | $len = strlen($name); |
518 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
519 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
520 | - else $pad = ''; |
|
638 | + if ($len > $max_len) { |
|
639 | + $name = substr($name,0,$max_len); |
|
640 | + } |
|
641 | + if ($len < $max_len) { |
|
642 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
643 | + } else { |
|
644 | + $pad = ''; |
|
645 | + } |
|
521 | 646 | $rv = ''; |
522 | 647 | $ais_chars = array( |
523 | 648 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -530,9 +655,12 @@ discard block |
||
530 | 655 | ); |
531 | 656 | // " |
532 | 657 | $_a = str_split($name); |
533 | - if ($_a) foreach ($_a as $_1) { |
|
658 | + if ($_a) { |
|
659 | + foreach ($_a as $_1) { |
|
534 | 660 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
535 | - else $dec = 0; |
|
661 | + } else { |
|
662 | + $dec = 0; |
|
663 | + } |
|
536 | 664 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
537 | 665 | $rv .= $bin; |
538 | 666 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -544,7 +672,9 @@ discard block |
||
544 | 672 | $len_bit = strlen($_enc); |
545 | 673 | $rem6 = $len_bit % 6; |
546 | 674 | $pad6_len = 0; |
547 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
675 | + if ($rem6) { |
|
676 | + $pad6_len = 6 - $rem6; |
|
677 | + } |
|
548 | 678 | //echo $pad6_len.'<br>'; |
549 | 679 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
550 | 680 | $len_enc = strlen($_enc) / 6; |
@@ -553,8 +683,11 @@ discard block |
||
553 | 683 | for ($i=0; $i<$len_enc; $i++) { |
554 | 684 | $offset = $i * 6; |
555 | 685 | $dec = bindec(substr($_enc,$offset,6)); |
556 | - if ($dec < 40) $dec += 48; |
|
557 | - else $dec += 56; |
|
686 | + if ($dec < 40) { |
|
687 | + $dec += 48; |
|
688 | + } else { |
|
689 | + $dec += 56; |
|
690 | + } |
|
558 | 691 | //echo chr($dec)." $dec<br/>"; |
559 | 692 | $itu .= chr($dec); |
560 | 693 | } |
@@ -567,25 +700,41 @@ discard block |
||
567 | 700 | } |
568 | 701 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
569 | 702 | $lsb = $chksum & 0x0F; |
570 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
571 | - else $lsbc = '0'; |
|
703 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
704 | + $lsbc = $hex_arr[$lsb]; |
|
705 | + } else { |
|
706 | + $lsbc = '0'; |
|
707 | + } |
|
572 | 708 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
573 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
574 | - else $msbc = '0'; |
|
709 | + if ($msb >=0 && $msb <= 15 ) { |
|
710 | + $msbc = $hex_arr[$msb]; |
|
711 | + } else { |
|
712 | + $msbc = '0'; |
|
713 | + } |
|
575 | 714 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
576 | 715 | return $itu; |
577 | 716 | } |
578 | 717 | |
579 | 718 | public function parse($buffer) { |
580 | 719 | $data = $this->process_ais_buf($buffer); |
581 | - if (!is_object($data)) return array(); |
|
582 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
583 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
720 | + if (!is_object($data)) { |
|
721 | + return array(); |
|
722 | + } |
|
723 | + if ($data->lon != 0) { |
|
724 | + $result['longitude'] = $data->lon; |
|
725 | + } |
|
726 | + if ($data->lat != 0) { |
|
727 | + $result['latitude'] = $data->lat; |
|
728 | + } |
|
584 | 729 | $result['ident'] = trim($data->name); |
585 | 730 | $result['timestamp'] = $data->ts; |
586 | 731 | $result['mmsi'] = $data->mmsi; |
587 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
588 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
732 | + if ($data->sog != -1.0) { |
|
733 | + $result['speed'] = $data->sog; |
|
734 | + } |
|
735 | + if ($data->cog != 0) { |
|
736 | + $result['heading'] = $data->cog; |
|
737 | + } |
|
589 | 738 | /* |
590 | 739 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
591 | 740 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -595,15 +744,25 @@ discard block |
||
595 | 744 | |
596 | 745 | public function mmsitype($mmsi) { |
597 | 746 | if (strlen($mmsi) == 9) { |
598 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
599 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
600 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
601 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
602 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
603 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
604 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
605 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
606 | - else return 'Ship'; |
|
747 | + if (substr($mmsi,0,3) == '974') { |
|
748 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
749 | + } elseif (substr($mmsi,0,3) == '972') { |
|
750 | + return 'MOB (Man Overboard) device'; |
|
751 | + } elseif (substr($mmsi,0,3) == '970') { |
|
752 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
753 | + } elseif (substr($mmsi,0,3) == '111') { |
|
754 | + return 'SAR (Search and Rescue) aircraft'; |
|
755 | + } elseif (substr($mmsi,0,2) == '98') { |
|
756 | + return 'Auxiliary craft associated with a parent ship'; |
|
757 | + } elseif (substr($mmsi,0,2) == '99') { |
|
758 | + return 'Aids to Navigation'; |
|
759 | + } elseif (substr($mmsi,0,2) == '00') { |
|
760 | + return 'Coastal stations'; |
|
761 | + } elseif (substr($mmsi,0,1) == '0') { |
|
762 | + return 'Group of ships'; |
|
763 | + } else { |
|
764 | + return 'Ship'; |
|
765 | + } |
|
607 | 766 | } |
608 | 767 | |
609 | 768 | |
@@ -620,32 +779,61 @@ discard block |
||
620 | 779 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
621 | 780 | return array(); |
622 | 781 | } |
623 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
624 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
782 | + if ($data->lon != 0) { |
|
783 | + $result['longitude'] = $data->lon; |
|
784 | + } |
|
785 | + if ($data->lat != 0) { |
|
786 | + $result['latitude'] = $data->lat; |
|
787 | + } |
|
625 | 788 | $result['ident'] = trim(str_replace('@','',$data->name)); |
626 | 789 | $result['timestamp'] = $data->ts; |
627 | 790 | $result['mmsi'] = $data->mmsi; |
628 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
791 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') { |
|
792 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
793 | + } |
|
629 | 794 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
630 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
631 | - if ($data->heading !== '') $result['heading'] = $data->heading; |
|
632 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
633 | - if ($data->status != '') $result['status'] = $data->status; |
|
634 | - if ($data->statusid !== '') $result['statusid'] = $data->statusid; |
|
635 | - if ($data->type !== '') $result['type'] = $data->type; |
|
636 | - if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
|
637 | - if ($data->imo !== '') $result['imo'] = $data->imo; |
|
638 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
795 | + if ($data->sog != -1.0) { |
|
796 | + $result['speed'] = $data->sog; |
|
797 | + } |
|
798 | + if ($data->heading !== '') { |
|
799 | + $result['heading'] = $data->heading; |
|
800 | + } elseif ($data->cog != 0) { |
|
801 | + $result['heading'] = $data->cog; |
|
802 | + } |
|
803 | + if ($data->status != '') { |
|
804 | + $result['status'] = $data->status; |
|
805 | + } |
|
806 | + if ($data->statusid !== '') { |
|
807 | + $result['statusid'] = $data->statusid; |
|
808 | + } |
|
809 | + if ($data->type !== '') { |
|
810 | + $result['type'] = $data->type; |
|
811 | + } |
|
812 | + if ($data->typeid !== '') { |
|
813 | + $result['typeid'] = $data->typeid; |
|
814 | + } |
|
815 | + if ($data->imo !== '') { |
|
816 | + $result['imo'] = $data->imo; |
|
817 | + } |
|
818 | + if ($data->callsign !== '') { |
|
819 | + $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
820 | + } |
|
639 | 821 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
640 | 822 | $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
641 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
823 | + if ($eta_ts != '') { |
|
824 | + $result['eta_ts'] = $eta_ts; |
|
825 | + } |
|
642 | 826 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
643 | 827 | $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
644 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
828 | + if ($eta_ts != '') { |
|
829 | + $result['eta_ts'] = $eta_ts; |
|
830 | + } |
|
645 | 831 | } |
646 | 832 | if ($data->destination != '') { |
647 | 833 | $dest = trim(str_replace('@','',$data->destination)); |
648 | - if ($dest != '') $result['destination'] = $dest; |
|
834 | + if ($dest != '') { |
|
835 | + $result['destination'] = $dest; |
|
836 | + } |
|
649 | 837 | } |
650 | 838 | $result['all'] = (array) $data; |
651 | 839 | /* |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
35 | 35 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
36 | 36 | $aircraft_types = $Stats->getAllAircraftTypes(); |
37 | - if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
37 | + if (empty($aircraft_types)) { |
|
38 | + $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
39 | + } |
|
38 | 40 | foreach($aircraft_types as $aircraft_item) |
39 | 41 | { |
40 | 42 | $output .= '<url>'; |
@@ -84,7 +86,9 @@ discard block |
||
84 | 86 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
85 | 87 | |
86 | 88 | $airport_names = $Stats->getAllAirportNames(); |
87 | - if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
|
89 | + if (empty($airport_names)) { |
|
90 | + $airport_names = $Spotter->getAllAirportNames(); |
|
91 | + } |
|
88 | 92 | foreach($airport_names as $airport_item) |
89 | 93 | { |
90 | 94 | $output .= '<url>'; |
@@ -99,7 +103,9 @@ discard block |
||
99 | 103 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
100 | 104 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
101 | 105 | $manufacturer_names = $Stats->getAllManufacturers(); |
102 | - if (empty($manufacturer_names)) $manufacturer_names = $Spotter->getAllManufacturers(); |
|
106 | + if (empty($manufacturer_names)) { |
|
107 | + $manufacturer_names = $Spotter->getAllManufacturers(); |
|
108 | + } |
|
103 | 109 | foreach($manufacturer_names as $manufacturer_item) |
104 | 110 | { |
105 | 111 | $output .= '<url>'; |
@@ -4,7 +4,9 @@ discard block |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Stats = new Stats(); |
6 | 6 | |
7 | -if (!isset($filter_name)) $filter_name = ''; |
|
7 | +if (!isset($filter_name)) { |
|
8 | + $filter_name = ''; |
|
9 | +} |
|
8 | 10 | $type = 'aircraft'; |
9 | 11 | if (isset($_GET['marine'])) { |
10 | 12 | $type = 'marine'; |
@@ -21,8 +23,10 @@ discard block |
||
21 | 23 | } |
22 | 24 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
23 | 25 | if ($airline_icao == '' && isset($globalFilter)) { |
24 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
25 | -} |
|
26 | + if (isset($globalFilter['airline'])) { |
|
27 | + $airline_icao = $globalFilter['airline'][0]; |
|
28 | + } |
|
29 | + } |
|
26 | 30 | |
27 | 31 | require_once('header.php'); |
28 | 32 | include('statistics-sub-menu.php'); |
@@ -64,10 +68,14 @@ discard block |
||
64 | 68 | $flightover_data = ''; |
65 | 69 | foreach($flightover_array as $flightover_item) |
66 | 70 | { |
67 | - if ($type == 'aircraft') $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
|
68 | - elseif ($type == 'marine') $flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],'; |
|
69 | - elseif ($type == 'tracker') $flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],'; |
|
70 | -} |
|
71 | + if ($type == 'aircraft') { |
|
72 | + $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
|
73 | + } elseif ($type == 'marine') { |
|
74 | + $flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],'; |
|
75 | + } elseif ($type == 'tracker') { |
|
76 | + $flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],'; |
|
77 | + } |
|
78 | + } |
|
71 | 79 | $flightover_data = substr($flightover_data, 0, -1); |
72 | 80 | print $flightover_data; |
73 | 81 | print '];'; |
@@ -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 { |
@@ -803,12 +855,16 @@ discard block |
||
803 | 855 | if ($globalDBdriver == 'mysql') { |
804 | 856 | if (!$Connection->tableExists('tle')) { |
805 | 857 | $error .= create_db::import_file('../db/tle.sql'); |
806 | - if ($error != '') return $error; |
|
858 | + if ($error != '') { |
|
859 | + return $error; |
|
860 | + } |
|
807 | 861 | } |
808 | 862 | } else { |
809 | 863 | if (!$Connection->tableExists('tle')) { |
810 | 864 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
811 | - if ($error != '') return $error; |
|
865 | + if ($error != '') { |
|
866 | + return $error; |
|
867 | + } |
|
812 | 868 | } |
813 | 869 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
814 | 870 | try { |
@@ -848,7 +904,9 @@ discard block |
||
848 | 904 | } else { |
849 | 905 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
850 | 906 | } |
851 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
907 | + if ($error != '') { |
|
908 | + return 'Import airlines.sql : '.$error; |
|
909 | + } |
|
852 | 910 | if (!$Connection->checkColumnName('airlines','forsource')) { |
853 | 911 | // Add forsource to airlines |
854 | 912 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1331,20 +1389,28 @@ discard block |
||
1331 | 1389 | } |
1332 | 1390 | if ($globalDBdriver == 'mysql') { |
1333 | 1391 | $error .= create_db::import_file('../db/airlines.sql'); |
1334 | - if ($error != '') return $error; |
|
1392 | + if ($error != '') { |
|
1393 | + return $error; |
|
1394 | + } |
|
1335 | 1395 | } else { |
1336 | 1396 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
1337 | - if ($error != '') return $error; |
|
1397 | + if ($error != '') { |
|
1398 | + return $error; |
|
1399 | + } |
|
1338 | 1400 | } |
1339 | 1401 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
1340 | 1402 | include_once(dirname(__FILE__).'/class.update_db.php'); |
1341 | 1403 | if (isset($globalVATSIM) && $globalVATSIM) { |
1342 | 1404 | $error .= update_db::update_vatsim(); |
1343 | - if ($error != '') return $error; |
|
1405 | + if ($error != '') { |
|
1406 | + return $error; |
|
1407 | + } |
|
1344 | 1408 | } |
1345 | 1409 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
1346 | 1410 | $error .= update_db::update_IVAO(); |
1347 | - if ($error != '') return $error; |
|
1411 | + if ($error != '') { |
|
1412 | + return $error; |
|
1413 | + } |
|
1348 | 1414 | } |
1349 | 1415 | } |
1350 | 1416 | |
@@ -1607,41 +1673,65 @@ discard block |
||
1607 | 1673 | if ($globalDBdriver == 'mysql') { |
1608 | 1674 | if (!$Connection->tableExists('tracker_output')) { |
1609 | 1675 | $error .= create_db::import_file('../db/tracker_output.sql'); |
1610 | - if ($error != '') return $error; |
|
1676 | + if ($error != '') { |
|
1677 | + return $error; |
|
1678 | + } |
|
1611 | 1679 | } |
1612 | 1680 | if (!$Connection->tableExists('tracker_live')) { |
1613 | 1681 | $error .= create_db::import_file('../db/tracker_live.sql'); |
1614 | - if ($error != '') return $error; |
|
1682 | + if ($error != '') { |
|
1683 | + return $error; |
|
1684 | + } |
|
1615 | 1685 | } |
1616 | 1686 | if (!$Connection->tableExists('marine_output')) { |
1617 | 1687 | $error .= create_db::import_file('../db/marine_output.sql'); |
1618 | - if ($error != '') return $error; |
|
1688 | + if ($error != '') { |
|
1689 | + return $error; |
|
1690 | + } |
|
1619 | 1691 | } |
1620 | 1692 | if (!$Connection->tableExists('marine_live')) { |
1621 | 1693 | $error .= create_db::import_file('../db/marine_live.sql'); |
1622 | - if ($error != '') return $error; |
|
1694 | + if ($error != '') { |
|
1695 | + return $error; |
|
1696 | + } |
|
1623 | 1697 | } |
1624 | 1698 | if (!$Connection->tableExists('marine_identity')) { |
1625 | 1699 | $error .= create_db::import_file('../db/marine_identity.sql'); |
1626 | - if ($error != '') return $error; |
|
1700 | + if ($error != '') { |
|
1701 | + return $error; |
|
1702 | + } |
|
1627 | 1703 | } |
1628 | 1704 | if (!$Connection->tableExists('marine_mid')) { |
1629 | 1705 | $error .= create_db::import_file('../db/marine_mid.sql'); |
1630 | - if ($error != '') return $error; |
|
1706 | + if ($error != '') { |
|
1707 | + return $error; |
|
1708 | + } |
|
1631 | 1709 | } |
1632 | 1710 | } else { |
1633 | 1711 | $error .= create_db::import_file('../db/pgsql/tracker_output.sql'); |
1634 | - if ($error != '') return $error; |
|
1712 | + if ($error != '') { |
|
1713 | + return $error; |
|
1714 | + } |
|
1635 | 1715 | $error .= create_db::import_file('../db/pgsql/tracker_live.sql'); |
1636 | - if ($error != '') return $error; |
|
1716 | + if ($error != '') { |
|
1717 | + return $error; |
|
1718 | + } |
|
1637 | 1719 | $error .= create_db::import_file('../db/pgsql/marine_output.sql'); |
1638 | - if ($error != '') return $error; |
|
1720 | + if ($error != '') { |
|
1721 | + return $error; |
|
1722 | + } |
|
1639 | 1723 | $error .= create_db::import_file('../db/pgsql/marine_live.sql'); |
1640 | - if ($error != '') return $error; |
|
1724 | + if ($error != '') { |
|
1725 | + return $error; |
|
1726 | + } |
|
1641 | 1727 | $error .= create_db::import_file('../db/pgsql/marine_identity.sql'); |
1642 | - if ($error != '') return $error; |
|
1728 | + if ($error != '') { |
|
1729 | + return $error; |
|
1730 | + } |
|
1643 | 1731 | $error .= create_db::import_file('../db/pgsql/marine_mid.sql'); |
1644 | - if ($error != '') return $error; |
|
1732 | + if ($error != '') { |
|
1733 | + return $error; |
|
1734 | + } |
|
1645 | 1735 | } |
1646 | 1736 | $query = "UPDATE config SET value = '37' WHERE name = 'schema_version'"; |
1647 | 1737 | try { |
@@ -1660,39 +1750,61 @@ discard block |
||
1660 | 1750 | if ($globalDBdriver == 'mysql') { |
1661 | 1751 | if (!$Connection->tableExists('marine_image')) { |
1662 | 1752 | $error .= create_db::import_file('../db/marine_image.sql'); |
1663 | - if ($error != '') return $error; |
|
1753 | + if ($error != '') { |
|
1754 | + return $error; |
|
1755 | + } |
|
1664 | 1756 | } |
1665 | 1757 | if (!$Connection->tableExists('marine_archive')) { |
1666 | 1758 | $error .= create_db::import_file('../db/marine_archive.sql'); |
1667 | - if ($error != '') return $error; |
|
1759 | + if ($error != '') { |
|
1760 | + return $error; |
|
1761 | + } |
|
1668 | 1762 | } |
1669 | 1763 | if (!$Connection->tableExists('marine_archive_output')) { |
1670 | 1764 | $error .= create_db::import_file('../db/marine_archive_output.sql'); |
1671 | - if ($error != '') return $error; |
|
1765 | + if ($error != '') { |
|
1766 | + return $error; |
|
1767 | + } |
|
1672 | 1768 | } |
1673 | 1769 | if (!$Connection->tableExists('tracker_archive')) { |
1674 | 1770 | $error .= create_db::import_file('../db/tracker_archive.sql'); |
1675 | - if ($error != '') return $error; |
|
1771 | + if ($error != '') { |
|
1772 | + return $error; |
|
1773 | + } |
|
1676 | 1774 | } |
1677 | 1775 | if (!$Connection->tableExists('tracker_archive_output')) { |
1678 | 1776 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1679 | - if ($error != '') return $error; |
|
1777 | + if ($error != '') { |
|
1778 | + return $error; |
|
1779 | + } |
|
1680 | 1780 | } |
1681 | 1781 | if (!$Connection->tableExists('marine_archive_output')) { |
1682 | 1782 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1683 | - if ($error != '') return $error; |
|
1783 | + if ($error != '') { |
|
1784 | + return $error; |
|
1785 | + } |
|
1684 | 1786 | } |
1685 | 1787 | } else { |
1686 | 1788 | $error .= create_db::import_file('../db/pgsql/marine_image.sql'); |
1687 | - if ($error != '') return $error; |
|
1789 | + if ($error != '') { |
|
1790 | + return $error; |
|
1791 | + } |
|
1688 | 1792 | $error .= create_db::import_file('../db/pgsql/marine_archive.sql'); |
1689 | - if ($error != '') return $error; |
|
1793 | + if ($error != '') { |
|
1794 | + return $error; |
|
1795 | + } |
|
1690 | 1796 | $error .= create_db::import_file('../db/pgsql/marine_archive_output.sql'); |
1691 | - if ($error != '') return $error; |
|
1797 | + if ($error != '') { |
|
1798 | + return $error; |
|
1799 | + } |
|
1692 | 1800 | $error .= create_db::import_file('../db/pgsql/tracker_archive.sql'); |
1693 | - if ($error != '') return $error; |
|
1801 | + if ($error != '') { |
|
1802 | + return $error; |
|
1803 | + } |
|
1694 | 1804 | $error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql'); |
1695 | - if ($error != '') return $error; |
|
1805 | + if ($error != '') { |
|
1806 | + return $error; |
|
1807 | + } |
|
1696 | 1808 | } |
1697 | 1809 | if ($globalDBdriver == 'mysql') { |
1698 | 1810 | $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
@@ -2063,7 +2175,9 @@ discard block |
||
2063 | 2175 | if ($globalDBdriver == 'mysql') { |
2064 | 2176 | if (!$Connection->tableExists('tracker_archive_output')) { |
2065 | 2177 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
2066 | - if ($error != '') return $error; |
|
2178 | + if ($error != '') { |
|
2179 | + return $error; |
|
2180 | + } |
|
2067 | 2181 | } |
2068 | 2182 | $query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;"; |
2069 | 2183 | } else { |
@@ -2091,14 +2205,22 @@ discard block |
||
2091 | 2205 | $error = ''; |
2092 | 2206 | if ($globalDBdriver == 'mysql') { |
2093 | 2207 | $error .= create_db::import_file('../db/airport.sql'); |
2094 | - if ($error != '') return $error; |
|
2208 | + if ($error != '') { |
|
2209 | + return $error; |
|
2210 | + } |
|
2095 | 2211 | $error .= create_db::import_file('../db/airlines.sql'); |
2096 | - if ($error != '') return $error; |
|
2212 | + if ($error != '') { |
|
2213 | + return $error; |
|
2214 | + } |
|
2097 | 2215 | } else { |
2098 | 2216 | $error .= create_db::import_file('../db/pgsql/airport.sql'); |
2099 | - if ($error != '') return $error; |
|
2217 | + if ($error != '') { |
|
2218 | + return $error; |
|
2219 | + } |
|
2100 | 2220 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
2101 | - if ($error != '') return $error; |
|
2221 | + if ($error != '') { |
|
2222 | + return $error; |
|
2223 | + } |
|
2102 | 2224 | } |
2103 | 2225 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
2104 | 2226 | if (file_exists('tmp/ivae_feb2013.zip')) { |
@@ -2115,7 +2237,9 @@ discard block |
||
2115 | 2237 | $error .= update_db::update_vatsim(); |
2116 | 2238 | } |
2117 | 2239 | } |
2118 | - if ($error != '') return $error; |
|
2240 | + if ($error != '') { |
|
2241 | + return $error; |
|
2242 | + } |
|
2119 | 2243 | $query = "UPDATE config SET value = '45' WHERE name = 'schema_version'"; |
2120 | 2244 | try { |
2121 | 2245 | $sth = $Connection->db->prepare($query); |
@@ -2133,10 +2257,14 @@ discard block |
||
2133 | 2257 | if (!$Connection->tableExists('satellite')) { |
2134 | 2258 | if ($globalDBdriver == 'mysql') { |
2135 | 2259 | $error .= create_db::import_file('../db/satellite.sql'); |
2136 | - if ($error != '') return $error; |
|
2260 | + if ($error != '') { |
|
2261 | + return $error; |
|
2262 | + } |
|
2137 | 2263 | } else { |
2138 | 2264 | $error .= create_db::import_file('../db/pgsql/satellite.sql'); |
2139 | - if ($error != '') return $error; |
|
2265 | + if ($error != '') { |
|
2266 | + return $error; |
|
2267 | + } |
|
2140 | 2268 | } |
2141 | 2269 | } |
2142 | 2270 | $query = "UPDATE config SET value = '46' WHERE name = 'schema_version'"; |
@@ -2156,37 +2284,53 @@ discard block |
||
2156 | 2284 | if (!$Connection->tableExists('stats_marine')) { |
2157 | 2285 | if ($globalDBdriver == 'mysql') { |
2158 | 2286 | $error .= create_db::import_file('../db/stats_marine.sql'); |
2159 | - if ($error != '') return $error; |
|
2287 | + if ($error != '') { |
|
2288 | + return $error; |
|
2289 | + } |
|
2160 | 2290 | } else { |
2161 | 2291 | $error .= create_db::import_file('../db/pgsql/stats_marine.sql'); |
2162 | - if ($error != '') return $error; |
|
2292 | + if ($error != '') { |
|
2293 | + return $error; |
|
2294 | + } |
|
2163 | 2295 | } |
2164 | 2296 | } |
2165 | 2297 | if (!$Connection->tableExists('stats_marine_country')) { |
2166 | 2298 | if ($globalDBdriver == 'mysql') { |
2167 | 2299 | $error .= create_db::import_file('../db/stats_marine_country.sql'); |
2168 | - if ($error != '') return $error; |
|
2300 | + if ($error != '') { |
|
2301 | + return $error; |
|
2302 | + } |
|
2169 | 2303 | } else { |
2170 | 2304 | $error .= create_db::import_file('../db/pgsql/stats_marine_country.sql'); |
2171 | - if ($error != '') return $error; |
|
2305 | + if ($error != '') { |
|
2306 | + return $error; |
|
2307 | + } |
|
2172 | 2308 | } |
2173 | 2309 | } |
2174 | 2310 | if (!$Connection->tableExists('stats_tracker')) { |
2175 | 2311 | if ($globalDBdriver == 'mysql') { |
2176 | 2312 | $error .= create_db::import_file('../db/stats_tracker.sql'); |
2177 | - if ($error != '') return $error; |
|
2313 | + if ($error != '') { |
|
2314 | + return $error; |
|
2315 | + } |
|
2178 | 2316 | } else { |
2179 | 2317 | $error .= create_db::import_file('../db/pgsql/stats_tracker.sql'); |
2180 | - if ($error != '') return $error; |
|
2318 | + if ($error != '') { |
|
2319 | + return $error; |
|
2320 | + } |
|
2181 | 2321 | } |
2182 | 2322 | } |
2183 | 2323 | if (!$Connection->tableExists('stats_tracker_country')) { |
2184 | 2324 | if ($globalDBdriver == 'mysql') { |
2185 | 2325 | $error .= create_db::import_file('../db/stats_tracker_country.sql'); |
2186 | - if ($error != '') return $error; |
|
2326 | + if ($error != '') { |
|
2327 | + return $error; |
|
2328 | + } |
|
2187 | 2329 | } else { |
2188 | 2330 | $error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql'); |
2189 | - if ($error != '') return $error; |
|
2331 | + if ($error != '') { |
|
2332 | + return $error; |
|
2333 | + } |
|
2190 | 2334 | } |
2191 | 2335 | } |
2192 | 2336 | $query = "UPDATE config SET value = '47' WHERE name = 'schema_version'"; |
@@ -2209,8 +2353,11 @@ discard block |
||
2209 | 2353 | if ($Connection->tableExists('aircraft')) { |
2210 | 2354 | if (!$Connection->tableExists('config')) { |
2211 | 2355 | $version = '1'; |
2212 | - if ($update) return self::update_from_1(); |
|
2213 | - else return $version; |
|
2356 | + if ($update) { |
|
2357 | + return self::update_from_1(); |
|
2358 | + } else { |
|
2359 | + return $version; |
|
2360 | + } |
|
2214 | 2361 | } else { |
2215 | 2362 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
2216 | 2363 | try { |
@@ -2223,191 +2370,333 @@ discard block |
||
2223 | 2370 | if ($update) { |
2224 | 2371 | if ($result['value'] == '2') { |
2225 | 2372 | $error = self::update_from_2(); |
2226 | - if ($error != '') return $error; |
|
2227 | - else return self::check_version(true); |
|
2373 | + if ($error != '') { |
|
2374 | + return $error; |
|
2375 | + } else { |
|
2376 | + return self::check_version(true); |
|
2377 | + } |
|
2228 | 2378 | } elseif ($result['value'] == '3') { |
2229 | 2379 | $error = self::update_from_3(); |
2230 | - if ($error != '') return $error; |
|
2231 | - else return self::check_version(true); |
|
2380 | + if ($error != '') { |
|
2381 | + return $error; |
|
2382 | + } else { |
|
2383 | + return self::check_version(true); |
|
2384 | + } |
|
2232 | 2385 | } elseif ($result['value'] == '4') { |
2233 | 2386 | $error = self::update_from_4(); |
2234 | - if ($error != '') return $error; |
|
2235 | - else return self::check_version(true); |
|
2387 | + if ($error != '') { |
|
2388 | + return $error; |
|
2389 | + } else { |
|
2390 | + return self::check_version(true); |
|
2391 | + } |
|
2236 | 2392 | } elseif ($result['value'] == '5') { |
2237 | 2393 | $error = self::update_from_5(); |
2238 | - if ($error != '') return $error; |
|
2239 | - else return self::check_version(true); |
|
2394 | + if ($error != '') { |
|
2395 | + return $error; |
|
2396 | + } else { |
|
2397 | + return self::check_version(true); |
|
2398 | + } |
|
2240 | 2399 | } elseif ($result['value'] == '6') { |
2241 | 2400 | $error = self::update_from_6(); |
2242 | - if ($error != '') return $error; |
|
2243 | - else return self::check_version(true); |
|
2401 | + if ($error != '') { |
|
2402 | + return $error; |
|
2403 | + } else { |
|
2404 | + return self::check_version(true); |
|
2405 | + } |
|
2244 | 2406 | } elseif ($result['value'] == '7') { |
2245 | 2407 | $error = self::update_from_7(); |
2246 | - if ($error != '') return $error; |
|
2247 | - else return self::check_version(true); |
|
2408 | + if ($error != '') { |
|
2409 | + return $error; |
|
2410 | + } else { |
|
2411 | + return self::check_version(true); |
|
2412 | + } |
|
2248 | 2413 | } elseif ($result['value'] == '8') { |
2249 | 2414 | $error = self::update_from_8(); |
2250 | - if ($error != '') return $error; |
|
2251 | - else return self::check_version(true); |
|
2415 | + if ($error != '') { |
|
2416 | + return $error; |
|
2417 | + } else { |
|
2418 | + return self::check_version(true); |
|
2419 | + } |
|
2252 | 2420 | } elseif ($result['value'] == '9') { |
2253 | 2421 | $error = self::update_from_9(); |
2254 | - if ($error != '') return $error; |
|
2255 | - else return self::check_version(true); |
|
2422 | + if ($error != '') { |
|
2423 | + return $error; |
|
2424 | + } else { |
|
2425 | + return self::check_version(true); |
|
2426 | + } |
|
2256 | 2427 | } elseif ($result['value'] == '10') { |
2257 | 2428 | $error = self::update_from_10(); |
2258 | - if ($error != '') return $error; |
|
2259 | - else return self::check_version(true); |
|
2429 | + if ($error != '') { |
|
2430 | + return $error; |
|
2431 | + } else { |
|
2432 | + return self::check_version(true); |
|
2433 | + } |
|
2260 | 2434 | } elseif ($result['value'] == '11') { |
2261 | 2435 | $error = self::update_from_11(); |
2262 | - if ($error != '') return $error; |
|
2263 | - else return self::check_version(true); |
|
2436 | + if ($error != '') { |
|
2437 | + return $error; |
|
2438 | + } else { |
|
2439 | + return self::check_version(true); |
|
2440 | + } |
|
2264 | 2441 | } elseif ($result['value'] == '12') { |
2265 | 2442 | $error = self::update_from_12(); |
2266 | - if ($error != '') return $error; |
|
2267 | - else return self::check_version(true); |
|
2443 | + if ($error != '') { |
|
2444 | + return $error; |
|
2445 | + } else { |
|
2446 | + return self::check_version(true); |
|
2447 | + } |
|
2268 | 2448 | } elseif ($result['value'] == '13') { |
2269 | 2449 | $error = self::update_from_13(); |
2270 | - if ($error != '') return $error; |
|
2271 | - else return self::check_version(true); |
|
2450 | + if ($error != '') { |
|
2451 | + return $error; |
|
2452 | + } else { |
|
2453 | + return self::check_version(true); |
|
2454 | + } |
|
2272 | 2455 | } elseif ($result['value'] == '14') { |
2273 | 2456 | $error = self::update_from_14(); |
2274 | - if ($error != '') return $error; |
|
2275 | - else return self::check_version(true); |
|
2457 | + if ($error != '') { |
|
2458 | + return $error; |
|
2459 | + } else { |
|
2460 | + return self::check_version(true); |
|
2461 | + } |
|
2276 | 2462 | } elseif ($result['value'] == '15') { |
2277 | 2463 | $error = self::update_from_15(); |
2278 | - if ($error != '') return $error; |
|
2279 | - else return self::check_version(true); |
|
2464 | + if ($error != '') { |
|
2465 | + return $error; |
|
2466 | + } else { |
|
2467 | + return self::check_version(true); |
|
2468 | + } |
|
2280 | 2469 | } elseif ($result['value'] == '16') { |
2281 | 2470 | $error = self::update_from_16(); |
2282 | - if ($error != '') return $error; |
|
2283 | - else return self::check_version(true); |
|
2471 | + if ($error != '') { |
|
2472 | + return $error; |
|
2473 | + } else { |
|
2474 | + return self::check_version(true); |
|
2475 | + } |
|
2284 | 2476 | } elseif ($result['value'] == '17') { |
2285 | 2477 | $error = self::update_from_17(); |
2286 | - if ($error != '') return $error; |
|
2287 | - else return self::check_version(true); |
|
2478 | + if ($error != '') { |
|
2479 | + return $error; |
|
2480 | + } else { |
|
2481 | + return self::check_version(true); |
|
2482 | + } |
|
2288 | 2483 | } elseif ($result['value'] == '18') { |
2289 | 2484 | $error = self::update_from_18(); |
2290 | - if ($error != '') return $error; |
|
2291 | - else return self::check_version(true); |
|
2485 | + if ($error != '') { |
|
2486 | + return $error; |
|
2487 | + } else { |
|
2488 | + return self::check_version(true); |
|
2489 | + } |
|
2292 | 2490 | } elseif ($result['value'] == '19') { |
2293 | 2491 | $error = self::update_from_19(); |
2294 | - if ($error != '') return $error; |
|
2295 | - else return self::check_version(true); |
|
2492 | + if ($error != '') { |
|
2493 | + return $error; |
|
2494 | + } else { |
|
2495 | + return self::check_version(true); |
|
2496 | + } |
|
2296 | 2497 | } elseif ($result['value'] == '20') { |
2297 | 2498 | $error = self::update_from_20(); |
2298 | - if ($error != '') return $error; |
|
2299 | - else return self::check_version(true); |
|
2499 | + if ($error != '') { |
|
2500 | + return $error; |
|
2501 | + } else { |
|
2502 | + return self::check_version(true); |
|
2503 | + } |
|
2300 | 2504 | } elseif ($result['value'] == '21') { |
2301 | 2505 | $error = self::update_from_21(); |
2302 | - if ($error != '') return $error; |
|
2303 | - else return self::check_version(true); |
|
2506 | + if ($error != '') { |
|
2507 | + return $error; |
|
2508 | + } else { |
|
2509 | + return self::check_version(true); |
|
2510 | + } |
|
2304 | 2511 | } elseif ($result['value'] == '22') { |
2305 | 2512 | $error = self::update_from_22(); |
2306 | - if ($error != '') return $error; |
|
2307 | - else return self::check_version(true); |
|
2513 | + if ($error != '') { |
|
2514 | + return $error; |
|
2515 | + } else { |
|
2516 | + return self::check_version(true); |
|
2517 | + } |
|
2308 | 2518 | } elseif ($result['value'] == '23') { |
2309 | 2519 | $error = self::update_from_23(); |
2310 | - if ($error != '') return $error; |
|
2311 | - else return self::check_version(true); |
|
2520 | + if ($error != '') { |
|
2521 | + return $error; |
|
2522 | + } else { |
|
2523 | + return self::check_version(true); |
|
2524 | + } |
|
2312 | 2525 | } elseif ($result['value'] == '24') { |
2313 | 2526 | $error = self::update_from_24(); |
2314 | - if ($error != '') return $error; |
|
2315 | - else return self::check_version(true); |
|
2527 | + if ($error != '') { |
|
2528 | + return $error; |
|
2529 | + } else { |
|
2530 | + return self::check_version(true); |
|
2531 | + } |
|
2316 | 2532 | } elseif ($result['value'] == '25') { |
2317 | 2533 | $error = self::update_from_25(); |
2318 | - if ($error != '') return $error; |
|
2319 | - else return self::check_version(true); |
|
2534 | + if ($error != '') { |
|
2535 | + return $error; |
|
2536 | + } else { |
|
2537 | + return self::check_version(true); |
|
2538 | + } |
|
2320 | 2539 | } elseif ($result['value'] == '26') { |
2321 | 2540 | $error = self::update_from_26(); |
2322 | - if ($error != '') return $error; |
|
2323 | - else return self::check_version(true); |
|
2541 | + if ($error != '') { |
|
2542 | + return $error; |
|
2543 | + } else { |
|
2544 | + return self::check_version(true); |
|
2545 | + } |
|
2324 | 2546 | } elseif ($result['value'] == '27') { |
2325 | 2547 | $error = self::update_from_27(); |
2326 | - if ($error != '') return $error; |
|
2327 | - else return self::check_version(true); |
|
2548 | + if ($error != '') { |
|
2549 | + return $error; |
|
2550 | + } else { |
|
2551 | + return self::check_version(true); |
|
2552 | + } |
|
2328 | 2553 | } elseif ($result['value'] == '28') { |
2329 | 2554 | $error = self::update_from_28(); |
2330 | - if ($error != '') return $error; |
|
2331 | - else return self::check_version(true); |
|
2555 | + if ($error != '') { |
|
2556 | + return $error; |
|
2557 | + } else { |
|
2558 | + return self::check_version(true); |
|
2559 | + } |
|
2332 | 2560 | } elseif ($result['value'] == '29') { |
2333 | 2561 | $error = self::update_from_29(); |
2334 | - if ($error != '') return $error; |
|
2335 | - else return self::check_version(true); |
|
2562 | + if ($error != '') { |
|
2563 | + return $error; |
|
2564 | + } else { |
|
2565 | + return self::check_version(true); |
|
2566 | + } |
|
2336 | 2567 | } elseif ($result['value'] == '30') { |
2337 | 2568 | $error = self::update_from_30(); |
2338 | - if ($error != '') return $error; |
|
2339 | - else return self::check_version(true); |
|
2569 | + if ($error != '') { |
|
2570 | + return $error; |
|
2571 | + } else { |
|
2572 | + return self::check_version(true); |
|
2573 | + } |
|
2340 | 2574 | } elseif ($result['value'] == '31') { |
2341 | 2575 | $error = self::update_from_31(); |
2342 | - if ($error != '') return $error; |
|
2343 | - else return self::check_version(true); |
|
2576 | + if ($error != '') { |
|
2577 | + return $error; |
|
2578 | + } else { |
|
2579 | + return self::check_version(true); |
|
2580 | + } |
|
2344 | 2581 | } elseif ($result['value'] == '32') { |
2345 | 2582 | $error = self::update_from_32(); |
2346 | - if ($error != '') return $error; |
|
2347 | - else return self::check_version(true); |
|
2583 | + if ($error != '') { |
|
2584 | + return $error; |
|
2585 | + } else { |
|
2586 | + return self::check_version(true); |
|
2587 | + } |
|
2348 | 2588 | } elseif ($result['value'] == '33') { |
2349 | 2589 | $error = self::update_from_33(); |
2350 | - if ($error != '') return $error; |
|
2351 | - else return self::check_version(true); |
|
2590 | + if ($error != '') { |
|
2591 | + return $error; |
|
2592 | + } else { |
|
2593 | + return self::check_version(true); |
|
2594 | + } |
|
2352 | 2595 | } elseif ($result['value'] == '34') { |
2353 | 2596 | $error = self::update_from_34(); |
2354 | - if ($error != '') return $error; |
|
2355 | - else return self::check_version(true); |
|
2597 | + if ($error != '') { |
|
2598 | + return $error; |
|
2599 | + } else { |
|
2600 | + return self::check_version(true); |
|
2601 | + } |
|
2356 | 2602 | } elseif ($result['value'] == '35') { |
2357 | 2603 | $error = self::update_from_35(); |
2358 | - if ($error != '') return $error; |
|
2359 | - else return self::check_version(true); |
|
2604 | + if ($error != '') { |
|
2605 | + return $error; |
|
2606 | + } else { |
|
2607 | + return self::check_version(true); |
|
2608 | + } |
|
2360 | 2609 | } elseif ($result['value'] == '36') { |
2361 | 2610 | $error = self::update_from_36(); |
2362 | - if ($error != '') return $error; |
|
2363 | - else return self::check_version(true); |
|
2611 | + if ($error != '') { |
|
2612 | + return $error; |
|
2613 | + } else { |
|
2614 | + return self::check_version(true); |
|
2615 | + } |
|
2364 | 2616 | } elseif ($result['value'] == '37') { |
2365 | 2617 | $error = self::update_from_37(); |
2366 | - if ($error != '') return $error; |
|
2367 | - else return self::check_version(true); |
|
2618 | + if ($error != '') { |
|
2619 | + return $error; |
|
2620 | + } else { |
|
2621 | + return self::check_version(true); |
|
2622 | + } |
|
2368 | 2623 | } elseif ($result['value'] == '38') { |
2369 | 2624 | $error = self::update_from_38(); |
2370 | - if ($error != '') return $error; |
|
2371 | - else return self::check_version(true); |
|
2625 | + if ($error != '') { |
|
2626 | + return $error; |
|
2627 | + } else { |
|
2628 | + return self::check_version(true); |
|
2629 | + } |
|
2372 | 2630 | } elseif ($result['value'] == '39') { |
2373 | 2631 | $error = self::update_from_39(); |
2374 | - if ($error != '') return $error; |
|
2375 | - else return self::check_version(true); |
|
2632 | + if ($error != '') { |
|
2633 | + return $error; |
|
2634 | + } else { |
|
2635 | + return self::check_version(true); |
|
2636 | + } |
|
2376 | 2637 | } elseif ($result['value'] == '40') { |
2377 | 2638 | $error = self::update_from_40(); |
2378 | - if ($error != '') return $error; |
|
2379 | - else return self::check_version(true); |
|
2639 | + if ($error != '') { |
|
2640 | + return $error; |
|
2641 | + } else { |
|
2642 | + return self::check_version(true); |
|
2643 | + } |
|
2380 | 2644 | } elseif ($result['value'] == '41') { |
2381 | 2645 | $error = self::update_from_41(); |
2382 | - if ($error != '') return $error; |
|
2383 | - else return self::check_version(true); |
|
2646 | + if ($error != '') { |
|
2647 | + return $error; |
|
2648 | + } else { |
|
2649 | + return self::check_version(true); |
|
2650 | + } |
|
2384 | 2651 | } elseif ($result['value'] == '42') { |
2385 | 2652 | $error = self::update_from_42(); |
2386 | - if ($error != '') return $error; |
|
2387 | - else return self::check_version(true); |
|
2653 | + if ($error != '') { |
|
2654 | + return $error; |
|
2655 | + } else { |
|
2656 | + return self::check_version(true); |
|
2657 | + } |
|
2388 | 2658 | } elseif ($result['value'] == '43') { |
2389 | 2659 | $error = self::update_from_43(); |
2390 | - if ($error != '') return $error; |
|
2391 | - else return self::check_version(true); |
|
2660 | + if ($error != '') { |
|
2661 | + return $error; |
|
2662 | + } else { |
|
2663 | + return self::check_version(true); |
|
2664 | + } |
|
2392 | 2665 | } elseif ($result['value'] == '44') { |
2393 | 2666 | $error = self::update_from_44(); |
2394 | - if ($error != '') return $error; |
|
2395 | - else return self::check_version(true); |
|
2667 | + if ($error != '') { |
|
2668 | + return $error; |
|
2669 | + } else { |
|
2670 | + return self::check_version(true); |
|
2671 | + } |
|
2396 | 2672 | } elseif ($result['value'] == '45') { |
2397 | 2673 | $error = self::update_from_45(); |
2398 | - if ($error != '') return $error; |
|
2399 | - else return self::check_version(true); |
|
2674 | + if ($error != '') { |
|
2675 | + return $error; |
|
2676 | + } else { |
|
2677 | + return self::check_version(true); |
|
2678 | + } |
|
2400 | 2679 | } elseif ($result['value'] == '46') { |
2401 | 2680 | $error = self::update_from_46(); |
2402 | - if ($error != '') return $error; |
|
2403 | - else return self::check_version(true); |
|
2404 | - } else return ''; |
|
2681 | + if ($error != '') { |
|
2682 | + return $error; |
|
2683 | + } else { |
|
2684 | + return self::check_version(true); |
|
2685 | + } |
|
2686 | + } else { |
|
2687 | + return ''; |
|
2688 | + } |
|
2405 | 2689 | } else { |
2406 | - if (isset($result['value']) && $result['value'] != '') return $result['value']; |
|
2407 | - else return 0; |
|
2690 | + if (isset($result['value']) && $result['value'] != '') { |
|
2691 | + return $result['value']; |
|
2692 | + } else { |
|
2693 | + return 0; |
|
2694 | + } |
|
2408 | 2695 | } |
2409 | 2696 | } |
2410 | - } else return $version; |
|
2697 | + } else { |
|
2698 | + return $version; |
|
2699 | + } |
|
2411 | 2700 | } |
2412 | 2701 | } |
2413 | 2702 | } |
@@ -46,8 +46,10 @@ discard block |
||
46 | 46 | $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00"; |
47 | 47 | $sql_date = $end_date; |
48 | 48 | } |
49 | - } else $sql_date = ''; |
|
50 | -} |
|
49 | + } else { |
|
50 | + $sql_date = ''; |
|
51 | + } |
|
52 | + } |
|
51 | 53 | |
52 | 54 | if (isset($_GET['highest_altitude'])) { |
53 | 55 | //for altitude manipulation |
@@ -61,8 +63,12 @@ discard block |
||
61 | 63 | } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
62 | 64 | $start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000"; |
63 | 65 | $sql_altitude = $start_altitude; |
64 | - } else $sql_altitude = ''; |
|
65 | -} else $sql_altitude = ''; |
|
66 | + } else { |
|
67 | + $sql_altitude = ''; |
|
68 | + } |
|
69 | + } else { |
|
70 | + $sql_altitude = ''; |
|
71 | +} |
|
66 | 72 | |
67 | 73 | //calculuation for the pagination |
68 | 74 | if(!isset($_GET['limit'])) |
@@ -80,7 +86,7 @@ discard block |
||
80 | 86 | $limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
81 | 87 | $absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
82 | 88 | } |
83 | -} else { |
|
89 | +} else { |
|
84 | 90 | $limit_explode = explode(",", $_GET['limit']); |
85 | 91 | $limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT); |
86 | 92 | $limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT); |
@@ -138,10 +144,15 @@ discard block |
||
138 | 144 | $dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT); |
139 | 145 | $number_results = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
140 | 146 | if ($dist != '') { |
141 | - if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934; |
|
142 | - elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852; |
|
147 | + if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') { |
|
148 | + $dist = $dist*1.60934; |
|
149 | + } elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') { |
|
150 | + $dist = $dist*1.852; |
|
151 | + } |
|
152 | + } |
|
153 | + if (!isset($sql_date)) { |
|
154 | + $sql_date = ''; |
|
143 | 155 | } |
144 | - if (!isset($sql_date)) $sql_date = ''; |
|
145 | 156 | if ($archive == 1) { |
146 | 157 | if ($type == 'aircraft') { |
147 | 158 | $SpotterArchive = new SpotterArchive(); |
@@ -219,7 +230,10 @@ discard block |
||
219 | 230 | if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; } |
220 | 231 | if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; } |
221 | 232 | if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; } |
222 | - if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; } |
|
233 | + if (isset($_GET['highlights'])) { |
|
234 | + if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; |
|
235 | + } |
|
236 | + } |
|
223 | 237 | if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; } |
224 | 238 | if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; } |
225 | 239 | if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; } |
@@ -355,7 +369,10 @@ discard block |
||
355 | 369 | <div class="form-group"> |
356 | 370 | <label class="control-label col-sm-2"><?php echo _("Keywords"); ?></label> |
357 | 371 | <div class="col-sm-10"> |
358 | - <input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) print $q; ?>" size="10" placeholder="<?php echo _("Keywords"); ?>" /> |
|
372 | + <input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) { |
|
373 | + print $q; |
|
374 | +} |
|
375 | +?>" size="10" placeholder="<?php echo _("Keywords"); ?>" /> |
|
359 | 376 | </div> |
360 | 377 | </div> |
361 | 378 | </fieldset> |
@@ -374,7 +391,10 @@ discard block |
||
374 | 391 | </select> |
375 | 392 | </div> |
376 | 393 | </div> |
377 | - <script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script> |
|
394 | + <script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) { |
|
395 | + print $manufacturer; |
|
396 | +} |
|
397 | +?>')</script> |
|
378 | 398 | <div class="form-group"> |
379 | 399 | <label class="control-label col-sm-2"><?php echo _("Type"); ?></label> |
380 | 400 | <div class="col-sm-10"> |
@@ -383,11 +403,17 @@ discard block |
||
383 | 403 | </select> |
384 | 404 | </div> |
385 | 405 | </div> |
386 | - <script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script> |
|
406 | + <script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) { |
|
407 | + print $aircraft_icao; |
|
408 | +} |
|
409 | +?>');</script> |
|
387 | 410 | <div class="form-group"> |
388 | 411 | <label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> |
389 | 412 | <div class="col-sm-10"> |
390 | - <input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) print $registration; ?>" size="8" placeholder="<?php echo _("Registration"); ?>" /> |
|
413 | + <input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) { |
|
414 | + print $registration; |
|
415 | +} |
|
416 | +?>" size="8" placeholder="<?php echo _("Registration"); ?>" /> |
|
391 | 417 | </div> |
392 | 418 | </div> |
393 | 419 | <?php |
@@ -396,22 +422,31 @@ discard block |
||
396 | 422 | <div class="form-group"> |
397 | 423 | <label class="control-label col-sm-2"><?php echo _("Pilot id"); ?></label> |
398 | 424 | <div class="col-sm-10"> |
399 | - <input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) print $pilot_id; ?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" /> |
|
425 | + <input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) { |
|
426 | + print $pilot_id; |
|
427 | +} |
|
428 | +?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" /> |
|
400 | 429 | </div> |
401 | 430 | </div> |
402 | 431 | <div class="form-group"> |
403 | 432 | <label class="control-label col-sm-2"><?php echo _("Pilot name"); ?></label> |
404 | 433 | <div class="col-sm-10"> |
405 | - <input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) print $pilot_name; ?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" /> |
|
434 | + <input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) { |
|
435 | + print $pilot_name; |
|
436 | +} |
|
437 | +?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" /> |
|
406 | 438 | </div> |
407 | 439 | </div> |
408 | 440 | <?php |
409 | - }else { |
|
441 | + } else { |
|
410 | 442 | ?> |
411 | 443 | <div class="form-group"> |
412 | 444 | <label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> |
413 | 445 | <div class="col-sm-10"> |
414 | - <input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) print $owner; ?>" size="15" placeholder="<?php echo _("Owner name"); ?>" /> |
|
446 | + <input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) { |
|
447 | + print $owner; |
|
448 | +} |
|
449 | +?>" size="15" placeholder="<?php echo _("Owner name"); ?>" /> |
|
415 | 450 | </div> |
416 | 451 | </div> |
417 | 452 | <?php |
@@ -419,8 +454,14 @@ discard block |
||
419 | 454 | ?> |
420 | 455 | <div class="form-group"> |
421 | 456 | <div class="col-sm-offset-2 col-sm-10"> |
422 | - <!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>--> |
|
423 | - <label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label> |
|
457 | + <!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) { |
|
458 | + if ($_GET['highlights'] == "true"){ print 'checked="checked"'; |
|
459 | +} |
|
460 | +} ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>--> |
|
461 | + <label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) { |
|
462 | + if ($_GET['highlights'] == "true"){ print 'checked="checked"'; |
|
463 | +} |
|
464 | +} ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label> |
|
424 | 465 | </div> |
425 | 466 | </div> |
426 | 467 | </fieldset> |
@@ -434,7 +475,10 @@ discard block |
||
434 | 475 | </select> |
435 | 476 | </div> |
436 | 477 | </div> |
437 | - <script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script> |
|
478 | + <script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) { |
|
479 | + print $airline; |
|
480 | +} |
|
481 | +?>');</script> |
|
438 | 482 | <div class="form-group"> |
439 | 483 | <label class="control-label col-sm-2"><?php echo _("Country"); ?></label> |
440 | 484 | <div class="col-sm-10"> |
@@ -443,19 +487,34 @@ discard block |
||
443 | 487 | </select> |
444 | 488 | </div> |
445 | 489 | </div> |
446 | - <script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script> |
|
490 | + <script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) { |
|
491 | + print $airline_country; |
|
492 | +} |
|
493 | +?>');</script> |
|
447 | 494 | <div class="form-group"> |
448 | 495 | <label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> |
449 | 496 | <div class="col-sm-10"> |
450 | - <input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" /> |
|
497 | + <input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) { |
|
498 | + print $callsign; |
|
499 | +} |
|
500 | +?>" size="8" placeholder="<?php echo _("Callsign"); ?>" /> |
|
451 | 501 | </div> |
452 | 502 | </div> |
453 | 503 | <div class="form-group"> |
454 | 504 | <div class="col-sm-offset-2 col-sm-10"> |
455 | 505 | <label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label> |
456 | - <label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label> |
|
457 | - <label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label> |
|
458 | - <label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label> |
|
506 | + <label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) { |
|
507 | + if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; |
|
508 | +} |
|
509 | +} ?>> <?php echo _("Only Passenger airlines"); ?></label> |
|
510 | + <label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) { |
|
511 | + if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; |
|
512 | +} |
|
513 | +} ?>> <?php echo _("Only Cargo airlines"); ?></label> |
|
514 | + <label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) { |
|
515 | + if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; |
|
516 | +} |
|
517 | +} ?>> <?php echo _("Only Military airlines"); ?></label> |
|
459 | 518 | </div> |
460 | 519 | </div> |
461 | 520 | </fieldset> |
@@ -469,7 +528,10 @@ discard block |
||
469 | 528 | </select> |
470 | 529 | </div> |
471 | 530 | </div> |
472 | - <script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script> |
|
531 | + <script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) { |
|
532 | + print $airport_icao; |
|
533 | +} |
|
534 | +?>');</script> |
|
473 | 535 | <div class="form-group"> |
474 | 536 | <label class="control-label col-sm-2"><?php echo _("Country"); ?></label> |
475 | 537 | <div class="col-sm-10"> |
@@ -478,7 +540,10 @@ discard block |
||
478 | 540 | </select> |
479 | 541 | </div> |
480 | 542 | </div> |
481 | - <script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script> |
|
543 | + <script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) { |
|
544 | + print $airport_country; |
|
545 | +} |
|
546 | +?>');</script> |
|
482 | 547 | </fieldset> |
483 | 548 | <fieldset> |
484 | 549 | <legend><?php echo _("Route"); ?></legend> |
@@ -490,7 +555,10 @@ discard block |
||
490 | 555 | </select> |
491 | 556 | </div> |
492 | 557 | </div> |
493 | - <script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script> |
|
558 | + <script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) { |
|
559 | + print $departure_airport_route; |
|
560 | +} |
|
561 | +?>');</script> |
|
494 | 562 | <div class="form-group"> |
495 | 563 | <label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> |
496 | 564 | <div class="col-sm-10"> |
@@ -499,7 +567,10 @@ discard block |
||
499 | 567 | </select> |
500 | 568 | </div> |
501 | 569 | </div> |
502 | - <script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script> |
|
570 | + <script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) { |
|
571 | + print $arrival_airport_route; |
|
572 | +} |
|
573 | +?>');</script> |
|
503 | 574 | </fieldset> |
504 | 575 | <fieldset> |
505 | 576 | <legend>Altitude</legend> |
@@ -549,19 +620,33 @@ discard block |
||
549 | 620 | <div class="form-group"> |
550 | 621 | <label class="control-label col-sm-2"><?php echo _("Latitude"); ?></label> |
551 | 622 | <div class="col-sm-10"> |
552 | - <input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) print $origlat; ?>" /> |
|
623 | + <input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) { |
|
624 | + print $origlat; |
|
625 | +} |
|
626 | +?>" /> |
|
553 | 627 | </div> |
554 | 628 | </div> |
555 | 629 | <div class="form-group"> |
556 | 630 | <label class="control-label col-sm-2"><?php echo _("Longitude"); ?></label> |
557 | 631 | <div class="col-sm-10"> |
558 | - <input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) print $origlon; ?>" /> |
|
632 | + <input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) { |
|
633 | + print $origlon; |
|
634 | +} |
|
635 | +?>" /> |
|
559 | 636 | </div> |
560 | 637 | </div> |
561 | 638 | <div class="form-group"> |
562 | - <label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) print $globalDistanceUnit; else print 'km'; print ')'; ?></label> |
|
639 | + <label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) { |
|
640 | + print $globalDistanceUnit; |
|
641 | +} else { |
|
642 | + print 'km'; |
|
643 | +} |
|
644 | +print ')'; ?></label> |
|
563 | 645 | <div class="col-sm-10"> |
564 | - <input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) print $distance; ?>" /> |
|
646 | + <input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) { |
|
647 | + print $distance; |
|
648 | +} |
|
649 | +?>" /> |
|
565 | 650 | </div> |
566 | 651 | </div> |
567 | 652 | </fieldset> |
@@ -572,7 +657,10 @@ discard block |
||
572 | 657 | <div class="form-group"> |
573 | 658 | <label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> |
574 | 659 | <div class="col-sm-10"> |
575 | - <input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" /> |
|
660 | + <input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) { |
|
661 | + print $callsign; |
|
662 | +} |
|
663 | +?>" size="8" placeholder="<?php echo _("Callsign"); ?>" /> |
|
576 | 664 | </div> |
577 | 665 | </div> |
578 | 666 | </fieldset> |
@@ -583,7 +671,10 @@ discard block |
||
583 | 671 | <div class="form-group"> |
584 | 672 | <label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> |
585 | 673 | <div class="col-sm-10"> |
586 | - <input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" /> |
|
674 | + <input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) { |
|
675 | + print $callsign; |
|
676 | +} |
|
677 | +?>" size="8" placeholder="<?php echo _("Callsign"); ?>" /> |
|
587 | 678 | </div> |
588 | 679 | </div> |
589 | 680 | </fieldset> |
@@ -591,7 +682,10 @@ discard block |
||
591 | 682 | <div class="form-group"> |
592 | 683 | <label class="control-label col-sm-2"><?php echo _("MMSI"); ?></label> |
593 | 684 | <div class="col-sm-10"> |
594 | - <input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) print $mmsi; ?>" size="8" placeholder="<?php echo _("MMSI"); ?>" /> |
|
685 | + <input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) { |
|
686 | + print $mmsi; |
|
687 | +} |
|
688 | +?>" size="8" placeholder="<?php echo _("MMSI"); ?>" /> |
|
595 | 689 | </div> |
596 | 690 | </div> |
597 | 691 | </fieldset> |
@@ -599,7 +693,10 @@ discard block |
||
599 | 693 | <div class="form-group"> |
600 | 694 | <label class="control-label col-sm-2"><?php echo _("IMO"); ?></label> |
601 | 695 | <div class="col-sm-10"> |
602 | - <input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) print $imo; ?>" size="8" placeholder="<?php echo _("IMO"); ?>" /> |
|
696 | + <input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) { |
|
697 | + print $imo; |
|
698 | +} |
|
699 | +?>" size="8" placeholder="<?php echo _("IMO"); ?>" /> |
|
603 | 700 | </div> |
604 | 701 | </div> |
605 | 702 | </fieldset> |
@@ -612,7 +709,10 @@ discard block |
||
612 | 709 | <label class="control-label col-sm-2"><?php echo _("Start Date"); ?></label> |
613 | 710 | <div class="col-sm-10"> |
614 | 711 | <div class='input-group date' id='datetimepicker1'> |
615 | - <input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') print $start_date; ?>" placeholder="<?php echo _("Start Date/Time"); ?>" /> |
|
712 | + <input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') { |
|
713 | + print $start_date; |
|
714 | +} |
|
715 | +?>" placeholder="<?php echo _("Start Date/Time"); ?>" /> |
|
616 | 716 | <span class="input-group-addon"> |
617 | 717 | <span class="glyphicon glyphicon-calendar"></span> |
618 | 718 | </span> |
@@ -623,7 +723,10 @@ discard block |
||
623 | 723 | <label class="control-label col-sm-2"><?php echo _("End Date"); ?></label> |
624 | 724 | <div class="col-sm-10"> |
625 | 725 | <div class='input-group date' id='datetimepicker2'> |
626 | - <input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') print $end_date; ?>" placeholder="<?php echo _("End Date/Time"); ?>" /> |
|
726 | + <input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') { |
|
727 | + print $end_date; |
|
728 | +} |
|
729 | +?>" placeholder="<?php echo _("End Date/Time"); ?>" /> |
|
627 | 730 | <span class="input-group-addon"> |
628 | 731 | <span class="glyphicon glyphicon-calendar"></span> |
629 | 732 | </span> |
@@ -22,11 +22,15 @@ discard block |
||
22 | 22 | require_once('require/class.Spotter.php'); |
23 | 23 | } |
24 | 24 | |
25 | -if (!isset($filter_name)) $filter_name = ''; |
|
25 | +if (!isset($filter_name)) { |
|
26 | + $filter_name = ''; |
|
27 | +} |
|
26 | 28 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
27 | 29 | if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) { |
28 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
29 | -} |
|
30 | + if (isset($globalFilter['airline'])) { |
|
31 | + $airline_icao = $globalFilter['airline'][0]; |
|
32 | + } |
|
33 | + } |
|
30 | 34 | if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') { |
31 | 35 | $Spotter = new Spotter(); |
32 | 36 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
@@ -61,7 +65,12 @@ discard block |
||
61 | 65 | <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script> |
62 | 66 | <div class="column"> |
63 | 67 | <div class="info"> |
64 | - <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1> |
|
68 | + <h1><?php if (isset($airline_name)) { |
|
69 | + echo _("Statistics for ").$airline_name; |
|
70 | +} else { |
|
71 | + echo _("Statistics"); |
|
72 | +} |
|
73 | +?></h1> |
|
65 | 74 | <?php |
66 | 75 | if ($type == 'aircraft') { |
67 | 76 | $last_update = $Stats->getLastStatsUpdate(); |
@@ -73,7 +82,9 @@ discard block |
||
73 | 82 | if (isset($last_update[0]['value'])) { |
74 | 83 | date_default_timezone_set('UTC'); |
75 | 84 | $lastupdate = strtotime($last_update[0]['value']); |
76 | - if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
|
85 | + if (isset($globalTimezone) && $globalTimezone != '') { |
|
86 | + date_default_timezone_set($globalTimezone); |
|
87 | + } |
|
77 | 88 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
78 | 89 | } |
79 | 90 | |
@@ -158,8 +169,11 @@ discard block |
||
158 | 169 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
159 | 170 | $aircraft_data = ''; |
160 | 171 | foreach($aircraft_array as $aircraft_item) { |
161 | - if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
162 | - else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
172 | + if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') { |
|
173 | + $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
174 | + } else { |
|
175 | + $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
176 | + } |
|
163 | 177 | } |
164 | 178 | $aircraft_data = substr($aircraft_data, 0, -1); |
165 | 179 | print 'var series = ['.$aircraft_data.'];'; |
@@ -176,11 +190,17 @@ discard block |
||
176 | 190 | <?php |
177 | 191 | if ($year != '' && $month != '') { |
178 | 192 | ?> |
179 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
193 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
194 | + echo '/'.$airline_icao; |
|
195 | +} |
|
196 | +?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
180 | 197 | <?php |
181 | 198 | } else { |
182 | 199 | ?> |
183 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
200 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
201 | + echo '/'.$airline_icao; |
|
202 | +} |
|
203 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
184 | 204 | <?php |
185 | 205 | } |
186 | 206 | ?> |
@@ -209,11 +229,15 @@ discard block |
||
209 | 229 | print '</script>'; |
210 | 230 | if ($year != '' && $month != '') { |
211 | 231 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
212 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
232 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
233 | + echo '/'.$airline_icao; |
|
234 | + } |
|
213 | 235 | print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
214 | 236 | } else { |
215 | 237 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
216 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
238 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
239 | + echo '/'.$airline_icao; |
|
240 | + } |
|
217 | 241 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
218 | 242 | } |
219 | 243 | print '</div>'; |
@@ -233,8 +257,9 @@ discard block |
||
233 | 257 | <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2> |
234 | 258 | <?php |
235 | 259 | $marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month); |
236 | - if (count($marine_array) == 0) print _("No data available"); |
|
237 | - else { |
|
260 | + if (count($marine_array) == 0) { |
|
261 | + print _("No data available"); |
|
262 | + } else { |
|
238 | 263 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
239 | 264 | $marine_data = ''; |
240 | 265 | foreach($marine_array as $marine_item) { |
@@ -278,8 +303,9 @@ discard block |
||
278 | 303 | <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2> |
279 | 304 | <?php |
280 | 305 | $tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month); |
281 | - if (count($tracker_array) == 0) print _("No data available"); |
|
282 | - else { |
|
306 | + if (count($tracker_array) == 0) { |
|
307 | + print _("No data available"); |
|
308 | + } else { |
|
283 | 309 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
284 | 310 | $tracker_data = ''; |
285 | 311 | foreach($tracker_array as $tracker_item) { |
@@ -323,8 +349,9 @@ discard block |
||
323 | 349 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
324 | 350 | <?php |
325 | 351 | $owner_array = $Satellite->countAllOwners(true); |
326 | - if (count($owner_array) == 0) print _("No data available"); |
|
327 | - else { |
|
352 | + if (count($owner_array) == 0) { |
|
353 | + print _("No data available"); |
|
354 | + } else { |
|
328 | 355 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
329 | 356 | $owner_data = ''; |
330 | 357 | foreach($owner_array as $owner_item) { |
@@ -343,7 +370,10 @@ discard block |
||
343 | 370 | ?> |
344 | 371 | <!-- |
345 | 372 | <div class="more"> |
346 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
373 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
374 | + echo '/'.$airline_icao; |
|
375 | +} |
|
376 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
347 | 377 | </div> |
348 | 378 | --> |
349 | 379 | </div> |
@@ -352,8 +382,9 @@ discard block |
||
352 | 382 | <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2> |
353 | 383 | <?php |
354 | 384 | $countries_array = $Satellite->countAllCountriesOwners(true); |
355 | - if (count($countries_array) == 0) print _("No data available"); |
|
356 | - else { |
|
385 | + if (count($countries_array) == 0) { |
|
386 | + print _("No data available"); |
|
387 | + } else { |
|
357 | 388 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
358 | 389 | $owner_data = ''; |
359 | 390 | foreach($countries_array as $owner_item) { |
@@ -372,7 +403,10 @@ discard block |
||
372 | 403 | ?> |
373 | 404 | <!-- |
374 | 405 | <div class="more"> |
375 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
406 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
407 | + echo '/'.$airline_icao; |
|
408 | +} |
|
409 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
376 | 410 | </div> |
377 | 411 | --> |
378 | 412 | </div> |
@@ -384,8 +418,9 @@ discard block |
||
384 | 418 | <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2> |
385 | 419 | <?php |
386 | 420 | $launch_site_array = $Satellite->countAllLaunchSite(true); |
387 | - if (count($launch_site_array) == 0) print _("No data available"); |
|
388 | - else { |
|
421 | + if (count($launch_site_array) == 0) { |
|
422 | + print _("No data available"); |
|
423 | + } else { |
|
389 | 424 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
390 | 425 | $launch_site_data = ''; |
391 | 426 | foreach($launch_site_array as $launch_site_item) { |
@@ -404,7 +439,10 @@ discard block |
||
404 | 439 | ?> |
405 | 440 | <!-- |
406 | 441 | <div class="more"> |
407 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
442 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
443 | + echo '/'.$airline_icao; |
|
444 | +} |
|
445 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
408 | 446 | </div> |
409 | 447 | --> |
410 | 448 | </div> |
@@ -427,8 +465,9 @@ discard block |
||
427 | 465 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
428 | 466 | <?php |
429 | 467 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
430 | - if (count($pilot_array) == 0) print _("No data available"); |
|
431 | - else { |
|
468 | + if (count($pilot_array) == 0) { |
|
469 | + print _("No data available"); |
|
470 | + } else { |
|
432 | 471 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
433 | 472 | $pilot_data = ''; |
434 | 473 | foreach($pilot_array as $pilot_item) { |
@@ -446,7 +485,9 @@ discard block |
||
446 | 485 | } |
447 | 486 | print '<div class="more">'; |
448 | 487 | print '<a href="'.$globalURL.'/statistics/pilot'; |
449 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
488 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
489 | + echo '/'.$airline_icao; |
|
490 | + } |
|
450 | 491 | print'" class="btn btn-default btn" role="button">'._("See full statistic").'»</a>'; |
451 | 492 | print '</div>'; |
452 | 493 | ?> |
@@ -462,8 +503,9 @@ discard block |
||
462 | 503 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
463 | 504 | <?php |
464 | 505 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
465 | - if (count($owner_array) == 0) print _("No data available"); |
|
466 | - else { |
|
506 | + if (count($owner_array) == 0) { |
|
507 | + print _("No data available"); |
|
508 | + } else { |
|
467 | 509 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
468 | 510 | $owner_data = ''; |
469 | 511 | foreach($owner_array as $owner_item) { |
@@ -481,7 +523,10 @@ discard block |
||
481 | 523 | } |
482 | 524 | ?> |
483 | 525 | <div class="more"> |
484 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
526 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
527 | + echo '/'.$airline_icao; |
|
528 | +} |
|
529 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
485 | 530 | </div> |
486 | 531 | </div> |
487 | 532 | |
@@ -494,8 +539,9 @@ discard block |
||
494 | 539 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
495 | 540 | <?php |
496 | 541 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
497 | - if (count($flightover_array) == 0) print _("No data available"); |
|
498 | - else { |
|
542 | + if (count($flightover_array) == 0) { |
|
543 | + print _("No data available"); |
|
544 | + } else { |
|
499 | 545 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
500 | 546 | print 'var series = ['; |
501 | 547 | $flightover_data = ''; |
@@ -537,7 +583,10 @@ discard block |
||
537 | 583 | } |
538 | 584 | ?> |
539 | 585 | <div class="more"> |
540 | - <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
586 | + <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
587 | + echo '/'.$airline_icao; |
|
588 | +} |
|
589 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
541 | 590 | </div> |
542 | 591 | </div> |
543 | 592 | <?php |
@@ -555,8 +604,9 @@ discard block |
||
555 | 604 | <div class="col-md-6"> |
556 | 605 | <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2> |
557 | 606 | <?php |
558 | - if (count($flightover_array) == 0) print _("No data available"); |
|
559 | - else { |
|
607 | + if (count($flightover_array) == 0) { |
|
608 | + print _("No data available"); |
|
609 | + } else { |
|
560 | 610 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
561 | 611 | print 'var series = ['; |
562 | 612 | $flightover_data = ''; |
@@ -612,8 +662,9 @@ discard block |
||
612 | 662 | <div class="col-md-6"> |
613 | 663 | <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2> |
614 | 664 | <?php |
615 | - if (count($flightover_array) == 0) print _("No data available"); |
|
616 | - else { |
|
665 | + if (count($flightover_array) == 0) { |
|
666 | + print _("No data available"); |
|
667 | + } else { |
|
617 | 668 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
618 | 669 | print 'var series = ['; |
619 | 670 | $flightover_data = ''; |
@@ -719,7 +770,9 @@ discard block |
||
719 | 770 | });"; |
720 | 771 | print '</script>'; |
721 | 772 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; |
722 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
773 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
774 | + echo '/'.$airline_icao; |
|
775 | + } |
|
723 | 776 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
724 | 777 | } |
725 | 778 | ?> |
@@ -781,7 +834,9 @@ discard block |
||
781 | 834 | });"; |
782 | 835 | print '</script>'; |
783 | 836 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival'; |
784 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
837 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
838 | + echo '/'.$airline_icao; |
|
839 | + } |
|
785 | 840 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
786 | 841 | } |
787 | 842 | ?> |
@@ -800,8 +855,9 @@ discard block |
||
800 | 855 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
801 | 856 | <?php |
802 | 857 | $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
803 | - if (count($year_array) == 0) print _("No data available"); |
|
804 | - else { |
|
858 | + if (count($year_array) == 0) { |
|
859 | + print _("No data available"); |
|
860 | + } else { |
|
805 | 861 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
806 | 862 | $year_data = ''; |
807 | 863 | $year_cnt = ''; |
@@ -820,7 +876,10 @@ discard block |
||
820 | 876 | } |
821 | 877 | ?> |
822 | 878 | <div class="more"> |
823 | - <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
879 | + <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
880 | + echo '/'.$airline_icao; |
|
881 | +} |
|
882 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
824 | 883 | </div> |
825 | 884 | </div> |
826 | 885 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -828,8 +887,9 @@ discard block |
||
828 | 887 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
829 | 888 | <?php |
830 | 889 | $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
831 | - if (count($month_array) == 0) print _("No data available"); |
|
832 | - else { |
|
890 | + if (count($month_array) == 0) { |
|
891 | + print _("No data available"); |
|
892 | + } else { |
|
833 | 893 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
834 | 894 | $month_data = ''; |
835 | 895 | $month_cnt = ''; |
@@ -848,7 +908,10 @@ discard block |
||
848 | 908 | } |
849 | 909 | ?> |
850 | 910 | <div class="more"> |
851 | - <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
911 | + <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
912 | + echo '/'.$airline_icao; |
|
913 | +} |
|
914 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
852 | 915 | </div> |
853 | 916 | </div> |
854 | 917 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -857,8 +920,9 @@ discard block |
||
857 | 920 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
858 | 921 | <?php |
859 | 922 | $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
860 | - if (empty($date_array)) print _("No data available"); |
|
861 | - else { |
|
923 | + if (empty($date_array)) { |
|
924 | + print _("No data available"); |
|
925 | + } else { |
|
862 | 926 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
863 | 927 | $date_data = ''; |
864 | 928 | $date_cnt = ''; |
@@ -877,7 +941,10 @@ discard block |
||
877 | 941 | } |
878 | 942 | ?> |
879 | 943 | <div class="more"> |
880 | - <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
944 | + <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
945 | + echo '/'.$airline_icao; |
|
946 | +} |
|
947 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
881 | 948 | </div> |
882 | 949 | </div> |
883 | 950 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -885,8 +952,9 @@ discard block |
||
885 | 952 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
886 | 953 | <?php |
887 | 954 | $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
888 | - if (empty($hour_array)) print _("No data available"); |
|
889 | - else { |
|
955 | + if (empty($hour_array)) { |
|
956 | + print _("No data available"); |
|
957 | + } else { |
|
890 | 958 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
891 | 959 | $hour_data = ''; |
892 | 960 | $hour_cnt = ''; |
@@ -905,7 +973,10 @@ discard block |
||
905 | 973 | } |
906 | 974 | ?> |
907 | 975 | <div class="more"> |
908 | - <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
976 | + <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
977 | + echo '/'.$airline_icao; |
|
978 | +} |
|
979 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
909 | 980 | </div> |
910 | 981 | </div> |
911 | 982 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -925,8 +996,9 @@ discard block |
||
925 | 996 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
926 | 997 | <?php |
927 | 998 | $year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
928 | - if (count($year_array) == 0) print _("No data available"); |
|
929 | - else { |
|
999 | + if (count($year_array) == 0) { |
|
1000 | + print _("No data available"); |
|
1001 | + } else { |
|
930 | 1002 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
931 | 1003 | $year_data = ''; |
932 | 1004 | $year_cnt = ''; |
@@ -954,8 +1026,9 @@ discard block |
||
954 | 1026 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
955 | 1027 | <?php |
956 | 1028 | $month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name); |
957 | - if (count($month_array) == 0) print _("No data available"); |
|
958 | - else { |
|
1029 | + if (count($month_array) == 0) { |
|
1030 | + print _("No data available"); |
|
1031 | + } else { |
|
959 | 1032 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
960 | 1033 | $month_data = ''; |
961 | 1034 | $month_cnt = ''; |
@@ -983,8 +1056,9 @@ discard block |
||
983 | 1056 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
984 | 1057 | <?php |
985 | 1058 | $date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name); |
986 | - if (empty($date_array)) print _("No data available"); |
|
987 | - else { |
|
1059 | + if (empty($date_array)) { |
|
1060 | + print _("No data available"); |
|
1061 | + } else { |
|
988 | 1062 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
989 | 1063 | $date_data = ''; |
990 | 1064 | $date_cnt = ''; |
@@ -1011,8 +1085,9 @@ discard block |
||
1011 | 1085 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
1012 | 1086 | <?php |
1013 | 1087 | $hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name); |
1014 | - if (empty($hour_array)) print _("No data available"); |
|
1015 | - else { |
|
1088 | + if (empty($hour_array)) { |
|
1089 | + print _("No data available"); |
|
1090 | + } else { |
|
1016 | 1091 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
1017 | 1092 | $hour_data = ''; |
1018 | 1093 | $hour_cnt = ''; |
@@ -1051,8 +1126,9 @@ discard block |
||
1051 | 1126 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
1052 | 1127 | <?php |
1053 | 1128 | $year_array = $Tracker->countAllMonthsLastYear(true); |
1054 | - if (count($year_array) == 0) print _("No data available"); |
|
1055 | - else { |
|
1129 | + if (count($year_array) == 0) { |
|
1130 | + print _("No data available"); |
|
1131 | + } else { |
|
1056 | 1132 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
1057 | 1133 | $year_data = ''; |
1058 | 1134 | $year_cnt = ''; |
@@ -1080,8 +1156,9 @@ discard block |
||
1080 | 1156 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
1081 | 1157 | <?php |
1082 | 1158 | $month_array = $Tracker->countAllDatesLastMonth(); |
1083 | - if (count($month_array) == 0) print _("No data available"); |
|
1084 | - else { |
|
1159 | + if (count($month_array) == 0) { |
|
1160 | + print _("No data available"); |
|
1161 | + } else { |
|
1085 | 1162 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
1086 | 1163 | $month_data = ''; |
1087 | 1164 | $month_cnt = ''; |
@@ -1109,8 +1186,9 @@ discard block |
||
1109 | 1186 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
1110 | 1187 | <?php |
1111 | 1188 | $date_array = $Tracker->countAllDatesLast7Days(); |
1112 | - if (empty($date_array)) print _("No data available"); |
|
1113 | - else { |
|
1189 | + if (empty($date_array)) { |
|
1190 | + print _("No data available"); |
|
1191 | + } else { |
|
1114 | 1192 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
1115 | 1193 | $date_data = ''; |
1116 | 1194 | $date_cnt = ''; |
@@ -1137,8 +1215,9 @@ discard block |
||
1137 | 1215 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
1138 | 1216 | <?php |
1139 | 1217 | $hour_array = $Tracker->countAllHours('hour',true); |
1140 | - if (empty($hour_array)) print _("No data available"); |
|
1141 | - else { |
|
1218 | + if (empty($hour_array)) { |
|
1219 | + print _("No data available"); |
|
1220 | + } else { |
|
1142 | 1221 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
1143 | 1222 | $hour_data = ''; |
1144 | 1223 | $hour_cnt = ''; |
@@ -1177,8 +1256,9 @@ discard block |
||
1177 | 1256 | <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2> |
1178 | 1257 | <?php |
1179 | 1258 | $year_array = $Satellite->countAllMonthsLastYear(); |
1180 | - if (count($year_array) == 0) print _("No data available"); |
|
1181 | - else { |
|
1259 | + if (count($year_array) == 0) { |
|
1260 | + print _("No data available"); |
|
1261 | + } else { |
|
1182 | 1262 | print '<div id="chart21" class="chart" width="100%"></div><script>'; |
1183 | 1263 | $year_data = ''; |
1184 | 1264 | $year_cnt = ''; |
@@ -1208,8 +1288,9 @@ discard block |
||
1208 | 1288 | <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2> |
1209 | 1289 | <?php |
1210 | 1290 | $year_array = $Satellite->countAllYears(); |
1211 | - if (count($year_array) == 0) print _("No data available"); |
|
1212 | - else { |
|
1291 | + if (count($year_array) == 0) { |
|
1292 | + print _("No data available"); |
|
1293 | + } else { |
|
1213 | 1294 | print '<div id="chart22" class="chart" width="100%"></div><script>'; |
1214 | 1295 | $year_data = ''; |
1215 | 1296 | $year_cnt = ''; |
@@ -1251,8 +1332,9 @@ discard block |
||
1251 | 1332 | <h2><?php echo _("Fatalities by Years"); ?></h2> |
1252 | 1333 | <?php |
1253 | 1334 | $year_array = $Stats->countFatalitiesByYear(); |
1254 | - if (count($year_array) == 0) print _("No data available"); |
|
1255 | - else { |
|
1335 | + if (count($year_array) == 0) { |
|
1336 | + print _("No data available"); |
|
1337 | + } else { |
|
1256 | 1338 | print '<div id="chart32" class="chart" width="100%"></div><script>'; |
1257 | 1339 | $year_data = ''; |
1258 | 1340 | $year_cnt = ''; |
@@ -1281,8 +1363,9 @@ discard block |
||
1281 | 1363 | <h2><?php echo _("Fatalities last 12 Months"); ?></h2> |
1282 | 1364 | <?php |
1283 | 1365 | $year_array = $Stats->countFatalitiesLast12Months(); |
1284 | - if (count($year_array) == 0) print _("No data available"); |
|
1285 | - else { |
|
1366 | + if (count($year_array) == 0) { |
|
1367 | + print _("No data available"); |
|
1368 | + } else { |
|
1286 | 1369 | print '<div id="chart33" class="chart" width="100%"></div><script>'; |
1287 | 1370 | $year_data = ''; |
1288 | 1371 | $year_cnt = ''; |
@@ -1353,8 +1436,11 @@ discard block |
||
1353 | 1436 | $distance = $distance; |
1354 | 1437 | $unit = 'km'; |
1355 | 1438 | } |
1356 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1357 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1439 | + if (!isset($polar_data)) { |
|
1440 | + $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1441 | + } else { |
|
1442 | + $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1443 | + } |
|
1358 | 1444 | } |
1359 | 1445 | ?> |
1360 | 1446 | <div class="col-md-6"> |
@@ -1418,9 +1504,12 @@ discard block |
||
1418 | 1504 | foreach ($msg as $eachmsg) { |
1419 | 1505 | //$eachmsg = $msg[0]; |
1420 | 1506 | $data = $eachmsg['source_data']; |
1421 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
1422 | - else $max = 500; |
|
1423 | -?> |
|
1507 | + if ($data > 500) { |
|
1508 | + $max = (round(($data+100)/100))*100; |
|
1509 | + } else { |
|
1510 | + $max = 500; |
|
1511 | + } |
|
1512 | + ?> |
|
1424 | 1513 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
1425 | 1514 | <script> |
1426 | 1515 | var g = new JustGage({ |
@@ -9,7 +9,9 @@ discard block |
||
9 | 9 | if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { |
10 | 10 | exec("ps ux", $output, $result); |
11 | 11 | $j = 0; |
12 | - foreach ($output as $line) if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ")) $j++; |
|
12 | + foreach ($output as $line) { |
|
13 | + if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ")) $j++; |
|
14 | + } |
|
13 | 15 | if ($j > 1) { |
14 | 16 | echo "Script is already runnning..."; |
15 | 17 | die(); |
@@ -29,14 +31,18 @@ discard block |
||
29 | 31 | $update_db->update_notam(); |
30 | 32 | } |
31 | 33 | $update_db->insert_last_notam_update(); |
32 | - } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n"; |
|
34 | + } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) { |
|
35 | + echo "NOTAM are only updated once a day.\n"; |
|
36 | + } |
|
33 | 37 | if ($update_db->check_last_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
34 | 38 | $update_db->update_all(); |
35 | 39 | // require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
36 | 40 | // $Spotter = new Spotter(); |
37 | 41 | // $Spotter->updateFieldsFromOtherTables(); |
38 | 42 | $update_db->insert_last_update(); |
39 | - } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
43 | + } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) { |
|
44 | + echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
45 | + } |
|
40 | 46 | if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) { |
41 | 47 | echo "Check if new airspace version exist..."; |
42 | 48 | echo $update_db->update_airspace_fam(); |
@@ -45,8 +51,11 @@ discard block |
||
45 | 51 | if (isset($globalGeoid) && $globalGeoid && $update_db->check_last_geoid_update()) { |
46 | 52 | echo "Check if new geoid version exist..."; |
47 | 53 | $error = $update_db->update_geoid_fam(); |
48 | - if ($error == '') $update_db->insert_last_geoid_update(); |
|
49 | - else echo $error; |
|
54 | + if ($error == '') { |
|
55 | + $update_db->insert_last_geoid_update(); |
|
56 | + } else { |
|
57 | + echo $error; |
|
58 | + } |
|
50 | 59 | } |
51 | 60 | if (isset($globalMarine) && $globalMarine && $update_db->check_last_marine_identity_update()) { |
52 | 61 | echo "Check if new marine identity version exist..."; |
@@ -64,13 +73,17 @@ discard block |
||
64 | 73 | //echo "Done"; |
65 | 74 | } |
66 | 75 | $update_db->insert_last_owner_update(); |
67 | - } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n"; |
|
76 | + } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
77 | + echo "Owner are only updated every 15 days.\n"; |
|
78 | + } |
|
68 | 79 | |
69 | 80 | if ($update_db->check_last_airlines_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
70 | 81 | echo "Updating airlines...\n"; |
71 | 82 | echo $update_db->update_airlines_fam(); |
72 | 83 | $update_db->insert_last_airlines_update(); |
73 | - } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Airlines are only updated every 15 days.\n"; |
|
84 | + } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
85 | + echo "Airlines are only updated every 15 days.\n"; |
|
86 | + } |
|
74 | 87 | |
75 | 88 | if (isset($globalAccidents) && $globalAccidents && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
76 | 89 | require_once(dirname(__FILE__).'/../require/class.Accident.php'); |
@@ -79,7 +92,9 @@ discard block |
||
79 | 92 | if ($Accident->check_last_accidents_update()) { |
80 | 93 | $Accident->download_update(); |
81 | 94 | $Accident->insert_last_accidents_update(); |
82 | - } else echo "Accidents are updated once a day.\n"; |
|
95 | + } else { |
|
96 | + echo "Accidents are updated once a day.\n"; |
|
97 | + } |
|
83 | 98 | } |
84 | 99 | |
85 | 100 | } |
@@ -92,15 +107,19 @@ discard block |
||
92 | 107 | if ($METAR->check_last_update()) { |
93 | 108 | $METAR->addMETARCycle(); |
94 | 109 | $METAR->insert_last_update(); |
95 | - } else echo "METAR are only updated every 30 minutes.\n"; |
|
96 | -} |
|
110 | + } else { |
|
111 | + echo "METAR are only updated every 30 minutes.\n"; |
|
112 | + } |
|
113 | + } |
|
97 | 114 | |
98 | 115 | if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
99 | 116 | echo "Updating schedules..."; |
100 | 117 | //$update_db->update_oneworld(); |
101 | 118 | $update_db->update_skyteam(); |
102 | 119 | $update_db->insert_last_schedules_update(); |
103 | -} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n"; |
|
120 | +} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
121 | + echo "Schedules are only updated every 15 days.\n"; |
|
122 | +} |
|
104 | 123 | |
105 | 124 | if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) { |
106 | 125 | echo "Updating statistics and archive old data...\n"; |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (Marine)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (Marine)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | /** |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -69,8 +73,11 @@ discard block |
||
69 | 73 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
70 | 74 | } |
71 | 75 | } |
72 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
73 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
76 | + if ($filter_query_where == '' && $where) { |
|
77 | + $filter_query_where = ' WHERE'; |
|
78 | + } elseif ($filter_query_where != '' && $and) { |
|
79 | + $filter_query_where .= ' AND'; |
|
80 | + } |
|
74 | 81 | if ($filter_query_where != '') { |
75 | 82 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
76 | 83 | } |
@@ -124,32 +131,54 @@ discard block |
||
124 | 131 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
125 | 132 | } elseif (isset($row['spotter_archive_output_id'])) { |
126 | 133 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
127 | - */} |
|
128 | - elseif (isset($row['marineid'])) { |
|
134 | + */} elseif (isset($row['marineid'])) { |
|
129 | 135 | $temp_array['marine_id'] = $row['marineid']; |
130 | 136 | } else { |
131 | 137 | $temp_array['marine_id'] = ''; |
132 | 138 | } |
133 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
134 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
135 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
136 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
137 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
138 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
139 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
140 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
139 | + if (isset($row['fammarine_id'])) { |
|
140 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
141 | + } |
|
142 | + if (isset($row['mmsi'])) { |
|
143 | + $temp_array['mmsi'] = $row['mmsi']; |
|
144 | + } |
|
145 | + if (isset($row['type'])) { |
|
146 | + $temp_array['type'] = $row['type']; |
|
147 | + } |
|
148 | + if (isset($row['type_id'])) { |
|
149 | + $temp_array['type_id'] = $row['type_id']; |
|
150 | + } |
|
151 | + if (isset($row['ident'])) { |
|
152 | + $temp_array['ident'] = $row['ident']; |
|
153 | + } |
|
154 | + if (isset($row['latitude'])) { |
|
155 | + $temp_array['latitude'] = $row['latitude']; |
|
156 | + } |
|
157 | + if (isset($row['longitude'])) { |
|
158 | + $temp_array['longitude'] = $row['longitude']; |
|
159 | + } |
|
160 | + if (isset($row['format_source'])) { |
|
161 | + $temp_array['format_source'] = $row['format_source']; |
|
162 | + } |
|
141 | 163 | if (isset($row['heading'])) { |
142 | 164 | $temp_array['heading'] = $row['heading']; |
143 | 165 | $heading_direction = $this->parseDirection($row['heading']); |
144 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
166 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
167 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
168 | + } |
|
169 | + } |
|
170 | + if (isset($row['ground_speed'])) { |
|
171 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
145 | 172 | } |
146 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
147 | 173 | |
148 | 174 | if($temp_array['mmsi'] != "") |
149 | 175 | { |
150 | 176 | $Image = new Image($this->db); |
151 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
152 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
177 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
178 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
179 | + } else { |
|
180 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
181 | + } |
|
153 | 182 | unset($Image); |
154 | 183 | if (count($image_array) > 0) { |
155 | 184 | $temp_array['image'] = $image_array[0]['image']; |
@@ -201,13 +230,21 @@ discard block |
||
201 | 230 | } |
202 | 231 | |
203 | 232 | $fromsource = NULL; |
204 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
205 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
206 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
233 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
234 | + $temp_array['source_name'] = $row['source_name']; |
|
235 | + } |
|
236 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
237 | + $temp_array['over_country'] = $row['over_country']; |
|
238 | + } |
|
239 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
240 | + $temp_array['distance'] = $row['distance']; |
|
241 | + } |
|
207 | 242 | $temp_array['query_number_rows'] = $num_rows; |
208 | 243 | $spotter_array[] = $temp_array; |
209 | 244 | } |
210 | - if ($num_rows == 0) return array(); |
|
245 | + if ($num_rows == 0) { |
|
246 | + return array(); |
|
247 | + } |
|
211 | 248 | $spotter_array[0]['query_number_rows'] = $num_rows; |
212 | 249 | return $spotter_array; |
213 | 250 | } |
@@ -233,8 +270,12 @@ discard block |
||
233 | 270 | { |
234 | 271 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
235 | 272 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
236 | - } else $limit_query = ""; |
|
237 | - } else $limit_query = ""; |
|
273 | + } else { |
|
274 | + $limit_query = ""; |
|
275 | + } |
|
276 | + } else { |
|
277 | + $limit_query = ""; |
|
278 | + } |
|
238 | 279 | if ($sort != "") |
239 | 280 | { |
240 | 281 | $search_orderby_array = $this->getOrderBy(); |
@@ -258,7 +299,9 @@ discard block |
||
258 | 299 | global $global_query; |
259 | 300 | |
260 | 301 | date_default_timezone_set('UTC'); |
261 | - if ($id == '') return array(); |
|
302 | + if ($id == '') { |
|
303 | + return array(); |
|
304 | + } |
|
262 | 305 | $additional_query = "marine_output.fammarine_id = :id"; |
263 | 306 | $query_values = array(':id' => $id); |
264 | 307 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -401,8 +444,11 @@ discard block |
||
401 | 444 | $query .= " ORDER BY marine_output.source_name ASC"; |
402 | 445 | |
403 | 446 | $sth = $this->db->prepare($query); |
404 | - if (!empty($query_values)) $sth->execute($query_values); |
|
405 | - else $sth->execute(); |
|
447 | + if (!empty($query_values)) { |
|
448 | + $sth->execute($query_values); |
|
449 | + } else { |
|
450 | + $sth->execute(); |
|
451 | + } |
|
406 | 452 | |
407 | 453 | $source_array = array(); |
408 | 454 | $temp_array = array(); |
@@ -457,8 +503,11 @@ discard block |
||
457 | 503 | $sth = $this->db->prepare($query); |
458 | 504 | $sth->execute(array(':mmsi' => $mmsi)); |
459 | 505 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
460 | - if (isset($result[0])) return $result[0]; |
|
461 | - else return array(); |
|
506 | + if (isset($result[0])) { |
|
507 | + return $result[0]; |
|
508 | + } else { |
|
509 | + return array(); |
|
510 | + } |
|
462 | 511 | } |
463 | 512 | |
464 | 513 | /* |
@@ -474,7 +523,9 @@ discard block |
||
474 | 523 | date_default_timezone_set($globalTimezone); |
475 | 524 | $datetime = new DateTime(); |
476 | 525 | $offset = $datetime->format('P'); |
477 | - } else $offset = '+00:00'; |
|
526 | + } else { |
|
527 | + $offset = '+00:00'; |
|
528 | + } |
|
478 | 529 | |
479 | 530 | if ($globalDBdriver == 'mysql') { |
480 | 531 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -704,9 +755,15 @@ discard block |
||
704 | 755 | $latitude = 0; |
705 | 756 | $longitude = 0; |
706 | 757 | } |
707 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
708 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
709 | - if ($arrival_date == '') $arrival_date = NULL; |
|
758 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
759 | + $heading = 0; |
|
760 | + } |
|
761 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
762 | + $groundspeed = 0; |
|
763 | + } |
|
764 | + if ($arrival_date == '') { |
|
765 | + $arrival_date = NULL; |
|
766 | + } |
|
710 | 767 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
711 | 768 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
712 | 769 | |
@@ -814,7 +871,9 @@ discard block |
||
814 | 871 | global $globalDBdriver, $globalArchive; |
815 | 872 | //$filter_query = $this->getFilter($filters,true,true); |
816 | 873 | $Connection= new Connection($this->db); |
817 | - if (!$Connection->tableExists('countries')) return array(); |
|
874 | + if (!$Connection->tableExists('countries')) { |
|
875 | + return array(); |
|
876 | + } |
|
818 | 877 | require_once('class.SpotterLive.php'); |
819 | 878 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
820 | 879 | $MarineLive = new MarineLive($this->db); |
@@ -858,7 +917,9 @@ discard block |
||
858 | 917 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
859 | 918 | } |
860 | 919 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
861 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
920 | + if ($limit) { |
|
921 | + $query .= " LIMIT 10 OFFSET 0"; |
|
922 | + } |
|
862 | 923 | |
863 | 924 | $sth = $this->db->prepare($query); |
864 | 925 | $sth->execute(); |
@@ -892,12 +953,18 @@ discard block |
||
892 | 953 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
893 | 954 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
894 | 955 | if ($olderthanmonths > 0) { |
895 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
896 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
956 | + if ($globalDBdriver == 'mysql') { |
|
957 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
958 | + } else { |
|
959 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
960 | + } |
|
897 | 961 | } |
898 | 962 | if ($sincedate != '') { |
899 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
900 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
963 | + if ($globalDBdriver == 'mysql') { |
|
964 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
965 | + } else { |
|
966 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
967 | + } |
|
901 | 968 | } |
902 | 969 | $query_values = array(); |
903 | 970 | if ($year != '') { |
@@ -928,7 +995,9 @@ discard block |
||
928 | 995 | } |
929 | 996 | } |
930 | 997 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
931 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
998 | + if ($limit) { |
|
999 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1000 | + } |
|
932 | 1001 | |
933 | 1002 | $sth = $this->db->prepare($query); |
934 | 1003 | $sth->execute($query_values); |
@@ -963,7 +1032,9 @@ discard block |
||
963 | 1032 | date_default_timezone_set($globalTimezone); |
964 | 1033 | $datetime = new DateTime(); |
965 | 1034 | $offset = $datetime->format('P'); |
966 | - } else $offset = '+00:00'; |
|
1035 | + } else { |
|
1036 | + $offset = '+00:00'; |
|
1037 | + } |
|
967 | 1038 | |
968 | 1039 | if ($globalDBdriver == 'mysql') { |
969 | 1040 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1013,7 +1084,9 @@ discard block |
||
1013 | 1084 | date_default_timezone_set($globalTimezone); |
1014 | 1085 | $datetime = new DateTime(); |
1015 | 1086 | $offset = $datetime->format('P'); |
1016 | - } else $offset = '+00:00'; |
|
1087 | + } else { |
|
1088 | + $offset = '+00:00'; |
|
1089 | + } |
|
1017 | 1090 | $filter_query = $this->getFilter($filters,true,true); |
1018 | 1091 | if ($globalDBdriver == 'mysql') { |
1019 | 1092 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1059,7 +1132,9 @@ discard block |
||
1059 | 1132 | date_default_timezone_set($globalTimezone); |
1060 | 1133 | $datetime = new DateTime(); |
1061 | 1134 | $offset = $datetime->format('P'); |
1062 | - } else $offset = '+00:00'; |
|
1135 | + } else { |
|
1136 | + $offset = '+00:00'; |
|
1137 | + } |
|
1063 | 1138 | $filter_query = $this->getFilter($filters,true,true); |
1064 | 1139 | if ($globalDBdriver == 'mysql') { |
1065 | 1140 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1107,7 +1182,9 @@ discard block |
||
1107 | 1182 | date_default_timezone_set($globalTimezone); |
1108 | 1183 | $datetime = new DateTime(); |
1109 | 1184 | $offset = $datetime->format('P'); |
1110 | - } else $offset = '+00:00'; |
|
1185 | + } else { |
|
1186 | + $offset = '+00:00'; |
|
1187 | + } |
|
1111 | 1188 | |
1112 | 1189 | if ($globalDBdriver == 'mysql') { |
1113 | 1190 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1156,7 +1233,9 @@ discard block |
||
1156 | 1233 | date_default_timezone_set($globalTimezone); |
1157 | 1234 | $datetime = new DateTime(); |
1158 | 1235 | $offset = $datetime->format('P'); |
1159 | - } else $offset = '+00:00'; |
|
1236 | + } else { |
|
1237 | + $offset = '+00:00'; |
|
1238 | + } |
|
1160 | 1239 | $filter_query = $this->getFilter($filters,true,true); |
1161 | 1240 | if ($globalDBdriver == 'mysql') { |
1162 | 1241 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1205,7 +1284,9 @@ discard block |
||
1205 | 1284 | date_default_timezone_set($globalTimezone); |
1206 | 1285 | $datetime = new DateTime(); |
1207 | 1286 | $offset = $datetime->format('P'); |
1208 | - } else $offset = '+00:00'; |
|
1287 | + } else { |
|
1288 | + $offset = '+00:00'; |
|
1289 | + } |
|
1209 | 1290 | |
1210 | 1291 | $orderby_sql = ''; |
1211 | 1292 | if ($orderby == "hour") |
@@ -1274,7 +1355,9 @@ discard block |
||
1274 | 1355 | date_default_timezone_set($globalTimezone); |
1275 | 1356 | $datetime = new DateTime($date); |
1276 | 1357 | $offset = $datetime->format('P'); |
1277 | - } else $offset = '+00:00'; |
|
1358 | + } else { |
|
1359 | + $offset = '+00:00'; |
|
1360 | + } |
|
1278 | 1361 | |
1279 | 1362 | if ($globalDBdriver == 'mysql') { |
1280 | 1363 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1322,7 +1405,9 @@ discard block |
||
1322 | 1405 | date_default_timezone_set($globalTimezone); |
1323 | 1406 | $datetime = new DateTime(); |
1324 | 1407 | $offset = $datetime->format('P'); |
1325 | - } else $offset = '+00:00'; |
|
1408 | + } else { |
|
1409 | + $offset = '+00:00'; |
|
1410 | + } |
|
1326 | 1411 | |
1327 | 1412 | if ($globalDBdriver == 'mysql') { |
1328 | 1413 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1387,8 +1472,11 @@ discard block |
||
1387 | 1472 | $query_values = array_merge($query_values,array(':month' => $month)); |
1388 | 1473 | } |
1389 | 1474 | } |
1390 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1391 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1475 | + if (empty($query_values)) { |
|
1476 | + $queryi .= $this->getFilter($filters); |
|
1477 | + } else { |
|
1478 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1479 | + } |
|
1392 | 1480 | |
1393 | 1481 | $sth = $this->db->prepare($queryi); |
1394 | 1482 | $sth->execute($query_values); |
@@ -1425,8 +1513,11 @@ discard block |
||
1425 | 1513 | $query_values = array_merge($query_values,array(':month' => $month)); |
1426 | 1514 | } |
1427 | 1515 | } |
1428 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1429 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1516 | + if (empty($query_values)) { |
|
1517 | + $queryi .= $this->getFilter($filters); |
|
1518 | + } else { |
|
1519 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1520 | + } |
|
1430 | 1521 | |
1431 | 1522 | $sth = $this->db->prepare($queryi); |
1432 | 1523 | $sth->execute($query_values); |
@@ -1448,7 +1539,9 @@ discard block |
||
1448 | 1539 | date_default_timezone_set($globalTimezone); |
1449 | 1540 | $datetime = new DateTime(); |
1450 | 1541 | $offset = $datetime->format('P'); |
1451 | - } else $offset = '+00:00'; |
|
1542 | + } else { |
|
1543 | + $offset = '+00:00'; |
|
1544 | + } |
|
1452 | 1545 | |
1453 | 1546 | if ($globalDBdriver == 'mysql') { |
1454 | 1547 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1552,7 +1645,9 @@ discard block |
||
1552 | 1645 | */ |
1553 | 1646 | public function parseDirection($direction = 0) |
1554 | 1647 | { |
1555 | - if ($direction == '') $direction = 0; |
|
1648 | + if ($direction == '') { |
|
1649 | + $direction = 0; |
|
1650 | + } |
|
1556 | 1651 | $direction_array = array(); |
1557 | 1652 | $temp_array = array(); |
1558 | 1653 | |
@@ -1641,7 +1736,9 @@ discard block |
||
1641 | 1736 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1642 | 1737 | |
1643 | 1738 | $Connection = new Connection($this->db); |
1644 | - if (!$Connection->tableExists('countries')) return ''; |
|
1739 | + if (!$Connection->tableExists('countries')) { |
|
1740 | + return ''; |
|
1741 | + } |
|
1645 | 1742 | |
1646 | 1743 | try { |
1647 | 1744 | /* |
@@ -1661,9 +1758,13 @@ discard block |
||
1661 | 1758 | $sth->closeCursor(); |
1662 | 1759 | if (count($row) > 0) { |
1663 | 1760 | return $row; |
1664 | - } else return ''; |
|
1761 | + } else { |
|
1762 | + return ''; |
|
1763 | + } |
|
1665 | 1764 | } catch (PDOException $e) { |
1666 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1765 | + if (isset($globalDebug) && $globalDebug) { |
|
1766 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1767 | + } |
|
1667 | 1768 | return ''; |
1668 | 1769 | } |
1669 | 1770 | |
@@ -1681,7 +1782,9 @@ discard block |
||
1681 | 1782 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1682 | 1783 | |
1683 | 1784 | $Connection = new Connection($this->db); |
1684 | - if (!$Connection->tableExists('countries')) return ''; |
|
1785 | + if (!$Connection->tableExists('countries')) { |
|
1786 | + return ''; |
|
1787 | + } |
|
1685 | 1788 | |
1686 | 1789 | try { |
1687 | 1790 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1693,9 +1796,13 @@ discard block |
||
1693 | 1796 | $sth->closeCursor(); |
1694 | 1797 | if (count($row) > 0) { |
1695 | 1798 | return $row; |
1696 | - } else return ''; |
|
1799 | + } else { |
|
1800 | + return ''; |
|
1801 | + } |
|
1697 | 1802 | } catch (PDOException $e) { |
1698 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1803 | + if (isset($globalDebug) && $globalDebug) { |
|
1804 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1805 | + } |
|
1699 | 1806 | return ''; |
1700 | 1807 | } |
1701 | 1808 | |
@@ -1713,7 +1820,9 @@ discard block |
||
1713 | 1820 | { |
1714 | 1821 | global $globalBitlyAccessToken; |
1715 | 1822 | |
1716 | - if ($globalBitlyAccessToken == '') return $url; |
|
1823 | + if ($globalBitlyAccessToken == '') { |
|
1824 | + return $url; |
|
1825 | + } |
|
1717 | 1826 | |
1718 | 1827 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1719 | 1828 | |
@@ -1789,7 +1898,9 @@ discard block |
||
1789 | 1898 | } |
1790 | 1899 | } |
1791 | 1900 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
1792 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1901 | + if ($limit) { |
|
1902 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1903 | + } |
|
1793 | 1904 | $sth = $this->db->prepare($query); |
1794 | 1905 | $sth->execute($query_values); |
1795 | 1906 | $marine_array = array(); |
@@ -1826,9 +1937,15 @@ discard block |
||
1826 | 1937 | foreach ($q_array as $q_item){ |
1827 | 1938 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
1828 | 1939 | $additional_query .= " AND ("; |
1829 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1830 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1831 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
1940 | + if (is_int($q_item)) { |
|
1941 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1942 | + } |
|
1943 | + if (is_int($q_item)) { |
|
1944 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1945 | + } |
|
1946 | + if (is_int($q_item)) { |
|
1947 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
1948 | + } |
|
1832 | 1949 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
1833 | 1950 | $additional_query .= ")"; |
1834 | 1951 | } |
@@ -1876,7 +1993,9 @@ discard block |
||
1876 | 1993 | date_default_timezone_set($globalTimezone); |
1877 | 1994 | $datetime = new DateTime(); |
1878 | 1995 | $offset = $datetime->format('P'); |
1879 | - } else $offset = '+00:00'; |
|
1996 | + } else { |
|
1997 | + $offset = '+00:00'; |
|
1998 | + } |
|
1880 | 1999 | if ($date_array[1] != "") |
1881 | 2000 | { |
1882 | 2001 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1903,8 +2022,12 @@ discard block |
||
1903 | 2022 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1904 | 2023 | { |
1905 | 2024 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1906 | - } else $limit_query = ""; |
|
1907 | - } else $limit_query = ""; |
|
2025 | + } else { |
|
2026 | + $limit_query = ""; |
|
2027 | + } |
|
2028 | + } else { |
|
2029 | + $limit_query = ""; |
|
2030 | + } |
|
1908 | 2031 | if ($sort != "") |
1909 | 2032 | { |
1910 | 2033 | $search_orderby_array = $this->getOrderBy(); |