@@ -19,47 +19,47 @@ discard block |
||
| 19 | 19 | // Check if schema is at latest version |
| 20 | 20 | $Connection = new Connection(); |
| 21 | 21 | if ($Connection->latest() === false) { |
| 22 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 23 | - exit(); |
|
| 22 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 23 | + exit(); |
|
| 24 | 24 | } |
| 25 | 25 | if (PHP_SAPI != 'cli') { |
| 26 | - echo "This script MUST be called from console, not a web browser."; |
|
| 26 | + echo "This script MUST be called from console, not a web browser."; |
|
| 27 | 27 | // exit(); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // This is to be compatible with old version of settings.php |
| 31 | 31 | if (!isset($globalSources)) { |
| 32 | - if (isset($globalSBS1Hosts)) { |
|
| 33 | - //$hosts = $globalSBS1Hosts; |
|
| 34 | - foreach ($globalSBS1Hosts as $host) { |
|
| 35 | - $globalSources[] = array('host' => $host); |
|
| 36 | - } |
|
| 37 | - } else { |
|
| 38 | - if (!isset($globalSBS1Host)) { |
|
| 39 | - echo '$globalSources MUST be defined !'; |
|
| 40 | - die; |
|
| 32 | + if (isset($globalSBS1Hosts)) { |
|
| 33 | + //$hosts = $globalSBS1Hosts; |
|
| 34 | + foreach ($globalSBS1Hosts as $host) { |
|
| 35 | + $globalSources[] = array('host' => $host); |
|
| 36 | + } |
|
| 37 | + } else { |
|
| 38 | + if (!isset($globalSBS1Host)) { |
|
| 39 | + echo '$globalSources MUST be defined !'; |
|
| 40 | + die; |
|
| 41 | 41 | } |
| 42 | 42 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 43 | 43 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $options = getopt('s::',array('source::','server','idsource::')); |
| 48 | 48 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 49 | 49 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 50 | 50 | if (isset($options['s'])) { |
| 51 | - $globalSources = array(); |
|
| 52 | - $globalSources[] = array('host' => $options['s']); |
|
| 51 | + $globalSources = array(); |
|
| 52 | + $globalSources[] = array('host' => $options['s']); |
|
| 53 | 53 | } elseif (isset($options['source'])) { |
| 54 | - $globalSources = array(); |
|
| 55 | - $globalSources[] = array('host' => $options['source']); |
|
| 54 | + $globalSources = array(); |
|
| 55 | + $globalSources[] = array('host' => $options['source']); |
|
| 56 | 56 | } |
| 57 | 57 | if (isset($options['server'])) $globalServer = TRUE; |
| 58 | 58 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 59 | 59 | else $id_source = 1; |
| 60 | 60 | if (isset($globalServer) && $globalServer) { |
| 61 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 62 | - $SI=new SpotterServer(); |
|
| 61 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 62 | + $SI=new SpotterServer(); |
|
| 63 | 63 | } else $SI=new SpotterImport($Connection->db); |
| 64 | 64 | //$APRS=new APRS($Connection->db); |
| 65 | 65 | $SBS=new SBS(); |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | //$servertz = system('date +%Z'); |
| 70 | 70 | // signal handler - playing nice with sockets and dump1090 |
| 71 | 71 | if (function_exists('pcntl_fork')) { |
| 72 | - pcntl_signal(SIGINT, function() { |
|
| 73 | - global $sockets; |
|
| 74 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 75 | - die("Bye!\n"); |
|
| 76 | - }); |
|
| 77 | - pcntl_signal_dispatch(); |
|
| 72 | + pcntl_signal(SIGINT, function() { |
|
| 73 | + global $sockets; |
|
| 74 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 75 | + die("Bye!\n"); |
|
| 76 | + }); |
|
| 77 | + pcntl_signal_dispatch(); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // let's try and connect |
@@ -84,162 +84,162 @@ discard block |
||
| 84 | 84 | $reset = 0; |
| 85 | 85 | |
| 86 | 86 | function create_socket($host, $port, &$errno, &$errstr) { |
| 87 | - $ip = gethostbyname($host); |
|
| 88 | - $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 89 | - $r = @socket_connect($s, $ip, $port); |
|
| 90 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 91 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 92 | - return $s; |
|
| 93 | - } |
|
| 94 | - $errno = socket_last_error($s); |
|
| 95 | - $errstr = socket_strerror($errno); |
|
| 96 | - socket_close($s); |
|
| 97 | - return false; |
|
| 87 | + $ip = gethostbyname($host); |
|
| 88 | + $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 89 | + $r = @socket_connect($s, $ip, $port); |
|
| 90 | + if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 91 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 92 | + return $s; |
|
| 93 | + } |
|
| 94 | + $errno = socket_last_error($s); |
|
| 95 | + $errstr = socket_strerror($errno); |
|
| 96 | + socket_close($s); |
|
| 97 | + return false; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | function create_socket_udp($host, $port, &$errno, &$errstr) { |
| 101 | - echo "UDP !!"; |
|
| 102 | - $ip = gethostbyname($host); |
|
| 103 | - $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
| 104 | - $r = @socket_bind($s, $ip, $port); |
|
| 105 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 106 | - return $s; |
|
| 107 | - } |
|
| 108 | - $errno = socket_last_error($s); |
|
| 109 | - $errstr = socket_strerror($errno); |
|
| 110 | - socket_close($s); |
|
| 111 | - return false; |
|
| 101 | + echo "UDP !!"; |
|
| 102 | + $ip = gethostbyname($host); |
|
| 103 | + $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
| 104 | + $r = @socket_bind($s, $ip, $port); |
|
| 105 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 106 | + return $s; |
|
| 107 | + } |
|
| 108 | + $errno = socket_last_error($s); |
|
| 109 | + $errstr = socket_strerror($errno); |
|
| 110 | + socket_close($s); |
|
| 111 | + return false; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | function connect_all($hosts) { |
| 115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 117 | - $reset++; |
|
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | - foreach ($hosts as $id => $value) { |
|
| 115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | + global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 117 | + $reset++; |
|
| 118 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | + foreach ($hosts as $id => $value) { |
|
| 120 | 120 | $host = $value['host']; |
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; |
| 122 | 122 | // Here we check type of source(s) |
| 123 | 123 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | - //$formats[$id] = 'deltadbtxt'; |
|
| 126 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | - //$last_exec['deltadbtxt'] = 0; |
|
| 128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | - //$formats[$id] = 'vatsimtxt'; |
|
| 131 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | - //$last_exec['vatsimtxt'] = 0; |
|
| 133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 145 | - //$formats[$id] = 'radarvirtueljson'; |
|
| 146 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 147 | - //$last_exec['radarvirtueljson'] = 0; |
|
| 148 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 149 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 150 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 151 | - exit(0); |
|
| 152 | - } |
|
| 153 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 154 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 155 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 156 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 157 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 158 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 159 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 160 | - exit(0); |
|
| 161 | - } |
|
| 162 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 163 | - //$formats[$id] = 'phpvmacars'; |
|
| 164 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 165 | - //$last_exec['phpvmacars'] = 0; |
|
| 166 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 167 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 168 | - //$formats[$id] = 'phpvmacars'; |
|
| 169 | - $globalSources[$id]['format'] = 'vam'; |
|
| 170 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 171 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 172 | - //$formats[$id] = 'whazzup'; |
|
| 173 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 174 | - //$last_exec['whazzup'] = 0; |
|
| 175 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 176 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 177 | - //$formats[$id] = 'pirepsjson'; |
|
| 178 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 179 | - //$last_exec['pirepsjson'] = 0; |
|
| 180 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 181 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 182 | - //$formats[$id] = 'fr24json'; |
|
| 183 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 184 | - //$last_exec['fr24json'] = 0; |
|
| 185 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 186 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 187 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 188 | - exit(0); |
|
| 189 | - } |
|
| 190 | - //} else if (preg_match('/10001/',$host)) { |
|
| 191 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 192 | - //$formats[$id] = 'tsv'; |
|
| 193 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 194 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 195 | - } |
|
| 196 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 197 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 198 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 199 | - $hostport = explode(':',$host); |
|
| 200 | - if (isset($hostport[1])) { |
|
| 124 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | + //$formats[$id] = 'deltadbtxt'; |
|
| 126 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | + //$last_exec['deltadbtxt'] = 0; |
|
| 128 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | + //$formats[$id] = 'vatsimtxt'; |
|
| 131 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | + //$last_exec['vatsimtxt'] = 0; |
|
| 133 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 145 | + //$formats[$id] = 'radarvirtueljson'; |
|
| 146 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 147 | + //$last_exec['radarvirtueljson'] = 0; |
|
| 148 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 149 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 150 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 151 | + exit(0); |
|
| 152 | + } |
|
| 153 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 154 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 155 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 156 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 157 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 158 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 159 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 160 | + exit(0); |
|
| 161 | + } |
|
| 162 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 163 | + //$formats[$id] = 'phpvmacars'; |
|
| 164 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 165 | + //$last_exec['phpvmacars'] = 0; |
|
| 166 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 167 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 168 | + //$formats[$id] = 'phpvmacars'; |
|
| 169 | + $globalSources[$id]['format'] = 'vam'; |
|
| 170 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 171 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 172 | + //$formats[$id] = 'whazzup'; |
|
| 173 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 174 | + //$last_exec['whazzup'] = 0; |
|
| 175 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 176 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 177 | + //$formats[$id] = 'pirepsjson'; |
|
| 178 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 179 | + //$last_exec['pirepsjson'] = 0; |
|
| 180 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 181 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 182 | + //$formats[$id] = 'fr24json'; |
|
| 183 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 184 | + //$last_exec['fr24json'] = 0; |
|
| 185 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 186 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 187 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 188 | + exit(0); |
|
| 189 | + } |
|
| 190 | + //} else if (preg_match('/10001/',$host)) { |
|
| 191 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 192 | + //$formats[$id] = 'tsv'; |
|
| 193 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 194 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 195 | + } |
|
| 196 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 197 | + if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 198 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 199 | + $hostport = explode(':',$host); |
|
| 200 | + if (isset($hostport[1])) { |
|
| 201 | 201 | $port = $hostport[1]; |
| 202 | 202 | $hostn = $hostport[0]; |
| 203 | - } else { |
|
| 203 | + } else { |
|
| 204 | 204 | $port = $globalSources[$id]['port']; |
| 205 | 205 | $hostn = $globalSources[$id]['host']; |
| 206 | - } |
|
| 207 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 208 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 209 | - } else { |
|
| 210 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 211 | - } |
|
| 212 | - if ($s) { |
|
| 213 | - $sockets[$id] = $s; |
|
| 214 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 215 | - if (preg_match('/aprs/',$hostn)) { |
|
| 206 | + } |
|
| 207 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 208 | + $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 209 | + } else { |
|
| 210 | + $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 211 | + } |
|
| 212 | + if ($s) { |
|
| 213 | + $sockets[$id] = $s; |
|
| 214 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 215 | + if (preg_match('/aprs/',$hostn)) { |
|
| 216 | 216 | //$formats[$id] = 'aprs'; |
| 217 | 217 | $globalSources[$id]['format'] = 'aprs'; |
| 218 | 218 | //$aprs_connect = 0; |
| 219 | 219 | //$use_aprs = true; |
| 220 | - } elseif ($port == '10001') { |
|
| 221 | - //$formats[$id] = 'tsv'; |
|
| 222 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 223 | - } elseif ($port == '30002') { |
|
| 224 | - //$formats[$id] = 'raw'; |
|
| 225 | - $globalSources[$id]['format'] = 'raw'; |
|
| 226 | - } elseif ($port == '5001') { |
|
| 227 | - //$formats[$id] = 'raw'; |
|
| 228 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 229 | - } elseif ($port == '30005') { |
|
| 220 | + } elseif ($port == '10001') { |
|
| 221 | + //$formats[$id] = 'tsv'; |
|
| 222 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 223 | + } elseif ($port == '30002') { |
|
| 224 | + //$formats[$id] = 'raw'; |
|
| 225 | + $globalSources[$id]['format'] = 'raw'; |
|
| 226 | + } elseif ($port == '5001') { |
|
| 227 | + //$formats[$id] = 'raw'; |
|
| 228 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 229 | + } elseif ($port == '30005') { |
|
| 230 | 230 | // Not yet supported |
| 231 | - //$formats[$id] = 'beast'; |
|
| 232 | - $globalSources[$id]['format'] = 'beast'; |
|
| 233 | - //} else $formats[$id] = 'sbs'; |
|
| 234 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 235 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 231 | + //$formats[$id] = 'beast'; |
|
| 232 | + $globalSources[$id]['format'] = 'beast'; |
|
| 233 | + //} else $formats[$id] = 'sbs'; |
|
| 234 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 235 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 236 | 236 | } |
| 237 | 237 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 238 | - } else { |
|
| 238 | + } else { |
|
| 239 | 239 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 240 | - } |
|
| 241 | - } |
|
| 242 | - } |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | 243 | } |
| 244 | 244 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 245 | 245 | |
@@ -266,18 +266,18 @@ discard block |
||
| 266 | 266 | die; |
| 267 | 267 | } |
| 268 | 268 | foreach ($globalSources as $key => $source) { |
| 269 | - if (!isset($source['format'])) { |
|
| 270 | - $globalSources[$key]['format'] = 'auto'; |
|
| 271 | - } |
|
| 269 | + if (!isset($source['format'])) { |
|
| 270 | + $globalSources[$key]['format'] = 'auto'; |
|
| 271 | + } |
|
| 272 | 272 | } |
| 273 | 273 | connect_all($globalSources); |
| 274 | 274 | foreach ($globalSources as $key => $source) { |
| 275 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 275 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 276 | 276 | $aprs_connect = 0; |
| 277 | 277 | $use_aprs = true; |
| 278 | 278 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 279 | 279 | break; |
| 280 | - } |
|
| 280 | + } |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | if ($use_aprs) { |
@@ -317,69 +317,69 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 319 | 319 | while ($i > 0) { |
| 320 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 321 | - // Delete old ATC |
|
| 322 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 320 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 321 | + // Delete old ATC |
|
| 322 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 323 | 323 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 324 | - $ATC->deleteOldATC(); |
|
| 325 | - } |
|
| 324 | + $ATC->deleteOldATC(); |
|
| 325 | + } |
|
| 326 | 326 | |
| 327 | - if (count($last_exec) > 0) { |
|
| 327 | + if (count($last_exec) > 0) { |
|
| 328 | 328 | $max = $globalMinFetch; |
| 329 | 329 | foreach ($last_exec as $last) { |
| 330 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 330 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 331 | 331 | } |
| 332 | 332 | if ($max != $globalMinFetch) { |
| 333 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 334 | - sleep($globalMinFetch-$max+2); |
|
| 333 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 334 | + sleep($globalMinFetch-$max+2); |
|
| 335 | + } |
|
| 335 | 336 | } |
| 336 | - } |
|
| 337 | 337 | |
| 338 | 338 | |
| 339 | - //foreach ($formats as $id => $value) { |
|
| 340 | - foreach ($globalSources as $id => $value) { |
|
| 339 | + //foreach ($formats as $id => $value) { |
|
| 340 | + foreach ($globalSources as $id => $value) { |
|
| 341 | 341 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 342 | 342 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 343 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 344 | - $buffer = $Common->getData($value['host']); |
|
| 345 | - if ($buffer != '') $reset = 0; |
|
| 346 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 347 | - $buffer = explode('\n',$buffer); |
|
| 348 | - foreach ($buffer as $line) { |
|
| 349 | - if ($line != '' && count($line) > 7) { |
|
| 350 | - $line = explode(',', $line); |
|
| 351 | - $data = array(); |
|
| 352 | - $data['hex'] = $line[1]; // hex |
|
| 353 | - $data['ident'] = $line[2]; // ident |
|
| 354 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 355 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 356 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 357 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 358 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 359 | - $data['verticalrate'] = ''; // vertical rate |
|
| 360 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 361 | - $data['emergency'] = ''; // emergency |
|
| 362 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 363 | - $data['format_source'] = 'deltadbtxt'; |
|
| 364 | - $data['id_source'] = $id_source; |
|
| 365 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 366 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 367 | - $SI->add($data); |
|
| 368 | - unset($data); |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - $last_exec[$id]['last'] = time(); |
|
| 343 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 344 | + $buffer = $Common->getData($value['host']); |
|
| 345 | + if ($buffer != '') $reset = 0; |
|
| 346 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 347 | + $buffer = explode('\n',$buffer); |
|
| 348 | + foreach ($buffer as $line) { |
|
| 349 | + if ($line != '' && count($line) > 7) { |
|
| 350 | + $line = explode(',', $line); |
|
| 351 | + $data = array(); |
|
| 352 | + $data['hex'] = $line[1]; // hex |
|
| 353 | + $data['ident'] = $line[2]; // ident |
|
| 354 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 355 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 356 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 357 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 358 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 359 | + $data['verticalrate'] = ''; // vertical rate |
|
| 360 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 361 | + $data['emergency'] = ''; // emergency |
|
| 362 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 363 | + $data['format_source'] = 'deltadbtxt'; |
|
| 364 | + $data['id_source'] = $id_source; |
|
| 365 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 366 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 367 | + $SI->add($data); |
|
| 368 | + unset($data); |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + $last_exec[$id]['last'] = time(); |
|
| 372 | 372 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 373 | 373 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 374 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 375 | - $buffer = $Common->getData($value['host']); |
|
| 376 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 377 | - $buffer = explode('\n',$buffer); |
|
| 378 | - $reset = 0; |
|
| 379 | - foreach ($buffer as $line) { |
|
| 380 | - if ($line != '') { |
|
| 381 | - $line = explode(':', $line); |
|
| 382 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 374 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 375 | + $buffer = $Common->getData($value['host']); |
|
| 376 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 377 | + $buffer = explode('\n',$buffer); |
|
| 378 | + $reset = 0; |
|
| 379 | + foreach ($buffer as $line) { |
|
| 380 | + if ($line != '') { |
|
| 381 | + $line = explode(':', $line); |
|
| 382 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 383 | 383 | $data = array(); |
| 384 | 384 | $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 385 | 385 | $data['pilot_id'] = $line[1]; |
@@ -391,36 +391,36 @@ discard block |
||
| 391 | 391 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 392 | 392 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 393 | 393 | $data['latitude'] = $line[5]; // lat |
| 394 | - $data['longitude'] = $line[6]; // long |
|
| 395 | - $data['verticalrate'] = ''; // vertical rate |
|
| 396 | - $data['squawk'] = ''; // squawk |
|
| 397 | - $data['emergency'] = ''; // emergency |
|
| 398 | - $data['waypoints'] = $line[30]; |
|
| 394 | + $data['longitude'] = $line[6]; // long |
|
| 395 | + $data['verticalrate'] = ''; // vertical rate |
|
| 396 | + $data['squawk'] = ''; // squawk |
|
| 397 | + $data['emergency'] = ''; // emergency |
|
| 398 | + $data['waypoints'] = $line[30]; |
|
| 399 | 399 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 400 | 400 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 401 | 401 | if (isset($line[37])) $data['last_update'] = $line[37]; |
| 402 | - $data['departure_airport_icao'] = $line[11]; |
|
| 403 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 404 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 402 | + $data['departure_airport_icao'] = $line[11]; |
|
| 403 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 404 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 405 | 405 | $data['frequency'] = $line[4]; |
| 406 | 406 | $data['type'] = $line[18]; |
| 407 | 407 | $data['range'] = $line[19]; |
| 408 | 408 | if (isset($line[35])) $data['info'] = $line[35]; |
| 409 | - $data['id_source'] = $id_source; |
|
| 410 | - //$data['arrival_airport_time'] = ; |
|
| 411 | - if ($line[9] != '') { |
|
| 412 | - $aircraft_data = explode('/',$line[9]); |
|
| 413 | - if (isset($aircraft_data[1])) { |
|
| 414 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 415 | - } |
|
| 416 | - } |
|
| 417 | - /* |
|
| 409 | + $data['id_source'] = $id_source; |
|
| 410 | + //$data['arrival_airport_time'] = ; |
|
| 411 | + if ($line[9] != '') { |
|
| 412 | + $aircraft_data = explode('/',$line[9]); |
|
| 413 | + if (isset($aircraft_data[1])) { |
|
| 414 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | + /* |
|
| 418 | 418 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 419 | 419 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 420 | 420 | */ |
| 421 | - $data['format_source'] = $value['format']; |
|
| 421 | + $data['format_source'] = $value['format']; |
|
| 422 | 422 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 423 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 423 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 424 | 424 | elseif ($line[3] == 'ATC') { |
| 425 | 425 | //print_r($data); |
| 426 | 426 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -438,247 +438,247 @@ discard block |
||
| 438 | 438 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 439 | 439 | 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']); |
| 440 | 440 | } |
| 441 | - unset($data); |
|
| 442 | - } |
|
| 443 | - } |
|
| 444 | - } |
|
| 445 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 446 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 447 | - $last_exec[$id]['last'] = time(); |
|
| 448 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 449 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 450 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 451 | - if ($buffer != '') { |
|
| 452 | - $all_data = json_decode($buffer,true); |
|
| 453 | - if (isset($all_data['acList'])) { |
|
| 441 | + unset($data); |
|
| 442 | + } |
|
| 443 | + } |
|
| 444 | + } |
|
| 445 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 446 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 447 | + $last_exec[$id]['last'] = time(); |
|
| 448 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 449 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 450 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 451 | + if ($buffer != '') { |
|
| 452 | + $all_data = json_decode($buffer,true); |
|
| 453 | + if (isset($all_data['acList'])) { |
|
| 454 | 454 | $reset = 0; |
| 455 | 455 | foreach ($all_data['acList'] as $line) { |
| 456 | - $data = array(); |
|
| 457 | - $data['hex'] = $line['Icao']; // hex |
|
| 458 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 459 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 460 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 461 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 462 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 463 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 464 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
| 465 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 466 | - $data['emergency'] = ''; // emergency |
|
| 467 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 468 | - /* |
|
| 456 | + $data = array(); |
|
| 457 | + $data['hex'] = $line['Icao']; // hex |
|
| 458 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 459 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 460 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 461 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 462 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 463 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 464 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
| 465 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 466 | + $data['emergency'] = ''; // emergency |
|
| 467 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 468 | + /* |
|
| 469 | 469 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 470 | 470 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 471 | 471 | */ |
| 472 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 473 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 474 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 475 | - $data['id_source'] = $id_source; |
|
| 476 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 477 | - if (isset($data['datetime'])) $SI->add($data); |
|
| 478 | - unset($data); |
|
| 472 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 473 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 474 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 475 | + $data['id_source'] = $id_source; |
|
| 476 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 477 | + if (isset($data['datetime'])) $SI->add($data); |
|
| 478 | + unset($data); |
|
| 479 | 479 | } |
| 480 | - } else { |
|
| 480 | + } else { |
|
| 481 | 481 | $reset = 0; |
| 482 | 482 | foreach ($all_data as $line) { |
| 483 | - $data = array(); |
|
| 484 | - $data['hex'] = $line['hex']; // hex |
|
| 485 | - $data['ident'] = $line['flight']; // ident |
|
| 486 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 487 | - $data['speed'] = $line['speed']; // speed |
|
| 488 | - $data['heading'] = $line['track']; // heading |
|
| 489 | - $data['latitude'] = $line['lat']; // lat |
|
| 490 | - $data['longitude'] = $line['lon']; // long |
|
| 491 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 492 | - $data['squawk'] = $line['squawk']; // squawk |
|
| 493 | - $data['emergency'] = ''; // emergency |
|
| 494 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 495 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 496 | - $data['id_source'] = $id_source; |
|
| 497 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 498 | - $SI->add($data); |
|
| 499 | - unset($data); |
|
| 483 | + $data = array(); |
|
| 484 | + $data['hex'] = $line['hex']; // hex |
|
| 485 | + $data['ident'] = $line['flight']; // ident |
|
| 486 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 487 | + $data['speed'] = $line['speed']; // speed |
|
| 488 | + $data['heading'] = $line['track']; // heading |
|
| 489 | + $data['latitude'] = $line['lat']; // lat |
|
| 490 | + $data['longitude'] = $line['lon']; // long |
|
| 491 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 492 | + $data['squawk'] = $line['squawk']; // squawk |
|
| 493 | + $data['emergency'] = ''; // emergency |
|
| 494 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 495 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 496 | + $data['id_source'] = $id_source; |
|
| 497 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 498 | + $SI->add($data); |
|
| 499 | + unset($data); |
|
| 500 | + } |
|
| 500 | 501 | } |
| 501 | - } |
|
| 502 | - } |
|
| 503 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 504 | - $last_exec[$id]['last'] = time(); |
|
| 505 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 506 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 507 | - $buffer = $Common->getData($value['host']); |
|
| 508 | - $all_data = json_decode($buffer,true); |
|
| 509 | - if (isset($all_data['planes'])) { |
|
| 502 | + } |
|
| 503 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 504 | + $last_exec[$id]['last'] = time(); |
|
| 505 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 506 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 507 | + $buffer = $Common->getData($value['host']); |
|
| 508 | + $all_data = json_decode($buffer,true); |
|
| 509 | + if (isset($all_data['planes'])) { |
|
| 510 | 510 | $reset = 0; |
| 511 | 511 | foreach ($all_data['planes'] as $key => $line) { |
| 512 | - $data = array(); |
|
| 513 | - $data['hex'] = $key; // hex |
|
| 514 | - $data['ident'] = $line[3]; // ident |
|
| 515 | - $data['altitude'] = $line[6]; // altitude |
|
| 516 | - $data['speed'] = $line[8]; // speed |
|
| 517 | - $data['heading'] = $line[7]; // heading |
|
| 518 | - $data['latitude'] = $line[4]; // lat |
|
| 519 | - $data['longitude'] = $line[5]; // long |
|
| 520 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 521 | - $data['squawk'] = $line[10]; // squawk |
|
| 522 | - $data['emergency'] = ''; // emergency |
|
| 523 | - $data['registration'] = $line[2]; |
|
| 524 | - $data['aircraft_icao'] = $line[0]; |
|
| 525 | - $deparr = explode('-',$line[1]); |
|
| 526 | - if (count($deparr) == 2) { |
|
| 512 | + $data = array(); |
|
| 513 | + $data['hex'] = $key; // hex |
|
| 514 | + $data['ident'] = $line[3]; // ident |
|
| 515 | + $data['altitude'] = $line[6]; // altitude |
|
| 516 | + $data['speed'] = $line[8]; // speed |
|
| 517 | + $data['heading'] = $line[7]; // heading |
|
| 518 | + $data['latitude'] = $line[4]; // lat |
|
| 519 | + $data['longitude'] = $line[5]; // long |
|
| 520 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 521 | + $data['squawk'] = $line[10]; // squawk |
|
| 522 | + $data['emergency'] = ''; // emergency |
|
| 523 | + $data['registration'] = $line[2]; |
|
| 524 | + $data['aircraft_icao'] = $line[0]; |
|
| 525 | + $deparr = explode('-',$line[1]); |
|
| 526 | + if (count($deparr) == 2) { |
|
| 527 | 527 | $data['departure_airport_icao'] = $deparr[0]; |
| 528 | 528 | $data['arrival_airport_icao'] = $deparr[1]; |
| 529 | - } |
|
| 530 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 531 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 532 | - $data['id_source'] = $id_source; |
|
| 533 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 534 | - $SI->add($data); |
|
| 535 | - unset($data); |
|
| 529 | + } |
|
| 530 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 531 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 532 | + $data['id_source'] = $id_source; |
|
| 533 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 534 | + $SI->add($data); |
|
| 535 | + unset($data); |
|
| 536 | + } |
|
| 536 | 537 | } |
| 537 | - } |
|
| 538 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 539 | - $last_exec[$id]['last'] = time(); |
|
| 540 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 541 | - $buffer = $Common->getData($value['host']); |
|
| 542 | - $all_data = json_decode($buffer,true); |
|
| 543 | - if (isset($all_data['states'])) { |
|
| 538 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 539 | + $last_exec[$id]['last'] = time(); |
|
| 540 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 541 | + $buffer = $Common->getData($value['host']); |
|
| 542 | + $all_data = json_decode($buffer,true); |
|
| 543 | + if (isset($all_data['states'])) { |
|
| 544 | 544 | $reset = 0; |
| 545 | 545 | foreach ($all_data['states'] as $key => $line) { |
| 546 | - $data = array(); |
|
| 547 | - $data['hex'] = $line[0]; // hex |
|
| 548 | - $data['ident'] = trim($line[1]); // ident |
|
| 549 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 550 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 551 | - $data['heading'] = round($line[10]); // heading |
|
| 552 | - $data['latitude'] = $line[5]; // lat |
|
| 553 | - $data['longitude'] = $line[6]; // long |
|
| 554 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 555 | - //$data['squawk'] = $line[10]; // squawk |
|
| 556 | - //$data['emergency'] = ''; // emergency |
|
| 557 | - //$data['registration'] = $line[2]; |
|
| 558 | - //$data['aircraft_icao'] = $line[0]; |
|
| 559 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 560 | - $data['format_source'] = 'opensky'; |
|
| 561 | - $data['id_source'] = $id_source; |
|
| 562 | - $SI->add($data); |
|
| 563 | - unset($data); |
|
| 546 | + $data = array(); |
|
| 547 | + $data['hex'] = $line[0]; // hex |
|
| 548 | + $data['ident'] = trim($line[1]); // ident |
|
| 549 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 550 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 551 | + $data['heading'] = round($line[10]); // heading |
|
| 552 | + $data['latitude'] = $line[5]; // lat |
|
| 553 | + $data['longitude'] = $line[6]; // long |
|
| 554 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 555 | + //$data['squawk'] = $line[10]; // squawk |
|
| 556 | + //$data['emergency'] = ''; // emergency |
|
| 557 | + //$data['registration'] = $line[2]; |
|
| 558 | + //$data['aircraft_icao'] = $line[0]; |
|
| 559 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 560 | + $data['format_source'] = 'opensky'; |
|
| 561 | + $data['id_source'] = $id_source; |
|
| 562 | + $SI->add($data); |
|
| 563 | + unset($data); |
|
| 564 | + } |
|
| 564 | 565 | } |
| 565 | - } |
|
| 566 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 567 | - $last_exec[$id]['last'] = time(); |
|
| 568 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 569 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 570 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 571 | - $buffer = $Common->getData($value['host']); |
|
| 572 | - $all_data = json_decode($buffer,true); |
|
| 573 | - if (!empty($all_data)) $reset = 0; |
|
| 574 | - foreach ($all_data as $key => $line) { |
|
| 566 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 567 | + $last_exec[$id]['last'] = time(); |
|
| 568 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 569 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 570 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 571 | + $buffer = $Common->getData($value['host']); |
|
| 572 | + $all_data = json_decode($buffer,true); |
|
| 573 | + if (!empty($all_data)) $reset = 0; |
|
| 574 | + foreach ($all_data as $key => $line) { |
|
| 575 | 575 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 576 | - $data = array(); |
|
| 577 | - $data['hex'] = $line[0]; |
|
| 578 | - $data['ident'] = $line[16]; //$line[13] |
|
| 579 | - $data['altitude'] = $line[4]; // altitude |
|
| 580 | - $data['speed'] = $line[5]; // speed |
|
| 581 | - $data['heading'] = $line[3]; // heading |
|
| 582 | - $data['latitude'] = $line[1]; // lat |
|
| 583 | - $data['longitude'] = $line[2]; // long |
|
| 584 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 585 | - $data['squawk'] = $line[6]; // squawk |
|
| 586 | - $data['aircraft_icao'] = $line[8]; |
|
| 587 | - $data['registration'] = $line[9]; |
|
| 588 | - $data['departure_airport_iata'] = $line[11]; |
|
| 589 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 590 | - $data['emergency'] = ''; // emergency |
|
| 591 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 592 | - $data['format_source'] = 'fr24json'; |
|
| 593 | - $data['id_source'] = $id_source; |
|
| 594 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 595 | - $SI->add($data); |
|
| 596 | - unset($data); |
|
| 576 | + $data = array(); |
|
| 577 | + $data['hex'] = $line[0]; |
|
| 578 | + $data['ident'] = $line[16]; //$line[13] |
|
| 579 | + $data['altitude'] = $line[4]; // altitude |
|
| 580 | + $data['speed'] = $line[5]; // speed |
|
| 581 | + $data['heading'] = $line[3]; // heading |
|
| 582 | + $data['latitude'] = $line[1]; // lat |
|
| 583 | + $data['longitude'] = $line[2]; // long |
|
| 584 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 585 | + $data['squawk'] = $line[6]; // squawk |
|
| 586 | + $data['aircraft_icao'] = $line[8]; |
|
| 587 | + $data['registration'] = $line[9]; |
|
| 588 | + $data['departure_airport_iata'] = $line[11]; |
|
| 589 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 590 | + $data['emergency'] = ''; // emergency |
|
| 591 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 592 | + $data['format_source'] = 'fr24json'; |
|
| 593 | + $data['id_source'] = $id_source; |
|
| 594 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 595 | + $SI->add($data); |
|
| 596 | + unset($data); |
|
| 597 | + } |
|
| 597 | 598 | } |
| 598 | - } |
|
| 599 | - //$last_exec['fr24json'] = time(); |
|
| 600 | - $last_exec[$id]['last'] = time(); |
|
| 601 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 602 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 603 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 604 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 605 | - //echo $buffer; |
|
| 606 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 607 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 608 | - $all_data = json_decode($buffer,true); |
|
| 609 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 599 | + //$last_exec['fr24json'] = time(); |
|
| 600 | + $last_exec[$id]['last'] = time(); |
|
| 601 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 602 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 603 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 604 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 605 | + //echo $buffer; |
|
| 606 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 607 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 608 | + $all_data = json_decode($buffer,true); |
|
| 609 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 610 | 610 | die(json_last_error_msg()); |
| 611 | - } |
|
| 612 | - if (isset($all_data['mrkrs'])) { |
|
| 611 | + } |
|
| 612 | + if (isset($all_data['mrkrs'])) { |
|
| 613 | 613 | $reset = 0; |
| 614 | 614 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 615 | - if (isset($line['inf'])) { |
|
| 615 | + if (isset($line['inf'])) { |
|
| 616 | 616 | $data = array(); |
| 617 | 617 | $data['hex'] = $line['inf']['ia']; |
| 618 | 618 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 619 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 620 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 621 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 622 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 623 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 624 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 625 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 626 | - //$data['aircraft_icao'] = $line[8]; |
|
| 627 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 619 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 620 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 621 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 622 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 623 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 624 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 625 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 626 | + //$data['aircraft_icao'] = $line[8]; |
|
| 627 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 628 | 628 | //$data['departure_airport_iata'] = $line[11]; |
| 629 | 629 | //$data['arrival_airport_iata'] = $line[12]; |
| 630 | - //$data['emergency'] = ''; // emergency |
|
| 630 | + //$data['emergency'] = ''; // emergency |
|
| 631 | 631 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 632 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 633 | - $data['id_source'] = $id_source; |
|
| 632 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 633 | + $data['id_source'] = $id_source; |
|
| 634 | 634 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 635 | 635 | $SI->add($data); |
| 636 | 636 | unset($data); |
| 637 | - } |
|
| 637 | + } |
|
| 638 | + } |
|
| 638 | 639 | } |
| 639 | - } |
|
| 640 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 641 | - $last_exec[$id]['last'] = time(); |
|
| 642 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 643 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 644 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 645 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 646 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 640 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 641 | + $last_exec[$id]['last'] = time(); |
|
| 642 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 643 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 644 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 645 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 646 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 647 | 647 | |
| 648 | - if (isset($all_data['pireps'])) { |
|
| 648 | + if (isset($all_data['pireps'])) { |
|
| 649 | 649 | $reset = 0; |
| 650 | - foreach ($all_data['pireps'] as $line) { |
|
| 651 | - $data = array(); |
|
| 652 | - $data['id'] = $line['id']; |
|
| 653 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 654 | - $data['ident'] = $line['callsign']; // ident |
|
| 655 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 656 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 657 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 658 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 659 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 660 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 661 | - $data['latitude'] = $line['lat']; // lat |
|
| 662 | - $data['longitude'] = $line['lon']; // long |
|
| 663 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 664 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 665 | - //$data['emergency'] = ''; // emergency |
|
| 666 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 667 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 668 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 669 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 670 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 671 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 672 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 673 | - else $data['info'] = ''; |
|
| 674 | - $data['format_source'] = 'pireps'; |
|
| 675 | - $data['id_source'] = $id_source; |
|
| 676 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 677 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 678 | - if ($line['icon'] == 'plane') { |
|
| 650 | + foreach ($all_data['pireps'] as $line) { |
|
| 651 | + $data = array(); |
|
| 652 | + $data['id'] = $line['id']; |
|
| 653 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 654 | + $data['ident'] = $line['callsign']; // ident |
|
| 655 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 656 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 657 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 658 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 659 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 660 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 661 | + $data['latitude'] = $line['lat']; // lat |
|
| 662 | + $data['longitude'] = $line['lon']; // long |
|
| 663 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 664 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 665 | + //$data['emergency'] = ''; // emergency |
|
| 666 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 667 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 668 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 669 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 670 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 671 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 672 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 673 | + else $data['info'] = ''; |
|
| 674 | + $data['format_source'] = 'pireps'; |
|
| 675 | + $data['id_source'] = $id_source; |
|
| 676 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 677 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 678 | + if ($line['icon'] == 'plane') { |
|
| 679 | 679 | $SI->add($data); |
| 680 | - // print_r($data); |
|
| 681 | - } elseif ($line['icon'] == 'ct') { |
|
| 680 | + // print_r($data); |
|
| 681 | + } elseif ($line['icon'] == 'ct') { |
|
| 682 | 682 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 683 | 683 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 684 | 684 | $typec = substr($data['ident'],-3); |
@@ -693,163 +693,163 @@ discard block |
||
| 693 | 693 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 694 | 694 | else $data['type'] = 'Observer'; |
| 695 | 695 | 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']); |
| 696 | - } |
|
| 697 | - unset($data); |
|
| 696 | + } |
|
| 697 | + unset($data); |
|
| 698 | + } |
|
| 698 | 699 | } |
| 699 | - } |
|
| 700 | - //$last_exec['pirepsjson'] = time(); |
|
| 701 | - $last_exec[$id]['last'] = time(); |
|
| 702 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 703 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 704 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 705 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 706 | - $buffer = $Common->getData($value['host']); |
|
| 707 | - $all_data = json_decode($buffer,true); |
|
| 708 | - if ($buffer != '' && is_array($all_data)) { |
|
| 700 | + //$last_exec['pirepsjson'] = time(); |
|
| 701 | + $last_exec[$id]['last'] = time(); |
|
| 702 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 703 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 704 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 705 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 706 | + $buffer = $Common->getData($value['host']); |
|
| 707 | + $all_data = json_decode($buffer,true); |
|
| 708 | + if ($buffer != '' && is_array($all_data)) { |
|
| 709 | 709 | $reset = 0; |
| 710 | 710 | foreach ($all_data as $line) { |
| 711 | - $data = array(); |
|
| 712 | - //$data['id'] = $line['id']; // id not usable |
|
| 713 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 714 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 715 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 716 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 717 | - $data['ident'] = $line['flightnum']; // ident |
|
| 718 | - $data['altitude'] = $line['alt']; // altitude |
|
| 719 | - $data['speed'] = $line['gs']; // speed |
|
| 720 | - $data['heading'] = $line['heading']; // heading |
|
| 721 | - $data['latitude'] = $line['lat']; // lat |
|
| 722 | - $data['longitude'] = $line['lng']; // long |
|
| 723 | - $data['verticalrate'] = ''; // verticale rate |
|
| 724 | - $data['squawk'] = ''; // squawk |
|
| 725 | - $data['emergency'] = ''; // emergency |
|
| 726 | - //$data['datetime'] = $line['lastupdate']; |
|
| 727 | - $data['last_update'] = $line['lastupdate']; |
|
| 728 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 729 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 730 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 731 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 732 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 733 | - $data['registration'] = $line['aircraft']; |
|
| 734 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 735 | - if (isset($line['aircraftname'])) { |
|
| 711 | + $data = array(); |
|
| 712 | + //$data['id'] = $line['id']; // id not usable |
|
| 713 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 714 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 715 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 716 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 717 | + $data['ident'] = $line['flightnum']; // ident |
|
| 718 | + $data['altitude'] = $line['alt']; // altitude |
|
| 719 | + $data['speed'] = $line['gs']; // speed |
|
| 720 | + $data['heading'] = $line['heading']; // heading |
|
| 721 | + $data['latitude'] = $line['lat']; // lat |
|
| 722 | + $data['longitude'] = $line['lng']; // long |
|
| 723 | + $data['verticalrate'] = ''; // verticale rate |
|
| 724 | + $data['squawk'] = ''; // squawk |
|
| 725 | + $data['emergency'] = ''; // emergency |
|
| 726 | + //$data['datetime'] = $line['lastupdate']; |
|
| 727 | + $data['last_update'] = $line['lastupdate']; |
|
| 728 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 729 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 730 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 731 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 732 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 733 | + $data['registration'] = $line['aircraft']; |
|
| 734 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 735 | + if (isset($line['aircraftname'])) { |
|
| 736 | 736 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 737 | 737 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 738 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 739 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 740 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 741 | - else { |
|
| 742 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 743 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 744 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 745 | - } |
|
| 746 | - } |
|
| 747 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 748 | - $data['id_source'] = $id_source; |
|
| 749 | - $data['format_source'] = 'phpvmacars'; |
|
| 750 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 751 | - $SI->add($data); |
|
| 752 | - unset($data); |
|
| 738 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 739 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 740 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 741 | + else { |
|
| 742 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 743 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 744 | + else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 748 | + $data['id_source'] = $id_source; |
|
| 749 | + $data['format_source'] = 'phpvmacars'; |
|
| 750 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 751 | + $SI->add($data); |
|
| 752 | + unset($data); |
|
| 753 | 753 | } |
| 754 | 754 | if ($globalDebug) echo 'No more data...'."\n"; |
| 755 | 755 | unset($buffer); |
| 756 | 756 | unset($all_data); |
| 757 | - } |
|
| 758 | - //$last_exec['phpvmacars'] = time(); |
|
| 759 | - $last_exec[$id]['last'] = time(); |
|
| 760 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 761 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 762 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 763 | - $buffer = $Common->getData($value['host']); |
|
| 764 | - $all_data = json_decode($buffer,true); |
|
| 765 | - if ($buffer != '' && is_array($all_data)) { |
|
| 757 | + } |
|
| 758 | + //$last_exec['phpvmacars'] = time(); |
|
| 759 | + $last_exec[$id]['last'] = time(); |
|
| 760 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 761 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 762 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 763 | + $buffer = $Common->getData($value['host']); |
|
| 764 | + $all_data = json_decode($buffer,true); |
|
| 765 | + if ($buffer != '' && is_array($all_data)) { |
|
| 766 | 766 | $reset = 0; |
| 767 | 767 | foreach ($all_data as $line) { |
| 768 | - $data = array(); |
|
| 769 | - //$data['id'] = $line['id']; // id not usable |
|
| 770 | - $data['id'] = trim($line['flight_id']); |
|
| 771 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 772 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 773 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 774 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 775 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 776 | - $data['speed'] = $line['gs']; // speed |
|
| 777 | - $data['heading'] = $line['heading']; // heading |
|
| 778 | - $data['latitude'] = $line['latitude']; // lat |
|
| 779 | - $data['longitude'] = $line['longitude']; // long |
|
| 780 | - $data['verticalrate'] = ''; // verticale rate |
|
| 781 | - $data['squawk'] = ''; // squawk |
|
| 782 | - $data['emergency'] = ''; // emergency |
|
| 783 | - //$data['datetime'] = $line['lastupdate']; |
|
| 784 | - $data['last_update'] = $line['last_update']; |
|
| 785 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 786 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 787 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 788 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 789 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 790 | - //$data['registration'] = $line['aircraft']; |
|
| 791 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 792 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 793 | - $data['id_source'] = $id_source; |
|
| 794 | - $data['format_source'] = 'vam'; |
|
| 795 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 796 | - $SI->add($data); |
|
| 797 | - unset($data); |
|
| 768 | + $data = array(); |
|
| 769 | + //$data['id'] = $line['id']; // id not usable |
|
| 770 | + $data['id'] = trim($line['flight_id']); |
|
| 771 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 772 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 773 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 774 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 775 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 776 | + $data['speed'] = $line['gs']; // speed |
|
| 777 | + $data['heading'] = $line['heading']; // heading |
|
| 778 | + $data['latitude'] = $line['latitude']; // lat |
|
| 779 | + $data['longitude'] = $line['longitude']; // long |
|
| 780 | + $data['verticalrate'] = ''; // verticale rate |
|
| 781 | + $data['squawk'] = ''; // squawk |
|
| 782 | + $data['emergency'] = ''; // emergency |
|
| 783 | + //$data['datetime'] = $line['lastupdate']; |
|
| 784 | + $data['last_update'] = $line['last_update']; |
|
| 785 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 786 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 787 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 788 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 789 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 790 | + //$data['registration'] = $line['aircraft']; |
|
| 791 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 792 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 793 | + $data['id_source'] = $id_source; |
|
| 794 | + $data['format_source'] = 'vam'; |
|
| 795 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 796 | + $SI->add($data); |
|
| 797 | + unset($data); |
|
| 798 | 798 | } |
| 799 | 799 | if ($globalDebug) echo 'No more data...'."\n"; |
| 800 | 800 | unset($buffer); |
| 801 | 801 | unset($all_data); |
| 802 | - } |
|
| 803 | - //$last_exec['phpvmacars'] = time(); |
|
| 804 | - $last_exec[$id]['last'] = time(); |
|
| 802 | + } |
|
| 803 | + //$last_exec['phpvmacars'] = time(); |
|
| 804 | + $last_exec[$id]['last'] = time(); |
|
| 805 | 805 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 806 | 806 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') { |
| 807 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 808 | - //$last_exec[$id]['last'] = time(); |
|
| 807 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 808 | + //$last_exec[$id]['last'] = time(); |
|
| 809 | 809 | |
| 810 | - //$read = array( $sockets[$id] ); |
|
| 811 | - $read = $sockets; |
|
| 812 | - $write = NULL; |
|
| 813 | - $e = NULL; |
|
| 814 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 815 | - if ($e != NULL) var_dump($e); |
|
| 816 | - if ($n > 0) { |
|
| 810 | + //$read = array( $sockets[$id] ); |
|
| 811 | + $read = $sockets; |
|
| 812 | + $write = NULL; |
|
| 813 | + $e = NULL; |
|
| 814 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 815 | + if ($e != NULL) var_dump($e); |
|
| 816 | + if ($n > 0) { |
|
| 817 | 817 | $reset = 0; |
| 818 | 818 | foreach ($read as $nb => $r) { |
| 819 | - //$value = $formats[$nb]; |
|
| 820 | - $format = $globalSources[$nb]['format']; |
|
| 821 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 822 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 823 | - } else { |
|
| 824 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 825 | - } |
|
| 826 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 827 | - //echo $buffer."\n"; |
|
| 828 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 829 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 830 | - $error = false; |
|
| 831 | - //$SI::del(); |
|
| 832 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 833 | - // SBS format is CSV format |
|
| 834 | - if ($buffer != '') { |
|
| 819 | + //$value = $formats[$nb]; |
|
| 820 | + $format = $globalSources[$nb]['format']; |
|
| 821 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 822 | + $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 823 | + } else { |
|
| 824 | + $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 825 | + } |
|
| 826 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 827 | + //echo $buffer."\n"; |
|
| 828 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 829 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 830 | + $error = false; |
|
| 831 | + //$SI::del(); |
|
| 832 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 833 | + // SBS format is CSV format |
|
| 834 | + if ($buffer != '') { |
|
| 835 | 835 | $tt[$format] = 0; |
| 836 | 836 | if ($format == 'acarssbs3') { |
| 837 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 838 | - $ACARS->add(trim($buffer)); |
|
| 839 | - $ACARS->deleteLiveAcarsData(); |
|
| 837 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 838 | + $ACARS->add(trim($buffer)); |
|
| 839 | + $ACARS->deleteLiveAcarsData(); |
|
| 840 | 840 | } elseif ($format == 'raw') { |
| 841 | - // AVR format |
|
| 842 | - $data = $SBS->parse($buffer); |
|
| 843 | - if (is_array($data)) { |
|
| 841 | + // AVR format |
|
| 842 | + $data = $SBS->parse($buffer); |
|
| 843 | + if (is_array($data)) { |
|
| 844 | 844 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 845 | 845 | $data['format_source'] = 'raw'; |
| 846 | 846 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 847 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 848 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 849 | - } |
|
| 850 | - } elseif ($format == 'flightgearsp') { |
|
| 851 | - //echo $buffer."\n"; |
|
| 852 | - if (strlen($buffer) > 5) { |
|
| 847 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 848 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 849 | + } |
|
| 850 | + } elseif ($format == 'flightgearsp') { |
|
| 851 | + //echo $buffer."\n"; |
|
| 852 | + if (strlen($buffer) > 5) { |
|
| 853 | 853 | $line = explode(',',$buffer); |
| 854 | 854 | $data = array(); |
| 855 | 855 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -865,114 +865,114 @@ discard block |
||
| 865 | 865 | $data['format_source'] = 'flightgearsp'; |
| 866 | 866 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 867 | 867 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 868 | - } |
|
| 869 | - } elseif ($format == 'acars') { |
|
| 870 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 871 | - $ACARS->add(trim($buffer)); |
|
| 872 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 873 | - $ACARS->deleteLiveAcarsData(); |
|
| 868 | + } |
|
| 869 | + } elseif ($format == 'acars') { |
|
| 870 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 871 | + $ACARS->add(trim($buffer)); |
|
| 872 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 873 | + $ACARS->deleteLiveAcarsData(); |
|
| 874 | 874 | } elseif ($format == 'flightgearmp') { |
| 875 | - if (substr($buffer,0,1) != '#') { |
|
| 875 | + if (substr($buffer,0,1) != '#') { |
|
| 876 | 876 | $data = array(); |
| 877 | 877 | //echo $buffer."\n"; |
| 878 | 878 | $line = explode(' ',$buffer); |
| 879 | 879 | if (count($line) == 11) { |
| 880 | - $userserver = explode('@',$line[0]); |
|
| 881 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 882 | - $data['ident'] = $userserver[0]; |
|
| 883 | - $data['registration'] = $userserver[0]; |
|
| 884 | - $data['latitude'] = $line[4]; |
|
| 885 | - $data['longitude'] = $line[5]; |
|
| 886 | - $data['altitude'] = $line[6]; |
|
| 887 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 888 | - $aircraft_type = $line[10]; |
|
| 889 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 890 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 891 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 880 | + $userserver = explode('@',$line[0]); |
|
| 881 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 882 | + $data['ident'] = $userserver[0]; |
|
| 883 | + $data['registration'] = $userserver[0]; |
|
| 884 | + $data['latitude'] = $line[4]; |
|
| 885 | + $data['longitude'] = $line[5]; |
|
| 886 | + $data['altitude'] = $line[6]; |
|
| 887 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 888 | + $aircraft_type = $line[10]; |
|
| 889 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 890 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 891 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 892 | + } |
|
| 892 | 893 | } |
| 893 | - } |
|
| 894 | 894 | } elseif ($format == 'beast') { |
| 895 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 896 | - die; |
|
| 895 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 896 | + die; |
|
| 897 | 897 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 898 | - $line = explode("\t", $buffer); |
|
| 899 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 898 | + $line = explode("\t", $buffer); |
|
| 899 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 900 | 900 | $key = $line[$k]; |
| 901 | - $lined[$key] = $line[$k+1]; |
|
| 902 | - } |
|
| 903 | - if (count($lined) > 3) { |
|
| 904 | - $data['hex'] = $lined['hexid']; |
|
| 905 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 906 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 907 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 908 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 909 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 910 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 911 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 912 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 913 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 914 | - $data['id_source'] = $id_source; |
|
| 915 | - $data['format_source'] = 'tsv'; |
|
| 916 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 917 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 918 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 919 | - unset($lined); |
|
| 920 | - unset($data); |
|
| 921 | - } else $error = true; |
|
| 901 | + $lined[$key] = $line[$k+1]; |
|
| 902 | + } |
|
| 903 | + if (count($lined) > 3) { |
|
| 904 | + $data['hex'] = $lined['hexid']; |
|
| 905 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 906 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 907 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 908 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 909 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 910 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 911 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 912 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 913 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 914 | + $data['id_source'] = $id_source; |
|
| 915 | + $data['format_source'] = 'tsv'; |
|
| 916 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 917 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 918 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 919 | + unset($lined); |
|
| 920 | + unset($data); |
|
| 921 | + } else $error = true; |
|
| 922 | 922 | } elseif ($format == 'aprs' && $use_aprs) { |
| 923 | - if ($aprs_connect == 0) { |
|
| 923 | + if ($aprs_connect == 0) { |
|
| 924 | 924 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 925 | 925 | $aprs_connect = 1; |
| 926 | - } |
|
| 927 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 926 | + } |
|
| 927 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 928 | 928 | $aprs_last_tx = time(); |
| 929 | 929 | $data_aprs = "# Keep alive"; |
| 930 | 930 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 931 | - } |
|
| 932 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 933 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 934 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 935 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 931 | + } |
|
| 932 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 933 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 934 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 935 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 936 | 936 | $line = $APRS->parse($buffer); |
| 937 | 937 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 938 | - $data = array(); |
|
| 939 | - //print_r($line); |
|
| 940 | - $data['hex'] = $line['address']; |
|
| 941 | - $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 942 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 943 | - $data['ident'] = $line['ident']; |
|
| 944 | - $data['latitude'] = $line['latitude']; |
|
| 945 | - $data['longitude'] = $line['longitude']; |
|
| 946 | - //$data['verticalrate'] = $line[16]; |
|
| 947 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 948 | - else $data['speed'] = 0; |
|
| 949 | - $data['altitude'] = $line['altitude']; |
|
| 950 | - if (isset($line['course'])) $data['heading'] = $line['course']; |
|
| 951 | - //else $data['heading'] = 0; |
|
| 952 | - $data['aircraft_type'] = $line['stealth']; |
|
| 953 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 954 | - $data['id_source'] = $id_source; |
|
| 955 | - $data['format_source'] = 'aprs'; |
|
| 956 | - $data['source_name'] = $line['source']; |
|
| 957 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 958 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 959 | - $aprsdate = strtotime($data['datetime']); |
|
| 960 | - // Accept data if time <= system time + 20s |
|
| 961 | - if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
| 962 | - else { |
|
| 938 | + $data = array(); |
|
| 939 | + //print_r($line); |
|
| 940 | + $data['hex'] = $line['address']; |
|
| 941 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 942 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 943 | + $data['ident'] = $line['ident']; |
|
| 944 | + $data['latitude'] = $line['latitude']; |
|
| 945 | + $data['longitude'] = $line['longitude']; |
|
| 946 | + //$data['verticalrate'] = $line[16]; |
|
| 947 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 948 | + else $data['speed'] = 0; |
|
| 949 | + $data['altitude'] = $line['altitude']; |
|
| 950 | + if (isset($line['course'])) $data['heading'] = $line['course']; |
|
| 951 | + //else $data['heading'] = 0; |
|
| 952 | + $data['aircraft_type'] = $line['stealth']; |
|
| 953 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 954 | + $data['id_source'] = $id_source; |
|
| 955 | + $data['format_source'] = 'aprs'; |
|
| 956 | + $data['source_name'] = $line['source']; |
|
| 957 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 958 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 959 | + $aprsdate = strtotime($data['datetime']); |
|
| 960 | + // Accept data if time <= system time + 20s |
|
| 961 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
| 962 | + else { |
|
| 963 | 963 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 964 | 964 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 965 | - } |
|
| 966 | - unset($data); |
|
| 965 | + } |
|
| 966 | + unset($data); |
|
| 967 | 967 | } |
| 968 | 968 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 969 | 969 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 970 | - } |
|
| 970 | + } |
|
| 971 | 971 | } else { |
| 972 | - $line = explode(',', $buffer); |
|
| 973 | - if (count($line) > 20) { |
|
| 974 | - $data['hex'] = $line[4]; |
|
| 975 | - /* |
|
| 972 | + $line = explode(',', $buffer); |
|
| 973 | + if (count($line) > 20) { |
|
| 974 | + $data['hex'] = $line[4]; |
|
| 975 | + /* |
|
| 976 | 976 | $data['datetime'] = $line[6].' '.$line[7]; |
| 977 | 977 | date_default_timezone_set($globalTimezone); |
| 978 | 978 | $datetime = new DateTime($data['datetime']); |
@@ -980,29 +980,29 @@ discard block |
||
| 980 | 980 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 981 | 981 | date_default_timezone_set('UTC'); |
| 982 | 982 | */ |
| 983 | - // Force datetime to current UTC datetime |
|
| 984 | - date_default_timezone_set('UTC'); |
|
| 985 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 986 | - $data['ident'] = trim($line[10]); |
|
| 987 | - $data['latitude'] = $line[14]; |
|
| 988 | - $data['longitude'] = $line[15]; |
|
| 989 | - $data['verticalrate'] = $line[16]; |
|
| 990 | - $data['emergency'] = $line[20]; |
|
| 991 | - $data['speed'] = $line[12]; |
|
| 992 | - $data['squawk'] = $line[17]; |
|
| 993 | - $data['altitude'] = $line[11]; |
|
| 994 | - $data['heading'] = $line[13]; |
|
| 995 | - $data['ground'] = $line[21]; |
|
| 996 | - $data['emergency'] = $line[19]; |
|
| 997 | - $data['format_source'] = 'sbs'; |
|
| 983 | + // Force datetime to current UTC datetime |
|
| 984 | + date_default_timezone_set('UTC'); |
|
| 985 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 986 | + $data['ident'] = trim($line[10]); |
|
| 987 | + $data['latitude'] = $line[14]; |
|
| 988 | + $data['longitude'] = $line[15]; |
|
| 989 | + $data['verticalrate'] = $line[16]; |
|
| 990 | + $data['emergency'] = $line[20]; |
|
| 991 | + $data['speed'] = $line[12]; |
|
| 992 | + $data['squawk'] = $line[17]; |
|
| 993 | + $data['altitude'] = $line[11]; |
|
| 994 | + $data['heading'] = $line[13]; |
|
| 995 | + $data['ground'] = $line[21]; |
|
| 996 | + $data['emergency'] = $line[19]; |
|
| 997 | + $data['format_source'] = 'sbs'; |
|
| 998 | 998 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 999 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1000 | - $data['id_source'] = $id_source; |
|
| 1001 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1002 | - else $error = true; |
|
| 1003 | - unset($data); |
|
| 1004 | - } else $error = true; |
|
| 1005 | - if ($error) { |
|
| 999 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1000 | + $data['id_source'] = $id_source; |
|
| 1001 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1002 | + else $error = true; |
|
| 1003 | + unset($data); |
|
| 1004 | + } else $error = true; |
|
| 1005 | + if ($error) { |
|
| 1006 | 1006 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1007 | 1007 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1008 | 1008 | } else { |
@@ -1018,13 +1018,13 @@ discard block |
||
| 1018 | 1018 | connect_all($sourceer); |
| 1019 | 1019 | $sourceer = array(); |
| 1020 | 1020 | } |
| 1021 | - } |
|
| 1021 | + } |
|
| 1022 | 1022 | } |
| 1023 | 1023 | // Sleep for xxx microseconds |
| 1024 | 1024 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1025 | - } else { |
|
| 1025 | + } else { |
|
| 1026 | 1026 | if ($format == 'flightgearmp') { |
| 1027 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1027 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1028 | 1028 | //@socket_close($r); |
| 1029 | 1029 | sleep($globalMinFetch); |
| 1030 | 1030 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1033,9 +1033,9 @@ discard block |
||
| 1033 | 1033 | break; |
| 1034 | 1034 | |
| 1035 | 1035 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1036 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1037 | - else $tt[$format] = 0; |
|
| 1038 | - if ($tt[$format] > 30) { |
|
| 1036 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1037 | + else $tt[$format] = 0; |
|
| 1038 | + if ($tt[$format] > 30) { |
|
| 1039 | 1039 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1040 | 1040 | //@socket_close($r); |
| 1041 | 1041 | sleep(2); |
@@ -1046,23 +1046,23 @@ discard block |
||
| 1046 | 1046 | //connect_all($globalSources); |
| 1047 | 1047 | $tt[$format]=0; |
| 1048 | 1048 | break; |
| 1049 | - } |
|
| 1049 | + } |
|
| 1050 | + } |
|
| 1050 | 1051 | } |
| 1051 | - } |
|
| 1052 | 1052 | } |
| 1053 | - } else { |
|
| 1053 | + } else { |
|
| 1054 | 1054 | $error = socket_strerror(socket_last_error()); |
| 1055 | 1055 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1056 | 1056 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
| 1057 | 1057 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1058 | 1058 | // Restart the script if possible |
| 1059 | 1059 | if (is_array($sockets)) { |
| 1060 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1060 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1061 | 1061 | |
| 1062 | - foreach ($sockets as $sock) { |
|
| 1062 | + foreach ($sockets as $sock) { |
|
| 1063 | 1063 | @socket_shutdown($sock,2); |
| 1064 | 1064 | @socket_close($sock); |
| 1065 | - } |
|
| 1065 | + } |
|
| 1066 | 1066 | |
| 1067 | 1067 | } |
| 1068 | 1068 | if ($globalDebug) echo "Restart all connections..."; |
@@ -1073,13 +1073,13 @@ discard block |
||
| 1073 | 1073 | if ($reset > 40) exit('Too many attempts...'); |
| 1074 | 1074 | connect_all($globalSources); |
| 1075 | 1075 | } |
| 1076 | - } |
|
| 1076 | + } |
|
| 1077 | 1077 | } |
| 1078 | 1078 | if ($globalDaemon === false) { |
| 1079 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1080 | - $SI->checkAll(); |
|
| 1079 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1080 | + $SI->checkAll(); |
|
| 1081 | + } |
|
| 1081 | 1082 | } |
| 1082 | - } |
|
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | 1085 | ?> |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | die; |
| 41 | 41 | } |
| 42 | 42 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 43 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
| 43 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -$options = getopt('s::',array('source::','server','idsource::')); |
|
| 47 | +$options = getopt('s::', array('source::', 'server', 'idsource::')); |
|
| 48 | 48 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 49 | 49 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 50 | 50 | if (isset($options['s'])) { |
@@ -59,17 +59,17 @@ discard block |
||
| 59 | 59 | else $id_source = 1; |
| 60 | 60 | if (isset($globalServer) && $globalServer) { |
| 61 | 61 | if ($globalDebug) echo "Using Server Mode\n"; |
| 62 | - $SI=new SpotterServer(); |
|
| 63 | -} else $SI=new SpotterImport($Connection->db); |
|
| 62 | + $SI = new SpotterServer(); |
|
| 63 | +} else $SI = new SpotterImport($Connection->db); |
|
| 64 | 64 | //$APRS=new APRS($Connection->db); |
| 65 | -$SBS=new SBS(); |
|
| 66 | -$ACARS=new ACARS($Connection->db); |
|
| 67 | -$Common=new Common(); |
|
| 65 | +$SBS = new SBS(); |
|
| 66 | +$ACARS = new ACARS($Connection->db); |
|
| 67 | +$Common = new Common(); |
|
| 68 | 68 | date_default_timezone_set('UTC'); |
| 69 | 69 | //$servertz = system('date +%Z'); |
| 70 | 70 | // signal handler - playing nice with sockets and dump1090 |
| 71 | 71 | if (function_exists('pcntl_fork')) { |
| 72 | - pcntl_signal(SIGINT, function() { |
|
| 72 | + pcntl_signal(SIGINT, function() { |
|
| 73 | 73 | global $sockets; |
| 74 | 74 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 75 | 75 | die("Bye!\n"); |
@@ -113,35 +113,35 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | function connect_all($hosts) { |
| 115 | 115 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 116 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 116 | + global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 117 | 117 | $reset++; |
| 118 | 118 | if ($globalDebug) echo 'Connect to all...'."\n"; |
| 119 | 119 | foreach ($hosts as $id => $value) { |
| 120 | 120 | $host = $value['host']; |
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; |
| 122 | 122 | // Here we check type of source(s) |
| 123 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 123 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 124 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
| 125 | 125 | //$formats[$id] = 'deltadbtxt'; |
| 126 | 126 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 127 | 127 | //$last_exec['deltadbtxt'] = 0; |
| 128 | 128 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 129 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 130 | 130 | //$formats[$id] = 'vatsimtxt'; |
| 131 | 131 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 132 | 132 | //$last_exec['vatsimtxt'] = 0; |
| 133 | 133 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 134 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 135 | 135 | //$formats[$id] = 'aircraftlistjson'; |
| 136 | 136 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 137 | 137 | //$last_exec['aircraftlistjson'] = 0; |
| 138 | 138 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 139 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 139 | + } else if (preg_match('/opensky/i', $host)) { |
|
| 140 | 140 | //$formats[$id] = 'aircraftlistjson'; |
| 141 | 141 | $globalSources[$id]['format'] = 'opensky'; |
| 142 | 142 | //$last_exec['aircraftlistjson'] = 0; |
| 143 | 143 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
| 144 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 144 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
| 145 | 145 | //$formats[$id] = 'radarvirtueljson'; |
| 146 | 146 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 147 | 147 | //$last_exec['radarvirtueljson'] = 0; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 151 | 151 | exit(0); |
| 152 | 152 | } |
| 153 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 153 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 154 | 154 | //$formats[$id] = 'planeupdatefaa'; |
| 155 | 155 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 156 | 156 | //$last_exec['planeupdatefaa'] = 0; |
@@ -159,26 +159,26 @@ discard block |
||
| 159 | 159 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 160 | 160 | exit(0); |
| 161 | 161 | } |
| 162 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 162 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 163 | 163 | //$formats[$id] = 'phpvmacars'; |
| 164 | 164 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 165 | 165 | //$last_exec['phpvmacars'] = 0; |
| 166 | 166 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 167 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 167 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
| 168 | 168 | //$formats[$id] = 'phpvmacars'; |
| 169 | 169 | $globalSources[$id]['format'] = 'vam'; |
| 170 | 170 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
| 171 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 171 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 172 | 172 | //$formats[$id] = 'whazzup'; |
| 173 | 173 | $globalSources[$id]['format'] = 'whazzup'; |
| 174 | 174 | //$last_exec['whazzup'] = 0; |
| 175 | 175 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 176 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 176 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 177 | 177 | //$formats[$id] = 'pirepsjson'; |
| 178 | 178 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 179 | 179 | //$last_exec['pirepsjson'] = 0; |
| 180 | 180 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 181 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 181 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 182 | 182 | //$formats[$id] = 'fr24json'; |
| 183 | 183 | $globalSources[$id]['format'] = 'fr24json'; |
| 184 | 184 | //$last_exec['fr24json'] = 0; |
@@ -188,15 +188,15 @@ discard block |
||
| 188 | 188 | exit(0); |
| 189 | 189 | } |
| 190 | 190 | //} else if (preg_match('/10001/',$host)) { |
| 191 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 191 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 192 | 192 | //$formats[$id] = 'tsv'; |
| 193 | 193 | $globalSources[$id]['format'] = 'tsv'; |
| 194 | 194 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 195 | 195 | } |
| 196 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 196 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 197 | 197 | if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 198 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 199 | - $hostport = explode(':',$host); |
|
| 198 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 199 | + $hostport = explode(':', $host); |
|
| 200 | 200 | if (isset($hostport[1])) { |
| 201 | 201 | $port = $hostport[1]; |
| 202 | 202 | $hostn = $hostport[0]; |
@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | $hostn = $globalSources[$id]['host']; |
| 206 | 206 | } |
| 207 | 207 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
| 208 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 208 | + $s = create_socket($hostn, $port, $errno, $errstr); |
|
| 209 | 209 | } else { |
| 210 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 210 | + $s = create_socket_udp($hostn, $port, $errno, $errstr); |
|
| 211 | 211 | } |
| 212 | 212 | if ($s) { |
| 213 | 213 | $sockets[$id] = $s; |
| 214 | 214 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 215 | - if (preg_match('/aprs/',$hostn)) { |
|
| 215 | + if (preg_match('/aprs/', $hostn)) { |
|
| 216 | 216 | //$formats[$id] = 'aprs'; |
| 217 | 217 | $globalSources[$id]['format'] = 'aprs'; |
| 218 | 218 | //$aprs_connect = 0; |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 254 | 254 | else $timeout = 20; |
| 255 | 255 | $errno = ''; |
| 256 | -$errstr=''; |
|
| 256 | +$errstr = ''; |
|
| 257 | 257 | |
| 258 | 258 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 259 | 259 | /* Initiate connections to all the hosts simultaneously */ |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | if ($use_aprs) { |
| 284 | 284 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 285 | - $APRS=new APRS(); |
|
| 285 | + $APRS = new APRS(); |
|
| 286 | 286 | $aprs_connect = 0; |
| 287 | 287 | $aprs_keep = 120; |
| 288 | 288 | $aprs_last_tx = time(); |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | else $aprs_ssid = 'FAM'; |
| 294 | 294 | //else $aprs_ssid = 'PerlEx'; |
| 295 | 295 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 296 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 296 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 297 | 297 | if ($aprs_full) $aprs_filter = ''; |
| 298 | 298 | if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
| 299 | 299 | else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
@@ -304,12 +304,12 @@ discard block |
||
| 304 | 304 | sleep(1); |
| 305 | 305 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 306 | 306 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 307 | -$endtime = time()+$globalCronEnd; |
|
| 307 | +$endtime = time() + $globalCronEnd; |
|
| 308 | 308 | $i = 1; |
| 309 | 309 | $tt = array(); |
| 310 | 310 | // Delete all ATC |
| 311 | 311 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 312 | - $ATC=new ATC($Connection->db); |
|
| 312 | + $ATC = new ATC($Connection->db); |
|
| 313 | 313 | } |
| 314 | 314 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 315 | 315 | $ATC->deleteAll(); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 319 | 319 | while ($i > 0) { |
| 320 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 320 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 321 | 321 | // Delete old ATC |
| 322 | 322 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 323 | 323 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | } |
| 332 | 332 | if ($max != $globalMinFetch) { |
| 333 | 333 | if ($globalDebug) echo 'Sleeping...'."\n"; |
| 334 | - sleep($globalMinFetch-$max+2); |
|
| 334 | + sleep($globalMinFetch - $max + 2); |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
@@ -343,8 +343,8 @@ discard block |
||
| 343 | 343 | //$buffer = $Common->getData($hosts[$id]); |
| 344 | 344 | $buffer = $Common->getData($value['host']); |
| 345 | 345 | if ($buffer != '') $reset = 0; |
| 346 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 347 | - $buffer = explode('\n',$buffer); |
|
| 346 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 347 | + $buffer = explode('\n', $buffer); |
|
| 348 | 348 | foreach ($buffer as $line) { |
| 349 | 349 | if ($line != '' && count($line) > 7) { |
| 350 | 350 | $line = explode(',', $line); |
@@ -373,8 +373,8 @@ discard block |
||
| 373 | 373 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 374 | 374 | //$buffer = $Common->getData($hosts[$id]); |
| 375 | 375 | $buffer = $Common->getData($value['host']); |
| 376 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 377 | - $buffer = explode('\n',$buffer); |
|
| 376 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 377 | + $buffer = explode('\n', $buffer); |
|
| 378 | 378 | $reset = 0; |
| 379 | 379 | foreach ($buffer as $line) { |
| 380 | 380 | if ($line != '') { |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 385 | 385 | $data['pilot_id'] = $line[1]; |
| 386 | 386 | $data['pilot_name'] = $line[2]; |
| 387 | - $data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT); |
|
| 387 | + $data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT); |
|
| 388 | 388 | $data['ident'] = $line[0]; // ident |
| 389 | 389 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 390 | 390 | $data['speed'] = $line[8]; // speed |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 401 | 401 | if (isset($line[37])) $data['last_update'] = $line[37]; |
| 402 | 402 | $data['departure_airport_icao'] = $line[11]; |
| 403 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 403 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 404 | 404 | $data['arrival_airport_icao'] = $line[13]; |
| 405 | 405 | $data['frequency'] = $line[4]; |
| 406 | 406 | $data['type'] = $line[18]; |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | $data['id_source'] = $id_source; |
| 410 | 410 | //$data['arrival_airport_time'] = ; |
| 411 | 411 | if ($line[9] != '') { |
| 412 | - $aircraft_data = explode('/',$line[9]); |
|
| 412 | + $aircraft_data = explode('/', $line[9]); |
|
| 413 | 413 | if (isset($aircraft_data[1])) { |
| 414 | 414 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 415 | 415 | } |
@@ -423,9 +423,9 @@ discard block |
||
| 423 | 423 | if ($line[3] == 'PILOT') $SI->add($data); |
| 424 | 424 | elseif ($line[3] == 'ATC') { |
| 425 | 425 | //print_r($data); |
| 426 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 427 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 428 | - $typec = substr($data['ident'],-3); |
|
| 426 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 427 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 428 | + $typec = substr($data['ident'], -3); |
|
| 429 | 429 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 430 | 430 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
| 431 | 431 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 437 | 437 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
| 438 | 438 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 439 | - 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']); |
|
| 439 | + 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']); |
|
| 440 | 440 | } |
| 441 | 441 | unset($data); |
| 442 | 442 | } |
@@ -447,9 +447,9 @@ discard block |
||
| 447 | 447 | $last_exec[$id]['last'] = time(); |
| 448 | 448 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
| 449 | 449 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 450 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 450 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 451 | 451 | if ($buffer != '') { |
| 452 | - $all_data = json_decode($buffer,true); |
|
| 452 | + $all_data = json_decode($buffer, true); |
|
| 453 | 453 | if (isset($all_data['acList'])) { |
| 454 | 454 | $reset = 0; |
| 455 | 455 | foreach ($all_data['acList'] as $line) { |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
| 506 | 506 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 507 | 507 | $buffer = $Common->getData($value['host']); |
| 508 | - $all_data = json_decode($buffer,true); |
|
| 508 | + $all_data = json_decode($buffer, true); |
|
| 509 | 509 | if (isset($all_data['planes'])) { |
| 510 | 510 | $reset = 0; |
| 511 | 511 | foreach ($all_data['planes'] as $key => $line) { |
@@ -522,12 +522,12 @@ discard block |
||
| 522 | 522 | $data['emergency'] = ''; // emergency |
| 523 | 523 | $data['registration'] = $line[2]; |
| 524 | 524 | $data['aircraft_icao'] = $line[0]; |
| 525 | - $deparr = explode('-',$line[1]); |
|
| 525 | + $deparr = explode('-', $line[1]); |
|
| 526 | 526 | if (count($deparr) == 2) { |
| 527 | 527 | $data['departure_airport_icao'] = $deparr[0]; |
| 528 | 528 | $data['arrival_airport_icao'] = $deparr[1]; |
| 529 | 529 | } |
| 530 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 530 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 531 | 531 | $data['format_source'] = 'planeupdatefaa'; |
| 532 | 532 | $data['id_source'] = $id_source; |
| 533 | 533 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | $last_exec[$id]['last'] = time(); |
| 540 | 540 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 541 | 541 | $buffer = $Common->getData($value['host']); |
| 542 | - $all_data = json_decode($buffer,true); |
|
| 542 | + $all_data = json_decode($buffer, true); |
|
| 543 | 543 | if (isset($all_data['states'])) { |
| 544 | 544 | $reset = 0; |
| 545 | 545 | foreach ($all_data['states'] as $key => $line) { |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | //$data['emergency'] = ''; // emergency |
| 557 | 557 | //$data['registration'] = $line[2]; |
| 558 | 558 | //$data['aircraft_icao'] = $line[0]; |
| 559 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 559 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 560 | 560 | $data['format_source'] = 'opensky'; |
| 561 | 561 | $data['id_source'] = $id_source; |
| 562 | 562 | $SI->add($data); |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 570 | 570 | //$buffer = $Common->getData($hosts[$id]); |
| 571 | 571 | $buffer = $Common->getData($value['host']); |
| 572 | - $all_data = json_decode($buffer,true); |
|
| 572 | + $all_data = json_decode($buffer, true); |
|
| 573 | 573 | if (!empty($all_data)) $reset = 0; |
| 574 | 574 | foreach ($all_data as $key => $line) { |
| 575 | 575 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -601,11 +601,11 @@ discard block |
||
| 601 | 601 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 602 | 602 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 603 | 603 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 604 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 604 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 605 | 605 | //echo $buffer; |
| 606 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 607 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 608 | - $all_data = json_decode($buffer,true); |
|
| 606 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 607 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 608 | + $all_data = json_decode($buffer, true); |
|
| 609 | 609 | if (json_last_error() != JSON_ERROR_NONE) { |
| 610 | 610 | die(json_last_error_msg()); |
| 611 | 611 | } |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | //$data['departure_airport_iata'] = $line[11]; |
| 629 | 629 | //$data['arrival_airport_iata'] = $line[12]; |
| 630 | 630 | //$data['emergency'] = ''; // emergency |
| 631 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 631 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 632 | 632 | $data['format_source'] = 'radarvirtueljson'; |
| 633 | 633 | $data['id_source'] = $id_source; |
| 634 | 634 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -643,14 +643,14 @@ discard block |
||
| 643 | 643 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 644 | 644 | //$buffer = $Common->getData($hosts[$id]); |
| 645 | 645 | $buffer = $Common->getData($value['host'].'?'.time()); |
| 646 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 646 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 647 | 647 | |
| 648 | 648 | if (isset($all_data['pireps'])) { |
| 649 | 649 | $reset = 0; |
| 650 | 650 | foreach ($all_data['pireps'] as $line) { |
| 651 | 651 | $data = array(); |
| 652 | 652 | $data['id'] = $line['id']; |
| 653 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 653 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 654 | 654 | $data['ident'] = $line['callsign']; // ident |
| 655 | 655 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 656 | 656 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -679,9 +679,9 @@ discard block |
||
| 679 | 679 | $SI->add($data); |
| 680 | 680 | // print_r($data); |
| 681 | 681 | } elseif ($line['icon'] == 'ct') { |
| 682 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 683 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 684 | - $typec = substr($data['ident'],-3); |
|
| 682 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 683 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 684 | + $typec = substr($data['ident'], -3); |
|
| 685 | 685 | $data['type'] = ''; |
| 686 | 686 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 687 | 687 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
| 693 | 693 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 694 | 694 | else $data['type'] = 'Observer'; |
| 695 | - 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']); |
|
| 695 | + 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']); |
|
| 696 | 696 | } |
| 697 | 697 | unset($data); |
| 698 | 698 | } |
@@ -704,14 +704,14 @@ discard block |
||
| 704 | 704 | //$buffer = $Common->getData($hosts[$id]); |
| 705 | 705 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 706 | 706 | $buffer = $Common->getData($value['host']); |
| 707 | - $all_data = json_decode($buffer,true); |
|
| 707 | + $all_data = json_decode($buffer, true); |
|
| 708 | 708 | if ($buffer != '' && is_array($all_data)) { |
| 709 | 709 | $reset = 0; |
| 710 | 710 | foreach ($all_data as $line) { |
| 711 | 711 | $data = array(); |
| 712 | 712 | //$data['id'] = $line['id']; // id not usable |
| 713 | 713 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
| 714 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 714 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 715 | 715 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 716 | 716 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 717 | 717 | $data['ident'] = $line['flightnum']; // ident |
@@ -734,12 +734,12 @@ discard block |
||
| 734 | 734 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 735 | 735 | if (isset($line['aircraftname'])) { |
| 736 | 736 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 737 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 738 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 737 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 738 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 739 | 739 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
| 740 | 740 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
| 741 | 741 | else { |
| 742 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 742 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 743 | 743 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
| 744 | 744 | else $data['aircraft_icao'] = $line['aircraftname']; |
| 745 | 745 | } |
@@ -761,14 +761,14 @@ discard block |
||
| 761 | 761 | //$buffer = $Common->getData($hosts[$id]); |
| 762 | 762 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 763 | 763 | $buffer = $Common->getData($value['host']); |
| 764 | - $all_data = json_decode($buffer,true); |
|
| 764 | + $all_data = json_decode($buffer, true); |
|
| 765 | 765 | if ($buffer != '' && is_array($all_data)) { |
| 766 | 766 | $reset = 0; |
| 767 | 767 | foreach ($all_data as $line) { |
| 768 | 768 | $data = array(); |
| 769 | 769 | //$data['id'] = $line['id']; // id not usable |
| 770 | 770 | $data['id'] = trim($line['flight_id']); |
| 771 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 771 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 772 | 772 | $data['pilot_name'] = $line['pilot_name']; |
| 773 | 773 | $data['pilot_id'] = $line['pilot_id']; |
| 774 | 774 | $data['ident'] = trim($line['callsign']); // ident |
@@ -819,9 +819,9 @@ discard block |
||
| 819 | 819 | //$value = $formats[$nb]; |
| 820 | 820 | $format = $globalSources[$nb]['format']; |
| 821 | 821 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
| 822 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 822 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 823 | 823 | } else { |
| 824 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 824 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 825 | 825 | } |
| 826 | 826 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 827 | 827 | //echo $buffer."\n"; |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
| 830 | 830 | $error = false; |
| 831 | 831 | //$SI::del(); |
| 832 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 832 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 833 | 833 | // SBS format is CSV format |
| 834 | 834 | if ($buffer != '') { |
| 835 | 835 | $tt[$format] = 0; |
@@ -850,10 +850,10 @@ discard block |
||
| 850 | 850 | } elseif ($format == 'flightgearsp') { |
| 851 | 851 | //echo $buffer."\n"; |
| 852 | 852 | if (strlen($buffer) > 5) { |
| 853 | - $line = explode(',',$buffer); |
|
| 853 | + $line = explode(',', $buffer); |
|
| 854 | 854 | $data = array(); |
| 855 | 855 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 856 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 856 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 857 | 857 | $data['ident'] = $line[6]; |
| 858 | 858 | $data['aircraft_name'] = $line[7]; |
| 859 | 859 | $data['longitude'] = $line[1]; |
@@ -864,21 +864,21 @@ discard block |
||
| 864 | 864 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 865 | 865 | $data['format_source'] = 'flightgearsp'; |
| 866 | 866 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 867 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 867 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 868 | 868 | } |
| 869 | 869 | } elseif ($format == 'acars') { |
| 870 | 870 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 871 | 871 | $ACARS->add(trim($buffer)); |
| 872 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 872 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 873 | 873 | $ACARS->deleteLiveAcarsData(); |
| 874 | 874 | } elseif ($format == 'flightgearmp') { |
| 875 | - if (substr($buffer,0,1) != '#') { |
|
| 875 | + if (substr($buffer, 0, 1) != '#') { |
|
| 876 | 876 | $data = array(); |
| 877 | 877 | //echo $buffer."\n"; |
| 878 | - $line = explode(' ',$buffer); |
|
| 878 | + $line = explode(' ', $buffer); |
|
| 879 | 879 | if (count($line) == 11) { |
| 880 | - $userserver = explode('@',$line[0]); |
|
| 881 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 880 | + $userserver = explode('@', $line[0]); |
|
| 881 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 882 | 882 | $data['ident'] = $userserver[0]; |
| 883 | 883 | $data['registration'] = $userserver[0]; |
| 884 | 884 | $data['latitude'] = $line[4]; |
@@ -886,24 +886,24 @@ discard block |
||
| 886 | 886 | $data['altitude'] = $line[6]; |
| 887 | 887 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 888 | 888 | $aircraft_type = $line[10]; |
| 889 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 890 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 889 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 890 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 891 | 891 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 892 | 892 | } |
| 893 | 893 | } |
| 894 | 894 | } elseif ($format == 'beast') { |
| 895 | 895 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 896 | 896 | die; |
| 897 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
| 897 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
| 898 | 898 | $line = explode("\t", $buffer); |
| 899 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 899 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 900 | 900 | $key = $line[$k]; |
| 901 | - $lined[$key] = $line[$k+1]; |
|
| 901 | + $lined[$key] = $line[$k + 1]; |
|
| 902 | 902 | } |
| 903 | 903 | if (count($lined) > 3) { |
| 904 | 904 | $data['hex'] = $lined['hexid']; |
| 905 | 905 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 906 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 906 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 907 | 907 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 908 | 908 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 909 | 909 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -921,24 +921,24 @@ discard block |
||
| 921 | 921 | } else $error = true; |
| 922 | 922 | } elseif ($format == 'aprs' && $use_aprs) { |
| 923 | 923 | if ($aprs_connect == 0) { |
| 924 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 924 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 925 | 925 | $aprs_connect = 1; |
| 926 | 926 | } |
| 927 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 927 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 928 | 928 | $aprs_last_tx = time(); |
| 929 | 929 | $data_aprs = "# Keep alive"; |
| 930 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 930 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 931 | 931 | } |
| 932 | 932 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 933 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 934 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 935 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 933 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 934 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 935 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 936 | 936 | $line = $APRS->parse($buffer); |
| 937 | 937 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 938 | 938 | $data = array(); |
| 939 | 939 | //print_r($line); |
| 940 | 940 | $data['hex'] = $line['address']; |
| 941 | - $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 941 | + $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 942 | 942 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 943 | 943 | $data['ident'] = $line['ident']; |
| 944 | 944 | $data['latitude'] = $line['latitude']; |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | $currentdate = date('Y-m-d H:i:s'); |
| 959 | 959 | $aprsdate = strtotime($data['datetime']); |
| 960 | 960 | // Accept data if time <= system time + 20s |
| 961 | - if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
| 961 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
| 962 | 962 | else { |
| 963 | 963 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 964 | 964 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
@@ -1044,7 +1044,7 @@ discard block |
||
| 1044 | 1044 | connect_all($sourceee); |
| 1045 | 1045 | $sourceee = array(); |
| 1046 | 1046 | //connect_all($globalSources); |
| 1047 | - $tt[$format]=0; |
|
| 1047 | + $tt[$format] = 0; |
|
| 1048 | 1048 | break; |
| 1049 | 1049 | } |
| 1050 | 1050 | } |
@@ -1052,7 +1052,7 @@ discard block |
||
| 1052 | 1052 | } |
| 1053 | 1053 | } else { |
| 1054 | 1054 | $error = socket_strerror(socket_last_error()); |
| 1055 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1055 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 1056 | 1056 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
| 1057 | 1057 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1058 | 1058 | // Restart the script if possible |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 1061 | 1061 | |
| 1062 | 1062 | foreach ($sockets as $sock) { |
| 1063 | - @socket_shutdown($sock,2); |
|
| 1063 | + @socket_shutdown($sock, 2); |
|
| 1064 | 1064 | @socket_close($sock); |
| 1065 | 1065 | } |
| 1066 | 1066 | |
@@ -14,7 +14,9 @@ discard block |
||
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 16 | 16 | |
| 17 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 17 | +if (!isset($globalDebug)) { |
|
| 18 | + $globalDebug = FALSE; |
|
| 19 | +} |
|
| 18 | 20 | |
| 19 | 21 | // Check if schema is at latest version |
| 20 | 22 | $Connection = new Connection(); |
@@ -54,13 +56,22 @@ discard block |
||
| 54 | 56 | $globalSources = array(); |
| 55 | 57 | $globalSources[] = array('host' => $options['source']); |
| 56 | 58 | } |
| 57 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 58 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 59 | -else $id_source = 1; |
|
| 59 | +if (isset($options['server'])) { |
|
| 60 | + $globalServer = TRUE; |
|
| 61 | +} |
|
| 62 | +if (isset($options['idsource'])) { |
|
| 63 | + $id_source = $options['idsource']; |
|
| 64 | +} else { |
|
| 65 | + $id_source = 1; |
|
| 66 | +} |
|
| 60 | 67 | if (isset($globalServer) && $globalServer) { |
| 61 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 68 | + if ($globalDebug) { |
|
| 69 | + echo "Using Server Mode\n"; |
|
| 70 | + } |
|
| 62 | 71 | $SI=new SpotterServer(); |
| 63 | -} else $SI=new SpotterImport($Connection->db); |
|
| 72 | +} else { |
|
| 73 | + $SI=new SpotterImport($Connection->db); |
|
| 74 | +} |
|
| 64 | 75 | //$APRS=new APRS($Connection->db); |
| 65 | 76 | $SBS=new SBS(); |
| 66 | 77 | $ACARS=new ACARS($Connection->db); |
@@ -78,7 +89,9 @@ discard block |
||
| 78 | 89 | } |
| 79 | 90 | |
| 80 | 91 | // let's try and connect |
| 81 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 92 | +if ($globalDebug) { |
|
| 93 | + echo "Connecting...\n"; |
|
| 94 | +} |
|
| 82 | 95 | $use_aprs = false; |
| 83 | 96 | $aprs_full = false; |
| 84 | 97 | $reset = 0; |
@@ -87,7 +100,9 @@ discard block |
||
| 87 | 100 | $ip = gethostbyname($host); |
| 88 | 101 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
| 89 | 102 | $r = @socket_connect($s, $ip, $port); |
| 90 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 103 | + if (!socket_set_nonblock($s)) { |
|
| 104 | + echo "Unable to set nonblock on socket\n"; |
|
| 105 | + } |
|
| 91 | 106 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
| 92 | 107 | return $s; |
| 93 | 108 | } |
@@ -115,7 +130,9 @@ discard block |
||
| 115 | 130 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 116 | 131 | global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
| 117 | 132 | $reset++; |
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 133 | + if ($globalDebug) { |
|
| 134 | + echo 'Connect to all...'."\n"; |
|
| 135 | + } |
|
| 119 | 136 | foreach ($hosts as $id => $value) { |
| 120 | 137 | $host = $value['host']; |
| 121 | 138 | $globalSources[$id]['last_exec'] = 0; |
@@ -125,27 +142,37 @@ discard block |
||
| 125 | 142 | //$formats[$id] = 'deltadbtxt'; |
| 126 | 143 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 127 | 144 | //$last_exec['deltadbtxt'] = 0; |
| 128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 145 | + if ($globalDebug) { |
|
| 146 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 147 | + } |
|
| 129 | 148 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 130 | 149 | //$formats[$id] = 'vatsimtxt'; |
| 131 | 150 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 132 | 151 | //$last_exec['vatsimtxt'] = 0; |
| 133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 152 | + if ($globalDebug) { |
|
| 153 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 154 | + } |
|
| 134 | 155 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 135 | 156 | //$formats[$id] = 'aircraftlistjson'; |
| 136 | 157 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 137 | 158 | //$last_exec['aircraftlistjson'] = 0; |
| 138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 159 | + if ($globalDebug) { |
|
| 160 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 161 | + } |
|
| 139 | 162 | } else if (preg_match('/opensky/i',$host)) { |
| 140 | 163 | //$formats[$id] = 'aircraftlistjson'; |
| 141 | 164 | $globalSources[$id]['format'] = 'opensky'; |
| 142 | 165 | //$last_exec['aircraftlistjson'] = 0; |
| 143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 166 | + if ($globalDebug) { |
|
| 167 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 168 | + } |
|
| 144 | 169 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
| 145 | 170 | //$formats[$id] = 'radarvirtueljson'; |
| 146 | 171 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 147 | 172 | //$last_exec['radarvirtueljson'] = 0; |
| 148 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 173 | + if ($globalDebug) { |
|
| 174 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 175 | + } |
|
| 149 | 176 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 150 | 177 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 151 | 178 | exit(0); |
@@ -154,7 +181,9 @@ discard block |
||
| 154 | 181 | //$formats[$id] = 'planeupdatefaa'; |
| 155 | 182 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 156 | 183 | //$last_exec['planeupdatefaa'] = 0; |
| 157 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 184 | + if ($globalDebug) { |
|
| 185 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 186 | + } |
|
| 158 | 187 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 159 | 188 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 160 | 189 | exit(0); |
@@ -163,26 +192,36 @@ discard block |
||
| 163 | 192 | //$formats[$id] = 'phpvmacars'; |
| 164 | 193 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 165 | 194 | //$last_exec['phpvmacars'] = 0; |
| 166 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 195 | + if ($globalDebug) { |
|
| 196 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 197 | + } |
|
| 167 | 198 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 168 | 199 | //$formats[$id] = 'phpvmacars'; |
| 169 | 200 | $globalSources[$id]['format'] = 'vam'; |
| 170 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 201 | + if ($globalDebug) { |
|
| 202 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 203 | + } |
|
| 171 | 204 | } else if (preg_match('/whazzup/i',$host)) { |
| 172 | 205 | //$formats[$id] = 'whazzup'; |
| 173 | 206 | $globalSources[$id]['format'] = 'whazzup'; |
| 174 | 207 | //$last_exec['whazzup'] = 0; |
| 175 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 208 | + if ($globalDebug) { |
|
| 209 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 210 | + } |
|
| 176 | 211 | } else if (preg_match('/recentpireps/i',$host)) { |
| 177 | 212 | //$formats[$id] = 'pirepsjson'; |
| 178 | 213 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 179 | 214 | //$last_exec['pirepsjson'] = 0; |
| 180 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 215 | + if ($globalDebug) { |
|
| 216 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 217 | + } |
|
| 181 | 218 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 182 | 219 | //$formats[$id] = 'fr24json'; |
| 183 | 220 | $globalSources[$id]['format'] = 'fr24json'; |
| 184 | 221 | //$last_exec['fr24json'] = 0; |
| 185 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 222 | + if ($globalDebug) { |
|
| 223 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 224 | + } |
|
| 186 | 225 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 187 | 226 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 188 | 227 | exit(0); |
@@ -191,10 +230,14 @@ discard block |
||
| 191 | 230 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 192 | 231 | //$formats[$id] = 'tsv'; |
| 193 | 232 | $globalSources[$id]['format'] = 'tsv'; |
| 194 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 233 | + if ($globalDebug) { |
|
| 234 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 235 | + } |
|
| 195 | 236 | } |
| 196 | 237 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 197 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 238 | + if ($globalDebug) { |
|
| 239 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 240 | + } |
|
| 198 | 241 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 199 | 242 | $hostport = explode(':',$host); |
| 200 | 243 | if (isset($hostport[1])) { |
@@ -231,17 +274,25 @@ discard block |
||
| 231 | 274 | //$formats[$id] = 'beast'; |
| 232 | 275 | $globalSources[$id]['format'] = 'beast'; |
| 233 | 276 | //} else $formats[$id] = 'sbs'; |
| 234 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 277 | + } else { |
|
| 278 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 279 | + } |
|
| 235 | 280 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 236 | 281 | } |
| 237 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 282 | + if ($globalDebug) { |
|
| 283 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 284 | + } |
|
| 238 | 285 | } else { |
| 239 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 286 | + if ($globalDebug) { |
|
| 287 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 288 | + } |
|
| 240 | 289 | } |
| 241 | 290 | } |
| 242 | 291 | } |
| 243 | 292 | } |
| 244 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 293 | +if (!isset($globalMinFetch)) { |
|
| 294 | + $globalMinFetch = 15; |
|
| 295 | +} |
|
| 245 | 296 | |
| 246 | 297 | // Initialize all |
| 247 | 298 | $status = array(); |
@@ -249,13 +300,19 @@ discard block |
||
| 249 | 300 | $formats = array(); |
| 250 | 301 | $last_exec = array(); |
| 251 | 302 | $time = time(); |
| 252 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 253 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 254 | -else $timeout = 20; |
|
| 303 | +if (isset($globalSourcesTimeout)) { |
|
| 304 | + $timeout = $globalSourcesTimeOut; |
|
| 305 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 306 | + $timeout = $globalSBS1TimeOut; |
|
| 307 | +} else { |
|
| 308 | + $timeout = 20; |
|
| 309 | +} |
|
| 255 | 310 | $errno = ''; |
| 256 | 311 | $errstr=''; |
| 257 | 312 | |
| 258 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 313 | +if (!isset($globalDaemon)) { |
|
| 314 | + $globalDaemon = TRUE; |
|
| 315 | +} |
|
| 259 | 316 | /* Initiate connections to all the hosts simultaneously */ |
| 260 | 317 | //connect_all($hosts); |
| 261 | 318 | //connect_all($globalSources); |
@@ -275,7 +332,9 @@ discard block |
||
| 275 | 332 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 276 | 333 | $aprs_connect = 0; |
| 277 | 334 | $use_aprs = true; |
| 278 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 335 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 336 | + $aprs_full = true; |
|
| 337 | + } |
|
| 279 | 338 | break; |
| 280 | 339 | } |
| 281 | 340 | } |
@@ -286,24 +345,44 @@ discard block |
||
| 286 | 345 | $aprs_connect = 0; |
| 287 | 346 | $aprs_keep = 120; |
| 288 | 347 | $aprs_last_tx = time(); |
| 289 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 290 | - else $aprs_version = $globalName.' using FlightAirMap'; |
|
| 348 | + if (isset($globalAPRSversion)) { |
|
| 349 | + $aprs_version = $globalAPRSversion; |
|
| 350 | + } else { |
|
| 351 | + $aprs_version = $globalName.' using FlightAirMap'; |
|
| 352 | + } |
|
| 291 | 353 | //else $aprs_version = 'Perl Example App'; |
| 292 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 293 | - else $aprs_ssid = 'FAM'; |
|
| 354 | + if (isset($globalAPRSssid)) { |
|
| 355 | + $aprs_ssid = $globalAPRSssid; |
|
| 356 | + } else { |
|
| 357 | + $aprs_ssid = 'FAM'; |
|
| 358 | + } |
|
| 294 | 359 | //else $aprs_ssid = 'PerlEx'; |
| 295 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 296 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 297 | - if ($aprs_full) $aprs_filter = ''; |
|
| 298 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
|
| 299 | - else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
|
| 300 | -} |
|
| 360 | + if (isset($globalAPRSfilter)) { |
|
| 361 | + $aprs_filter = $globalAPRSfilter; |
|
| 362 | + } else { |
|
| 363 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 364 | + } |
|
| 365 | + if ($aprs_full) { |
|
| 366 | + $aprs_filter = ''; |
|
| 367 | + } |
|
| 368 | + if ($aprs_filter != '') { |
|
| 369 | + $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
|
| 370 | + } else { |
|
| 371 | + $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
|
| 372 | + } |
|
| 373 | + } |
|
| 301 | 374 | |
| 302 | 375 | // connected - lets do some work |
| 303 | -if ($globalDebug) echo "Connected!\n"; |
|
| 376 | +if ($globalDebug) { |
|
| 377 | + echo "Connected!\n"; |
|
| 378 | +} |
|
| 304 | 379 | sleep(1); |
| 305 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 306 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 380 | +if ($globalDebug) { |
|
| 381 | + echo "SCAN MODE \n\n"; |
|
| 382 | +} |
|
| 383 | +if (!isset($globalCronEnd)) { |
|
| 384 | + $globalCronEnd = 60; |
|
| 385 | +} |
|
| 307 | 386 | $endtime = time()+$globalCronEnd; |
| 308 | 387 | $i = 1; |
| 309 | 388 | $tt = array(); |
@@ -317,20 +396,28 @@ discard block |
||
| 317 | 396 | |
| 318 | 397 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 319 | 398 | while ($i > 0) { |
| 320 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 399 | + if (!$globalDaemon) { |
|
| 400 | + $i = $endtime-time(); |
|
| 401 | + } |
|
| 321 | 402 | // Delete old ATC |
| 322 | 403 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 323 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 404 | + if ($globalDebug) { |
|
| 405 | + echo 'Delete old ATC...'."\n"; |
|
| 406 | + } |
|
| 324 | 407 | $ATC->deleteOldATC(); |
| 325 | 408 | } |
| 326 | 409 | |
| 327 | 410 | if (count($last_exec) > 0) { |
| 328 | 411 | $max = $globalMinFetch; |
| 329 | 412 | foreach ($last_exec as $last) { |
| 330 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 413 | + if ((time() - $last['last']) < $max) { |
|
| 414 | + $max = time() - $last['last']; |
|
| 415 | + } |
|
| 331 | 416 | } |
| 332 | 417 | if ($max != $globalMinFetch) { |
| 333 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 418 | + if ($globalDebug) { |
|
| 419 | + echo 'Sleeping...'."\n"; |
|
| 420 | + } |
|
| 334 | 421 | sleep($globalMinFetch-$max+2); |
| 335 | 422 | } |
| 336 | 423 | } |
@@ -338,11 +425,15 @@ discard block |
||
| 338 | 425 | |
| 339 | 426 | //foreach ($formats as $id => $value) { |
| 340 | 427 | foreach ($globalSources as $id => $value) { |
| 341 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 428 | + if (!isset($last_exec[$id]['last'])) { |
|
| 429 | + $last_exec[$id]['last'] = 0; |
|
| 430 | + } |
|
| 342 | 431 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 343 | 432 | //$buffer = $Common->getData($hosts[$id]); |
| 344 | 433 | $buffer = $Common->getData($value['host']); |
| 345 | - if ($buffer != '') $reset = 0; |
|
| 434 | + if ($buffer != '') { |
|
| 435 | + $reset = 0; |
|
| 436 | + } |
|
| 346 | 437 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 347 | 438 | $buffer = explode('\n',$buffer); |
| 348 | 439 | foreach ($buffer as $line) { |
@@ -351,19 +442,38 @@ discard block |
||
| 351 | 442 | $data = array(); |
| 352 | 443 | $data['hex'] = $line[1]; // hex |
| 353 | 444 | $data['ident'] = $line[2]; // ident |
| 354 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 355 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 356 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 357 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 358 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 445 | + if (isset($line[3])) { |
|
| 446 | + $data['altitude'] = $line[3]; |
|
| 447 | + } |
|
| 448 | + // altitude |
|
| 449 | + if (isset($line[4])) { |
|
| 450 | + $data['speed'] = $line[4]; |
|
| 451 | + } |
|
| 452 | + // speed |
|
| 453 | + if (isset($line[5])) { |
|
| 454 | + $data['heading'] = $line[5]; |
|
| 455 | + } |
|
| 456 | + // heading |
|
| 457 | + if (isset($line[6])) { |
|
| 458 | + $data['latitude'] = $line[6]; |
|
| 459 | + } |
|
| 460 | + // lat |
|
| 461 | + if (isset($line[7])) { |
|
| 462 | + $data['longitude'] = $line[7]; |
|
| 463 | + } |
|
| 464 | + // long |
|
| 359 | 465 | $data['verticalrate'] = ''; // vertical rate |
| 360 | 466 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 361 | 467 | $data['emergency'] = ''; // emergency |
| 362 | 468 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 363 | 469 | $data['format_source'] = 'deltadbtxt'; |
| 364 | 470 | $data['id_source'] = $id_source; |
| 365 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 366 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 471 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 472 | + $data['source_name'] = $value['name']; |
|
| 473 | + } |
|
| 474 | + if (isset($value['sourcestats'])) { |
|
| 475 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 476 | + } |
|
| 367 | 477 | $SI->add($data); |
| 368 | 478 | unset($data); |
| 369 | 479 | } |
@@ -386,10 +496,19 @@ discard block |
||
| 386 | 496 | $data['pilot_name'] = $line[2]; |
| 387 | 497 | $data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT); |
| 388 | 498 | $data['ident'] = $line[0]; // ident |
| 389 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 499 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 500 | + $data['altitude'] = $line[7]; |
|
| 501 | + } |
|
| 502 | + // altitude |
|
| 390 | 503 | $data['speed'] = $line[8]; // speed |
| 391 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 392 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 504 | + if (isset($line[45])) { |
|
| 505 | + $data['heading'] = $line[45]; |
|
| 506 | + } |
|
| 507 | + // heading |
|
| 508 | + elseif (isset($line[38])) { |
|
| 509 | + $data['heading'] = $line[38]; |
|
| 510 | + } |
|
| 511 | + // heading |
|
| 393 | 512 | $data['latitude'] = $line[5]; // lat |
| 394 | 513 | $data['longitude'] = $line[6]; // long |
| 395 | 514 | $data['verticalrate'] = ''; // vertical rate |
@@ -398,14 +517,18 @@ discard block |
||
| 398 | 517 | $data['waypoints'] = $line[30]; |
| 399 | 518 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 400 | 519 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 401 | - if (isset($line[37])) $data['last_update'] = $line[37]; |
|
| 520 | + if (isset($line[37])) { |
|
| 521 | + $data['last_update'] = $line[37]; |
|
| 522 | + } |
|
| 402 | 523 | $data['departure_airport_icao'] = $line[11]; |
| 403 | 524 | $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
| 404 | 525 | $data['arrival_airport_icao'] = $line[13]; |
| 405 | 526 | $data['frequency'] = $line[4]; |
| 406 | 527 | $data['type'] = $line[18]; |
| 407 | 528 | $data['range'] = $line[19]; |
| 408 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 529 | + if (isset($line[35])) { |
|
| 530 | + $data['info'] = $line[35]; |
|
| 531 | + } |
|
| 409 | 532 | $data['id_source'] = $id_source; |
| 410 | 533 | //$data['arrival_airport_time'] = ; |
| 411 | 534 | if ($line[9] != '') { |
@@ -419,23 +542,38 @@ discard block |
||
| 419 | 542 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 420 | 543 | */ |
| 421 | 544 | $data['format_source'] = $value['format']; |
| 422 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 423 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 424 | - elseif ($line[3] == 'ATC') { |
|
| 545 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 546 | + $data['source_name'] = $value['name']; |
|
| 547 | + } |
|
| 548 | + if ($line[3] == 'PILOT') { |
|
| 549 | + $SI->add($data); |
|
| 550 | + } elseif ($line[3] == 'ATC') { |
|
| 425 | 551 | //print_r($data); |
| 426 | 552 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 427 | 553 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 428 | 554 | $typec = substr($data['ident'],-3); |
| 429 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 430 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 431 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 432 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 433 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 434 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 435 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 436 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 437 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 438 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 555 | + if ($typec == 'APP') { |
|
| 556 | + $data['type'] = 'Approach'; |
|
| 557 | + } elseif ($typec == 'TWR') { |
|
| 558 | + $data['type'] = 'Tower'; |
|
| 559 | + } elseif ($typec == 'OBS') { |
|
| 560 | + $data['type'] = 'Observer'; |
|
| 561 | + } elseif ($typec == 'GND') { |
|
| 562 | + $data['type'] = 'Ground'; |
|
| 563 | + } elseif ($typec == 'DEL') { |
|
| 564 | + $data['type'] = 'Delivery'; |
|
| 565 | + } elseif ($typec == 'DEP') { |
|
| 566 | + $data['type'] = 'Departure'; |
|
| 567 | + } elseif ($typec == 'FSS') { |
|
| 568 | + $data['type'] = 'Flight Service Station'; |
|
| 569 | + } elseif ($typec == 'CTR') { |
|
| 570 | + $data['type'] = 'Control Radar or Centre'; |
|
| 571 | + } elseif ($data['type'] == '') { |
|
| 572 | + $data['type'] = 'Observer'; |
|
| 573 | + } |
|
| 574 | + if (!isset($data['source_name'])) { |
|
| 575 | + $data['source_name'] = ''; |
|
| 576 | + } |
|
| 439 | 577 | 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']); |
| 440 | 578 | } |
| 441 | 579 | unset($data); |
@@ -455,26 +593,55 @@ discard block |
||
| 455 | 593 | foreach ($all_data['acList'] as $line) { |
| 456 | 594 | $data = array(); |
| 457 | 595 | $data['hex'] = $line['Icao']; // hex |
| 458 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 459 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 460 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 461 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 462 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 463 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 596 | + if (isset($line['Call'])) { |
|
| 597 | + $data['ident'] = $line['Call']; |
|
| 598 | + } |
|
| 599 | + // ident |
|
| 600 | + if (isset($line['Alt'])) { |
|
| 601 | + $data['altitude'] = $line['Alt']; |
|
| 602 | + } |
|
| 603 | + // altitude |
|
| 604 | + if (isset($line['Spd'])) { |
|
| 605 | + $data['speed'] = $line['Spd']; |
|
| 606 | + } |
|
| 607 | + // speed |
|
| 608 | + if (isset($line['Trak'])) { |
|
| 609 | + $data['heading'] = $line['Trak']; |
|
| 610 | + } |
|
| 611 | + // heading |
|
| 612 | + if (isset($line['Lat'])) { |
|
| 613 | + $data['latitude'] = $line['Lat']; |
|
| 614 | + } |
|
| 615 | + // lat |
|
| 616 | + if (isset($line['Long'])) { |
|
| 617 | + $data['longitude'] = $line['Long']; |
|
| 618 | + } |
|
| 619 | + // long |
|
| 464 | 620 | //$data['verticalrate'] = $line['']; // verticale rate |
| 465 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 621 | + if (isset($line['Sqk'])) { |
|
| 622 | + $data['squawk'] = $line['Sqk']; |
|
| 623 | + } |
|
| 624 | + // squawk |
|
| 466 | 625 | $data['emergency'] = ''; // emergency |
| 467 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 626 | + if (isset($line['Reg'])) { |
|
| 627 | + $data['registration'] = $line['Reg']; |
|
| 628 | + } |
|
| 468 | 629 | /* |
| 469 | 630 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 470 | 631 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 471 | 632 | */ |
| 472 | 633 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 473 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 634 | + if (isset($line['Type'])) { |
|
| 635 | + $data['aircraft_icao'] = $line['Type']; |
|
| 636 | + } |
|
| 474 | 637 | $data['format_source'] = 'aircraftlistjson'; |
| 475 | 638 | $data['id_source'] = $id_source; |
| 476 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 477 | - if (isset($data['datetime'])) $SI->add($data); |
|
| 639 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 640 | + $data['source_name'] = $value['name']; |
|
| 641 | + } |
|
| 642 | + if (isset($data['datetime'])) { |
|
| 643 | + $SI->add($data); |
|
| 644 | + } |
|
| 478 | 645 | unset($data); |
| 479 | 646 | } |
| 480 | 647 | } else { |
@@ -494,7 +661,9 @@ discard block |
||
| 494 | 661 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 495 | 662 | $data['format_source'] = 'aircraftlistjson'; |
| 496 | 663 | $data['id_source'] = $id_source; |
| 497 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 664 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 665 | + $data['source_name'] = $value['name']; |
|
| 666 | + } |
|
| 498 | 667 | $SI->add($data); |
| 499 | 668 | unset($data); |
| 500 | 669 | } |
@@ -530,7 +699,9 @@ discard block |
||
| 530 | 699 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 531 | 700 | $data['format_source'] = 'planeupdatefaa'; |
| 532 | 701 | $data['id_source'] = $id_source; |
| 533 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 702 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 703 | + $data['source_name'] = $value['name']; |
|
| 704 | + } |
|
| 534 | 705 | $SI->add($data); |
| 535 | 706 | unset($data); |
| 536 | 707 | } |
@@ -570,7 +741,9 @@ discard block |
||
| 570 | 741 | //$buffer = $Common->getData($hosts[$id]); |
| 571 | 742 | $buffer = $Common->getData($value['host']); |
| 572 | 743 | $all_data = json_decode($buffer,true); |
| 573 | - if (!empty($all_data)) $reset = 0; |
|
| 744 | + if (!empty($all_data)) { |
|
| 745 | + $reset = 0; |
|
| 746 | + } |
|
| 574 | 747 | foreach ($all_data as $key => $line) { |
| 575 | 748 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 576 | 749 | $data = array(); |
@@ -591,7 +764,9 @@ discard block |
||
| 591 | 764 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 592 | 765 | $data['format_source'] = 'fr24json'; |
| 593 | 766 | $data['id_source'] = $id_source; |
| 594 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 767 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 768 | + $data['source_name'] = $value['name']; |
|
| 769 | + } |
|
| 595 | 770 | $SI->add($data); |
| 596 | 771 | unset($data); |
| 597 | 772 | } |
@@ -615,23 +790,39 @@ discard block |
||
| 615 | 790 | if (isset($line['inf'])) { |
| 616 | 791 | $data = array(); |
| 617 | 792 | $data['hex'] = $line['inf']['ia']; |
| 618 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 793 | + if (isset($line['inf']['cs'])) { |
|
| 794 | + $data['ident'] = $line['inf']['cs']; |
|
| 795 | + } |
|
| 796 | + //$line[13] |
|
| 619 | 797 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 620 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 621 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 798 | + if (isset($line['inf']['gs'])) { |
|
| 799 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 800 | + } |
|
| 801 | + // speed |
|
| 802 | + if (isset($line['inf']['tr'])) { |
|
| 803 | + $data['heading'] = $line['inf']['tr']; |
|
| 804 | + } |
|
| 805 | + // heading |
|
| 622 | 806 | $data['latitude'] = $line['pt'][0]; // lat |
| 623 | 807 | $data['longitude'] = $line['pt'][1]; // long |
| 624 | 808 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 625 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 809 | + if (isset($line['inf']['sq'])) { |
|
| 810 | + $data['squawk'] = $line['inf']['sq']; |
|
| 811 | + } |
|
| 812 | + // squawk |
|
| 626 | 813 | //$data['aircraft_icao'] = $line[8]; |
| 627 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 814 | + if (isset($line['inf']['rc'])) { |
|
| 815 | + $data['registration'] = $line['inf']['rc']; |
|
| 816 | + } |
|
| 628 | 817 | //$data['departure_airport_iata'] = $line[11]; |
| 629 | 818 | //$data['arrival_airport_iata'] = $line[12]; |
| 630 | 819 | //$data['emergency'] = ''; // emergency |
| 631 | 820 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 632 | 821 | $data['format_source'] = 'radarvirtueljson'; |
| 633 | 822 | $data['id_source'] = $id_source; |
| 634 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 823 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 824 | + $data['source_name'] = $value['name']; |
|
| 825 | + } |
|
| 635 | 826 | $SI->add($data); |
| 636 | 827 | unset($data); |
| 637 | 828 | } |
@@ -652,29 +843,62 @@ discard block |
||
| 652 | 843 | $data['id'] = $line['id']; |
| 653 | 844 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 654 | 845 | $data['ident'] = $line['callsign']; // ident |
| 655 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 656 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 657 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 658 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 659 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 660 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 846 | + if (isset($line['pilotid'])) { |
|
| 847 | + $data['pilot_id'] = $line['pilotid']; |
|
| 848 | + } |
|
| 849 | + // pilot id |
|
| 850 | + if (isset($line['name'])) { |
|
| 851 | + $data['pilot_name'] = $line['name']; |
|
| 852 | + } |
|
| 853 | + // pilot name |
|
| 854 | + if (isset($line['alt'])) { |
|
| 855 | + $data['altitude'] = $line['alt']; |
|
| 856 | + } |
|
| 857 | + // altitude |
|
| 858 | + if (isset($line['gs'])) { |
|
| 859 | + $data['speed'] = $line['gs']; |
|
| 860 | + } |
|
| 861 | + // speed |
|
| 862 | + if (isset($line['heading'])) { |
|
| 863 | + $data['heading'] = $line['heading']; |
|
| 864 | + } |
|
| 865 | + // heading |
|
| 866 | + if (isset($line['route'])) { |
|
| 867 | + $data['waypoints'] = $line['route']; |
|
| 868 | + } |
|
| 869 | + // route |
|
| 661 | 870 | $data['latitude'] = $line['lat']; // lat |
| 662 | 871 | $data['longitude'] = $line['lon']; // long |
| 663 | 872 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 664 | 873 | //$data['squawk'] = $line['squawk']; // squawk |
| 665 | 874 | //$data['emergency'] = ''; // emergency |
| 666 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 667 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 668 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 875 | + if (isset($line['depicao'])) { |
|
| 876 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 877 | + } |
|
| 878 | + if (isset($line['deptime'])) { |
|
| 879 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 880 | + } |
|
| 881 | + if (isset($line['arricao'])) { |
|
| 882 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 883 | + } |
|
| 669 | 884 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 670 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 671 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 672 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 673 | - else $data['info'] = ''; |
|
| 885 | + if (isset($line['aircraft'])) { |
|
| 886 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 887 | + } |
|
| 888 | + if (isset($line['transponder'])) { |
|
| 889 | + $data['squawk'] = $line['transponder']; |
|
| 890 | + } |
|
| 891 | + if (isset($line['atis'])) { |
|
| 892 | + $data['info'] = $line['atis']; |
|
| 893 | + } else { |
|
| 894 | + $data['info'] = ''; |
|
| 895 | + } |
|
| 674 | 896 | $data['format_source'] = 'pireps'; |
| 675 | 897 | $data['id_source'] = $id_source; |
| 676 | 898 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 677 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 899 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 900 | + $data['source_name'] = $value['name']; |
|
| 901 | + } |
|
| 678 | 902 | if ($line['icon'] == 'plane') { |
| 679 | 903 | $SI->add($data); |
| 680 | 904 | // print_r($data); |
@@ -683,15 +907,25 @@ discard block |
||
| 683 | 907 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 684 | 908 | $typec = substr($data['ident'],-3); |
| 685 | 909 | $data['type'] = ''; |
| 686 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 687 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 688 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 689 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 690 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 691 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 692 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 693 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 694 | - else $data['type'] = 'Observer'; |
|
| 910 | + if ($typec == 'APP') { |
|
| 911 | + $data['type'] = 'Approach'; |
|
| 912 | + } elseif ($typec == 'TWR') { |
|
| 913 | + $data['type'] = 'Tower'; |
|
| 914 | + } elseif ($typec == 'OBS') { |
|
| 915 | + $data['type'] = 'Observer'; |
|
| 916 | + } elseif ($typec == 'GND') { |
|
| 917 | + $data['type'] = 'Ground'; |
|
| 918 | + } elseif ($typec == 'DEL') { |
|
| 919 | + $data['type'] = 'Delivery'; |
|
| 920 | + } elseif ($typec == 'DEP') { |
|
| 921 | + $data['type'] = 'Departure'; |
|
| 922 | + } elseif ($typec == 'FSS') { |
|
| 923 | + $data['type'] = 'Flight Service Station'; |
|
| 924 | + } elseif ($typec == 'CTR') { |
|
| 925 | + $data['type'] = 'Control Radar or Centre'; |
|
| 926 | + } else { |
|
| 927 | + $data['type'] = 'Observer'; |
|
| 928 | + } |
|
| 695 | 929 | 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']); |
| 696 | 930 | } |
| 697 | 931 | unset($data); |
@@ -702,7 +936,9 @@ discard block |
||
| 702 | 936 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 703 | 937 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 704 | 938 | //$buffer = $Common->getData($hosts[$id]); |
| 705 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 939 | + if ($globalDebug) { |
|
| 940 | + echo 'Get Data...'."\n"; |
|
| 941 | + } |
|
| 706 | 942 | $buffer = $Common->getData($value['host']); |
| 707 | 943 | $all_data = json_decode($buffer,true); |
| 708 | 944 | if ($buffer != '' && is_array($all_data)) { |
@@ -710,10 +946,16 @@ discard block |
||
| 710 | 946 | foreach ($all_data as $line) { |
| 711 | 947 | $data = array(); |
| 712 | 948 | //$data['id'] = $line['id']; // id not usable |
| 713 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 949 | + if (isset($line['pilotid'])) { |
|
| 950 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 951 | + } |
|
| 714 | 952 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 715 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 716 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 953 | + if (isset($line['pilotname'])) { |
|
| 954 | + $data['pilot_name'] = $line['pilotname']; |
|
| 955 | + } |
|
| 956 | + if (isset($line['pilotid'])) { |
|
| 957 | + $data['pilot_id'] = $line['pilotid']; |
|
| 958 | + } |
|
| 717 | 959 | $data['ident'] = $line['flightnum']; // ident |
| 718 | 960 | $data['altitude'] = $line['alt']; // altitude |
| 719 | 961 | $data['speed'] = $line['gs']; // speed |
@@ -731,27 +973,41 @@ discard block |
||
| 731 | 973 | $data['arrival_airport_icao'] = $line['arricao']; |
| 732 | 974 | $data['arrival_airport_time'] = $line['arrtime']; |
| 733 | 975 | $data['registration'] = $line['aircraft']; |
| 734 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 976 | + if (isset($line['route'])) { |
|
| 977 | + $data['waypoints'] = $line['route']; |
|
| 978 | + } |
|
| 979 | + // route |
|
| 735 | 980 | if (isset($line['aircraftname'])) { |
| 736 | 981 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 737 | 982 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 738 | 983 | $aircraft_data = explode('-',$line['aircraftname']); |
| 739 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 740 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 741 | - else { |
|
| 984 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) { |
|
| 985 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 986 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) { |
|
| 987 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 988 | + } else { |
|
| 742 | 989 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 743 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 744 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 990 | + if (isset($aircraft_data[1])) { |
|
| 991 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 992 | + } else { |
|
| 993 | + $data['aircraft_icao'] = $line['aircraftname']; |
|
| 994 | + } |
|
| 745 | 995 | } |
| 746 | 996 | } |
| 747 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 997 | + if (isset($line['route'])) { |
|
| 998 | + $data['waypoints'] = $line['route']; |
|
| 999 | + } |
|
| 748 | 1000 | $data['id_source'] = $id_source; |
| 749 | 1001 | $data['format_source'] = 'phpvmacars'; |
| 750 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1002 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1003 | + $data['source_name'] = $value['name']; |
|
| 1004 | + } |
|
| 751 | 1005 | $SI->add($data); |
| 752 | 1006 | unset($data); |
| 753 | 1007 | } |
| 754 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1008 | + if ($globalDebug) { |
|
| 1009 | + echo 'No more data...'."\n"; |
|
| 1010 | + } |
|
| 755 | 1011 | unset($buffer); |
| 756 | 1012 | unset($all_data); |
| 757 | 1013 | } |
@@ -759,7 +1015,9 @@ discard block |
||
| 759 | 1015 | $last_exec[$id]['last'] = time(); |
| 760 | 1016 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 761 | 1017 | //$buffer = $Common->getData($hosts[$id]); |
| 762 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1018 | + if ($globalDebug) { |
|
| 1019 | + echo 'Get Data...'."\n"; |
|
| 1020 | + } |
|
| 763 | 1021 | $buffer = $Common->getData($value['host']); |
| 764 | 1022 | $all_data = json_decode($buffer,true); |
| 765 | 1023 | if ($buffer != '' && is_array($all_data)) { |
@@ -788,15 +1046,22 @@ discard block |
||
| 788 | 1046 | $data['arrival_airport_icao'] = $line['arrival']; |
| 789 | 1047 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 790 | 1048 | //$data['registration'] = $line['aircraft']; |
| 791 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1049 | + if (isset($line['route'])) { |
|
| 1050 | + $data['waypoints'] = $line['route']; |
|
| 1051 | + } |
|
| 1052 | + // route |
|
| 792 | 1053 | $data['aircraft_icao'] = $line['plane_type']; |
| 793 | 1054 | $data['id_source'] = $id_source; |
| 794 | 1055 | $data['format_source'] = 'vam'; |
| 795 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1056 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1057 | + $data['source_name'] = $value['name']; |
|
| 1058 | + } |
|
| 796 | 1059 | $SI->add($data); |
| 797 | 1060 | unset($data); |
| 798 | 1061 | } |
| 799 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1062 | + if ($globalDebug) { |
|
| 1063 | + echo 'No more data...'."\n"; |
|
| 1064 | + } |
|
| 800 | 1065 | unset($buffer); |
| 801 | 1066 | unset($all_data); |
| 802 | 1067 | } |
@@ -804,7 +1069,9 @@ discard block |
||
| 804 | 1069 | $last_exec[$id]['last'] = time(); |
| 805 | 1070 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 806 | 1071 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') { |
| 807 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1072 | + if (function_exists('pcntl_fork')) { |
|
| 1073 | + pcntl_signal_dispatch(); |
|
| 1074 | + } |
|
| 808 | 1075 | //$last_exec[$id]['last'] = time(); |
| 809 | 1076 | |
| 810 | 1077 | //$read = array( $sockets[$id] ); |
@@ -812,7 +1079,9 @@ discard block |
||
| 812 | 1079 | $write = NULL; |
| 813 | 1080 | $e = NULL; |
| 814 | 1081 | $n = socket_select($read, $write, $e, $timeout); |
| 815 | - if ($e != NULL) var_dump($e); |
|
| 1082 | + if ($e != NULL) { |
|
| 1083 | + var_dump($e); |
|
| 1084 | + } |
|
| 816 | 1085 | if ($n > 0) { |
| 817 | 1086 | $reset = 0; |
| 818 | 1087 | foreach ($read as $nb => $r) { |
@@ -834,7 +1103,9 @@ discard block |
||
| 834 | 1103 | if ($buffer != '') { |
| 835 | 1104 | $tt[$format] = 0; |
| 836 | 1105 | if ($format == 'acarssbs3') { |
| 837 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1106 | + if ($globalDebug) { |
|
| 1107 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1108 | + } |
|
| 838 | 1109 | $ACARS->add(trim($buffer)); |
| 839 | 1110 | $ACARS->deleteLiveAcarsData(); |
| 840 | 1111 | } elseif ($format == 'raw') { |
@@ -843,9 +1114,15 @@ discard block |
||
| 843 | 1114 | if (is_array($data)) { |
| 844 | 1115 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 845 | 1116 | $data['format_source'] = 'raw'; |
| 846 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 847 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 848 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1117 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1118 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1119 | + } |
|
| 1120 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1121 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1122 | + } |
|
| 1123 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1124 | + $SI->add($data); |
|
| 1125 | + } |
|
| 849 | 1126 | } |
| 850 | 1127 | } elseif ($format == 'flightgearsp') { |
| 851 | 1128 | //echo $buffer."\n"; |
@@ -863,11 +1140,15 @@ discard block |
||
| 863 | 1140 | $data['speed'] = round($line[5]*1.94384); |
| 864 | 1141 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 865 | 1142 | $data['format_source'] = 'flightgearsp'; |
| 866 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1143 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1144 | + $SI->add($data); |
|
| 1145 | + } |
|
| 867 | 1146 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 868 | 1147 | } |
| 869 | 1148 | } elseif ($format == 'acars') { |
| 870 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1149 | + if ($globalDebug) { |
|
| 1150 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1151 | + } |
|
| 871 | 1152 | $ACARS->add(trim($buffer)); |
| 872 | 1153 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 873 | 1154 | $ACARS->deleteLiveAcarsData(); |
@@ -888,7 +1169,9 @@ discard block |
||
| 888 | 1169 | $aircraft_type = $line[10]; |
| 889 | 1170 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 890 | 1171 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 891 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1172 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1173 | + $SI->add($data); |
|
| 1174 | + } |
|
| 892 | 1175 | } |
| 893 | 1176 | } |
| 894 | 1177 | } elseif ($format == 'beast') { |
@@ -904,21 +1187,43 @@ discard block |
||
| 904 | 1187 | $data['hex'] = $lined['hexid']; |
| 905 | 1188 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 906 | 1189 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 907 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 908 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 909 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 910 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 911 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 912 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 913 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1190 | + if (isset($lined['ident'])) { |
|
| 1191 | + $data['ident'] = $lined['ident']; |
|
| 1192 | + } |
|
| 1193 | + if (isset($lined['lat'])) { |
|
| 1194 | + $data['latitude'] = $lined['lat']; |
|
| 1195 | + } |
|
| 1196 | + if (isset($lined['lon'])) { |
|
| 1197 | + $data['longitude'] = $lined['lon']; |
|
| 1198 | + } |
|
| 1199 | + if (isset($lined['speed'])) { |
|
| 1200 | + $data['speed'] = $lined['speed']; |
|
| 1201 | + } |
|
| 1202 | + if (isset($lined['squawk'])) { |
|
| 1203 | + $data['squawk'] = $lined['squawk']; |
|
| 1204 | + } |
|
| 1205 | + if (isset($lined['alt'])) { |
|
| 1206 | + $data['altitude'] = $lined['alt']; |
|
| 1207 | + } |
|
| 1208 | + if (isset($lined['heading'])) { |
|
| 1209 | + $data['heading'] = $lined['heading']; |
|
| 1210 | + } |
|
| 914 | 1211 | $data['id_source'] = $id_source; |
| 915 | 1212 | $data['format_source'] = 'tsv'; |
| 916 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 917 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 918 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1213 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1214 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1215 | + } |
|
| 1216 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1217 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1218 | + } |
|
| 1219 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1220 | + $SI->add($data); |
|
| 1221 | + } |
|
| 919 | 1222 | unset($lined); |
| 920 | 1223 | unset($data); |
| 921 | - } else $error = true; |
|
| 1224 | + } else { |
|
| 1225 | + $error = true; |
|
| 1226 | + } |
|
| 922 | 1227 | } elseif ($format == 'aprs' && $use_aprs) { |
| 923 | 1228 | if ($aprs_connect == 0) { |
| 924 | 1229 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -944,29 +1249,44 @@ discard block |
||
| 944 | 1249 | $data['latitude'] = $line['latitude']; |
| 945 | 1250 | $data['longitude'] = $line['longitude']; |
| 946 | 1251 | //$data['verticalrate'] = $line[16]; |
| 947 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 948 | - else $data['speed'] = 0; |
|
| 1252 | + if (isset($line['speed'])) { |
|
| 1253 | + $data['speed'] = $line['speed']; |
|
| 1254 | + } else { |
|
| 1255 | + $data['speed'] = 0; |
|
| 1256 | + } |
|
| 949 | 1257 | $data['altitude'] = $line['altitude']; |
| 950 | - if (isset($line['course'])) $data['heading'] = $line['course']; |
|
| 1258 | + if (isset($line['course'])) { |
|
| 1259 | + $data['heading'] = $line['course']; |
|
| 1260 | + } |
|
| 951 | 1261 | //else $data['heading'] = 0; |
| 952 | 1262 | $data['aircraft_type'] = $line['stealth']; |
| 953 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 1263 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
| 1264 | + $data['noarchive'] = true; |
|
| 1265 | + } |
|
| 954 | 1266 | $data['id_source'] = $id_source; |
| 955 | 1267 | $data['format_source'] = 'aprs'; |
| 956 | 1268 | $data['source_name'] = $line['source']; |
| 957 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1269 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1270 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1271 | + } |
|
| 958 | 1272 | $currentdate = date('Y-m-d H:i:s'); |
| 959 | 1273 | $aprsdate = strtotime($data['datetime']); |
| 960 | 1274 | // Accept data if time <= system time + 20s |
| 961 | - if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
| 962 | - else { |
|
| 963 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 964 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1275 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1276 | + $send = $SI->add($data); |
|
| 1277 | + } else { |
|
| 1278 | + if ($line['stealth'] != 0) { |
|
| 1279 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1280 | + } else { |
|
| 1281 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1282 | + } |
|
| 965 | 1283 | } |
| 966 | 1284 | unset($data); |
| 967 | 1285 | } |
| 968 | 1286 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 969 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 1287 | + elseif ($line == true && $globalDebug) { |
|
| 1288 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 1289 | + } |
|
| 970 | 1290 | } |
| 971 | 1291 | } else { |
| 972 | 1292 | $line = explode(',', $buffer); |
@@ -995,25 +1315,42 @@ discard block |
||
| 995 | 1315 | $data['ground'] = $line[21]; |
| 996 | 1316 | $data['emergency'] = $line[19]; |
| 997 | 1317 | $data['format_source'] = 'sbs'; |
| 998 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 999 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1318 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1319 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1320 | + } |
|
| 1321 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1322 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1323 | + } |
|
| 1000 | 1324 | $data['id_source'] = $id_source; |
| 1001 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1002 | - else $error = true; |
|
| 1325 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1326 | + $send = $SI->add($data); |
|
| 1327 | + } else { |
|
| 1328 | + $error = true; |
|
| 1329 | + } |
|
| 1003 | 1330 | unset($data); |
| 1004 | - } else $error = true; |
|
| 1331 | + } else { |
|
| 1332 | + $error = true; |
|
| 1333 | + } |
|
| 1005 | 1334 | if ($error) { |
| 1006 | 1335 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1007 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 1336 | + if ($globalDebug) { |
|
| 1337 | + echo "Not a message. Ignoring... \n"; |
|
| 1338 | + } |
|
| 1008 | 1339 | } else { |
| 1009 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 1340 | + if ($globalDebug) { |
|
| 1341 | + echo "Wrong line format. Ignoring... \n"; |
|
| 1342 | + } |
|
| 1010 | 1343 | if ($globalDebug) { |
| 1011 | 1344 | echo $buffer; |
| 1012 | 1345 | print_r($line); |
| 1013 | 1346 | } |
| 1014 | 1347 | //socket_close($r); |
| 1015 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1016 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 1348 | + if ($globalDebug) { |
|
| 1349 | + echo "Reconnect after an error...\n"; |
|
| 1350 | + } |
|
| 1351 | + if ($format == 'aprs') { |
|
| 1352 | + $aprs_connect = 0; |
|
| 1353 | + } |
|
| 1017 | 1354 | $sourceer[$nb] = $globalSources[$nb]; |
| 1018 | 1355 | connect_all($sourceer); |
| 1019 | 1356 | $sourceer = array(); |
@@ -1021,10 +1358,14 @@ discard block |
||
| 1021 | 1358 | } |
| 1022 | 1359 | } |
| 1023 | 1360 | // Sleep for xxx microseconds |
| 1024 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 1361 | + if (isset($globalSBSSleep)) { |
|
| 1362 | + usleep($globalSBSSleep); |
|
| 1363 | + } |
|
| 1025 | 1364 | } else { |
| 1026 | 1365 | if ($format == 'flightgearmp') { |
| 1027 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1366 | + if ($globalDebug) { |
|
| 1367 | + echo "Reconnect FlightGear MP..."; |
|
| 1368 | + } |
|
| 1028 | 1369 | //@socket_close($r); |
| 1029 | 1370 | sleep($globalMinFetch); |
| 1030 | 1371 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1033,10 +1374,15 @@ discard block |
||
| 1033 | 1374 | break; |
| 1034 | 1375 | |
| 1035 | 1376 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1036 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1037 | - else $tt[$format] = 0; |
|
| 1377 | + if (isset($tt[$format])) { |
|
| 1378 | + $tt[$format]++; |
|
| 1379 | + } else { |
|
| 1380 | + $tt[$format] = 0; |
|
| 1381 | + } |
|
| 1038 | 1382 | if ($tt[$format] > 30) { |
| 1039 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 1383 | + if ($globalDebug) { |
|
| 1384 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 1385 | + } |
|
| 1040 | 1386 | //@socket_close($r); |
| 1041 | 1387 | sleep(2); |
| 1042 | 1388 | $aprs_connect = 0; |
@@ -1052,12 +1398,18 @@ discard block |
||
| 1052 | 1398 | } |
| 1053 | 1399 | } else { |
| 1054 | 1400 | $error = socket_strerror(socket_last_error()); |
| 1055 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1401 | + if ($globalDebug) { |
|
| 1402 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1403 | + } |
|
| 1056 | 1404 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
| 1057 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 1405 | + if (isset($globalDebug)) { |
|
| 1406 | + echo "Restarting...\n"; |
|
| 1407 | + } |
|
| 1058 | 1408 | // Restart the script if possible |
| 1059 | 1409 | if (is_array($sockets)) { |
| 1060 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1410 | + if ($globalDebug) { |
|
| 1411 | + echo "Shutdown all sockets..."; |
|
| 1412 | + } |
|
| 1061 | 1413 | |
| 1062 | 1414 | foreach ($sockets as $sock) { |
| 1063 | 1415 | @socket_shutdown($sock,2); |
@@ -1065,18 +1417,24 @@ discard block |
||
| 1065 | 1417 | } |
| 1066 | 1418 | |
| 1067 | 1419 | } |
| 1068 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 1420 | + if ($globalDebug) { |
|
| 1421 | + echo "Restart all connections..."; |
|
| 1422 | + } |
|
| 1069 | 1423 | sleep(2); |
| 1070 | 1424 | $time = time(); |
| 1071 | 1425 | //connect_all($hosts); |
| 1072 | 1426 | $aprs_connect = 0; |
| 1073 | - if ($reset > 40) exit('Too many attempts...'); |
|
| 1427 | + if ($reset > 40) { |
|
| 1428 | + exit('Too many attempts...'); |
|
| 1429 | + } |
|
| 1074 | 1430 | connect_all($globalSources); |
| 1075 | 1431 | } |
| 1076 | 1432 | } |
| 1077 | 1433 | } |
| 1078 | 1434 | if ($globalDaemon === false) { |
| 1079 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1435 | + if ($globalDebug) { |
|
| 1436 | + echo 'Check all...'."\n"; |
|
| 1437 | + } |
|
| 1080 | 1438 | $SI->checkAll(); |
| 1081 | 1439 | } |
| 1082 | 1440 | } |