@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 18 | 18 | if (isset($globalMarine) && $globalMarine) { |
| 19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,46 +25,46 @@ discard block |
||
| 25 | 25 | // Check if schema is at latest version |
| 26 | 26 | $Connection = new Connection(); |
| 27 | 27 | if ($Connection->connectionExists() === false) { |
| 28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 29 | - exit(); |
|
| 28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 29 | + exit(); |
|
| 30 | 30 | } |
| 31 | 31 | if ($Connection->latest() === false) { |
| 32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 33 | - exit(); |
|
| 32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 33 | + exit(); |
|
| 34 | 34 | } |
| 35 | 35 | if (PHP_SAPI != 'cli') { |
| 36 | - echo "This script MUST be called from console, not a web browser."; |
|
| 36 | + echo "This script MUST be called from console, not a web browser."; |
|
| 37 | 37 | // exit(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // This is to be compatible with old version of settings.php |
| 41 | 41 | if (!isset($globalSources)) { |
| 42 | - if (isset($globalSBS1Hosts)) { |
|
| 43 | - //$hosts = $globalSBS1Hosts; |
|
| 44 | - foreach ($globalSBS1Hosts as $host) { |
|
| 45 | - $globalSources[] = array('host' => $host); |
|
| 46 | - } |
|
| 47 | - } else { |
|
| 48 | - if (!isset($globalSBS1Host)) { |
|
| 49 | - echo '$globalSources MUST be defined !'; |
|
| 50 | - die; |
|
| 42 | + if (isset($globalSBS1Hosts)) { |
|
| 43 | + //$hosts = $globalSBS1Hosts; |
|
| 44 | + foreach ($globalSBS1Hosts as $host) { |
|
| 45 | + $globalSources[] = array('host' => $host); |
|
| 46 | + } |
|
| 47 | + } else { |
|
| 48 | + if (!isset($globalSBS1Host)) { |
|
| 49 | + echo '$globalSources MUST be defined !'; |
|
| 50 | + die; |
|
| 51 | 51 | } |
| 52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $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')); |
| 58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 60 | 60 | if (isset($options['s'])) { |
| 61 | - $globalSources = array(); |
|
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['s']); |
|
| 61 | + $globalSources = array(); |
|
| 62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | + else $globalSources[] = array('host' => $options['s']); |
|
| 64 | 64 | } elseif (isset($options['source'])) { |
| 65 | - $globalSources = array(); |
|
| 66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | - else $globalSources[] = array('host' => $options['source']); |
|
| 65 | + $globalSources = array(); |
|
| 66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | + else $globalSources[] = array('host' => $options['source']); |
|
| 68 | 68 | } |
| 69 | 69 | if (isset($options['aprsserverhost'])) { |
| 70 | 70 | $globalServerAPRS = TRUE; |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 104 | 104 | else $id_source = 1; |
| 105 | 105 | if (isset($globalServer) && $globalServer) { |
| 106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 107 | - $SI=new SpotterServer(); |
|
| 106 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 107 | + $SI=new SpotterServer(); |
|
| 108 | 108 | /* |
| 109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 110 | 110 | $SI = new adsb2aprs(); |
@@ -114,14 +114,14 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 116 | 116 | if (isset($globalMarine) && $globalMarine) { |
| 117 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 118 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 117 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 118 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 122 | 122 | if (isset($globalMarine) && $globalMarine) { |
| 123 | - $AIS = new AIS(); |
|
| 124 | - $MI = new MarineImport($Connection->db); |
|
| 123 | + $AIS = new AIS(); |
|
| 124 | + $MI = new MarineImport($Connection->db); |
|
| 125 | 125 | } |
| 126 | 126 | //$APRS=new APRS($Connection->db); |
| 127 | 127 | $SBS=new SBS(); |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | //$servertz = system('date +%Z'); |
| 135 | 135 | // signal handler - playing nice with sockets and dump1090 |
| 136 | 136 | if (function_exists('pcntl_fork')) { |
| 137 | - pcntl_signal(SIGINT, function() { |
|
| 138 | - global $sockets; |
|
| 139 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 140 | - die("Bye!\n"); |
|
| 141 | - }); |
|
| 142 | - pcntl_signal_dispatch(); |
|
| 137 | + pcntl_signal(SIGINT, function() { |
|
| 138 | + global $sockets; |
|
| 139 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 140 | + die("Bye!\n"); |
|
| 141 | + }); |
|
| 142 | + pcntl_signal_dispatch(); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // let's try and connect |
@@ -149,36 +149,36 @@ discard block |
||
| 149 | 149 | $reset = 0; |
| 150 | 150 | |
| 151 | 151 | function connect_all($hosts) { |
| 152 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 154 | - $reset++; |
|
| 155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 156 | - foreach ($hosts as $id => $value) { |
|
| 152 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 153 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 154 | + $reset++; |
|
| 155 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 156 | + foreach ($hosts as $id => $value) { |
|
| 157 | 157 | $host = $value['host']; |
| 158 | 158 | $globalSources[$id]['last_exec'] = 0; |
| 159 | 159 | // Here we check type of source(s) |
| 160 | 160 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 162 | - //$formats[$id] = 'deltadbtxt'; |
|
| 163 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 164 | - //$last_exec['deltadbtxt'] = 0; |
|
| 165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 167 | - //$formats[$id] = 'vatsimtxt'; |
|
| 168 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 169 | - //$last_exec['vatsimtxt'] = 0; |
|
| 170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 172 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 173 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 174 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 176 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 177 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 178 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 179 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 180 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 181 | - /* |
|
| 161 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 162 | + //$formats[$id] = 'deltadbtxt'; |
|
| 163 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 164 | + //$last_exec['deltadbtxt'] = 0; |
|
| 165 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 166 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 167 | + //$formats[$id] = 'vatsimtxt'; |
|
| 168 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 169 | + //$last_exec['vatsimtxt'] = 0; |
|
| 170 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 171 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 172 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 173 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 174 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 175 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 176 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 177 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 178 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 179 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 180 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 181 | + /* |
|
| 182 | 182 | // Disabled for now, site change source format |
| 183 | 183 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
| 184 | 184 | //$formats[$id] = 'radarvirtueljson'; |
@@ -190,120 +190,120 @@ discard block |
||
| 190 | 190 | exit(0); |
| 191 | 191 | } |
| 192 | 192 | */ |
| 193 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 194 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 195 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 196 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 197 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 198 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 199 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 200 | - exit(0); |
|
| 201 | - } |
|
| 202 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 203 | - //$formats[$id] = 'phpvmacars'; |
|
| 204 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 205 | - //$last_exec['phpvmacars'] = 0; |
|
| 206 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 207 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 208 | - //$formats[$id] = 'phpvmacars'; |
|
| 209 | - $globalSources[$id]['format'] = 'vam'; |
|
| 210 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 211 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 212 | - //$formats[$id] = 'whazzup'; |
|
| 213 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 214 | - //$last_exec['whazzup'] = 0; |
|
| 215 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 216 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
| 217 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
| 218 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 219 | - } else if (preg_match('/airwhere/i',$host)) { |
|
| 220 | - $globalSources[$id]['format'] = 'airwhere'; |
|
| 221 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 222 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 223 | - //$formats[$id] = 'pirepsjson'; |
|
| 224 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 225 | - //$last_exec['pirepsjson'] = 0; |
|
| 226 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 227 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 228 | - //$formats[$id] = 'fr24json'; |
|
| 229 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 230 | - //$last_exec['fr24json'] = 0; |
|
| 231 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 232 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 233 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 234 | - exit(0); |
|
| 235 | - } |
|
| 236 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 237 | - //$formats[$id] = 'fr24json'; |
|
| 238 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 239 | - //$last_exec['fr24json'] = 0; |
|
| 240 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 241 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 242 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 243 | - exit(0); |
|
| 244 | - } |
|
| 245 | - //} else if (preg_match('/10001/',$host)) { |
|
| 246 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 247 | - //$formats[$id] = 'tsv'; |
|
| 248 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 249 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 250 | - } |
|
| 251 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 252 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 253 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 254 | - if ($idf !== false) { |
|
| 255 | - $httpfeeds[$id] = $idf; |
|
| 256 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 257 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 258 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 259 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 260 | - $hostport = explode(':',$host); |
|
| 261 | - if (isset($hostport[1])) { |
|
| 193 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 194 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 195 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 196 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 197 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 198 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 199 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 200 | + exit(0); |
|
| 201 | + } |
|
| 202 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 203 | + //$formats[$id] = 'phpvmacars'; |
|
| 204 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 205 | + //$last_exec['phpvmacars'] = 0; |
|
| 206 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 207 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 208 | + //$formats[$id] = 'phpvmacars'; |
|
| 209 | + $globalSources[$id]['format'] = 'vam'; |
|
| 210 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 211 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 212 | + //$formats[$id] = 'whazzup'; |
|
| 213 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 214 | + //$last_exec['whazzup'] = 0; |
|
| 215 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 216 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
| 217 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
| 218 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 219 | + } else if (preg_match('/airwhere/i',$host)) { |
|
| 220 | + $globalSources[$id]['format'] = 'airwhere'; |
|
| 221 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 222 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 223 | + //$formats[$id] = 'pirepsjson'; |
|
| 224 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 225 | + //$last_exec['pirepsjson'] = 0; |
|
| 226 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 227 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 228 | + //$formats[$id] = 'fr24json'; |
|
| 229 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 230 | + //$last_exec['fr24json'] = 0; |
|
| 231 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 232 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 233 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 234 | + exit(0); |
|
| 235 | + } |
|
| 236 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 237 | + //$formats[$id] = 'fr24json'; |
|
| 238 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 239 | + //$last_exec['fr24json'] = 0; |
|
| 240 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 241 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 242 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 243 | + exit(0); |
|
| 244 | + } |
|
| 245 | + //} else if (preg_match('/10001/',$host)) { |
|
| 246 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 247 | + //$formats[$id] = 'tsv'; |
|
| 248 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 249 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 250 | + } |
|
| 251 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 252 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 253 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 254 | + if ($idf !== false) { |
|
| 255 | + $httpfeeds[$id] = $idf; |
|
| 256 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 257 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 258 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 259 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 260 | + $hostport = explode(':',$host); |
|
| 261 | + if (isset($hostport[1])) { |
|
| 262 | 262 | $port = $hostport[1]; |
| 263 | 263 | $hostn = $hostport[0]; |
| 264 | - } else { |
|
| 264 | + } else { |
|
| 265 | 265 | $port = $globalSources[$id]['port']; |
| 266 | 266 | $hostn = $globalSources[$id]['host']; |
| 267 | - } |
|
| 268 | - $Common = new Common(); |
|
| 269 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 270 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 271 | - } else { |
|
| 272 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 273 | - } |
|
| 274 | - if ($s) { |
|
| 275 | - $sockets[$id] = $s; |
|
| 276 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 277 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 267 | + } |
|
| 268 | + $Common = new Common(); |
|
| 269 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 270 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 271 | + } else { |
|
| 272 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 273 | + } |
|
| 274 | + if ($s) { |
|
| 275 | + $sockets[$id] = $s; |
|
| 276 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 277 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 278 | 278 | //$formats[$id] = 'aprs'; |
| 279 | 279 | $globalSources[$id]['format'] = 'aprs'; |
| 280 | 280 | //$aprs_connect = 0; |
| 281 | 281 | //$use_aprs = true; |
| 282 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 282 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 283 | 283 | $globalSources[$id]['format'] = 'vrstcp'; |
| 284 | - } elseif ($port == '10001') { |
|
| 285 | - //$formats[$id] = 'tsv'; |
|
| 286 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 287 | - } elseif ($port == '30002') { |
|
| 288 | - //$formats[$id] = 'raw'; |
|
| 289 | - $globalSources[$id]['format'] = 'raw'; |
|
| 290 | - } elseif ($port == '5001') { |
|
| 291 | - //$formats[$id] = 'raw'; |
|
| 292 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 293 | - } elseif ($port == '30005') { |
|
| 284 | + } elseif ($port == '10001') { |
|
| 285 | + //$formats[$id] = 'tsv'; |
|
| 286 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 287 | + } elseif ($port == '30002') { |
|
| 288 | + //$formats[$id] = 'raw'; |
|
| 289 | + $globalSources[$id]['format'] = 'raw'; |
|
| 290 | + } elseif ($port == '5001') { |
|
| 291 | + //$formats[$id] = 'raw'; |
|
| 292 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 293 | + } elseif ($port == '30005') { |
|
| 294 | 294 | // Not yet supported |
| 295 | - //$formats[$id] = 'beast'; |
|
| 296 | - $globalSources[$id]['format'] = 'beast'; |
|
| 297 | - //} else $formats[$id] = 'sbs'; |
|
| 298 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 299 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 295 | + //$formats[$id] = 'beast'; |
|
| 296 | + $globalSources[$id]['format'] = 'beast'; |
|
| 297 | + //} else $formats[$id] = 'sbs'; |
|
| 298 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 299 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 300 | 300 | } |
| 301 | 301 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 302 | - } else { |
|
| 302 | + } else { |
|
| 303 | 303 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 304 | - } |
|
| 305 | - } |
|
| 306 | - } |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | 307 | } |
| 308 | 308 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 309 | 309 | |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | //connect_all($globalSources); |
| 327 | 327 | |
| 328 | 328 | if (isset($globalProxy) && $globalProxy) { |
| 329 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 329 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 330 | 330 | } else { |
| 331 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 331 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // APRS Configuration |
@@ -337,21 +337,21 @@ discard block |
||
| 337 | 337 | die; |
| 338 | 338 | } |
| 339 | 339 | foreach ($globalSources as $key => $source) { |
| 340 | - if (!isset($source['format'])) { |
|
| 341 | - $globalSources[$key]['format'] = 'auto'; |
|
| 342 | - } |
|
| 343 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 344 | - unset($globalSources[$key]); |
|
| 345 | - } |
|
| 340 | + if (!isset($source['format'])) { |
|
| 341 | + $globalSources[$key]['format'] = 'auto'; |
|
| 342 | + } |
|
| 343 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 344 | + unset($globalSources[$key]); |
|
| 345 | + } |
|
| 346 | 346 | } |
| 347 | 347 | connect_all($globalSources); |
| 348 | 348 | foreach ($globalSources as $key => $source) { |
| 349 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 349 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 350 | 350 | $aprs_connect = 0; |
| 351 | 351 | $use_aprs = true; |
| 352 | 352 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 353 | 353 | break; |
| 354 | - } |
|
| 354 | + } |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | if ($use_aprs) { |
@@ -392,129 +392,129 @@ discard block |
||
| 392 | 392 | |
| 393 | 393 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 394 | 394 | while ($i > 0) { |
| 395 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 396 | - // Delete old ATC |
|
| 397 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 395 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 396 | + // Delete old ATC |
|
| 397 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 398 | 398 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 399 | - $ATC->deleteOldATC(); |
|
| 400 | - } |
|
| 399 | + $ATC->deleteOldATC(); |
|
| 400 | + } |
|
| 401 | 401 | |
| 402 | - if (count($last_exec) == count($globalSources)) { |
|
| 402 | + if (count($last_exec) == count($globalSources)) { |
|
| 403 | 403 | $max = $globalMinFetch; |
| 404 | 404 | foreach ($last_exec as $last) { |
| 405 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 405 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 406 | 406 | } |
| 407 | 407 | if ($max != $globalMinFetch) { |
| 408 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 409 | - sleep($globalMinFetch-$max+2); |
|
| 408 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 409 | + sleep($globalMinFetch-$max+2); |
|
| 410 | + } |
|
| 410 | 411 | } |
| 411 | - } |
|
| 412 | 412 | |
| 413 | 413 | |
| 414 | - //foreach ($formats as $id => $value) { |
|
| 415 | - foreach ($globalSources as $id => $value) { |
|
| 414 | + //foreach ($formats as $id => $value) { |
|
| 415 | + foreach ($globalSources as $id => $value) { |
|
| 416 | 416 | date_default_timezone_set('UTC'); |
| 417 | 417 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 418 | 418 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 419 | 419 | if ($value['format'] == 'deltadbtxt' && |
| 420 | - ( |
|
| 420 | + ( |
|
| 421 | 421 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 422 | 422 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 423 | - ) |
|
| 423 | + ) |
|
| 424 | 424 | ) { |
| 425 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 426 | - $buffer = $Common->getData($value['host']); |
|
| 427 | - if ($buffer != '') $reset = 0; |
|
| 428 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 429 | - $buffer = explode('\n',$buffer); |
|
| 430 | - foreach ($buffer as $line) { |
|
| 431 | - if ($line != '' && count($line) > 7) { |
|
| 432 | - $line = explode(',', $line); |
|
| 433 | - $data = array(); |
|
| 434 | - $data['hex'] = $line[1]; // hex |
|
| 435 | - $data['ident'] = $line[2]; // ident |
|
| 436 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 437 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 438 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 439 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 440 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 441 | - $data['verticalrate'] = ''; // vertical rate |
|
| 442 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 443 | - $data['emergency'] = ''; // emergency |
|
| 444 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 445 | - $data['format_source'] = 'deltadbtxt'; |
|
| 446 | - $data['id_source'] = $id_source; |
|
| 447 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 448 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 449 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 450 | - $SI->add($data); |
|
| 451 | - unset($data); |
|
| 452 | - } |
|
| 453 | - } |
|
| 454 | - $last_exec[$id]['last'] = time(); |
|
| 425 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 426 | + $buffer = $Common->getData($value['host']); |
|
| 427 | + if ($buffer != '') $reset = 0; |
|
| 428 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 429 | + $buffer = explode('\n',$buffer); |
|
| 430 | + foreach ($buffer as $line) { |
|
| 431 | + if ($line != '' && count($line) > 7) { |
|
| 432 | + $line = explode(',', $line); |
|
| 433 | + $data = array(); |
|
| 434 | + $data['hex'] = $line[1]; // hex |
|
| 435 | + $data['ident'] = $line[2]; // ident |
|
| 436 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 437 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 438 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 439 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 440 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 441 | + $data['verticalrate'] = ''; // vertical rate |
|
| 442 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 443 | + $data['emergency'] = ''; // emergency |
|
| 444 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 445 | + $data['format_source'] = 'deltadbtxt'; |
|
| 446 | + $data['id_source'] = $id_source; |
|
| 447 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 448 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 449 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 450 | + $SI->add($data); |
|
| 451 | + unset($data); |
|
| 452 | + } |
|
| 453 | + } |
|
| 454 | + $last_exec[$id]['last'] = time(); |
|
| 455 | 455 | } elseif ($value['format'] == 'aisnmeatxt' && |
| 456 | - ( |
|
| 456 | + ( |
|
| 457 | 457 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 458 | 458 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 459 | - ) |
|
| 459 | + ) |
|
| 460 | 460 | ) { |
| 461 | - date_default_timezone_set('CET'); |
|
| 462 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 463 | - date_default_timezone_set('UTC'); |
|
| 464 | - if ($buffer != '') $reset = 0; |
|
| 465 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 466 | - $buffer = explode('\n',$buffer); |
|
| 467 | - foreach ($buffer as $line) { |
|
| 461 | + date_default_timezone_set('CET'); |
|
| 462 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 463 | + date_default_timezone_set('UTC'); |
|
| 464 | + if ($buffer != '') $reset = 0; |
|
| 465 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 466 | + $buffer = explode('\n',$buffer); |
|
| 467 | + foreach ($buffer as $line) { |
|
| 468 | 468 | if ($line != '') { |
| 469 | - //echo "'".$line."'\n"; |
|
| 470 | - $add = false; |
|
| 471 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 472 | - $data = array(); |
|
| 473 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 474 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 475 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 476 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 477 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 478 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 479 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 480 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 481 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 482 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 483 | - if (isset($ais_data['timestamp'])) { |
|
| 469 | + //echo "'".$line."'\n"; |
|
| 470 | + $add = false; |
|
| 471 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 472 | + $data = array(); |
|
| 473 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 474 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 475 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 476 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 477 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 478 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 479 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 480 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 481 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 482 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 483 | + if (isset($ais_data['timestamp'])) { |
|
| 484 | 484 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 485 | 485 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 486 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 487 | - $add = true; |
|
| 486 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 487 | + $add = true; |
|
| 488 | 488 | } |
| 489 | - } else { |
|
| 489 | + } else { |
|
| 490 | 490 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 491 | 491 | $add = true; |
| 492 | - } |
|
| 493 | - $data['format_source'] = 'aisnmeatxt'; |
|
| 494 | - $data['id_source'] = $id_source; |
|
| 495 | - //print_r($data); |
|
| 496 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 497 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 498 | - unset($data); |
|
| 492 | + } |
|
| 493 | + $data['format_source'] = 'aisnmeatxt'; |
|
| 494 | + $data['id_source'] = $id_source; |
|
| 495 | + //print_r($data); |
|
| 496 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 497 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 498 | + unset($data); |
|
| 499 | 499 | } |
| 500 | - } |
|
| 501 | - $last_exec[$id]['last'] = time(); |
|
| 500 | + } |
|
| 501 | + $last_exec[$id]['last'] = time(); |
|
| 502 | 502 | } elseif ($value['format'] == 'aisnmeahttp') { |
| 503 | - $arr = $httpfeeds; |
|
| 504 | - $w = $e = null; |
|
| 503 | + $arr = $httpfeeds; |
|
| 504 | + $w = $e = null; |
|
| 505 | 505 | |
| 506 | - if (isset($arr[$id])) { |
|
| 506 | + if (isset($arr[$id])) { |
|
| 507 | 507 | $nn = stream_select($arr,$w,$e,$timeout); |
| 508 | 508 | if ($nn > 0) { |
| 509 | - foreach ($httpfeeds as $feed) { |
|
| 509 | + foreach ($httpfeeds as $feed) { |
|
| 510 | 510 | $buffer = stream_get_line($feed,2000,"\n"); |
| 511 | 511 | if ($buffer === FALSE) { |
| 512 | - connect_all($globalSources); |
|
| 512 | + connect_all($globalSources); |
|
| 513 | 513 | } |
| 514 | 514 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 515 | 515 | $buffer = explode('\n',$buffer); |
| 516 | 516 | foreach ($buffer as $line) { |
| 517 | - if ($line != '') { |
|
| 517 | + if ($line != '') { |
|
| 518 | 518 | $ais_data = $AIS->parse_line(trim($line)); |
| 519 | 519 | $data = array(); |
| 520 | 520 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -532,115 +532,115 @@ discard block |
||
| 532 | 532 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 533 | 533 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
| 534 | 534 | if (isset($ais_data['timestamp'])) { |
| 535 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 535 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 536 | 536 | } else { |
| 537 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 537 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 538 | 538 | } |
| 539 | 539 | $data['format_source'] = 'aisnmeahttp'; |
| 540 | 540 | $data['id_source'] = $id_source; |
| 541 | 541 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 542 | 542 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
| 543 | 543 | unset($data); |
| 544 | - } |
|
| 544 | + } |
|
| 545 | + } |
|
| 545 | 546 | } |
| 546 | - } |
|
| 547 | 547 | } else { |
| 548 | - $format = $value['format']; |
|
| 549 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 550 | - else $tt[$format] = 0; |
|
| 551 | - if ($tt[$format] > 30) { |
|
| 548 | + $format = $value['format']; |
|
| 549 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 550 | + else $tt[$format] = 0; |
|
| 551 | + if ($tt[$format] > 30) { |
|
| 552 | 552 | if ($globalDebug) echo 'Reconnect...'."\n"; |
| 553 | 553 | sleep(2); |
| 554 | 554 | //$sourceeen[] = $value; |
| 555 | 555 | //connect_all($sourceeen); |
| 556 | 556 | //$sourceeen = array(); |
| 557 | 557 | connect_all($globalSources); |
| 558 | - } |
|
| 558 | + } |
|
| 559 | + } |
|
| 559 | 560 | } |
| 560 | - } |
|
| 561 | 561 | } elseif ($value['format'] == 'myshiptracking' && |
| 562 | - ( |
|
| 562 | + ( |
|
| 563 | 563 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 564 | 564 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 565 | - ) |
|
| 565 | + ) |
|
| 566 | 566 | ) { |
| 567 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 568 | - if ($buffer != '') { |
|
| 567 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 568 | + if ($buffer != '') { |
|
| 569 | 569 | //echo $buffer; |
| 570 | 570 | $all_data = json_decode($buffer,true); |
| 571 | 571 | //print_r($all_data); |
| 572 | 572 | if (isset($all_data[0]['DATA'])) { |
| 573 | - foreach ($all_data[0]['DATA'] as $line) { |
|
| 573 | + foreach ($all_data[0]['DATA'] as $line) { |
|
| 574 | 574 | if ($line != '') { |
| 575 | - $data = array(); |
|
| 576 | - $data['ident'] = $line['NAME']; |
|
| 577 | - $data['mmsi'] = $line['MMSI']; |
|
| 578 | - if (strlen($data['mmsi']) > 9) { |
|
| 575 | + $data = array(); |
|
| 576 | + $data['ident'] = $line['NAME']; |
|
| 577 | + $data['mmsi'] = $line['MMSI']; |
|
| 578 | + if (strlen($data['mmsi']) > 9) { |
|
| 579 | 579 | $data['mmsi'] = substr($data['mmsi'],-9); |
| 580 | - } |
|
| 581 | - $data['speed'] = $line['SOG']; |
|
| 582 | - $data['heading'] = $line['COG']; |
|
| 583 | - $data['latitude'] = $line['LAT']; |
|
| 584 | - $data['longitude'] = $line['LNG']; |
|
| 585 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 586 | - $data['imo'] = $line['IMO']; |
|
| 587 | - //$data['arrival_code'] = $ais_data['destination']; |
|
| 588 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 589 | - $data['format_source'] = 'myshiptracking'; |
|
| 590 | - $data['id_source'] = $id_source; |
|
| 591 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 592 | - $MI->add($data); |
|
| 593 | - unset($data); |
|
| 580 | + } |
|
| 581 | + $data['speed'] = $line['SOG']; |
|
| 582 | + $data['heading'] = $line['COG']; |
|
| 583 | + $data['latitude'] = $line['LAT']; |
|
| 584 | + $data['longitude'] = $line['LNG']; |
|
| 585 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 586 | + $data['imo'] = $line['IMO']; |
|
| 587 | + //$data['arrival_code'] = $ais_data['destination']; |
|
| 588 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 589 | + $data['format_source'] = 'myshiptracking'; |
|
| 590 | + $data['id_source'] = $id_source; |
|
| 591 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 592 | + $MI->add($data); |
|
| 593 | + unset($data); |
|
| 594 | + } |
|
| 594 | 595 | } |
| 595 | - } |
|
| 596 | 596 | } |
| 597 | - } |
|
| 598 | - $last_exec[$id]['last'] = time(); |
|
| 597 | + } |
|
| 598 | + $last_exec[$id]['last'] = time(); |
|
| 599 | 599 | } elseif ($value['format'] == 'boatbeaconapp' && |
| 600 | - ( |
|
| 600 | + ( |
|
| 601 | 601 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 602 | 602 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 603 | - ) |
|
| 603 | + ) |
|
| 604 | 604 | ) { |
| 605 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 606 | - if ($buffer != '') { |
|
| 605 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 606 | + if ($buffer != '') { |
|
| 607 | 607 | $all_data = json_decode($buffer,true); |
| 608 | 608 | if (isset($all_data[0]['mmsi'])) { |
| 609 | - foreach ($all_data as $line) { |
|
| 609 | + foreach ($all_data as $line) { |
|
| 610 | 610 | if ($line != '') { |
| 611 | - $data = array(); |
|
| 612 | - $data['ident'] = $line['shipname']; |
|
| 613 | - $data['callsign'] = $line['callsign']; |
|
| 614 | - $data['mmsi'] = $line['mmsi']; |
|
| 615 | - $data['speed'] = $line['sog']; |
|
| 616 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 617 | - $data['latitude'] = $line['latitude']; |
|
| 618 | - $data['longitude'] = $line['longitude']; |
|
| 619 | - $data['type_id'] = $line['shiptype']; |
|
| 620 | - $data['arrival_code'] = $line['destination']; |
|
| 621 | - $data['datetime'] = $line['time']; |
|
| 622 | - $data['format_source'] = 'boatbeaconapp'; |
|
| 623 | - $data['id_source'] = $id_source; |
|
| 624 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 625 | - $MI->add($data); |
|
| 626 | - unset($data); |
|
| 611 | + $data = array(); |
|
| 612 | + $data['ident'] = $line['shipname']; |
|
| 613 | + $data['callsign'] = $line['callsign']; |
|
| 614 | + $data['mmsi'] = $line['mmsi']; |
|
| 615 | + $data['speed'] = $line['sog']; |
|
| 616 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 617 | + $data['latitude'] = $line['latitude']; |
|
| 618 | + $data['longitude'] = $line['longitude']; |
|
| 619 | + $data['type_id'] = $line['shiptype']; |
|
| 620 | + $data['arrival_code'] = $line['destination']; |
|
| 621 | + $data['datetime'] = $line['time']; |
|
| 622 | + $data['format_source'] = 'boatbeaconapp'; |
|
| 623 | + $data['id_source'] = $id_source; |
|
| 624 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 625 | + $MI->add($data); |
|
| 626 | + unset($data); |
|
| 627 | + } |
|
| 627 | 628 | } |
| 628 | - } |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | - } |
|
| 632 | - $last_exec[$id]['last'] = time(); |
|
| 631 | + } |
|
| 632 | + $last_exec[$id]['last'] = time(); |
|
| 633 | 633 | } elseif ($value['format'] == 'boatnerd' && |
| 634 | - ( |
|
| 634 | + ( |
|
| 635 | 635 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 636 | 636 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 637 | - ) |
|
| 637 | + ) |
|
| 638 | 638 | ) { |
| 639 | - $buffer = $Common->getData($value['host']); |
|
| 640 | - if ($buffer != '') { |
|
| 639 | + $buffer = $Common->getData($value['host']); |
|
| 640 | + if ($buffer != '') { |
|
| 641 | 641 | $all_data = json_decode($buffer,true); |
| 642 | 642 | if (isset($all_data['features'][0]['id'])) { |
| 643 | - foreach ($all_data['features'] as $line) { |
|
| 643 | + foreach ($all_data['features'] as $line) { |
|
| 644 | 644 | $data = array(); |
| 645 | 645 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
| 646 | 646 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -659,78 +659,78 @@ discard block |
||
| 659 | 659 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 660 | 660 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
| 661 | 661 | unset($data); |
| 662 | - } |
|
| 662 | + } |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | - } |
|
| 666 | - $last_exec[$id]['last'] = time(); |
|
| 665 | + } |
|
| 666 | + $last_exec[$id]['last'] = time(); |
|
| 667 | 667 | } elseif ($value['format'] == 'shipplotter' && |
| 668 | - ( |
|
| 668 | + ( |
|
| 669 | 669 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 670 | 670 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 671 | - ) |
|
| 671 | + ) |
|
| 672 | 672 | ) { |
| 673 | - echo 'download...'; |
|
| 674 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 675 | - echo 'done !'."\n"; |
|
| 676 | - if ($buffer != '') $reset = 0; |
|
| 677 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 678 | - $buffer = explode('\n',$buffer); |
|
| 679 | - foreach ($buffer as $line) { |
|
| 673 | + echo 'download...'; |
|
| 674 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 675 | + echo 'done !'."\n"; |
|
| 676 | + if ($buffer != '') $reset = 0; |
|
| 677 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 678 | + $buffer = explode('\n',$buffer); |
|
| 679 | + foreach ($buffer as $line) { |
|
| 680 | 680 | if ($line != '') { |
| 681 | - $data = array(); |
|
| 682 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 683 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 684 | - //$data['status'] = substr($line,21,2); |
|
| 685 | - //$data['type'] = substr($line,24,3); |
|
| 686 | - $data['latitude'] = substr($line,29,9); |
|
| 687 | - $data['longitude'] = substr($line,41,9); |
|
| 688 | - $data['speed'] = round(substr($line,51,5)); |
|
| 689 | - //$data['course'] = substr($line,57,5); |
|
| 690 | - $data['heading'] = round(substr($line,63,3)); |
|
| 691 | - //$data['draft'] = substr($line,67,4); |
|
| 692 | - //$data['length'] = substr($line,72,3); |
|
| 693 | - //$data['beam'] = substr($line,76,2); |
|
| 694 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 695 | - //$data['callsign'] = trim(substr($line,100,7); |
|
| 696 | - //$data['dest'] = substr($line,108,20); |
|
| 697 | - //$data['etaDate'] = substr($line,129,5); |
|
| 698 | - //$data['etaTime'] = substr($line,135,5); |
|
| 699 | - $data['format_source'] = 'shipplotter'; |
|
| 700 | - $data['id_source'] = $id_source; |
|
| 701 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 702 | - //print_r($data); |
|
| 703 | - echo 'Add...'."\n"; |
|
| 704 | - $MI->add($data); |
|
| 705 | - unset($data); |
|
| 681 | + $data = array(); |
|
| 682 | + $data['mmsi'] = (int)substr($line,0,9); |
|
| 683 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 684 | + //$data['status'] = substr($line,21,2); |
|
| 685 | + //$data['type'] = substr($line,24,3); |
|
| 686 | + $data['latitude'] = substr($line,29,9); |
|
| 687 | + $data['longitude'] = substr($line,41,9); |
|
| 688 | + $data['speed'] = round(substr($line,51,5)); |
|
| 689 | + //$data['course'] = substr($line,57,5); |
|
| 690 | + $data['heading'] = round(substr($line,63,3)); |
|
| 691 | + //$data['draft'] = substr($line,67,4); |
|
| 692 | + //$data['length'] = substr($line,72,3); |
|
| 693 | + //$data['beam'] = substr($line,76,2); |
|
| 694 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 695 | + //$data['callsign'] = trim(substr($line,100,7); |
|
| 696 | + //$data['dest'] = substr($line,108,20); |
|
| 697 | + //$data['etaDate'] = substr($line,129,5); |
|
| 698 | + //$data['etaTime'] = substr($line,135,5); |
|
| 699 | + $data['format_source'] = 'shipplotter'; |
|
| 700 | + $data['id_source'] = $id_source; |
|
| 701 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 702 | + //print_r($data); |
|
| 703 | + echo 'Add...'."\n"; |
|
| 704 | + $MI->add($data); |
|
| 705 | + unset($data); |
|
| 706 | 706 | } |
| 707 | - } |
|
| 708 | - $last_exec[$id]['last'] = time(); |
|
| 707 | + } |
|
| 708 | + $last_exec[$id]['last'] = time(); |
|
| 709 | 709 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 710 | 710 | } elseif ( |
| 711 | - ( |
|
| 711 | + ( |
|
| 712 | 712 | $value['format'] == 'whazzup' && |
| 713 | 713 | ( |
| 714 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 715 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 714 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 715 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 716 | 716 | ) |
| 717 | - ) || ( |
|
| 717 | + ) || ( |
|
| 718 | 718 | $value['format'] == 'vatsimtxt' && |
| 719 | 719 | ( |
| 720 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 721 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 720 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 721 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 722 | + ) |
|
| 722 | 723 | ) |
| 723 | - ) |
|
| 724 | 724 | ) { |
| 725 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 726 | - $buffer = $Common->getData($value['host']); |
|
| 727 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 728 | - $buffer = explode('\n',$buffer); |
|
| 729 | - $reset = 0; |
|
| 730 | - foreach ($buffer as $line) { |
|
| 731 | - if ($line != '') { |
|
| 732 | - $line = explode(':', $line); |
|
| 733 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 725 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 726 | + $buffer = $Common->getData($value['host']); |
|
| 727 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 728 | + $buffer = explode('\n',$buffer); |
|
| 729 | + $reset = 0; |
|
| 730 | + foreach ($buffer as $line) { |
|
| 731 | + if ($line != '') { |
|
| 732 | + $line = explode(':', $line); |
|
| 733 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 734 | 734 | $data = array(); |
| 735 | 735 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 736 | 736 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -743,37 +743,37 @@ discard block |
||
| 743 | 743 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 744 | 744 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 745 | 745 | $data['latitude'] = $line[5]; // lat |
| 746 | - $data['longitude'] = $line[6]; // long |
|
| 747 | - $data['verticalrate'] = ''; // vertical rate |
|
| 748 | - $data['squawk'] = ''; // squawk |
|
| 749 | - $data['emergency'] = ''; // emergency |
|
| 750 | - $data['waypoints'] = $line[30]; |
|
| 746 | + $data['longitude'] = $line[6]; // long |
|
| 747 | + $data['verticalrate'] = ''; // vertical rate |
|
| 748 | + $data['squawk'] = ''; // squawk |
|
| 749 | + $data['emergency'] = ''; // emergency |
|
| 750 | + $data['waypoints'] = $line[30]; |
|
| 751 | 751 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 752 | 752 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 753 | 753 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 754 | - $data['departure_airport_icao'] = $line[11]; |
|
| 755 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 756 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 754 | + $data['departure_airport_icao'] = $line[11]; |
|
| 755 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 756 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 757 | 757 | $data['frequency'] = $line[4]; |
| 758 | 758 | $data['type'] = $line[18]; |
| 759 | 759 | $data['range'] = $line[19]; |
| 760 | 760 | if (isset($line[35])) $data['info'] = $line[35]; |
| 761 | - $data['id_source'] = $id_source; |
|
| 762 | - //$data['arrival_airport_time'] = ; |
|
| 763 | - if ($line[9] != '') { |
|
| 764 | - $aircraft_data = explode('/',$line[9]); |
|
| 765 | - if (isset($aircraft_data[1])) { |
|
| 766 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 767 | - } |
|
| 768 | - } |
|
| 769 | - /* |
|
| 761 | + $data['id_source'] = $id_source; |
|
| 762 | + //$data['arrival_airport_time'] = ; |
|
| 763 | + if ($line[9] != '') { |
|
| 764 | + $aircraft_data = explode('/',$line[9]); |
|
| 765 | + if (isset($aircraft_data[1])) { |
|
| 766 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 767 | + } |
|
| 768 | + } |
|
| 769 | + /* |
|
| 770 | 770 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 771 | 771 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 772 | 772 | */ |
| 773 | - $data['format_source'] = $value['format']; |
|
| 773 | + $data['format_source'] = $value['format']; |
|
| 774 | 774 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 775 | 775 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 776 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 776 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 777 | 777 | elseif ($line[3] == 'ATC') { |
| 778 | 778 | //print_r($data); |
| 779 | 779 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -794,21 +794,21 @@ discard block |
||
| 794 | 794 | 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']); |
| 795 | 795 | } |
| 796 | 796 | } |
| 797 | - unset($data); |
|
| 798 | - } |
|
| 799 | - } |
|
| 800 | - } |
|
| 801 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 802 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 803 | - $last_exec[$id]['last'] = time(); |
|
| 804 | - } elseif ($value['format'] == 'airwhere' && |
|
| 805 | - ( |
|
| 806 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 807 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 808 | - ) |
|
| 809 | - ) { |
|
| 810 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 811 | - if ($buffer != '') { |
|
| 797 | + unset($data); |
|
| 798 | + } |
|
| 799 | + } |
|
| 800 | + } |
|
| 801 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 802 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 803 | + $last_exec[$id]['last'] = time(); |
|
| 804 | + } elseif ($value['format'] == 'airwhere' && |
|
| 805 | + ( |
|
| 806 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 807 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 808 | + ) |
|
| 809 | + ) { |
|
| 810 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 811 | + if ($buffer != '') { |
|
| 812 | 812 | $all_data = simplexml_load_string($buffer); |
| 813 | 813 | foreach($all_data->children() as $childdata) { |
| 814 | 814 | $data = array(); |
@@ -830,10 +830,10 @@ discard block |
||
| 830 | 830 | $SI->add($data); |
| 831 | 831 | unset($data); |
| 832 | 832 | } |
| 833 | - } |
|
| 834 | - $Source->deleteOldLocationByType('gs'); |
|
| 835 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 836 | - if ($buffer != '') { |
|
| 833 | + } |
|
| 834 | + $Source->deleteOldLocationByType('gs'); |
|
| 835 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 836 | + if ($buffer != '') { |
|
| 837 | 837 | $all_data = simplexml_load_string($buffer); |
| 838 | 838 | foreach($all_data->children() as $childdata) { |
| 839 | 839 | $data = array(); |
@@ -851,8 +851,8 @@ discard block |
||
| 851 | 851 | } |
| 852 | 852 | unset($data); |
| 853 | 853 | } |
| 854 | - } |
|
| 855 | - $last_exec[$id]['last'] = time(); |
|
| 854 | + } |
|
| 855 | + $last_exec[$id]['last'] = time(); |
|
| 856 | 856 | /* |
| 857 | 857 | } if ($value['format'] == 'aircraftlistjson') { |
| 858 | 858 | print_r($globalSources); |
@@ -860,17 +860,17 @@ discard block |
||
| 860 | 860 | echo $globalMinFetch; |
| 861 | 861 | */ |
| 862 | 862 | } elseif ($value['format'] == 'aircraftlistjson' && |
| 863 | - ( |
|
| 863 | + ( |
|
| 864 | 864 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 865 | 865 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 866 | - ) |
|
| 866 | + ) |
|
| 867 | 867 | ) { |
| 868 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 869 | - if ($buffer != '') { |
|
| 870 | - $all_data = json_decode($buffer,true); |
|
| 868 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 869 | + if ($buffer != '') { |
|
| 870 | + $all_data = json_decode($buffer,true); |
|
| 871 | 871 | if (isset($all_data['acList'])) { |
| 872 | - $reset = 0; |
|
| 873 | - foreach ($all_data['acList'] as $line) { |
|
| 872 | + $reset = 0; |
|
| 873 | + foreach ($all_data['acList'] as $line) { |
|
| 874 | 874 | $data = array(); |
| 875 | 875 | $data['hex'] = $line['Icao']; // hex |
| 876 | 876 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -893,10 +893,10 @@ discard block |
||
| 893 | 893 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 894 | 894 | if (isset($data['latitude'])) $SI->add($data); |
| 895 | 895 | unset($data); |
| 896 | - } |
|
| 896 | + } |
|
| 897 | 897 | } elseif (is_array($all_data)) { |
| 898 | - $reset = 0; |
|
| 899 | - foreach ($all_data as $line) { |
|
| 898 | + $reset = 0; |
|
| 899 | + foreach ($all_data as $line) { |
|
| 900 | 900 | $data = array(); |
| 901 | 901 | $data['hex'] = $line['hex']; // hex |
| 902 | 902 | $data['ident'] = $line['flight']; // ident |
@@ -916,218 +916,218 @@ discard block |
||
| 916 | 916 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 917 | 917 | $SI->add($data); |
| 918 | 918 | unset($data); |
| 919 | - } |
|
| 919 | + } |
|
| 920 | 920 | } |
| 921 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 922 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 923 | - $last_exec[$id]['last'] = time(); |
|
| 924 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 925 | - } elseif ($value['format'] == 'planeupdatefaa' && |
|
| 926 | - ( |
|
| 927 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 928 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 929 | - ) |
|
| 930 | - ) { |
|
| 931 | - $buffer = $Common->getData($value['host']); |
|
| 932 | - $all_data = json_decode($buffer,true); |
|
| 933 | - if (isset($all_data['planes'])) { |
|
| 921 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 922 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 923 | + $last_exec[$id]['last'] = time(); |
|
| 924 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 925 | + } elseif ($value['format'] == 'planeupdatefaa' && |
|
| 926 | + ( |
|
| 927 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 928 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 929 | + ) |
|
| 930 | + ) { |
|
| 931 | + $buffer = $Common->getData($value['host']); |
|
| 932 | + $all_data = json_decode($buffer,true); |
|
| 933 | + if (isset($all_data['planes'])) { |
|
| 934 | 934 | $reset = 0; |
| 935 | 935 | foreach ($all_data['planes'] as $key => $line) { |
| 936 | - $data = array(); |
|
| 937 | - $data['hex'] = $key; // hex |
|
| 938 | - $data['ident'] = $line[3]; // ident |
|
| 939 | - $data['altitude'] = $line[6]; // altitude |
|
| 940 | - $data['speed'] = $line[8]; // speed |
|
| 941 | - $data['heading'] = $line[7]; // heading |
|
| 942 | - $data['latitude'] = $line[4]; // lat |
|
| 943 | - $data['longitude'] = $line[5]; // long |
|
| 944 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 945 | - $data['squawk'] = $line[10]; // squawk |
|
| 946 | - $data['emergency'] = ''; // emergency |
|
| 947 | - $data['registration'] = $line[2]; |
|
| 948 | - $data['aircraft_icao'] = $line[0]; |
|
| 949 | - $deparr = explode('-',$line[1]); |
|
| 950 | - if (count($deparr) == 2) { |
|
| 936 | + $data = array(); |
|
| 937 | + $data['hex'] = $key; // hex |
|
| 938 | + $data['ident'] = $line[3]; // ident |
|
| 939 | + $data['altitude'] = $line[6]; // altitude |
|
| 940 | + $data['speed'] = $line[8]; // speed |
|
| 941 | + $data['heading'] = $line[7]; // heading |
|
| 942 | + $data['latitude'] = $line[4]; // lat |
|
| 943 | + $data['longitude'] = $line[5]; // long |
|
| 944 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 945 | + $data['squawk'] = $line[10]; // squawk |
|
| 946 | + $data['emergency'] = ''; // emergency |
|
| 947 | + $data['registration'] = $line[2]; |
|
| 948 | + $data['aircraft_icao'] = $line[0]; |
|
| 949 | + $deparr = explode('-',$line[1]); |
|
| 950 | + if (count($deparr) == 2) { |
|
| 951 | 951 | $data['departure_airport_icao'] = $deparr[0]; |
| 952 | 952 | $data['arrival_airport_icao'] = $deparr[1]; |
| 953 | - } |
|
| 954 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 955 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 956 | - $data['id_source'] = $id_source; |
|
| 957 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 958 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 959 | - $SI->add($data); |
|
| 960 | - unset($data); |
|
| 953 | + } |
|
| 954 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 955 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 956 | + $data['id_source'] = $id_source; |
|
| 957 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 958 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 959 | + $SI->add($data); |
|
| 960 | + unset($data); |
|
| 961 | + } |
|
| 961 | 962 | } |
| 962 | - } |
|
| 963 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 964 | - $last_exec[$id]['last'] = time(); |
|
| 963 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 964 | + $last_exec[$id]['last'] = time(); |
|
| 965 | 965 | } elseif ($value['format'] == 'opensky' && |
| 966 | - ( |
|
| 966 | + ( |
|
| 967 | 967 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 968 | 968 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 969 | - ) |
|
| 969 | + ) |
|
| 970 | 970 | ) { |
| 971 | - $buffer = $Common->getData($value['host']); |
|
| 972 | - $all_data = json_decode($buffer,true); |
|
| 973 | - if (isset($all_data['states'])) { |
|
| 971 | + $buffer = $Common->getData($value['host']); |
|
| 972 | + $all_data = json_decode($buffer,true); |
|
| 973 | + if (isset($all_data['states'])) { |
|
| 974 | 974 | $reset = 0; |
| 975 | 975 | foreach ($all_data['states'] as $key => $line) { |
| 976 | - $data = array(); |
|
| 977 | - $data['hex'] = $line[0]; // hex |
|
| 978 | - $data['ident'] = trim($line[1]); // ident |
|
| 979 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 980 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 981 | - $data['heading'] = round($line[10]); // heading |
|
| 982 | - $data['latitude'] = $line[6]; // lat |
|
| 983 | - $data['longitude'] = $line[5]; // long |
|
| 984 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 985 | - //$data['squawk'] = $line[10]; // squawk |
|
| 986 | - //$data['emergency'] = ''; // emergency |
|
| 987 | - //$data['registration'] = $line[2]; |
|
| 988 | - //$data['aircraft_icao'] = $line[0]; |
|
| 989 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 990 | - $data['format_source'] = 'opensky'; |
|
| 991 | - $data['id_source'] = $id_source; |
|
| 992 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 993 | - $SI->add($data); |
|
| 994 | - unset($data); |
|
| 976 | + $data = array(); |
|
| 977 | + $data['hex'] = $line[0]; // hex |
|
| 978 | + $data['ident'] = trim($line[1]); // ident |
|
| 979 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 980 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 981 | + $data['heading'] = round($line[10]); // heading |
|
| 982 | + $data['latitude'] = $line[6]; // lat |
|
| 983 | + $data['longitude'] = $line[5]; // long |
|
| 984 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 985 | + //$data['squawk'] = $line[10]; // squawk |
|
| 986 | + //$data['emergency'] = ''; // emergency |
|
| 987 | + //$data['registration'] = $line[2]; |
|
| 988 | + //$data['aircraft_icao'] = $line[0]; |
|
| 989 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 990 | + $data['format_source'] = 'opensky'; |
|
| 991 | + $data['id_source'] = $id_source; |
|
| 992 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 993 | + $SI->add($data); |
|
| 994 | + unset($data); |
|
| 995 | 995 | } |
| 996 | - } |
|
| 997 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 998 | - $last_exec[$id]['last'] = time(); |
|
| 996 | + } |
|
| 997 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 998 | + $last_exec[$id]['last'] = time(); |
|
| 999 | 999 | //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
| 1000 | 1000 | } elseif ($value['format'] == 'fr24json' && |
| 1001 | - ( |
|
| 1001 | + ( |
|
| 1002 | 1002 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1003 | 1003 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1004 | - ) |
|
| 1004 | + ) |
|
| 1005 | 1005 | ) { |
| 1006 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1007 | - $buffer = $Common->getData($value['host']); |
|
| 1008 | - $all_data = json_decode($buffer,true); |
|
| 1009 | - if (!empty($all_data)) $reset = 0; |
|
| 1010 | - foreach ($all_data as $key => $line) { |
|
| 1006 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1007 | + $buffer = $Common->getData($value['host']); |
|
| 1008 | + $all_data = json_decode($buffer,true); |
|
| 1009 | + if (!empty($all_data)) $reset = 0; |
|
| 1010 | + foreach ($all_data as $key => $line) { |
|
| 1011 | 1011 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1012 | - $data = array(); |
|
| 1013 | - $data['hex'] = $line[0]; |
|
| 1014 | - $data['ident'] = $line[16]; //$line[13] |
|
| 1015 | - $data['altitude'] = $line[4]; // altitude |
|
| 1016 | - $data['speed'] = $line[5]; // speed |
|
| 1017 | - $data['heading'] = $line[3]; // heading |
|
| 1018 | - $data['latitude'] = $line[1]; // lat |
|
| 1019 | - $data['longitude'] = $line[2]; // long |
|
| 1020 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1021 | - $data['squawk'] = $line[6]; // squawk |
|
| 1022 | - $data['aircraft_icao'] = $line[8]; |
|
| 1023 | - $data['registration'] = $line[9]; |
|
| 1024 | - $data['departure_airport_iata'] = $line[11]; |
|
| 1025 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 1026 | - $data['emergency'] = ''; // emergency |
|
| 1027 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1028 | - $data['format_source'] = 'fr24json'; |
|
| 1029 | - $data['id_source'] = $id_source; |
|
| 1030 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1031 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1032 | - $SI->add($data); |
|
| 1033 | - unset($data); |
|
| 1012 | + $data = array(); |
|
| 1013 | + $data['hex'] = $line[0]; |
|
| 1014 | + $data['ident'] = $line[16]; //$line[13] |
|
| 1015 | + $data['altitude'] = $line[4]; // altitude |
|
| 1016 | + $data['speed'] = $line[5]; // speed |
|
| 1017 | + $data['heading'] = $line[3]; // heading |
|
| 1018 | + $data['latitude'] = $line[1]; // lat |
|
| 1019 | + $data['longitude'] = $line[2]; // long |
|
| 1020 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1021 | + $data['squawk'] = $line[6]; // squawk |
|
| 1022 | + $data['aircraft_icao'] = $line[8]; |
|
| 1023 | + $data['registration'] = $line[9]; |
|
| 1024 | + $data['departure_airport_iata'] = $line[11]; |
|
| 1025 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 1026 | + $data['emergency'] = ''; // emergency |
|
| 1027 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1028 | + $data['format_source'] = 'fr24json'; |
|
| 1029 | + $data['id_source'] = $id_source; |
|
| 1030 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1031 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1032 | + $SI->add($data); |
|
| 1033 | + unset($data); |
|
| 1034 | 1034 | } |
| 1035 | - } |
|
| 1036 | - //$last_exec['fr24json'] = time(); |
|
| 1037 | - $last_exec[$id]['last'] = time(); |
|
| 1035 | + } |
|
| 1036 | + //$last_exec['fr24json'] = time(); |
|
| 1037 | + $last_exec[$id]['last'] = time(); |
|
| 1038 | 1038 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 1039 | 1039 | } elseif ($value['format'] == 'radarvirtueljson' && |
| 1040 | - ( |
|
| 1040 | + ( |
|
| 1041 | 1041 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1042 | 1042 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1043 | - ) |
|
| 1043 | + ) |
|
| 1044 | 1044 | ) { |
| 1045 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1046 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1047 | - //echo $buffer; |
|
| 1048 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1049 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1050 | - $all_data = json_decode($buffer,true); |
|
| 1051 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1045 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1046 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1047 | + //echo $buffer; |
|
| 1048 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1049 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1050 | + $all_data = json_decode($buffer,true); |
|
| 1051 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1052 | 1052 | die(json_last_error_msg()); |
| 1053 | - } |
|
| 1054 | - if (isset($all_data['mrkrs'])) { |
|
| 1053 | + } |
|
| 1054 | + if (isset($all_data['mrkrs'])) { |
|
| 1055 | 1055 | $reset = 0; |
| 1056 | 1056 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 1057 | - if (isset($line['inf'])) { |
|
| 1057 | + if (isset($line['inf'])) { |
|
| 1058 | 1058 | $data = array(); |
| 1059 | 1059 | $data['hex'] = $line['inf']['ia']; |
| 1060 | 1060 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 1061 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1062 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1063 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1064 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 1065 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 1066 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1067 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1068 | - //$data['aircraft_icao'] = $line[8]; |
|
| 1069 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1061 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1062 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1063 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1064 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 1065 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 1066 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1067 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1068 | + //$data['aircraft_icao'] = $line[8]; |
|
| 1069 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1070 | 1070 | //$data['departure_airport_iata'] = $line[11]; |
| 1071 | 1071 | //$data['arrival_airport_iata'] = $line[12]; |
| 1072 | - //$data['emergency'] = ''; // emergency |
|
| 1072 | + //$data['emergency'] = ''; // emergency |
|
| 1073 | 1073 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1074 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 1075 | - $data['id_source'] = $id_source; |
|
| 1074 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 1075 | + $data['id_source'] = $id_source; |
|
| 1076 | 1076 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1077 | 1077 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1078 | 1078 | $SI->add($data); |
| 1079 | 1079 | unset($data); |
| 1080 | - } |
|
| 1080 | + } |
|
| 1081 | + } |
|
| 1081 | 1082 | } |
| 1082 | - } |
|
| 1083 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 1084 | - $last_exec[$id]['last'] = time(); |
|
| 1083 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 1084 | + $last_exec[$id]['last'] = time(); |
|
| 1085 | 1085 | //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
| 1086 | 1086 | } elseif ($value['format'] == 'pirepsjson' && |
| 1087 | - ( |
|
| 1087 | + ( |
|
| 1088 | 1088 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1089 | 1089 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1090 | - ) |
|
| 1090 | + ) |
|
| 1091 | 1091 | ) { |
| 1092 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1093 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1094 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1092 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1093 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1094 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1095 | 1095 | |
| 1096 | - if (isset($all_data['pireps'])) { |
|
| 1096 | + if (isset($all_data['pireps'])) { |
|
| 1097 | 1097 | $reset = 0; |
| 1098 | - foreach ($all_data['pireps'] as $line) { |
|
| 1099 | - $data = array(); |
|
| 1100 | - $data['id'] = $line['id']; |
|
| 1101 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1102 | - $data['ident'] = $line['callsign']; // ident |
|
| 1103 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1104 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1105 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1106 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1107 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1108 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1109 | - $data['latitude'] = $line['lat']; // lat |
|
| 1110 | - $data['longitude'] = $line['lon']; // long |
|
| 1111 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1112 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 1113 | - //$data['emergency'] = ''; // emergency |
|
| 1114 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1115 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1116 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1117 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1118 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1119 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1120 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1121 | - else $data['info'] = ''; |
|
| 1122 | - $data['format_source'] = 'pireps'; |
|
| 1123 | - $data['id_source'] = $id_source; |
|
| 1124 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1125 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1126 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1127 | - if ($line['icon'] == 'plane') { |
|
| 1098 | + foreach ($all_data['pireps'] as $line) { |
|
| 1099 | + $data = array(); |
|
| 1100 | + $data['id'] = $line['id']; |
|
| 1101 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1102 | + $data['ident'] = $line['callsign']; // ident |
|
| 1103 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1104 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1105 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1106 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1107 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1108 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1109 | + $data['latitude'] = $line['lat']; // lat |
|
| 1110 | + $data['longitude'] = $line['lon']; // long |
|
| 1111 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1112 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 1113 | + //$data['emergency'] = ''; // emergency |
|
| 1114 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1115 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1116 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1117 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1118 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1119 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1120 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1121 | + else $data['info'] = ''; |
|
| 1122 | + $data['format_source'] = 'pireps'; |
|
| 1123 | + $data['id_source'] = $id_source; |
|
| 1124 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1125 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1126 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1127 | + if ($line['icon'] == 'plane') { |
|
| 1128 | 1128 | $SI->add($data); |
| 1129 | - // print_r($data); |
|
| 1130 | - } elseif ($line['icon'] == 'ct') { |
|
| 1129 | + // print_r($data); |
|
| 1130 | + } elseif ($line['icon'] == 'ct') { |
|
| 1131 | 1131 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 1132 | 1132 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1133 | 1133 | $typec = substr($data['ident'],-3); |
@@ -1142,151 +1142,151 @@ discard block |
||
| 1142 | 1142 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1143 | 1143 | else $data['type'] = 'Observer'; |
| 1144 | 1144 | 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']); |
| 1145 | - } |
|
| 1146 | - unset($data); |
|
| 1145 | + } |
|
| 1146 | + unset($data); |
|
| 1147 | + } |
|
| 1147 | 1148 | } |
| 1148 | - } |
|
| 1149 | - //$last_exec['pirepsjson'] = time(); |
|
| 1150 | - $last_exec[$id]['last'] = time(); |
|
| 1149 | + //$last_exec['pirepsjson'] = time(); |
|
| 1150 | + $last_exec[$id]['last'] = time(); |
|
| 1151 | 1151 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 1152 | 1152 | } elseif ($value['format'] == 'phpvmacars' && |
| 1153 | - ( |
|
| 1153 | + ( |
|
| 1154 | 1154 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1155 | 1155 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1156 | - ) |
|
| 1156 | + ) |
|
| 1157 | 1157 | ) { |
| 1158 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1159 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1160 | - $buffer = $Common->getData($value['host']); |
|
| 1161 | - $all_data = json_decode($buffer,true); |
|
| 1162 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1158 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1159 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1160 | + $buffer = $Common->getData($value['host']); |
|
| 1161 | + $all_data = json_decode($buffer,true); |
|
| 1162 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1163 | 1163 | $reset = 0; |
| 1164 | 1164 | foreach ($all_data as $line) { |
| 1165 | - $data = array(); |
|
| 1166 | - //$data['id'] = $line['id']; // id not usable |
|
| 1167 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1168 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1169 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1170 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1171 | - $data['ident'] = $line['flightnum']; // ident |
|
| 1172 | - $data['altitude'] = $line['alt']; // altitude |
|
| 1173 | - $data['speed'] = $line['gs']; // speed |
|
| 1174 | - $data['heading'] = $line['heading']; // heading |
|
| 1175 | - $data['latitude'] = $line['lat']; // lat |
|
| 1176 | - $data['longitude'] = $line['lng']; // long |
|
| 1177 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1178 | - $data['squawk'] = ''; // squawk |
|
| 1179 | - $data['emergency'] = ''; // emergency |
|
| 1180 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1181 | - //$data['last_update'] = $line['lastupdate']; |
|
| 1182 | - if (isset($value['timezone'])) { |
|
| 1183 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1184 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1185 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1186 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1187 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 1188 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 1189 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1190 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1191 | - if (isset($line['registration'])) { |
|
| 1192 | - $data['registration'] = $line['registration']; |
|
| 1193 | - if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1194 | - } else $data['registration'] = $line['aircraft']; |
|
| 1195 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1196 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1197 | - if (isset($line['aircraftname'])) { |
|
| 1165 | + $data = array(); |
|
| 1166 | + //$data['id'] = $line['id']; // id not usable |
|
| 1167 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1168 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1169 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1170 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1171 | + $data['ident'] = $line['flightnum']; // ident |
|
| 1172 | + $data['altitude'] = $line['alt']; // altitude |
|
| 1173 | + $data['speed'] = $line['gs']; // speed |
|
| 1174 | + $data['heading'] = $line['heading']; // heading |
|
| 1175 | + $data['latitude'] = $line['lat']; // lat |
|
| 1176 | + $data['longitude'] = $line['lng']; // long |
|
| 1177 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1178 | + $data['squawk'] = ''; // squawk |
|
| 1179 | + $data['emergency'] = ''; // emergency |
|
| 1180 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1181 | + //$data['last_update'] = $line['lastupdate']; |
|
| 1182 | + if (isset($value['timezone'])) { |
|
| 1183 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1184 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1185 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1186 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1187 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1188 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1189 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1190 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1191 | + if (isset($line['registration'])) { |
|
| 1192 | + $data['registration'] = $line['registration']; |
|
| 1193 | + if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1194 | + } else $data['registration'] = $line['aircraft']; |
|
| 1195 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1196 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1197 | + if (isset($line['aircraftname'])) { |
|
| 1198 | 1198 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1199 | 1199 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1200 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1201 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1202 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1203 | - else { |
|
| 1204 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1205 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1206 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1207 | - } |
|
| 1208 | - } |
|
| 1209 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1210 | - $data['id_source'] = $id_source; |
|
| 1211 | - $data['format_source'] = 'phpvmacars'; |
|
| 1212 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1213 | - $SI->add($data); |
|
| 1214 | - unset($data); |
|
| 1200 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1201 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1202 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1203 | + else { |
|
| 1204 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1205 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1206 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1207 | + } |
|
| 1208 | + } |
|
| 1209 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1210 | + $data['id_source'] = $id_source; |
|
| 1211 | + $data['format_source'] = 'phpvmacars'; |
|
| 1212 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1213 | + $SI->add($data); |
|
| 1214 | + unset($data); |
|
| 1215 | 1215 | } |
| 1216 | 1216 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1217 | 1217 | unset($buffer); |
| 1218 | 1218 | unset($all_data); |
| 1219 | - } |
|
| 1220 | - //$last_exec['phpvmacars'] = time(); |
|
| 1221 | - $last_exec[$id]['last'] = time(); |
|
| 1219 | + } |
|
| 1220 | + //$last_exec['phpvmacars'] = time(); |
|
| 1221 | + $last_exec[$id]['last'] = time(); |
|
| 1222 | 1222 | } elseif ($value['format'] == 'vam' && |
| 1223 | - ( |
|
| 1223 | + ( |
|
| 1224 | 1224 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1225 | 1225 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1226 | - ) |
|
| 1226 | + ) |
|
| 1227 | 1227 | ) { |
| 1228 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1229 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1230 | - $buffer = $Common->getData($value['host']); |
|
| 1231 | - $all_data = json_decode($buffer,true); |
|
| 1232 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1228 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1229 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1230 | + $buffer = $Common->getData($value['host']); |
|
| 1231 | + $all_data = json_decode($buffer,true); |
|
| 1232 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1233 | 1233 | $reset = 0; |
| 1234 | 1234 | foreach ($all_data as $line) { |
| 1235 | - $data = array(); |
|
| 1236 | - //$data['id'] = $line['id']; // id not usable |
|
| 1237 | - $data['id'] = trim($line['flight_id']); |
|
| 1238 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1239 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 1240 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 1241 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 1242 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1243 | - $data['speed'] = $line['gs']; // speed |
|
| 1244 | - $data['heading'] = $line['heading']; // heading |
|
| 1245 | - $data['latitude'] = $line['latitude']; // lat |
|
| 1246 | - $data['longitude'] = $line['longitude']; // long |
|
| 1247 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1248 | - $data['squawk'] = ''; // squawk |
|
| 1249 | - $data['emergency'] = ''; // emergency |
|
| 1250 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1251 | - $data['last_update'] = $line['last_update']; |
|
| 1252 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1253 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 1254 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1255 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1256 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1257 | - //$data['registration'] = $line['aircraft']; |
|
| 1258 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1259 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 1260 | - $data['id_source'] = $id_source; |
|
| 1261 | - $data['format_source'] = 'vam'; |
|
| 1262 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1263 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1264 | - $SI->add($data); |
|
| 1265 | - unset($data); |
|
| 1235 | + $data = array(); |
|
| 1236 | + //$data['id'] = $line['id']; // id not usable |
|
| 1237 | + $data['id'] = trim($line['flight_id']); |
|
| 1238 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1239 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 1240 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 1241 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 1242 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1243 | + $data['speed'] = $line['gs']; // speed |
|
| 1244 | + $data['heading'] = $line['heading']; // heading |
|
| 1245 | + $data['latitude'] = $line['latitude']; // lat |
|
| 1246 | + $data['longitude'] = $line['longitude']; // long |
|
| 1247 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1248 | + $data['squawk'] = ''; // squawk |
|
| 1249 | + $data['emergency'] = ''; // emergency |
|
| 1250 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1251 | + $data['last_update'] = $line['last_update']; |
|
| 1252 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1253 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 1254 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1255 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1256 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1257 | + //$data['registration'] = $line['aircraft']; |
|
| 1258 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1259 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 1260 | + $data['id_source'] = $id_source; |
|
| 1261 | + $data['format_source'] = 'vam'; |
|
| 1262 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1263 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1264 | + $SI->add($data); |
|
| 1265 | + unset($data); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1268 | 1268 | unset($buffer); |
| 1269 | 1269 | unset($all_data); |
| 1270 | - } |
|
| 1271 | - //$last_exec['phpvmacars'] = time(); |
|
| 1272 | - $last_exec[$id]['last'] = time(); |
|
| 1270 | + } |
|
| 1271 | + //$last_exec['phpvmacars'] = time(); |
|
| 1272 | + $last_exec[$id]['last'] = time(); |
|
| 1273 | 1273 | } elseif ($value['format'] == 'blitzortung' && |
| 1274 | - ( |
|
| 1274 | + ( |
|
| 1275 | 1275 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1276 | 1276 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1277 | - ) |
|
| 1277 | + ) |
|
| 1278 | 1278 | ) { |
| 1279 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1280 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1281 | - $buffer = $Common->getData($value['host']); |
|
| 1282 | - $all_data = json_decode($buffer,true); |
|
| 1283 | - if ($buffer != '') { |
|
| 1279 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1280 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1281 | + $buffer = $Common->getData($value['host']); |
|
| 1282 | + $all_data = json_decode($buffer,true); |
|
| 1283 | + if ($buffer != '') { |
|
| 1284 | 1284 | $Source->deleteLocationBySource('blitzortung'); |
| 1285 | 1285 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 1286 | 1286 | $buffer = explode('\n',$buffer); |
| 1287 | 1287 | foreach ($buffer as $buffer_line) { |
| 1288 | - $line = json_decode($buffer_line,true); |
|
| 1289 | - if (isset($line['time'])) { |
|
| 1288 | + $line = json_decode($buffer_line,true); |
|
| 1289 | + if (isset($line['time'])) { |
|
| 1290 | 1290 | $data = array(); |
| 1291 | 1291 | $data['altitude'] = $line['alt']; // altitude |
| 1292 | 1292 | $data['latitude'] = $line['lat']; // lat |
@@ -1298,96 +1298,96 @@ discard block |
||
| 1298 | 1298 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1299 | 1299 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1300 | 1300 | unset($data); |
| 1301 | - } |
|
| 1301 | + } |
|
| 1302 | 1302 | } |
| 1303 | 1303 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1304 | 1304 | unset($buffer); |
| 1305 | - } |
|
| 1306 | - $last_exec[$id]['last'] = time(); |
|
| 1305 | + } |
|
| 1306 | + $last_exec[$id]['last'] = time(); |
|
| 1307 | 1307 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1308 | 1308 | } 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'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1309 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1310 | - //$last_exec[$id]['last'] = time(); |
|
| 1309 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1310 | + //$last_exec[$id]['last'] = time(); |
|
| 1311 | 1311 | |
| 1312 | - //$read = array( $sockets[$id] ); |
|
| 1313 | - $read = $sockets; |
|
| 1314 | - $write = NULL; |
|
| 1315 | - $e = NULL; |
|
| 1316 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 1317 | - if ($e != NULL) var_dump($e); |
|
| 1318 | - if ($n > 0) { |
|
| 1312 | + //$read = array( $sockets[$id] ); |
|
| 1313 | + $read = $sockets; |
|
| 1314 | + $write = NULL; |
|
| 1315 | + $e = NULL; |
|
| 1316 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 1317 | + if ($e != NULL) var_dump($e); |
|
| 1318 | + if ($n > 0) { |
|
| 1319 | 1319 | $reset = 0; |
| 1320 | 1320 | foreach ($read as $nb => $r) { |
| 1321 | - //$value = $formats[$nb]; |
|
| 1322 | - $format = $globalSources[$nb]['format']; |
|
| 1323 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 1321 | + //$value = $formats[$nb]; |
|
| 1322 | + $format = $globalSources[$nb]['format']; |
|
| 1323 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 1324 | 1324 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
| 1325 | - } elseif ($format == 'vrstcp') { |
|
| 1325 | + } elseif ($format == 'vrstcp') { |
|
| 1326 | 1326 | $buffer = @socket_read($r, 6000); |
| 1327 | - } else { |
|
| 1327 | + } else { |
|
| 1328 | 1328 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
| 1329 | - } |
|
| 1330 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1331 | - //echo $buffer."\n"; |
|
| 1332 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1333 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1334 | - $error = false; |
|
| 1335 | - //$SI::del(); |
|
| 1336 | - if ($buffer !== FALSE) { |
|
| 1329 | + } |
|
| 1330 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1331 | + //echo $buffer."\n"; |
|
| 1332 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1333 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1334 | + $error = false; |
|
| 1335 | + //$SI::del(); |
|
| 1336 | + if ($buffer !== FALSE) { |
|
| 1337 | 1337 | if ($format == 'vrstcp') { |
| 1338 | - $buffer = explode('},{',$buffer); |
|
| 1338 | + $buffer = explode('},{',$buffer); |
|
| 1339 | 1339 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
| 1340 | - } |
|
| 1341 | - // SBS format is CSV format |
|
| 1342 | - if ($buffer !== FALSE && $buffer !== '') { |
|
| 1340 | + } |
|
| 1341 | + // SBS format is CSV format |
|
| 1342 | + if ($buffer !== FALSE && $buffer !== '') { |
|
| 1343 | 1343 | $tt[$format] = 0; |
| 1344 | 1344 | if ($format == 'acarssbs3') { |
| 1345 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1346 | - $ACARS->add(trim($buffer)); |
|
| 1347 | - $ACARS->deleteLiveAcarsData(); |
|
| 1345 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1346 | + $ACARS->add(trim($buffer)); |
|
| 1347 | + $ACARS->deleteLiveAcarsData(); |
|
| 1348 | 1348 | } elseif ($format == 'raw') { |
| 1349 | - // AVR format |
|
| 1350 | - $data = $SBS->parse($buffer); |
|
| 1351 | - if (is_array($data)) { |
|
| 1349 | + // AVR format |
|
| 1350 | + $data = $SBS->parse($buffer); |
|
| 1351 | + if (is_array($data)) { |
|
| 1352 | 1352 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1353 | 1353 | $data['format_source'] = 'raw'; |
| 1354 | 1354 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1355 | 1355 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 1356 | 1356 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1357 | 1357 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1358 | - } |
|
| 1358 | + } |
|
| 1359 | 1359 | } elseif ($format == 'ais') { |
| 1360 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1361 | - $data = array(); |
|
| 1362 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1363 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1364 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1365 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1366 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1367 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1368 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1369 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1370 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1371 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1372 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1373 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1374 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1375 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1376 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1377 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1360 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1361 | + $data = array(); |
|
| 1362 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1363 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1364 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1365 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1366 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1367 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1368 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1369 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1370 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1371 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1372 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1373 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1374 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1375 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1376 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1377 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1378 | 1378 | |
| 1379 | - if (isset($ais_data['timestamp'])) { |
|
| 1379 | + if (isset($ais_data['timestamp'])) { |
|
| 1380 | 1380 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 1381 | - } else { |
|
| 1381 | + } else { |
|
| 1382 | 1382 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1383 | - } |
|
| 1384 | - $data['format_source'] = 'aisnmea'; |
|
| 1385 | - $data['id_source'] = $id_source; |
|
| 1386 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1387 | - unset($data); |
|
| 1388 | - } elseif ($format == 'flightgearsp') { |
|
| 1389 | - //echo $buffer."\n"; |
|
| 1390 | - if (strlen($buffer) > 5) { |
|
| 1383 | + } |
|
| 1384 | + $data['format_source'] = 'aisnmea'; |
|
| 1385 | + $data['id_source'] = $id_source; |
|
| 1386 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1387 | + unset($data); |
|
| 1388 | + } elseif ($format == 'flightgearsp') { |
|
| 1389 | + //echo $buffer."\n"; |
|
| 1390 | + if (strlen($buffer) > 5) { |
|
| 1391 | 1391 | $line = explode(',',$buffer); |
| 1392 | 1392 | $data = array(); |
| 1393 | 1393 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1404,38 +1404,38 @@ discard block |
||
| 1404 | 1404 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1405 | 1405 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1406 | 1406 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1407 | - } |
|
| 1408 | - } elseif ($format == 'acars') { |
|
| 1409 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1410 | - $ACARS->add(trim($buffer)); |
|
| 1411 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1412 | - $ACARS->deleteLiveAcarsData(); |
|
| 1407 | + } |
|
| 1408 | + } elseif ($format == 'acars') { |
|
| 1409 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1410 | + $ACARS->add(trim($buffer)); |
|
| 1411 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1412 | + $ACARS->deleteLiveAcarsData(); |
|
| 1413 | 1413 | } elseif ($format == 'flightgearmp') { |
| 1414 | - if (substr($buffer,0,1) != '#') { |
|
| 1414 | + if (substr($buffer,0,1) != '#') { |
|
| 1415 | 1415 | $data = array(); |
| 1416 | 1416 | //echo $buffer."\n"; |
| 1417 | 1417 | $line = explode(' ',$buffer); |
| 1418 | 1418 | if (count($line) == 11) { |
| 1419 | - $userserver = explode('@',$line[0]); |
|
| 1420 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1421 | - $data['ident'] = $userserver[0]; |
|
| 1422 | - $data['registration'] = $userserver[0]; |
|
| 1423 | - $data['latitude'] = $line[4]; |
|
| 1424 | - $data['longitude'] = $line[5]; |
|
| 1425 | - $data['altitude'] = $line[6]; |
|
| 1426 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1427 | - $aircraft_type = $line[10]; |
|
| 1428 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1429 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1430 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1431 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1419 | + $userserver = explode('@',$line[0]); |
|
| 1420 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1421 | + $data['ident'] = $userserver[0]; |
|
| 1422 | + $data['registration'] = $userserver[0]; |
|
| 1423 | + $data['latitude'] = $line[4]; |
|
| 1424 | + $data['longitude'] = $line[5]; |
|
| 1425 | + $data['altitude'] = $line[6]; |
|
| 1426 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1427 | + $aircraft_type = $line[10]; |
|
| 1428 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1429 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1430 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1431 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1432 | + } |
|
| 1432 | 1433 | } |
| 1433 | - } |
|
| 1434 | 1434 | } elseif ($format == 'beast') { |
| 1435 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1436 | - die; |
|
| 1435 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1436 | + die; |
|
| 1437 | 1437 | } elseif ($format == 'vrstcp') { |
| 1438 | - foreach($buffer as $all_data) { |
|
| 1438 | + foreach($buffer as $all_data) { |
|
| 1439 | 1439 | $line = json_decode('{'.$all_data.'}',true); |
| 1440 | 1440 | $data = array(); |
| 1441 | 1441 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1455,153 +1455,153 @@ discard block |
||
| 1455 | 1455 | */ |
| 1456 | 1456 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1457 | 1457 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
| 1458 | - $data['format_source'] = 'vrstcp'; |
|
| 1458 | + $data['format_source'] = 'vrstcp'; |
|
| 1459 | 1459 | $data['id_source'] = $id_source; |
| 1460 | 1460 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1461 | 1461 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1462 | 1462 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1463 | 1463 | unset($data); |
| 1464 | - } |
|
| 1464 | + } |
|
| 1465 | 1465 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 1466 | - $line = explode("\t", $buffer); |
|
| 1467 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1466 | + $line = explode("\t", $buffer); |
|
| 1467 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1468 | 1468 | $key = $line[$k]; |
| 1469 | - $lined[$key] = $line[$k+1]; |
|
| 1470 | - } |
|
| 1471 | - if (count($lined) > 3) { |
|
| 1472 | - $data['hex'] = $lined['hexid']; |
|
| 1473 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1474 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1475 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1476 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1477 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1478 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1479 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1480 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1481 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1482 | - $data['id_source'] = $id_source; |
|
| 1483 | - $data['format_source'] = 'tsv'; |
|
| 1484 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1485 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1469 | + $lined[$key] = $line[$k+1]; |
|
| 1470 | + } |
|
| 1471 | + if (count($lined) > 3) { |
|
| 1472 | + $data['hex'] = $lined['hexid']; |
|
| 1473 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1474 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1475 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1476 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1477 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1478 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1479 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1480 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1481 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1482 | + $data['id_source'] = $id_source; |
|
| 1483 | + $data['format_source'] = 'tsv'; |
|
| 1484 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1485 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1486 | 1486 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1487 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1488 | - unset($lined); |
|
| 1489 | - unset($data); |
|
| 1490 | - } else $error = true; |
|
| 1487 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1488 | + unset($lined); |
|
| 1489 | + unset($data); |
|
| 1490 | + } else $error = true; |
|
| 1491 | 1491 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1492 | - if ($aprs_connect == 0) { |
|
| 1492 | + if ($aprs_connect == 0) { |
|
| 1493 | 1493 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 1494 | 1494 | $aprs_connect = 1; |
| 1495 | - } |
|
| 1495 | + } |
|
| 1496 | 1496 | |
| 1497 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1497 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1498 | 1498 | $aprs_last_tx = time(); |
| 1499 | 1499 | $data_aprs = "# Keep alive"; |
| 1500 | 1500 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1501 | - } |
|
| 1501 | + } |
|
| 1502 | 1502 | |
| 1503 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1504 | - //echo 'APRS data : '.$buffer."\n"; |
|
| 1505 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1506 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1507 | - //echo $buffer."\n"; |
|
| 1508 | - date_default_timezone_set('UTC'); |
|
| 1509 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1503 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1504 | + //echo 'APRS data : '.$buffer."\n"; |
|
| 1505 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1506 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1507 | + //echo $buffer."\n"; |
|
| 1508 | + date_default_timezone_set('UTC'); |
|
| 1509 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1510 | 1510 | $line = $APRS->parse($buffer); |
| 1511 | 1511 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1512 | 1512 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
| 1513 | - $aprs_last_tx = time(); |
|
| 1514 | - $data = array(); |
|
| 1515 | - //print_r($line); |
|
| 1516 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1517 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1518 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1519 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1520 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1521 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1522 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1523 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1524 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1525 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1526 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1527 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1528 | - $data['latitude'] = $line['latitude']; |
|
| 1529 | - $data['longitude'] = $line['longitude']; |
|
| 1530 | - //$data['verticalrate'] = $line[16]; |
|
| 1531 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1532 | - //else $data['speed'] = 0; |
|
| 1533 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1534 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1535 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1536 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1513 | + $aprs_last_tx = time(); |
|
| 1514 | + $data = array(); |
|
| 1515 | + //print_r($line); |
|
| 1516 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1517 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1518 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1519 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1520 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1521 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1522 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1523 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1524 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1525 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1526 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1527 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1528 | + $data['latitude'] = $line['latitude']; |
|
| 1529 | + $data['longitude'] = $line['longitude']; |
|
| 1530 | + //$data['verticalrate'] = $line[16]; |
|
| 1531 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1532 | + //else $data['speed'] = 0; |
|
| 1533 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1534 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1535 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1536 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1537 | 1537 | |
| 1538 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1539 | - //else echo 'No heading...'."\n"; |
|
| 1540 | - //else $data['heading'] = 0; |
|
| 1541 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1542 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1543 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1544 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1545 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1546 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1547 | - $data['id_source'] = $id_source; |
|
| 1548 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1549 | - else $data['format_source'] = 'aprs'; |
|
| 1550 | - $data['source_name'] = $line['source']; |
|
| 1551 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1552 | - else $data['source_type'] = 'flarm'; |
|
| 1553 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1554 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 1555 | - $aprsdate = strtotime($data['datetime']); |
|
| 1556 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1557 | - // Accept data if time <= system time + 20s |
|
| 1558 | - //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'])))) { |
|
| 1559 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1538 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1539 | + //else echo 'No heading...'."\n"; |
|
| 1540 | + //else $data['heading'] = 0; |
|
| 1541 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1542 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1543 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1544 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1545 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1546 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1547 | + $data['id_source'] = $id_source; |
|
| 1548 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1549 | + else $data['format_source'] = 'aprs'; |
|
| 1550 | + $data['source_name'] = $line['source']; |
|
| 1551 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1552 | + else $data['source_type'] = 'flarm'; |
|
| 1553 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1554 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 1555 | + $aprsdate = strtotime($data['datetime']); |
|
| 1556 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1557 | + // Accept data if time <= system time + 20s |
|
| 1558 | + //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'])))) { |
|
| 1559 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1560 | 1560 | $send = $SI->add($data); |
| 1561 | - } elseif ($data['source_type'] == 'ais') { |
|
| 1561 | + } elseif ($data['source_type'] == 'ais') { |
|
| 1562 | 1562 | $data['type'] = ''; |
| 1563 | 1563 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
| 1564 | - } elseif (isset($line['stealth'])) { |
|
| 1564 | + } elseif (isset($line['stealth'])) { |
|
| 1565 | 1565 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1566 | 1566 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 1567 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1568 | - //$line['symbol'] == 'Balloon' || |
|
| 1569 | - $line['symbol'] == 'Glider' || |
|
| 1570 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1571 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1572 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1573 | - $send = $SI->add($data); |
|
| 1574 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1575 | - $line['symbol'] == 'Yacht (Sail)' || |
|
| 1576 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
| 1577 | - $send = $MI->add($data); |
|
| 1578 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1579 | - $line['symbol'] == 'Car' || |
|
| 1580 | - $line['symbol'] == 'Ambulance' || |
|
| 1581 | - $line['symbol'] == 'Van' || |
|
| 1582 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
| 1583 | - $line['symbol'] == 'Motorcycle' || |
|
| 1584 | - $line['symbol'] == 'Tractor' || |
|
| 1585 | - $line['symbol'] == 'Police' || |
|
| 1586 | - $line['symbol'] == 'Bike' || |
|
| 1587 | - $line['symbol'] == 'Jogger' || |
|
| 1588 | - $line['symbol'] == 'Horse' || |
|
| 1589 | - $line['symbol'] == 'Bus' || |
|
| 1590 | - $line['symbol'] == 'Jeep' || |
|
| 1591 | - $line['symbol'] == 'Recreational Vehicle' || |
|
| 1592 | - $line['symbol'] == 'Yacht (Sail)' || |
|
| 1593 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
| 1594 | - $line['symbol'] == 'Firetruck' || |
|
| 1595 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
| 1596 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
| 1597 | - $line['symbol'] == 'SUV' || |
|
| 1598 | - $line['symbol'] == 'Snowmobile' || |
|
| 1599 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
| 1600 | - //} 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') { |
|
| 1567 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1568 | + //$line['symbol'] == 'Balloon' || |
|
| 1569 | + $line['symbol'] == 'Glider' || |
|
| 1570 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1571 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1572 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1573 | + $send = $SI->add($data); |
|
| 1574 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1575 | + $line['symbol'] == 'Yacht (Sail)' || |
|
| 1576 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
| 1577 | + $send = $MI->add($data); |
|
| 1578 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1579 | + $line['symbol'] == 'Car' || |
|
| 1580 | + $line['symbol'] == 'Ambulance' || |
|
| 1581 | + $line['symbol'] == 'Van' || |
|
| 1582 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
| 1583 | + $line['symbol'] == 'Motorcycle' || |
|
| 1584 | + $line['symbol'] == 'Tractor' || |
|
| 1585 | + $line['symbol'] == 'Police' || |
|
| 1586 | + $line['symbol'] == 'Bike' || |
|
| 1587 | + $line['symbol'] == 'Jogger' || |
|
| 1588 | + $line['symbol'] == 'Horse' || |
|
| 1589 | + $line['symbol'] == 'Bus' || |
|
| 1590 | + $line['symbol'] == 'Jeep' || |
|
| 1591 | + $line['symbol'] == 'Recreational Vehicle' || |
|
| 1592 | + $line['symbol'] == 'Yacht (Sail)' || |
|
| 1593 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
| 1594 | + $line['symbol'] == 'Firetruck' || |
|
| 1595 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
| 1596 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
| 1597 | + $line['symbol'] == 'SUV' || |
|
| 1598 | + $line['symbol'] == 'Snowmobile' || |
|
| 1599 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
| 1600 | + //} 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') { |
|
| 1601 | 1601 | // } 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') { |
| 1602 | 1602 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1603 | 1603 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
| 1604 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1604 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1605 | 1605 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 1606 | 1606 | $Source->deleteOldLocationByType('gs'); |
| 1607 | 1607 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1609,7 +1609,7 @@ discard block |
||
| 1609 | 1609 | } else { |
| 1610 | 1610 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
| 1611 | 1611 | } |
| 1612 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1612 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1613 | 1613 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1614 | 1614 | if ($globalDebug) echo '# Weather Station added'."\n"; |
| 1615 | 1615 | $Source->deleteOldLocationByType('wx'); |
@@ -1619,7 +1619,7 @@ discard block |
||
| 1619 | 1619 | } else { |
| 1620 | 1620 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
| 1621 | 1621 | } |
| 1622 | - } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
|
| 1622 | + } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
|
| 1623 | 1623 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1624 | 1624 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1625 | 1625 | $Source->deleteOldLocationByType('lightning'); |
@@ -1628,11 +1628,11 @@ discard block |
||
| 1628 | 1628 | } else { |
| 1629 | 1629 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
| 1630 | 1630 | } |
| 1631 | - } elseif ($globalDebug) { |
|
| 1632 | - echo '/!\ Not added: '.$buffer."\n"; |
|
| 1633 | - print_r($line); |
|
| 1634 | - } |
|
| 1635 | - unset($data); |
|
| 1631 | + } elseif ($globalDebug) { |
|
| 1632 | + echo '/!\ Not added: '.$buffer."\n"; |
|
| 1633 | + print_r($line); |
|
| 1634 | + } |
|
| 1635 | + unset($data); |
|
| 1636 | 1636 | } |
| 1637 | 1637 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
| 1638 | 1638 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1651,12 +1651,12 @@ discard block |
||
| 1651 | 1651 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
| 1652 | 1652 | $globalSources[$nb]['last_weather_clean'] = time(); |
| 1653 | 1653 | } |
| 1654 | - } |
|
| 1654 | + } |
|
| 1655 | 1655 | } else { |
| 1656 | - $line = explode(',', $buffer); |
|
| 1657 | - if (count($line) > 20) { |
|
| 1658 | - $data['hex'] = $line[4]; |
|
| 1659 | - /* |
|
| 1656 | + $line = explode(',', $buffer); |
|
| 1657 | + if (count($line) > 20) { |
|
| 1658 | + $data['hex'] = $line[4]; |
|
| 1659 | + /* |
|
| 1660 | 1660 | $data['datetime'] = $line[6].' '.$line[7]; |
| 1661 | 1661 | date_default_timezone_set($globalTimezone); |
| 1662 | 1662 | $datetime = new DateTime($data['datetime']); |
@@ -1664,30 +1664,30 @@ discard block |
||
| 1664 | 1664 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1665 | 1665 | date_default_timezone_set('UTC'); |
| 1666 | 1666 | */ |
| 1667 | - // Force datetime to current UTC datetime |
|
| 1668 | - date_default_timezone_set('UTC'); |
|
| 1669 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1670 | - $data['ident'] = trim($line[10]); |
|
| 1671 | - $data['latitude'] = $line[14]; |
|
| 1672 | - $data['longitude'] = $line[15]; |
|
| 1673 | - $data['verticalrate'] = $line[16]; |
|
| 1674 | - $data['emergency'] = $line[20]; |
|
| 1675 | - $data['speed'] = $line[12]; |
|
| 1676 | - $data['squawk'] = $line[17]; |
|
| 1677 | - $data['altitude'] = $line[11]; |
|
| 1678 | - $data['heading'] = $line[13]; |
|
| 1679 | - $data['ground'] = $line[21]; |
|
| 1680 | - $data['emergency'] = $line[19]; |
|
| 1681 | - $data['format_source'] = 'sbs'; |
|
| 1667 | + // Force datetime to current UTC datetime |
|
| 1668 | + date_default_timezone_set('UTC'); |
|
| 1669 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1670 | + $data['ident'] = trim($line[10]); |
|
| 1671 | + $data['latitude'] = $line[14]; |
|
| 1672 | + $data['longitude'] = $line[15]; |
|
| 1673 | + $data['verticalrate'] = $line[16]; |
|
| 1674 | + $data['emergency'] = $line[20]; |
|
| 1675 | + $data['speed'] = $line[12]; |
|
| 1676 | + $data['squawk'] = $line[17]; |
|
| 1677 | + $data['altitude'] = $line[11]; |
|
| 1678 | + $data['heading'] = $line[13]; |
|
| 1679 | + $data['ground'] = $line[21]; |
|
| 1680 | + $data['emergency'] = $line[19]; |
|
| 1681 | + $data['format_source'] = 'sbs'; |
|
| 1682 | 1682 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1683 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1683 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1684 | 1684 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1685 | - $data['id_source'] = $id_source; |
|
| 1686 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1687 | - else $error = true; |
|
| 1688 | - unset($data); |
|
| 1689 | - } else $error = true; |
|
| 1690 | - if ($error) { |
|
| 1685 | + $data['id_source'] = $id_source; |
|
| 1686 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1687 | + else $error = true; |
|
| 1688 | + unset($data); |
|
| 1689 | + } else $error = true; |
|
| 1690 | + if ($error) { |
|
| 1691 | 1691 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1692 | 1692 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1693 | 1693 | } else { |
@@ -1703,13 +1703,13 @@ discard block |
||
| 1703 | 1703 | connect_all($sourceer); |
| 1704 | 1704 | $sourceer = array(); |
| 1705 | 1705 | } |
| 1706 | - } |
|
| 1706 | + } |
|
| 1707 | 1707 | } |
| 1708 | 1708 | // Sleep for xxx microseconds |
| 1709 | 1709 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1710 | - } else { |
|
| 1710 | + } else { |
|
| 1711 | 1711 | if ($format == 'flightgearmp') { |
| 1712 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1712 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1713 | 1713 | //@socket_close($r); |
| 1714 | 1714 | sleep($globalMinFetch); |
| 1715 | 1715 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1718,9 +1718,9 @@ discard block |
||
| 1718 | 1718 | break; |
| 1719 | 1719 | |
| 1720 | 1720 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1721 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1722 | - else $tt[$format] = 0; |
|
| 1723 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 1721 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1722 | + else $tt[$format] = 0; |
|
| 1723 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 1724 | 1724 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1725 | 1725 | //@socket_close($r); |
| 1726 | 1726 | sleep(2); |
@@ -1731,24 +1731,24 @@ discard block |
||
| 1731 | 1731 | //connect_all($globalSources); |
| 1732 | 1732 | $tt[$format]=0; |
| 1733 | 1733 | break; |
| 1734 | - } |
|
| 1735 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 1734 | + } |
|
| 1735 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 1736 | + } |
|
| 1736 | 1737 | } |
| 1737 | - } |
|
| 1738 | 1738 | } |
| 1739 | - } else { |
|
| 1739 | + } else { |
|
| 1740 | 1740 | $error = socket_strerror(socket_last_error()); |
| 1741 | 1741 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1742 | 1742 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1743 | 1743 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1744 | 1744 | // Restart the script if possible |
| 1745 | 1745 | if (is_array($sockets)) { |
| 1746 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1746 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1747 | 1747 | |
| 1748 | - foreach ($sockets as $sock) { |
|
| 1748 | + foreach ($sockets as $sock) { |
|
| 1749 | 1749 | @socket_shutdown($sock,2); |
| 1750 | 1750 | @socket_close($sock); |
| 1751 | - } |
|
| 1751 | + } |
|
| 1752 | 1752 | |
| 1753 | 1753 | } |
| 1754 | 1754 | if ($globalDebug) echo "Waiting..."; |
@@ -1763,15 +1763,15 @@ discard block |
||
| 1763 | 1763 | if ($globalDebug) echo "Restart all connections..."; |
| 1764 | 1764 | connect_all($globalSources); |
| 1765 | 1765 | } |
| 1766 | - } |
|
| 1766 | + } |
|
| 1767 | 1767 | } |
| 1768 | 1768 | if ($globalDaemon === false) { |
| 1769 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1770 | - if (isset($SI)) $SI->checkAll(); |
|
| 1771 | - if (isset($TI)) $TI->checkAll(); |
|
| 1772 | - if (isset($MI)) $MI->checkAll(); |
|
| 1769 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1770 | + if (isset($SI)) $SI->checkAll(); |
|
| 1771 | + if (isset($TI)) $TI->checkAll(); |
|
| 1772 | + if (isset($MI)) $MI->checkAll(); |
|
| 1773 | + } |
|
| 1773 | 1774 | } |
| 1774 | - } |
|
| 1775 | 1775 | } |
| 1776 | 1776 | |
| 1777 | 1777 | ?> |