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