@@ -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,35 +212,50 @@ 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->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
| 191 | 219 | $Marine->db = null; |
| 192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 220 | + if ($globalDebugTimeElapsed) { |
|
| 221 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 222 | + } |
|
| 193 | 223 | } |
| 194 | 224 | } |
| 195 | 225 | } |
| 196 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 226 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 227 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 228 | + } |
|
| 197 | 229 | } |
| 198 | 230 | |
| 199 | 231 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
| 200 | 232 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 201 | 233 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 202 | 234 | } else { |
| 203 | - 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"; |
|
| 204 | - 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"; |
|
| 235 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 236 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 237 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 238 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 239 | + } |
|
| 205 | 240 | return ''; |
| 206 | 241 | } |
| 207 | 242 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
| 208 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 243 | + if ($globalDebug) { |
|
| 244 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 245 | + } |
|
| 209 | 246 | return ''; |
| 210 | 247 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
| 211 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 248 | + if ($globalDebug) { |
|
| 249 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 250 | + } |
|
| 212 | 251 | return ''; |
| 213 | 252 | } elseif (!isset($line['datetime'])) { |
| 214 | 253 | date_default_timezone_set('UTC'); |
| 215 | 254 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 216 | 255 | } else { |
| 217 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
| 256 | + if ($globalDebug) { |
|
| 257 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
| 258 | + } |
|
| 218 | 259 | return ''; |
| 219 | 260 | } |
| 220 | 261 | |
@@ -227,14 +268,21 @@ discard block |
||
| 227 | 268 | if ($distance > 1000 && $distance < 10000) { |
| 228 | 269 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 229 | 270 | $speed = $speed*3.6; |
| 230 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 231 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 271 | + if ($speed < 1000) { |
|
| 272 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 273 | + } |
|
| 274 | + if ($globalDebug) { |
|
| 275 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 276 | + } |
|
| 232 | 277 | } |
| 233 | 278 | } |
| 234 | 279 | |
| 235 | 280 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 236 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 237 | - else unset($timediff); |
|
| 281 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 282 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 283 | + } else { |
|
| 284 | + unset($timediff); |
|
| 285 | + } |
|
| 238 | 286 | 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')))) { |
| 239 | 287 | 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'])) { |
| 240 | 288 | 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'])) { |
@@ -242,22 +290,32 @@ discard block |
||
| 242 | 290 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 243 | 291 | $this->all_tracked[$id]['putinarchive'] = true; |
| 244 | 292 | |
| 245 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 293 | + if ($globalDebug) { |
|
| 294 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 295 | + } |
|
| 246 | 296 | $timeelapsed = microtime(true); |
| 247 | 297 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 248 | 298 | $Marine = new Marine($this->db); |
| 249 | 299 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 250 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 300 | + if (!empty($all_country)) { |
|
| 301 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 302 | + } |
|
| 251 | 303 | $Marine->db = null; |
| 252 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 304 | + if ($globalDebugTimeElapsed) { |
|
| 305 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 306 | + } |
|
| 253 | 307 | } |
| 254 | 308 | $this->tmd = 0; |
| 255 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 309 | + if ($globalDebug) { |
|
| 310 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 311 | + } |
|
| 256 | 312 | } |
| 257 | 313 | } |
| 258 | 314 | |
| 259 | 315 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 260 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 316 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 317 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 318 | + } |
|
| 261 | 319 | 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') { |
| 262 | 320 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 263 | 321 | $dataFound = true; |
@@ -266,8 +324,12 @@ discard block |
||
| 266 | 324 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 267 | 325 | } |
| 268 | 326 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 269 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 270 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 327 | + if ($line['longitude'] > 180) { |
|
| 328 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 329 | + } |
|
| 330 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 331 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 332 | + } |
|
| 271 | 333 | 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') { |
| 272 | 334 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 273 | 335 | $dataFound = true; |
@@ -285,7 +347,9 @@ discard block |
||
| 285 | 347 | } |
| 286 | 348 | } |
| 287 | 349 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 288 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 350 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 351 | + $dataFound = true; |
|
| 352 | + } |
|
| 289 | 353 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 290 | 354 | } |
| 291 | 355 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -315,15 +379,21 @@ discard block |
||
| 315 | 379 | } |
| 316 | 380 | |
| 317 | 381 | if (isset($line['heading']) && $line['heading'] != '') { |
| 318 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 382 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 383 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 384 | + } |
|
| 319 | 385 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 320 | 386 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 321 | 387 | //$dataFound = true; |
| 322 | 388 | } 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']) { |
| 323 | 389 | $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']); |
| 324 | 390 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 325 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 326 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 391 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 392 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 393 | + } |
|
| 394 | + if ($globalDebug) { |
|
| 395 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 396 | + } |
|
| 327 | 397 | } |
| 328 | 398 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 329 | 399 | |
@@ -335,23 +405,38 @@ discard block |
||
| 335 | 405 | 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'])) { |
| 336 | 406 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 337 | 407 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 338 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 408 | + if ($globalDebug) { |
|
| 409 | + echo "Check if aircraft is already in DB..."; |
|
| 410 | + } |
|
| 339 | 411 | $timeelapsed = microtime(true); |
| 340 | 412 | $MarineLive = new MarineLive($this->db); |
| 341 | 413 | if (isset($line['id'])) { |
| 342 | 414 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 343 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 415 | + if ($globalDebugTimeElapsed) { |
|
| 416 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 417 | + } |
|
| 344 | 418 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 345 | 419 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 420 | + if ($globalDebugTimeElapsed) { |
|
| 421 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 422 | + } |
|
| 347 | 423 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 348 | 424 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 349 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 350 | - } else $recent_ident = ''; |
|
| 425 | + if ($globalDebugTimeElapsed) { |
|
| 426 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 427 | + } |
|
| 428 | + } else { |
|
| 429 | + $recent_ident = ''; |
|
| 430 | + } |
|
| 351 | 431 | $MarineLive->db=null; |
| 352 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 353 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 354 | - } else $recent_ident = ''; |
|
| 432 | + if ($globalDebug && $recent_ident == '') { |
|
| 433 | + echo " Not in DB.\n"; |
|
| 434 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 435 | + echo " Already in DB.\n"; |
|
| 436 | + } |
|
| 437 | + } else { |
|
| 438 | + $recent_ident = ''; |
|
| 439 | + } |
|
| 355 | 440 | } else { |
| 356 | 441 | $recent_ident = ''; |
| 357 | 442 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -359,30 +444,44 @@ discard block |
||
| 359 | 444 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 360 | 445 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
| 361 | 446 | { |
| 362 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 447 | + if ($globalDebug) { |
|
| 448 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 449 | + } |
|
| 363 | 450 | //adds the spotter data for the archive |
| 364 | 451 | $highlight = ''; |
| 365 | - 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'))); |
|
| 452 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 453 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 454 | + } |
|
| 366 | 455 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 367 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 368 | 457 | $timeelapsed = microtime(true); |
| 369 | 458 | $Marine = new Marine($this->db); |
| 370 | 459 | $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']); |
| 371 | 460 | $Marine->db = null; |
| 372 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 373 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 461 | + if ($globalDebug && isset($result)) { |
|
| 462 | + echo $result."\n"; |
|
| 463 | + } |
|
| 464 | + if ($globalDebugTimeElapsed) { |
|
| 465 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 466 | + } |
|
| 374 | 467 | } |
| 375 | 468 | } |
| 376 | 469 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 377 | 470 | // Add source stat in DB |
| 378 | 471 | $Stats = new Stats($this->db); |
| 379 | 472 | if (!empty($this->stats)) { |
| 380 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 473 | + if ($globalDebug) { |
|
| 474 | + echo 'Add source stats : '; |
|
| 475 | + } |
|
| 381 | 476 | foreach($this->stats as $date => $data) { |
| 382 | 477 | foreach($data as $source => $sourced) { |
| 383 | 478 | //print_r($sourced); |
| 384 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 385 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 479 | + if (isset($sourced['polar'])) { |
|
| 480 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 481 | + } |
|
| 482 | + if (isset($sourced['hist'])) { |
|
| 483 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 484 | + } |
|
| 386 | 485 | if (isset($sourced['msg'])) { |
| 387 | 486 | if (time() - $sourced['msg']['date'] > 10) { |
| 388 | 487 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -395,7 +494,9 @@ discard block |
||
| 395 | 494 | unset($this->stats[$date]); |
| 396 | 495 | } |
| 397 | 496 | } |
| 398 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 497 | + if ($globalDebug) { |
|
| 498 | + echo 'Done'."\n"; |
|
| 499 | + } |
|
| 399 | 500 | } |
| 400 | 501 | $Stats->db = null; |
| 401 | 502 | } |
@@ -405,13 +506,17 @@ discard block |
||
| 405 | 506 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 406 | 507 | //print_r($this->all_tracked[$id]); |
| 407 | 508 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 408 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 509 | + if ($globalDebug) { |
|
| 510 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 511 | + } |
|
| 409 | 512 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 410 | 513 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 411 | 514 | $MarineLive = new MarineLive($this->db); |
| 412 | 515 | $MarineLive->deleteLiveMarineData(); |
| 413 | 516 | $MarineLive->db=null; |
| 414 | - if ($globalDebug) echo " Done\n"; |
|
| 517 | + if ($globalDebug) { |
|
| 518 | + echo " Done\n"; |
|
| 519 | + } |
|
| 415 | 520 | } |
| 416 | 521 | $this->last_delete = time(); |
| 417 | 522 | } |
@@ -437,15 +542,21 @@ discard block |
||
| 437 | 542 | |
| 438 | 543 | if (!$ignoreImport) { |
| 439 | 544 | 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'])) { |
| 440 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 545 | + if ($globalDebug) { |
|
| 546 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 547 | + } |
|
| 441 | 548 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 442 | 549 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 443 | 550 | $timeelapsed = microtime(true); |
| 444 | 551 | $MarineLive = new MarineLive($this->db); |
| 445 | 552 | $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']); |
| 446 | 553 | $MarineLive->db = null; |
| 447 | - if ($globalDebug) echo $result."\n"; |
|
| 448 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 554 | + if ($globalDebug) { |
|
| 555 | + echo $result."\n"; |
|
| 556 | + } |
|
| 557 | + if ($globalDebugTimeElapsed) { |
|
| 558 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 559 | + } |
|
| 449 | 560 | } |
| 450 | 561 | } |
| 451 | 562 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -457,7 +568,9 @@ discard block |
||
| 457 | 568 | |
| 458 | 569 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 459 | 570 | $source = $this->all_tracked[$id]['source_name']; |
| 460 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
| 571 | + if ($source == '') { |
|
| 572 | + $source = $this->all_tracked[$id]['format_source']; |
|
| 573 | + } |
|
| 461 | 574 | if (!isset($this->source_location[$source])) { |
| 462 | 575 | $Location = new Source($this->db); |
| 463 | 576 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -478,7 +591,9 @@ discard block |
||
| 478 | 591 | $stats_heading = round($stats_heading/22.5); |
| 479 | 592 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 480 | 593 | $current_date = date('Y-m-d'); |
| 481 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 594 | + if ($stats_heading == 16) { |
|
| 595 | + $stats_heading = 0; |
|
| 596 | + } |
|
| 482 | 597 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 483 | 598 | for ($i=0;$i<=15;$i++) { |
| 484 | 599 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -496,7 +611,9 @@ discard block |
||
| 496 | 611 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 497 | 612 | end($this->stats[$current_date][$source]['hist']); |
| 498 | 613 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 499 | - } else $mini = 0; |
|
| 614 | + } else { |
|
| 615 | + $mini = 0; |
|
| 616 | + } |
|
| 500 | 617 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 501 | 618 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 502 | 619 | } |
@@ -508,19 +625,27 @@ discard block |
||
| 508 | 625 | |
| 509 | 626 | |
| 510 | 627 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 511 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 512 | - } 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"; |
|
| 628 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 629 | + $send = true; |
|
| 630 | + } |
|
| 631 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 632 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 633 | + } |
|
| 513 | 634 | //$this->del(); |
| 514 | 635 | |
| 515 | 636 | |
| 516 | 637 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 517 | 638 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 518 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 639 | + if ($globalDebug) { |
|
| 640 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 641 | + } |
|
| 519 | 642 | $MarineLive = new MarineLive($this->db); |
| 520 | 643 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 521 | 644 | $MarineLive->db = null; |
| 522 | 645 | //MarineLive->deleteLiveMarineData(); |
| 523 | - if ($globalDebug) echo " Done\n"; |
|
| 646 | + if ($globalDebug) { |
|
| 647 | + echo " Done\n"; |
|
| 648 | + } |
|
| 524 | 649 | } |
| 525 | 650 | $this->last_delete_hourly = time(); |
| 526 | 651 | } |
@@ -529,7 +654,9 @@ discard block |
||
| 529 | 654 | //$ignoreImport = false; |
| 530 | 655 | } |
| 531 | 656 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 532 | - if ($send) return $this->all_tracked[$id]; |
|
| 657 | + if ($send) { |
|
| 658 | + return $this->all_tracked[$id]; |
|
| 659 | + } |
|
| 533 | 660 | } |
| 534 | 661 | } |
| 535 | 662 | } |
@@ -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) { |
@@ -72,8 +76,11 @@ discard block |
||
| 72 | 76 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 73 | 77 | } |
| 74 | 78 | } |
| 75 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 76 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 79 | + if ($filter_query_where == '' && $where) { |
|
| 80 | + $filter_query_where = ' WHERE'; |
|
| 81 | + } elseif ($filter_query_where != '' && $and) { |
|
| 82 | + $filter_query_where .= ' AND'; |
|
| 83 | + } |
|
| 77 | 84 | if ($filter_query_where != '') { |
| 78 | 85 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 79 | 86 | } |
@@ -127,32 +134,54 @@ discard block |
||
| 127 | 134 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 128 | 135 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 129 | 136 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 130 | - */} |
|
| 131 | - elseif (isset($row['marineid'])) { |
|
| 137 | + */} elseif (isset($row['marineid'])) { |
|
| 132 | 138 | $temp_array['marine_id'] = $row['marineid']; |
| 133 | 139 | } else { |
| 134 | 140 | $temp_array['marine_id'] = ''; |
| 135 | 141 | } |
| 136 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 137 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
| 138 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 139 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
| 140 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
| 141 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 142 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 143 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 142 | + if (isset($row['fammarine_id'])) { |
|
| 143 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 144 | + } |
|
| 145 | + if (isset($row['mmsi'])) { |
|
| 146 | + $temp_array['mmsi'] = $row['mmsi']; |
|
| 147 | + } |
|
| 148 | + if (isset($row['type'])) { |
|
| 149 | + $temp_array['type'] = $row['type']; |
|
| 150 | + } |
|
| 151 | + if (isset($row['type_id'])) { |
|
| 152 | + $temp_array['type_id'] = $row['type_id']; |
|
| 153 | + } |
|
| 154 | + if (isset($row['ident'])) { |
|
| 155 | + $temp_array['ident'] = $row['ident']; |
|
| 156 | + } |
|
| 157 | + if (isset($row['latitude'])) { |
|
| 158 | + $temp_array['latitude'] = $row['latitude']; |
|
| 159 | + } |
|
| 160 | + if (isset($row['longitude'])) { |
|
| 161 | + $temp_array['longitude'] = $row['longitude']; |
|
| 162 | + } |
|
| 163 | + if (isset($row['format_source'])) { |
|
| 164 | + $temp_array['format_source'] = $row['format_source']; |
|
| 165 | + } |
|
| 144 | 166 | if (isset($row['heading'])) { |
| 145 | 167 | $temp_array['heading'] = $row['heading']; |
| 146 | 168 | $heading_direction = $this->parseDirection($row['heading']); |
| 147 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 169 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 170 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + if (isset($row['ground_speed'])) { |
|
| 174 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 148 | 175 | } |
| 149 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 150 | 176 | |
| 151 | 177 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
| 152 | 178 | { |
| 153 | 179 | $Image = new Image($this->db); |
| 154 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 155 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 180 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
| 181 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 182 | + } else { |
|
| 183 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 184 | + } |
|
| 156 | 185 | unset($Image); |
| 157 | 186 | if (count($image_array) > 0) { |
| 158 | 187 | $temp_array['image'] = $image_array[0]['image']; |
@@ -204,13 +233,21 @@ discard block |
||
| 204 | 233 | } |
| 205 | 234 | |
| 206 | 235 | $fromsource = NULL; |
| 207 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 208 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 209 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 236 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 237 | + $temp_array['source_name'] = $row['source_name']; |
|
| 238 | + } |
|
| 239 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 240 | + $temp_array['over_country'] = $row['over_country']; |
|
| 241 | + } |
|
| 242 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 243 | + $temp_array['distance'] = $row['distance']; |
|
| 244 | + } |
|
| 210 | 245 | $temp_array['query_number_rows'] = $num_rows; |
| 211 | 246 | $spotter_array[] = $temp_array; |
| 212 | 247 | } |
| 213 | - if ($num_rows == 0) return array(); |
|
| 248 | + if ($num_rows == 0) { |
|
| 249 | + return array(); |
|
| 250 | + } |
|
| 214 | 251 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 215 | 252 | return $spotter_array; |
| 216 | 253 | } |
@@ -236,8 +273,12 @@ discard block |
||
| 236 | 273 | { |
| 237 | 274 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 238 | 275 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 239 | - } else $limit_query = ""; |
|
| 240 | - } else $limit_query = ""; |
|
| 276 | + } else { |
|
| 277 | + $limit_query = ""; |
|
| 278 | + } |
|
| 279 | + } else { |
|
| 280 | + $limit_query = ""; |
|
| 281 | + } |
|
| 241 | 282 | if ($sort != "") |
| 242 | 283 | { |
| 243 | 284 | $search_orderby_array = $this->getOrderBy(); |
@@ -261,7 +302,9 @@ discard block |
||
| 261 | 302 | global $global_query; |
| 262 | 303 | |
| 263 | 304 | date_default_timezone_set('UTC'); |
| 264 | - if ($id == '') return array(); |
|
| 305 | + if ($id == '') { |
|
| 306 | + return array(); |
|
| 307 | + } |
|
| 265 | 308 | $additional_query = "marine_output.fammarine_id = :id"; |
| 266 | 309 | $query_values = array(':id' => $id); |
| 267 | 310 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -404,8 +447,11 @@ discard block |
||
| 404 | 447 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 405 | 448 | |
| 406 | 449 | $sth = $this->db->prepare($query); |
| 407 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 408 | - else $sth->execute(); |
|
| 450 | + if (!empty($query_values)) { |
|
| 451 | + $sth->execute($query_values); |
|
| 452 | + } else { |
|
| 453 | + $sth->execute(); |
|
| 454 | + } |
|
| 409 | 455 | |
| 410 | 456 | $source_array = array(); |
| 411 | 457 | $temp_array = array(); |
@@ -460,8 +506,11 @@ discard block |
||
| 460 | 506 | $sth = $this->db->prepare($query); |
| 461 | 507 | $sth->execute(array(':mmsi' => $mmsi)); |
| 462 | 508 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 463 | - if (isset($result[0])) return $result[0]; |
|
| 464 | - else return array(); |
|
| 509 | + if (isset($result[0])) { |
|
| 510 | + return $result[0]; |
|
| 511 | + } else { |
|
| 512 | + return array(); |
|
| 513 | + } |
|
| 465 | 514 | } |
| 466 | 515 | |
| 467 | 516 | /** |
@@ -495,7 +544,9 @@ discard block |
||
| 495 | 544 | date_default_timezone_set($globalTimezone); |
| 496 | 545 | $datetime = new DateTime(); |
| 497 | 546 | $offset = $datetime->format('P'); |
| 498 | - } else $offset = '+00:00'; |
|
| 547 | + } else { |
|
| 548 | + $offset = '+00:00'; |
|
| 549 | + } |
|
| 499 | 550 | |
| 500 | 551 | if ($globalDBdriver == 'mysql') { |
| 501 | 552 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -720,9 +771,15 @@ discard block |
||
| 720 | 771 | $latitude = 0; |
| 721 | 772 | $longitude = 0; |
| 722 | 773 | } |
| 723 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 724 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 725 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 774 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 775 | + $heading = 0; |
|
| 776 | + } |
|
| 777 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
| 778 | + $groundspeed = 0; |
|
| 779 | + } |
|
| 780 | + if ($arrival_date == '') { |
|
| 781 | + $arrival_date = NULL; |
|
| 782 | + } |
|
| 726 | 783 | $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) |
| 727 | 784 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 728 | 785 | |
@@ -830,7 +887,9 @@ discard block |
||
| 830 | 887 | global $globalDBdriver, $globalArchive; |
| 831 | 888 | //$filter_query = $this->getFilter($filters,true,true); |
| 832 | 889 | $Connection= new Connection($this->db); |
| 833 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 890 | + if (!$Connection->tableExists('countries')) { |
|
| 891 | + return array(); |
|
| 892 | + } |
|
| 834 | 893 | require_once('class.SpotterLive.php'); |
| 835 | 894 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 836 | 895 | $MarineLive = new MarineLive($this->db); |
@@ -874,7 +933,9 @@ discard block |
||
| 874 | 933 | $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 "; |
| 875 | 934 | } |
| 876 | 935 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 877 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 936 | + if ($limit) { |
|
| 937 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 938 | + } |
|
| 878 | 939 | |
| 879 | 940 | $sth = $this->db->prepare($query); |
| 880 | 941 | $sth->execute(); |
@@ -908,12 +969,18 @@ discard block |
||
| 908 | 969 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 909 | 970 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 910 | 971 | if ($olderthanmonths > 0) { |
| 911 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 912 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 972 | + if ($globalDBdriver == 'mysql') { |
|
| 973 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 974 | + } else { |
|
| 975 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 976 | + } |
|
| 913 | 977 | } |
| 914 | 978 | if ($sincedate != '') { |
| 915 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 916 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 979 | + if ($globalDBdriver == 'mysql') { |
|
| 980 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 981 | + } else { |
|
| 982 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 983 | + } |
|
| 917 | 984 | } |
| 918 | 985 | $query_values = array(); |
| 919 | 986 | if ($year != '') { |
@@ -944,7 +1011,9 @@ discard block |
||
| 944 | 1011 | } |
| 945 | 1012 | } |
| 946 | 1013 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 947 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1014 | + if ($limit) { |
|
| 1015 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1016 | + } |
|
| 948 | 1017 | |
| 949 | 1018 | $sth = $this->db->prepare($query); |
| 950 | 1019 | $sth->execute($query_values); |
@@ -979,7 +1048,9 @@ discard block |
||
| 979 | 1048 | date_default_timezone_set($globalTimezone); |
| 980 | 1049 | $datetime = new DateTime(); |
| 981 | 1050 | $offset = $datetime->format('P'); |
| 982 | - } else $offset = '+00:00'; |
|
| 1051 | + } else { |
|
| 1052 | + $offset = '+00:00'; |
|
| 1053 | + } |
|
| 983 | 1054 | |
| 984 | 1055 | if ($globalDBdriver == 'mysql') { |
| 985 | 1056 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1029,7 +1100,9 @@ discard block |
||
| 1029 | 1100 | date_default_timezone_set($globalTimezone); |
| 1030 | 1101 | $datetime = new DateTime(); |
| 1031 | 1102 | $offset = $datetime->format('P'); |
| 1032 | - } else $offset = '+00:00'; |
|
| 1103 | + } else { |
|
| 1104 | + $offset = '+00:00'; |
|
| 1105 | + } |
|
| 1033 | 1106 | $filter_query = $this->getFilter($filters,true,true); |
| 1034 | 1107 | if ($globalDBdriver == 'mysql') { |
| 1035 | 1108 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1075,7 +1148,9 @@ discard block |
||
| 1075 | 1148 | date_default_timezone_set($globalTimezone); |
| 1076 | 1149 | $datetime = new DateTime(); |
| 1077 | 1150 | $offset = $datetime->format('P'); |
| 1078 | - } else $offset = '+00:00'; |
|
| 1151 | + } else { |
|
| 1152 | + $offset = '+00:00'; |
|
| 1153 | + } |
|
| 1079 | 1154 | $filter_query = $this->getFilter($filters,true,true); |
| 1080 | 1155 | if ($globalDBdriver == 'mysql') { |
| 1081 | 1156 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1123,7 +1198,9 @@ discard block |
||
| 1123 | 1198 | date_default_timezone_set($globalTimezone); |
| 1124 | 1199 | $datetime = new DateTime(); |
| 1125 | 1200 | $offset = $datetime->format('P'); |
| 1126 | - } else $offset = '+00:00'; |
|
| 1201 | + } else { |
|
| 1202 | + $offset = '+00:00'; |
|
| 1203 | + } |
|
| 1127 | 1204 | |
| 1128 | 1205 | if ($globalDBdriver == 'mysql') { |
| 1129 | 1206 | $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 |
@@ -1172,7 +1249,9 @@ discard block |
||
| 1172 | 1249 | date_default_timezone_set($globalTimezone); |
| 1173 | 1250 | $datetime = new DateTime(); |
| 1174 | 1251 | $offset = $datetime->format('P'); |
| 1175 | - } else $offset = '+00:00'; |
|
| 1252 | + } else { |
|
| 1253 | + $offset = '+00:00'; |
|
| 1254 | + } |
|
| 1176 | 1255 | $filter_query = $this->getFilter($filters,true,true); |
| 1177 | 1256 | if ($globalDBdriver == 'mysql') { |
| 1178 | 1257 | $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 |
@@ -1221,7 +1300,9 @@ discard block |
||
| 1221 | 1300 | date_default_timezone_set($globalTimezone); |
| 1222 | 1301 | $datetime = new DateTime(); |
| 1223 | 1302 | $offset = $datetime->format('P'); |
| 1224 | - } else $offset = '+00:00'; |
|
| 1303 | + } else { |
|
| 1304 | + $offset = '+00:00'; |
|
| 1305 | + } |
|
| 1225 | 1306 | |
| 1226 | 1307 | $orderby_sql = ''; |
| 1227 | 1308 | if ($orderby == "hour") |
@@ -1290,7 +1371,9 @@ discard block |
||
| 1290 | 1371 | date_default_timezone_set($globalTimezone); |
| 1291 | 1372 | $datetime = new DateTime($date); |
| 1292 | 1373 | $offset = $datetime->format('P'); |
| 1293 | - } else $offset = '+00:00'; |
|
| 1374 | + } else { |
|
| 1375 | + $offset = '+00:00'; |
|
| 1376 | + } |
|
| 1294 | 1377 | |
| 1295 | 1378 | if ($globalDBdriver == 'mysql') { |
| 1296 | 1379 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1338,7 +1421,9 @@ discard block |
||
| 1338 | 1421 | date_default_timezone_set($globalTimezone); |
| 1339 | 1422 | $datetime = new DateTime(); |
| 1340 | 1423 | $offset = $datetime->format('P'); |
| 1341 | - } else $offset = '+00:00'; |
|
| 1424 | + } else { |
|
| 1425 | + $offset = '+00:00'; |
|
| 1426 | + } |
|
| 1342 | 1427 | |
| 1343 | 1428 | if ($globalDBdriver == 'mysql') { |
| 1344 | 1429 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1403,8 +1488,11 @@ discard block |
||
| 1403 | 1488 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1404 | 1489 | } |
| 1405 | 1490 | } |
| 1406 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1407 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1491 | + if (empty($query_values)) { |
|
| 1492 | + $queryi .= $this->getFilter($filters); |
|
| 1493 | + } else { |
|
| 1494 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1495 | + } |
|
| 1408 | 1496 | |
| 1409 | 1497 | $sth = $this->db->prepare($queryi); |
| 1410 | 1498 | $sth->execute($query_values); |
@@ -1441,8 +1529,11 @@ discard block |
||
| 1441 | 1529 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1442 | 1530 | } |
| 1443 | 1531 | } |
| 1444 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1445 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1532 | + if (empty($query_values)) { |
|
| 1533 | + $queryi .= $this->getFilter($filters); |
|
| 1534 | + } else { |
|
| 1535 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1536 | + } |
|
| 1446 | 1537 | |
| 1447 | 1538 | $sth = $this->db->prepare($queryi); |
| 1448 | 1539 | $sth->execute($query_values); |
@@ -1464,7 +1555,9 @@ discard block |
||
| 1464 | 1555 | date_default_timezone_set($globalTimezone); |
| 1465 | 1556 | $datetime = new DateTime(); |
| 1466 | 1557 | $offset = $datetime->format('P'); |
| 1467 | - } else $offset = '+00:00'; |
|
| 1558 | + } else { |
|
| 1559 | + $offset = '+00:00'; |
|
| 1560 | + } |
|
| 1468 | 1561 | |
| 1469 | 1562 | if ($globalDBdriver == 'mysql') { |
| 1470 | 1563 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1568,7 +1661,9 @@ discard block |
||
| 1568 | 1661 | */ |
| 1569 | 1662 | public function parseDirection($direction = 0) |
| 1570 | 1663 | { |
| 1571 | - if ($direction == '') $direction = 0; |
|
| 1664 | + if ($direction == '') { |
|
| 1665 | + $direction = 0; |
|
| 1666 | + } |
|
| 1572 | 1667 | $direction_array = array(); |
| 1573 | 1668 | $temp_array = array(); |
| 1574 | 1669 | |
@@ -1657,7 +1752,9 @@ discard block |
||
| 1657 | 1752 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1658 | 1753 | |
| 1659 | 1754 | $Connection = new Connection($this->db); |
| 1660 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1755 | + if (!$Connection->tableExists('countries')) { |
|
| 1756 | + return ''; |
|
| 1757 | + } |
|
| 1661 | 1758 | |
| 1662 | 1759 | try { |
| 1663 | 1760 | /* |
@@ -1677,9 +1774,13 @@ discard block |
||
| 1677 | 1774 | $sth->closeCursor(); |
| 1678 | 1775 | if (count($row) > 0) { |
| 1679 | 1776 | return $row; |
| 1680 | - } else return ''; |
|
| 1777 | + } else { |
|
| 1778 | + return ''; |
|
| 1779 | + } |
|
| 1681 | 1780 | } catch (PDOException $e) { |
| 1682 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1781 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1782 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1783 | + } |
|
| 1683 | 1784 | return ''; |
| 1684 | 1785 | } |
| 1685 | 1786 | |
@@ -1697,7 +1798,9 @@ discard block |
||
| 1697 | 1798 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 1698 | 1799 | |
| 1699 | 1800 | $Connection = new Connection($this->db); |
| 1700 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1801 | + if (!$Connection->tableExists('countries')) { |
|
| 1802 | + return ''; |
|
| 1803 | + } |
|
| 1701 | 1804 | |
| 1702 | 1805 | try { |
| 1703 | 1806 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1709,9 +1812,13 @@ discard block |
||
| 1709 | 1812 | $sth->closeCursor(); |
| 1710 | 1813 | if (count($row) > 0) { |
| 1711 | 1814 | return $row; |
| 1712 | - } else return ''; |
|
| 1815 | + } else { |
|
| 1816 | + return ''; |
|
| 1817 | + } |
|
| 1713 | 1818 | } catch (PDOException $e) { |
| 1714 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1819 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1820 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1821 | + } |
|
| 1715 | 1822 | return ''; |
| 1716 | 1823 | } |
| 1717 | 1824 | |
@@ -1729,7 +1836,9 @@ discard block |
||
| 1729 | 1836 | { |
| 1730 | 1837 | global $globalBitlyAccessToken; |
| 1731 | 1838 | |
| 1732 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 1839 | + if ($globalBitlyAccessToken == '') { |
|
| 1840 | + return $url; |
|
| 1841 | + } |
|
| 1733 | 1842 | |
| 1734 | 1843 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 1735 | 1844 | |
@@ -1805,7 +1914,9 @@ discard block |
||
| 1805 | 1914 | } |
| 1806 | 1915 | } |
| 1807 | 1916 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
| 1808 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1917 | + if ($limit) { |
|
| 1918 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1919 | + } |
|
| 1809 | 1920 | $sth = $this->db->prepare($query); |
| 1810 | 1921 | $sth->execute($query_values); |
| 1811 | 1922 | $marine_array = array(); |
@@ -1842,9 +1953,15 @@ discard block |
||
| 1842 | 1953 | foreach ($q_array as $q_item){ |
| 1843 | 1954 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
| 1844 | 1955 | $additional_query .= " AND ("; |
| 1845 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 1846 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 1847 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 1956 | + if (is_int($q_item)) { |
|
| 1957 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 1958 | + } |
|
| 1959 | + if (is_int($q_item)) { |
|
| 1960 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 1961 | + } |
|
| 1962 | + if (is_int($q_item)) { |
|
| 1963 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 1964 | + } |
|
| 1848 | 1965 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
| 1849 | 1966 | $additional_query .= ")"; |
| 1850 | 1967 | } |
@@ -1892,7 +2009,9 @@ discard block |
||
| 1892 | 2009 | date_default_timezone_set($globalTimezone); |
| 1893 | 2010 | $datetime = new DateTime(); |
| 1894 | 2011 | $offset = $datetime->format('P'); |
| 1895 | - } else $offset = '+00:00'; |
|
| 2012 | + } else { |
|
| 2013 | + $offset = '+00:00'; |
|
| 2014 | + } |
|
| 1896 | 2015 | if ($date_array[1] != "") |
| 1897 | 2016 | { |
| 1898 | 2017 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1919,8 +2038,12 @@ discard block |
||
| 1919 | 2038 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1920 | 2039 | { |
| 1921 | 2040 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1922 | - } else $limit_query = ""; |
|
| 1923 | - } else $limit_query = ""; |
|
| 2041 | + } else { |
|
| 2042 | + $limit_query = ""; |
|
| 2043 | + } |
|
| 2044 | + } else { |
|
| 2045 | + $limit_query = ""; |
|
| 2046 | + } |
|
| 1924 | 2047 | if ($sort != "") |
| 1925 | 2048 | { |
| 1926 | 2049 | $search_orderby_array = $this->getOrderBy(); |