@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -$options = getopt('s::',array('source::','server','idsource::')); |
|
| 43 | +$options = getopt('s::', array('source::', 'server', 'idsource::')); |
|
| 44 | 44 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 45 | 45 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 46 | 46 | if (isset($options['s'])) $globalSources[] = array('host' => $options['s']); |
@@ -50,16 +50,16 @@ discard block |
||
| 50 | 50 | else $id_source = 1; |
| 51 | 51 | if (isset($globalServer) && $globalServer) { |
| 52 | 52 | if ($globalDebug) echo "Using Server Mode\n"; |
| 53 | - $SI=new SpotterServer(); |
|
| 54 | -} else $SI=new SpotterImport($Connection->db); |
|
| 53 | + $SI = new SpotterServer(); |
|
| 54 | +} else $SI = new SpotterImport($Connection->db); |
|
| 55 | 55 | //$APRS=new APRS($Connection->db); |
| 56 | -$SBS=new SBS($Connection->db); |
|
| 57 | -$Common=new Common(); |
|
| 56 | +$SBS = new SBS($Connection->db); |
|
| 57 | +$Common = new Common(); |
|
| 58 | 58 | date_default_timezone_set('UTC'); |
| 59 | 59 | //$servertz = system('date +%Z'); |
| 60 | 60 | // signal handler - playing nice with sockets and dump1090 |
| 61 | 61 | if (function_exists('pcntl_fork')) { |
| 62 | - pcntl_signal(SIGINT, function($signo) { |
|
| 62 | + pcntl_signal(SIGINT, function($signo) { |
|
| 63 | 63 | global $sockets; |
| 64 | 64 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 65 | 65 | die("Bye!\n"); |
@@ -87,28 +87,28 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | function connect_all($hosts) { |
| 89 | 89 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 90 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 90 | + global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs; |
|
| 91 | 91 | foreach ($hosts as $id => $value) { |
| 92 | 92 | $host = $value['host']; |
| 93 | 93 | $globalSources[$id]['last_exec'] = 0; |
| 94 | 94 | // Here we check type of source(s) |
| 95 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 96 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 95 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 96 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
| 97 | 97 | //$formats[$id] = 'deltadbtxt'; |
| 98 | 98 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 99 | 99 | //$last_exec['deltadbtxt'] = 0; |
| 100 | 100 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 101 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 101 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 102 | 102 | //$formats[$id] = 'vatsimtxt'; |
| 103 | 103 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 104 | 104 | //$last_exec['vatsimtxt'] = 0; |
| 105 | 105 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 106 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 106 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 107 | 107 | //$formats[$id] = 'aircraftlistjson'; |
| 108 | 108 | $$globalSources[$id]['format'] = 'aircraftlistjson'; |
| 109 | 109 | //$last_exec['aircraftlistjson'] = 0; |
| 110 | 110 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 111 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 111 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
| 112 | 112 | //$formats[$id] = 'radarvirtueljson'; |
| 113 | 113 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 114 | 114 | //$last_exec['radarvirtueljson'] = 0; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 118 | 118 | exit(0); |
| 119 | 119 | } |
| 120 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 120 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 121 | 121 | //$formats[$id] = 'planeupdatefaa'; |
| 122 | 122 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 123 | 123 | //$last_exec['planeupdatefaa'] = 0; |
@@ -126,22 +126,22 @@ discard block |
||
| 126 | 126 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 127 | 127 | exit(0); |
| 128 | 128 | } |
| 129 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 129 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 130 | 130 | //$formats[$id] = 'phpvmacars'; |
| 131 | 131 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 132 | 132 | //$last_exec['phpvmacars'] = 0; |
| 133 | 133 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 134 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 134 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 135 | 135 | //$formats[$id] = 'whazzup'; |
| 136 | 136 | $globalSources[$id]['format'] = 'whazzup'; |
| 137 | 137 | //$last_exec['whazzup'] = 0; |
| 138 | 138 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 139 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 139 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 140 | 140 | //$formats[$id] = 'pirepsjson'; |
| 141 | 141 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 142 | 142 | //$last_exec['pirepsjson'] = 0; |
| 143 | 143 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 144 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 144 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 145 | 145 | //$formats[$id] = 'fr24json'; |
| 146 | 146 | $globalSources[$id]['format'] = 'fr24json'; |
| 147 | 147 | //$last_exec['fr24json'] = 0; |
@@ -151,22 +151,22 @@ discard block |
||
| 151 | 151 | exit(0); |
| 152 | 152 | } |
| 153 | 153 | //} else if (preg_match('/10001/',$host)) { |
| 154 | - } else if (preg_match('/10001/',$host) || $globalSources[$id]['port'] == '10001') { |
|
| 154 | + } else if (preg_match('/10001/', $host) || $globalSources[$id]['port'] == '10001') { |
|
| 155 | 155 | //$formats[$id] = 'tsv'; |
| 156 | 156 | $globalSources[$id]['format'] = 'tsv'; |
| 157 | 157 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 158 | 158 | } |
| 159 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 159 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 160 | 160 | if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 161 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 162 | - $hostport = explode(':',$host); |
|
| 161 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 162 | + $hostport = explode(':', $host); |
|
| 163 | 163 | if (isset($hostport[1])) $port = $hostport[1]; |
| 164 | 164 | else $port = $globalSources[$id]['port']; |
| 165 | - $s = create_socket($host,$port, $errno, $errstr); |
|
| 165 | + $s = create_socket($host, $port, $errno, $errstr); |
|
| 166 | 166 | if ($s) { |
| 167 | 167 | $sockets[$id] = $s; |
| 168 | 168 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 169 | - if (preg_match('/aprs/',$host)) { |
|
| 169 | + if (preg_match('/aprs/', $host)) { |
|
| 170 | 170 | //$formats[$id] = 'aprs'; |
| 171 | 171 | $globalSources[$id]['format'] = 'aprs'; |
| 172 | 172 | //$aprs_connect = 0; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 205 | 205 | else $timeout = 20; |
| 206 | 206 | $errno = ''; |
| 207 | -$errstr=''; |
|
| 207 | +$errstr = ''; |
|
| 208 | 208 | |
| 209 | 209 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 210 | 210 | /* Initiate connections to all the hosts simultaneously */ |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | if ($use_aprs) { |
| 226 | 226 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 227 | - $APRS=new APRS($Connection->db); |
|
| 227 | + $APRS = new APRS($Connection->db); |
|
| 228 | 228 | $aprs_connect = 0; |
| 229 | 229 | $aprs_keep = 240; |
| 230 | 230 | $aprs_last_tx = time(); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | else $aprs_ssid = 'FAM'; |
| 236 | 236 | //else $aprs_ssid = 'PerlEx'; |
| 237 | 237 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 238 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 238 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 239 | 239 | if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
| 240 | 240 | else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
| 241 | 241 | } |
@@ -245,13 +245,13 @@ discard block |
||
| 245 | 245 | sleep(1); |
| 246 | 246 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 247 | 247 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 248 | -$endtime = time()+$globalCronEnd; |
|
| 248 | +$endtime = time() + $globalCronEnd; |
|
| 249 | 249 | $i = 1; |
| 250 | 250 | $tt = 0; |
| 251 | 251 | |
| 252 | 252 | // Delete all ATC |
| 253 | 253 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 254 | - $ATC=new ATC($Connection->db); |
|
| 254 | + $ATC = new ATC($Connection->db); |
|
| 255 | 255 | } |
| 256 | 256 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 257 | 257 | $ATC->deleteAll(); |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 261 | 261 | while ($i > 0) { |
| 262 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 262 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 263 | 263 | // Delete old ATC |
| 264 | 264 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 265 | 265 | $ATC->deleteOldATC(); |
@@ -270,8 +270,8 @@ discard block |
||
| 270 | 270 | if ($value['format'] == 'deltadbtxt' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 271 | 271 | //$buffer = $Common->getData($hosts[$id]); |
| 272 | 272 | $buffer = $Common->getData($value['host']); |
| 273 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 274 | - $buffer = explode('\n',$buffer); |
|
| 273 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 274 | + $buffer = explode('\n', $buffer); |
|
| 275 | 275 | foreach ($buffer as $line) { |
| 276 | 276 | if ($line != '') { |
| 277 | 277 | $line = explode(',', $line); |
@@ -300,8 +300,8 @@ discard block |
||
| 300 | 300 | } elseif (($value['format'] == 'whazzup' && (time() - $value['last_exec'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value['last_exec'] > $globalMinFetch))) { |
| 301 | 301 | //$buffer = $Common->getData($hosts[$id]); |
| 302 | 302 | $buffer = $Common->getData($value['host']); |
| 303 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 304 | - $buffer = explode('\n',$buffer); |
|
| 303 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 304 | + $buffer = explode('\n', $buffer); |
|
| 305 | 305 | foreach ($buffer as $line) { |
| 306 | 306 | if ($line != '') { |
| 307 | 307 | $line = explode(':', $line); |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | $data['id'] = $line[1].'-'.$line[0]; |
| 311 | 311 | $data['pilot_id'] = $line[1]; |
| 312 | 312 | $data['pilot_name'] = $line[2]; |
| 313 | - $data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT); |
|
| 313 | + $data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT); |
|
| 314 | 314 | $data['ident'] = $line[0]; // ident |
| 315 | 315 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 316 | 316 | $data['speed'] = $line[8]; // speed |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 326 | 326 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 327 | 327 | $data['departure_airport_icao'] = $line[11]; |
| 328 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 328 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 329 | 329 | $data['arrival_airport_icao'] = $line[13]; |
| 330 | 330 | $data['frequency'] = $line[4]; |
| 331 | 331 | $data['type'] = $line[18]; |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $data['id_source'] = $id_source; |
| 335 | 335 | //$data['arrival_airport_time'] = ; |
| 336 | 336 | if ($line[9] != '') { |
| 337 | - $aircraft_data = explode('/',$line[9]); |
|
| 337 | + $aircraft_data = explode('/', $line[9]); |
|
| 338 | 338 | if (isset($aircraft_data[1])) { |
| 339 | 339 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 340 | 340 | } |
@@ -348,9 +348,9 @@ discard block |
||
| 348 | 348 | if ($line[3] == 'PILOT') $SI->add($data); |
| 349 | 349 | elseif ($line[3] == 'ATC') { |
| 350 | 350 | //print_r($data); |
| 351 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 352 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 353 | - $typec = substr($data['ident'],-3); |
|
| 351 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 352 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 353 | + $typec = substr($data['ident'], -3); |
|
| 354 | 354 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 355 | 355 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
| 356 | 356 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 362 | 362 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
| 363 | 363 | |
| 364 | - 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']); |
|
| 364 | + 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']); |
|
| 365 | 365 | } |
| 366 | 366 | unset($data); |
| 367 | 367 | } |
@@ -372,9 +372,9 @@ discard block |
||
| 372 | 372 | $value['last_exec'] = time(); |
| 373 | 373 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
| 374 | 374 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 375 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 375 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 376 | 376 | if ($buffer != '') { |
| 377 | - $all_data = json_decode($buffer,true); |
|
| 377 | + $all_data = json_decode($buffer, true); |
|
| 378 | 378 | if (isset($all_data['acList'])) { |
| 379 | 379 | foreach ($all_data['acList'] as $line) { |
| 380 | 380 | $data = array(); |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
| 429 | 429 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 430 | 430 | $buffer = $Common->getData($value['host']); |
| 431 | - $all_data = json_decode($buffer,true); |
|
| 431 | + $all_data = json_decode($buffer, true); |
|
| 432 | 432 | if (isset($all_data['planes'])) { |
| 433 | 433 | foreach ($all_data['planes'] as $key => $line) { |
| 434 | 434 | $data = array(); |
@@ -444,12 +444,12 @@ discard block |
||
| 444 | 444 | $data['emergency'] = ''; // emergency |
| 445 | 445 | $data['registration'] = $line[2]; |
| 446 | 446 | $data['aircraft_icao'] = $line[0]; |
| 447 | - $deparr = explode('-',$line[1]); |
|
| 447 | + $deparr = explode('-', $line[1]); |
|
| 448 | 448 | if (count($deparr) == 2) { |
| 449 | 449 | $data['departure_airport_icao'] = $deparr[0]; |
| 450 | 450 | $data['arrival_airport_icao'] = $deparr[1]; |
| 451 | 451 | } |
| 452 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 452 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 453 | 453 | $data['format_source'] = 'planeupdatefaa'; |
| 454 | 454 | $data['id_source'] = $id_source; |
| 455 | 455 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } elseif ($value['format'] == 'fr24json' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 464 | 464 | //$buffer = $Common->getData($hosts[$id]); |
| 465 | 465 | $buffer = $Common->getData($value['host']); |
| 466 | - $all_data = json_decode($buffer,true); |
|
| 466 | + $all_data = json_decode($buffer, true); |
|
| 467 | 467 | foreach ($all_data as $key => $line) { |
| 468 | 468 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 469 | 469 | $data = array(); |
@@ -494,11 +494,11 @@ discard block |
||
| 494 | 494 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 495 | 495 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 496 | 496 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 497 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 497 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 498 | 498 | //echo $buffer; |
| 499 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 500 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 501 | - $all_data = json_decode($buffer,true); |
|
| 499 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 500 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 501 | + $all_data = json_decode($buffer, true); |
|
| 502 | 502 | if (json_last_error() != JSON_ERROR_NONE) { |
| 503 | 503 | die(json_last_error_msg()); |
| 504 | 504 | } |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | //$data['departure_airport_iata'] = $line[11]; |
| 521 | 521 | //$data['arrival_airport_iata'] = $line[12]; |
| 522 | 522 | //$data['emergency'] = ''; // emergency |
| 523 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 523 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 524 | 524 | $data['format_source'] = 'radarvirtueljson'; |
| 525 | 525 | $data['id_source'] = $id_source; |
| 526 | 526 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -535,12 +535,12 @@ discard block |
||
| 535 | 535 | } elseif ($value['format'] == 'pirepsjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 536 | 536 | //$buffer = $Common->getData($hosts[$id]); |
| 537 | 537 | $buffer = $Common->getData($value['host']); |
| 538 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 538 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 539 | 539 | |
| 540 | 540 | if (isset($all_data['pireps'])) { |
| 541 | 541 | foreach ($all_data['pireps'] as $line) { |
| 542 | 542 | $data = array(); |
| 543 | - $data['hex'] = str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT); |
|
| 543 | + $data['hex'] = str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT); |
|
| 544 | 544 | $data['ident'] = $line['callsign']; // ident |
| 545 | 545 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 546 | 546 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -569,9 +569,9 @@ discard block |
||
| 569 | 569 | $SI->add($data); |
| 570 | 570 | // print_r($data); |
| 571 | 571 | } elseif ($line['icon'] == 'ct') { |
| 572 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 573 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 574 | - $typec = substr($data['ident'],-3); |
|
| 572 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 573 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 574 | + $typec = substr($data['ident'], -3); |
|
| 575 | 575 | $data['type'] = ''; |
| 576 | 576 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 577 | 577 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
| 583 | 583 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 584 | 584 | else $data['type'] = 'Observer'; |
| 585 | - echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
|
| 585 | + echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name']); |
|
| 586 | 586 | } |
| 587 | 587 | unset($data); |
| 588 | 588 | } |
@@ -593,12 +593,12 @@ discard block |
||
| 593 | 593 | } elseif ($value['format'] == 'phpvmacars' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 594 | 594 | //$buffer = $Common->getData($hosts[$id]); |
| 595 | 595 | $buffer = $Common->getData($value['host']); |
| 596 | - $all_data = json_decode($buffer,true); |
|
| 596 | + $all_data = json_decode($buffer, true); |
|
| 597 | 597 | if ($buffer != '' && is_array($all_data)) { |
| 598 | 598 | foreach ($all_data as $line) { |
| 599 | 599 | $data = array(); |
| 600 | 600 | //$data['id'] = $line['id']; // id not usable |
| 601 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 601 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 602 | 602 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 603 | 603 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 604 | 604 | $data['ident'] = $line['flightnum']; // ident |
@@ -620,12 +620,12 @@ discard block |
||
| 620 | 620 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 621 | 621 | if (isset($line['aircraftname'])) { |
| 622 | 622 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 623 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 624 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 623 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 624 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 625 | 625 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
| 626 | 626 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
| 627 | 627 | else { |
| 628 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 628 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 629 | 629 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
| 630 | 630 | else $data['aircraft_icao'] = $line['aircraftname']; |
| 631 | 631 | } |
@@ -654,14 +654,14 @@ discard block |
||
| 654 | 654 | foreach ($read as $nb => $r) { |
| 655 | 655 | //$value = $formats[$nb]; |
| 656 | 656 | $format = $globalSources[$nb]['format']; |
| 657 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 657 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 658 | 658 | //echo $buffer."\n"; |
| 659 | 659 | // lets play nice and handle signals such as ctrl-c/kill properly |
| 660 | 660 | //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
| 661 | 661 | $dataFound = false; |
| 662 | 662 | $error = false; |
| 663 | 663 | //$SI::del(); |
| 664 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 664 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 665 | 665 | // SBS format is CSV format |
| 666 | 666 | if ($buffer != '') { |
| 667 | 667 | $tt = 0; |
@@ -678,16 +678,16 @@ discard block |
||
| 678 | 678 | } elseif ($format == 'beast') { |
| 679 | 679 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 680 | 680 | die; |
| 681 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
| 681 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
| 682 | 682 | $line = explode("\t", $buffer); |
| 683 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 683 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 684 | 684 | $key = $line[$k]; |
| 685 | - $lined[$key] = $line[$k+1]; |
|
| 685 | + $lined[$key] = $line[$k + 1]; |
|
| 686 | 686 | } |
| 687 | 687 | if (count($lined) > 3) { |
| 688 | 688 | $data['hex'] = $lined['hexid']; |
| 689 | 689 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 690 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 690 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 691 | 691 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 692 | 692 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 693 | 693 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -705,22 +705,22 @@ discard block |
||
| 705 | 705 | } else $error = true; |
| 706 | 706 | } elseif ($format == 'aprs' && $use_aprs) { |
| 707 | 707 | if ($aprs_connect == 0) { |
| 708 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 708 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 709 | 709 | $aprs_connect = 1; |
| 710 | 710 | } |
| 711 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 711 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 712 | 712 | $aprs_last_tx = time(); |
| 713 | 713 | $data_aprs = "# Keep alive"; |
| 714 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 714 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 715 | 715 | } |
| 716 | 716 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 717 | - if (substr($buffer,0,1) != '#') { |
|
| 717 | + if (substr($buffer, 0, 1) != '#') { |
|
| 718 | 718 | $line = $APRS->parse($buffer); |
| 719 | 719 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 720 | 720 | $data = array(); |
| 721 | 721 | //print_r($line); |
| 722 | 722 | $data['hex'] = $line['address']; |
| 723 | - $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 723 | + $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 724 | 724 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 725 | 725 | $data['ident'] = $line['ident']; |
| 726 | 726 | $data['latitude'] = $line['latitude']; |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | $currentdate = date('Y-m-d H:i:s'); |
| 741 | 741 | $aprsdate = strtotime($data['datetime']); |
| 742 | 742 | // Accept data if time <= system time + 20s |
| 743 | - if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20)) $send = $SI->add($data); |
|
| 743 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20)) $send = $SI->add($data); |
|
| 744 | 744 | else { |
| 745 | 745 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 746 | 746 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | } |
| 814 | 814 | } else { |
| 815 | 815 | $error = socket_strerror(socket_last_error()); |
| 816 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 816 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 817 | 817 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) { |
| 818 | 818 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 819 | 819 | // Restart the script if possible |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 822 | 822 | |
| 823 | 823 | foreach ($sockets as $sock) { |
| 824 | - @socket_shutdown($sock,2); |
|
| 824 | + @socket_shutdown($sock, 2); |
|
| 825 | 825 | @socket_close($sock); |
| 826 | 826 | } |
| 827 | 827 | |