@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug; |
56 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
56 | + if ($globalDebug) { |
|
57 | + echo "Update last seen tracked data...\n"; |
|
58 | + } |
|
57 | 59 | foreach ($this->all_tracked as $key => $flight) { |
58 | 60 | if (isset($this->all_tracked[$key]['id'])) { |
59 | 61 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -66,12 +68,16 @@ discard block |
||
66 | 68 | public function del() { |
67 | 69 | global $globalDebug; |
68 | 70 | // Delete old infos |
69 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
71 | + if ($globalDebug) { |
|
72 | + echo 'Delete old values and update latest data...'."\n"; |
|
73 | + } |
|
70 | 74 | foreach ($this->all_tracked as $key => $flight) { |
71 | 75 | if (isset($flight['lastupdate'])) { |
72 | 76 | if ($flight['lastupdate'] < (time()-3000)) { |
73 | 77 | if (isset($this->all_tracked[$key]['id'])) { |
74 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | + if ($globalDebug) { |
|
79 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
80 | + } |
|
75 | 81 | /* |
76 | 82 | $MarineLive = new MarineLive(); |
77 | 83 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -81,7 +87,9 @@ discard block |
||
81 | 87 | $Marine = new Marine($this->db); |
82 | 88 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
83 | 89 | $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']); |
84 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
90 | + if ($globalDebug && $result != 'success') { |
|
91 | + echo '!!! ERROR : '.$result."\n"; |
|
92 | + } |
|
85 | 93 | } |
86 | 94 | // Put in archive |
87 | 95 | // $Marine->db = null; |
@@ -94,7 +102,9 @@ discard block |
||
94 | 102 | |
95 | 103 | public function add($line) { |
96 | 104 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
97 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
105 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
106 | + $globalCoordMinChange = '0.02'; |
|
107 | + } |
|
98 | 108 | date_default_timezone_set('UTC'); |
99 | 109 | $dataFound = false; |
100 | 110 | $send = false; |
@@ -119,8 +129,11 @@ discard block |
||
119 | 129 | |
120 | 130 | $Common = new Common(); |
121 | 131 | $AIS = new AIS(); |
122 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
123 | - else $id = trim($line['id']); |
|
132 | + if (!isset($line['id'])) { |
|
133 | + $id = trim($line['mmsi']); |
|
134 | + } else { |
|
135 | + $id = trim($line['id']); |
|
136 | + } |
|
124 | 137 | |
125 | 138 | if (!isset($this->all_tracked[$id])) { |
126 | 139 | $this->all_tracked[$id] = array(); |
@@ -128,10 +141,16 @@ discard block |
||
128 | 141 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
129 | 142 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
130 | 143 | if (!isset($line['id'])) { |
131 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
144 | + if (!isset($globalDaemon)) { |
|
145 | + $globalDaemon = TRUE; |
|
146 | + } |
|
132 | 147 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
133 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
134 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
148 | + } else { |
|
149 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
150 | + } |
|
151 | + if ($globalAllTracked !== FALSE) { |
|
152 | + $dataFound = true; |
|
153 | + } |
|
135 | 154 | } |
136 | 155 | |
137 | 156 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -181,13 +200,19 @@ discard block |
||
181 | 200 | $Marine = new Marine($this->db); |
182 | 201 | $fromsource = NULL; |
183 | 202 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
184 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
203 | + if ($globalDebug && $result != 'success') { |
|
204 | + echo '!!! ERROR : '.$result."\n"; |
|
205 | + } |
|
185 | 206 | $Marine->db = null; |
186 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
207 | + if ($globalDebugTimeElapsed) { |
|
208 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
209 | + } |
|
187 | 210 | } |
188 | 211 | } |
189 | 212 | } |
190 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
213 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
214 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
215 | + } |
|
191 | 216 | } |
192 | 217 | |
193 | 218 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -198,14 +223,21 @@ discard block |
||
198 | 223 | if ($distance > 1000 && $distance < 10000) { |
199 | 224 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
200 | 225 | $speed = $speed*3.6; |
201 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
202 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
226 | + if ($speed < 1000) { |
|
227 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
228 | + } |
|
229 | + if ($globalDebug) { |
|
230 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
231 | + } |
|
203 | 232 | } |
204 | 233 | } |
205 | 234 | |
206 | 235 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
207 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
208 | - else unset($timediff); |
|
236 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
237 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
238 | + } else { |
|
239 | + unset($timediff); |
|
240 | + } |
|
209 | 241 | 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')))) { |
210 | 242 | 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'])) { |
211 | 243 | 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'])) { |
@@ -213,22 +245,32 @@ discard block |
||
213 | 245 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
214 | 246 | $this->all_tracked[$id]['putinarchive'] = true; |
215 | 247 | |
216 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
248 | + if ($globalDebug) { |
|
249 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
250 | + } |
|
217 | 251 | $timeelapsed = microtime(true); |
218 | 252 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
219 | 253 | $Marine = new Marine($this->db); |
220 | 254 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
221 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
255 | + if (!empty($all_country)) { |
|
256 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
257 | + } |
|
222 | 258 | $Marine->db = null; |
223 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
259 | + if ($globalDebugTimeElapsed) { |
|
260 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
261 | + } |
|
224 | 262 | } |
225 | 263 | $this->tmd = 0; |
226 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
264 | + if ($globalDebug) { |
|
265 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
266 | + } |
|
227 | 267 | } |
228 | 268 | } |
229 | 269 | |
230 | 270 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
231 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
271 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
272 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
273 | + } |
|
232 | 274 | 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') { |
233 | 275 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
234 | 276 | $dataFound = true; |
@@ -237,8 +279,12 @@ discard block |
||
237 | 279 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
238 | 280 | } |
239 | 281 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
240 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
241 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
282 | + if ($line['longitude'] > 180) { |
|
283 | + $line['longitude'] = $line['longitude'] - 360; |
|
284 | + } |
|
285 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
286 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
287 | + } |
|
242 | 288 | 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') { |
243 | 289 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
244 | 290 | $dataFound = true; |
@@ -256,7 +302,9 @@ discard block |
||
256 | 302 | } |
257 | 303 | } |
258 | 304 | if (isset($line['last_update']) && $line['last_update'] != '') { |
259 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
305 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
306 | + $dataFound = true; |
|
307 | + } |
|
260 | 308 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
261 | 309 | } |
262 | 310 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -274,15 +322,21 @@ discard block |
||
274 | 322 | } |
275 | 323 | |
276 | 324 | if (isset($line['heading']) && $line['heading'] != '') { |
277 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
326 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
327 | + } |
|
278 | 328 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
279 | 329 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
280 | 330 | //$dataFound = true; |
281 | 331 | } 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']) { |
282 | 332 | $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']); |
283 | 333 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
284 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
285 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
334 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
335 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
336 | + } |
|
337 | + if ($globalDebug) { |
|
338 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
339 | + } |
|
286 | 340 | } |
287 | 341 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
288 | 342 | |
@@ -290,8 +344,11 @@ discard block |
||
290 | 344 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
291 | 345 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
292 | 346 | } else { |
293 | - 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"; |
|
294 | - 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"; |
|
347 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
348 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
349 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
350 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
351 | + } |
|
295 | 352 | return ''; |
296 | 353 | } |
297 | 354 | } else { |
@@ -306,23 +363,38 @@ discard block |
||
306 | 363 | 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'])) { |
307 | 364 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
308 | 365 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
309 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
366 | + if ($globalDebug) { |
|
367 | + echo "Check if aircraft is already in DB..."; |
|
368 | + } |
|
310 | 369 | $timeelapsed = microtime(true); |
311 | 370 | $MarineLive = new MarineLive($this->db); |
312 | 371 | if (isset($line['id'])) { |
313 | 372 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
314 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
373 | + if ($globalDebugTimeElapsed) { |
|
374 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
375 | + } |
|
315 | 376 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
316 | 377 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
317 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
378 | + if ($globalDebugTimeElapsed) { |
|
379 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
380 | + } |
|
318 | 381 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
319 | 382 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
320 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
321 | - } else $recent_ident = ''; |
|
383 | + if ($globalDebugTimeElapsed) { |
|
384 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
385 | + } |
|
386 | + } else { |
|
387 | + $recent_ident = ''; |
|
388 | + } |
|
322 | 389 | $MarineLive->db=null; |
323 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
324 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
325 | - } else $recent_ident = ''; |
|
390 | + if ($globalDebug && $recent_ident == '') { |
|
391 | + echo " Not in DB.\n"; |
|
392 | + } elseif ($globalDebug && $recent_ident != '') { |
|
393 | + echo " Already in DB.\n"; |
|
394 | + } |
|
395 | + } else { |
|
396 | + $recent_ident = ''; |
|
397 | + } |
|
326 | 398 | } else { |
327 | 399 | $recent_ident = ''; |
328 | 400 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -330,18 +402,26 @@ discard block |
||
330 | 402 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
331 | 403 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
332 | 404 | { |
333 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
405 | + if ($globalDebug) { |
|
406 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
407 | + } |
|
334 | 408 | //adds the spotter data for the archive |
335 | 409 | $highlight = ''; |
336 | - 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'))); |
|
410 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
411 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
412 | + } |
|
337 | 413 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
338 | 414 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
339 | 415 | $timeelapsed = microtime(true); |
340 | 416 | $Marine = new Marine($this->db); |
341 | 417 | $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]['format_source'],$this->all_tracked[$id]['source_name']); |
342 | 418 | $Marine->db = null; |
343 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
344 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
419 | + if ($globalDebug && isset($result)) { |
|
420 | + echo $result."\n"; |
|
421 | + } |
|
422 | + if ($globalDebugTimeElapsed) { |
|
423 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
424 | + } |
|
345 | 425 | } |
346 | 426 | } |
347 | 427 | /* |
@@ -376,13 +456,17 @@ discard block |
||
376 | 456 | $this->all_tracked[$id]['addedMarine'] = 1; |
377 | 457 | //print_r($this->all_tracked[$id]); |
378 | 458 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
379 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
459 | + if ($globalDebug) { |
|
460 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
461 | + } |
|
380 | 462 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
381 | 463 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
382 | 464 | $MarineLive = new MarineLive($this->db); |
383 | 465 | $MarineLive->deleteLiveMarineData(); |
384 | 466 | $MarineLive->db=null; |
385 | - if ($globalDebug) echo " Done\n"; |
|
467 | + if ($globalDebug) { |
|
468 | + echo " Done\n"; |
|
469 | + } |
|
386 | 470 | } |
387 | 471 | $this->last_delete = time(); |
388 | 472 | } |
@@ -408,15 +492,21 @@ discard block |
||
408 | 492 | |
409 | 493 | if (!$ignoreImport) { |
410 | 494 | 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'])) { |
411 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
495 | + if ($globalDebug) { |
|
496 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
497 | + } |
|
412 | 498 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
413 | 499 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
414 | 500 | $timeelapsed = microtime(true); |
415 | 501 | $MarineLive = new MarineLive($this->db); |
416 | 502 | $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]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
417 | 503 | $MarineLive->db = null; |
418 | - if ($globalDebug) echo $result."\n"; |
|
419 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
504 | + if ($globalDebug) { |
|
505 | + echo $result."\n"; |
|
506 | + } |
|
507 | + if ($globalDebugTimeElapsed) { |
|
508 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
509 | + } |
|
420 | 510 | } |
421 | 511 | } |
422 | 512 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -479,19 +569,27 @@ discard block |
||
479 | 569 | */ |
480 | 570 | |
481 | 571 | $this->all_tracked[$id]['lastupdate'] = time(); |
482 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
483 | - } 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"; |
|
572 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
573 | + $send = true; |
|
574 | + } |
|
575 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
576 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
577 | + } |
|
484 | 578 | //$this->del(); |
485 | 579 | |
486 | 580 | |
487 | 581 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
488 | 582 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
489 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
583 | + if ($globalDebug) { |
|
584 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
585 | + } |
|
490 | 586 | $MarineLive = new MarineLive($this->db); |
491 | 587 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
492 | 588 | $MarineLive->db = null; |
493 | 589 | //MarineLive->deleteLiveMarineData(); |
494 | - if ($globalDebug) echo " Done\n"; |
|
590 | + if ($globalDebug) { |
|
591 | + echo " Done\n"; |
|
592 | + } |
|
495 | 593 | } |
496 | 594 | $this->last_delete_hourly = time(); |
497 | 595 | } |
@@ -500,7 +598,9 @@ discard block |
||
500 | 598 | //$ignoreImport = false; |
501 | 599 | } |
502 | 600 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
503 | - if ($send) return $this->all_tracked[$id]; |
|
601 | + if ($send) { |
|
602 | + return $this->all_tracked[$id]; |
|
603 | + } |
|
504 | 604 | } |
505 | 605 | } |
506 | 606 | } |