@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | die; |
| 46 | 46 | } |
| 47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 48 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
| 48 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | -$options = getopt('s::',array('source::','server','idsource::')); |
|
| 52 | +$options = getopt('s::', array('source::', 'server', 'idsource::')); |
|
| 53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 55 | 55 | if (isset($options['s'])) { |
@@ -64,22 +64,22 @@ discard block |
||
| 64 | 64 | else $id_source = 1; |
| 65 | 65 | if (isset($globalServer) && $globalServer) { |
| 66 | 66 | if ($globalDebug) echo "Using Server Mode\n"; |
| 67 | - $SI=new SpotterServer(); |
|
| 68 | -} else $SI=new SpotterImport($Connection->db); |
|
| 67 | + $SI = new SpotterServer(); |
|
| 68 | +} else $SI = new SpotterImport($Connection->db); |
|
| 69 | 69 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 70 | 70 | if (isset($globalMarine) && $globalMarine) { |
| 71 | 71 | $AIS = new AIS(); |
| 72 | 72 | $MI = new MarineImport($Connection->db); |
| 73 | 73 | } |
| 74 | 74 | //$APRS=new APRS($Connection->db); |
| 75 | -$SBS=new SBS(); |
|
| 76 | -$ACARS=new ACARS($Connection->db); |
|
| 77 | -$Common=new Common(); |
|
| 75 | +$SBS = new SBS(); |
|
| 76 | +$ACARS = new ACARS($Connection->db); |
|
| 77 | +$Common = new Common(); |
|
| 78 | 78 | date_default_timezone_set('UTC'); |
| 79 | 79 | //$servertz = system('date +%Z'); |
| 80 | 80 | // signal handler - playing nice with sockets and dump1090 |
| 81 | 81 | if (function_exists('pcntl_fork')) { |
| 82 | - pcntl_signal(SIGINT, function() { |
|
| 82 | + pcntl_signal(SIGINT, function() { |
|
| 83 | 83 | global $sockets; |
| 84 | 84 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 85 | 85 | die("Bye!\n"); |
@@ -123,35 +123,35 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | function connect_all($hosts) { |
| 125 | 125 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 126 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 126 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
| 127 | 127 | $reset++; |
| 128 | 128 | if ($globalDebug) echo 'Connect to all...'."\n"; |
| 129 | 129 | foreach ($hosts as $id => $value) { |
| 130 | 130 | $host = $value['host']; |
| 131 | 131 | $globalSources[$id]['last_exec'] = 0; |
| 132 | 132 | // Here we check type of source(s) |
| 133 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 134 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 133 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 134 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
| 135 | 135 | //$formats[$id] = 'deltadbtxt'; |
| 136 | 136 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 137 | 137 | //$last_exec['deltadbtxt'] = 0; |
| 138 | 138 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 139 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 139 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 140 | 140 | //$formats[$id] = 'vatsimtxt'; |
| 141 | 141 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 142 | 142 | //$last_exec['vatsimtxt'] = 0; |
| 143 | 143 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 144 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 144 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 145 | 145 | //$formats[$id] = 'aircraftlistjson'; |
| 146 | 146 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 147 | 147 | //$last_exec['aircraftlistjson'] = 0; |
| 148 | 148 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 149 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 149 | + } else if (preg_match('/opensky/i', $host)) { |
|
| 150 | 150 | //$formats[$id] = 'aircraftlistjson'; |
| 151 | 151 | $globalSources[$id]['format'] = 'opensky'; |
| 152 | 152 | //$last_exec['aircraftlistjson'] = 0; |
| 153 | 153 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
| 154 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 154 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
| 155 | 155 | //$formats[$id] = 'radarvirtueljson'; |
| 156 | 156 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 157 | 157 | //$last_exec['radarvirtueljson'] = 0; |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 161 | 161 | exit(0); |
| 162 | 162 | } |
| 163 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 163 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 164 | 164 | //$formats[$id] = 'planeupdatefaa'; |
| 165 | 165 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 166 | 166 | //$last_exec['planeupdatefaa'] = 0; |
@@ -169,26 +169,26 @@ discard block |
||
| 169 | 169 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 170 | 170 | exit(0); |
| 171 | 171 | } |
| 172 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 172 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 173 | 173 | //$formats[$id] = 'phpvmacars'; |
| 174 | 174 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 175 | 175 | //$last_exec['phpvmacars'] = 0; |
| 176 | 176 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 177 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 177 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
| 178 | 178 | //$formats[$id] = 'phpvmacars'; |
| 179 | 179 | $globalSources[$id]['format'] = 'vam'; |
| 180 | 180 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
| 181 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 181 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 182 | 182 | //$formats[$id] = 'whazzup'; |
| 183 | 183 | $globalSources[$id]['format'] = 'whazzup'; |
| 184 | 184 | //$last_exec['whazzup'] = 0; |
| 185 | 185 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 186 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 186 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 187 | 187 | //$formats[$id] = 'pirepsjson'; |
| 188 | 188 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 189 | 189 | //$last_exec['pirepsjson'] = 0; |
| 190 | 190 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 191 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 191 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 192 | 192 | //$formats[$id] = 'fr24json'; |
| 193 | 193 | $globalSources[$id]['format'] = 'fr24json'; |
| 194 | 194 | //$last_exec['fr24json'] = 0; |
@@ -198,22 +198,22 @@ discard block |
||
| 198 | 198 | exit(0); |
| 199 | 199 | } |
| 200 | 200 | //} else if (preg_match('/10001/',$host)) { |
| 201 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 201 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 202 | 202 | //$formats[$id] = 'tsv'; |
| 203 | 203 | $globalSources[$id]['format'] = 'tsv'; |
| 204 | 204 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 205 | 205 | } |
| 206 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 206 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 207 | 207 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 208 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 208 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
| 209 | 209 | if ($idf !== false) { |
| 210 | 210 | $httpfeeds[$id] = $idf; |
| 211 | 211 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 212 | 212 | } |
| 213 | 213 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
| 214 | 214 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 215 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 216 | - $hostport = explode(':',$host); |
|
| 215 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 216 | + $hostport = explode(':', $host); |
|
| 217 | 217 | if (isset($hostport[1])) { |
| 218 | 218 | $port = $hostport[1]; |
| 219 | 219 | $hostn = $hostport[0]; |
@@ -222,14 +222,14 @@ discard block |
||
| 222 | 222 | $hostn = $globalSources[$id]['host']; |
| 223 | 223 | } |
| 224 | 224 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
| 225 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 225 | + $s = create_socket($hostn, $port, $errno, $errstr); |
|
| 226 | 226 | } else { |
| 227 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 227 | + $s = create_socket_udp($hostn, $port, $errno, $errstr); |
|
| 228 | 228 | } |
| 229 | 229 | if ($s) { |
| 230 | 230 | $sockets[$id] = $s; |
| 231 | 231 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 232 | - if (preg_match('/aprs/',$hostn)) { |
|
| 232 | + if (preg_match('/aprs/', $hostn)) { |
|
| 233 | 233 | //$formats[$id] = 'aprs'; |
| 234 | 234 | $globalSources[$id]['format'] = 'aprs'; |
| 235 | 235 | //$aprs_connect = 0; |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 272 | 272 | else $timeout = 20; |
| 273 | 273 | $errno = ''; |
| 274 | -$errstr=''; |
|
| 274 | +$errstr = ''; |
|
| 275 | 275 | |
| 276 | 276 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 277 | 277 | /* Initiate connections to all the hosts simultaneously */ |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | //connect_all($globalSources); |
| 280 | 280 | |
| 281 | 281 | if (isset($globalProxy) && $globalProxy) { |
| 282 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 282 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
| 283 | 283 | } else { |
| 284 | 284 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
| 285 | 285 | } |
@@ -306,16 +306,16 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | if ($use_aprs) { |
| 308 | 308 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 309 | - $APRS=new APRS(); |
|
| 309 | + $APRS = new APRS(); |
|
| 310 | 310 | $aprs_connect = 0; |
| 311 | 311 | $aprs_keep = 120; |
| 312 | 312 | $aprs_last_tx = time(); |
| 313 | 313 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 314 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 314 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 315 | 315 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
| 316 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 316 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 317 | 317 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 318 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 318 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 319 | 319 | if ($aprs_full) $aprs_filter = ''; |
| 320 | 320 | |
| 321 | 321 | if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n"; |
@@ -327,12 +327,12 @@ discard block |
||
| 327 | 327 | sleep(1); |
| 328 | 328 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 329 | 329 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 330 | -$endtime = time()+$globalCronEnd; |
|
| 330 | +$endtime = time() + $globalCronEnd; |
|
| 331 | 331 | $i = 1; |
| 332 | 332 | $tt = array(); |
| 333 | 333 | // Delete all ATC |
| 334 | 334 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 335 | - $ATC=new ATC($Connection->db); |
|
| 335 | + $ATC = new ATC($Connection->db); |
|
| 336 | 336 | } |
| 337 | 337 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 338 | 338 | $ATC->deleteAll(); |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 342 | 342 | while ($i > 0) { |
| 343 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 343 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 344 | 344 | // Delete old ATC |
| 345 | 345 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 346 | 346 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | } |
| 356 | 356 | if ($max != $globalMinFetch) { |
| 357 | 357 | if ($globalDebug) echo 'Sleeping...'."\n"; |
| 358 | - sleep($globalMinFetch-$max+2); |
|
| 358 | + sleep($globalMinFetch - $max + 2); |
|
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | //$buffer = $Common->getData($hosts[$id]); |
| 369 | 369 | $buffer = $Common->getData($value['host']); |
| 370 | 370 | if ($buffer != '') $reset = 0; |
| 371 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 372 | - $buffer = explode('\n',$buffer); |
|
| 371 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 372 | + $buffer = explode('\n', $buffer); |
|
| 373 | 373 | foreach ($buffer as $line) { |
| 374 | 374 | if ($line != '' && count($line) > 7) { |
| 375 | 375 | $line = explode(',', $line); |
@@ -396,11 +396,11 @@ discard block |
||
| 396 | 396 | $last_exec[$id]['last'] = time(); |
| 397 | 397 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 398 | 398 | date_default_timezone_set('CET'); |
| 399 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 399 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
| 400 | 400 | date_default_timezone_set('UTC'); |
| 401 | 401 | if ($buffer != '') $reset = 0; |
| 402 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 403 | - $buffer = explode('\n',$buffer); |
|
| 402 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 403 | + $buffer = explode('\n', $buffer); |
|
| 404 | 404 | foreach ($buffer as $line) { |
| 405 | 405 | if ($line != '') { |
| 406 | 406 | echo "'".$line."'\n"; |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 419 | 419 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 420 | 420 | if (isset($ais_data['timestamp'])) { |
| 421 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 421 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 422 | 422 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 423 | 423 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
| 424 | 424 | $add = true; |
@@ -441,12 +441,12 @@ discard block |
||
| 441 | 441 | $w = $e = null; |
| 442 | 442 | |
| 443 | 443 | if (isset($arr[$id])) { |
| 444 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 444 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
| 445 | 445 | if ($nn > 0) { |
| 446 | 446 | foreach ($httpfeeds as $feed) { |
| 447 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 448 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 449 | - $buffer = explode('\n',$buffer); |
|
| 447 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
| 448 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 449 | + $buffer = explode('\n', $buffer); |
|
| 450 | 450 | foreach ($buffer as $line) { |
| 451 | 451 | if ($line != '') { |
| 452 | 452 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 463 | 463 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 464 | 464 | if (isset($ais_data['timestamp'])) { |
| 465 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 465 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 466 | 466 | } else { |
| 467 | 467 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 468 | 468 | } |
@@ -477,27 +477,27 @@ discard block |
||
| 477 | 477 | } |
| 478 | 478 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 479 | 479 | echo 'download...'; |
| 480 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 480 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
| 481 | 481 | echo 'done !'."\n"; |
| 482 | 482 | if ($buffer != '') $reset = 0; |
| 483 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 484 | - $buffer = explode('\n',$buffer); |
|
| 483 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 484 | + $buffer = explode('\n', $buffer); |
|
| 485 | 485 | foreach ($buffer as $line) { |
| 486 | 486 | if ($line != '') { |
| 487 | 487 | $data = array(); |
| 488 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 489 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 488 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
| 489 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
| 490 | 490 | //$data['status'] = substr($line,21,2); |
| 491 | 491 | //$data['type'] = substr($line,24,3); |
| 492 | - $data['latitude'] = substr($line,29,9); |
|
| 493 | - $data['longitude'] = substr($line,41,9); |
|
| 494 | - $data['speed'] = round(substr($line,51,5)); |
|
| 492 | + $data['latitude'] = substr($line, 29, 9); |
|
| 493 | + $data['longitude'] = substr($line, 41, 9); |
|
| 494 | + $data['speed'] = round(substr($line, 51, 5)); |
|
| 495 | 495 | //$data['course'] = substr($line,57,5); |
| 496 | - $data['heading'] = round(substr($line,63,3)); |
|
| 496 | + $data['heading'] = round(substr($line, 63, 3)); |
|
| 497 | 497 | //$data['draft'] = substr($line,67,4); |
| 498 | 498 | //$data['length'] = substr($line,72,3); |
| 499 | 499 | //$data['beam'] = substr($line,76,2); |
| 500 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 500 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
| 501 | 501 | //$data['callsign'] = trim(substr($line,100,7); |
| 502 | 502 | //$data['dest'] = substr($line,108,20); |
| 503 | 503 | //$data['etaDate'] = substr($line,129,5); |
@@ -515,8 +515,8 @@ discard block |
||
| 515 | 515 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 516 | 516 | //$buffer = $Common->getData($hosts[$id]); |
| 517 | 517 | $buffer = $Common->getData($value['host']); |
| 518 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 519 | - $buffer = explode('\n',$buffer); |
|
| 518 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 519 | + $buffer = explode('\n', $buffer); |
|
| 520 | 520 | $reset = 0; |
| 521 | 521 | foreach ($buffer as $line) { |
| 522 | 522 | if ($line != '') { |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 528 | 528 | $data['pilot_id'] = $line[1]; |
| 529 | 529 | $data['pilot_name'] = $line[2]; |
| 530 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
| 530 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
| 531 | 531 | $data['ident'] = $line[0]; // ident |
| 532 | 532 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 533 | 533 | $data['speed'] = $line[8]; // speed |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 544 | 544 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 545 | 545 | $data['departure_airport_icao'] = $line[11]; |
| 546 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 546 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 547 | 547 | $data['arrival_airport_icao'] = $line[13]; |
| 548 | 548 | $data['frequency'] = $line[4]; |
| 549 | 549 | $data['type'] = $line[18]; |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | $data['id_source'] = $id_source; |
| 553 | 553 | //$data['arrival_airport_time'] = ; |
| 554 | 554 | if ($line[9] != '') { |
| 555 | - $aircraft_data = explode('/',$line[9]); |
|
| 555 | + $aircraft_data = explode('/', $line[9]); |
|
| 556 | 556 | if (isset($aircraft_data[1])) { |
| 557 | 557 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 558 | 558 | } |
@@ -566,9 +566,9 @@ discard block |
||
| 566 | 566 | if ($line[3] == 'PILOT') $SI->add($data); |
| 567 | 567 | elseif ($line[3] == 'ATC') { |
| 568 | 568 | //print_r($data); |
| 569 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 570 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 571 | - $typec = substr($data['ident'],-3); |
|
| 569 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 570 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 571 | + $typec = substr($data['ident'], -3); |
|
| 572 | 572 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 573 | 573 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
| 574 | 574 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 580 | 580 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
| 581 | 581 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 582 | - if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 582 | + if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
| 583 | 583 | } |
| 584 | 584 | unset($data); |
| 585 | 585 | } |
@@ -590,9 +590,9 @@ discard block |
||
| 590 | 590 | $last_exec[$id]['last'] = time(); |
| 591 | 591 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
| 592 | 592 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 593 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 593 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 594 | 594 | if ($buffer != '') { |
| 595 | - $all_data = json_decode($buffer,true); |
|
| 595 | + $all_data = json_decode($buffer, true); |
|
| 596 | 596 | if (isset($all_data['acList'])) { |
| 597 | 597 | $reset = 0; |
| 598 | 598 | foreach ($all_data['acList'] as $line) { |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
| 649 | 649 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 650 | 650 | $buffer = $Common->getData($value['host']); |
| 651 | - $all_data = json_decode($buffer,true); |
|
| 651 | + $all_data = json_decode($buffer, true); |
|
| 652 | 652 | if (isset($all_data['planes'])) { |
| 653 | 653 | $reset = 0; |
| 654 | 654 | foreach ($all_data['planes'] as $key => $line) { |
@@ -665,12 +665,12 @@ discard block |
||
| 665 | 665 | $data['emergency'] = ''; // emergency |
| 666 | 666 | $data['registration'] = $line[2]; |
| 667 | 667 | $data['aircraft_icao'] = $line[0]; |
| 668 | - $deparr = explode('-',$line[1]); |
|
| 668 | + $deparr = explode('-', $line[1]); |
|
| 669 | 669 | if (count($deparr) == 2) { |
| 670 | 670 | $data['departure_airport_icao'] = $deparr[0]; |
| 671 | 671 | $data['arrival_airport_icao'] = $deparr[1]; |
| 672 | 672 | } |
| 673 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 673 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 674 | 674 | $data['format_source'] = 'planeupdatefaa'; |
| 675 | 675 | $data['id_source'] = $id_source; |
| 676 | 676 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | $last_exec[$id]['last'] = time(); |
| 683 | 683 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 684 | 684 | $buffer = $Common->getData($value['host']); |
| 685 | - $all_data = json_decode($buffer,true); |
|
| 685 | + $all_data = json_decode($buffer, true); |
|
| 686 | 686 | if (isset($all_data['states'])) { |
| 687 | 687 | $reset = 0; |
| 688 | 688 | foreach ($all_data['states'] as $key => $line) { |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | //$data['emergency'] = ''; // emergency |
| 700 | 700 | //$data['registration'] = $line[2]; |
| 701 | 701 | //$data['aircraft_icao'] = $line[0]; |
| 702 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 702 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 703 | 703 | $data['format_source'] = 'opensky'; |
| 704 | 704 | $data['id_source'] = $id_source; |
| 705 | 705 | $SI->add($data); |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 713 | 713 | //$buffer = $Common->getData($hosts[$id]); |
| 714 | 714 | $buffer = $Common->getData($value['host']); |
| 715 | - $all_data = json_decode($buffer,true); |
|
| 715 | + $all_data = json_decode($buffer, true); |
|
| 716 | 716 | if (!empty($all_data)) $reset = 0; |
| 717 | 717 | foreach ($all_data as $key => $line) { |
| 718 | 718 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -744,11 +744,11 @@ discard block |
||
| 744 | 744 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 745 | 745 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 746 | 746 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 747 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 747 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 748 | 748 | //echo $buffer; |
| 749 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 750 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 751 | - $all_data = json_decode($buffer,true); |
|
| 749 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 750 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 751 | + $all_data = json_decode($buffer, true); |
|
| 752 | 752 | if (json_last_error() != JSON_ERROR_NONE) { |
| 753 | 753 | die(json_last_error_msg()); |
| 754 | 754 | } |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | //$data['departure_airport_iata'] = $line[11]; |
| 772 | 772 | //$data['arrival_airport_iata'] = $line[12]; |
| 773 | 773 | //$data['emergency'] = ''; // emergency |
| 774 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 774 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 775 | 775 | $data['format_source'] = 'radarvirtueljson'; |
| 776 | 776 | $data['id_source'] = $id_source; |
| 777 | 777 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -786,14 +786,14 @@ discard block |
||
| 786 | 786 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 787 | 787 | //$buffer = $Common->getData($hosts[$id]); |
| 788 | 788 | $buffer = $Common->getData($value['host'].'?'.time()); |
| 789 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 789 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 790 | 790 | |
| 791 | 791 | if (isset($all_data['pireps'])) { |
| 792 | 792 | $reset = 0; |
| 793 | 793 | foreach ($all_data['pireps'] as $line) { |
| 794 | 794 | $data = array(); |
| 795 | 795 | $data['id'] = $line['id']; |
| 796 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 796 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 797 | 797 | $data['ident'] = $line['callsign']; // ident |
| 798 | 798 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 799 | 799 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -822,9 +822,9 @@ discard block |
||
| 822 | 822 | $SI->add($data); |
| 823 | 823 | // print_r($data); |
| 824 | 824 | } elseif ($line['icon'] == 'ct') { |
| 825 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 826 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 827 | - $typec = substr($data['ident'],-3); |
|
| 825 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 826 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 827 | + $typec = substr($data['ident'], -3); |
|
| 828 | 828 | $data['type'] = ''; |
| 829 | 829 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 830 | 830 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
| 836 | 836 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 837 | 837 | else $data['type'] = 'Observer'; |
| 838 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
| 838 | + if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']); |
|
| 839 | 839 | } |
| 840 | 840 | unset($data); |
| 841 | 841 | } |
@@ -847,14 +847,14 @@ discard block |
||
| 847 | 847 | //$buffer = $Common->getData($hosts[$id]); |
| 848 | 848 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 849 | 849 | $buffer = $Common->getData($value['host']); |
| 850 | - $all_data = json_decode($buffer,true); |
|
| 850 | + $all_data = json_decode($buffer, true); |
|
| 851 | 851 | if ($buffer != '' && is_array($all_data)) { |
| 852 | 852 | $reset = 0; |
| 853 | 853 | foreach ($all_data as $line) { |
| 854 | 854 | $data = array(); |
| 855 | 855 | //$data['id'] = $line['id']; // id not usable |
| 856 | 856 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
| 857 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 857 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 858 | 858 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 859 | 859 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 860 | 860 | $data['ident'] = $line['flightnum']; // ident |
@@ -877,12 +877,12 @@ discard block |
||
| 877 | 877 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 878 | 878 | if (isset($line['aircraftname'])) { |
| 879 | 879 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 880 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 881 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 880 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 881 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 882 | 882 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
| 883 | 883 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
| 884 | 884 | else { |
| 885 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 885 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 886 | 886 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
| 887 | 887 | else $data['aircraft_icao'] = $line['aircraftname']; |
| 888 | 888 | } |
@@ -904,14 +904,14 @@ discard block |
||
| 904 | 904 | //$buffer = $Common->getData($hosts[$id]); |
| 905 | 905 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 906 | 906 | $buffer = $Common->getData($value['host']); |
| 907 | - $all_data = json_decode($buffer,true); |
|
| 907 | + $all_data = json_decode($buffer, true); |
|
| 908 | 908 | if ($buffer != '' && is_array($all_data)) { |
| 909 | 909 | $reset = 0; |
| 910 | 910 | foreach ($all_data as $line) { |
| 911 | 911 | $data = array(); |
| 912 | 912 | //$data['id'] = $line['id']; // id not usable |
| 913 | 913 | $data['id'] = trim($line['flight_id']); |
| 914 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 914 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 915 | 915 | $data['pilot_name'] = $line['pilot_name']; |
| 916 | 916 | $data['pilot_id'] = $line['pilot_id']; |
| 917 | 917 | $data['ident'] = trim($line['callsign']); // ident |
@@ -962,9 +962,9 @@ discard block |
||
| 962 | 962 | //$value = $formats[$nb]; |
| 963 | 963 | $format = $globalSources[$nb]['format']; |
| 964 | 964 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
| 965 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 965 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 966 | 966 | } else { |
| 967 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 967 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 968 | 968 | } |
| 969 | 969 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 970 | 970 | //echo $buffer."\n"; |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
| 973 | 973 | $error = false; |
| 974 | 974 | //$SI::del(); |
| 975 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 975 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 976 | 976 | // SBS format is CSV format |
| 977 | 977 | if ($buffer != '') { |
| 978 | 978 | $tt[$format] = 0; |
@@ -1005,7 +1005,7 @@ discard block |
||
| 1005 | 1005 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 1006 | 1006 | |
| 1007 | 1007 | if (isset($ais_data['timestamp'])) { |
| 1008 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 1008 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 1009 | 1009 | } else { |
| 1010 | 1010 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1011 | 1011 | } |
@@ -1016,10 +1016,10 @@ discard block |
||
| 1016 | 1016 | } elseif ($format == 'flightgearsp') { |
| 1017 | 1017 | //echo $buffer."\n"; |
| 1018 | 1018 | if (strlen($buffer) > 5) { |
| 1019 | - $line = explode(',',$buffer); |
|
| 1019 | + $line = explode(',', $buffer); |
|
| 1020 | 1020 | $data = array(); |
| 1021 | 1021 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 1022 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1022 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1023 | 1023 | $data['ident'] = $line[6]; |
| 1024 | 1024 | $data['aircraft_name'] = $line[7]; |
| 1025 | 1025 | $data['longitude'] = $line[1]; |
@@ -1030,21 +1030,21 @@ discard block |
||
| 1030 | 1030 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1031 | 1031 | $data['format_source'] = 'flightgearsp'; |
| 1032 | 1032 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1033 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1033 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | } elseif ($format == 'acars') { |
| 1036 | 1036 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1037 | 1037 | $ACARS->add(trim($buffer)); |
| 1038 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1038 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1039 | 1039 | $ACARS->deleteLiveAcarsData(); |
| 1040 | 1040 | } elseif ($format == 'flightgearmp') { |
| 1041 | - if (substr($buffer,0,1) != '#') { |
|
| 1041 | + if (substr($buffer, 0, 1) != '#') { |
|
| 1042 | 1042 | $data = array(); |
| 1043 | 1043 | //echo $buffer."\n"; |
| 1044 | - $line = explode(' ',$buffer); |
|
| 1044 | + $line = explode(' ', $buffer); |
|
| 1045 | 1045 | if (count($line) == 11) { |
| 1046 | - $userserver = explode('@',$line[0]); |
|
| 1047 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1046 | + $userserver = explode('@', $line[0]); |
|
| 1047 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 1048 | 1048 | $data['ident'] = $userserver[0]; |
| 1049 | 1049 | $data['registration'] = $userserver[0]; |
| 1050 | 1050 | $data['latitude'] = $line[4]; |
@@ -1052,24 +1052,24 @@ discard block |
||
| 1052 | 1052 | $data['altitude'] = $line[6]; |
| 1053 | 1053 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1054 | 1054 | $aircraft_type = $line[10]; |
| 1055 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1056 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1055 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 1056 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 1057 | 1057 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1058 | 1058 | } |
| 1059 | 1059 | } |
| 1060 | 1060 | } elseif ($format == 'beast') { |
| 1061 | 1061 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 1062 | 1062 | die; |
| 1063 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
| 1063 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
| 1064 | 1064 | $line = explode("\t", $buffer); |
| 1065 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1065 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 1066 | 1066 | $key = $line[$k]; |
| 1067 | - $lined[$key] = $line[$k+1]; |
|
| 1067 | + $lined[$key] = $line[$k + 1]; |
|
| 1068 | 1068 | } |
| 1069 | 1069 | if (count($lined) > 3) { |
| 1070 | 1070 | $data['hex'] = $lined['hexid']; |
| 1071 | 1071 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1072 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1072 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 1073 | 1073 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 1074 | 1074 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 1075 | 1075 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1087,21 +1087,21 @@ discard block |
||
| 1087 | 1087 | } else $error = true; |
| 1088 | 1088 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1089 | 1089 | if ($aprs_connect == 0) { |
| 1090 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 1090 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 1091 | 1091 | $aprs_connect = 1; |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1094 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 1095 | 1095 | $aprs_last_tx = time(); |
| 1096 | 1096 | $data_aprs = "# Keep alive"; |
| 1097 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1097 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | 1100 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 1101 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1102 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1101 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 1102 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 1103 | 1103 | //echo $buffer."\n"; |
| 1104 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1104 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 1105 | 1105 | $line = $APRS->parse($buffer); |
| 1106 | 1106 | //print_r($line); |
| 1107 | 1107 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
@@ -1110,7 +1110,7 @@ discard block |
||
| 1110 | 1110 | $data = array(); |
| 1111 | 1111 | //print_r($line); |
| 1112 | 1112 | if (isset($line['address'])) $data['hex'] = $line['address']; |
| 1113 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1113 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 1114 | 1114 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1115 | 1115 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1116 | 1116 | $data['ident'] = $line['ident']; |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | $currentdate = date('Y-m-d H:i:s'); |
| 1135 | 1135 | $aprsdate = strtotime($data['datetime']); |
| 1136 | 1136 | // Accept data if time <= system time + 20s |
| 1137 | - if (isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1137 | + if (isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1138 | 1138 | $send = $SI->add($data); |
| 1139 | 1139 | } elseif (isset($line['stealth'])) { |
| 1140 | 1140 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | connect_all($sourceee); |
| 1232 | 1232 | $sourceee = array(); |
| 1233 | 1233 | //connect_all($globalSources); |
| 1234 | - $tt[$format]=0; |
|
| 1234 | + $tt[$format] = 0; |
|
| 1235 | 1235 | break; |
| 1236 | 1236 | } |
| 1237 | 1237 | } |
@@ -1240,14 +1240,14 @@ discard block |
||
| 1240 | 1240 | } else { |
| 1241 | 1241 | $error = socket_strerror(socket_last_error()); |
| 1242 | 1242 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1243 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1243 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 1244 | 1244 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1245 | 1245 | // Restart the script if possible |
| 1246 | 1246 | if (is_array($sockets)) { |
| 1247 | 1247 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 1248 | 1248 | |
| 1249 | 1249 | foreach ($sockets as $sock) { |
| 1250 | - @socket_shutdown($sock,2); |
|
| 1250 | + @socket_shutdown($sock, 2); |
|
| 1251 | 1251 | @socket_close($sock); |
| 1252 | 1252 | } |
| 1253 | 1253 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 5 | 5 | $global_query = "SELECT marine_output.* FROM marine_output"; |
| 6 | 6 | |
| 7 | -class Marine{ |
|
| 7 | +class Marine { |
|
| 8 | 8 | public $db; |
| 9 | 9 | |
| 10 | 10 | public function __construct($dbc = null) { |
@@ -18,33 +18,33 @@ discard block |
||
| 18 | 18 | * @return Array the SQL part |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 21 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 22 | 22 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 23 | 23 | $filters = array(); |
| 24 | 24 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 25 | 25 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 26 | 26 | $filters = $globalStatsFilters[$globalFilterName]; |
| 27 | 27 | } else { |
| 28 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 28 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | if (isset($filter[0]['source'])) { |
| 32 | - $filters = array_merge($filters,$filter); |
|
| 32 | + $filters = array_merge($filters, $filter); |
|
| 33 | 33 | } |
| 34 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 34 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 35 | 35 | $filter_query_join = ''; |
| 36 | 36 | $filter_query_where = ''; |
| 37 | - foreach($filters as $flt) { |
|
| 37 | + foreach ($filters as $flt) { |
|
| 38 | 38 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 39 | 39 | if (isset($flt['source'])) { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 41 | 41 | } else { |
| 42 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 42 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 47 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 47 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 48 | 48 | } |
| 49 | 49 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 50 | 50 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 74 | 74 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 75 | 75 | if ($filter_query_where != '') { |
| 76 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 76 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 77 | 77 | } |
| 78 | 78 | $filter_query = $filter_query_join.$filter_query_where; |
| 79 | 79 | return $filter_query; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @return Array the spotter information |
| 89 | 89 | * |
| 90 | 90 | */ |
| 91 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 91 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 92 | 92 | { |
| 93 | 93 | date_default_timezone_set('UTC'); |
| 94 | 94 | if (!is_string($query)) |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | $sth = $this->db->prepare($query.$limitQuery); |
| 109 | 109 | $sth->execute($params); |
| 110 | 110 | } catch (PDOException $e) { |
| 111 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 111 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 112 | 112 | exit(); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $num_rows = 0; |
| 116 | 116 | $spotter_array = array(); |
| 117 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 117 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 118 | 118 | { |
| 119 | 119 | $num_rows++; |
| 120 | 120 | $temp_array = array(); |
@@ -169,17 +169,17 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 171 | 171 | } else { |
| 172 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 172 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 173 | 173 | } |
| 174 | 174 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 175 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 176 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 175 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 176 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 177 | 177 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 178 | 178 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 179 | 179 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 180 | 180 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 181 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 182 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 181 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 182 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 183 | 183 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 184 | 184 | } |
| 185 | 185 | } |
@@ -216,8 +216,8 @@ discard block |
||
| 216 | 216 | { |
| 217 | 217 | $limit_array = explode(",", $limit); |
| 218 | 218 | |
| 219 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 220 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 219 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 220 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 221 | 221 | |
| 222 | 222 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 223 | 223 | { |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
| 237 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
| 238 | 238 | |
| 239 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 239 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 240 | 240 | |
| 241 | 241 | return $spotter_array; |
| 242 | 242 | } |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | if ($id == '') return array(); |
| 256 | 256 | $additional_query = "marine_output.fammarine_id = :id"; |
| 257 | 257 | $query_values = array(':id' => $id); |
| 258 | - $query = $global_query." WHERE ".$additional_query." "; |
|
| 259 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 258 | + $query = $global_query." WHERE ".$additional_query." "; |
|
| 259 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 260 | 260 | return $spotter_array; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $query_values = array(); |
| 276 | 276 | $limit_query = ''; |
| 277 | 277 | $additional_query = ''; |
| 278 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 278 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 279 | 279 | if ($ident != "") |
| 280 | 280 | { |
| 281 | 281 | if (!is_string($ident)) |
@@ -291,8 +291,8 @@ discard block |
||
| 291 | 291 | { |
| 292 | 292 | $limit_array = explode(",", $limit); |
| 293 | 293 | |
| 294 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 295 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 294 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 295 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 296 | 296 | |
| 297 | 297 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 298 | 298 | { |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | return $spotter_array; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 319 | + public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 320 | 320 | { |
| 321 | 321 | global $global_query, $globalTimezone, $globalDBdriver; |
| 322 | 322 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $limit_query = ''; |
| 325 | 325 | $additional_query = ''; |
| 326 | 326 | |
| 327 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 327 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 328 | 328 | |
| 329 | 329 | if ($date != "") |
| 330 | 330 | { |
@@ -350,8 +350,8 @@ discard block |
||
| 350 | 350 | { |
| 351 | 351 | $limit_array = explode(",", $limit); |
| 352 | 352 | |
| 353 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 354 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 353 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 354 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 355 | 355 | |
| 356 | 356 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 357 | 357 | { |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | * @return Array list of source name |
| 383 | 383 | * |
| 384 | 384 | */ |
| 385 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 385 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 386 | 386 | { |
| 387 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 387 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 388 | 388 | $query_values = array(); |
| 389 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 389 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 390 | 390 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 391 | 391 | if ($type != '') { |
| 392 | 392 | $query_values = array(':type' => $type); |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | $source_array = array(); |
| 402 | 402 | $temp_array = array(); |
| 403 | 403 | |
| 404 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 404 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 405 | 405 | { |
| 406 | 406 | $temp_array['source_name'] = $row['source_name']; |
| 407 | 407 | $source_array[] = $temp_array; |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | public function getAllIdents($filters = array()) |
| 420 | 420 | { |
| 421 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 422 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 421 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 422 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 423 | 423 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 424 | 424 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 425 | 425 | |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | $ident_array = array(); |
| 430 | 430 | $temp_array = array(); |
| 431 | 431 | |
| 432 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 432 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 433 | 433 | { |
| 434 | 434 | $temp_array['ident'] = $row['ident']; |
| 435 | 435 | $ident_array[] = $temp_array; |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | */ |
| 447 | 447 | public function getIdentity($mmsi) |
| 448 | 448 | { |
| 449 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 449 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 450 | 450 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 451 | 451 | $sth = $this->db->prepare($query); |
| 452 | 452 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -471,12 +471,12 @@ discard block |
||
| 471 | 471 | } else $offset = '+00:00'; |
| 472 | 472 | |
| 473 | 473 | if ($globalDBdriver == 'mysql') { |
| 474 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 474 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 475 | 475 | FROM marine_output |
| 476 | 476 | WHERE marine_output.date <> '' |
| 477 | 477 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
| 478 | 478 | } else { |
| 479 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 479 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 480 | 480 | FROM marine_output |
| 481 | 481 | WHERE marine_output.date <> '' |
| 482 | 482 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | $date_array = array(); |
| 489 | 489 | $temp_array = array(); |
| 490 | 490 | |
| 491 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 491 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 492 | 492 | { |
| 493 | 493 | $temp_array['date'] = $row['date']; |
| 494 | 494 | |
@@ -507,11 +507,11 @@ discard block |
||
| 507 | 507 | * @return String success or false |
| 508 | 508 | * |
| 509 | 509 | */ |
| 510 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 510 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 511 | 511 | { |
| 512 | 512 | |
| 513 | 513 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 514 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 514 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 515 | 515 | |
| 516 | 516 | try { |
| 517 | 517 | $sth = $this->db->prepare($query); |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 535 | 535 | { |
| 536 | 536 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
| 537 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 537 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
| 538 | 538 | |
| 539 | 539 | try { |
| 540 | 540 | $sth = $this->db->prepare($query); |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | * @param String $verticalrate vertival rate of flight |
| 573 | 573 | * @return String success or false |
| 574 | 574 | */ |
| 575 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$imo = '',$callsign = '',$status = '',$format_source = '', $source_name = '') |
|
| 575 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $imo = '', $callsign = '', $status = '', $format_source = '', $source_name = '') |
|
| 576 | 576 | { |
| 577 | 577 | global $globalURL; |
| 578 | 578 | |
@@ -639,23 +639,23 @@ discard block |
||
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | |
| 642 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 642 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 643 | 643 | { |
| 644 | 644 | $date = date("Y-m-d H:i:s", time()); |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 648 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 649 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 650 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 651 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 652 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 653 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 654 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 655 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 656 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 657 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 658 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 647 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 648 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 649 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 650 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 651 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 652 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 653 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 654 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 655 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 656 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 657 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 658 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 659 | 659 | |
| 660 | 660 | if ($latitude == '' && $longitude == '') { |
| 661 | 661 | $latitude = 0; |
@@ -663,10 +663,10 @@ discard block |
||
| 663 | 663 | } |
| 664 | 664 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 665 | 665 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 666 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo) |
|
| 666 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo) |
|
| 667 | 667 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo)"; |
| 668 | 668 | |
| 669 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo); |
|
| 669 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo); |
|
| 670 | 670 | |
| 671 | 671 | try { |
| 672 | 672 | |
@@ -692,13 +692,13 @@ discard block |
||
| 692 | 692 | { |
| 693 | 693 | global $globalDBdriver, $globalTimezone; |
| 694 | 694 | if ($globalDBdriver == 'mysql') { |
| 695 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 695 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 696 | 696 | WHERE marine_output.ident = :ident |
| 697 | 697 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 698 | 698 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 699 | 699 | $query_data = array(':ident' => $ident); |
| 700 | 700 | } else { |
| 701 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 701 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 702 | 702 | WHERE marine_output.ident = :ident |
| 703 | 703 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 704 | 704 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -707,8 +707,8 @@ discard block |
||
| 707 | 707 | |
| 708 | 708 | $sth = $this->db->prepare($query); |
| 709 | 709 | $sth->execute($query_data); |
| 710 | - $ident_result=''; |
|
| 711 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 710 | + $ident_result = ''; |
|
| 711 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 712 | 712 | { |
| 713 | 713 | $ident_result = $row['ident']; |
| 714 | 714 | } |
@@ -734,8 +734,8 @@ discard block |
||
| 734 | 734 | return false; |
| 735 | 735 | } else { |
| 736 | 736 | $q_array = explode(" ", $q); |
| 737 | - foreach ($q_array as $q_item){ |
|
| 738 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 737 | + foreach ($q_array as $q_item) { |
|
| 738 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 739 | 739 | $additional_query .= " AND ("; |
| 740 | 740 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 741 | 741 | $additional_query .= ")"; |
@@ -743,11 +743,11 @@ discard block |
||
| 743 | 743 | } |
| 744 | 744 | } |
| 745 | 745 | if ($globalDBdriver == 'mysql') { |
| 746 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 746 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 747 | 747 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 748 | 748 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 749 | 749 | } else { |
| 750 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 750 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 751 | 751 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 752 | 752 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 753 | 753 | } |
@@ -820,11 +820,11 @@ discard block |
||
| 820 | 820 | * @return Array the callsign list |
| 821 | 821 | * |
| 822 | 822 | */ |
| 823 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 823 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 824 | 824 | { |
| 825 | 825 | global $globalDBdriver; |
| 826 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 827 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 826 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 827 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 828 | 828 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 829 | 829 | if ($olderthanmonths > 0) { |
| 830 | 830 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -838,28 +838,28 @@ discard block |
||
| 838 | 838 | if ($year != '') { |
| 839 | 839 | if ($globalDBdriver == 'mysql') { |
| 840 | 840 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 841 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 841 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 842 | 842 | } else { |
| 843 | 843 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 844 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 844 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 845 | 845 | } |
| 846 | 846 | } |
| 847 | 847 | if ($month != '') { |
| 848 | 848 | if ($globalDBdriver == 'mysql') { |
| 849 | 849 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 850 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 850 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 851 | 851 | } else { |
| 852 | 852 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 853 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 853 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | if ($day != '') { |
| 857 | 857 | if ($globalDBdriver == 'mysql') { |
| 858 | 858 | $query .= " AND DAY(marine_output.date) = :day"; |
| 859 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 859 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 860 | 860 | } else { |
| 861 | 861 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 862 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 862 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 863 | 863 | } |
| 864 | 864 | } |
| 865 | 865 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | $callsign_array = array(); |
| 872 | 872 | $temp_array = array(); |
| 873 | 873 | |
| 874 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 874 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 875 | 875 | { |
| 876 | 876 | $temp_array['callsign_icao'] = $row['ident']; |
| 877 | 877 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -923,7 +923,7 @@ discard block |
||
| 923 | 923 | $date_array = array(); |
| 924 | 924 | $temp_array = array(); |
| 925 | 925 | |
| 926 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 926 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 927 | 927 | { |
| 928 | 928 | $temp_array['date_name'] = $row['date_name']; |
| 929 | 929 | $temp_array['date_count'] = $row['date_count']; |
@@ -949,7 +949,7 @@ discard block |
||
| 949 | 949 | $datetime = new DateTime(); |
| 950 | 950 | $offset = $datetime->format('P'); |
| 951 | 951 | } else $offset = '+00:00'; |
| 952 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 952 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 953 | 953 | if ($globalDBdriver == 'mysql') { |
| 954 | 954 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 955 | 955 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -970,7 +970,7 @@ discard block |
||
| 970 | 970 | $date_array = array(); |
| 971 | 971 | $temp_array = array(); |
| 972 | 972 | |
| 973 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 973 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 974 | 974 | { |
| 975 | 975 | $temp_array['date_name'] = $row['date_name']; |
| 976 | 976 | $temp_array['date_count'] = $row['date_count']; |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | $datetime = new DateTime(); |
| 996 | 996 | $offset = $datetime->format('P'); |
| 997 | 997 | } else $offset = '+00:00'; |
| 998 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 998 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 999 | 999 | if ($globalDBdriver == 'mysql') { |
| 1000 | 1000 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1001 | 1001 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1016,7 +1016,7 @@ discard block |
||
| 1016 | 1016 | $date_array = array(); |
| 1017 | 1017 | $temp_array = array(); |
| 1018 | 1018 | |
| 1019 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1019 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1020 | 1020 | { |
| 1021 | 1021 | $temp_array['date_name'] = $row['date_name']; |
| 1022 | 1022 | $temp_array['date_count'] = $row['date_count']; |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | $date_array = array(); |
| 1064 | 1064 | $temp_array = array(); |
| 1065 | 1065 | |
| 1066 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1066 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1067 | 1067 | { |
| 1068 | 1068 | $temp_array['month_name'] = $row['month_name']; |
| 1069 | 1069 | $temp_array['year_name'] = $row['year_name']; |
@@ -1092,7 +1092,7 @@ discard block |
||
| 1092 | 1092 | $datetime = new DateTime(); |
| 1093 | 1093 | $offset = $datetime->format('P'); |
| 1094 | 1094 | } else $offset = '+00:00'; |
| 1095 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1095 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1096 | 1096 | if ($globalDBdriver == 'mysql') { |
| 1097 | 1097 | $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 |
| 1098 | 1098 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1113,7 +1113,7 @@ discard block |
||
| 1113 | 1113 | $date_array = array(); |
| 1114 | 1114 | $temp_array = array(); |
| 1115 | 1115 | |
| 1116 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1116 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1117 | 1117 | { |
| 1118 | 1118 | $temp_array['year_name'] = $row['year_name']; |
| 1119 | 1119 | $temp_array['month_name'] = $row['month_name']; |
@@ -1133,7 +1133,7 @@ discard block |
||
| 1133 | 1133 | * @return Array the hour list |
| 1134 | 1134 | * |
| 1135 | 1135 | */ |
| 1136 | - public function countAllHours($orderby,$filters = array()) |
|
| 1136 | + public function countAllHours($orderby, $filters = array()) |
|
| 1137 | 1137 | { |
| 1138 | 1138 | global $globalTimezone, $globalDBdriver; |
| 1139 | 1139 | if ($globalTimezone != '') { |
@@ -1181,7 +1181,7 @@ discard block |
||
| 1181 | 1181 | $hour_array = array(); |
| 1182 | 1182 | $temp_array = array(); |
| 1183 | 1183 | |
| 1184 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1184 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1185 | 1185 | { |
| 1186 | 1186 | $temp_array['hour_name'] = $row['hour_name']; |
| 1187 | 1187 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1203,8 +1203,8 @@ discard block |
||
| 1203 | 1203 | public function countAllHoursByDate($date, $filters = array()) |
| 1204 | 1204 | { |
| 1205 | 1205 | global $globalTimezone, $globalDBdriver; |
| 1206 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1207 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1206 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1207 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1208 | 1208 | if ($globalTimezone != '') { |
| 1209 | 1209 | date_default_timezone_set($globalTimezone); |
| 1210 | 1210 | $datetime = new DateTime($date); |
@@ -1212,12 +1212,12 @@ discard block |
||
| 1212 | 1212 | } else $offset = '+00:00'; |
| 1213 | 1213 | |
| 1214 | 1214 | if ($globalDBdriver == 'mysql') { |
| 1215 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1215 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1216 | 1216 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1217 | 1217 | GROUP BY hour_name |
| 1218 | 1218 | ORDER BY hour_name ASC"; |
| 1219 | 1219 | } else { |
| 1220 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1220 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1221 | 1221 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1222 | 1222 | GROUP BY hour_name |
| 1223 | 1223 | ORDER BY hour_name ASC"; |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | $hour_array = array(); |
| 1230 | 1230 | $temp_array = array(); |
| 1231 | 1231 | |
| 1232 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1232 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1233 | 1233 | { |
| 1234 | 1234 | $temp_array['hour_name'] = $row['hour_name']; |
| 1235 | 1235 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1251,8 +1251,8 @@ discard block |
||
| 1251 | 1251 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1252 | 1252 | { |
| 1253 | 1253 | global $globalTimezone, $globalDBdriver; |
| 1254 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1255 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1254 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1255 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1256 | 1256 | if ($globalTimezone != '') { |
| 1257 | 1257 | date_default_timezone_set($globalTimezone); |
| 1258 | 1258 | $datetime = new DateTime(); |
@@ -1260,12 +1260,12 @@ discard block |
||
| 1260 | 1260 | } else $offset = '+00:00'; |
| 1261 | 1261 | |
| 1262 | 1262 | if ($globalDBdriver == 'mysql') { |
| 1263 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1263 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1264 | 1264 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1265 | 1265 | GROUP BY hour_name |
| 1266 | 1266 | ORDER BY hour_name ASC"; |
| 1267 | 1267 | } else { |
| 1268 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1268 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1269 | 1269 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1270 | 1270 | GROUP BY hour_name |
| 1271 | 1271 | ORDER BY hour_name ASC"; |
@@ -1273,12 +1273,12 @@ discard block |
||
| 1273 | 1273 | |
| 1274 | 1274 | |
| 1275 | 1275 | $sth = $this->db->prepare($query); |
| 1276 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1276 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1277 | 1277 | |
| 1278 | 1278 | $hour_array = array(); |
| 1279 | 1279 | $temp_array = array(); |
| 1280 | 1280 | |
| 1281 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1281 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1282 | 1282 | { |
| 1283 | 1283 | $temp_array['hour_name'] = $row['hour_name']; |
| 1284 | 1284 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1297,32 +1297,32 @@ discard block |
||
| 1297 | 1297 | * @return Integer the number of flights |
| 1298 | 1298 | * |
| 1299 | 1299 | */ |
| 1300 | - public function countOverallTracked($filters = array(),$year = '',$month = '') |
|
| 1300 | + public function countOverallTracked($filters = array(), $year = '', $month = '') |
|
| 1301 | 1301 | { |
| 1302 | 1302 | global $globalDBdriver; |
| 1303 | - $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
| 1303 | + $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
| 1304 | 1304 | $query_values = array(); |
| 1305 | 1305 | $query = ''; |
| 1306 | 1306 | if ($year != '') { |
| 1307 | 1307 | if ($globalDBdriver == 'mysql') { |
| 1308 | 1308 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1309 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1309 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1310 | 1310 | } else { |
| 1311 | 1311 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1312 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1312 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1313 | 1313 | } |
| 1314 | 1314 | } |
| 1315 | 1315 | if ($month != '') { |
| 1316 | 1316 | if ($globalDBdriver == 'mysql') { |
| 1317 | 1317 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1318 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1318 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1319 | 1319 | } else { |
| 1320 | 1320 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1321 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1321 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1322 | 1322 | } |
| 1323 | 1323 | } |
| 1324 | 1324 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1325 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1325 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1326 | 1326 | |
| 1327 | 1327 | $sth = $this->db->prepare($queryi); |
| 1328 | 1328 | $sth->execute($query_values); |
@@ -1339,7 +1339,7 @@ discard block |
||
| 1339 | 1339 | public function countAllHoursFromToday($filters = array()) |
| 1340 | 1340 | { |
| 1341 | 1341 | global $globalTimezone, $globalDBdriver; |
| 1342 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1342 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1343 | 1343 | if ($globalTimezone != '') { |
| 1344 | 1344 | date_default_timezone_set($globalTimezone); |
| 1345 | 1345 | $datetime = new DateTime(); |
@@ -1347,12 +1347,12 @@ discard block |
||
| 1347 | 1347 | } else $offset = '+00:00'; |
| 1348 | 1348 | |
| 1349 | 1349 | if ($globalDBdriver == 'mysql') { |
| 1350 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1350 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1351 | 1351 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1352 | 1352 | GROUP BY hour_name |
| 1353 | 1353 | ORDER BY hour_name ASC"; |
| 1354 | 1354 | } else { |
| 1355 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1355 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1356 | 1356 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1357 | 1357 | GROUP BY hour_name |
| 1358 | 1358 | ORDER BY hour_name ASC"; |
@@ -1364,7 +1364,7 @@ discard block |
||
| 1364 | 1364 | $hour_array = array(); |
| 1365 | 1365 | $temp_array = array(); |
| 1366 | 1366 | |
| 1367 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1367 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1368 | 1368 | { |
| 1369 | 1369 | $temp_array['hour_name'] = $row['hour_name']; |
| 1370 | 1370 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1383,9 +1383,9 @@ discard block |
||
| 1383 | 1383 | */ |
| 1384 | 1384 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1385 | 1385 | { |
| 1386 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1386 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1387 | 1387 | |
| 1388 | - $query = "SELECT marine_output.marine_id |
|
| 1388 | + $query = "SELECT marine_output.marine_id |
|
| 1389 | 1389 | FROM marine_output |
| 1390 | 1390 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1391 | 1391 | |
@@ -1393,7 +1393,7 @@ discard block |
||
| 1393 | 1393 | $sth = $this->db->prepare($query); |
| 1394 | 1394 | $sth->execute(); |
| 1395 | 1395 | |
| 1396 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1396 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1397 | 1397 | { |
| 1398 | 1398 | return $row['marine_id']; |
| 1399 | 1399 | } |
@@ -1418,23 +1418,23 @@ discard block |
||
| 1418 | 1418 | } |
| 1419 | 1419 | |
| 1420 | 1420 | $current_date = date("Y-m-d H:i:s"); |
| 1421 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1421 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1422 | 1422 | |
| 1423 | 1423 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1424 | 1424 | |
| 1425 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1425 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1426 | 1426 | $years = $time_array['years']; |
| 1427 | 1427 | |
| 1428 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1428 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1429 | 1429 | $months = $time_array['months']; |
| 1430 | 1430 | |
| 1431 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1431 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1432 | 1432 | $days = $time_array['days']; |
| 1433 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1433 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1434 | 1434 | $hours = $time_array['hours']; |
| 1435 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1435 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1436 | 1436 | $minutes = $time_array['minutes']; |
| 1437 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1437 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1438 | 1438 | |
| 1439 | 1439 | return $time_array; |
| 1440 | 1440 | } |
@@ -1457,63 +1457,63 @@ discard block |
||
| 1457 | 1457 | $temp_array['direction_degree'] = $direction; |
| 1458 | 1458 | $temp_array['direction_shortname'] = "N"; |
| 1459 | 1459 | $temp_array['direction_fullname'] = "North"; |
| 1460 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1460 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1461 | 1461 | $temp_array['direction_degree'] = $direction; |
| 1462 | 1462 | $temp_array['direction_shortname'] = "NNE"; |
| 1463 | 1463 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 1464 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 1464 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 1465 | 1465 | $temp_array['direction_degree'] = $direction; |
| 1466 | 1466 | $temp_array['direction_shortname'] = "NE"; |
| 1467 | 1467 | $temp_array['direction_fullname'] = "Northeast"; |
| 1468 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 1468 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 1469 | 1469 | $temp_array['direction_degree'] = $direction; |
| 1470 | 1470 | $temp_array['direction_shortname'] = "ENE"; |
| 1471 | 1471 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 1472 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 1472 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 1473 | 1473 | $temp_array['direction_degree'] = $direction; |
| 1474 | 1474 | $temp_array['direction_shortname'] = "E"; |
| 1475 | 1475 | $temp_array['direction_fullname'] = "East"; |
| 1476 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 1476 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 1477 | 1477 | $temp_array['direction_degree'] = $direction; |
| 1478 | 1478 | $temp_array['direction_shortname'] = "ESE"; |
| 1479 | 1479 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 1480 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 1480 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 1481 | 1481 | $temp_array['direction_degree'] = $direction; |
| 1482 | 1482 | $temp_array['direction_shortname'] = "SE"; |
| 1483 | 1483 | $temp_array['direction_fullname'] = "Southeast"; |
| 1484 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 1484 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 1485 | 1485 | $temp_array['direction_degree'] = $direction; |
| 1486 | 1486 | $temp_array['direction_shortname'] = "SSE"; |
| 1487 | 1487 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 1488 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 1488 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 1489 | 1489 | $temp_array['direction_degree'] = $direction; |
| 1490 | 1490 | $temp_array['direction_shortname'] = "S"; |
| 1491 | 1491 | $temp_array['direction_fullname'] = "South"; |
| 1492 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 1492 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 1493 | 1493 | $temp_array['direction_degree'] = $direction; |
| 1494 | 1494 | $temp_array['direction_shortname'] = "SSW"; |
| 1495 | 1495 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 1496 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 1496 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 1497 | 1497 | $temp_array['direction_degree'] = $direction; |
| 1498 | 1498 | $temp_array['direction_shortname'] = "SW"; |
| 1499 | 1499 | $temp_array['direction_fullname'] = "Southwest"; |
| 1500 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 1500 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 1501 | 1501 | $temp_array['direction_degree'] = $direction; |
| 1502 | 1502 | $temp_array['direction_shortname'] = "WSW"; |
| 1503 | 1503 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 1504 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 1504 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 1505 | 1505 | $temp_array['direction_degree'] = $direction; |
| 1506 | 1506 | $temp_array['direction_shortname'] = "W"; |
| 1507 | 1507 | $temp_array['direction_fullname'] = "West"; |
| 1508 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 1508 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 1509 | 1509 | $temp_array['direction_degree'] = $direction; |
| 1510 | 1510 | $temp_array['direction_shortname'] = "WNW"; |
| 1511 | 1511 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 1512 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 1512 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 1513 | 1513 | $temp_array['direction_degree'] = $direction; |
| 1514 | 1514 | $temp_array['direction_shortname'] = "NW"; |
| 1515 | 1515 | $temp_array['direction_fullname'] = "Northwest"; |
| 1516 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 1516 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 1517 | 1517 | $temp_array['direction_degree'] = $direction; |
| 1518 | 1518 | $temp_array['direction_shortname'] = "NNW"; |
| 1519 | 1519 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1530,11 +1530,11 @@ discard block |
||
| 1530 | 1530 | * @param Float $longitude longitute of the flight |
| 1531 | 1531 | * @return String the countrie |
| 1532 | 1532 | */ |
| 1533 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 1533 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 1534 | 1534 | { |
| 1535 | 1535 | global $globalDBdriver, $globalDebug; |
| 1536 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1537 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1536 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1537 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1538 | 1538 | |
| 1539 | 1539 | $Connection = new Connection($this->db); |
| 1540 | 1540 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1574,7 +1574,7 @@ discard block |
||
| 1574 | 1574 | public function getCountryFromISO2($iso2) |
| 1575 | 1575 | { |
| 1576 | 1576 | global $globalDBdriver, $globalDebug; |
| 1577 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 1577 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 1578 | 1578 | |
| 1579 | 1579 | $Connection = new Connection($this->db); |
| 1580 | 1580 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1622,7 +1622,7 @@ discard block |
||
| 1622 | 1622 | |
| 1623 | 1623 | $bitly_data = json_decode($bitly_data); |
| 1624 | 1624 | $bitly_url = ''; |
| 1625 | - if ($bitly_data->status_txt = "OK"){ |
|
| 1625 | + if ($bitly_data->status_txt = "OK") { |
|
| 1626 | 1626 | $bitly_url = $bitly_data->data->url; |
| 1627 | 1627 | } |
| 1628 | 1628 | |
@@ -1632,7 +1632,7 @@ discard block |
||
| 1632 | 1632 | |
| 1633 | 1633 | public function getOrderBy() |
| 1634 | 1634 | { |
| 1635 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
| 1635 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
| 1636 | 1636 | |
| 1637 | 1637 | return $orderby; |
| 1638 | 1638 | |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | * @param Array $filter the filter |
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 37 | 37 | if (isset($flt['source'])) { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 39 | 39 | } else { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 75 | 75 | } |
| 76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 78 | 78 | } |
| 79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 81 | 81 | if ($filter_query_where != '') { |
| 82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 83 | 83 | } |
| 84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
| 85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | if ($limit != '') |
| 103 | 103 | { |
| 104 | 104 | $limit_array = explode(',', $limit); |
| 105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 108 | 108 | { |
| 109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } else { |
| 127 | 127 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
| 128 | 128 | } |
| 129 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 129 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 130 | 130 | |
| 131 | 131 | return $spotter_array; |
| 132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | global $globalDBdriver, $globalLiveInterval; |
| 143 | 143 | date_default_timezone_set('UTC'); |
| 144 | 144 | |
| 145 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 145 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 146 | 146 | |
| 147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | try { |
| 157 | 157 | $sth = $this->db->prepare($query); |
| 158 | 158 | $sth->execute(); |
| 159 | - } catch(PDOException $e) { |
|
| 159 | + } catch (PDOException $e) { |
|
| 160 | 160 | echo $e->getMessage(); |
| 161 | 161 | die; |
| 162 | 162 | } |
@@ -176,15 +176,15 @@ discard block |
||
| 176 | 176 | global $globalDBdriver, $globalLiveInterval; |
| 177 | 177 | date_default_timezone_set('UTC'); |
| 178 | 178 | |
| 179 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 179 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 180 | 180 | |
| 181 | 181 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 182 | 182 | if ($globalDBdriver == 'mysql') { |
| 183 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 183 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 186 | 186 | } else { |
| 187 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 187 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | try { |
| 193 | 193 | $sth = $this->db->prepare($query); |
| 194 | 194 | $sth->execute(); |
| 195 | - } catch(PDOException $e) { |
|
| 195 | + } catch (PDOException $e) { |
|
| 196 | 196 | echo $e->getMessage(); |
| 197 | 197 | die; |
| 198 | 198 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | public function getLiveMarineCount($filter = array()) |
| 210 | 210 | { |
| 211 | 211 | global $globalDBdriver, $globalLiveInterval; |
| 212 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 212 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 213 | 213 | |
| 214 | 214 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 215 | 215 | if ($globalDBdriver == 'mysql') { |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | try { |
| 221 | 221 | $sth = $this->db->prepare($query); |
| 222 | 222 | $sth->execute(); |
| 223 | - } catch(PDOException $e) { |
|
| 223 | + } catch (PDOException $e) { |
|
| 224 | 224 | echo $e->getMessage(); |
| 225 | 225 | die; |
| 226 | 226 | } |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | $filter_query = $this->getFilter($filter); |
| 244 | 244 | |
| 245 | 245 | if (is_array($coord)) { |
| 246 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 247 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 248 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 249 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 246 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 247 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 248 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 249 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 250 | 250 | } else return array(); |
| 251 | 251 | if ($globalDBdriver == 'mysql') { |
| 252 | 252 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | if ($interval == '1m') |
| 299 | 299 | { |
| 300 | 300 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 301 | - } else if ($interval == '15m'){ |
|
| 301 | + } else if ($interval == '15m') { |
|
| 302 | 302 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
| 303 | 303 | } |
| 304 | 304 | } |
@@ -306,14 +306,14 @@ discard block |
||
| 306 | 306 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 309 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 310 | 310 | WHERE marine_live.latitude <> '' |
| 311 | 311 | AND marine_live.longitude <> '' |
| 312 | 312 | ".$additional_query." |
| 313 | 313 | HAVING distance < :radius |
| 314 | 314 | ORDER BY distance"; |
| 315 | 315 | |
| 316 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 316 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 317 | 317 | |
| 318 | 318 | return $spotter_array; |
| 319 | 319 | } |
@@ -331,9 +331,9 @@ discard block |
||
| 331 | 331 | date_default_timezone_set('UTC'); |
| 332 | 332 | |
| 333 | 333 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 334 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 334 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 335 | 335 | |
| 336 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 336 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 337 | 337 | |
| 338 | 338 | return $spotter_array; |
| 339 | 339 | } |
@@ -344,16 +344,16 @@ discard block |
||
| 344 | 344 | * @return Array the spotter information |
| 345 | 345 | * |
| 346 | 346 | */ |
| 347 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
| 347 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
| 348 | 348 | { |
| 349 | 349 | $Marine = new Marine($this->db); |
| 350 | 350 | date_default_timezone_set('UTC'); |
| 351 | 351 | |
| 352 | 352 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 353 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 353 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 354 | 354 | |
| 355 | - $date = date('c',$date); |
|
| 356 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 355 | + $date = date('c', $date); |
|
| 356 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 357 | 357 | |
| 358 | 358 | return $spotter_array; |
| 359 | 359 | } |
@@ -370,9 +370,9 @@ discard block |
||
| 370 | 370 | date_default_timezone_set('UTC'); |
| 371 | 371 | |
| 372 | 372 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 373 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 373 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 374 | 374 | |
| 375 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 375 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 376 | 376 | |
| 377 | 377 | return $spotter_array; |
| 378 | 378 | } |
@@ -383,15 +383,15 @@ discard block |
||
| 383 | 383 | * @return Array the spotter information |
| 384 | 384 | * |
| 385 | 385 | */ |
| 386 | - public function getDateLiveMarineDataById($id,$date) |
|
| 386 | + public function getDateLiveMarineDataById($id, $date) |
|
| 387 | 387 | { |
| 388 | 388 | $Marine = new Marine($this->db); |
| 389 | 389 | date_default_timezone_set('UTC'); |
| 390 | 390 | |
| 391 | 391 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 392 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 393 | - $date = date('c',$date); |
|
| 394 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 392 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 393 | + $date = date('c', $date); |
|
| 394 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 395 | 395 | |
| 396 | 396 | return $spotter_array; |
| 397 | 397 | } |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | * @return Array the spotter information |
| 404 | 404 | * |
| 405 | 405 | */ |
| 406 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
| 406 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
| 407 | 407 | { |
| 408 | 408 | global $globalDBdriver, $globalLiveInterval; |
| 409 | 409 | date_default_timezone_set('UTC'); |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | try { |
| 423 | 423 | $sth = $this->db->prepare($query); |
| 424 | 424 | $sth->execute(array(':id' => $id)); |
| 425 | - } catch(PDOException $e) { |
|
| 425 | + } catch (PDOException $e) { |
|
| 426 | 426 | echo $e->getMessage(); |
| 427 | 427 | die; |
| 428 | 428 | } |
@@ -440,12 +440,12 @@ discard block |
||
| 440 | 440 | { |
| 441 | 441 | date_default_timezone_set('UTC'); |
| 442 | 442 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 443 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 443 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 444 | 444 | try { |
| 445 | 445 | |
| 446 | 446 | $sth = $this->db->prepare($query); |
| 447 | 447 | $sth->execute(array(':ident' => $ident)); |
| 448 | - } catch(PDOException $e) { |
|
| 448 | + } catch (PDOException $e) { |
|
| 449 | 449 | echo $e->getMessage(); |
| 450 | 450 | die; |
| 451 | 451 | } |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | $sth = $this->db->prepare($query); |
| 477 | 477 | $sth->execute(); |
| 478 | - } catch(PDOException $e) { |
|
| 478 | + } catch (PDOException $e) { |
|
| 479 | 479 | return "error"; |
| 480 | 480 | } |
| 481 | 481 | |
@@ -498,14 +498,14 @@ discard block |
||
| 498 | 498 | |
| 499 | 499 | $sth = $this->db->prepare($query); |
| 500 | 500 | $sth->execute(); |
| 501 | - } catch(PDOException $e) { |
|
| 501 | + } catch (PDOException $e) { |
|
| 502 | 502 | return "error"; |
| 503 | 503 | } |
| 504 | 504 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 505 | 505 | $i = 0; |
| 506 | - $j =0; |
|
| 506 | + $j = 0; |
|
| 507 | 507 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 508 | - foreach($all as $row) |
|
| 508 | + foreach ($all as $row) |
|
| 509 | 509 | { |
| 510 | 510 | $i++; |
| 511 | 511 | $j++; |
@@ -513,9 +513,9 @@ discard block |
||
| 513 | 513 | if ($globalDebug) echo "."; |
| 514 | 514 | try { |
| 515 | 515 | |
| 516 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 516 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 517 | 517 | $sth->execute(); |
| 518 | - } catch(PDOException $e) { |
|
| 518 | + } catch (PDOException $e) { |
|
| 519 | 519 | return "error"; |
| 520 | 520 | } |
| 521 | 521 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -526,9 +526,9 @@ discard block |
||
| 526 | 526 | if ($i > 0) { |
| 527 | 527 | try { |
| 528 | 528 | |
| 529 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 529 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 530 | 530 | $sth->execute(); |
| 531 | - } catch(PDOException $e) { |
|
| 531 | + } catch (PDOException $e) { |
|
| 532 | 532 | return "error"; |
| 533 | 533 | } |
| 534 | 534 | } |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | |
| 542 | 542 | $sth = $this->db->prepare($query); |
| 543 | 543 | $sth->execute(); |
| 544 | - } catch(PDOException $e) { |
|
| 544 | + } catch (PDOException $e) { |
|
| 545 | 545 | return "error"; |
| 546 | 546 | } |
| 547 | 547 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -589,13 +589,13 @@ discard block |
||
| 589 | 589 | public function deleteLiveMarineDataByIdent($ident) |
| 590 | 590 | { |
| 591 | 591 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 592 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 592 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 593 | 593 | |
| 594 | 594 | try { |
| 595 | 595 | |
| 596 | 596 | $sth = $this->db->prepare($query); |
| 597 | 597 | $sth->execute(array(':ident' => $ident)); |
| 598 | - } catch(PDOException $e) { |
|
| 598 | + } catch (PDOException $e) { |
|
| 599 | 599 | return "error"; |
| 600 | 600 | } |
| 601 | 601 | |
@@ -611,13 +611,13 @@ discard block |
||
| 611 | 611 | public function deleteLiveMarineDataById($id) |
| 612 | 612 | { |
| 613 | 613 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 614 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 614 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 615 | 615 | |
| 616 | 616 | try { |
| 617 | 617 | |
| 618 | 618 | $sth = $this->db->prepare($query); |
| 619 | 619 | $sth->execute(array(':id' => $id)); |
| 620 | - } catch(PDOException $e) { |
|
| 620 | + } catch (PDOException $e) { |
|
| 621 | 621 | return "error"; |
| 622 | 622 | } |
| 623 | 623 | |
@@ -635,13 +635,13 @@ discard block |
||
| 635 | 635 | { |
| 636 | 636 | global $globalDBdriver, $globalTimezone; |
| 637 | 637 | if ($globalDBdriver == 'mysql') { |
| 638 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
| 638 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
| 639 | 639 | WHERE marine_live.ident = :ident |
| 640 | 640 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 641 | 641 | AND marine_live.date < UTC_TIMESTAMP()'; |
| 642 | 642 | $query_data = array(':ident' => $ident); |
| 643 | 643 | } else { |
| 644 | - $query = "SELECT marine_live.ident FROM marine_live |
|
| 644 | + $query = "SELECT marine_live.ident FROM marine_live |
|
| 645 | 645 | WHERE marine_live.ident = :ident |
| 646 | 646 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 647 | 647 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -650,8 +650,8 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | $sth = $this->db->prepare($query); |
| 652 | 652 | $sth->execute($query_data); |
| 653 | - $ident_result=''; |
|
| 654 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 653 | + $ident_result = ''; |
|
| 654 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 655 | 655 | { |
| 656 | 656 | $ident_result = $row['ident']; |
| 657 | 657 | } |
@@ -668,13 +668,13 @@ discard block |
||
| 668 | 668 | { |
| 669 | 669 | global $globalDBdriver, $globalTimezone; |
| 670 | 670 | if ($globalDBdriver == 'mysql') { |
| 671 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 671 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 672 | 672 | WHERE marine_live.ident = :ident |
| 673 | 673 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 674 | 674 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 675 | 675 | $query_data = array(':ident' => $ident); |
| 676 | 676 | } else { |
| 677 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 677 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 678 | 678 | WHERE marine_live.ident = :ident |
| 679 | 679 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 680 | 680 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -683,8 +683,8 @@ discard block |
||
| 683 | 683 | |
| 684 | 684 | $sth = $this->db->prepare($query); |
| 685 | 685 | $sth->execute($query_data); |
| 686 | - $ident_result=''; |
|
| 687 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 686 | + $ident_result = ''; |
|
| 687 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 688 | 688 | { |
| 689 | 689 | $ident_result = $row['fammarine_id']; |
| 690 | 690 | } |
@@ -701,13 +701,13 @@ discard block |
||
| 701 | 701 | { |
| 702 | 702 | global $globalDBdriver, $globalTimezone; |
| 703 | 703 | if ($globalDBdriver == 'mysql') { |
| 704 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 704 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 705 | 705 | WHERE marine_live.fammarine_id = :id |
| 706 | 706 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 707 | 707 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 708 | 708 | $query_data = array(':id' => $id); |
| 709 | 709 | } else { |
| 710 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 710 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 711 | 711 | WHERE marine_live.fammarine_id = :id |
| 712 | 712 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 713 | 713 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -716,8 +716,8 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | $sth = $this->db->prepare($query); |
| 718 | 718 | $sth->execute($query_data); |
| 719 | - $ident_result=''; |
|
| 720 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 719 | + $ident_result = ''; |
|
| 720 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 721 | 721 | { |
| 722 | 722 | $ident_result = $row['fammarine_id']; |
| 723 | 723 | } |
@@ -734,13 +734,13 @@ discard block |
||
| 734 | 734 | { |
| 735 | 735 | global $globalDBdriver, $globalTimezone; |
| 736 | 736 | if ($globalDBdriver == 'mysql') { |
| 737 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 737 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 738 | 738 | WHERE marine_live.mmsi = :mmsi |
| 739 | 739 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 740 | 740 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 741 | 741 | $query_data = array(':mmsi' => $mmsi); |
| 742 | 742 | } else { |
| 743 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 743 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 744 | 744 | WHERE marine_live.mmsi = :mmsi |
| 745 | 745 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 746 | 746 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -749,8 +749,8 @@ discard block |
||
| 749 | 749 | |
| 750 | 750 | $sth = $this->db->prepare($query); |
| 751 | 751 | $sth->execute($query_data); |
| 752 | - $ident_result=''; |
|
| 753 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 752 | + $ident_result = ''; |
|
| 753 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 754 | 754 | { |
| 755 | 755 | $ident_result = $row['fammarine_id']; |
| 756 | 756 | } |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | * @return String success or false |
| 769 | 769 | * |
| 770 | 770 | */ |
| 771 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$imo = '', $callsign = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 771 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $imo = '', $callsign = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 772 | 772 | { |
| 773 | 773 | global $globalURL, $globalArchive, $globalDebug; |
| 774 | 774 | $Common = new Common(); |
@@ -820,33 +820,33 @@ discard block |
||
| 820 | 820 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 821 | 821 | |
| 822 | 822 | |
| 823 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 824 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 825 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 826 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 827 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 828 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 829 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 830 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 831 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 832 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 833 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 834 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 835 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 836 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 837 | - |
|
| 838 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 839 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 823 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 824 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 825 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 826 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 827 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 828 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 829 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 830 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 831 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 832 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 833 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 834 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 835 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 836 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 837 | + |
|
| 838 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 839 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 840 | 840 | |
| 841 | - $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo) |
|
| 841 | + $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo) |
|
| 842 | 842 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo)'; |
| 843 | 843 | |
| 844 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo); |
|
| 844 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo); |
|
| 845 | 845 | try { |
| 846 | 846 | |
| 847 | 847 | $sth = $this->db->prepare($query); |
| 848 | 848 | $sth->execute($query_values); |
| 849 | - } catch(PDOException $e) { |
|
| 849 | + } catch (PDOException $e) { |
|
| 850 | 850 | return "error : ".$e->getMessage(); |
| 851 | 851 | } |
| 852 | 852 | /* |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | |
| 864 | 864 | public function getOrderBy() |
| 865 | 865 | { |
| 866 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 866 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 867 | 867 | return $orderby; |
| 868 | 868 | } |
| 869 | 869 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
| 50 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
| 51 | 51 | $Marine = new Marine($this->db); |
| 52 | - $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']); |
|
| 52 | + $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']); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
| 62 | 62 | if (isset($flight['lastupdate'])) { |
| 63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 63 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
| 64 | 64 | if (isset($this->all_tracked[$key]['id'])) { |
| 65 | 65 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
| 66 | 66 | /* |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | //$real_arrival = $this->arrival($key); |
| 72 | 72 | $Marine = new Marine($this->db); |
| 73 | 73 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 74 | - $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']); |
|
| 74 | + $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']); |
|
| 75 | 75 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 76 | 76 | } |
| 77 | 77 | // Put in archive |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $send = false; |
| 92 | 92 | |
| 93 | 93 | // SBS format is CSV format |
| 94 | - if(is_array($line) && isset($line['mmsi'])) { |
|
| 94 | + if (is_array($line) && isset($line['mmsi'])) { |
|
| 95 | 95 | //print_r($line); |
| 96 | 96 | if (isset($line['mmsi'])) { |
| 97 | 97 | |
@@ -114,18 +114,18 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | if (!isset($this->all_tracked[$id])) { |
| 116 | 116 | $this->all_tracked[$id] = array(); |
| 117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '')); |
|
| 119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
| 118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'imo' => '', 'callsign' => '')); |
|
| 119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
| 120 | 120 | if (!isset($line['id'])) { |
| 121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 122 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 122 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 123 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
| 124 | 124 | if ($globalAllTracked !== FALSE) $dataFound = true; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 128 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 128 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
| 129 | 129 | $Marine = new Marine($this->db); |
| 130 | 130 | $identity = $Marine->getIdentity($line['mmsi']); |
| 131 | 131 | if (!empty($identity)) { |
@@ -137,50 +137,50 @@ discard block |
||
| 137 | 137 | //$dataFound = true; |
| 138 | 138 | } |
| 139 | 139 | if (isset($line['type']) && $line['type'] != '') { |
| 140 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 140 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
| 141 | 141 | } |
| 142 | 142 | if (isset($line['imo']) && $line['imo'] != '') { |
| 143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
| 144 | 144 | } |
| 145 | 145 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 146 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 146 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
| 151 | 151 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 152 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 152 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
| 153 | 153 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
| 154 | 154 | $timeelapsed = microtime(true); |
| 155 | 155 | $Marine = new Marine($this->db); |
| 156 | 156 | $fromsource = NULL; |
| 157 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 157 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
| 158 | 158 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 159 | 159 | $Marine->db = null; |
| 160 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 160 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 161 | 161 | } |
| 162 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 162 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | if (isset($line['speed']) && $line['speed'] != '') { |
| 166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 167 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
| 167 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
| 168 | 168 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 169 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 169 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
| 170 | 170 | if ($distance > 1000 && $distance < 10000) { |
| 171 | 171 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 172 | 172 | $speed = $speed*3.6; |
| 173 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 173 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
| 174 | 174 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 179 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 179 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
| 180 | 180 | else unset($timediff); |
| 181 | - 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')))) { |
|
| 181 | + 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')))) { |
|
| 182 | 182 | 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'])) { |
| 183 | - 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'])) { |
|
| 183 | + 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'])) { |
|
| 184 | 184 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 185 | 185 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 186 | 186 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -188,10 +188,10 @@ discard block |
||
| 188 | 188 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 189 | 189 | $timeelapsed = microtime(true); |
| 190 | 190 | $Marine = new Marine($this->db); |
| 191 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 191 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 192 | 192 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
| 193 | 193 | $Marine->db = null; |
| 194 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 194 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 195 | 195 | $this->tmd = 0; |
| 196 | 196 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 197 | 197 | } |
@@ -199,66 +199,66 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 201 | 201 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 202 | - 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') { |
|
| 202 | + 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') { |
|
| 203 | 203 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 204 | 204 | $dataFound = true; |
| 205 | 205 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 206 | 206 | } |
| 207 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
| 207 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
| 208 | 208 | } |
| 209 | 209 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 210 | 210 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
| 211 | 211 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 212 | - 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') { |
|
| 212 | + 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') { |
|
| 213 | 213 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 214 | 214 | $dataFound = true; |
| 215 | 215 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 216 | 216 | } |
| 217 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
| 217 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | } else if ($globalDebug && $timediff > 20) { |
| 221 | 221 | $this->tmd = $this->tmd + 1; |
| 222 | 222 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 223 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
| 224 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 223 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
| 224 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 225 | 225 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 229 | 229 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
| 231 | 231 | } |
| 232 | 232 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
| 234 | 234 | } |
| 235 | 235 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
| 237 | 237 | } |
| 238 | 238 | if (isset($line['status']) && $line['status'] != '') { |
| 239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 243 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 243 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | if (isset($line['heading']) && $line['heading'] != '') { |
| 247 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 248 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 249 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 247 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 248 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
| 249 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
| 250 | 250 | //$dataFound = true; |
| 251 | 251 | } 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']) { |
| 252 | - $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']); |
|
| 253 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 254 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 252 | + $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']); |
|
| 253 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
| 254 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 255 | 255 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
| 256 | 256 | } |
| 257 | 257 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 258 | 258 | |
| 259 | 259 | if (isset($line['datetime'])) { |
| 260 | 260 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 261 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
| 261 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
| 262 | 262 | } else { |
| 263 | 263 | 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"; |
| 264 | 264 | 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"; |
@@ -266,48 +266,48 @@ discard block |
||
| 266 | 266 | } |
| 267 | 267 | } else { |
| 268 | 268 | date_default_timezone_set('UTC'); |
| 269 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 269 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | |
| 273 | 273 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
| 274 | 274 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 275 | 275 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
| 276 | - 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'])) { |
|
| 276 | + 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'])) { |
|
| 277 | 277 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 278 | 278 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
| 279 | 279 | $timeelapsed = microtime(true); |
| 280 | 280 | $MarineLive = new MarineLive($this->db); |
| 281 | 281 | if (isset($line['id'])) { |
| 282 | 282 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 283 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 284 | 284 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 285 | 285 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 286 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 287 | 287 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 288 | 288 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 289 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 289 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 290 | 290 | } else $recent_ident = ''; |
| 291 | - $MarineLive->db=null; |
|
| 291 | + $MarineLive->db = null; |
|
| 292 | 292 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 293 | 293 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 294 | 294 | } else { |
| 295 | 295 | $recent_ident = ''; |
| 296 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
| 296 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
| 297 | 297 | } |
| 298 | 298 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 299 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 299 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 300 | 300 | { |
| 301 | 301 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 302 | 302 | //adds the spotter data for the archive |
| 303 | 303 | $highlight = ''; |
| 304 | - 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'))); |
|
| 304 | + 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'))); |
|
| 305 | 305 | $timeelapsed = microtime(true); |
| 306 | 306 | $Marine = new Marine($this->db); |
| 307 | - $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]['imo'],$this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 307 | + $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]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
| 308 | 308 | $Marine->db = null; |
| 309 | 309 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 310 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 310 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 311 | 311 | |
| 312 | 312 | /* |
| 313 | 313 | // Add source stat in DB |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 346 | 346 | $MarineLive = new MarineLive($this->db); |
| 347 | 347 | $MarineLive->deleteLiveMarineData(); |
| 348 | - $MarineLive->db=null; |
|
| 348 | + $MarineLive->db = null; |
|
| 349 | 349 | if ($globalDebug) echo " Done\n"; |
| 350 | 350 | $this->last_delete = time(); |
| 351 | 351 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 355 | 355 | if (isset($globalDaemon) && !$globalDaemon) { |
| 356 | 356 | $Marine = new Marine($this->db); |
| 357 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
| 357 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
| 358 | 358 | $Marine->db = null; |
| 359 | 359 | } |
| 360 | 360 | |
@@ -368,14 +368,14 @@ discard block |
||
| 368 | 368 | $ignoreImport = false; |
| 369 | 369 | |
| 370 | 370 | if (!$ignoreImport) { |
| 371 | - 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'])) { |
|
| 371 | + 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'])) { |
|
| 372 | 372 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 373 | 373 | $timeelapsed = microtime(true); |
| 374 | 374 | $MarineLive = new MarineLive($this->db); |
| 375 | - $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]['imo'],$this->all_tracked[$id]['callsign'],$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']); |
|
| 375 | + $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]['imo'], $this->all_tracked[$id]['callsign'], $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']); |
|
| 376 | 376 | $MarineLive->db = null; |
| 377 | 377 | $this->all_tracked[$id]['putinarchive'] = false; |
| 378 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 378 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 379 | 379 | |
| 380 | 380 | // Put statistics in $this->stats variable |
| 381 | 381 | /* |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 435 | 435 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
| 436 | 436 | if ($globalDebug) echo $result."\n"; |
| 437 | - } 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"; |
|
| 437 | + } 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"; |
|
| 438 | 438 | //$this->del(); |
| 439 | 439 | |
| 440 | 440 | |
@@ -29,31 +29,31 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | private function make_latf($temp) { // unsigned long |
| 31 | 31 | $flat = 0.0; // float |
| 32 | - $temp = $temp & 0x07FFFFFF; |
|
| 33 | - if ($temp & 0x04000000) { |
|
| 34 | - $temp = $temp ^ 0x07FFFFFF; |
|
| 32 | + $temp = $temp&0x07FFFFFF; |
|
| 33 | + if ($temp&0x04000000) { |
|
| 34 | + $temp = $temp^0x07FFFFFF; |
|
| 35 | 35 | $temp += 1; |
| 36 | - $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 36 | + $flat = (float) ($temp/(60.0*10000.0)); |
|
| 37 | 37 | $flat *= -1.0; |
| 38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 38 | + } else $flat = (float) ($temp/(60.0*10000.0)); |
|
| 39 | 39 | return $flat; // float |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | private function make_lonf($temp) { // unsigned long |
| 43 | 43 | $flon = 0.0; // float |
| 44 | - $temp = $temp & 0x0FFFFFFF; |
|
| 45 | - if ($temp & 0x08000000) { |
|
| 46 | - $temp = $temp ^ 0x0FFFFFFF; |
|
| 44 | + $temp = $temp&0x0FFFFFFF; |
|
| 45 | + if ($temp&0x08000000) { |
|
| 46 | + $temp = $temp^0x0FFFFFFF; |
|
| 47 | 47 | $temp += 1; |
| 48 | - $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 48 | + $flon = (float) ($temp/(60.0*10000.0)); |
|
| 49 | 49 | $flon *= -1.0; |
| 50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 50 | + } else $flon = (float) ($temp/(60.0*10000.0)); |
|
| 51 | 51 | return $flon; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | private function ascii_2_dec($chr) { |
| 55 | - $dec=ord($chr);//get decimal ascii code |
|
| 56 | - $hex=dechex($dec);//convert decimal to hex |
|
| 55 | + $dec = ord($chr); //get decimal ascii code |
|
| 56 | + $hex = dechex($dec); //convert decimal to hex |
|
| 57 | 57 | return ($dec); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | //only process in the following range: 48-87, 96-119 |
| 73 | 73 | if ($ascii < 48) { } |
| 74 | 74 | else { |
| 75 | - if($ascii>119) { } |
|
| 75 | + if ($ascii > 119) { } |
|
| 76 | 76 | else { |
| 77 | - if ($ascii>87 && $ascii<96) ; |
|
| 77 | + if ($ascii > 87 && $ascii < 96); |
|
| 78 | 78 | else { |
| 79 | - $ascii=$ascii+40; |
|
| 80 | - if ($ascii>128){ |
|
| 81 | - $ascii=$ascii+32; |
|
| 79 | + $ascii = $ascii + 40; |
|
| 80 | + if ($ascii > 128) { |
|
| 81 | + $ascii = $ascii + 32; |
|
| 82 | 82 | } else { |
| 83 | - $ascii=$ascii+40; |
|
| 83 | + $ascii = $ascii + 40; |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | private function dec_2_6bit($dec) { |
| 92 | - $bin=decbin($dec); |
|
| 92 | + $bin = decbin($dec); |
|
| 93 | 93 | return(substr($bin, -6)); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | '<', '=', '>', '?' |
| 107 | 107 | ); |
| 108 | 108 | $rv = ''; |
| 109 | - if ($_size % 6 == 0) { |
|
| 110 | - $len = $_size / 6; |
|
| 111 | - for ($i=0; $i<$len; $i++) { |
|
| 112 | - $offset = $i * 6; |
|
| 113 | - $rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ]; |
|
| 109 | + if ($_size%6 == 0) { |
|
| 110 | + $len = $_size/6; |
|
| 111 | + for ($i = 0; $i < $len; $i++) { |
|
| 112 | + $offset = $i*6; |
|
| 113 | + $rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))]; |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | return $rv; |
@@ -132,23 +132,23 @@ discard block |
||
| 132 | 132 | $ro->lat = 0.0; |
| 133 | 133 | $ro->heading = ''; |
| 134 | 134 | $ro->ts = time(); |
| 135 | - $ro->id = bindec(substr($_aisdata,0,6)); |
|
| 136 | - $ro->mmsi = bindec(substr($_aisdata,8,30)); |
|
| 135 | + $ro->id = bindec(substr($_aisdata, 0, 6)); |
|
| 136 | + $ro->mmsi = bindec(substr($_aisdata, 8, 30)); |
|
| 137 | 137 | if ($ro->id >= 1 && $ro->id <= 3) { |
| 138 | - $ro->cog = bindec(substr($_aisdata,116,12))/10; |
|
| 139 | - $ro->sog = bindec(substr($_aisdata,50,10))/10; |
|
| 140 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
| 141 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
| 138 | + $ro->cog = bindec(substr($_aisdata, 116, 12))/10; |
|
| 139 | + $ro->sog = bindec(substr($_aisdata, 50, 10))/10; |
|
| 140 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
| 141 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
| 142 | 142 | $ro->cls = 1; // class A |
| 143 | 143 | } else if ($ro->id == 4) { |
| 144 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28))); |
|
| 145 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27))); |
|
| 144 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28))); |
|
| 145 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27))); |
|
| 146 | 146 | $ro->cls = 1; // class A |
| 147 | 147 | } else if ($ro->id == 5) { |
| 148 | - $ro->imo = bindec(substr($_aisdata,40,30)); |
|
| 149 | - $ro->callsign = $this->binchar($_aisdata,70,42); |
|
| 150 | - $ro->name = $this->binchar($_aisdata,112,120); |
|
| 151 | - $ro->typeid = bindec(substr($_aisdata,232,8)); |
|
| 148 | + $ro->imo = bindec(substr($_aisdata, 40, 30)); |
|
| 149 | + $ro->callsign = $this->binchar($_aisdata, 70, 42); |
|
| 150 | + $ro->name = $this->binchar($_aisdata, 112, 120); |
|
| 151 | + $ro->typeid = bindec(substr($_aisdata, 232, 8)); |
|
| 152 | 152 | $ro->type = $this->getShipType($ro->typeid); |
| 153 | 153 | //$ro->to_bow = bindec(substr($_aisdata,240,9)); |
| 154 | 154 | //$ro->to_stern = bindec(substr($_aisdata,249,9)); |
@@ -164,61 +164,61 @@ discard block |
||
| 164 | 164 | } else if ($ro->id == 9) { |
| 165 | 165 | // Search and Rescue aircraft position report |
| 166 | 166 | } else if ($ro->id == 18) { |
| 167 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
| 168 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
| 169 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
|
| 170 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
|
| 171 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
| 167 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
| 168 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
| 169 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28))); |
|
| 170 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27))); |
|
| 171 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
| 172 | 172 | if ($ro->heading == 511) $ro->heading = ''; |
| 173 | 173 | $ro->cls = 2; // class B |
| 174 | 174 | } else if ($ro->id == 19) { |
| 175 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
| 176 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
| 177 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
| 178 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
| 179 | - $ro->name = $this->binchar($_aisdata,143,120); |
|
| 175 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
| 176 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
| 177 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
| 178 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
| 179 | + $ro->name = $this->binchar($_aisdata, 143, 120); |
|
| 180 | 180 | $ro->cls = 2; // class B |
| 181 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
| 181 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
| 182 | 182 | if ($ro->heading == 511) $ro->heading = ''; |
| 183 | - $ro->typeid = bindec(substr($_aisdata,263,8)); |
|
| 183 | + $ro->typeid = bindec(substr($_aisdata, 263, 8)); |
|
| 184 | 184 | $ro->type = $this->getShipType($ro->typeid); |
| 185 | 185 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
| 186 | 186 | //$ro->to_stern = bindec(substr($_aisdata,280,9)); |
| 187 | 187 | //$ro->to_port = bindec(substr($_aisdata,289,6)); |
| 188 | 188 | //$ro->to_starboard = bindec(substr($_aisdata,295,6)); |
| 189 | 189 | } else if ($ro->id == 21) { |
| 190 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28))); |
|
| 191 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27))); |
|
| 192 | - $ro->name = $this->binchar($_aisdata,43,120); |
|
| 190 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28))); |
|
| 191 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27))); |
|
| 192 | + $ro->name = $this->binchar($_aisdata, 43, 120); |
|
| 193 | 193 | //$ro->to_bow = bindec(substr($_aisdata,219,9)); |
| 194 | 194 | //$ro->to_stern = bindec(substr($_aisdata,228,9)); |
| 195 | 195 | //$ro->to_port = bindec(substr($_aisdata,237,6)); |
| 196 | 196 | //$ro->to_starboard = bindec(substr($_aisdata,243,6)); |
| 197 | 197 | $ro->cls = 2; // class B |
| 198 | 198 | } else if ($ro->id == 24) { |
| 199 | - $pn = bindec(substr($_aisdata,38,2)); |
|
| 199 | + $pn = bindec(substr($_aisdata, 38, 2)); |
|
| 200 | 200 | if ($pn == 0) { |
| 201 | - $ro->name = $this->binchar($_aisdata,40,120); |
|
| 201 | + $ro->name = $this->binchar($_aisdata, 40, 120); |
|
| 202 | 202 | } |
| 203 | - $ro->typeid = bindec(substr($_aisdata,40,8)); |
|
| 203 | + $ro->typeid = bindec(substr($_aisdata, 40, 8)); |
|
| 204 | 204 | $ro->type = $this->getShipType($ro->typeid); |
| 205 | - $ro->callsign = $this->binchar($_aisdata,90,42); |
|
| 205 | + $ro->callsign = $this->binchar($_aisdata, 90, 42); |
|
| 206 | 206 | //$ro->to_bow = bindec(substr($_aisdata,132,9)); |
| 207 | 207 | //$ro->to_stern = bindec(substr($_aisdata,141,9)); |
| 208 | 208 | //$ro->to_port = bindec(substr($_aisdata,150,6)); |
| 209 | 209 | //$ro->to_starboard = bindec(substr($_aisdata,156,6)); |
| 210 | 210 | $ro->cls = 2; // class B |
| 211 | 211 | } else if ($ro->id == 27) { |
| 212 | - $ro->cog = bindec(substr($_aisdata,85,9)); |
|
| 212 | + $ro->cog = bindec(substr($_aisdata, 85, 9)); |
|
| 213 | 213 | if ($ro->cog == 511) $ro->cog = 0.0; |
| 214 | - $ro->sog = bindec(substr($_aisdata,79,6)); |
|
| 214 | + $ro->sog = bindec(substr($_aisdata, 79, 6)); |
|
| 215 | 215 | if ($ro->sog == 63) $ro->sog = 0.0; |
| 216 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
|
| 217 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
|
| 216 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10); |
|
| 217 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10); |
|
| 218 | 218 | $ro->cls = 1; // class A |
| 219 | 219 | |
| 220 | 220 | } |
| 221 | - $ro->statusid = bindec(substr($_aisdata,38,4)); |
|
| 221 | + $ro->statusid = bindec(substr($_aisdata, 38, 4)); |
|
| 222 | 222 | $ro->status = $this->getStatus($ro->statusid); |
| 223 | 223 | //var_dump($ro); // dump results here for demo purpose |
| 224 | 224 | return $ro; |
@@ -349,14 +349,14 @@ discard block |
||
| 349 | 349 | global $port; // tcpip port... |
| 350 | 350 | |
| 351 | 351 | static $debug_counter = 0; |
| 352 | - $aisdata168='';//six bit array of ascii characters |
|
| 352 | + $aisdata168 = ''; //six bit array of ascii characters |
|
| 353 | 353 | $ais_nmea_array = str_split($_itu); // convert to an array |
| 354 | 354 | foreach ($ais_nmea_array as $value) { |
| 355 | 355 | $dec = $this->ascii_2_dec($value); |
| 356 | 356 | $bit8 = $this->asciidec_2_8bit($dec); |
| 357 | 357 | $bit6 = $this->dec_2_6bit($bit8); |
| 358 | 358 | //echo $value ."-" .$bit6 .""; |
| 359 | - $aisdata168 .=$bit6; |
|
| 359 | + $aisdata168 .= $bit6; |
|
| 360 | 360 | } |
| 361 | 361 | //echo $aisdata168 . "<br/>"; |
| 362 | 362 | //return $this->decode_ais($aisdata168, $aux); |
@@ -379,20 +379,20 @@ discard block |
||
| 379 | 379 | // calculate checksum after ! till * |
| 380 | 380 | // assume 1st ! is valid |
| 381 | 381 | // find * ensure that it is at correct position |
| 382 | - $end = strrpos ( $rawdata , '*' ); |
|
| 382 | + $end = strrpos($rawdata, '*'); |
|
| 383 | 383 | if ($end === FALSE) return -1; // check for NULLS!!! |
| 384 | - $cs = substr( $rawdata, $end + 1 ); |
|
| 385 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
| 386 | - $dcs = (int)hexdec( $cs ); |
|
| 387 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
| 388 | - if ( $chksum == $dcs ) { // NMEA checksum pass |
|
| 384 | + $cs = substr($rawdata, $end + 1); |
|
| 385 | + if (strlen($cs) != 2) return -1; // correct cs length |
|
| 386 | + $dcs = (int) hexdec($cs); |
|
| 387 | + for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum |
|
| 388 | + if ($chksum == $dcs) { // NMEA checksum pass |
|
| 389 | 389 | $pcs = explode(',', $rawdata); |
| 390 | 390 | // !AI??? identifier |
| 391 | - $num_seq = (int)$pcs[1]; // number of sequences |
|
| 392 | - $seq = (int)$pcs[2]; // get sequence |
|
| 391 | + $num_seq = (int) $pcs[1]; // number of sequences |
|
| 392 | + $seq = (int) $pcs[2]; // get sequence |
|
| 393 | 393 | // get msg sequence id |
| 394 | 394 | if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
| 395 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
| 395 | + else $msg_sid = (int) $pcs[3]; // multipart message |
|
| 396 | 396 | $ais_ch = $pcs[4]; // get AIS channel |
| 397 | 397 | // message sequence checking |
| 398 | 398 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | $itu = $itu.$pcs[5]; // get itu message |
| 428 | - $filler += (int)$pcs[6][0]; // get filler |
|
| 428 | + $filler += (int) $pcs[6][0]; // get filler |
|
| 429 | 429 | if ($num_seq == 1 // valid single message |
| 430 | 430 | || $num_seq == $pseq // valid multi-part message |
| 431 | 431 | ) { |
@@ -445,13 +445,13 @@ discard block |
||
| 445 | 445 | $cbuf = $cbuf.$ibuf; |
| 446 | 446 | $last_pos = 0; |
| 447 | 447 | $result = new stdClass(); |
| 448 | - while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) { |
|
| 448 | + while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) { |
|
| 449 | 449 | //while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) { |
| 450 | 450 | //DEBUG echo $cbuf; |
| 451 | - if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
| 451 | + if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
| 452 | 452 | $tst = substr($cbuf, $start - 3, ($end - $start + 3)); |
| 453 | 453 | //DEBUG echo "[$start $end $tst]\n"; |
| 454 | - $result = $this->process_ais_raw( $tst, "" ); |
|
| 454 | + $result = $this->process_ais_raw($tst, ""); |
|
| 455 | 455 | $last_pos = $end + 1; |
| 456 | 456 | } else break; |
| 457 | 457 | } |
@@ -463,41 +463,41 @@ discard block |
||
| 463 | 463 | // incoming data from serial or IP comms |
| 464 | 464 | public function process_ais_line($cbuf) { |
| 465 | 465 | $result = new stdClass(); |
| 466 | - $start = strpos($cbuf,"VDM"); |
|
| 466 | + $start = strpos($cbuf, "VDM"); |
|
| 467 | 467 | $tst = substr($cbuf, $start - 3); |
| 468 | - $result = $this->process_ais_raw( $tst, "" ); |
|
| 468 | + $result = $this->process_ais_raw($tst, ""); |
|
| 469 | 469 | return $result; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /* AIS Encoding |
| 473 | 473 | */ |
| 474 | - private function mk_ais_lat( $lat ) { |
|
| 474 | + private function mk_ais_lat($lat) { |
|
| 475 | 475 | //$lat = 1.2569; |
| 476 | - if ($lat<0.0) { |
|
| 476 | + if ($lat < 0.0) { |
|
| 477 | 477 | $lat = -$lat; |
| 478 | - $neg=true; |
|
| 479 | - } else $neg=false; |
|
| 478 | + $neg = true; |
|
| 479 | + } else $neg = false; |
|
| 480 | 480 | $latd = 0x00000000; |
| 481 | - $latd = intval ($lat * 600000.0); |
|
| 482 | - if ($neg==true) { |
|
| 481 | + $latd = intval($lat*600000.0); |
|
| 482 | + if ($neg == true) { |
|
| 483 | 483 | $latd = ~$latd; |
| 484 | - $latd+=1; |
|
| 484 | + $latd += 1; |
|
| 485 | 485 | $latd &= 0x07FFFFFF; |
| 486 | 486 | } |
| 487 | 487 | return $latd; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - private function mk_ais_lon( $lon ) { |
|
| 490 | + private function mk_ais_lon($lon) { |
|
| 491 | 491 | //$lon = 103.851; |
| 492 | - if ($lon<0.0) { |
|
| 492 | + if ($lon < 0.0) { |
|
| 493 | 493 | $lon = -$lon; |
| 494 | - $neg=true; |
|
| 495 | - } else $neg=false; |
|
| 494 | + $neg = true; |
|
| 495 | + } else $neg = false; |
|
| 496 | 496 | $lond = 0x00000000; |
| 497 | - $lond = intval ($lon * 600000.0); |
|
| 498 | - if ($neg==true) { |
|
| 497 | + $lond = intval($lon*600000.0); |
|
| 498 | + if ($neg == true) { |
|
| 499 | 499 | $lond = ~$lond; |
| 500 | - $lond+=1; |
|
| 500 | + $lond += 1; |
|
| 501 | 501 | $lond &= 0x0FFFFFFF; |
| 502 | 502 | } |
| 503 | 503 | return $lond; |
@@ -505,8 +505,8 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | private function char2bin($name, $max_len) { |
| 507 | 507 | $len = strlen($name); |
| 508 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
| 509 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 508 | + if ($len > $max_len) $name = substr($name, 0, $max_len); |
|
| 509 | + if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6); |
|
| 510 | 510 | else $pad = ''; |
| 511 | 511 | $rv = ''; |
| 512 | 512 | $ais_chars = array( |
@@ -522,26 +522,26 @@ discard block |
||
| 522 | 522 | if ($_a) foreach ($_a as $_1) { |
| 523 | 523 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
| 524 | 524 | else $dec = 0; |
| 525 | - $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
|
| 525 | + $bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT); |
|
| 526 | 526 | $rv .= $bin; |
| 527 | 527 | //echo "$_1 $dec ($bin)<br/>"; |
| 528 | 528 | } |
| 529 | 529 | return $rv.$pad; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') { |
|
| 532 | + private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') { |
|
| 533 | 533 | $len_bit = strlen($_enc); |
| 534 | - $rem6 = $len_bit % 6; |
|
| 534 | + $rem6 = $len_bit%6; |
|
| 535 | 535 | $pad6_len = 0; |
| 536 | 536 | if ($rem6) $pad6_len = 6 - $rem6; |
| 537 | 537 | //echo $pad6_len.'<br>'; |
| 538 | 538 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
| 539 | - $len_enc = strlen($_enc) / 6; |
|
| 539 | + $len_enc = strlen($_enc)/6; |
|
| 540 | 540 | //echo $_enc.' '.$len_enc.'<br/>'; |
| 541 | 541 | $itu = ''; |
| 542 | - for ($i=0; $i<$len_enc; $i++) { |
|
| 543 | - $offset = $i * 6; |
|
| 544 | - $dec = bindec(substr($_enc,$offset,6)); |
|
| 542 | + for ($i = 0; $i < $len_enc; $i++) { |
|
| 543 | + $offset = $i*6; |
|
| 544 | + $dec = bindec(substr($_enc, $offset, 6)); |
|
| 545 | 545 | if ($dec < 40) $dec += 48; |
| 546 | 546 | else $dec += 56; |
| 547 | 547 | //echo chr($dec)." $dec<br/>"; |
@@ -551,15 +551,15 @@ discard block |
||
| 551 | 551 | $chksum = 0; |
| 552 | 552 | $itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0"; |
| 553 | 553 | $len_itu = strlen($itu); |
| 554 | - for ($i=0; $i<$len_itu; $i++) { |
|
| 555 | - $chksum ^= ord( $itu[$i] ); |
|
| 554 | + for ($i = 0; $i < $len_itu; $i++) { |
|
| 555 | + $chksum ^= ord($itu[$i]); |
|
| 556 | 556 | } |
| 557 | - $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
| 558 | - $lsb = $chksum & 0x0F; |
|
| 559 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
| 557 | + $hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
| 558 | + $lsb = $chksum&0x0F; |
|
| 559 | + if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb]; |
|
| 560 | 560 | else $lsbc = '0'; |
| 561 | - $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
|
| 562 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
| 561 | + $msb = (($chksum&0xF0) >> 4)&0x0F; |
|
| 562 | + if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb]; |
|
| 563 | 563 | else $msbc = '0'; |
| 564 | 564 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
| 565 | 565 | return $itu; |
@@ -585,13 +585,13 @@ discard block |
||
| 585 | 585 | public function parse_line($buffer) { |
| 586 | 586 | $result = array(); |
| 587 | 587 | $data = new stdClass(); |
| 588 | - $start = strpos($buffer,"VDM"); |
|
| 588 | + $start = strpos($buffer, "VDM"); |
|
| 589 | 589 | $tst = substr($buffer, $start - 3); |
| 590 | - $data = $this->process_ais_raw( $tst, "" ); |
|
| 590 | + $data = $this->process_ais_raw($tst, ""); |
|
| 591 | 591 | if (!is_object($data)) return array(); |
| 592 | 592 | if ($data->lon != 0) $result['longitude'] = $data->lon; |
| 593 | 593 | if ($data->lat != 0) $result['latitude'] = $data->lat; |
| 594 | - $result['ident'] = trim(str_replace('@','',$data->name)); |
|
| 594 | + $result['ident'] = trim(str_replace('@', '', $data->name)); |
|
| 595 | 595 | $result['timestamp'] = $data->ts; |
| 596 | 596 | $result['mmsi'] = $data->mmsi; |
| 597 | 597 | if ($data->sog != -1.0) $result['speed'] = $data->sog; |