@@ -19,44 +19,44 @@ 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 | |
| 26 | 26 | |
| 27 | 27 | // This is to be compatible with old version of settings.php |
| 28 | 28 | if (!isset($globalSources)) { |
| 29 | - if (isset($globalSBS1Hosts)) { |
|
| 30 | - //$hosts = $globalSBS1Hosts; |
|
| 31 | - foreach ($globalSBS1Hosts as $host) { |
|
| 32 | - $globalSources[] = array('host' => $host); |
|
| 33 | - } |
|
| 34 | - } else { |
|
| 35 | - if (!isset($globalSBS1Host)) { |
|
| 36 | - echo '$globalSources MUST be defined !'; |
|
| 37 | - die; |
|
| 29 | + if (isset($globalSBS1Hosts)) { |
|
| 30 | + //$hosts = $globalSBS1Hosts; |
|
| 31 | + foreach ($globalSBS1Hosts as $host) { |
|
| 32 | + $globalSources[] = array('host' => $host); |
|
| 33 | + } |
|
| 34 | + } else { |
|
| 35 | + if (!isset($globalSBS1Host)) { |
|
| 36 | + echo '$globalSources MUST be defined !'; |
|
| 37 | + die; |
|
| 38 | 38 | } |
| 39 | 39 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 40 | 40 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $options = getopt('s::',array('source::','server','idsource::')); |
| 45 | 45 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 46 | 46 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 47 | 47 | if (isset($options['s'])) { |
| 48 | - $globalSources = array(); |
|
| 49 | - $globalSources[] = array('host' => $options['s']); |
|
| 48 | + $globalSources = array(); |
|
| 49 | + $globalSources[] = array('host' => $options['s']); |
|
| 50 | 50 | } elseif (isset($options['source'])) { |
| 51 | - $globalSources = array(); |
|
| 52 | - $globalSources[] = array('host' => $options['source']); |
|
| 51 | + $globalSources = array(); |
|
| 52 | + $globalSources[] = array('host' => $options['source']); |
|
| 53 | 53 | } |
| 54 | 54 | if (isset($options['server'])) $globalServer = TRUE; |
| 55 | 55 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 56 | 56 | else $id_source = 1; |
| 57 | 57 | if (isset($globalServer) && $globalServer) { |
| 58 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 59 | - $SI=new SpotterServer(); |
|
| 58 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 59 | + $SI=new SpotterServer(); |
|
| 60 | 60 | } else $SI=new SpotterImport($Connection->db); |
| 61 | 61 | //$APRS=new APRS($Connection->db); |
| 62 | 62 | $SBS=new SBS($Connection->db); |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | //$servertz = system('date +%Z'); |
| 67 | 67 | // signal handler - playing nice with sockets and dump1090 |
| 68 | 68 | if (function_exists('pcntl_fork')) { |
| 69 | - pcntl_signal(SIGINT, function($signo) { |
|
| 70 | - global $sockets; |
|
| 71 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 72 | - die("Bye!\n"); |
|
| 73 | - }); |
|
| 74 | - pcntl_signal_dispatch(); |
|
| 69 | + pcntl_signal(SIGINT, function($signo) { |
|
| 70 | + global $sockets; |
|
| 71 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 72 | + die("Bye!\n"); |
|
| 73 | + }); |
|
| 74 | + pcntl_signal_dispatch(); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // let's try and connect |
@@ -80,156 +80,156 @@ discard block |
||
| 80 | 80 | $aprs_full = false; |
| 81 | 81 | |
| 82 | 82 | function create_socket($host, $port, &$errno, &$errstr) { |
| 83 | - $ip = gethostbyname($host); |
|
| 84 | - $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 85 | - $r = @socket_connect($s, $ip, $port); |
|
| 86 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 87 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 88 | - return $s; |
|
| 89 | - } |
|
| 90 | - $errno = socket_last_error($s); |
|
| 91 | - $errstr = socket_strerror($errno); |
|
| 92 | - socket_close($s); |
|
| 93 | - return false; |
|
| 83 | + $ip = gethostbyname($host); |
|
| 84 | + $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 85 | + $r = @socket_connect($s, $ip, $port); |
|
| 86 | + if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 87 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 88 | + return $s; |
|
| 89 | + } |
|
| 90 | + $errno = socket_last_error($s); |
|
| 91 | + $errstr = socket_strerror($errno); |
|
| 92 | + socket_close($s); |
|
| 93 | + return false; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | function create_socket_udp($host, $port, &$errno, &$errstr) { |
| 97 | - echo "UDP !!"; |
|
| 98 | - $ip = gethostbyname($host); |
|
| 99 | - $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
| 100 | - $r = @socket_bind($s, $ip, $port); |
|
| 101 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 102 | - return $s; |
|
| 103 | - } |
|
| 104 | - $errno = socket_last_error($s); |
|
| 105 | - $errstr = socket_strerror($errno); |
|
| 106 | - socket_close($s); |
|
| 107 | - return false; |
|
| 97 | + echo "UDP !!"; |
|
| 98 | + $ip = gethostbyname($host); |
|
| 99 | + $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
| 100 | + $r = @socket_bind($s, $ip, $port); |
|
| 101 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 102 | + return $s; |
|
| 103 | + } |
|
| 104 | + $errno = socket_last_error($s); |
|
| 105 | + $errstr = socket_strerror($errno); |
|
| 106 | + socket_close($s); |
|
| 107 | + return false; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | function connect_all($hosts) { |
| 111 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 112 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 113 | - foreach ($hosts as $id => $value) { |
|
| 111 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 112 | + global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 113 | + foreach ($hosts as $id => $value) { |
|
| 114 | 114 | $host = $value['host']; |
| 115 | 115 | $globalSources[$id]['last_exec'] = 0; |
| 116 | 116 | // Here we check type of source(s) |
| 117 | 117 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 118 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 119 | - //$formats[$id] = 'deltadbtxt'; |
|
| 120 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 121 | - //$last_exec['deltadbtxt'] = 0; |
|
| 122 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 123 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 124 | - //$formats[$id] = 'vatsimtxt'; |
|
| 125 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 126 | - //$last_exec['vatsimtxt'] = 0; |
|
| 127 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 128 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 129 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 130 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 131 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 132 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 133 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 134 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 135 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 136 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 137 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 138 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 139 | - //$formats[$id] = 'radarvirtueljson'; |
|
| 140 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 141 | - //$last_exec['radarvirtueljson'] = 0; |
|
| 142 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 143 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 144 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 145 | - exit(0); |
|
| 146 | - } |
|
| 147 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 148 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 149 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 150 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 151 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 152 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 153 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 154 | - exit(0); |
|
| 155 | - } |
|
| 156 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 157 | - //$formats[$id] = 'phpvmacars'; |
|
| 158 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 159 | - //$last_exec['phpvmacars'] = 0; |
|
| 160 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 162 | - //$formats[$id] = 'whazzup'; |
|
| 163 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 164 | - //$last_exec['whazzup'] = 0; |
|
| 165 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 167 | - //$formats[$id] = 'pirepsjson'; |
|
| 168 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 169 | - //$last_exec['pirepsjson'] = 0; |
|
| 170 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 172 | - //$formats[$id] = 'fr24json'; |
|
| 173 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 174 | - //$last_exec['fr24json'] = 0; |
|
| 175 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 176 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 177 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 178 | - exit(0); |
|
| 179 | - } |
|
| 180 | - //} else if (preg_match('/10001/',$host)) { |
|
| 181 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 182 | - //$formats[$id] = 'tsv'; |
|
| 183 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 184 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 185 | - } |
|
| 186 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 187 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 188 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 189 | - $hostport = explode(':',$host); |
|
| 190 | - if (isset($hostport[1])) { |
|
| 118 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 119 | + //$formats[$id] = 'deltadbtxt'; |
|
| 120 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 121 | + //$last_exec['deltadbtxt'] = 0; |
|
| 122 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 123 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 124 | + //$formats[$id] = 'vatsimtxt'; |
|
| 125 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 126 | + //$last_exec['vatsimtxt'] = 0; |
|
| 127 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 128 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 129 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 130 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 131 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 132 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 133 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 134 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 135 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 136 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 137 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 138 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 139 | + //$formats[$id] = 'radarvirtueljson'; |
|
| 140 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 141 | + //$last_exec['radarvirtueljson'] = 0; |
|
| 142 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 143 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 144 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 145 | + exit(0); |
|
| 146 | + } |
|
| 147 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 148 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 149 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 150 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 151 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 152 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 153 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 154 | + exit(0); |
|
| 155 | + } |
|
| 156 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 157 | + //$formats[$id] = 'phpvmacars'; |
|
| 158 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 159 | + //$last_exec['phpvmacars'] = 0; |
|
| 160 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 161 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 162 | + //$formats[$id] = 'whazzup'; |
|
| 163 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 164 | + //$last_exec['whazzup'] = 0; |
|
| 165 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 166 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 167 | + //$formats[$id] = 'pirepsjson'; |
|
| 168 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 169 | + //$last_exec['pirepsjson'] = 0; |
|
| 170 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 172 | + //$formats[$id] = 'fr24json'; |
|
| 173 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 174 | + //$last_exec['fr24json'] = 0; |
|
| 175 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 176 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 177 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 178 | + exit(0); |
|
| 179 | + } |
|
| 180 | + //} else if (preg_match('/10001/',$host)) { |
|
| 181 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 182 | + //$formats[$id] = 'tsv'; |
|
| 183 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 184 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 185 | + } |
|
| 186 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 187 | + if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 188 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 189 | + $hostport = explode(':',$host); |
|
| 190 | + if (isset($hostport[1])) { |
|
| 191 | 191 | $port = $hostport[1]; |
| 192 | 192 | $hostn = $hostport[0]; |
| 193 | - } else { |
|
| 193 | + } else { |
|
| 194 | 194 | $port = $globalSources[$id]['port']; |
| 195 | 195 | $hostn = $globalSources[$id]['host']; |
| 196 | - } |
|
| 197 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 198 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 199 | - } else { |
|
| 200 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 201 | - } |
|
| 202 | - if ($s) { |
|
| 203 | - $sockets[$id] = $s; |
|
| 204 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 205 | - if (preg_match('/aprs/',$hostn)) { |
|
| 196 | + } |
|
| 197 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 198 | + $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 199 | + } else { |
|
| 200 | + $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 201 | + } |
|
| 202 | + if ($s) { |
|
| 203 | + $sockets[$id] = $s; |
|
| 204 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 205 | + if (preg_match('/aprs/',$hostn)) { |
|
| 206 | 206 | //$formats[$id] = 'aprs'; |
| 207 | 207 | $globalSources[$id]['format'] = 'aprs'; |
| 208 | 208 | //$aprs_connect = 0; |
| 209 | 209 | //$use_aprs = true; |
| 210 | - } elseif ($port == '10001') { |
|
| 211 | - //$formats[$id] = 'tsv'; |
|
| 212 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 213 | - } elseif ($port == '30002') { |
|
| 214 | - //$formats[$id] = 'raw'; |
|
| 215 | - $globalSources[$id]['format'] = 'raw'; |
|
| 216 | - } elseif ($port == '5001') { |
|
| 217 | - //$formats[$id] = 'raw'; |
|
| 218 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 219 | - } elseif ($port == '30005') { |
|
| 210 | + } elseif ($port == '10001') { |
|
| 211 | + //$formats[$id] = 'tsv'; |
|
| 212 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 213 | + } elseif ($port == '30002') { |
|
| 214 | + //$formats[$id] = 'raw'; |
|
| 215 | + $globalSources[$id]['format'] = 'raw'; |
|
| 216 | + } elseif ($port == '5001') { |
|
| 217 | + //$formats[$id] = 'raw'; |
|
| 218 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 219 | + } elseif ($port == '30005') { |
|
| 220 | 220 | // Not yet supported |
| 221 | - //$formats[$id] = 'beast'; |
|
| 222 | - $globalSources[$id]['format'] = 'beast'; |
|
| 223 | - //} else $formats[$id] = 'sbs'; |
|
| 224 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 225 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 221 | + //$formats[$id] = 'beast'; |
|
| 222 | + $globalSources[$id]['format'] = 'beast'; |
|
| 223 | + //} else $formats[$id] = 'sbs'; |
|
| 224 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 225 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 226 | 226 | } |
| 227 | 227 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 228 | - } else { |
|
| 228 | + } else { |
|
| 229 | 229 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 230 | - } |
|
| 231 | - } |
|
| 232 | - } |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | 233 | } |
| 234 | 234 | if (!isset($globalMinFetch)) $globalMinFetch = 0; |
| 235 | 235 | |
@@ -252,14 +252,14 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | // APRS Configuration |
| 254 | 254 | foreach ($globalSources as $key => $source) { |
| 255 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 255 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 256 | 256 | $aprs_connect = 0; |
| 257 | 257 | $use_aprs = true; |
| 258 | 258 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 259 | 259 | break; |
| 260 | - } elseif (!isset($source['format'])) { |
|
| 261 | - $globalSources[$key]['format'] = 'auto'; |
|
| 262 | - } |
|
| 260 | + } elseif (!isset($source['format'])) { |
|
| 261 | + $globalSources[$key]['format'] = 'auto'; |
|
| 262 | + } |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | if ($use_aprs) { |
@@ -299,52 +299,52 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 301 | 301 | while ($i > 0) { |
| 302 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 303 | - // Delete old ATC |
|
| 304 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 305 | - $ATC->deleteOldATC(); |
|
| 306 | - } |
|
| 307 | - //foreach ($formats as $id => $value) { |
|
| 308 | - foreach ($globalSources as $id => $value) { |
|
| 302 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 303 | + // Delete old ATC |
|
| 304 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 305 | + $ATC->deleteOldATC(); |
|
| 306 | + } |
|
| 307 | + //foreach ($formats as $id => $value) { |
|
| 308 | + foreach ($globalSources as $id => $value) { |
|
| 309 | 309 | if ($value['format'] == 'deltadbtxt' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 310 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 311 | - $buffer = $Common->getData($value['host']); |
|
| 312 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 313 | - $buffer = explode('\n',$buffer); |
|
| 314 | - foreach ($buffer as $line) { |
|
| 315 | - if ($line != '') { |
|
| 316 | - $line = explode(',', $line); |
|
| 317 | - $data = array(); |
|
| 318 | - $data['hex'] = $line[1]; // hex |
|
| 319 | - $data['ident'] = $line[2]; // ident |
|
| 320 | - $data['altitude'] = $line[3]; // altitude |
|
| 321 | - $data['speed'] = $line[4]; // speed |
|
| 322 | - $data['heading'] = $line[5]; // heading |
|
| 323 | - $data['latitude'] = $line[6]; // lat |
|
| 324 | - $data['longitude'] = $line[7]; // long |
|
| 325 | - $data['verticalrate'] = ''; // vertical rate |
|
| 326 | - $data['squawk'] = ''; // squawk |
|
| 327 | - $data['emergency'] = ''; // emergency |
|
| 328 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 329 | - $data['format_source'] = 'deltadbtxt'; |
|
| 330 | - $data['id_source'] = $id_source; |
|
| 331 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 332 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 333 | - $SI->add($data); |
|
| 334 | - unset($data); |
|
| 335 | - } |
|
| 336 | - } |
|
| 337 | - $value['last_exec'] = time(); |
|
| 310 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 311 | + $buffer = $Common->getData($value['host']); |
|
| 312 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 313 | + $buffer = explode('\n',$buffer); |
|
| 314 | + foreach ($buffer as $line) { |
|
| 315 | + if ($line != '') { |
|
| 316 | + $line = explode(',', $line); |
|
| 317 | + $data = array(); |
|
| 318 | + $data['hex'] = $line[1]; // hex |
|
| 319 | + $data['ident'] = $line[2]; // ident |
|
| 320 | + $data['altitude'] = $line[3]; // altitude |
|
| 321 | + $data['speed'] = $line[4]; // speed |
|
| 322 | + $data['heading'] = $line[5]; // heading |
|
| 323 | + $data['latitude'] = $line[6]; // lat |
|
| 324 | + $data['longitude'] = $line[7]; // long |
|
| 325 | + $data['verticalrate'] = ''; // vertical rate |
|
| 326 | + $data['squawk'] = ''; // squawk |
|
| 327 | + $data['emergency'] = ''; // emergency |
|
| 328 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 329 | + $data['format_source'] = 'deltadbtxt'; |
|
| 330 | + $data['id_source'] = $id_source; |
|
| 331 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 332 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 333 | + $SI->add($data); |
|
| 334 | + unset($data); |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + $value['last_exec'] = time(); |
|
| 338 | 338 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 339 | 339 | } elseif (($value['format'] == 'whazzup' && (time() - $value['last_exec'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value['last_exec'] > $globalMinFetch))) { |
| 340 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 341 | - $buffer = $Common->getData($value['host']); |
|
| 342 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 343 | - $buffer = explode('\n',$buffer); |
|
| 344 | - foreach ($buffer as $line) { |
|
| 345 | - if ($line != '') { |
|
| 346 | - $line = explode(':', $line); |
|
| 347 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 340 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 341 | + $buffer = $Common->getData($value['host']); |
|
| 342 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 343 | + $buffer = explode('\n',$buffer); |
|
| 344 | + foreach ($buffer as $line) { |
|
| 345 | + if ($line != '') { |
|
| 346 | + $line = explode(':', $line); |
|
| 347 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 348 | 348 | $data = array(); |
| 349 | 349 | $data['id'] = $line[1].'-'.$line[0]; |
| 350 | 350 | $data['pilot_id'] = $line[1]; |
@@ -356,35 +356,35 @@ discard block |
||
| 356 | 356 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 357 | 357 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 358 | 358 | $data['latitude'] = $line[5]; // lat |
| 359 | - $data['longitude'] = $line[6]; // long |
|
| 360 | - $data['verticalrate'] = ''; // vertical rate |
|
| 361 | - $data['squawk'] = ''; // squawk |
|
| 362 | - $data['emergency'] = ''; // emergency |
|
| 363 | - $data['waypoints'] = $line[30]; |
|
| 359 | + $data['longitude'] = $line[6]; // long |
|
| 360 | + $data['verticalrate'] = ''; // vertical rate |
|
| 361 | + $data['squawk'] = ''; // squawk |
|
| 362 | + $data['emergency'] = ''; // emergency |
|
| 363 | + $data['waypoints'] = $line[30]; |
|
| 364 | 364 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 365 | 365 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 366 | - $data['departure_airport_icao'] = $line[11]; |
|
| 367 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 368 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 366 | + $data['departure_airport_icao'] = $line[11]; |
|
| 367 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 368 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 369 | 369 | $data['frequency'] = $line[4]; |
| 370 | 370 | $data['type'] = $line[18]; |
| 371 | 371 | $data['range'] = $line[19]; |
| 372 | 372 | if (isset($line[35])) $data['info'] = $line[35]; |
| 373 | - $data['id_source'] = $id_source; |
|
| 374 | - //$data['arrival_airport_time'] = ; |
|
| 375 | - if ($line[9] != '') { |
|
| 376 | - $aircraft_data = explode('/',$line[9]); |
|
| 377 | - if (isset($aircraft_data[1])) { |
|
| 378 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 379 | - } |
|
| 380 | - } |
|
| 381 | - /* |
|
| 373 | + $data['id_source'] = $id_source; |
|
| 374 | + //$data['arrival_airport_time'] = ; |
|
| 375 | + if ($line[9] != '') { |
|
| 376 | + $aircraft_data = explode('/',$line[9]); |
|
| 377 | + if (isset($aircraft_data[1])) { |
|
| 378 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 379 | + } |
|
| 380 | + } |
|
| 381 | + /* |
|
| 382 | 382 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 383 | 383 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 384 | 384 | */ |
| 385 | - $data['format_source'] = $value['format']; |
|
| 385 | + $data['format_source'] = $value['format']; |
|
| 386 | 386 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 387 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 387 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 388 | 388 | elseif ($line[3] == 'ATC') { |
| 389 | 389 | //print_r($data); |
| 390 | 390 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -402,240 +402,240 @@ discard block |
||
| 402 | 402 | |
| 403 | 403 | 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']); |
| 404 | 404 | } |
| 405 | - unset($data); |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 410 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 411 | - $value['last_exec'] = time(); |
|
| 412 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 413 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 414 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 415 | - if ($buffer != '') { |
|
| 416 | - $all_data = json_decode($buffer,true); |
|
| 417 | - if (isset($all_data['acList'])) { |
|
| 405 | + unset($data); |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 410 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 411 | + $value['last_exec'] = time(); |
|
| 412 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 413 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 414 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 415 | + if ($buffer != '') { |
|
| 416 | + $all_data = json_decode($buffer,true); |
|
| 417 | + if (isset($all_data['acList'])) { |
|
| 418 | 418 | foreach ($all_data['acList'] as $line) { |
| 419 | - $data = array(); |
|
| 420 | - $data['hex'] = $line['Icao']; // hex |
|
| 421 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 422 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 423 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 424 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 425 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 426 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 427 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
| 428 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 429 | - $data['emergency'] = ''; // emergency |
|
| 430 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 431 | - /* |
|
| 419 | + $data = array(); |
|
| 420 | + $data['hex'] = $line['Icao']; // hex |
|
| 421 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 422 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 423 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 424 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 425 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 426 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 427 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
| 428 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 429 | + $data['emergency'] = ''; // emergency |
|
| 430 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 431 | + /* |
|
| 432 | 432 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 433 | 433 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 434 | 434 | */ |
| 435 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 436 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 437 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 438 | - $data['id_source'] = $id_source; |
|
| 439 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 440 | - if (isset($data['datetime'])) $SI->add($data); |
|
| 441 | - unset($data); |
|
| 435 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 436 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 437 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 438 | + $data['id_source'] = $id_source; |
|
| 439 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 440 | + if (isset($data['datetime'])) $SI->add($data); |
|
| 441 | + unset($data); |
|
| 442 | 442 | } |
| 443 | - } else { |
|
| 443 | + } else { |
|
| 444 | 444 | foreach ($all_data as $line) { |
| 445 | - $data = array(); |
|
| 446 | - $data['hex'] = $line['hex']; // hex |
|
| 447 | - $data['ident'] = $line['flight']; // ident |
|
| 448 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 449 | - $data['speed'] = $line['speed']; // speed |
|
| 450 | - $data['heading'] = $line['track']; // heading |
|
| 451 | - $data['latitude'] = $line['lat']; // lat |
|
| 452 | - $data['longitude'] = $line['lon']; // long |
|
| 453 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 454 | - $data['squawk'] = $line['squawk']; // squawk |
|
| 455 | - $data['emergency'] = ''; // emergency |
|
| 456 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 457 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 458 | - $data['id_source'] = $id_source; |
|
| 459 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 460 | - $SI->add($data); |
|
| 461 | - unset($data); |
|
| 445 | + $data = array(); |
|
| 446 | + $data['hex'] = $line['hex']; // hex |
|
| 447 | + $data['ident'] = $line['flight']; // ident |
|
| 448 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 449 | + $data['speed'] = $line['speed']; // speed |
|
| 450 | + $data['heading'] = $line['track']; // heading |
|
| 451 | + $data['latitude'] = $line['lat']; // lat |
|
| 452 | + $data['longitude'] = $line['lon']; // long |
|
| 453 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 454 | + $data['squawk'] = $line['squawk']; // squawk |
|
| 455 | + $data['emergency'] = ''; // emergency |
|
| 456 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 457 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 458 | + $data['id_source'] = $id_source; |
|
| 459 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 460 | + $SI->add($data); |
|
| 461 | + unset($data); |
|
| 462 | + } |
|
| 462 | 463 | } |
| 463 | - } |
|
| 464 | - } |
|
| 465 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 466 | - $value['last_exec'] = time(); |
|
| 467 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 468 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 469 | - $buffer = $Common->getData($value['host']); |
|
| 470 | - $all_data = json_decode($buffer,true); |
|
| 471 | - if (isset($all_data['planes'])) { |
|
| 464 | + } |
|
| 465 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 466 | + $value['last_exec'] = time(); |
|
| 467 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 468 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 469 | + $buffer = $Common->getData($value['host']); |
|
| 470 | + $all_data = json_decode($buffer,true); |
|
| 471 | + if (isset($all_data['planes'])) { |
|
| 472 | 472 | foreach ($all_data['planes'] as $key => $line) { |
| 473 | - $data = array(); |
|
| 474 | - $data['hex'] = $key; // hex |
|
| 475 | - $data['ident'] = $line[3]; // ident |
|
| 476 | - $data['altitude'] = $line[6]; // altitude |
|
| 477 | - $data['speed'] = $line[8]; // speed |
|
| 478 | - $data['heading'] = $line[7]; // heading |
|
| 479 | - $data['latitude'] = $line[4]; // lat |
|
| 480 | - $data['longitude'] = $line[5]; // long |
|
| 481 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 482 | - $data['squawk'] = $line[10]; // squawk |
|
| 483 | - $data['emergency'] = ''; // emergency |
|
| 484 | - $data['registration'] = $line[2]; |
|
| 485 | - $data['aircraft_icao'] = $line[0]; |
|
| 486 | - $deparr = explode('-',$line[1]); |
|
| 487 | - if (count($deparr) == 2) { |
|
| 473 | + $data = array(); |
|
| 474 | + $data['hex'] = $key; // hex |
|
| 475 | + $data['ident'] = $line[3]; // ident |
|
| 476 | + $data['altitude'] = $line[6]; // altitude |
|
| 477 | + $data['speed'] = $line[8]; // speed |
|
| 478 | + $data['heading'] = $line[7]; // heading |
|
| 479 | + $data['latitude'] = $line[4]; // lat |
|
| 480 | + $data['longitude'] = $line[5]; // long |
|
| 481 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 482 | + $data['squawk'] = $line[10]; // squawk |
|
| 483 | + $data['emergency'] = ''; // emergency |
|
| 484 | + $data['registration'] = $line[2]; |
|
| 485 | + $data['aircraft_icao'] = $line[0]; |
|
| 486 | + $deparr = explode('-',$line[1]); |
|
| 487 | + if (count($deparr) == 2) { |
|
| 488 | 488 | $data['departure_airport_icao'] = $deparr[0]; |
| 489 | 489 | $data['arrival_airport_icao'] = $deparr[1]; |
| 490 | - } |
|
| 491 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 492 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 493 | - $data['id_source'] = $id_source; |
|
| 494 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 495 | - $SI->add($data); |
|
| 496 | - unset($data); |
|
| 490 | + } |
|
| 491 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 492 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 493 | + $data['id_source'] = $id_source; |
|
| 494 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 495 | + $SI->add($data); |
|
| 496 | + unset($data); |
|
| 497 | + } |
|
| 497 | 498 | } |
| 498 | - } |
|
| 499 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 500 | - $value['last_exec'] = time(); |
|
| 501 | - } elseif ($value['format'] == 'opensky' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 502 | - $buffer = $Common->getData($value['host']); |
|
| 503 | - $all_data = json_decode($buffer,true); |
|
| 504 | - if (isset($all_data['states'])) { |
|
| 499 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 500 | + $value['last_exec'] = time(); |
|
| 501 | + } elseif ($value['format'] == 'opensky' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 502 | + $buffer = $Common->getData($value['host']); |
|
| 503 | + $all_data = json_decode($buffer,true); |
|
| 504 | + if (isset($all_data['states'])) { |
|
| 505 | 505 | foreach ($all_data['states'] as $key => $line) { |
| 506 | - $data = array(); |
|
| 507 | - $data['hex'] = $line[0]; // hex |
|
| 508 | - $data['ident'] = trim($line[1]); // ident |
|
| 509 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 510 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 511 | - $data['heading'] = round($line[10]); // heading |
|
| 512 | - $data['latitude'] = $line[5]; // lat |
|
| 513 | - $data['longitude'] = $line[6]; // long |
|
| 514 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 515 | - //$data['squawk'] = $line[10]; // squawk |
|
| 516 | - //$data['emergency'] = ''; // emergency |
|
| 517 | - //$data['registration'] = $line[2]; |
|
| 518 | - //$data['aircraft_icao'] = $line[0]; |
|
| 519 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 520 | - $data['format_source'] = 'opensky'; |
|
| 521 | - $data['id_source'] = $id_source; |
|
| 522 | - $SI->add($data); |
|
| 523 | - unset($data); |
|
| 506 | + $data = array(); |
|
| 507 | + $data['hex'] = $line[0]; // hex |
|
| 508 | + $data['ident'] = trim($line[1]); // ident |
|
| 509 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 510 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 511 | + $data['heading'] = round($line[10]); // heading |
|
| 512 | + $data['latitude'] = $line[5]; // lat |
|
| 513 | + $data['longitude'] = $line[6]; // long |
|
| 514 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 515 | + //$data['squawk'] = $line[10]; // squawk |
|
| 516 | + //$data['emergency'] = ''; // emergency |
|
| 517 | + //$data['registration'] = $line[2]; |
|
| 518 | + //$data['aircraft_icao'] = $line[0]; |
|
| 519 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 520 | + $data['format_source'] = 'opensky'; |
|
| 521 | + $data['id_source'] = $id_source; |
|
| 522 | + $SI->add($data); |
|
| 523 | + unset($data); |
|
| 524 | + } |
|
| 524 | 525 | } |
| 525 | - } |
|
| 526 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 527 | - $value['last_exec'] = time(); |
|
| 528 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 529 | - } elseif ($value['format'] == 'fr24json' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 530 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 531 | - $buffer = $Common->getData($value['host']); |
|
| 532 | - $all_data = json_decode($buffer,true); |
|
| 533 | - foreach ($all_data as $key => $line) { |
|
| 526 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 527 | + $value['last_exec'] = time(); |
|
| 528 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 529 | + } elseif ($value['format'] == 'fr24json' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 530 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 531 | + $buffer = $Common->getData($value['host']); |
|
| 532 | + $all_data = json_decode($buffer,true); |
|
| 533 | + foreach ($all_data as $key => $line) { |
|
| 534 | 534 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 535 | - $data = array(); |
|
| 536 | - $data['hex'] = $line[0]; |
|
| 537 | - $data['ident'] = $line[16]; //$line[13] |
|
| 538 | - $data['altitude'] = $line[4]; // altitude |
|
| 539 | - $data['speed'] = $line[5]; // speed |
|
| 540 | - $data['heading'] = $line[3]; // heading |
|
| 541 | - $data['latitude'] = $line[1]; // lat |
|
| 542 | - $data['longitude'] = $line[2]; // long |
|
| 543 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 544 | - $data['squawk'] = $line[6]; // squawk |
|
| 545 | - $data['aircraft_icao'] = $line[8]; |
|
| 546 | - $data['registration'] = $line[9]; |
|
| 547 | - $data['departure_airport_iata'] = $line[11]; |
|
| 548 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 549 | - $data['emergency'] = ''; // emergency |
|
| 550 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 551 | - $data['format_source'] = 'fr24json'; |
|
| 552 | - $data['id_source'] = $id_source; |
|
| 553 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 554 | - $SI->add($data); |
|
| 555 | - unset($data); |
|
| 535 | + $data = array(); |
|
| 536 | + $data['hex'] = $line[0]; |
|
| 537 | + $data['ident'] = $line[16]; //$line[13] |
|
| 538 | + $data['altitude'] = $line[4]; // altitude |
|
| 539 | + $data['speed'] = $line[5]; // speed |
|
| 540 | + $data['heading'] = $line[3]; // heading |
|
| 541 | + $data['latitude'] = $line[1]; // lat |
|
| 542 | + $data['longitude'] = $line[2]; // long |
|
| 543 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 544 | + $data['squawk'] = $line[6]; // squawk |
|
| 545 | + $data['aircraft_icao'] = $line[8]; |
|
| 546 | + $data['registration'] = $line[9]; |
|
| 547 | + $data['departure_airport_iata'] = $line[11]; |
|
| 548 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 549 | + $data['emergency'] = ''; // emergency |
|
| 550 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 551 | + $data['format_source'] = 'fr24json'; |
|
| 552 | + $data['id_source'] = $id_source; |
|
| 553 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 554 | + $SI->add($data); |
|
| 555 | + unset($data); |
|
| 556 | 556 | } |
| 557 | - } |
|
| 558 | - //$last_exec['fr24json'] = time(); |
|
| 559 | - $value['last_exec'] = time(); |
|
| 560 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 561 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 562 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 563 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 564 | - //echo $buffer; |
|
| 565 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 566 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 567 | - $all_data = json_decode($buffer,true); |
|
| 568 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 557 | + } |
|
| 558 | + //$last_exec['fr24json'] = time(); |
|
| 559 | + $value['last_exec'] = time(); |
|
| 560 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 561 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 562 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 563 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 564 | + //echo $buffer; |
|
| 565 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 566 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 567 | + $all_data = json_decode($buffer,true); |
|
| 568 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 569 | 569 | die(json_last_error_msg()); |
| 570 | - } |
|
| 571 | - if (isset($all_data['mrkrs'])) { |
|
| 570 | + } |
|
| 571 | + if (isset($all_data['mrkrs'])) { |
|
| 572 | 572 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 573 | - if (isset($line['inf'])) { |
|
| 573 | + if (isset($line['inf'])) { |
|
| 574 | 574 | $data = array(); |
| 575 | 575 | $data['hex'] = $line['inf']['ia']; |
| 576 | 576 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 577 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 578 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 579 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 580 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 581 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 582 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 583 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 584 | - //$data['aircraft_icao'] = $line[8]; |
|
| 585 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 577 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 578 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 579 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 580 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 581 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 582 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 583 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 584 | + //$data['aircraft_icao'] = $line[8]; |
|
| 585 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 586 | 586 | //$data['departure_airport_iata'] = $line[11]; |
| 587 | 587 | //$data['arrival_airport_iata'] = $line[12]; |
| 588 | - //$data['emergency'] = ''; // emergency |
|
| 588 | + //$data['emergency'] = ''; // emergency |
|
| 589 | 589 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 590 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 591 | - $data['id_source'] = $id_source; |
|
| 590 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 591 | + $data['id_source'] = $id_source; |
|
| 592 | 592 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 593 | 593 | $SI->add($data); |
| 594 | 594 | unset($data); |
| 595 | - } |
|
| 595 | + } |
|
| 596 | 596 | } |
| 597 | - } |
|
| 598 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 599 | - $value['last_exec'] = time(); |
|
| 600 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 601 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 602 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 603 | - $buffer = $Common->getData($value['host']); |
|
| 604 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 597 | + } |
|
| 598 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 599 | + $value['last_exec'] = time(); |
|
| 600 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 601 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 602 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 603 | + $buffer = $Common->getData($value['host']); |
|
| 604 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 605 | 605 | |
| 606 | - if (isset($all_data['pireps'])) { |
|
| 607 | - foreach ($all_data['pireps'] as $line) { |
|
| 608 | - $data = array(); |
|
| 609 | - $data['id'] = $line['id']; |
|
| 610 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 611 | - $data['ident'] = $line['callsign']; // ident |
|
| 612 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 613 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 614 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 615 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 616 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 617 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 618 | - $data['latitude'] = $line['lat']; // lat |
|
| 619 | - $data['longitude'] = $line['lon']; // long |
|
| 620 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 621 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 622 | - //$data['emergency'] = ''; // emergency |
|
| 623 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 624 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 625 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 626 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 627 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 628 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 629 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 630 | - else $data['info'] = ''; |
|
| 631 | - $data['format_source'] = 'pireps'; |
|
| 632 | - $data['id_source'] = $id_source; |
|
| 633 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 634 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 635 | - if ($line['icon'] == 'plane') { |
|
| 606 | + if (isset($all_data['pireps'])) { |
|
| 607 | + foreach ($all_data['pireps'] as $line) { |
|
| 608 | + $data = array(); |
|
| 609 | + $data['id'] = $line['id']; |
|
| 610 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 611 | + $data['ident'] = $line['callsign']; // ident |
|
| 612 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 613 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 614 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 615 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 616 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 617 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 618 | + $data['latitude'] = $line['lat']; // lat |
|
| 619 | + $data['longitude'] = $line['lon']; // long |
|
| 620 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 621 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 622 | + //$data['emergency'] = ''; // emergency |
|
| 623 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 624 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 625 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 626 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 627 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 628 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 629 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 630 | + else $data['info'] = ''; |
|
| 631 | + $data['format_source'] = 'pireps'; |
|
| 632 | + $data['id_source'] = $id_source; |
|
| 633 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 634 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 635 | + if ($line['icon'] == 'plane') { |
|
| 636 | 636 | $SI->add($data); |
| 637 | - // print_r($data); |
|
| 638 | - } elseif ($line['icon'] == 'ct') { |
|
| 637 | + // print_r($data); |
|
| 638 | + } elseif ($line['icon'] == 'ct') { |
|
| 639 | 639 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 640 | 640 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 641 | 641 | $typec = substr($data['ident'],-3); |
@@ -650,108 +650,108 @@ discard block |
||
| 650 | 650 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 651 | 651 | else $data['type'] = 'Observer'; |
| 652 | 652 | echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
| 653 | - } |
|
| 654 | - unset($data); |
|
| 653 | + } |
|
| 654 | + unset($data); |
|
| 655 | 655 | } |
| 656 | - } |
|
| 657 | - //$last_exec['pirepsjson'] = time(); |
|
| 658 | - $value['last_exec'] = time(); |
|
| 659 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 660 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 661 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 662 | - $buffer = $Common->getData($value['host']); |
|
| 663 | - $all_data = json_decode($buffer,true); |
|
| 664 | - if ($buffer != '' && is_array($all_data)) { |
|
| 656 | + } |
|
| 657 | + //$last_exec['pirepsjson'] = time(); |
|
| 658 | + $value['last_exec'] = time(); |
|
| 659 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 660 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 661 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 662 | + $buffer = $Common->getData($value['host']); |
|
| 663 | + $all_data = json_decode($buffer,true); |
|
| 664 | + if ($buffer != '' && is_array($all_data)) { |
|
| 665 | 665 | foreach ($all_data as $line) { |
| 666 | - $data = array(); |
|
| 667 | - //$data['id'] = $line['id']; // id not usable |
|
| 668 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 669 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 670 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 671 | - $data['ident'] = $line['flightnum']; // ident |
|
| 672 | - $data['altitude'] = $line['alt']; // altitude |
|
| 673 | - $data['speed'] = $line['gs']; // speed |
|
| 674 | - $data['heading'] = $line['heading']; // heading |
|
| 675 | - $data['latitude'] = $line['lat']; // lat |
|
| 676 | - $data['longitude'] = $line['lng']; // long |
|
| 677 | - $data['verticalrate'] = ''; // verticale rate |
|
| 678 | - $data['squawk'] = ''; // squawk |
|
| 679 | - $data['emergency'] = ''; // emergency |
|
| 680 | - //$data['datetime'] = $line['lastupdate']; |
|
| 681 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 682 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 683 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 684 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 685 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 686 | - $data['registration'] = $line['aircraft']; |
|
| 687 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 688 | - if (isset($line['aircraftname'])) { |
|
| 666 | + $data = array(); |
|
| 667 | + //$data['id'] = $line['id']; // id not usable |
|
| 668 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 669 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 670 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 671 | + $data['ident'] = $line['flightnum']; // ident |
|
| 672 | + $data['altitude'] = $line['alt']; // altitude |
|
| 673 | + $data['speed'] = $line['gs']; // speed |
|
| 674 | + $data['heading'] = $line['heading']; // heading |
|
| 675 | + $data['latitude'] = $line['lat']; // lat |
|
| 676 | + $data['longitude'] = $line['lng']; // long |
|
| 677 | + $data['verticalrate'] = ''; // verticale rate |
|
| 678 | + $data['squawk'] = ''; // squawk |
|
| 679 | + $data['emergency'] = ''; // emergency |
|
| 680 | + //$data['datetime'] = $line['lastupdate']; |
|
| 681 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 682 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 683 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 684 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 685 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 686 | + $data['registration'] = $line['aircraft']; |
|
| 687 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 688 | + if (isset($line['aircraftname'])) { |
|
| 689 | 689 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 690 | 690 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 691 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 692 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 693 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 694 | - else { |
|
| 695 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 696 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 697 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 698 | - } |
|
| 699 | - } |
|
| 700 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 701 | - $data['id_source'] = $id_source; |
|
| 702 | - $data['format_source'] = 'phpvmacars'; |
|
| 703 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 704 | - $SI->add($data); |
|
| 705 | - unset($data); |
|
| 691 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 692 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 693 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 694 | + else { |
|
| 695 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 696 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 697 | + else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 698 | + } |
|
| 699 | + } |
|
| 700 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 701 | + $data['id_source'] = $id_source; |
|
| 702 | + $data['format_source'] = 'phpvmacars'; |
|
| 703 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 704 | + $SI->add($data); |
|
| 705 | + unset($data); |
|
| 706 | 706 | } |
| 707 | - } |
|
| 708 | - //$last_exec['phpvmacars'] = time(); |
|
| 709 | - $value['last_exec'] = time(); |
|
| 707 | + } |
|
| 708 | + //$last_exec['phpvmacars'] = time(); |
|
| 709 | + $value['last_exec'] = time(); |
|
| 710 | 710 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 711 | 711 | } 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') { |
| 712 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 713 | - $value['last_exec'] = time(); |
|
| 712 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 713 | + $value['last_exec'] = time(); |
|
| 714 | 714 | |
| 715 | - //$read = array( $sockets[$id] ); |
|
| 716 | - $read = $sockets; |
|
| 717 | - $write = NULL; |
|
| 718 | - $e = NULL; |
|
| 719 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 720 | - if ($e != NULL) var_dump($e); |
|
| 721 | - if ($n > 0) { |
|
| 715 | + //$read = array( $sockets[$id] ); |
|
| 716 | + $read = $sockets; |
|
| 717 | + $write = NULL; |
|
| 718 | + $e = NULL; |
|
| 719 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 720 | + if ($e != NULL) var_dump($e); |
|
| 721 | + if ($n > 0) { |
|
| 722 | 722 | foreach ($read as $nb => $r) { |
| 723 | - //$value = $formats[$nb]; |
|
| 724 | - $format = $globalSources[$nb]['format']; |
|
| 725 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') { |
|
| 726 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 727 | - } else { |
|
| 728 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 729 | - } |
|
| 730 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 731 | - //echo $buffer."\n"; |
|
| 732 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 733 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 734 | - $error = false; |
|
| 735 | - //$SI::del(); |
|
| 736 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 737 | - // SBS format is CSV format |
|
| 738 | - if ($buffer != '') { |
|
| 723 | + //$value = $formats[$nb]; |
|
| 724 | + $format = $globalSources[$nb]['format']; |
|
| 725 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') { |
|
| 726 | + $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 727 | + } else { |
|
| 728 | + $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 729 | + } |
|
| 730 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 731 | + //echo $buffer."\n"; |
|
| 732 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 733 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 734 | + $error = false; |
|
| 735 | + //$SI::del(); |
|
| 736 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 737 | + // SBS format is CSV format |
|
| 738 | + if ($buffer != '') { |
|
| 739 | 739 | $tt[$format] = 0; |
| 740 | 740 | if ($format == 'acarssbs3') { |
| 741 | - echo $buffer."\n"; |
|
| 741 | + echo $buffer."\n"; |
|
| 742 | 742 | } elseif ($format == 'raw') { |
| 743 | - // AVR format |
|
| 744 | - $data = $SBS->parse($buffer); |
|
| 745 | - if (is_array($data)) { |
|
| 743 | + // AVR format |
|
| 744 | + $data = $SBS->parse($buffer); |
|
| 745 | + if (is_array($data)) { |
|
| 746 | 746 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 747 | 747 | $data['format_source'] = 'raw'; |
| 748 | 748 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 749 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 750 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 751 | - } |
|
| 752 | - } elseif ($format == 'flightgearsp') { |
|
| 753 | - //echo $buffer."\n"; |
|
| 754 | - if (strlen($buffer) > 5) { |
|
| 749 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 750 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 751 | + } |
|
| 752 | + } elseif ($format == 'flightgearsp') { |
|
| 753 | + //echo $buffer."\n"; |
|
| 754 | + if (strlen($buffer) > 5) { |
|
| 755 | 755 | $line = explode(',',$buffer); |
| 756 | 756 | $data = array(); |
| 757 | 757 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -767,114 +767,114 @@ discard block |
||
| 767 | 767 | $data['format_source'] = 'flightgearsp'; |
| 768 | 768 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 769 | 769 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 770 | - } |
|
| 771 | - } elseif ($format == 'acars') { |
|
| 772 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 773 | - $ACARS->add(trim($buffer)); |
|
| 774 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 775 | - $ACARS->deleteLiveAcarsData(); |
|
| 770 | + } |
|
| 771 | + } elseif ($format == 'acars') { |
|
| 772 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 773 | + $ACARS->add(trim($buffer)); |
|
| 774 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 775 | + $ACARS->deleteLiveAcarsData(); |
|
| 776 | 776 | } elseif ($format == 'flightgearmp') { |
| 777 | - if (substr($buffer,0,1) != '#') { |
|
| 777 | + if (substr($buffer,0,1) != '#') { |
|
| 778 | 778 | $data = array(); |
| 779 | 779 | //echo $buffer."\n"; |
| 780 | 780 | $line = explode(' ',$buffer); |
| 781 | 781 | if (count($line) == 11) { |
| 782 | - $userserver = explode('@',$line[0]); |
|
| 783 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 784 | - $data['ident'] = $userserver[0]; |
|
| 785 | - $data['registration'] = $userserver[0]; |
|
| 786 | - $data['latitude'] = $line[4]; |
|
| 787 | - $data['longitude'] = $line[5]; |
|
| 788 | - $data['altitude'] = $line[6]; |
|
| 789 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 790 | - $aircraft_type = $line[10]; |
|
| 791 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 792 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 793 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 782 | + $userserver = explode('@',$line[0]); |
|
| 783 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 784 | + $data['ident'] = $userserver[0]; |
|
| 785 | + $data['registration'] = $userserver[0]; |
|
| 786 | + $data['latitude'] = $line[4]; |
|
| 787 | + $data['longitude'] = $line[5]; |
|
| 788 | + $data['altitude'] = $line[6]; |
|
| 789 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 790 | + $aircraft_type = $line[10]; |
|
| 791 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 792 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 793 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 794 | + } |
|
| 794 | 795 | } |
| 795 | - } |
|
| 796 | 796 | } elseif ($format == 'beast') { |
| 797 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 798 | - die; |
|
| 797 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 798 | + die; |
|
| 799 | 799 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 800 | - $line = explode("\t", $buffer); |
|
| 801 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 800 | + $line = explode("\t", $buffer); |
|
| 801 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 802 | 802 | $key = $line[$k]; |
| 803 | - $lined[$key] = $line[$k+1]; |
|
| 804 | - } |
|
| 805 | - if (count($lined) > 3) { |
|
| 806 | - $data['hex'] = $lined['hexid']; |
|
| 807 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 808 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 809 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 810 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 811 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 812 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 813 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 814 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 815 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 816 | - $data['id_source'] = $id_source; |
|
| 817 | - $data['format_source'] = 'tsv'; |
|
| 818 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 819 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 820 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 821 | - unset($lined); |
|
| 822 | - unset($data); |
|
| 823 | - } else $error = true; |
|
| 803 | + $lined[$key] = $line[$k+1]; |
|
| 804 | + } |
|
| 805 | + if (count($lined) > 3) { |
|
| 806 | + $data['hex'] = $lined['hexid']; |
|
| 807 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 808 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 809 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 810 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 811 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 812 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 813 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 814 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 815 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 816 | + $data['id_source'] = $id_source; |
|
| 817 | + $data['format_source'] = 'tsv'; |
|
| 818 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 819 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 820 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 821 | + unset($lined); |
|
| 822 | + unset($data); |
|
| 823 | + } else $error = true; |
|
| 824 | 824 | } elseif ($format == 'aprs' && $use_aprs) { |
| 825 | - if ($aprs_connect == 0) { |
|
| 825 | + if ($aprs_connect == 0) { |
|
| 826 | 826 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 827 | 827 | $aprs_connect = 1; |
| 828 | - } |
|
| 829 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 828 | + } |
|
| 829 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 830 | 830 | $aprs_last_tx = time(); |
| 831 | 831 | $data_aprs = "# Keep alive"; |
| 832 | 832 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 833 | - } |
|
| 834 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 835 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 836 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 837 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 833 | + } |
|
| 834 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 835 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 836 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 837 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 838 | 838 | $line = $APRS->parse($buffer); |
| 839 | 839 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 840 | - $data = array(); |
|
| 841 | - //print_r($line); |
|
| 842 | - $data['hex'] = $line['address']; |
|
| 843 | - $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 844 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 845 | - $data['ident'] = $line['ident']; |
|
| 846 | - $data['latitude'] = $line['latitude']; |
|
| 847 | - $data['longitude'] = $line['longitude']; |
|
| 848 | - //$data['verticalrate'] = $line[16]; |
|
| 849 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 850 | - else $data['speed'] = 0; |
|
| 851 | - $data['altitude'] = $line['altitude']; |
|
| 852 | - if (isset($line['course'])) $data['heading'] = $line['course']; |
|
| 853 | - //else $data['heading'] = 0; |
|
| 854 | - $data['aircraft_type'] = $line['stealth']; |
|
| 855 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 856 | - $data['id_source'] = $id_source; |
|
| 857 | - $data['format_source'] = 'aprs'; |
|
| 858 | - $data['source_name'] = $line['source']; |
|
| 859 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 860 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 861 | - $aprsdate = strtotime($data['datetime']); |
|
| 862 | - // Accept data if time <= system time + 20s |
|
| 863 | - 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); |
|
| 864 | - else { |
|
| 840 | + $data = array(); |
|
| 841 | + //print_r($line); |
|
| 842 | + $data['hex'] = $line['address']; |
|
| 843 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 844 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 845 | + $data['ident'] = $line['ident']; |
|
| 846 | + $data['latitude'] = $line['latitude']; |
|
| 847 | + $data['longitude'] = $line['longitude']; |
|
| 848 | + //$data['verticalrate'] = $line[16]; |
|
| 849 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 850 | + else $data['speed'] = 0; |
|
| 851 | + $data['altitude'] = $line['altitude']; |
|
| 852 | + if (isset($line['course'])) $data['heading'] = $line['course']; |
|
| 853 | + //else $data['heading'] = 0; |
|
| 854 | + $data['aircraft_type'] = $line['stealth']; |
|
| 855 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 856 | + $data['id_source'] = $id_source; |
|
| 857 | + $data['format_source'] = 'aprs'; |
|
| 858 | + $data['source_name'] = $line['source']; |
|
| 859 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 860 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 861 | + $aprsdate = strtotime($data['datetime']); |
|
| 862 | + // Accept data if time <= system time + 20s |
|
| 863 | + 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); |
|
| 864 | + else { |
|
| 865 | 865 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 866 | 866 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 867 | - } |
|
| 868 | - unset($data); |
|
| 867 | + } |
|
| 868 | + unset($data); |
|
| 869 | 869 | } |
| 870 | 870 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 871 | 871 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 872 | - } |
|
| 872 | + } |
|
| 873 | 873 | } else { |
| 874 | - $line = explode(',', $buffer); |
|
| 875 | - if (count($line) > 20) { |
|
| 876 | - $data['hex'] = $line[4]; |
|
| 877 | - /* |
|
| 874 | + $line = explode(',', $buffer); |
|
| 875 | + if (count($line) > 20) { |
|
| 876 | + $data['hex'] = $line[4]; |
|
| 877 | + /* |
|
| 878 | 878 | $data['datetime'] = $line[6].' '.$line[7]; |
| 879 | 879 | date_default_timezone_set($globalTimezone); |
| 880 | 880 | $datetime = new DateTime($data['datetime']); |
@@ -882,28 +882,28 @@ discard block |
||
| 882 | 882 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 883 | 883 | date_default_timezone_set('UTC'); |
| 884 | 884 | */ |
| 885 | - // Force datetime to current UTC datetime |
|
| 886 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 887 | - $data['ident'] = trim($line[10]); |
|
| 888 | - $data['latitude'] = $line[14]; |
|
| 889 | - $data['longitude'] = $line[15]; |
|
| 890 | - $data['verticalrate'] = $line[16]; |
|
| 891 | - $data['emergency'] = $line[20]; |
|
| 892 | - $data['speed'] = $line[12]; |
|
| 893 | - $data['squawk'] = $line[17]; |
|
| 894 | - $data['altitude'] = $line[11]; |
|
| 895 | - $data['heading'] = $line[13]; |
|
| 896 | - $data['ground'] = $line[21]; |
|
| 897 | - $data['emergency'] = $line[19]; |
|
| 898 | - $data['format_source'] = 'sbs'; |
|
| 885 | + // Force datetime to current UTC datetime |
|
| 886 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 887 | + $data['ident'] = trim($line[10]); |
|
| 888 | + $data['latitude'] = $line[14]; |
|
| 889 | + $data['longitude'] = $line[15]; |
|
| 890 | + $data['verticalrate'] = $line[16]; |
|
| 891 | + $data['emergency'] = $line[20]; |
|
| 892 | + $data['speed'] = $line[12]; |
|
| 893 | + $data['squawk'] = $line[17]; |
|
| 894 | + $data['altitude'] = $line[11]; |
|
| 895 | + $data['heading'] = $line[13]; |
|
| 896 | + $data['ground'] = $line[21]; |
|
| 897 | + $data['emergency'] = $line[19]; |
|
| 898 | + $data['format_source'] = 'sbs'; |
|
| 899 | 899 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 900 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 901 | - $data['id_source'] = $id_source; |
|
| 902 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 903 | - else $error = true; |
|
| 904 | - unset($data); |
|
| 905 | - } else $error = true; |
|
| 906 | - if ($error) { |
|
| 900 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 901 | + $data['id_source'] = $id_source; |
|
| 902 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 903 | + else $error = true; |
|
| 904 | + unset($data); |
|
| 905 | + } else $error = true; |
|
| 906 | + if ($error) { |
|
| 907 | 907 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 908 | 908 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 909 | 909 | } else { |
@@ -919,13 +919,13 @@ discard block |
||
| 919 | 919 | connect_all($sourceer); |
| 920 | 920 | $sourceer = array(); |
| 921 | 921 | } |
| 922 | - } |
|
| 922 | + } |
|
| 923 | 923 | } |
| 924 | 924 | // Sleep for xxx microseconds |
| 925 | 925 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 926 | - } else { |
|
| 926 | + } else { |
|
| 927 | 927 | if ($format == 'flightgearmp') { |
| 928 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 928 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 929 | 929 | //@socket_close($r); |
| 930 | 930 | sleep($globalMinFetch); |
| 931 | 931 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -934,9 +934,9 @@ discard block |
||
| 934 | 934 | break; |
| 935 | 935 | |
| 936 | 936 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 937 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 938 | - else $tt[$format] = 0; |
|
| 939 | - if ($tt[$format] > 30) { |
|
| 937 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 938 | + else $tt[$format] = 0; |
|
| 939 | + if ($tt[$format] > 30) { |
|
| 940 | 940 | if ($globalDebug)echo "ERROR : Reconnect ".$format."..."; |
| 941 | 941 | //@socket_close($r); |
| 942 | 942 | sleep(2); |
@@ -947,39 +947,39 @@ discard block |
||
| 947 | 947 | //connect_all($globalSources); |
| 948 | 948 | $tt[$format]=0; |
| 949 | 949 | break; |
| 950 | - } |
|
| 950 | + } |
|
| 951 | + } |
|
| 951 | 952 | } |
| 952 | - } |
|
| 953 | 953 | } |
| 954 | - } else { |
|
| 954 | + } else { |
|
| 955 | 955 | $error = socket_strerror(socket_last_error()); |
| 956 | 956 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 957 | 957 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) { |
| 958 | 958 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 959 | 959 | // Restart the script if possible |
| 960 | 960 | if (is_array($sockets)) { |
| 961 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 961 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 962 | 962 | |
| 963 | - foreach ($sockets as $sock) { |
|
| 963 | + foreach ($sockets as $sock) { |
|
| 964 | 964 | @socket_shutdown($sock,2); |
| 965 | 965 | @socket_close($sock); |
| 966 | - } |
|
| 966 | + } |
|
| 967 | 967 | |
| 968 | 968 | } |
| 969 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 970 | - sleep(2); |
|
| 971 | - $time = time(); |
|
| 972 | - //connect_all($hosts); |
|
| 973 | - $aprs_connect = 0; |
|
| 974 | - connect_all($globalSources); |
|
| 969 | + if ($globalDebug) echo "Restart all connections..."; |
|
| 970 | + sleep(2); |
|
| 971 | + $time = time(); |
|
| 972 | + //connect_all($hosts); |
|
| 973 | + $aprs_connect = 0; |
|
| 974 | + connect_all($globalSources); |
|
| 975 | 975 | |
| 976 | 976 | } |
| 977 | - } |
|
| 977 | + } |
|
| 978 | 978 | } |
| 979 | 979 | if ($globalDaemon == false) { |
| 980 | - $SI->checkAll(); |
|
| 980 | + $SI->checkAll(); |
|
| 981 | + } |
|
| 981 | 982 | } |
| 982 | - } |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | ?> |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | die; |
| 38 | 38 | } |
| 39 | 39 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 40 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
| 40 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -$options = getopt('s::',array('source::','server','idsource::')); |
|
| 44 | +$options = getopt('s::', array('source::', 'server', 'idsource::')); |
|
| 45 | 45 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 46 | 46 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 47 | 47 | if (isset($options['s'])) { |
@@ -56,17 +56,17 @@ discard block |
||
| 56 | 56 | else $id_source = 1; |
| 57 | 57 | if (isset($globalServer) && $globalServer) { |
| 58 | 58 | if ($globalDebug) echo "Using Server Mode\n"; |
| 59 | - $SI=new SpotterServer(); |
|
| 60 | -} else $SI=new SpotterImport($Connection->db); |
|
| 59 | + $SI = new SpotterServer(); |
|
| 60 | +} else $SI = new SpotterImport($Connection->db); |
|
| 61 | 61 | //$APRS=new APRS($Connection->db); |
| 62 | -$SBS=new SBS($Connection->db); |
|
| 63 | -$ACARS=new ACARS($Connection->db); |
|
| 64 | -$Common=new Common(); |
|
| 62 | +$SBS = new SBS($Connection->db); |
|
| 63 | +$ACARS = new ACARS($Connection->db); |
|
| 64 | +$Common = new Common(); |
|
| 65 | 65 | date_default_timezone_set('UTC'); |
| 66 | 66 | //$servertz = system('date +%Z'); |
| 67 | 67 | // signal handler - playing nice with sockets and dump1090 |
| 68 | 68 | if (function_exists('pcntl_fork')) { |
| 69 | - pcntl_signal(SIGINT, function($signo) { |
|
| 69 | + pcntl_signal(SIGINT, function($signo) { |
|
| 70 | 70 | global $sockets; |
| 71 | 71 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 72 | 72 | die("Bye!\n"); |
@@ -109,33 +109,33 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | function connect_all($hosts) { |
| 111 | 111 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 112 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 112 | + global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs; |
|
| 113 | 113 | foreach ($hosts as $id => $value) { |
| 114 | 114 | $host = $value['host']; |
| 115 | 115 | $globalSources[$id]['last_exec'] = 0; |
| 116 | 116 | // Here we check type of source(s) |
| 117 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 118 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 117 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 118 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
| 119 | 119 | //$formats[$id] = 'deltadbtxt'; |
| 120 | 120 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 121 | 121 | //$last_exec['deltadbtxt'] = 0; |
| 122 | 122 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 123 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 123 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 124 | 124 | //$formats[$id] = 'vatsimtxt'; |
| 125 | 125 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 126 | 126 | //$last_exec['vatsimtxt'] = 0; |
| 127 | 127 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 128 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 128 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 129 | 129 | //$formats[$id] = 'aircraftlistjson'; |
| 130 | 130 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 131 | 131 | //$last_exec['aircraftlistjson'] = 0; |
| 132 | 132 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 133 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 133 | + } else if (preg_match('/opensky/i', $host)) { |
|
| 134 | 134 | //$formats[$id] = 'aircraftlistjson'; |
| 135 | 135 | $globalSources[$id]['format'] = 'opensky'; |
| 136 | 136 | //$last_exec['aircraftlistjson'] = 0; |
| 137 | 137 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
| 138 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 138 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
| 139 | 139 | //$formats[$id] = 'radarvirtueljson'; |
| 140 | 140 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 141 | 141 | //$last_exec['radarvirtueljson'] = 0; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 145 | 145 | exit(0); |
| 146 | 146 | } |
| 147 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 147 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 148 | 148 | //$formats[$id] = 'planeupdatefaa'; |
| 149 | 149 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 150 | 150 | //$last_exec['planeupdatefaa'] = 0; |
@@ -153,22 +153,22 @@ discard block |
||
| 153 | 153 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 154 | 154 | exit(0); |
| 155 | 155 | } |
| 156 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 156 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 157 | 157 | //$formats[$id] = 'phpvmacars'; |
| 158 | 158 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 159 | 159 | //$last_exec['phpvmacars'] = 0; |
| 160 | 160 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 161 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 162 | 162 | //$formats[$id] = 'whazzup'; |
| 163 | 163 | $globalSources[$id]['format'] = 'whazzup'; |
| 164 | 164 | //$last_exec['whazzup'] = 0; |
| 165 | 165 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 166 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 167 | 167 | //$formats[$id] = 'pirepsjson'; |
| 168 | 168 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 169 | 169 | //$last_exec['pirepsjson'] = 0; |
| 170 | 170 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 172 | 172 | //$formats[$id] = 'fr24json'; |
| 173 | 173 | $globalSources[$id]['format'] = 'fr24json'; |
| 174 | 174 | //$last_exec['fr24json'] = 0; |
@@ -178,15 +178,15 @@ discard block |
||
| 178 | 178 | exit(0); |
| 179 | 179 | } |
| 180 | 180 | //} else if (preg_match('/10001/',$host)) { |
| 181 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 181 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 182 | 182 | //$formats[$id] = 'tsv'; |
| 183 | 183 | $globalSources[$id]['format'] = 'tsv'; |
| 184 | 184 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 185 | 185 | } |
| 186 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 186 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 187 | 187 | if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 188 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 189 | - $hostport = explode(':',$host); |
|
| 188 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 189 | + $hostport = explode(':', $host); |
|
| 190 | 190 | if (isset($hostport[1])) { |
| 191 | 191 | $port = $hostport[1]; |
| 192 | 192 | $hostn = $hostport[0]; |
@@ -195,14 +195,14 @@ discard block |
||
| 195 | 195 | $hostn = $globalSources[$id]['host']; |
| 196 | 196 | } |
| 197 | 197 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
| 198 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 198 | + $s = create_socket($hostn, $port, $errno, $errstr); |
|
| 199 | 199 | } else { |
| 200 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 200 | + $s = create_socket_udp($hostn, $port, $errno, $errstr); |
|
| 201 | 201 | } |
| 202 | 202 | if ($s) { |
| 203 | 203 | $sockets[$id] = $s; |
| 204 | 204 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 205 | - if (preg_match('/aprs/',$hostn)) { |
|
| 205 | + if (preg_match('/aprs/', $hostn)) { |
|
| 206 | 206 | //$formats[$id] = 'aprs'; |
| 207 | 207 | $globalSources[$id]['format'] = 'aprs'; |
| 208 | 208 | //$aprs_connect = 0; |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 244 | 244 | else $timeout = 20; |
| 245 | 245 | $errno = ''; |
| 246 | -$errstr=''; |
|
| 246 | +$errstr = ''; |
|
| 247 | 247 | |
| 248 | 248 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 249 | 249 | /* Initiate connections to all the hosts simultaneously */ |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | if ($use_aprs) { |
| 266 | 266 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 267 | - $APRS=new APRS($Connection->db); |
|
| 267 | + $APRS = new APRS($Connection->db); |
|
| 268 | 268 | $aprs_connect = 0; |
| 269 | 269 | $aprs_keep = 120; |
| 270 | 270 | $aprs_last_tx = time(); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | else $aprs_ssid = 'FAM'; |
| 276 | 276 | //else $aprs_ssid = 'PerlEx'; |
| 277 | 277 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 278 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 278 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 279 | 279 | if ($aprs_full) $aprs_filter = ''; |
| 280 | 280 | if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
| 281 | 281 | else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
@@ -286,12 +286,12 @@ discard block |
||
| 286 | 286 | sleep(1); |
| 287 | 287 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 288 | 288 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 289 | -$endtime = time()+$globalCronEnd; |
|
| 289 | +$endtime = time() + $globalCronEnd; |
|
| 290 | 290 | $i = 1; |
| 291 | 291 | $tt = array(); |
| 292 | 292 | // Delete all ATC |
| 293 | 293 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 294 | - $ATC=new ATC($Connection->db); |
|
| 294 | + $ATC = new ATC($Connection->db); |
|
| 295 | 295 | } |
| 296 | 296 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 297 | 297 | $ATC->deleteAll(); |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 301 | 301 | while ($i > 0) { |
| 302 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 302 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 303 | 303 | // Delete old ATC |
| 304 | 304 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 305 | 305 | $ATC->deleteOldATC(); |
@@ -309,8 +309,8 @@ discard block |
||
| 309 | 309 | if ($value['format'] == 'deltadbtxt' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 310 | 310 | //$buffer = $Common->getData($hosts[$id]); |
| 311 | 311 | $buffer = $Common->getData($value['host']); |
| 312 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 313 | - $buffer = explode('\n',$buffer); |
|
| 312 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 313 | + $buffer = explode('\n', $buffer); |
|
| 314 | 314 | foreach ($buffer as $line) { |
| 315 | 315 | if ($line != '') { |
| 316 | 316 | $line = explode(',', $line); |
@@ -339,8 +339,8 @@ discard block |
||
| 339 | 339 | } elseif (($value['format'] == 'whazzup' && (time() - $value['last_exec'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value['last_exec'] > $globalMinFetch))) { |
| 340 | 340 | //$buffer = $Common->getData($hosts[$id]); |
| 341 | 341 | $buffer = $Common->getData($value['host']); |
| 342 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 343 | - $buffer = explode('\n',$buffer); |
|
| 342 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 343 | + $buffer = explode('\n', $buffer); |
|
| 344 | 344 | foreach ($buffer as $line) { |
| 345 | 345 | if ($line != '') { |
| 346 | 346 | $line = explode(':', $line); |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | $data['id'] = $line[1].'-'.$line[0]; |
| 350 | 350 | $data['pilot_id'] = $line[1]; |
| 351 | 351 | $data['pilot_name'] = $line[2]; |
| 352 | - $data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT); |
|
| 352 | + $data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT); |
|
| 353 | 353 | $data['ident'] = $line[0]; // ident |
| 354 | 354 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 355 | 355 | $data['speed'] = $line[8]; // speed |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 365 | 365 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 366 | 366 | $data['departure_airport_icao'] = $line[11]; |
| 367 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 367 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 368 | 368 | $data['arrival_airport_icao'] = $line[13]; |
| 369 | 369 | $data['frequency'] = $line[4]; |
| 370 | 370 | $data['type'] = $line[18]; |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | $data['id_source'] = $id_source; |
| 374 | 374 | //$data['arrival_airport_time'] = ; |
| 375 | 375 | if ($line[9] != '') { |
| 376 | - $aircraft_data = explode('/',$line[9]); |
|
| 376 | + $aircraft_data = explode('/', $line[9]); |
|
| 377 | 377 | if (isset($aircraft_data[1])) { |
| 378 | 378 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 379 | 379 | } |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | if ($line[3] == 'PILOT') $SI->add($data); |
| 388 | 388 | elseif ($line[3] == 'ATC') { |
| 389 | 389 | //print_r($data); |
| 390 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 391 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 392 | - $typec = substr($data['ident'],-3); |
|
| 390 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 391 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 392 | + $typec = substr($data['ident'], -3); |
|
| 393 | 393 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 394 | 394 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
| 395 | 395 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 401 | 401 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
| 402 | 402 | |
| 403 | - 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']); |
|
| 403 | + 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']); |
|
| 404 | 404 | } |
| 405 | 405 | unset($data); |
| 406 | 406 | } |
@@ -411,9 +411,9 @@ discard block |
||
| 411 | 411 | $value['last_exec'] = time(); |
| 412 | 412 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
| 413 | 413 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 414 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 414 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 415 | 415 | if ($buffer != '') { |
| 416 | - $all_data = json_decode($buffer,true); |
|
| 416 | + $all_data = json_decode($buffer, true); |
|
| 417 | 417 | if (isset($all_data['acList'])) { |
| 418 | 418 | foreach ($all_data['acList'] as $line) { |
| 419 | 419 | $data = array(); |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
| 468 | 468 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 469 | 469 | $buffer = $Common->getData($value['host']); |
| 470 | - $all_data = json_decode($buffer,true); |
|
| 470 | + $all_data = json_decode($buffer, true); |
|
| 471 | 471 | if (isset($all_data['planes'])) { |
| 472 | 472 | foreach ($all_data['planes'] as $key => $line) { |
| 473 | 473 | $data = array(); |
@@ -483,12 +483,12 @@ discard block |
||
| 483 | 483 | $data['emergency'] = ''; // emergency |
| 484 | 484 | $data['registration'] = $line[2]; |
| 485 | 485 | $data['aircraft_icao'] = $line[0]; |
| 486 | - $deparr = explode('-',$line[1]); |
|
| 486 | + $deparr = explode('-', $line[1]); |
|
| 487 | 487 | if (count($deparr) == 2) { |
| 488 | 488 | $data['departure_airport_icao'] = $deparr[0]; |
| 489 | 489 | $data['arrival_airport_icao'] = $deparr[1]; |
| 490 | 490 | } |
| 491 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 491 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 492 | 492 | $data['format_source'] = 'planeupdatefaa'; |
| 493 | 493 | $data['id_source'] = $id_source; |
| 494 | 494 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | $value['last_exec'] = time(); |
| 501 | 501 | } elseif ($value['format'] == 'opensky' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 502 | 502 | $buffer = $Common->getData($value['host']); |
| 503 | - $all_data = json_decode($buffer,true); |
|
| 503 | + $all_data = json_decode($buffer, true); |
|
| 504 | 504 | if (isset($all_data['states'])) { |
| 505 | 505 | foreach ($all_data['states'] as $key => $line) { |
| 506 | 506 | $data = array(); |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | //$data['emergency'] = ''; // emergency |
| 517 | 517 | //$data['registration'] = $line[2]; |
| 518 | 518 | //$data['aircraft_icao'] = $line[0]; |
| 519 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 519 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 520 | 520 | $data['format_source'] = 'opensky'; |
| 521 | 521 | $data['id_source'] = $id_source; |
| 522 | 522 | $SI->add($data); |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | } elseif ($value['format'] == 'fr24json' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 530 | 530 | //$buffer = $Common->getData($hosts[$id]); |
| 531 | 531 | $buffer = $Common->getData($value['host']); |
| 532 | - $all_data = json_decode($buffer,true); |
|
| 532 | + $all_data = json_decode($buffer, true); |
|
| 533 | 533 | foreach ($all_data as $key => $line) { |
| 534 | 534 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 535 | 535 | $data = array(); |
@@ -560,11 +560,11 @@ discard block |
||
| 560 | 560 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 561 | 561 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 562 | 562 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 563 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 563 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 564 | 564 | //echo $buffer; |
| 565 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 566 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 567 | - $all_data = json_decode($buffer,true); |
|
| 565 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 566 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 567 | + $all_data = json_decode($buffer, true); |
|
| 568 | 568 | if (json_last_error() != JSON_ERROR_NONE) { |
| 569 | 569 | die(json_last_error_msg()); |
| 570 | 570 | } |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | //$data['departure_airport_iata'] = $line[11]; |
| 587 | 587 | //$data['arrival_airport_iata'] = $line[12]; |
| 588 | 588 | //$data['emergency'] = ''; // emergency |
| 589 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 589 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 590 | 590 | $data['format_source'] = 'radarvirtueljson'; |
| 591 | 591 | $data['id_source'] = $id_source; |
| 592 | 592 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -601,13 +601,13 @@ discard block |
||
| 601 | 601 | } elseif ($value['format'] == 'pirepsjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 602 | 602 | //$buffer = $Common->getData($hosts[$id]); |
| 603 | 603 | $buffer = $Common->getData($value['host']); |
| 604 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 604 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 605 | 605 | |
| 606 | 606 | if (isset($all_data['pireps'])) { |
| 607 | 607 | foreach ($all_data['pireps'] as $line) { |
| 608 | 608 | $data = array(); |
| 609 | 609 | $data['id'] = $line['id']; |
| 610 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 610 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 611 | 611 | $data['ident'] = $line['callsign']; // ident |
| 612 | 612 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 613 | 613 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -636,9 +636,9 @@ discard block |
||
| 636 | 636 | $SI->add($data); |
| 637 | 637 | // print_r($data); |
| 638 | 638 | } elseif ($line['icon'] == 'ct') { |
| 639 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 640 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 641 | - $typec = substr($data['ident'],-3); |
|
| 639 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 640 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 641 | + $typec = substr($data['ident'], -3); |
|
| 642 | 642 | $data['type'] = ''; |
| 643 | 643 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 644 | 644 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
| 650 | 650 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 651 | 651 | else $data['type'] = 'Observer'; |
| 652 | - echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
|
| 652 | + echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name']); |
|
| 653 | 653 | } |
| 654 | 654 | unset($data); |
| 655 | 655 | } |
@@ -660,12 +660,12 @@ discard block |
||
| 660 | 660 | } elseif ($value['format'] == 'phpvmacars' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 661 | 661 | //$buffer = $Common->getData($hosts[$id]); |
| 662 | 662 | $buffer = $Common->getData($value['host']); |
| 663 | - $all_data = json_decode($buffer,true); |
|
| 663 | + $all_data = json_decode($buffer, true); |
|
| 664 | 664 | if ($buffer != '' && is_array($all_data)) { |
| 665 | 665 | foreach ($all_data as $line) { |
| 666 | 666 | $data = array(); |
| 667 | 667 | //$data['id'] = $line['id']; // id not usable |
| 668 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 668 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 669 | 669 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 670 | 670 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 671 | 671 | $data['ident'] = $line['flightnum']; // ident |
@@ -687,12 +687,12 @@ discard block |
||
| 687 | 687 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 688 | 688 | if (isset($line['aircraftname'])) { |
| 689 | 689 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 690 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 691 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 690 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 691 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 692 | 692 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
| 693 | 693 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
| 694 | 694 | else { |
| 695 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 695 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 696 | 696 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
| 697 | 697 | else $data['aircraft_icao'] = $line['aircraftname']; |
| 698 | 698 | } |
@@ -723,9 +723,9 @@ discard block |
||
| 723 | 723 | //$value = $formats[$nb]; |
| 724 | 724 | $format = $globalSources[$nb]['format']; |
| 725 | 725 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') { |
| 726 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 726 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 727 | 727 | } else { |
| 728 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 728 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 729 | 729 | } |
| 730 | 730 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 731 | 731 | //echo $buffer."\n"; |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
| 734 | 734 | $error = false; |
| 735 | 735 | //$SI::del(); |
| 736 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 736 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 737 | 737 | // SBS format is CSV format |
| 738 | 738 | if ($buffer != '') { |
| 739 | 739 | $tt[$format] = 0; |
@@ -752,10 +752,10 @@ discard block |
||
| 752 | 752 | } elseif ($format == 'flightgearsp') { |
| 753 | 753 | //echo $buffer."\n"; |
| 754 | 754 | if (strlen($buffer) > 5) { |
| 755 | - $line = explode(',',$buffer); |
|
| 755 | + $line = explode(',', $buffer); |
|
| 756 | 756 | $data = array(); |
| 757 | 757 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 758 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 758 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 759 | 759 | $data['ident'] = $line[6]; |
| 760 | 760 | $data['aircraft_name'] = $line[7]; |
| 761 | 761 | $data['longitude'] = $line[1]; |
@@ -766,21 +766,21 @@ discard block |
||
| 766 | 766 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 767 | 767 | $data['format_source'] = 'flightgearsp'; |
| 768 | 768 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 769 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 769 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 770 | 770 | } |
| 771 | 771 | } elseif ($format == 'acars') { |
| 772 | 772 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 773 | 773 | $ACARS->add(trim($buffer)); |
| 774 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 774 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 775 | 775 | $ACARS->deleteLiveAcarsData(); |
| 776 | 776 | } elseif ($format == 'flightgearmp') { |
| 777 | - if (substr($buffer,0,1) != '#') { |
|
| 777 | + if (substr($buffer, 0, 1) != '#') { |
|
| 778 | 778 | $data = array(); |
| 779 | 779 | //echo $buffer."\n"; |
| 780 | - $line = explode(' ',$buffer); |
|
| 780 | + $line = explode(' ', $buffer); |
|
| 781 | 781 | if (count($line) == 11) { |
| 782 | - $userserver = explode('@',$line[0]); |
|
| 783 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 782 | + $userserver = explode('@', $line[0]); |
|
| 783 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 784 | 784 | $data['ident'] = $userserver[0]; |
| 785 | 785 | $data['registration'] = $userserver[0]; |
| 786 | 786 | $data['latitude'] = $line[4]; |
@@ -788,24 +788,24 @@ discard block |
||
| 788 | 788 | $data['altitude'] = $line[6]; |
| 789 | 789 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 790 | 790 | $aircraft_type = $line[10]; |
| 791 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 792 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 791 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 792 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 793 | 793 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 794 | 794 | } |
| 795 | 795 | } |
| 796 | 796 | } elseif ($format == 'beast') { |
| 797 | 797 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 798 | 798 | die; |
| 799 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
| 799 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
| 800 | 800 | $line = explode("\t", $buffer); |
| 801 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 801 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 802 | 802 | $key = $line[$k]; |
| 803 | - $lined[$key] = $line[$k+1]; |
|
| 803 | + $lined[$key] = $line[$k + 1]; |
|
| 804 | 804 | } |
| 805 | 805 | if (count($lined) > 3) { |
| 806 | 806 | $data['hex'] = $lined['hexid']; |
| 807 | 807 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 808 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 808 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 809 | 809 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 810 | 810 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 811 | 811 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -823,24 +823,24 @@ discard block |
||
| 823 | 823 | } else $error = true; |
| 824 | 824 | } elseif ($format == 'aprs' && $use_aprs) { |
| 825 | 825 | if ($aprs_connect == 0) { |
| 826 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 826 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 827 | 827 | $aprs_connect = 1; |
| 828 | 828 | } |
| 829 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 829 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 830 | 830 | $aprs_last_tx = time(); |
| 831 | 831 | $data_aprs = "# Keep alive"; |
| 832 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 832 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 833 | 833 | } |
| 834 | 834 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 835 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 836 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 837 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 835 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 836 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 837 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 838 | 838 | $line = $APRS->parse($buffer); |
| 839 | 839 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 840 | 840 | $data = array(); |
| 841 | 841 | //print_r($line); |
| 842 | 842 | $data['hex'] = $line['address']; |
| 843 | - $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 843 | + $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 844 | 844 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 845 | 845 | $data['ident'] = $line['ident']; |
| 846 | 846 | $data['latitude'] = $line['latitude']; |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | $currentdate = date('Y-m-d H:i:s'); |
| 861 | 861 | $aprsdate = strtotime($data['datetime']); |
| 862 | 862 | // Accept data if time <= system time + 20s |
| 863 | - 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); |
|
| 863 | + 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); |
|
| 864 | 864 | else { |
| 865 | 865 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 866 | 866 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | connect_all($sourceee); |
| 946 | 946 | $sourceee = array(); |
| 947 | 947 | //connect_all($globalSources); |
| 948 | - $tt[$format]=0; |
|
| 948 | + $tt[$format] = 0; |
|
| 949 | 949 | break; |
| 950 | 950 | } |
| 951 | 951 | } |
@@ -953,7 +953,7 @@ discard block |
||
| 953 | 953 | } |
| 954 | 954 | } else { |
| 955 | 955 | $error = socket_strerror(socket_last_error()); |
| 956 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 956 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 957 | 957 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) { |
| 958 | 958 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 959 | 959 | // Restart the script if possible |
@@ -961,7 +961,7 @@ discard block |
||
| 961 | 961 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 962 | 962 | |
| 963 | 963 | foreach ($sockets as $sock) { |
| 964 | - @socket_shutdown($sock,2); |
|
| 964 | + @socket_shutdown($sock, 2); |
|
| 965 | 965 | @socket_close($sock); |
| 966 | 966 | } |
| 967 | 967 | |