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