@@ -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"; |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
| 416 | 416 | if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
| 417 | 417 | if (isset($ais_data['timestamp'])) { |
| 418 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 418 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 419 | 419 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 420 | 420 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
| 421 | 421 | $add = true; |
@@ -438,12 +438,12 @@ discard block |
||
| 438 | 438 | $w = $e = null; |
| 439 | 439 | |
| 440 | 440 | if (isset($arr[$id])) { |
| 441 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 441 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
| 442 | 442 | if ($nn > 0) { |
| 443 | 443 | foreach ($httpfeeds as $feed) { |
| 444 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 445 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 446 | - $buffer = explode('\n',$buffer); |
|
| 444 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
| 445 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 446 | + $buffer = explode('\n', $buffer); |
|
| 447 | 447 | foreach ($buffer as $line) { |
| 448 | 448 | if ($line != '') { |
| 449 | 449 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
| 457 | 457 | if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
| 458 | 458 | if (isset($ais_data['timestamp'])) { |
| 459 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 459 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 460 | 460 | } else { |
| 461 | 461 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 462 | 462 | } |
@@ -471,27 +471,27 @@ discard block |
||
| 471 | 471 | } |
| 472 | 472 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 473 | 473 | echo 'download...'; |
| 474 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 474 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
| 475 | 475 | echo 'done !'."\n"; |
| 476 | 476 | if ($buffer != '') $reset = 0; |
| 477 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 478 | - $buffer = explode('\n',$buffer); |
|
| 477 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 478 | + $buffer = explode('\n', $buffer); |
|
| 479 | 479 | foreach ($buffer as $line) { |
| 480 | 480 | if ($line != '') { |
| 481 | 481 | $data = array(); |
| 482 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 483 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 482 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
| 483 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
| 484 | 484 | //$data['status'] = substr($line,21,2); |
| 485 | 485 | //$data['type'] = substr($line,24,3); |
| 486 | - $data['latitude'] = substr($line,29,9); |
|
| 487 | - $data['longitude'] = substr($line,41,9); |
|
| 488 | - $data['speed'] = round(substr($line,51,5)); |
|
| 486 | + $data['latitude'] = substr($line, 29, 9); |
|
| 487 | + $data['longitude'] = substr($line, 41, 9); |
|
| 488 | + $data['speed'] = round(substr($line, 51, 5)); |
|
| 489 | 489 | //$data['course'] = substr($line,57,5); |
| 490 | - $data['heading'] = round(substr($line,63,3)); |
|
| 490 | + $data['heading'] = round(substr($line, 63, 3)); |
|
| 491 | 491 | //$data['draft'] = substr($line,67,4); |
| 492 | 492 | //$data['length'] = substr($line,72,3); |
| 493 | 493 | //$data['beam'] = substr($line,76,2); |
| 494 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 494 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
| 495 | 495 | //$data['callsign'] = trim(substr($line,100,7); |
| 496 | 496 | //$data['dest'] = substr($line,108,20); |
| 497 | 497 | //$data['etaDate'] = substr($line,129,5); |
@@ -509,8 +509,8 @@ discard block |
||
| 509 | 509 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 510 | 510 | //$buffer = $Common->getData($hosts[$id]); |
| 511 | 511 | $buffer = $Common->getData($value['host']); |
| 512 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 513 | - $buffer = explode('\n',$buffer); |
|
| 512 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 513 | + $buffer = explode('\n', $buffer); |
|
| 514 | 514 | $reset = 0; |
| 515 | 515 | foreach ($buffer as $line) { |
| 516 | 516 | if ($line != '') { |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 522 | 522 | $data['pilot_id'] = $line[1]; |
| 523 | 523 | $data['pilot_name'] = $line[2]; |
| 524 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
| 524 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
| 525 | 525 | $data['ident'] = $line[0]; // ident |
| 526 | 526 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 527 | 527 | $data['speed'] = $line[8]; // speed |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 538 | 538 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 539 | 539 | $data['departure_airport_icao'] = $line[11]; |
| 540 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 540 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 541 | 541 | $data['arrival_airport_icao'] = $line[13]; |
| 542 | 542 | $data['frequency'] = $line[4]; |
| 543 | 543 | $data['type'] = $line[18]; |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | $data['id_source'] = $id_source; |
| 547 | 547 | //$data['arrival_airport_time'] = ; |
| 548 | 548 | if ($line[9] != '') { |
| 549 | - $aircraft_data = explode('/',$line[9]); |
|
| 549 | + $aircraft_data = explode('/', $line[9]); |
|
| 550 | 550 | if (isset($aircraft_data[1])) { |
| 551 | 551 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 552 | 552 | } |
@@ -560,9 +560,9 @@ discard block |
||
| 560 | 560 | if ($line[3] == 'PILOT') $SI->add($data); |
| 561 | 561 | elseif ($line[3] == 'ATC') { |
| 562 | 562 | //print_r($data); |
| 563 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 564 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 565 | - $typec = substr($data['ident'],-3); |
|
| 563 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 564 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 565 | + $typec = substr($data['ident'], -3); |
|
| 566 | 566 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 567 | 567 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
| 568 | 568 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 574 | 574 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
| 575 | 575 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 576 | - 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']); |
|
| 576 | + 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']); |
|
| 577 | 577 | } |
| 578 | 578 | unset($data); |
| 579 | 579 | } |
@@ -584,9 +584,9 @@ discard block |
||
| 584 | 584 | $last_exec[$id]['last'] = time(); |
| 585 | 585 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
| 586 | 586 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 587 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 587 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 588 | 588 | if ($buffer != '') { |
| 589 | - $all_data = json_decode($buffer,true); |
|
| 589 | + $all_data = json_decode($buffer, true); |
|
| 590 | 590 | if (isset($all_data['acList'])) { |
| 591 | 591 | $reset = 0; |
| 592 | 592 | foreach ($all_data['acList'] as $line) { |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
| 643 | 643 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 644 | 644 | $buffer = $Common->getData($value['host']); |
| 645 | - $all_data = json_decode($buffer,true); |
|
| 645 | + $all_data = json_decode($buffer, true); |
|
| 646 | 646 | if (isset($all_data['planes'])) { |
| 647 | 647 | $reset = 0; |
| 648 | 648 | foreach ($all_data['planes'] as $key => $line) { |
@@ -659,12 +659,12 @@ discard block |
||
| 659 | 659 | $data['emergency'] = ''; // emergency |
| 660 | 660 | $data['registration'] = $line[2]; |
| 661 | 661 | $data['aircraft_icao'] = $line[0]; |
| 662 | - $deparr = explode('-',$line[1]); |
|
| 662 | + $deparr = explode('-', $line[1]); |
|
| 663 | 663 | if (count($deparr) == 2) { |
| 664 | 664 | $data['departure_airport_icao'] = $deparr[0]; |
| 665 | 665 | $data['arrival_airport_icao'] = $deparr[1]; |
| 666 | 666 | } |
| 667 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 667 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 668 | 668 | $data['format_source'] = 'planeupdatefaa'; |
| 669 | 669 | $data['id_source'] = $id_source; |
| 670 | 670 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | $last_exec[$id]['last'] = time(); |
| 677 | 677 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 678 | 678 | $buffer = $Common->getData($value['host']); |
| 679 | - $all_data = json_decode($buffer,true); |
|
| 679 | + $all_data = json_decode($buffer, true); |
|
| 680 | 680 | if (isset($all_data['states'])) { |
| 681 | 681 | $reset = 0; |
| 682 | 682 | foreach ($all_data['states'] as $key => $line) { |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | //$data['emergency'] = ''; // emergency |
| 694 | 694 | //$data['registration'] = $line[2]; |
| 695 | 695 | //$data['aircraft_icao'] = $line[0]; |
| 696 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 696 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 697 | 697 | $data['format_source'] = 'opensky'; |
| 698 | 698 | $data['id_source'] = $id_source; |
| 699 | 699 | $SI->add($data); |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 707 | 707 | //$buffer = $Common->getData($hosts[$id]); |
| 708 | 708 | $buffer = $Common->getData($value['host']); |
| 709 | - $all_data = json_decode($buffer,true); |
|
| 709 | + $all_data = json_decode($buffer, true); |
|
| 710 | 710 | if (!empty($all_data)) $reset = 0; |
| 711 | 711 | foreach ($all_data as $key => $line) { |
| 712 | 712 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -738,11 +738,11 @@ discard block |
||
| 738 | 738 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 739 | 739 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 740 | 740 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 741 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 741 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 742 | 742 | //echo $buffer; |
| 743 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 744 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 745 | - $all_data = json_decode($buffer,true); |
|
| 743 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 744 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 745 | + $all_data = json_decode($buffer, true); |
|
| 746 | 746 | if (json_last_error() != JSON_ERROR_NONE) { |
| 747 | 747 | die(json_last_error_msg()); |
| 748 | 748 | } |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | //$data['departure_airport_iata'] = $line[11]; |
| 766 | 766 | //$data['arrival_airport_iata'] = $line[12]; |
| 767 | 767 | //$data['emergency'] = ''; // emergency |
| 768 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 768 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 769 | 769 | $data['format_source'] = 'radarvirtueljson'; |
| 770 | 770 | $data['id_source'] = $id_source; |
| 771 | 771 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -780,14 +780,14 @@ discard block |
||
| 780 | 780 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 781 | 781 | //$buffer = $Common->getData($hosts[$id]); |
| 782 | 782 | $buffer = $Common->getData($value['host'].'?'.time()); |
| 783 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 783 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 784 | 784 | |
| 785 | 785 | if (isset($all_data['pireps'])) { |
| 786 | 786 | $reset = 0; |
| 787 | 787 | foreach ($all_data['pireps'] as $line) { |
| 788 | 788 | $data = array(); |
| 789 | 789 | $data['id'] = $line['id']; |
| 790 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 790 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 791 | 791 | $data['ident'] = $line['callsign']; // ident |
| 792 | 792 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 793 | 793 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -816,9 +816,9 @@ discard block |
||
| 816 | 816 | $SI->add($data); |
| 817 | 817 | // print_r($data); |
| 818 | 818 | } elseif ($line['icon'] == 'ct') { |
| 819 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 820 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 821 | - $typec = substr($data['ident'],-3); |
|
| 819 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 820 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 821 | + $typec = substr($data['ident'], -3); |
|
| 822 | 822 | $data['type'] = ''; |
| 823 | 823 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 824 | 824 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
| 830 | 830 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 831 | 831 | else $data['type'] = 'Observer'; |
| 832 | - 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']); |
|
| 832 | + 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']); |
|
| 833 | 833 | } |
| 834 | 834 | unset($data); |
| 835 | 835 | } |
@@ -841,14 +841,14 @@ discard block |
||
| 841 | 841 | //$buffer = $Common->getData($hosts[$id]); |
| 842 | 842 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 843 | 843 | $buffer = $Common->getData($value['host']); |
| 844 | - $all_data = json_decode($buffer,true); |
|
| 844 | + $all_data = json_decode($buffer, true); |
|
| 845 | 845 | if ($buffer != '' && is_array($all_data)) { |
| 846 | 846 | $reset = 0; |
| 847 | 847 | foreach ($all_data as $line) { |
| 848 | 848 | $data = array(); |
| 849 | 849 | //$data['id'] = $line['id']; // id not usable |
| 850 | 850 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
| 851 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 851 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 852 | 852 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 853 | 853 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 854 | 854 | $data['ident'] = $line['flightnum']; // ident |
@@ -871,12 +871,12 @@ discard block |
||
| 871 | 871 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 872 | 872 | if (isset($line['aircraftname'])) { |
| 873 | 873 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 874 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 875 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 874 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 875 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 876 | 876 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
| 877 | 877 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
| 878 | 878 | else { |
| 879 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 879 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 880 | 880 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
| 881 | 881 | else $data['aircraft_icao'] = $line['aircraftname']; |
| 882 | 882 | } |
@@ -898,14 +898,14 @@ discard block |
||
| 898 | 898 | //$buffer = $Common->getData($hosts[$id]); |
| 899 | 899 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 900 | 900 | $buffer = $Common->getData($value['host']); |
| 901 | - $all_data = json_decode($buffer,true); |
|
| 901 | + $all_data = json_decode($buffer, true); |
|
| 902 | 902 | if ($buffer != '' && is_array($all_data)) { |
| 903 | 903 | $reset = 0; |
| 904 | 904 | foreach ($all_data as $line) { |
| 905 | 905 | $data = array(); |
| 906 | 906 | //$data['id'] = $line['id']; // id not usable |
| 907 | 907 | $data['id'] = trim($line['flight_id']); |
| 908 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 908 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 909 | 909 | $data['pilot_name'] = $line['pilot_name']; |
| 910 | 910 | $data['pilot_id'] = $line['pilot_id']; |
| 911 | 911 | $data['ident'] = trim($line['callsign']); // ident |
@@ -956,9 +956,9 @@ discard block |
||
| 956 | 956 | //$value = $formats[$nb]; |
| 957 | 957 | $format = $globalSources[$nb]['format']; |
| 958 | 958 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
| 959 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 959 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 960 | 960 | } else { |
| 961 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 961 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 962 | 962 | } |
| 963 | 963 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 964 | 964 | //echo $buffer."\n"; |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
| 967 | 967 | $error = false; |
| 968 | 968 | //$SI::del(); |
| 969 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 969 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 970 | 970 | // SBS format is CSV format |
| 971 | 971 | if ($buffer != '') { |
| 972 | 972 | $tt[$format] = 0; |
@@ -994,7 +994,7 @@ discard block |
||
| 994 | 994 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
| 995 | 995 | if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
| 996 | 996 | if (isset($ais_data['timestamp'])) { |
| 997 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 997 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 998 | 998 | } else { |
| 999 | 999 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1000 | 1000 | } |
@@ -1005,10 +1005,10 @@ discard block |
||
| 1005 | 1005 | } elseif ($format == 'flightgearsp') { |
| 1006 | 1006 | //echo $buffer."\n"; |
| 1007 | 1007 | if (strlen($buffer) > 5) { |
| 1008 | - $line = explode(',',$buffer); |
|
| 1008 | + $line = explode(',', $buffer); |
|
| 1009 | 1009 | $data = array(); |
| 1010 | 1010 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 1011 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1011 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1012 | 1012 | $data['ident'] = $line[6]; |
| 1013 | 1013 | $data['aircraft_name'] = $line[7]; |
| 1014 | 1014 | $data['longitude'] = $line[1]; |
@@ -1019,21 +1019,21 @@ discard block |
||
| 1019 | 1019 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1020 | 1020 | $data['format_source'] = 'flightgearsp'; |
| 1021 | 1021 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1022 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1022 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1023 | 1023 | } |
| 1024 | 1024 | } elseif ($format == 'acars') { |
| 1025 | 1025 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1026 | 1026 | $ACARS->add(trim($buffer)); |
| 1027 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1027 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1028 | 1028 | $ACARS->deleteLiveAcarsData(); |
| 1029 | 1029 | } elseif ($format == 'flightgearmp') { |
| 1030 | - if (substr($buffer,0,1) != '#') { |
|
| 1030 | + if (substr($buffer, 0, 1) != '#') { |
|
| 1031 | 1031 | $data = array(); |
| 1032 | 1032 | //echo $buffer."\n"; |
| 1033 | - $line = explode(' ',$buffer); |
|
| 1033 | + $line = explode(' ', $buffer); |
|
| 1034 | 1034 | if (count($line) == 11) { |
| 1035 | - $userserver = explode('@',$line[0]); |
|
| 1036 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1035 | + $userserver = explode('@', $line[0]); |
|
| 1036 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 1037 | 1037 | $data['ident'] = $userserver[0]; |
| 1038 | 1038 | $data['registration'] = $userserver[0]; |
| 1039 | 1039 | $data['latitude'] = $line[4]; |
@@ -1041,24 +1041,24 @@ discard block |
||
| 1041 | 1041 | $data['altitude'] = $line[6]; |
| 1042 | 1042 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1043 | 1043 | $aircraft_type = $line[10]; |
| 1044 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1045 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1044 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 1045 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 1046 | 1046 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1047 | 1047 | } |
| 1048 | 1048 | } |
| 1049 | 1049 | } elseif ($format == 'beast') { |
| 1050 | 1050 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 1051 | 1051 | die; |
| 1052 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
| 1052 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
| 1053 | 1053 | $line = explode("\t", $buffer); |
| 1054 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1054 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 1055 | 1055 | $key = $line[$k]; |
| 1056 | - $lined[$key] = $line[$k+1]; |
|
| 1056 | + $lined[$key] = $line[$k + 1]; |
|
| 1057 | 1057 | } |
| 1058 | 1058 | if (count($lined) > 3) { |
| 1059 | 1059 | $data['hex'] = $lined['hexid']; |
| 1060 | 1060 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1061 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1061 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 1062 | 1062 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 1063 | 1063 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 1064 | 1064 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1076,21 +1076,21 @@ discard block |
||
| 1076 | 1076 | } else $error = true; |
| 1077 | 1077 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1078 | 1078 | if ($aprs_connect == 0) { |
| 1079 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 1079 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 1080 | 1080 | $aprs_connect = 1; |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1083 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 1084 | 1084 | $aprs_last_tx = time(); |
| 1085 | 1085 | $data_aprs = "# Keep alive"; |
| 1086 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1086 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 1090 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1091 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1090 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 1091 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 1092 | 1092 | //echo $buffer."\n"; |
| 1093 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1093 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 1094 | 1094 | $line = $APRS->parse($buffer); |
| 1095 | 1095 | //print_r($line); |
| 1096 | 1096 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
@@ -1099,7 +1099,7 @@ discard block |
||
| 1099 | 1099 | $data = array(); |
| 1100 | 1100 | //print_r($line); |
| 1101 | 1101 | if (isset($line['address'])) $data['hex'] = $line['address']; |
| 1102 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1102 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 1103 | 1103 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1104 | 1104 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1105 | 1105 | $data['ident'] = $line['ident']; |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | $currentdate = date('Y-m-d H:i:s'); |
| 1124 | 1124 | $aprsdate = strtotime($data['datetime']); |
| 1125 | 1125 | // Accept data if time <= system time + 20s |
| 1126 | - 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'])))) { |
|
| 1126 | + 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'])))) { |
|
| 1127 | 1127 | $send = $SI->add($data); |
| 1128 | 1128 | } elseif (isset($line['stealth'])) { |
| 1129 | 1129 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
@@ -1220,7 +1220,7 @@ discard block |
||
| 1220 | 1220 | connect_all($sourceee); |
| 1221 | 1221 | $sourceee = array(); |
| 1222 | 1222 | //connect_all($globalSources); |
| 1223 | - $tt[$format]=0; |
|
| 1223 | + $tt[$format] = 0; |
|
| 1224 | 1224 | break; |
| 1225 | 1225 | } |
| 1226 | 1226 | } |
@@ -1229,14 +1229,14 @@ discard block |
||
| 1229 | 1229 | } else { |
| 1230 | 1230 | $error = socket_strerror(socket_last_error()); |
| 1231 | 1231 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1232 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1232 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 1233 | 1233 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1234 | 1234 | // Restart the script if possible |
| 1235 | 1235 | if (is_array($sockets)) { |
| 1236 | 1236 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 1237 | 1237 | |
| 1238 | 1238 | foreach ($sockets as $sock) { |
| 1239 | - @socket_shutdown($sock,2); |
|
| 1239 | + @socket_shutdown($sock, 2); |
|
| 1240 | 1240 | @socket_close($sock); |
| 1241 | 1241 | } |
| 1242 | 1242 | |