@@ -15,65 +15,65 @@ discard block |
||
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | 17 | if (isset($globalTracker) && $globalTracker) { |
| 18 | - require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 19 | 19 | } |
| 20 | 20 | if (isset($globalMarine) && $globalMarine) { |
| 21 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 22 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 21 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 22 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if (!isset($globalDebug)) $globalDebug = FALSE; |
| 26 | 26 | |
| 27 | 27 | if ($globalInstalled === FALSE) { |
| 28 | - echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
|
| 29 | - sleep(5); |
|
| 30 | - die(); |
|
| 28 | + echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
|
| 29 | + sleep(5); |
|
| 30 | + die(); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | // Check if schema is at latest version |
| 35 | 35 | $Connection = new Connection(); |
| 36 | 36 | if ($Connection->connectionExists() === false) { |
| 37 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 38 | - exit(); |
|
| 37 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 38 | + exit(); |
|
| 39 | 39 | } |
| 40 | 40 | if ($Connection->latest() === false) { |
| 41 | - echo "You MUST update to latest schema. Use your web browser to run install/index.php"; |
|
| 42 | - exit(); |
|
| 41 | + echo "You MUST update to latest schema. Use your web browser to run install/index.php"; |
|
| 42 | + exit(); |
|
| 43 | 43 | } |
| 44 | 44 | if (PHP_SAPI != 'cli') { |
| 45 | - echo "This script MUST be called from console, not a web browser."; |
|
| 45 | + echo "This script MUST be called from console, not a web browser."; |
|
| 46 | 46 | // exit(); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // This is to be compatible with old version of settings.php |
| 50 | 50 | if (!isset($globalSources)) { |
| 51 | - if (isset($globalSBS1Hosts)) { |
|
| 52 | - //$hosts = $globalSBS1Hosts; |
|
| 53 | - foreach ($globalSBS1Hosts as $host) { |
|
| 54 | - $globalSources[] = array('host' => $host); |
|
| 55 | - } |
|
| 56 | - } else { |
|
| 57 | - if (!isset($globalSBS1Host)) { |
|
| 58 | - echo '$globalSources MUST be defined !'; |
|
| 59 | - die; |
|
| 51 | + if (isset($globalSBS1Hosts)) { |
|
| 52 | + //$hosts = $globalSBS1Hosts; |
|
| 53 | + foreach ($globalSBS1Hosts as $host) { |
|
| 54 | + $globalSources[] = array('host' => $host); |
|
| 55 | + } |
|
| 56 | + } else { |
|
| 57 | + if (!isset($globalSBS1Host)) { |
|
| 58 | + echo '$globalSources MUST be defined !'; |
|
| 59 | + die; |
|
| 60 | 60 | } |
| 61 | 61 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 62 | 62 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
| 67 | 67 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 68 | 68 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 69 | 69 | if (isset($options['s'])) { |
| 70 | - $globalSources = array(); |
|
| 71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 72 | - else $globalSources[] = array('host' => $options['s']); |
|
| 70 | + $globalSources = array(); |
|
| 71 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 72 | + else $globalSources[] = array('host' => $options['s']); |
|
| 73 | 73 | } elseif (isset($options['source'])) { |
| 74 | - $globalSources = array(); |
|
| 75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 76 | - else $globalSources[] = array('host' => $options['source']); |
|
| 74 | + $globalSources = array(); |
|
| 75 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 76 | + else $globalSources[] = array('host' => $options['source']); |
|
| 77 | 77 | } |
| 78 | 78 | if (isset($options['aprsserverhost'])) { |
| 79 | 79 | $globalServerAPRS = TRUE; |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 113 | 113 | else $id_source = 1; |
| 114 | 114 | if (isset($globalServer) && $globalServer) { |
| 115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 116 | - $SI=new SpotterServer(); |
|
| 115 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 116 | + $SI=new SpotterServer(); |
|
| 117 | 117 | /* |
| 118 | 118 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 119 | 119 | $SI = new adsb2aprs(); |
@@ -123,14 +123,14 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 125 | 125 | if (isset($globalMarine) && $globalMarine) { |
| 126 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 127 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 126 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 127 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 131 | 131 | if (isset($globalMarine) && $globalMarine) { |
| 132 | - $AIS = new AIS(); |
|
| 133 | - $MI = new MarineImport($Connection->db); |
|
| 132 | + $AIS = new AIS(); |
|
| 133 | + $MI = new MarineImport($Connection->db); |
|
| 134 | 134 | } |
| 135 | 135 | //$APRS=new APRS($Connection->db); |
| 136 | 136 | $SBS=new SBS(); |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | //$servertz = system('date +%Z'); |
| 144 | 144 | // signal handler - playing nice with sockets and dump1090 |
| 145 | 145 | if (function_exists('pcntl_fork')) { |
| 146 | - pcntl_signal(SIGINT, function() { |
|
| 147 | - global $sockets; |
|
| 148 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 149 | - die("Bye!\n"); |
|
| 150 | - }); |
|
| 151 | - pcntl_signal_dispatch(); |
|
| 146 | + pcntl_signal(SIGINT, function() { |
|
| 147 | + global $sockets; |
|
| 148 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 149 | + die("Bye!\n"); |
|
| 150 | + }); |
|
| 151 | + pcntl_signal_dispatch(); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // let's try and connect |
@@ -158,47 +158,47 @@ discard block |
||
| 158 | 158 | $reset = 0; |
| 159 | 159 | |
| 160 | 160 | function connect_all($hosts) { |
| 161 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 162 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 163 | - $reset++; |
|
| 164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 165 | - foreach ($hosts as $id => $value) { |
|
| 161 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 162 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 163 | + $reset++; |
|
| 164 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 165 | + foreach ($hosts as $id => $value) { |
|
| 166 | 166 | $host = $value['host']; |
| 167 | 167 | $udp = false; |
| 168 | 168 | $globalSources[$id]['last_exec'] = 0; |
| 169 | 169 | // Here we check type of source(s) |
| 170 | 170 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 171 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 172 | - //$formats[$id] = 'deltadbtxt'; |
|
| 173 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 174 | - //$last_exec['deltadbtxt'] = 0; |
|
| 175 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 176 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 177 | - //$formats[$id] = 'vatsimtxt'; |
|
| 178 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 179 | - //$last_exec['vatsimtxt'] = 0; |
|
| 180 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 181 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 182 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 183 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 184 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 185 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 186 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
| 187 | - //$formats[$id] = 'aircraftjson'; |
|
| 188 | - $globalSources[$id]['format'] = 'aircraftjson'; |
|
| 189 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 190 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 191 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
| 192 | - //$formats[$id] = 'planefinderclient'; |
|
| 193 | - $globalSources[$id]['format'] = 'planefinderclient'; |
|
| 194 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 195 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 196 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 197 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 198 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 199 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 200 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 201 | - /* |
|
| 171 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 172 | + //$formats[$id] = 'deltadbtxt'; |
|
| 173 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 174 | + //$last_exec['deltadbtxt'] = 0; |
|
| 175 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 176 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 177 | + //$formats[$id] = 'vatsimtxt'; |
|
| 178 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 179 | + //$last_exec['vatsimtxt'] = 0; |
|
| 180 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 181 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 182 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 183 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 184 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 185 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 186 | + } else if (preg_match('/aircraft.json$/i',$host)) { |
|
| 187 | + //$formats[$id] = 'aircraftjson'; |
|
| 188 | + $globalSources[$id]['format'] = 'aircraftjson'; |
|
| 189 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 190 | + if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 191 | + } else if (preg_match('/aircraft$/i',$host)) { |
|
| 192 | + //$formats[$id] = 'planefinderclient'; |
|
| 193 | + $globalSources[$id]['format'] = 'planefinderclient'; |
|
| 194 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 195 | + if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 196 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 197 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 198 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 199 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 200 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 201 | + /* |
|
| 202 | 202 | // Disabled for now, site change source format |
| 203 | 203 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
| 204 | 204 | //$formats[$id] = 'radarvirtueljson'; |
@@ -210,130 +210,130 @@ discard block |
||
| 210 | 210 | exit(0); |
| 211 | 211 | } |
| 212 | 212 | */ |
| 213 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 214 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 215 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 216 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 217 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 218 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 219 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 220 | - exit(0); |
|
| 221 | - } |
|
| 222 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 223 | - //$formats[$id] = 'phpvmacars'; |
|
| 224 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 225 | - //$last_exec['phpvmacars'] = 0; |
|
| 226 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 227 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
| 228 | - //$formats[$id] = 'phpvmacars'; |
|
| 229 | - $globalSources[$id]['format'] = 'vaos'; |
|
| 230 | - //$last_exec['phpvmacars'] = 0; |
|
| 231 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 232 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 233 | - //$formats[$id] = 'phpvmacars'; |
|
| 234 | - $globalSources[$id]['format'] = 'vam'; |
|
| 235 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 236 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 237 | - //$formats[$id] = 'whazzup'; |
|
| 238 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 239 | - //$last_exec['whazzup'] = 0; |
|
| 240 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 241 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
| 242 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
| 243 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 244 | - } else if (preg_match('/airwhere/i',$host)) { |
|
| 245 | - $globalSources[$id]['format'] = 'airwhere'; |
|
| 246 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 247 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 248 | - //$formats[$id] = 'pirepsjson'; |
|
| 249 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 250 | - //$last_exec['pirepsjson'] = 0; |
|
| 251 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 252 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 253 | - //$formats[$id] = 'fr24json'; |
|
| 254 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 255 | - //$last_exec['fr24json'] = 0; |
|
| 256 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 257 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 258 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 259 | - exit(0); |
|
| 260 | - } |
|
| 261 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 262 | - //$formats[$id] = 'fr24json'; |
|
| 263 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 264 | - //$last_exec['fr24json'] = 0; |
|
| 265 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 266 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 267 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 268 | - exit(0); |
|
| 269 | - } |
|
| 270 | - //} else if (preg_match('/10001/',$host)) { |
|
| 271 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 272 | - //$formats[$id] = 'tsv'; |
|
| 273 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 274 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 275 | - } |
|
| 276 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
| 277 | - if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
|
| 278 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 279 | - if ($idf !== false) { |
|
| 280 | - $httpfeeds[$id] = $idf; |
|
| 281 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 282 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 283 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 284 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 285 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 286 | - $hostport = explode(':',$host); |
|
| 287 | - if (isset($hostport[1])) { |
|
| 213 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 214 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 215 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 216 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 217 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 218 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 219 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 220 | + exit(0); |
|
| 221 | + } |
|
| 222 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 223 | + //$formats[$id] = 'phpvmacars'; |
|
| 224 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 225 | + //$last_exec['phpvmacars'] = 0; |
|
| 226 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 227 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
| 228 | + //$formats[$id] = 'phpvmacars'; |
|
| 229 | + $globalSources[$id]['format'] = 'vaos'; |
|
| 230 | + //$last_exec['phpvmacars'] = 0; |
|
| 231 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 232 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 233 | + //$formats[$id] = 'phpvmacars'; |
|
| 234 | + $globalSources[$id]['format'] = 'vam'; |
|
| 235 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 236 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 237 | + //$formats[$id] = 'whazzup'; |
|
| 238 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 239 | + //$last_exec['whazzup'] = 0; |
|
| 240 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 241 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
| 242 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
| 243 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 244 | + } else if (preg_match('/airwhere/i',$host)) { |
|
| 245 | + $globalSources[$id]['format'] = 'airwhere'; |
|
| 246 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 247 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 248 | + //$formats[$id] = 'pirepsjson'; |
|
| 249 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 250 | + //$last_exec['pirepsjson'] = 0; |
|
| 251 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 252 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 253 | + //$formats[$id] = 'fr24json'; |
|
| 254 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 255 | + //$last_exec['fr24json'] = 0; |
|
| 256 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 257 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 258 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 259 | + exit(0); |
|
| 260 | + } |
|
| 261 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 262 | + //$formats[$id] = 'fr24json'; |
|
| 263 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 264 | + //$last_exec['fr24json'] = 0; |
|
| 265 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 266 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 267 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 268 | + exit(0); |
|
| 269 | + } |
|
| 270 | + //} else if (preg_match('/10001/',$host)) { |
|
| 271 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 272 | + //$formats[$id] = 'tsv'; |
|
| 273 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 274 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 275 | + } |
|
| 276 | + } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
| 277 | + if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
|
| 278 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 279 | + if ($idf !== false) { |
|
| 280 | + $httpfeeds[$id] = $idf; |
|
| 281 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 282 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 283 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 284 | + elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 285 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 286 | + $hostport = explode(':',$host); |
|
| 287 | + if (isset($hostport[1])) { |
|
| 288 | 288 | $port = $hostport[1]; |
| 289 | 289 | $hostn = $hostport[0]; |
| 290 | - } else { |
|
| 290 | + } else { |
|
| 291 | 291 | $port = $globalSources[$id]['port']; |
| 292 | 292 | $hostn = $globalSources[$id]['host']; |
| 293 | - } |
|
| 294 | - $Common = new Common(); |
|
| 295 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 296 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 297 | - } else { |
|
| 298 | - $udp = true; |
|
| 299 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 300 | - } |
|
| 301 | - if ($s) { |
|
| 302 | - $sockets[$id] = $s; |
|
| 303 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 304 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 293 | + } |
|
| 294 | + $Common = new Common(); |
|
| 295 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 296 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 297 | + } else { |
|
| 298 | + $udp = true; |
|
| 299 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 300 | + } |
|
| 301 | + if ($s) { |
|
| 302 | + $sockets[$id] = $s; |
|
| 303 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 304 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 305 | 305 | //$formats[$id] = 'aprs'; |
| 306 | 306 | $globalSources[$id]['format'] = 'aprs'; |
| 307 | 307 | //$aprs_connect = 0; |
| 308 | 308 | //$use_aprs = true; |
| 309 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 309 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 310 | 310 | $globalSources[$id]['format'] = 'vrstcp'; |
| 311 | - } elseif ($port == '10001') { |
|
| 312 | - //$formats[$id] = 'tsv'; |
|
| 313 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 314 | - } elseif ($port == '30002') { |
|
| 315 | - //$formats[$id] = 'raw'; |
|
| 316 | - $globalSources[$id]['format'] = 'raw'; |
|
| 317 | - } elseif ($port == '5001') { |
|
| 318 | - //$formats[$id] = 'raw'; |
|
| 319 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 320 | - } elseif ($port == '30005') { |
|
| 311 | + } elseif ($port == '10001') { |
|
| 312 | + //$formats[$id] = 'tsv'; |
|
| 313 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 314 | + } elseif ($port == '30002') { |
|
| 315 | + //$formats[$id] = 'raw'; |
|
| 316 | + $globalSources[$id]['format'] = 'raw'; |
|
| 317 | + } elseif ($port == '5001') { |
|
| 318 | + //$formats[$id] = 'raw'; |
|
| 319 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 320 | + } elseif ($port == '30005') { |
|
| 321 | 321 | // Not yet supported |
| 322 | - //$formats[$id] = 'beast'; |
|
| 323 | - $globalSources[$id]['format'] = 'beast'; |
|
| 324 | - //} else $formats[$id] = 'sbs'; |
|
| 325 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 326 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 322 | + //$formats[$id] = 'beast'; |
|
| 323 | + $globalSources[$id]['format'] = 'beast'; |
|
| 324 | + //} else $formats[$id] = 'sbs'; |
|
| 325 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 326 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 327 | 327 | } |
| 328 | 328 | if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 329 | 329 | elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 330 | - } else { |
|
| 330 | + } else { |
|
| 331 | 331 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 332 | 332 | sleep(10); |
| 333 | 333 | connect_all($hosts); |
| 334 | - } |
|
| 335 | - } |
|
| 336 | - } |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | 337 | } |
| 338 | 338 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 339 | 339 | |
@@ -356,9 +356,9 @@ discard block |
||
| 356 | 356 | //connect_all($globalSources); |
| 357 | 357 | |
| 358 | 358 | if (isset($globalProxy) && $globalProxy) { |
| 359 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 359 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 360 | 360 | } else { |
| 361 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 361 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | // APRS Configuration |
@@ -367,21 +367,21 @@ discard block |
||
| 367 | 367 | die; |
| 368 | 368 | } |
| 369 | 369 | foreach ($globalSources as $key => $source) { |
| 370 | - if (!isset($source['format'])) { |
|
| 371 | - $globalSources[$key]['format'] = 'auto'; |
|
| 372 | - } |
|
| 373 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 374 | - unset($globalSources[$key]); |
|
| 375 | - } |
|
| 370 | + if (!isset($source['format'])) { |
|
| 371 | + $globalSources[$key]['format'] = 'auto'; |
|
| 372 | + } |
|
| 373 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 374 | + unset($globalSources[$key]); |
|
| 375 | + } |
|
| 376 | 376 | } |
| 377 | 377 | connect_all($globalSources); |
| 378 | 378 | foreach ($globalSources as $key => $source) { |
| 379 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 379 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 380 | 380 | $aprs_connect = 0; |
| 381 | 381 | $use_aprs = true; |
| 382 | 382 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 383 | 383 | break; |
| 384 | - } |
|
| 384 | + } |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | if ($use_aprs) { |
@@ -422,173 +422,173 @@ discard block |
||
| 422 | 422 | |
| 423 | 423 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 424 | 424 | while ($i > 0) { |
| 425 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 425 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 426 | 426 | |
| 427 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 428 | - // Delete old ATC |
|
| 429 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 427 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 428 | + // Delete old ATC |
|
| 429 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 430 | 430 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 431 | - $ATC->deleteOldATC(); |
|
| 432 | - } |
|
| 431 | + $ATC->deleteOldATC(); |
|
| 432 | + } |
|
| 433 | 433 | |
| 434 | - if (count($last_exec) == count($globalSources)) { |
|
| 434 | + if (count($last_exec) == count($globalSources)) { |
|
| 435 | 435 | $max = $globalMinFetch; |
| 436 | 436 | foreach ($last_exec as $last) { |
| 437 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 437 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 438 | 438 | } |
| 439 | 439 | if ($max < $globalMinFetch) { |
| 440 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 441 | - sleep($globalMinFetch-$max+2); |
|
| 440 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 441 | + sleep($globalMinFetch-$max+2); |
|
| 442 | + } |
|
| 442 | 443 | } |
| 443 | - } |
|
| 444 | 444 | |
| 445 | 445 | |
| 446 | - //foreach ($formats as $id => $value) { |
|
| 447 | - foreach ($globalSources as $id => $value) { |
|
| 446 | + //foreach ($formats as $id => $value) { |
|
| 447 | + foreach ($globalSources as $id => $value) { |
|
| 448 | 448 | date_default_timezone_set('UTC'); |
| 449 | 449 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 450 | 450 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 451 | 451 | if ($value['format'] === 'deltadbtxt' && |
| 452 | - ( |
|
| 452 | + ( |
|
| 453 | 453 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 454 | 454 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 455 | - ) |
|
| 455 | + ) |
|
| 456 | 456 | ) { |
| 457 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 458 | - $buffer = $Common->getData($value['host']); |
|
| 459 | - if ($buffer != '') $reset = 0; |
|
| 460 | - $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 461 | - $buffer = explode('\n', $buffer); |
|
| 462 | - foreach ($buffer as $line) { |
|
| 463 | - if ($line != '' && count($line) > 7) { |
|
| 464 | - $line = explode(',', $line); |
|
| 465 | - $data = array(); |
|
| 466 | - $data['hex'] = $line[1]; // hex |
|
| 467 | - $data['ident'] = $line[2]; // ident |
|
| 468 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 469 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 470 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 471 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 472 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 473 | - $data['verticalrate'] = ''; // vertical rate |
|
| 474 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 475 | - $data['emergency'] = ''; // emergency |
|
| 476 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 477 | - $data['format_source'] = 'deltadbtxt'; |
|
| 478 | - $data['id_source'] = $id_source; |
|
| 479 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 480 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 481 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 482 | - $SI->add($data); |
|
| 483 | - unset($data); |
|
| 484 | - } |
|
| 485 | - } |
|
| 486 | - $last_exec[$id]['last'] = time(); |
|
| 487 | - } elseif ($value['format'] === 'radarcapejson' && |
|
| 488 | - ( |
|
| 489 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 490 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 491 | - ) |
|
| 492 | - ) { |
|
| 493 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 494 | - $buffer = $Common->getData($value['host']); |
|
| 495 | - if ($buffer != '') { |
|
| 496 | - $all_data = json_decode($buffer,true); |
|
| 497 | - foreach ($all_data as $line) { |
|
| 498 | - $data = array(); |
|
| 499 | - $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
| 500 | - $data['hex'] = $line['hex']; // hex |
|
| 501 | - $data['ident'] = $line['fli']; // ident |
|
| 502 | - $data['altitude'] = $line['alt']; // altitude |
|
| 503 | - $data['speed'] = $line['spd']; // speed |
|
| 504 | - $data['heading'] = $line['trk']; // heading |
|
| 505 | - $data['latitude'] = $line['lat']; // lat |
|
| 506 | - $data['longitude'] = $line['lon']; // long |
|
| 507 | - $data['verticalrate'] = $line['vrt']; // vertical rate |
|
| 508 | - $data['squawk'] = $line['squ']; // squawk |
|
| 509 | - $data['ground'] = $line['gda']; // ground |
|
| 510 | - $data['registration'] = $line['reg']; |
|
| 511 | - //$data['emergency'] = ''; // emergency |
|
| 512 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 513 | - $data['format_source'] = 'radarcapejson'; |
|
| 514 | - $data['id_source'] = $id_source; |
|
| 515 | - if (isset($value['name']) && $value['name'] != '') { |
|
| 516 | - if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
| 517 | - else $data['source_name'] = $value['name']; |
|
| 518 | - } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
| 519 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 520 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 457 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 458 | + $buffer = $Common->getData($value['host']); |
|
| 459 | + if ($buffer != '') $reset = 0; |
|
| 460 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 461 | + $buffer = explode('\n', $buffer); |
|
| 462 | + foreach ($buffer as $line) { |
|
| 463 | + if ($line != '' && count($line) > 7) { |
|
| 464 | + $line = explode(',', $line); |
|
| 465 | + $data = array(); |
|
| 466 | + $data['hex'] = $line[1]; // hex |
|
| 467 | + $data['ident'] = $line[2]; // ident |
|
| 468 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 469 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 470 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 471 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 472 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 473 | + $data['verticalrate'] = ''; // vertical rate |
|
| 474 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 475 | + $data['emergency'] = ''; // emergency |
|
| 476 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 477 | + $data['format_source'] = 'deltadbtxt'; |
|
| 478 | + $data['id_source'] = $id_source; |
|
| 479 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 480 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 481 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 482 | + $SI->add($data); |
|
| 483 | + unset($data); |
|
| 484 | + } |
|
| 485 | + } |
|
| 486 | + $last_exec[$id]['last'] = time(); |
|
| 487 | + } elseif ($value['format'] === 'radarcapejson' && |
|
| 488 | + ( |
|
| 489 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 490 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 491 | + ) |
|
| 492 | + ) { |
|
| 493 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 494 | + $buffer = $Common->getData($value['host']); |
|
| 495 | + if ($buffer != '') { |
|
| 496 | + $all_data = json_decode($buffer,true); |
|
| 497 | + foreach ($all_data as $line) { |
|
| 498 | + $data = array(); |
|
| 499 | + $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
| 500 | + $data['hex'] = $line['hex']; // hex |
|
| 501 | + $data['ident'] = $line['fli']; // ident |
|
| 502 | + $data['altitude'] = $line['alt']; // altitude |
|
| 503 | + $data['speed'] = $line['spd']; // speed |
|
| 504 | + $data['heading'] = $line['trk']; // heading |
|
| 505 | + $data['latitude'] = $line['lat']; // lat |
|
| 506 | + $data['longitude'] = $line['lon']; // long |
|
| 507 | + $data['verticalrate'] = $line['vrt']; // vertical rate |
|
| 508 | + $data['squawk'] = $line['squ']; // squawk |
|
| 509 | + $data['ground'] = $line['gda']; // ground |
|
| 510 | + $data['registration'] = $line['reg']; |
|
| 511 | + //$data['emergency'] = ''; // emergency |
|
| 512 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 513 | + $data['format_source'] = 'radarcapejson'; |
|
| 514 | + $data['id_source'] = $id_source; |
|
| 515 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 516 | + if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
| 517 | + else $data['source_name'] = $value['name']; |
|
| 518 | + } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
| 519 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 520 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 521 | 521 | |
| 522 | - $SI->add($data); |
|
| 523 | - unset($data); |
|
| 524 | - } |
|
| 525 | - } |
|
| 526 | - $last_exec[$id]['last'] = time(); |
|
| 522 | + $SI->add($data); |
|
| 523 | + unset($data); |
|
| 524 | + } |
|
| 525 | + } |
|
| 526 | + $last_exec[$id]['last'] = time(); |
|
| 527 | 527 | } elseif ($value['format'] === 'aisnmeatxt' && |
| 528 | - ( |
|
| 528 | + ( |
|
| 529 | 529 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 530 | 530 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 531 | - ) |
|
| 531 | + ) |
|
| 532 | 532 | ) { |
| 533 | - date_default_timezone_set('CET'); |
|
| 534 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 535 | - date_default_timezone_set('UTC'); |
|
| 536 | - if ($buffer != '') $reset = 0; |
|
| 537 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 538 | - $buffer = explode('\n',$buffer); |
|
| 539 | - foreach ($buffer as $line) { |
|
| 533 | + date_default_timezone_set('CET'); |
|
| 534 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 535 | + date_default_timezone_set('UTC'); |
|
| 536 | + if ($buffer != '') $reset = 0; |
|
| 537 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 538 | + $buffer = explode('\n',$buffer); |
|
| 539 | + foreach ($buffer as $line) { |
|
| 540 | 540 | if ($line != '') { |
| 541 | - //echo "'".$line."'\n"; |
|
| 542 | - $add = false; |
|
| 543 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 544 | - $data = array(); |
|
| 545 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 546 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 547 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 548 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 549 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 550 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 551 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 552 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 553 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 554 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 555 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 556 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 557 | - if (isset($ais_data['timestamp'])) { |
|
| 541 | + //echo "'".$line."'\n"; |
|
| 542 | + $add = false; |
|
| 543 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 544 | + $data = array(); |
|
| 545 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 546 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 547 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 548 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 549 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 550 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 551 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 552 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 553 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 554 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 555 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 556 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 557 | + if (isset($ais_data['timestamp'])) { |
|
| 558 | 558 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 559 | 559 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 560 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 561 | - $add = true; |
|
| 560 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 561 | + $add = true; |
|
| 562 | 562 | } |
| 563 | - } else { |
|
| 563 | + } else { |
|
| 564 | 564 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 565 | 565 | $add = true; |
| 566 | - } |
|
| 567 | - $data['format_source'] = 'aisnmeatxt'; |
|
| 568 | - $data['id_source'] = $id_source; |
|
| 569 | - //print_r($data); |
|
| 570 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 571 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 572 | - unset($data); |
|
| 566 | + } |
|
| 567 | + $data['format_source'] = 'aisnmeatxt'; |
|
| 568 | + $data['id_source'] = $id_source; |
|
| 569 | + //print_r($data); |
|
| 570 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 571 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 572 | + unset($data); |
|
| 573 | 573 | } |
| 574 | - } |
|
| 575 | - $last_exec[$id]['last'] = time(); |
|
| 574 | + } |
|
| 575 | + $last_exec[$id]['last'] = time(); |
|
| 576 | 576 | } elseif ($value['format'] === 'aisnmeahttp') { |
| 577 | - $arr = $httpfeeds; |
|
| 578 | - $w = $e = null; |
|
| 577 | + $arr = $httpfeeds; |
|
| 578 | + $w = $e = null; |
|
| 579 | 579 | |
| 580 | - if (isset($arr[$id])) { |
|
| 580 | + if (isset($arr[$id])) { |
|
| 581 | 581 | $nn = stream_select($arr,$w,$e,$timeout); |
| 582 | 582 | if ($nn > 0) { |
| 583 | - foreach ($httpfeeds as $feed) { |
|
| 583 | + foreach ($httpfeeds as $feed) { |
|
| 584 | 584 | $buffer = stream_get_line($feed,2000,"\n"); |
| 585 | 585 | if ($buffer === FALSE) { |
| 586 | - connect_all($globalSources); |
|
| 586 | + connect_all($globalSources); |
|
| 587 | 587 | } |
| 588 | 588 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 589 | 589 | $buffer = explode('\n',$buffer); |
| 590 | 590 | foreach ($buffer as $line) { |
| 591 | - if ($line != '') { |
|
| 591 | + if ($line != '') { |
|
| 592 | 592 | $ais_data = $AIS->parse_line(trim($line)); |
| 593 | 593 | $data = array(); |
| 594 | 594 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -606,117 +606,117 @@ discard block |
||
| 606 | 606 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 607 | 607 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
| 608 | 608 | if (isset($ais_data['timestamp'])) { |
| 609 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 609 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 610 | 610 | } else { |
| 611 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 611 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 612 | 612 | } |
| 613 | 613 | $data['format_source'] = 'aisnmeahttp'; |
| 614 | 614 | $data['id_source'] = $id_source; |
| 615 | 615 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 616 | 616 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
| 617 | 617 | unset($data); |
| 618 | - } |
|
| 618 | + } |
|
| 619 | + } |
|
| 619 | 620 | } |
| 620 | - } |
|
| 621 | 621 | } else { |
| 622 | - $format = $value['format']; |
|
| 623 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 624 | - else $tt[$format] = 0; |
|
| 625 | - if ($tt[$format] > 30) { |
|
| 622 | + $format = $value['format']; |
|
| 623 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 624 | + else $tt[$format] = 0; |
|
| 625 | + if ($tt[$format] > 30) { |
|
| 626 | 626 | if ($globalDebug) echo 'Reconnect...'."\n"; |
| 627 | 627 | sleep(2); |
| 628 | 628 | //$sourceeen[] = $value; |
| 629 | 629 | //connect_all($sourceeen); |
| 630 | 630 | //$sourceeen = array(); |
| 631 | 631 | connect_all($globalSources); |
| 632 | - } |
|
| 632 | + } |
|
| 633 | + } |
|
| 633 | 634 | } |
| 634 | - } |
|
| 635 | 635 | } elseif ($value['format'] === 'myshiptracking' && |
| 636 | - ( |
|
| 636 | + ( |
|
| 637 | 637 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 638 | 638 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 639 | - ) |
|
| 639 | + ) |
|
| 640 | 640 | ) { |
| 641 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 642 | - if ($buffer != '') { |
|
| 641 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 642 | + if ($buffer != '') { |
|
| 643 | 643 | //echo $buffer; |
| 644 | 644 | $all_data = json_decode($buffer,true); |
| 645 | 645 | //print_r($all_data); |
| 646 | 646 | if (isset($all_data[0]['DATA'])) { |
| 647 | - foreach ($all_data[0]['DATA'] as $line) { |
|
| 647 | + foreach ($all_data[0]['DATA'] as $line) { |
|
| 648 | 648 | if ($line != '') { |
| 649 | - $data = array(); |
|
| 650 | - $data['ident'] = $line['NAME']; |
|
| 651 | - $data['mmsi'] = $line['MMSI']; |
|
| 652 | - if (strlen($data['mmsi']) > 9) { |
|
| 649 | + $data = array(); |
|
| 650 | + $data['ident'] = $line['NAME']; |
|
| 651 | + $data['mmsi'] = $line['MMSI']; |
|
| 652 | + if (strlen($data['mmsi']) > 9) { |
|
| 653 | 653 | $data['mmsi'] = substr($data['mmsi'],-9); |
| 654 | - } |
|
| 655 | - $data['speed'] = $line['SOG']; |
|
| 656 | - $data['heading'] = $line['COG']; |
|
| 657 | - $data['latitude'] = $line['LAT']; |
|
| 658 | - $data['longitude'] = $line['LNG']; |
|
| 659 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 660 | - //$data['type_id'] = $line['TYPE']; |
|
| 661 | - $data['imo'] = $line['IMO']; |
|
| 662 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 663 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 664 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 665 | - $data['format_source'] = 'myshiptracking'; |
|
| 666 | - $data['id_source'] = $id_source; |
|
| 667 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 668 | - $MI->add($data); |
|
| 669 | - unset($data); |
|
| 654 | + } |
|
| 655 | + $data['speed'] = $line['SOG']; |
|
| 656 | + $data['heading'] = $line['COG']; |
|
| 657 | + $data['latitude'] = $line['LAT']; |
|
| 658 | + $data['longitude'] = $line['LNG']; |
|
| 659 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 660 | + //$data['type_id'] = $line['TYPE']; |
|
| 661 | + $data['imo'] = $line['IMO']; |
|
| 662 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 663 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 664 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 665 | + $data['format_source'] = 'myshiptracking'; |
|
| 666 | + $data['id_source'] = $id_source; |
|
| 667 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 668 | + $MI->add($data); |
|
| 669 | + unset($data); |
|
| 670 | + } |
|
| 670 | 671 | } |
| 671 | - } |
|
| 672 | 672 | } |
| 673 | - } |
|
| 674 | - $last_exec[$id]['last'] = time(); |
|
| 673 | + } |
|
| 674 | + $last_exec[$id]['last'] = time(); |
|
| 675 | 675 | } elseif ($value['format'] === 'boatbeaconapp' && |
| 676 | - ( |
|
| 676 | + ( |
|
| 677 | 677 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 678 | 678 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 679 | - ) |
|
| 679 | + ) |
|
| 680 | 680 | ) { |
| 681 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 682 | - if ($buffer != '') { |
|
| 681 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 682 | + if ($buffer != '') { |
|
| 683 | 683 | $all_data = json_decode($buffer,true); |
| 684 | 684 | if (isset($all_data[0]['mmsi'])) { |
| 685 | - foreach ($all_data as $line) { |
|
| 685 | + foreach ($all_data as $line) { |
|
| 686 | 686 | if ($line != '') { |
| 687 | - $data = array(); |
|
| 688 | - $data['ident'] = $line['shipname']; |
|
| 689 | - $data['callsign'] = $line['callsign']; |
|
| 690 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
| 691 | - $data['speed'] = $line['sog']; |
|
| 692 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 693 | - $data['latitude'] = $line['latitude']; |
|
| 694 | - $data['longitude'] = $line['longitude']; |
|
| 695 | - $data['type_id'] = $line['shiptype']; |
|
| 696 | - $data['arrival_code'] = $line['destination']; |
|
| 697 | - $data['datetime'] = $line['time']; |
|
| 698 | - $data['format_source'] = 'boatbeaconapp'; |
|
| 699 | - $data['id_source'] = $id_source; |
|
| 700 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 701 | - $MI->add($data); |
|
| 702 | - unset($data); |
|
| 687 | + $data = array(); |
|
| 688 | + $data['ident'] = $line['shipname']; |
|
| 689 | + $data['callsign'] = $line['callsign']; |
|
| 690 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
| 691 | + $data['speed'] = $line['sog']; |
|
| 692 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 693 | + $data['latitude'] = $line['latitude']; |
|
| 694 | + $data['longitude'] = $line['longitude']; |
|
| 695 | + $data['type_id'] = $line['shiptype']; |
|
| 696 | + $data['arrival_code'] = $line['destination']; |
|
| 697 | + $data['datetime'] = $line['time']; |
|
| 698 | + $data['format_source'] = 'boatbeaconapp'; |
|
| 699 | + $data['id_source'] = $id_source; |
|
| 700 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 701 | + $MI->add($data); |
|
| 702 | + unset($data); |
|
| 703 | + } |
|
| 703 | 704 | } |
| 704 | - } |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - } |
|
| 708 | - $last_exec[$id]['last'] = time(); |
|
| 707 | + } |
|
| 708 | + $last_exec[$id]['last'] = time(); |
|
| 709 | 709 | } elseif ($value['format'] === 'boatnerd' && |
| 710 | - ( |
|
| 710 | + ( |
|
| 711 | 711 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 712 | 712 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 713 | - ) |
|
| 713 | + ) |
|
| 714 | 714 | ) { |
| 715 | - $buffer = $Common->getData($value['host']); |
|
| 716 | - if ($buffer != '') { |
|
| 715 | + $buffer = $Common->getData($value['host']); |
|
| 716 | + if ($buffer != '') { |
|
| 717 | 717 | $all_data = json_decode($buffer,true); |
| 718 | 718 | if (isset($all_data['features'][0]['id'])) { |
| 719 | - foreach ($all_data['features'] as $line) { |
|
| 719 | + foreach ($all_data['features'] as $line) { |
|
| 720 | 720 | print_r($line); |
| 721 | 721 | $data = array(); |
| 722 | 722 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -736,75 +736,75 @@ discard block |
||
| 736 | 736 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 737 | 737 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
| 738 | 738 | unset($data); |
| 739 | - } |
|
| 739 | + } |
|
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - } |
|
| 743 | - $last_exec[$id]['last'] = time(); |
|
| 742 | + } |
|
| 743 | + $last_exec[$id]['last'] = time(); |
|
| 744 | 744 | } elseif ($value['format'] === 'shipplotter' && |
| 745 | - ( |
|
| 745 | + ( |
|
| 746 | 746 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 747 | 747 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 748 | - ) |
|
| 748 | + ) |
|
| 749 | 749 | ) { |
| 750 | - if ($globalDebug) echo 'download...'; |
|
| 751 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 752 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 753 | - // FIXME: Need more work |
|
| 754 | - if ($buffer != '') $reset = 0; |
|
| 755 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 756 | - $buffer = explode('\n',$buffer); |
|
| 757 | - foreach ($buffer as $line) { |
|
| 750 | + if ($globalDebug) echo 'download...'; |
|
| 751 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 752 | + if ($globalDebug) echo 'done !'."\n"; |
|
| 753 | + // FIXME: Need more work |
|
| 754 | + if ($buffer != '') $reset = 0; |
|
| 755 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 756 | + $buffer = explode('\n',$buffer); |
|
| 757 | + foreach ($buffer as $line) { |
|
| 758 | 758 | if ($line != '') { |
| 759 | - $data = array(); |
|
| 760 | - //echo $line."\n"; |
|
| 761 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 762 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 763 | - $data['status_id'] = substr($line,21,2); |
|
| 764 | - $data['type_id'] = substr($line,24,3); |
|
| 765 | - $data['latitude'] = substr($line,29,9); |
|
| 766 | - $data['longitude'] = substr($line,41,9); |
|
| 767 | - $data['speed'] = round(substr($line,51,5)); |
|
| 768 | - //$data['course'] = substr($line,57,5); |
|
| 769 | - $data['heading'] = round(substr($line,63,3)); |
|
| 770 | - //$data['draft'] = substr($line,67,4); |
|
| 771 | - //$data['length'] = substr($line,72,3); |
|
| 772 | - //$data['beam'] = substr($line,76,2); |
|
| 773 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
| 774 | - //$data['callsign'] = trim(substr($line,100,7); |
|
| 775 | - $data['arrival_code'] = substr($line,108,20); |
|
| 776 | - //$data['etaDate'] = substr($line,129,5); |
|
| 777 | - //$data['etaTime'] = substr($line,135,5); |
|
| 778 | - $data['format_source'] = 'shipplotter'; |
|
| 779 | - $data['id_source'] = $id_source; |
|
| 780 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 781 | - //print_r($data); |
|
| 782 | - //echo 'Add...'."\n"; |
|
| 783 | - $MI->add($data); |
|
| 784 | - unset($data); |
|
| 759 | + $data = array(); |
|
| 760 | + //echo $line."\n"; |
|
| 761 | + $data['mmsi'] = (int)substr($line,0,9); |
|
| 762 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 763 | + $data['status_id'] = substr($line,21,2); |
|
| 764 | + $data['type_id'] = substr($line,24,3); |
|
| 765 | + $data['latitude'] = substr($line,29,9); |
|
| 766 | + $data['longitude'] = substr($line,41,9); |
|
| 767 | + $data['speed'] = round(substr($line,51,5)); |
|
| 768 | + //$data['course'] = substr($line,57,5); |
|
| 769 | + $data['heading'] = round(substr($line,63,3)); |
|
| 770 | + //$data['draft'] = substr($line,67,4); |
|
| 771 | + //$data['length'] = substr($line,72,3); |
|
| 772 | + //$data['beam'] = substr($line,76,2); |
|
| 773 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
| 774 | + //$data['callsign'] = trim(substr($line,100,7); |
|
| 775 | + $data['arrival_code'] = substr($line,108,20); |
|
| 776 | + //$data['etaDate'] = substr($line,129,5); |
|
| 777 | + //$data['etaTime'] = substr($line,135,5); |
|
| 778 | + $data['format_source'] = 'shipplotter'; |
|
| 779 | + $data['id_source'] = $id_source; |
|
| 780 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 781 | + //print_r($data); |
|
| 782 | + //echo 'Add...'."\n"; |
|
| 783 | + $MI->add($data); |
|
| 784 | + unset($data); |
|
| 785 | 785 | } |
| 786 | - } |
|
| 787 | - $last_exec[$id]['last'] = time(); |
|
| 786 | + } |
|
| 787 | + $last_exec[$id]['last'] = time(); |
|
| 788 | 788 | } elseif ($value['format'] === 'sailaway' && |
| 789 | - ( |
|
| 789 | + ( |
|
| 790 | 790 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 5*60)) |
| 791 | - ) |
|
| 791 | + ) |
|
| 792 | 792 | ) { |
| 793 | - if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
| 793 | + if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
| 794 | 794 | $authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true); |
| 795 | 795 | //echo $authsailaway; |
| 796 | 796 | preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie); |
| 797 | 797 | if (isset($setcookie[1][0])) { |
| 798 | - $sailaway_authcookie = $setcookie[1][0]; |
|
| 798 | + $sailaway_authcookie = $setcookie[1][0]; |
|
| 799 | + } |
|
| 799 | 800 | } |
| 800 | - } |
|
| 801 | 801 | |
| 802 | - if ($globalDebug) echo '! Download... '; |
|
| 803 | - for ($i =0; $i <= 1; $i++) { |
|
| 802 | + if ($globalDebug) echo '! Download... '; |
|
| 803 | + for ($i =0; $i <= 1; $i++) { |
|
| 804 | 804 | if ($globalDebug) echo 'Racetype: '.$i.' '; |
| 805 | 805 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
| 806 | - if ($globalDebug) echo 'done'."\n"; |
|
| 807 | - if ($buffer != '') { |
|
| 806 | + if ($globalDebug) echo 'done'."\n"; |
|
| 807 | + if ($buffer != '') { |
|
| 808 | 808 | $all_data = json_decode($buffer,true); |
| 809 | 809 | if (isset($all_data['missions'])) { |
| 810 | 810 | foreach ($all_data['missions'] as $mission) { |
@@ -823,19 +823,19 @@ discard block |
||
| 823 | 823 | //print_r($race_data); |
| 824 | 824 | unset($racebuffer); |
| 825 | 825 | if (isset($race_data['mission'])) { |
| 826 | - $datar = array(); |
|
| 827 | - $datar['id'] = $mission['misnr']; |
|
| 828 | - $datar['desc'] = $race_data['mission']['misdescr']; |
|
| 829 | - $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
| 830 | - $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
| 831 | - $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
| 832 | - $markers = array(); |
|
| 833 | - foreach ($race_data['mission']['course'] as $course) { |
|
| 826 | + $datar = array(); |
|
| 827 | + $datar['id'] = $mission['misnr']; |
|
| 828 | + $datar['desc'] = $race_data['mission']['misdescr']; |
|
| 829 | + $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
| 830 | + $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
| 831 | + $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
| 832 | + $markers = array(); |
|
| 833 | + foreach ($race_data['mission']['course'] as $course) { |
|
| 834 | 834 | $markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']); |
| 835 | - } |
|
| 836 | - $datar['markers'] = json_encode($markers); |
|
| 837 | - //print_r($datar); |
|
| 838 | - $MI->race_add($datar); |
|
| 835 | + } |
|
| 836 | + $datar['markers'] = json_encode($markers); |
|
| 837 | + //print_r($datar); |
|
| 838 | + $MI->race_add($datar); |
|
| 839 | 839 | } |
| 840 | 840 | } |
| 841 | 841 | if ($bufferm != '') { |
@@ -900,35 +900,35 @@ discard block |
||
| 900 | 900 | sleep(5); |
| 901 | 901 | } |
| 902 | 902 | } |
| 903 | - } |
|
| 904 | - sleep(5); |
|
| 905 | - } |
|
| 906 | - $last_exec[$id]['last'] = time(); |
|
| 903 | + } |
|
| 904 | + sleep(5); |
|
| 905 | + } |
|
| 906 | + $last_exec[$id]['last'] = time(); |
|
| 907 | 907 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 908 | 908 | } elseif ( |
| 909 | - ( |
|
| 909 | + ( |
|
| 910 | 910 | $value['format'] === 'whazzup' && |
| 911 | 911 | ( |
| 912 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 913 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 912 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 913 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 914 | 914 | ) |
| 915 | - ) || ( |
|
| 915 | + ) || ( |
|
| 916 | 916 | $value['format'] === 'vatsimtxt' && |
| 917 | 917 | ( |
| 918 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 919 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 918 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 919 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 920 | + ) |
|
| 920 | 921 | ) |
| 921 | - ) |
|
| 922 | 922 | ) { |
| 923 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 924 | - $buffer = $Common->getData($value['host']); |
|
| 925 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 926 | - $buffer = explode('\n',$buffer); |
|
| 927 | - $reset = 0; |
|
| 928 | - foreach ($buffer as $line) { |
|
| 929 | - if ($line != '') { |
|
| 930 | - $line = explode(':', $line); |
|
| 931 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 923 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 924 | + $buffer = $Common->getData($value['host']); |
|
| 925 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 926 | + $buffer = explode('\n',$buffer); |
|
| 927 | + $reset = 0; |
|
| 928 | + foreach ($buffer as $line) { |
|
| 929 | + if ($line != '') { |
|
| 930 | + $line = explode(':', $line); |
|
| 931 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 932 | 932 | $data = array(); |
| 933 | 933 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 934 | 934 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -941,37 +941,37 @@ discard block |
||
| 941 | 941 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 942 | 942 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 943 | 943 | $data['latitude'] = $line[5]; // lat |
| 944 | - $data['longitude'] = $line[6]; // long |
|
| 945 | - $data['verticalrate'] = ''; // vertical rate |
|
| 946 | - $data['squawk'] = ''; // squawk |
|
| 947 | - $data['emergency'] = ''; // emergency |
|
| 948 | - $data['waypoints'] = $line[30]; |
|
| 944 | + $data['longitude'] = $line[6]; // long |
|
| 945 | + $data['verticalrate'] = ''; // vertical rate |
|
| 946 | + $data['squawk'] = ''; // squawk |
|
| 947 | + $data['emergency'] = ''; // emergency |
|
| 948 | + $data['waypoints'] = $line[30]; |
|
| 949 | 949 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 950 | 950 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 951 | 951 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 952 | - $data['departure_airport_icao'] = $line[11]; |
|
| 953 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 954 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 952 | + $data['departure_airport_icao'] = $line[11]; |
|
| 953 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 954 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 955 | 955 | $data['frequency'] = $line[4]; |
| 956 | 956 | $data['type'] = $line[18]; |
| 957 | 957 | $data['range'] = $line[19]; |
| 958 | 958 | if (isset($line[35])) $data['info'] = $line[35]; |
| 959 | - $data['id_source'] = $id_source; |
|
| 960 | - //$data['arrival_airport_time'] = ; |
|
| 961 | - if ($line[9] != '') { |
|
| 962 | - $aircraft_data = explode('/',$line[9]); |
|
| 963 | - if (isset($aircraft_data[1])) { |
|
| 964 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 965 | - } |
|
| 966 | - } |
|
| 967 | - /* |
|
| 959 | + $data['id_source'] = $id_source; |
|
| 960 | + //$data['arrival_airport_time'] = ; |
|
| 961 | + if ($line[9] != '') { |
|
| 962 | + $aircraft_data = explode('/',$line[9]); |
|
| 963 | + if (isset($aircraft_data[1])) { |
|
| 964 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 965 | + } |
|
| 966 | + } |
|
| 967 | + /* |
|
| 968 | 968 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
| 969 | 969 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 970 | 970 | */ |
| 971 | - $data['format_source'] = $value['format']; |
|
| 971 | + $data['format_source'] = $value['format']; |
|
| 972 | 972 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 973 | 973 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 974 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 974 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
| 975 | 975 | elseif ($line[3] === 'ATC') { |
| 976 | 976 | //print_r($data); |
| 977 | 977 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -992,21 +992,21 @@ discard block |
||
| 992 | 992 | else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
| 993 | 993 | } |
| 994 | 994 | } |
| 995 | - unset($data); |
|
| 996 | - } |
|
| 997 | - } |
|
| 998 | - } |
|
| 999 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
| 1000 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 1001 | - $last_exec[$id]['last'] = time(); |
|
| 1002 | - } elseif ($value['format'] === 'airwhere' && |
|
| 1003 | - ( |
|
| 1004 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1005 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1006 | - ) |
|
| 1007 | - ) { |
|
| 1008 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 1009 | - if ($buffer != '') { |
|
| 995 | + unset($data); |
|
| 996 | + } |
|
| 997 | + } |
|
| 998 | + } |
|
| 999 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
| 1000 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 1001 | + $last_exec[$id]['last'] = time(); |
|
| 1002 | + } elseif ($value['format'] === 'airwhere' && |
|
| 1003 | + ( |
|
| 1004 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1005 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1006 | + ) |
|
| 1007 | + ) { |
|
| 1008 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 1009 | + if ($buffer != '') { |
|
| 1010 | 1010 | $all_data = simplexml_load_string($buffer); |
| 1011 | 1011 | foreach($all_data->children() as $childdata) { |
| 1012 | 1012 | $data = array(); |
@@ -1028,10 +1028,10 @@ discard block |
||
| 1028 | 1028 | $SI->add($data); |
| 1029 | 1029 | unset($data); |
| 1030 | 1030 | } |
| 1031 | - } |
|
| 1032 | - $Source->deleteOldLocationByType('gs'); |
|
| 1033 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 1034 | - if ($buffer != '') { |
|
| 1031 | + } |
|
| 1032 | + $Source->deleteOldLocationByType('gs'); |
|
| 1033 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 1034 | + if ($buffer != '') { |
|
| 1035 | 1035 | $all_data = simplexml_load_string($buffer); |
| 1036 | 1036 | foreach($all_data->children() as $childdata) { |
| 1037 | 1037 | $data = array(); |
@@ -1049,8 +1049,8 @@ discard block |
||
| 1049 | 1049 | } |
| 1050 | 1050 | unset($data); |
| 1051 | 1051 | } |
| 1052 | - } |
|
| 1053 | - $last_exec[$id]['last'] = time(); |
|
| 1052 | + } |
|
| 1053 | + $last_exec[$id]['last'] = time(); |
|
| 1054 | 1054 | /* |
| 1055 | 1055 | } if ($value['format'] === 'aircraftlistjson') { |
| 1056 | 1056 | print_r($globalSources); |
@@ -1058,17 +1058,17 @@ discard block |
||
| 1058 | 1058 | echo $globalMinFetch; |
| 1059 | 1059 | */ |
| 1060 | 1060 | } elseif ($value['format'] === 'aircraftlistjson' && |
| 1061 | - ( |
|
| 1061 | + ( |
|
| 1062 | 1062 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1063 | 1063 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1064 | - ) |
|
| 1064 | + ) |
|
| 1065 | 1065 | ) { |
| 1066 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 1067 | - if ($buffer != '') { |
|
| 1068 | - $all_data = json_decode($buffer,true); |
|
| 1066 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 1067 | + if ($buffer != '') { |
|
| 1068 | + $all_data = json_decode($buffer,true); |
|
| 1069 | 1069 | if (isset($all_data['acList'])) { |
| 1070 | - $reset = 0; |
|
| 1071 | - foreach ($all_data['acList'] as $line) { |
|
| 1070 | + $reset = 0; |
|
| 1071 | + foreach ($all_data['acList'] as $line) { |
|
| 1072 | 1072 | $data = array(); |
| 1073 | 1073 | $data['hex'] = $line['Icao']; // hex |
| 1074 | 1074 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1091,10 +1091,10 @@ discard block |
||
| 1091 | 1091 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1092 | 1092 | if (isset($data['latitude'])) $SI->add($data); |
| 1093 | 1093 | unset($data); |
| 1094 | - } |
|
| 1094 | + } |
|
| 1095 | 1095 | } elseif (is_array($all_data)) { |
| 1096 | - $reset = 0; |
|
| 1097 | - foreach ($all_data as $line) { |
|
| 1096 | + $reset = 0; |
|
| 1097 | + foreach ($all_data as $line) { |
|
| 1098 | 1098 | $data = array(); |
| 1099 | 1099 | $data['hex'] = $line['hex']; // hex |
| 1100 | 1100 | $data['ident'] = $line['flight']; // ident |
@@ -1114,291 +1114,291 @@ discard block |
||
| 1114 | 1114 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1115 | 1115 | $SI->add($data); |
| 1116 | 1116 | unset($data); |
| 1117 | - } |
|
| 1117 | + } |
|
| 1118 | 1118 | } |
| 1119 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1120 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 1121 | - $last_exec[$id]['last'] = time(); |
|
| 1122 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 1123 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
| 1124 | - ( |
|
| 1125 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1126 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1127 | - ) |
|
| 1128 | - ) { |
|
| 1129 | - $buffer = $Common->getData($value['host']); |
|
| 1130 | - $all_data = json_decode($buffer,true); |
|
| 1131 | - if (isset($all_data['planes'])) { |
|
| 1119 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1120 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 1121 | + $last_exec[$id]['last'] = time(); |
|
| 1122 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 1123 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
| 1124 | + ( |
|
| 1125 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1126 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1127 | + ) |
|
| 1128 | + ) { |
|
| 1129 | + $buffer = $Common->getData($value['host']); |
|
| 1130 | + $all_data = json_decode($buffer,true); |
|
| 1131 | + if (isset($all_data['planes'])) { |
|
| 1132 | 1132 | $reset = 0; |
| 1133 | 1133 | foreach ($all_data['planes'] as $key => $line) { |
| 1134 | - $data = array(); |
|
| 1135 | - $data['hex'] = $key; // hex |
|
| 1136 | - $data['ident'] = $line[3]; // ident |
|
| 1137 | - $data['altitude'] = $line[6]; // altitude |
|
| 1138 | - $data['speed'] = $line[8]; // speed |
|
| 1139 | - $data['heading'] = $line[7]; // heading |
|
| 1140 | - $data['latitude'] = $line[4]; // lat |
|
| 1141 | - $data['longitude'] = $line[5]; // long |
|
| 1142 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 1143 | - $data['squawk'] = $line[10]; // squawk |
|
| 1144 | - $data['emergency'] = ''; // emergency |
|
| 1145 | - $data['registration'] = $line[2]; |
|
| 1146 | - $data['aircraft_icao'] = $line[0]; |
|
| 1147 | - $deparr = explode('-',$line[1]); |
|
| 1148 | - if (count($deparr) === 2) { |
|
| 1134 | + $data = array(); |
|
| 1135 | + $data['hex'] = $key; // hex |
|
| 1136 | + $data['ident'] = $line[3]; // ident |
|
| 1137 | + $data['altitude'] = $line[6]; // altitude |
|
| 1138 | + $data['speed'] = $line[8]; // speed |
|
| 1139 | + $data['heading'] = $line[7]; // heading |
|
| 1140 | + $data['latitude'] = $line[4]; // lat |
|
| 1141 | + $data['longitude'] = $line[5]; // long |
|
| 1142 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 1143 | + $data['squawk'] = $line[10]; // squawk |
|
| 1144 | + $data['emergency'] = ''; // emergency |
|
| 1145 | + $data['registration'] = $line[2]; |
|
| 1146 | + $data['aircraft_icao'] = $line[0]; |
|
| 1147 | + $deparr = explode('-',$line[1]); |
|
| 1148 | + if (count($deparr) === 2) { |
|
| 1149 | 1149 | $data['departure_airport_icao'] = $deparr[0]; |
| 1150 | 1150 | $data['arrival_airport_icao'] = $deparr[1]; |
| 1151 | - } |
|
| 1152 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1153 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 1154 | - $data['id_source'] = $id_source; |
|
| 1155 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1156 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1157 | - $SI->add($data); |
|
| 1158 | - unset($data); |
|
| 1151 | + } |
|
| 1152 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1153 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 1154 | + $data['id_source'] = $id_source; |
|
| 1155 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1156 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1157 | + $SI->add($data); |
|
| 1158 | + unset($data); |
|
| 1159 | + } |
|
| 1159 | 1160 | } |
| 1160 | - } |
|
| 1161 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1162 | - $last_exec[$id]['last'] = time(); |
|
| 1161 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1162 | + $last_exec[$id]['last'] = time(); |
|
| 1163 | 1163 | } elseif ($value['format'] === 'opensky' && |
| 1164 | - ( |
|
| 1164 | + ( |
|
| 1165 | 1165 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1166 | 1166 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1167 | - ) |
|
| 1167 | + ) |
|
| 1168 | 1168 | ) { |
| 1169 | - $buffer = $Common->getData($value['host']); |
|
| 1170 | - $all_data = json_decode($buffer,true); |
|
| 1171 | - if (isset($all_data['states'])) { |
|
| 1169 | + $buffer = $Common->getData($value['host']); |
|
| 1170 | + $all_data = json_decode($buffer,true); |
|
| 1171 | + if (isset($all_data['states'])) { |
|
| 1172 | 1172 | $reset = 0; |
| 1173 | 1173 | foreach ($all_data['states'] as $key => $line) { |
| 1174 | - $data = array(); |
|
| 1175 | - $data['hex'] = $line[0]; // hex |
|
| 1176 | - $data['ident'] = trim($line[1]); // ident |
|
| 1177 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 1178 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 1179 | - $data['heading'] = round($line[10]); // heading |
|
| 1180 | - $data['latitude'] = $line[6]; // lat |
|
| 1181 | - $data['longitude'] = $line[5]; // long |
|
| 1182 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 1183 | - //$data['squawk'] = $line[10]; // squawk |
|
| 1184 | - //$data['emergency'] = ''; // emergency |
|
| 1185 | - //$data['registration'] = $line[2]; |
|
| 1186 | - //$data['aircraft_icao'] = $line[0]; |
|
| 1187 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1188 | - $data['format_source'] = 'opensky'; |
|
| 1189 | - $data['id_source'] = $id_source; |
|
| 1190 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1191 | - $SI->add($data); |
|
| 1192 | - unset($data); |
|
| 1174 | + $data = array(); |
|
| 1175 | + $data['hex'] = $line[0]; // hex |
|
| 1176 | + $data['ident'] = trim($line[1]); // ident |
|
| 1177 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 1178 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 1179 | + $data['heading'] = round($line[10]); // heading |
|
| 1180 | + $data['latitude'] = $line[6]; // lat |
|
| 1181 | + $data['longitude'] = $line[5]; // long |
|
| 1182 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 1183 | + //$data['squawk'] = $line[10]; // squawk |
|
| 1184 | + //$data['emergency'] = ''; // emergency |
|
| 1185 | + //$data['registration'] = $line[2]; |
|
| 1186 | + //$data['aircraft_icao'] = $line[0]; |
|
| 1187 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1188 | + $data['format_source'] = 'opensky'; |
|
| 1189 | + $data['id_source'] = $id_source; |
|
| 1190 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1191 | + $SI->add($data); |
|
| 1192 | + unset($data); |
|
| 1193 | 1193 | } |
| 1194 | - } |
|
| 1195 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1196 | - $last_exec[$id]['last'] = time(); |
|
| 1194 | + } |
|
| 1195 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1196 | + $last_exec[$id]['last'] = time(); |
|
| 1197 | 1197 | } elseif ($value['format'] === 'aircraftjson' && |
| 1198 | - ( |
|
| 1198 | + ( |
|
| 1199 | 1199 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1200 | 1200 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1201 | - ) |
|
| 1201 | + ) |
|
| 1202 | 1202 | ) { |
| 1203 | - $buffer = $Common->getData($value['host']); |
|
| 1204 | - $all_data = json_decode($buffer,true); |
|
| 1205 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1203 | + $buffer = $Common->getData($value['host']); |
|
| 1204 | + $all_data = json_decode($buffer,true); |
|
| 1205 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1206 | 1206 | $reset = 0; |
| 1207 | 1207 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1208 | - $data = array(); |
|
| 1209 | - // add support for ground vehicule with ~ in front of hex |
|
| 1210 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1211 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1212 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1213 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1214 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1215 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1216 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1217 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1218 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1219 | - //$data['emergency'] = ''; // emergency |
|
| 1220 | - //$data['registration'] = $line[2]; |
|
| 1221 | - //$data['aircraft_icao'] = $line[0]; |
|
| 1222 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1223 | - $data['format_source'] = 'aircraftjson'; |
|
| 1224 | - $data['id_source'] = $id_source; |
|
| 1225 | - if (isset($value['name']) && $value['name'] != '') { |
|
| 1226 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1227 | - else $data['source_name'] = $value['name']; |
|
| 1228 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1229 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1230 | - $SI->add($data); |
|
| 1231 | - unset($data); |
|
| 1208 | + $data = array(); |
|
| 1209 | + // add support for ground vehicule with ~ in front of hex |
|
| 1210 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1211 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1212 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1213 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1214 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1215 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1216 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1217 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1218 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1219 | + //$data['emergency'] = ''; // emergency |
|
| 1220 | + //$data['registration'] = $line[2]; |
|
| 1221 | + //$data['aircraft_icao'] = $line[0]; |
|
| 1222 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1223 | + $data['format_source'] = 'aircraftjson'; |
|
| 1224 | + $data['id_source'] = $id_source; |
|
| 1225 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1226 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1227 | + else $data['source_name'] = $value['name']; |
|
| 1228 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1229 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1230 | + $SI->add($data); |
|
| 1231 | + unset($data); |
|
| 1232 | + } |
|
| 1232 | 1233 | } |
| 1233 | - } |
|
| 1234 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1235 | - $last_exec[$id]['last'] = time(); |
|
| 1234 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1235 | + $last_exec[$id]['last'] = time(); |
|
| 1236 | 1236 | } elseif ($value['format'] === 'planefinderclient' && |
| 1237 | - ( |
|
| 1237 | + ( |
|
| 1238 | 1238 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1239 | 1239 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1240 | - ) |
|
| 1240 | + ) |
|
| 1241 | 1241 | ) { |
| 1242 | - $buffer = $Common->getData($value['host']); |
|
| 1243 | - $all_data = json_decode($buffer,true); |
|
| 1244 | - if (isset($all_data['aircraft'])) { |
|
| 1242 | + $buffer = $Common->getData($value['host']); |
|
| 1243 | + $all_data = json_decode($buffer,true); |
|
| 1244 | + if (isset($all_data['aircraft'])) { |
|
| 1245 | 1245 | $reset = 0; |
| 1246 | 1246 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1247 | - $data = array(); |
|
| 1248 | - $data['hex'] = $key; // hex |
|
| 1249 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1250 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1251 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1252 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1253 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1254 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1255 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1256 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1257 | - //$data['emergency'] = ''; // emergency |
|
| 1258 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1259 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1260 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1261 | - $data['format_source'] = 'planefinderclient'; |
|
| 1262 | - $data['id_source'] = $id_source; |
|
| 1263 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1264 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1265 | - $SI->add($data); |
|
| 1266 | - unset($data); |
|
| 1247 | + $data = array(); |
|
| 1248 | + $data['hex'] = $key; // hex |
|
| 1249 | + if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1250 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1251 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1252 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1253 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1254 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1255 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1256 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1257 | + //$data['emergency'] = ''; // emergency |
|
| 1258 | + if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1259 | + if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1260 | + $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1261 | + $data['format_source'] = 'planefinderclient'; |
|
| 1262 | + $data['id_source'] = $id_source; |
|
| 1263 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1264 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1265 | + $SI->add($data); |
|
| 1266 | + unset($data); |
|
| 1267 | 1267 | } |
| 1268 | - } |
|
| 1269 | - $last_exec[$id]['last'] = time(); |
|
| 1268 | + } |
|
| 1269 | + $last_exec[$id]['last'] = time(); |
|
| 1270 | 1270 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
| 1271 | 1271 | } elseif ($value['format'] === 'fr24json' && |
| 1272 | - ( |
|
| 1272 | + ( |
|
| 1273 | 1273 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1274 | 1274 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1275 | - ) |
|
| 1275 | + ) |
|
| 1276 | 1276 | ) { |
| 1277 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1278 | - $buffer = $Common->getData($value['host']); |
|
| 1279 | - $all_data = json_decode($buffer,true); |
|
| 1280 | - if (!empty($all_data)) $reset = 0; |
|
| 1281 | - foreach ($all_data as $key => $line) { |
|
| 1277 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1278 | + $buffer = $Common->getData($value['host']); |
|
| 1279 | + $all_data = json_decode($buffer,true); |
|
| 1280 | + if (!empty($all_data)) $reset = 0; |
|
| 1281 | + foreach ($all_data as $key => $line) { |
|
| 1282 | 1282 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1283 | - $data = array(); |
|
| 1284 | - $data['hex'] = $line[0]; |
|
| 1285 | - $data['ident'] = $line[16]; //$line[13] |
|
| 1286 | - $data['altitude'] = $line[4]; // altitude |
|
| 1287 | - $data['speed'] = $line[5]; // speed |
|
| 1288 | - $data['heading'] = $line[3]; // heading |
|
| 1289 | - $data['latitude'] = $line[1]; // lat |
|
| 1290 | - $data['longitude'] = $line[2]; // long |
|
| 1291 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1292 | - $data['squawk'] = $line[6]; // squawk |
|
| 1293 | - $data['aircraft_icao'] = $line[8]; |
|
| 1294 | - $data['registration'] = $line[9]; |
|
| 1295 | - $data['departure_airport_iata'] = $line[11]; |
|
| 1296 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 1297 | - $data['emergency'] = ''; // emergency |
|
| 1298 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1299 | - $data['format_source'] = 'fr24json'; |
|
| 1300 | - $data['id_source'] = $id_source; |
|
| 1301 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1302 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1303 | - $SI->add($data); |
|
| 1304 | - unset($data); |
|
| 1283 | + $data = array(); |
|
| 1284 | + $data['hex'] = $line[0]; |
|
| 1285 | + $data['ident'] = $line[16]; //$line[13] |
|
| 1286 | + $data['altitude'] = $line[4]; // altitude |
|
| 1287 | + $data['speed'] = $line[5]; // speed |
|
| 1288 | + $data['heading'] = $line[3]; // heading |
|
| 1289 | + $data['latitude'] = $line[1]; // lat |
|
| 1290 | + $data['longitude'] = $line[2]; // long |
|
| 1291 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1292 | + $data['squawk'] = $line[6]; // squawk |
|
| 1293 | + $data['aircraft_icao'] = $line[8]; |
|
| 1294 | + $data['registration'] = $line[9]; |
|
| 1295 | + $data['departure_airport_iata'] = $line[11]; |
|
| 1296 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 1297 | + $data['emergency'] = ''; // emergency |
|
| 1298 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1299 | + $data['format_source'] = 'fr24json'; |
|
| 1300 | + $data['id_source'] = $id_source; |
|
| 1301 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1302 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1303 | + $SI->add($data); |
|
| 1304 | + unset($data); |
|
| 1305 | 1305 | } |
| 1306 | - } |
|
| 1307 | - //$last_exec['fr24json'] = time(); |
|
| 1308 | - $last_exec[$id]['last'] = time(); |
|
| 1306 | + } |
|
| 1307 | + //$last_exec['fr24json'] = time(); |
|
| 1308 | + $last_exec[$id]['last'] = time(); |
|
| 1309 | 1309 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 1310 | 1310 | } elseif ($value['format'] === 'radarvirtueljson' && |
| 1311 | - ( |
|
| 1311 | + ( |
|
| 1312 | 1312 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1313 | 1313 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1314 | - ) |
|
| 1314 | + ) |
|
| 1315 | 1315 | ) { |
| 1316 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1317 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1318 | - //echo $buffer; |
|
| 1319 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1320 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1321 | - $all_data = json_decode($buffer,true); |
|
| 1322 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1316 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1317 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1318 | + //echo $buffer; |
|
| 1319 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1320 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1321 | + $all_data = json_decode($buffer,true); |
|
| 1322 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1323 | 1323 | die(json_last_error_msg()); |
| 1324 | - } |
|
| 1325 | - if (isset($all_data['mrkrs'])) { |
|
| 1324 | + } |
|
| 1325 | + if (isset($all_data['mrkrs'])) { |
|
| 1326 | 1326 | $reset = 0; |
| 1327 | 1327 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 1328 | - if (isset($line['inf'])) { |
|
| 1328 | + if (isset($line['inf'])) { |
|
| 1329 | 1329 | $data = array(); |
| 1330 | 1330 | $data['hex'] = $line['inf']['ia']; |
| 1331 | 1331 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 1332 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1333 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1334 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1335 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 1336 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 1337 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1338 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1339 | - //$data['aircraft_icao'] = $line[8]; |
|
| 1340 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1332 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1333 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1334 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1335 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 1336 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 1337 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1338 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1339 | + //$data['aircraft_icao'] = $line[8]; |
|
| 1340 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1341 | 1341 | //$data['departure_airport_iata'] = $line[11]; |
| 1342 | 1342 | //$data['arrival_airport_iata'] = $line[12]; |
| 1343 | - //$data['emergency'] = ''; // emergency |
|
| 1343 | + //$data['emergency'] = ''; // emergency |
|
| 1344 | 1344 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1345 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 1346 | - $data['id_source'] = $id_source; |
|
| 1345 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 1346 | + $data['id_source'] = $id_source; |
|
| 1347 | 1347 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1348 | 1348 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1349 | 1349 | $SI->add($data); |
| 1350 | 1350 | unset($data); |
| 1351 | - } |
|
| 1351 | + } |
|
| 1352 | 1352 | } |
| 1353 | - } |
|
| 1354 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 1355 | - $last_exec[$id]['last'] = time(); |
|
| 1353 | + } |
|
| 1354 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 1355 | + $last_exec[$id]['last'] = time(); |
|
| 1356 | 1356 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
| 1357 | 1357 | } elseif ($value['format'] === 'pirepsjson' && |
| 1358 | - ( |
|
| 1358 | + ( |
|
| 1359 | 1359 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1360 | 1360 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1361 | - ) |
|
| 1361 | + ) |
|
| 1362 | 1362 | ) { |
| 1363 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1364 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1365 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1363 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1364 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1365 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1366 | 1366 | |
| 1367 | - if (isset($all_data['pireps'])) { |
|
| 1367 | + if (isset($all_data['pireps'])) { |
|
| 1368 | 1368 | $reset = 0; |
| 1369 | - foreach ($all_data['pireps'] as $line) { |
|
| 1370 | - $data = array(); |
|
| 1371 | - $data['id'] = $line['id']; |
|
| 1372 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1373 | - $data['ident'] = $line['callsign']; // ident |
|
| 1374 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1375 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1376 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1377 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1378 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1379 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1380 | - $data['latitude'] = $line['lat']; // lat |
|
| 1381 | - $data['longitude'] = $line['lon']; // long |
|
| 1382 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1383 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 1384 | - //$data['emergency'] = ''; // emergency |
|
| 1385 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1386 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1387 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1388 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1389 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1390 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1391 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1392 | - else $data['info'] = ''; |
|
| 1393 | - $data['format_source'] = 'pireps'; |
|
| 1394 | - $data['id_source'] = $id_source; |
|
| 1395 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1396 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1397 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1398 | - if ($line['icon'] === 'plane') { |
|
| 1369 | + foreach ($all_data['pireps'] as $line) { |
|
| 1370 | + $data = array(); |
|
| 1371 | + $data['id'] = $line['id']; |
|
| 1372 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1373 | + $data['ident'] = $line['callsign']; // ident |
|
| 1374 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1375 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1376 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1377 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1378 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1379 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1380 | + $data['latitude'] = $line['lat']; // lat |
|
| 1381 | + $data['longitude'] = $line['lon']; // long |
|
| 1382 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1383 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 1384 | + //$data['emergency'] = ''; // emergency |
|
| 1385 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1386 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1387 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1388 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1389 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1390 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1391 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1392 | + else $data['info'] = ''; |
|
| 1393 | + $data['format_source'] = 'pireps'; |
|
| 1394 | + $data['id_source'] = $id_source; |
|
| 1395 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1396 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1397 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1398 | + if ($line['icon'] === 'plane') { |
|
| 1399 | 1399 | $SI->add($data); |
| 1400 | - // print_r($data); |
|
| 1401 | - } elseif ($line['icon'] === 'ct') { |
|
| 1400 | + // print_r($data); |
|
| 1401 | + } elseif ($line['icon'] === 'ct') { |
|
| 1402 | 1402 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 1403 | 1403 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1404 | 1404 | $typec = substr($data['ident'],-3); |
@@ -1413,209 +1413,209 @@ discard block |
||
| 1413 | 1413 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1414 | 1414 | else $data['type'] = 'Observer'; |
| 1415 | 1415 | if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
| 1416 | - } |
|
| 1417 | - unset($data); |
|
| 1416 | + } |
|
| 1417 | + unset($data); |
|
| 1418 | 1418 | } |
| 1419 | - } |
|
| 1420 | - //$last_exec['pirepsjson'] = time(); |
|
| 1421 | - $last_exec[$id]['last'] = time(); |
|
| 1419 | + } |
|
| 1420 | + //$last_exec['pirepsjson'] = time(); |
|
| 1421 | + $last_exec[$id]['last'] = time(); |
|
| 1422 | 1422 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 1423 | 1423 | } elseif ($value['format'] === 'phpvmacars' && |
| 1424 | - ( |
|
| 1424 | + ( |
|
| 1425 | 1425 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1426 | 1426 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1427 | - ) |
|
| 1427 | + ) |
|
| 1428 | 1428 | ) { |
| 1429 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1430 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1431 | - $buffer = $Common->getData($value['host']); |
|
| 1432 | - $all_data = json_decode($buffer,true); |
|
| 1433 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1429 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1430 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1431 | + $buffer = $Common->getData($value['host']); |
|
| 1432 | + $all_data = json_decode($buffer,true); |
|
| 1433 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1434 | 1434 | $reset = 0; |
| 1435 | 1435 | foreach ($all_data as $line) { |
| 1436 | - $data = array(); |
|
| 1437 | - //$data['id'] = $line['id']; // id not usable |
|
| 1438 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1439 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1440 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1441 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1442 | - $data['ident'] = $line['flightnum']; // ident |
|
| 1443 | - $data['altitude'] = $line['alt']; // altitude |
|
| 1444 | - $data['speed'] = $line['gs']; // speed |
|
| 1445 | - $data['heading'] = $line['heading']; // heading |
|
| 1446 | - $data['latitude'] = $line['lat']; // lat |
|
| 1447 | - $data['longitude'] = $line['lng']; // long |
|
| 1448 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1449 | - $data['squawk'] = ''; // squawk |
|
| 1450 | - $data['emergency'] = ''; // emergency |
|
| 1451 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1452 | - //$data['last_update'] = $line['lastupdate']; |
|
| 1453 | - if (isset($value['timezone'])) { |
|
| 1454 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1455 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1456 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1457 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1458 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 1459 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 1460 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1461 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1462 | - if (isset($line['registration'])) { |
|
| 1463 | - $data['registration'] = $line['registration']; |
|
| 1464 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1465 | - } else $data['registration'] = $line['aircraft']; |
|
| 1466 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1467 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1468 | - if (isset($line['aircraftname'])) { |
|
| 1436 | + $data = array(); |
|
| 1437 | + //$data['id'] = $line['id']; // id not usable |
|
| 1438 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1439 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1440 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1441 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1442 | + $data['ident'] = $line['flightnum']; // ident |
|
| 1443 | + $data['altitude'] = $line['alt']; // altitude |
|
| 1444 | + $data['speed'] = $line['gs']; // speed |
|
| 1445 | + $data['heading'] = $line['heading']; // heading |
|
| 1446 | + $data['latitude'] = $line['lat']; // lat |
|
| 1447 | + $data['longitude'] = $line['lng']; // long |
|
| 1448 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1449 | + $data['squawk'] = ''; // squawk |
|
| 1450 | + $data['emergency'] = ''; // emergency |
|
| 1451 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1452 | + //$data['last_update'] = $line['lastupdate']; |
|
| 1453 | + if (isset($value['timezone'])) { |
|
| 1454 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1455 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1456 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1457 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1458 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1459 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1460 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1461 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1462 | + if (isset($line['registration'])) { |
|
| 1463 | + $data['registration'] = $line['registration']; |
|
| 1464 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1465 | + } else $data['registration'] = $line['aircraft']; |
|
| 1466 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1467 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1468 | + if (isset($line['aircraftname'])) { |
|
| 1469 | 1469 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1470 | 1470 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1471 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1472 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1473 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1474 | - else { |
|
| 1475 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1476 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1477 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1478 | - } |
|
| 1479 | - } |
|
| 1480 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1481 | - $data['id_source'] = $id_source; |
|
| 1482 | - $data['format_source'] = 'phpvmacars'; |
|
| 1483 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1484 | - $SI->add($data); |
|
| 1485 | - unset($data); |
|
| 1471 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1472 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1473 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1474 | + else { |
|
| 1475 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1476 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1477 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1478 | + } |
|
| 1479 | + } |
|
| 1480 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1481 | + $data['id_source'] = $id_source; |
|
| 1482 | + $data['format_source'] = 'phpvmacars'; |
|
| 1483 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1484 | + $SI->add($data); |
|
| 1485 | + unset($data); |
|
| 1486 | 1486 | } |
| 1487 | 1487 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1488 | 1488 | unset($buffer); |
| 1489 | 1489 | unset($all_data); |
| 1490 | - } |
|
| 1491 | - //$last_exec['phpvmacars'] = time(); |
|
| 1492 | - $last_exec[$id]['last'] = time(); |
|
| 1490 | + } |
|
| 1491 | + //$last_exec['phpvmacars'] = time(); |
|
| 1492 | + $last_exec[$id]['last'] = time(); |
|
| 1493 | 1493 | } elseif ($value['format'] === 'vaos' && |
| 1494 | - ( |
|
| 1494 | + ( |
|
| 1495 | 1495 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1496 | 1496 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1497 | - ) |
|
| 1497 | + ) |
|
| 1498 | 1498 | ) { |
| 1499 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1500 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1501 | - $buffer = $Common->getData($value['host']); |
|
| 1502 | - $all_data = json_decode($buffer,true); |
|
| 1503 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
| 1499 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1500 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1501 | + $buffer = $Common->getData($value['host']); |
|
| 1502 | + $all_data = json_decode($buffer,true); |
|
| 1503 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
| 1504 | 1504 | $reset = 0; |
| 1505 | 1505 | foreach ($all_data['ACARSData'] as $line) { |
| 1506 | - //print_r($line); |
|
| 1507 | - $data = array(); |
|
| 1508 | - //$data['id'] = $line['id']; // id not usable |
|
| 1509 | - $data['id'] = $line['id']; |
|
| 1510 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1511 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1512 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1513 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1514 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1515 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1516 | - $data['speed'] = $line['groundspeed']; // speed |
|
| 1517 | - $data['heading'] = $line['heading']; // heading |
|
| 1518 | - $data['latitude'] = $line['lat']; // lat |
|
| 1519 | - $data['longitude'] = $line['lon']; // long |
|
| 1520 | - //$data['verticalrate'] = ''; // verticale rate |
|
| 1521 | - //$data['squawk'] = ''; // squawk |
|
| 1522 | - //$data['emergency'] = ''; // emergency |
|
| 1523 | - if (isset($value['timezone'])) { |
|
| 1524 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1525 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1526 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1527 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1506 | + //print_r($line); |
|
| 1507 | + $data = array(); |
|
| 1508 | + //$data['id'] = $line['id']; // id not usable |
|
| 1509 | + $data['id'] = $line['id']; |
|
| 1510 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1511 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1512 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1513 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1514 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1515 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1516 | + $data['speed'] = $line['groundspeed']; // speed |
|
| 1517 | + $data['heading'] = $line['heading']; // heading |
|
| 1518 | + $data['latitude'] = $line['lat']; // lat |
|
| 1519 | + $data['longitude'] = $line['lon']; // long |
|
| 1520 | + //$data['verticalrate'] = ''; // verticale rate |
|
| 1521 | + //$data['squawk'] = ''; // squawk |
|
| 1522 | + //$data['emergency'] = ''; // emergency |
|
| 1523 | + if (isset($value['timezone'])) { |
|
| 1524 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1525 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1526 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1527 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1528 | 1528 | |
| 1529 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
| 1530 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
| 1531 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
| 1532 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
| 1533 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
| 1529 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
| 1530 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
| 1531 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
| 1532 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
| 1533 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
| 1534 | 1534 | |
| 1535 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1536 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1537 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
| 1535 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1536 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1537 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
| 1538 | 1538 | |
| 1539 | - $data['id_source'] = $id_source; |
|
| 1540 | - $data['format_source'] = 'vaos'; |
|
| 1541 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1542 | - $SI->add($data); |
|
| 1543 | - unset($data); |
|
| 1539 | + $data['id_source'] = $id_source; |
|
| 1540 | + $data['format_source'] = 'vaos'; |
|
| 1541 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1542 | + $SI->add($data); |
|
| 1543 | + unset($data); |
|
| 1544 | 1544 | } |
| 1545 | 1545 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1546 | 1546 | unset($buffer); |
| 1547 | 1547 | unset($all_data); |
| 1548 | - } |
|
| 1549 | - //$last_exec['phpvmacars'] = time(); |
|
| 1550 | - $last_exec[$id]['last'] = time(); |
|
| 1548 | + } |
|
| 1549 | + //$last_exec['phpvmacars'] = time(); |
|
| 1550 | + $last_exec[$id]['last'] = time(); |
|
| 1551 | 1551 | } elseif ($value['format'] === 'vam' && |
| 1552 | - ( |
|
| 1552 | + ( |
|
| 1553 | 1553 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1554 | 1554 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1555 | - ) |
|
| 1555 | + ) |
|
| 1556 | 1556 | ) { |
| 1557 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1558 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1559 | - $buffer = $Common->getData($value['host']); |
|
| 1560 | - $all_data = json_decode($buffer,true); |
|
| 1561 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1557 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1558 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1559 | + $buffer = $Common->getData($value['host']); |
|
| 1560 | + $all_data = json_decode($buffer,true); |
|
| 1561 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1562 | 1562 | $reset = 0; |
| 1563 | 1563 | foreach ($all_data as $line) { |
| 1564 | - $data = array(); |
|
| 1565 | - //$data['id'] = $line['id']; // id not usable |
|
| 1566 | - $data['id'] = trim($line['flight_id']); |
|
| 1567 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1568 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 1569 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 1570 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 1571 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1572 | - $data['speed'] = $line['gs']; // speed |
|
| 1573 | - $data['heading'] = $line['heading']; // heading |
|
| 1574 | - $data['latitude'] = $line['latitude']; // lat |
|
| 1575 | - $data['longitude'] = $line['longitude']; // long |
|
| 1576 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1577 | - $data['squawk'] = ''; // squawk |
|
| 1578 | - $data['emergency'] = ''; // emergency |
|
| 1579 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1580 | - $data['last_update'] = $line['last_update']; |
|
| 1581 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1582 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 1583 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1584 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1585 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1586 | - //$data['registration'] = $line['aircraft']; |
|
| 1587 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1588 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 1589 | - $data['id_source'] = $id_source; |
|
| 1590 | - $data['format_source'] = 'vam'; |
|
| 1591 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1592 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1593 | - $SI->add($data); |
|
| 1594 | - unset($data); |
|
| 1564 | + $data = array(); |
|
| 1565 | + //$data['id'] = $line['id']; // id not usable |
|
| 1566 | + $data['id'] = trim($line['flight_id']); |
|
| 1567 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1568 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 1569 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 1570 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 1571 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1572 | + $data['speed'] = $line['gs']; // speed |
|
| 1573 | + $data['heading'] = $line['heading']; // heading |
|
| 1574 | + $data['latitude'] = $line['latitude']; // lat |
|
| 1575 | + $data['longitude'] = $line['longitude']; // long |
|
| 1576 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1577 | + $data['squawk'] = ''; // squawk |
|
| 1578 | + $data['emergency'] = ''; // emergency |
|
| 1579 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1580 | + $data['last_update'] = $line['last_update']; |
|
| 1581 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1582 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 1583 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1584 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1585 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1586 | + //$data['registration'] = $line['aircraft']; |
|
| 1587 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1588 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 1589 | + $data['id_source'] = $id_source; |
|
| 1590 | + $data['format_source'] = 'vam'; |
|
| 1591 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1592 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1593 | + $SI->add($data); |
|
| 1594 | + unset($data); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1597 | 1597 | unset($buffer); |
| 1598 | 1598 | unset($all_data); |
| 1599 | - } |
|
| 1600 | - //$last_exec['phpvmacars'] = time(); |
|
| 1601 | - $last_exec[$id]['last'] = time(); |
|
| 1599 | + } |
|
| 1600 | + //$last_exec['phpvmacars'] = time(); |
|
| 1601 | + $last_exec[$id]['last'] = time(); |
|
| 1602 | 1602 | } elseif ($value['format'] === 'blitzortung' && |
| 1603 | - ( |
|
| 1603 | + ( |
|
| 1604 | 1604 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1605 | 1605 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1606 | - ) |
|
| 1606 | + ) |
|
| 1607 | 1607 | ) { |
| 1608 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1609 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1610 | - $buffer = $Common->getData($value['host']); |
|
| 1611 | - $all_data = json_decode($buffer,true); |
|
| 1612 | - if ($buffer != '') { |
|
| 1608 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1609 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1610 | + $buffer = $Common->getData($value['host']); |
|
| 1611 | + $all_data = json_decode($buffer,true); |
|
| 1612 | + if ($buffer != '') { |
|
| 1613 | 1613 | $Source->deleteLocationBySource('blitzortung'); |
| 1614 | 1614 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 1615 | 1615 | $buffer = explode('\n',$buffer); |
| 1616 | 1616 | foreach ($buffer as $buffer_line) { |
| 1617 | - $line = json_decode($buffer_line,true); |
|
| 1618 | - if (isset($line['time'])) { |
|
| 1617 | + $line = json_decode($buffer_line,true); |
|
| 1618 | + if (isset($line['time'])) { |
|
| 1619 | 1619 | $data = array(); |
| 1620 | 1620 | $data['altitude'] = $line['alt']; // altitude |
| 1621 | 1621 | $data['latitude'] = $line['lat']; // lat |
@@ -1627,92 +1627,92 @@ discard block |
||
| 1627 | 1627 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1628 | 1628 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1629 | 1629 | unset($data); |
| 1630 | - } |
|
| 1630 | + } |
|
| 1631 | 1631 | } |
| 1632 | 1632 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1633 | 1633 | unset($buffer); |
| 1634 | - } |
|
| 1635 | - $last_exec[$id]['last'] = time(); |
|
| 1634 | + } |
|
| 1635 | + $last_exec[$id]['last'] = time(); |
|
| 1636 | 1636 | } elseif ($value['format'] === 'acarsjson') { |
| 1637 | - $arr = $httpfeeds; |
|
| 1638 | - $w = $e = null; |
|
| 1639 | - if (isset($arr[$id])) { |
|
| 1640 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 1641 | - if ($nn > 0) { |
|
| 1642 | - foreach ($httpfeeds as $feed) { |
|
| 1643 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 1644 | - if ($buffer === FALSE) { |
|
| 1645 | - connect_all($globalSources); |
|
| 1646 | - } |
|
| 1647 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1648 | - $buffer = explode('\n',$buffer); |
|
| 1649 | - foreach ($buffer as $line) { |
|
| 1650 | - if ($line != '') { |
|
| 1651 | - $line = json_decode($line, true); |
|
| 1652 | - if (!empty($line)) { |
|
| 1653 | - $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
| 1654 | - $ACARS->deleteLiveAcarsData(); |
|
| 1655 | - } |
|
| 1656 | - } |
|
| 1657 | - } |
|
| 1658 | - } |
|
| 1659 | - } else { |
|
| 1660 | - $format = $value['format']; |
|
| 1661 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1662 | - else $tt[$format] = 0; |
|
| 1663 | - if ($tt[$format] > 30) { |
|
| 1664 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 1665 | - sleep(2); |
|
| 1666 | - //$sourceeen[] = $value; |
|
| 1667 | - //connect_all($sourceeen); |
|
| 1668 | - //$sourceeen = array(); |
|
| 1669 | - connect_all($globalSources); |
|
| 1670 | - } |
|
| 1671 | - } |
|
| 1672 | - } |
|
| 1637 | + $arr = $httpfeeds; |
|
| 1638 | + $w = $e = null; |
|
| 1639 | + if (isset($arr[$id])) { |
|
| 1640 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
| 1641 | + if ($nn > 0) { |
|
| 1642 | + foreach ($httpfeeds as $feed) { |
|
| 1643 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
| 1644 | + if ($buffer === FALSE) { |
|
| 1645 | + connect_all($globalSources); |
|
| 1646 | + } |
|
| 1647 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1648 | + $buffer = explode('\n',$buffer); |
|
| 1649 | + foreach ($buffer as $line) { |
|
| 1650 | + if ($line != '') { |
|
| 1651 | + $line = json_decode($line, true); |
|
| 1652 | + if (!empty($line)) { |
|
| 1653 | + $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
| 1654 | + $ACARS->deleteLiveAcarsData(); |
|
| 1655 | + } |
|
| 1656 | + } |
|
| 1657 | + } |
|
| 1658 | + } |
|
| 1659 | + } else { |
|
| 1660 | + $format = $value['format']; |
|
| 1661 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1662 | + else $tt[$format] = 0; |
|
| 1663 | + if ($tt[$format] > 30) { |
|
| 1664 | + if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 1665 | + sleep(2); |
|
| 1666 | + //$sourceeen[] = $value; |
|
| 1667 | + //connect_all($sourceeen); |
|
| 1668 | + //$sourceeen = array(); |
|
| 1669 | + connect_all($globalSources); |
|
| 1670 | + } |
|
| 1671 | + } |
|
| 1672 | + } |
|
| 1673 | 1673 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
| 1674 | 1674 | } elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarsjsonudp' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') { |
| 1675 | - //$last_exec[$id]['last'] = time(); |
|
| 1676 | - //$read = array( $sockets[$id] ); |
|
| 1677 | - $read = $sockets; |
|
| 1678 | - $write = NULL; |
|
| 1679 | - $e = NULL; |
|
| 1680 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 1681 | - if ($e != NULL) var_dump($e); |
|
| 1682 | - if ($n > 0) { |
|
| 1675 | + //$last_exec[$id]['last'] = time(); |
|
| 1676 | + //$read = array( $sockets[$id] ); |
|
| 1677 | + $read = $sockets; |
|
| 1678 | + $write = NULL; |
|
| 1679 | + $e = NULL; |
|
| 1680 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 1681 | + if ($e != NULL) var_dump($e); |
|
| 1682 | + if ($n > 0) { |
|
| 1683 | 1683 | $reset = 0; |
| 1684 | 1684 | foreach ($read as $nb => $r) { |
| 1685 | - //$value = $formats[$nb]; |
|
| 1686 | - $format = $globalSources[$nb]['format']; |
|
| 1687 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
| 1685 | + //$value = $formats[$nb]; |
|
| 1686 | + $format = $globalSources[$nb]['format']; |
|
| 1687 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
| 1688 | 1688 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
| 1689 | - } elseif ($format === 'vrstcp') { |
|
| 1689 | + } elseif ($format === 'vrstcp') { |
|
| 1690 | 1690 | $buffer = @socket_read($r, 6000); |
| 1691 | - } else { |
|
| 1691 | + } else { |
|
| 1692 | 1692 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
| 1693 | - } |
|
| 1694 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1695 | - //echo $buffer."\n"; |
|
| 1696 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1697 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1698 | - $error = false; |
|
| 1699 | - //$SI::del(); |
|
| 1700 | - if ($buffer !== FALSE) { |
|
| 1693 | + } |
|
| 1694 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1695 | + //echo $buffer."\n"; |
|
| 1696 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1697 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1698 | + $error = false; |
|
| 1699 | + //$SI::del(); |
|
| 1700 | + if ($buffer !== FALSE) { |
|
| 1701 | 1701 | if ($format === 'vrstcp') { |
| 1702 | - $buffer = explode('},{',$buffer); |
|
| 1702 | + $buffer = explode('},{',$buffer); |
|
| 1703 | 1703 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
| 1704 | - } |
|
| 1705 | - // SBS format is CSV format |
|
| 1706 | - if ($buffer !== FALSE && $buffer !== '') { |
|
| 1704 | + } |
|
| 1705 | + // SBS format is CSV format |
|
| 1706 | + if ($buffer !== FALSE && $buffer !== '') { |
|
| 1707 | 1707 | $tt[$format] = 0; |
| 1708 | 1708 | if ($format === 'acarssbs3') { |
| 1709 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1710 | - $ACARS->add(trim($buffer)); |
|
| 1711 | - $ACARS->deleteLiveAcarsData(); |
|
| 1709 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1710 | + $ACARS->add(trim($buffer)); |
|
| 1711 | + $ACARS->deleteLiveAcarsData(); |
|
| 1712 | 1712 | } elseif ($format === 'raw') { |
| 1713 | - // AVR format |
|
| 1714 | - $data = $SBS->parse($buffer); |
|
| 1715 | - if (is_array($data)) { |
|
| 1713 | + // AVR format |
|
| 1714 | + $data = $SBS->parse($buffer); |
|
| 1715 | + if (is_array($data)) { |
|
| 1716 | 1716 | //if (!empty($data)) print_r($data); |
| 1717 | 1717 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1718 | 1718 | $data['format_source'] = 'raw'; |
@@ -1722,39 +1722,39 @@ discard block |
||
| 1722 | 1722 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1723 | 1723 | $SI->add($data); |
| 1724 | 1724 | unset($data); |
| 1725 | - } |
|
| 1725 | + } |
|
| 1726 | 1726 | } elseif ($format === 'ais') { |
| 1727 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1728 | - $data = array(); |
|
| 1729 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1730 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1731 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1732 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1733 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1734 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1735 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1736 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1737 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1738 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1739 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1740 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1741 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1742 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1743 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1744 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1727 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1728 | + $data = array(); |
|
| 1729 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1730 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1731 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1732 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1733 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1734 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1735 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1736 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1737 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1738 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1739 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1740 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1741 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1742 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1743 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1744 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1745 | 1745 | |
| 1746 | - if (isset($ais_data['timestamp'])) { |
|
| 1746 | + if (isset($ais_data['timestamp'])) { |
|
| 1747 | 1747 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 1748 | - } else { |
|
| 1748 | + } else { |
|
| 1749 | 1749 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1750 | - } |
|
| 1751 | - $data['format_source'] = 'aisnmea'; |
|
| 1752 | - $data['id_source'] = $id_source; |
|
| 1753 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 1754 | - unset($data); |
|
| 1755 | - } elseif ($format === 'flightgearsp') { |
|
| 1756 | - //echo $buffer."\n"; |
|
| 1757 | - if (strlen($buffer) > 5) { |
|
| 1750 | + } |
|
| 1751 | + $data['format_source'] = 'aisnmea'; |
|
| 1752 | + $data['id_source'] = $id_source; |
|
| 1753 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 1754 | + unset($data); |
|
| 1755 | + } elseif ($format === 'flightgearsp') { |
|
| 1756 | + //echo $buffer."\n"; |
|
| 1757 | + if (strlen($buffer) > 5) { |
|
| 1758 | 1758 | $line = explode(',',$buffer); |
| 1759 | 1759 | $data = array(); |
| 1760 | 1760 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1771,47 +1771,47 @@ discard block |
||
| 1771 | 1771 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1772 | 1772 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1773 | 1773 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1774 | - } |
|
| 1775 | - } elseif ($format === 'acars') { |
|
| 1776 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1777 | - $ACARS->add(trim($buffer)); |
|
| 1778 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1779 | - $ACARS->deleteLiveAcarsData(); |
|
| 1774 | + } |
|
| 1775 | + } elseif ($format === 'acars') { |
|
| 1776 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1777 | + $ACARS->add(trim($buffer)); |
|
| 1778 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1779 | + $ACARS->deleteLiveAcarsData(); |
|
| 1780 | 1780 | } elseif ($format === 'acarsjsonudp') { |
| 1781 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1782 | - $line = json_decode(trim($buffer), true); |
|
| 1783 | - if (!empty($line)) { |
|
| 1781 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1782 | + $line = json_decode(trim($buffer), true); |
|
| 1783 | + if (!empty($line)) { |
|
| 1784 | 1784 | $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
| 1785 | - $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
| 1786 | - $ACARS->deleteLiveAcarsData(); |
|
| 1787 | - } |
|
| 1788 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1785 | + $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
| 1786 | + $ACARS->deleteLiveAcarsData(); |
|
| 1787 | + } |
|
| 1788 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1789 | 1789 | } elseif ($format === 'flightgearmp') { |
| 1790 | - if (substr($buffer,0,1) != '#') { |
|
| 1790 | + if (substr($buffer,0,1) != '#') { |
|
| 1791 | 1791 | $data = array(); |
| 1792 | 1792 | //echo $buffer."\n"; |
| 1793 | 1793 | $line = explode(' ',$buffer); |
| 1794 | 1794 | if (count($line) === 11) { |
| 1795 | - $userserver = explode('@',$line[0]); |
|
| 1796 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1797 | - $data['ident'] = $userserver[0]; |
|
| 1798 | - $data['registration'] = $userserver[0]; |
|
| 1799 | - $data['latitude'] = $line[4]; |
|
| 1800 | - $data['longitude'] = $line[5]; |
|
| 1801 | - $data['altitude'] = $line[6]; |
|
| 1802 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1803 | - $aircraft_type = $line[10]; |
|
| 1804 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1805 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1806 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1807 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1795 | + $userserver = explode('@',$line[0]); |
|
| 1796 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1797 | + $data['ident'] = $userserver[0]; |
|
| 1798 | + $data['registration'] = $userserver[0]; |
|
| 1799 | + $data['latitude'] = $line[4]; |
|
| 1800 | + $data['longitude'] = $line[5]; |
|
| 1801 | + $data['altitude'] = $line[6]; |
|
| 1802 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1803 | + $aircraft_type = $line[10]; |
|
| 1804 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1805 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1806 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1807 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1808 | + } |
|
| 1808 | 1809 | } |
| 1809 | - } |
|
| 1810 | 1810 | } elseif ($format === 'beast') { |
| 1811 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1812 | - die; |
|
| 1811 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1812 | + die; |
|
| 1813 | 1813 | } elseif ($format === 'vrstcp') { |
| 1814 | - foreach($buffer as $all_data) { |
|
| 1814 | + foreach($buffer as $all_data) { |
|
| 1815 | 1815 | $line = json_decode('{'.$all_data.'}',true); |
| 1816 | 1816 | $data = array(); |
| 1817 | 1817 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1831,158 +1831,158 @@ discard block |
||
| 1831 | 1831 | */ |
| 1832 | 1832 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1833 | 1833 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
| 1834 | - $data['format_source'] = 'vrstcp'; |
|
| 1834 | + $data['format_source'] = 'vrstcp'; |
|
| 1835 | 1835 | $data['id_source'] = $id_source; |
| 1836 | 1836 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1837 | 1837 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1838 | 1838 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1839 | 1839 | unset($data); |
| 1840 | - } |
|
| 1840 | + } |
|
| 1841 | 1841 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
| 1842 | - $line = explode("\t", $buffer); |
|
| 1843 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1842 | + $line = explode("\t", $buffer); |
|
| 1843 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1844 | 1844 | $key = $line[$k]; |
| 1845 | - $lined[$key] = $line[$k+1]; |
|
| 1846 | - } |
|
| 1847 | - if (count($lined) > 3) { |
|
| 1848 | - $data['hex'] = $lined['hexid']; |
|
| 1849 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1850 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1851 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1852 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1853 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1854 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1855 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1856 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1857 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1858 | - $data['id_source'] = $id_source; |
|
| 1859 | - $data['format_source'] = 'tsv'; |
|
| 1860 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1861 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1845 | + $lined[$key] = $line[$k+1]; |
|
| 1846 | + } |
|
| 1847 | + if (count($lined) > 3) { |
|
| 1848 | + $data['hex'] = $lined['hexid']; |
|
| 1849 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1850 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1851 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1852 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1853 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1854 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1855 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1856 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1857 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1858 | + $data['id_source'] = $id_source; |
|
| 1859 | + $data['format_source'] = 'tsv'; |
|
| 1860 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1861 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1862 | 1862 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1863 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1864 | - unset($lined); |
|
| 1865 | - unset($data); |
|
| 1866 | - } else $error = true; |
|
| 1863 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1864 | + unset($lined); |
|
| 1865 | + unset($data); |
|
| 1866 | + } else $error = true; |
|
| 1867 | 1867 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1868 | - if ($aprs_connect === 0) { |
|
| 1868 | + if ($aprs_connect === 0) { |
|
| 1869 | 1869 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 1870 | 1870 | $aprs_connect = 1; |
| 1871 | - } |
|
| 1871 | + } |
|
| 1872 | 1872 | |
| 1873 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1873 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1874 | 1874 | $aprs_last_tx = time(); |
| 1875 | 1875 | $data_aprs = "# Keep alive"; |
| 1876 | 1876 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1877 | - } |
|
| 1877 | + } |
|
| 1878 | 1878 | |
| 1879 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1880 | - //echo 'APRS data : '.$buffer."\n"; |
|
| 1881 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1882 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1883 | - //echo $buffer."\n"; |
|
| 1884 | - date_default_timezone_set('UTC'); |
|
| 1885 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1879 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1880 | + //echo 'APRS data : '.$buffer."\n"; |
|
| 1881 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1882 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1883 | + //echo $buffer."\n"; |
|
| 1884 | + date_default_timezone_set('UTC'); |
|
| 1885 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1886 | 1886 | $line = $APRS->parse($buffer); |
| 1887 | 1887 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1888 | 1888 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
| 1889 | - $aprs_last_tx = time(); |
|
| 1890 | - $data = array(); |
|
| 1891 | - //print_r($line); |
|
| 1892 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1893 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1894 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1895 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1896 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1897 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1898 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1899 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1900 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1901 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1902 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1903 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1904 | - $data['latitude'] = $line['latitude']; |
|
| 1905 | - $data['longitude'] = $line['longitude']; |
|
| 1906 | - //$data['verticalrate'] = $line[16]; |
|
| 1907 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1908 | - //else $data['speed'] = 0; |
|
| 1909 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1910 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1911 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1912 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1889 | + $aprs_last_tx = time(); |
|
| 1890 | + $data = array(); |
|
| 1891 | + //print_r($line); |
|
| 1892 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1893 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1894 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1895 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1896 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1897 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1898 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1899 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1900 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1901 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1902 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1903 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1904 | + $data['latitude'] = $line['latitude']; |
|
| 1905 | + $data['longitude'] = $line['longitude']; |
|
| 1906 | + //$data['verticalrate'] = $line[16]; |
|
| 1907 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1908 | + //else $data['speed'] = 0; |
|
| 1909 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1910 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1911 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1912 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1913 | 1913 | |
| 1914 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1915 | - //else echo 'No heading...'."\n"; |
|
| 1916 | - //else $data['heading'] = 0; |
|
| 1917 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1918 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1919 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1920 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1921 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1922 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1923 | - $data['id_source'] = $id_source; |
|
| 1924 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1925 | - else $data['format_source'] = 'aprs'; |
|
| 1926 | - $data['source_name'] = $line['source']; |
|
| 1927 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1928 | - else $data['source_type'] = 'flarm'; |
|
| 1929 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1930 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 1931 | - $aprsdate = strtotime($data['datetime']); |
|
| 1932 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1933 | - // Accept data if time <= system time + 20s |
|
| 1934 | - //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1935 | - if ( |
|
| 1914 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1915 | + //else echo 'No heading...'."\n"; |
|
| 1916 | + //else $data['heading'] = 0; |
|
| 1917 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1918 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1919 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1920 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1921 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1922 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1923 | + $data['id_source'] = $id_source; |
|
| 1924 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1925 | + else $data['format_source'] = 'aprs'; |
|
| 1926 | + $data['source_name'] = $line['source']; |
|
| 1927 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1928 | + else $data['source_type'] = 'flarm'; |
|
| 1929 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1930 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 1931 | + $aprsdate = strtotime($data['datetime']); |
|
| 1932 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1933 | + // Accept data if time <= system time + 20s |
|
| 1934 | + //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1935 | + if ( |
|
| 1936 | 1936 | ($data['source_type'] === 'modes') || |
| 1937 | 1937 | isset($line['stealth']) && |
| 1938 | 1938 | (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && |
| 1939 | 1939 | ($line['stealth'] === 0 || $line['stealth'] == '') && |
| 1940 | 1940 | (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1941 | 1941 | $send = $SI->add($data); |
| 1942 | - } elseif ($data['source_type'] === 'ais') { |
|
| 1942 | + } elseif ($data['source_type'] === 'ais') { |
|
| 1943 | 1943 | $data['type'] = ''; |
| 1944 | 1944 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
| 1945 | - } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
| 1945 | + } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
| 1946 | 1946 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1947 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1948 | - //$line['symbol'] === 'Balloon' || |
|
| 1949 | - $line['symbol'] === 'Glider' || |
|
| 1950 | - $line['symbol'] === 'No. Plane' || |
|
| 1951 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
| 1952 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1953 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1954 | - $send = $SI->add($data); |
|
| 1955 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1956 | - $line['symbol'] === 'Yacht (Sail)' || |
|
| 1957 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
| 1958 | - $send = $MI->add($data); |
|
| 1959 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1960 | - $line['symbol'] === 'Car' || |
|
| 1961 | - $line['symbol'] === 'Ambulance' || |
|
| 1962 | - $line['symbol'] === 'Van' || |
|
| 1963 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
| 1964 | - $line['symbol'] === 'Motorcycle' || |
|
| 1965 | - $line['symbol'] === 'Tractor' || |
|
| 1966 | - $line['symbol'] === 'Police' || |
|
| 1967 | - $line['symbol'] === 'Bike' || |
|
| 1968 | - $line['symbol'] === 'Jogger' || |
|
| 1969 | - $line['symbol'] === 'Horse' || |
|
| 1970 | - $line['symbol'] === 'Bus' || |
|
| 1971 | - $line['symbol'] === 'Jeep' || |
|
| 1972 | - $line['symbol'] === 'Recreational Vehicle' || |
|
| 1973 | - $line['symbol'] === 'Yacht (Sail)' || |
|
| 1974 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
| 1975 | - $line['symbol'] === 'Firetruck' || |
|
| 1976 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
| 1977 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
| 1978 | - $line['symbol'] === 'SUV' || |
|
| 1979 | - $line['symbol'] === 'Snowmobile' || |
|
| 1980 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
| 1981 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
| 1947 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1948 | + //$line['symbol'] === 'Balloon' || |
|
| 1949 | + $line['symbol'] === 'Glider' || |
|
| 1950 | + $line['symbol'] === 'No. Plane' || |
|
| 1951 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
| 1952 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1953 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1954 | + $send = $SI->add($data); |
|
| 1955 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1956 | + $line['symbol'] === 'Yacht (Sail)' || |
|
| 1957 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
| 1958 | + $send = $MI->add($data); |
|
| 1959 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1960 | + $line['symbol'] === 'Car' || |
|
| 1961 | + $line['symbol'] === 'Ambulance' || |
|
| 1962 | + $line['symbol'] === 'Van' || |
|
| 1963 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
| 1964 | + $line['symbol'] === 'Motorcycle' || |
|
| 1965 | + $line['symbol'] === 'Tractor' || |
|
| 1966 | + $line['symbol'] === 'Police' || |
|
| 1967 | + $line['symbol'] === 'Bike' || |
|
| 1968 | + $line['symbol'] === 'Jogger' || |
|
| 1969 | + $line['symbol'] === 'Horse' || |
|
| 1970 | + $line['symbol'] === 'Bus' || |
|
| 1971 | + $line['symbol'] === 'Jeep' || |
|
| 1972 | + $line['symbol'] === 'Recreational Vehicle' || |
|
| 1973 | + $line['symbol'] === 'Yacht (Sail)' || |
|
| 1974 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
| 1975 | + $line['symbol'] === 'Firetruck' || |
|
| 1976 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
| 1977 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
| 1978 | + $line['symbol'] === 'SUV' || |
|
| 1979 | + $line['symbol'] === 'Snowmobile' || |
|
| 1980 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
| 1981 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
| 1982 | 1982 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 1983 | 1983 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1984 | 1984 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
| 1985 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1985 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1986 | 1986 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 1987 | 1987 | $Source->deleteOldLocationByType('gs'); |
| 1988 | 1988 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1990,7 +1990,7 @@ discard block |
||
| 1990 | 1990 | } else { |
| 1991 | 1991 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
| 1992 | 1992 | } |
| 1993 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
| 1993 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
| 1994 | 1994 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1995 | 1995 | if ($globalDebug) echo '# Weather Station added'."\n"; |
| 1996 | 1996 | $Source->deleteOldLocationByType('wx'); |
@@ -2000,7 +2000,7 @@ discard block |
||
| 2000 | 2000 | } else { |
| 2001 | 2001 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
| 2002 | 2002 | } |
| 2003 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
| 2003 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
| 2004 | 2004 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2005 | 2005 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 2006 | 2006 | $Source->deleteOldLocationByType('lightning'); |
@@ -2009,11 +2009,11 @@ discard block |
||
| 2009 | 2009 | } else { |
| 2010 | 2010 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
| 2011 | 2011 | } |
| 2012 | - } elseif ($globalDebug) { |
|
| 2013 | - echo '/!\ Not added: '.$buffer."\n"; |
|
| 2014 | - print_r($line); |
|
| 2015 | - } |
|
| 2016 | - unset($data); |
|
| 2012 | + } elseif ($globalDebug) { |
|
| 2013 | + echo '/!\ Not added: '.$buffer."\n"; |
|
| 2014 | + print_r($line); |
|
| 2015 | + } |
|
| 2016 | + unset($data); |
|
| 2017 | 2017 | } |
| 2018 | 2018 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
| 2019 | 2019 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -2032,13 +2032,13 @@ discard block |
||
| 2032 | 2032 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
| 2033 | 2033 | $globalSources[$nb]['last_weather_clean'] = time(); |
| 2034 | 2034 | } |
| 2035 | - } |
|
| 2035 | + } |
|
| 2036 | 2036 | } else { |
| 2037 | - $line = explode(',', $buffer); |
|
| 2038 | - //print_r($line); |
|
| 2039 | - if (count($line) > 20) { |
|
| 2040 | - $data['hex'] = $line[4]; |
|
| 2041 | - /* |
|
| 2037 | + $line = explode(',', $buffer); |
|
| 2038 | + //print_r($line); |
|
| 2039 | + if (count($line) > 20) { |
|
| 2040 | + $data['hex'] = $line[4]; |
|
| 2041 | + /* |
|
| 2042 | 2042 | $data['datetime'] = $line[6].' '.$line[7]; |
| 2043 | 2043 | date_default_timezone_set($globalTimezone); |
| 2044 | 2044 | $datetime = new DateTime($data['datetime']); |
@@ -2046,31 +2046,31 @@ discard block |
||
| 2046 | 2046 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 2047 | 2047 | date_default_timezone_set('UTC'); |
| 2048 | 2048 | */ |
| 2049 | - // Force datetime to current UTC datetime |
|
| 2050 | - date_default_timezone_set('UTC'); |
|
| 2051 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2052 | - $data['ident'] = trim($line[10]); |
|
| 2053 | - $data['latitude'] = $line[14]; |
|
| 2054 | - $data['longitude'] = $line[15]; |
|
| 2055 | - $data['verticalrate'] = $line[16]; |
|
| 2056 | - $data['emergency'] = $line[20]; |
|
| 2057 | - $data['speed'] = $line[12]; |
|
| 2058 | - $data['squawk'] = $line[17]; |
|
| 2059 | - $data['altitude'] = $line[11]; |
|
| 2060 | - $data['heading'] = $line[13]; |
|
| 2061 | - $data['ground'] = $line[21]; |
|
| 2062 | - $data['emergency'] = $line[19]; |
|
| 2063 | - $data['format_source'] = 'sbs'; |
|
| 2049 | + // Force datetime to current UTC datetime |
|
| 2050 | + date_default_timezone_set('UTC'); |
|
| 2051 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2052 | + $data['ident'] = trim($line[10]); |
|
| 2053 | + $data['latitude'] = $line[14]; |
|
| 2054 | + $data['longitude'] = $line[15]; |
|
| 2055 | + $data['verticalrate'] = $line[16]; |
|
| 2056 | + $data['emergency'] = $line[20]; |
|
| 2057 | + $data['speed'] = $line[12]; |
|
| 2058 | + $data['squawk'] = $line[17]; |
|
| 2059 | + $data['altitude'] = $line[11]; |
|
| 2060 | + $data['heading'] = $line[13]; |
|
| 2061 | + $data['ground'] = $line[21]; |
|
| 2062 | + $data['emergency'] = $line[19]; |
|
| 2063 | + $data['format_source'] = 'sbs'; |
|
| 2064 | 2064 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 2065 | 2065 | elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
| 2066 | 2066 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 2067 | 2067 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 2068 | - $data['id_source'] = $id_source; |
|
| 2069 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 2070 | - else $error = true; |
|
| 2071 | - unset($data); |
|
| 2072 | - } else $error = true; |
|
| 2073 | - if ($error) { |
|
| 2068 | + $data['id_source'] = $id_source; |
|
| 2069 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 2070 | + else $error = true; |
|
| 2071 | + unset($data); |
|
| 2072 | + } else $error = true; |
|
| 2073 | + if ($error) { |
|
| 2074 | 2074 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 2075 | 2075 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 2076 | 2076 | } else { |
@@ -2086,13 +2086,13 @@ discard block |
||
| 2086 | 2086 | connect_all($sourceer); |
| 2087 | 2087 | $sourceer = array(); |
| 2088 | 2088 | } |
| 2089 | - } |
|
| 2089 | + } |
|
| 2090 | 2090 | } |
| 2091 | 2091 | // Sleep for xxx microseconds |
| 2092 | 2092 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 2093 | - } else { |
|
| 2093 | + } else { |
|
| 2094 | 2094 | if ($format === 'flightgearmp') { |
| 2095 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2095 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2096 | 2096 | //@socket_close($r); |
| 2097 | 2097 | sleep($globalMinFetch); |
| 2098 | 2098 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2101,9 +2101,9 @@ discard block |
||
| 2101 | 2101 | break; |
| 2102 | 2102 | |
| 2103 | 2103 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 2104 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 2105 | - else $tt[$format] = 0; |
|
| 2106 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 2104 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 2105 | + else $tt[$format] = 0; |
|
| 2106 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 2107 | 2107 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 2108 | 2108 | //@socket_close($r); |
| 2109 | 2109 | sleep(2); |
@@ -2114,24 +2114,24 @@ discard block |
||
| 2114 | 2114 | //connect_all($globalSources); |
| 2115 | 2115 | $tt[$format]=0; |
| 2116 | 2116 | break; |
| 2117 | - } |
|
| 2118 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 2117 | + } |
|
| 2118 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 2119 | + } |
|
| 2119 | 2120 | } |
| 2120 | - } |
|
| 2121 | 2121 | } |
| 2122 | - } else { |
|
| 2122 | + } else { |
|
| 2123 | 2123 | $error = socket_strerror(socket_last_error()); |
| 2124 | 2124 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2125 | 2125 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 2126 | 2126 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 2127 | 2127 | // Restart the script if possible |
| 2128 | 2128 | if (is_array($sockets)) { |
| 2129 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2129 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2130 | 2130 | |
| 2131 | - foreach ($sockets as $sock) { |
|
| 2131 | + foreach ($sockets as $sock) { |
|
| 2132 | 2132 | @socket_shutdown($sock,2); |
| 2133 | 2133 | @socket_close($sock); |
| 2134 | - } |
|
| 2134 | + } |
|
| 2135 | 2135 | |
| 2136 | 2136 | } |
| 2137 | 2137 | if ($globalDebug) echo "Waiting..."; |
@@ -2146,15 +2146,15 @@ discard block |
||
| 2146 | 2146 | if ($globalDebug) echo "Restart all connections..."; |
| 2147 | 2147 | connect_all($globalSources); |
| 2148 | 2148 | } |
| 2149 | - } |
|
| 2149 | + } |
|
| 2150 | 2150 | } |
| 2151 | 2151 | if ($globalDaemon === false) { |
| 2152 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2153 | - if (isset($SI)) $SI->checkAll(); |
|
| 2154 | - if (isset($TI)) $TI->checkAll(); |
|
| 2155 | - if (isset($MI)) $MI->checkAll(); |
|
| 2152 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2153 | + if (isset($SI)) $SI->checkAll(); |
|
| 2154 | + if (isset($TI)) $TI->checkAll(); |
|
| 2155 | + if (isset($MI)) $MI->checkAll(); |
|
| 2156 | + } |
|
| 2156 | 2157 | } |
| 2157 | - } |
|
| 2158 | 2158 | } |
| 2159 | 2159 | |
| 2160 | 2160 | ?> |