@@ -15,65 +15,65 @@ discard block |
||
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | 17 | if (isset($globalTracker) && $globalTracker) { |
| 18 | - require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 19 | 19 | } |
| 20 | 20 | if (isset($globalMarine) && $globalMarine) { |
| 21 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 22 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 21 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 22 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if (!isset($globalDebug)) $globalDebug = FALSE; |
| 26 | 26 | |
| 27 | 27 | if ($globalInstalled === FALSE) { |
| 28 | - echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
|
| 29 | - sleep(5); |
|
| 30 | - die(); |
|
| 28 | + echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
|
| 29 | + sleep(5); |
|
| 30 | + die(); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | // Check if schema is at latest version |
| 35 | 35 | $Connection = new Connection(); |
| 36 | 36 | if ($Connection->connectionExists() === false) { |
| 37 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 38 | - exit(); |
|
| 37 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 38 | + exit(); |
|
| 39 | 39 | } |
| 40 | 40 | if ($Connection->latest() === false) { |
| 41 | - echo "You MUST update to latest schema. Use your web browser to run install/index.php"; |
|
| 42 | - exit(); |
|
| 41 | + echo "You MUST update to latest schema. Use your web browser to run install/index.php"; |
|
| 42 | + exit(); |
|
| 43 | 43 | } |
| 44 | 44 | if (PHP_SAPI != 'cli') { |
| 45 | - echo "This script MUST be called from console, not a web browser."; |
|
| 45 | + echo "This script MUST be called from console, not a web browser."; |
|
| 46 | 46 | // exit(); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // This is to be compatible with old version of settings.php |
| 50 | 50 | if (!isset($globalSources)) { |
| 51 | - if (isset($globalSBS1Hosts)) { |
|
| 52 | - //$hosts = $globalSBS1Hosts; |
|
| 53 | - foreach ($globalSBS1Hosts as $host) { |
|
| 54 | - $globalSources[] = array('host' => $host); |
|
| 55 | - } |
|
| 56 | - } else { |
|
| 57 | - if (!isset($globalSBS1Host)) { |
|
| 58 | - echo '$globalSources MUST be defined !'; |
|
| 59 | - die; |
|
| 51 | + if (isset($globalSBS1Hosts)) { |
|
| 52 | + //$hosts = $globalSBS1Hosts; |
|
| 53 | + foreach ($globalSBS1Hosts as $host) { |
|
| 54 | + $globalSources[] = array('host' => $host); |
|
| 55 | + } |
|
| 56 | + } else { |
|
| 57 | + if (!isset($globalSBS1Host)) { |
|
| 58 | + echo '$globalSources MUST be defined !'; |
|
| 59 | + die; |
|
| 60 | 60 | } |
| 61 | 61 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 62 | 62 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
| 67 | 67 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 68 | 68 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 69 | 69 | if (isset($options['s'])) { |
| 70 | - $globalSources = array(); |
|
| 71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 72 | - else $globalSources[] = array('host' => $options['s']); |
|
| 70 | + $globalSources = array(); |
|
| 71 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 72 | + else $globalSources[] = array('host' => $options['s']); |
|
| 73 | 73 | } elseif (isset($options['source'])) { |
| 74 | - $globalSources = array(); |
|
| 75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 76 | - else $globalSources[] = array('host' => $options['source']); |
|
| 74 | + $globalSources = array(); |
|
| 75 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 76 | + else $globalSources[] = array('host' => $options['source']); |
|
| 77 | 77 | } |
| 78 | 78 | if (isset($options['aprsserverhost'])) { |
| 79 | 79 | $globalServerAPRS = TRUE; |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 113 | 113 | else $id_source = 1; |
| 114 | 114 | if (isset($globalServer) && $globalServer) { |
| 115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 116 | - $SI=new SpotterServer(); |
|
| 115 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 116 | + $SI=new SpotterServer(); |
|
| 117 | 117 | /* |
| 118 | 118 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 119 | 119 | $SI = new adsb2aprs(); |
@@ -123,14 +123,14 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 125 | 125 | if (isset($globalMarine) && $globalMarine) { |
| 126 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 127 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 126 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 127 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 131 | 131 | if (isset($globalMarine) && $globalMarine) { |
| 132 | - $AIS = new AIS(); |
|
| 133 | - $MI = new MarineImport($Connection->db); |
|
| 132 | + $AIS = new AIS(); |
|
| 133 | + $MI = new MarineImport($Connection->db); |
|
| 134 | 134 | } |
| 135 | 135 | //$APRS=new APRS($Connection->db); |
| 136 | 136 | $SBS=new SBS(); |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | //$servertz = system('date +%Z'); |
| 144 | 144 | // signal handler - playing nice with sockets and dump1090 |
| 145 | 145 | if (function_exists('pcntl_fork')) { |
| 146 | - pcntl_signal(SIGINT, function() { |
|
| 147 | - global $sockets; |
|
| 148 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 149 | - die("Bye!\n"); |
|
| 150 | - }); |
|
| 151 | - pcntl_signal_dispatch(); |
|
| 146 | + pcntl_signal(SIGINT, function() { |
|
| 147 | + global $sockets; |
|
| 148 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 149 | + die("Bye!\n"); |
|
| 150 | + }); |
|
| 151 | + pcntl_signal_dispatch(); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // let's try and connect |
@@ -158,47 +158,47 @@ discard block |
||
| 158 | 158 | $reset = 0; |
| 159 | 159 | |
| 160 | 160 | function connect_all($hosts) { |
| 161 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 162 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 163 | - $reset++; |
|
| 164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 165 | - foreach ($hosts as $id => $value) { |
|
| 161 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 162 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 163 | + $reset++; |
|
| 164 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 165 | + foreach ($hosts as $id => $value) { |
|
| 166 | 166 | $host = $value['host']; |
| 167 | 167 | $udp = false; |
| 168 | 168 | $globalSources[$id]['last_exec'] = 0; |
| 169 | 169 | // Here we check type of source(s) |
| 170 | 170 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 171 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 172 | - //$formats[$id] = 'deltadbtxt'; |
|
| 173 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 174 | - //$last_exec['deltadbtxt'] = 0; |
|
| 175 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 176 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 177 | - //$formats[$id] = 'vatsimtxt'; |
|
| 178 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 179 | - //$last_exec['vatsimtxt'] = 0; |
|
| 180 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 181 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 182 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 183 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 184 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 185 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 186 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
| 187 | - //$formats[$id] = 'aircraftjson'; |
|
| 188 | - $globalSources[$id]['format'] = 'aircraftjson'; |
|
| 189 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 190 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 191 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
| 192 | - //$formats[$id] = 'planefinderclient'; |
|
| 193 | - $globalSources[$id]['format'] = 'planefinderclient'; |
|
| 194 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 195 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 196 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 197 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 198 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 199 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 200 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 201 | - /* |
|
| 171 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 172 | + //$formats[$id] = 'deltadbtxt'; |
|
| 173 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 174 | + //$last_exec['deltadbtxt'] = 0; |
|
| 175 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 176 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 177 | + //$formats[$id] = 'vatsimtxt'; |
|
| 178 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 179 | + //$last_exec['vatsimtxt'] = 0; |
|
| 180 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 181 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 182 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 183 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 184 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 185 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 186 | + } else if (preg_match('/aircraft.json$/i',$host)) { |
|
| 187 | + //$formats[$id] = 'aircraftjson'; |
|
| 188 | + $globalSources[$id]['format'] = 'aircraftjson'; |
|
| 189 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 190 | + if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 191 | + } else if (preg_match('/aircraft$/i',$host)) { |
|
| 192 | + //$formats[$id] = 'planefinderclient'; |
|
| 193 | + $globalSources[$id]['format'] = 'planefinderclient'; |
|
| 194 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 195 | + if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 196 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 197 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 198 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 199 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 200 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 201 | + /* |
|
| 202 | 202 | // Disabled for now, site change source format |
| 203 | 203 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
| 204 | 204 | //$formats[$id] = 'radarvirtueljson'; |
@@ -210,131 +210,131 @@ discard block |
||
| 210 | 210 | exit(0); |
| 211 | 211 | } |
| 212 | 212 | */ |
| 213 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 214 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 215 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 216 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 217 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 218 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 219 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 220 | - exit(0); |
|
| 221 | - } |
|
| 222 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 223 | - //$formats[$id] = 'phpvmacars'; |
|
| 224 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 225 | - //$last_exec['phpvmacars'] = 0; |
|
| 226 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 227 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
| 228 | - //$formats[$id] = 'phpvmacars'; |
|
| 229 | - $globalSources[$id]['format'] = 'vaos'; |
|
| 230 | - //$last_exec['phpvmacars'] = 0; |
|
| 231 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 232 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 233 | - //$formats[$id] = 'phpvmacars'; |
|
| 234 | - $globalSources[$id]['format'] = 'vam'; |
|
| 235 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 236 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 237 | - //$formats[$id] = 'whazzup'; |
|
| 238 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 239 | - //$last_exec['whazzup'] = 0; |
|
| 240 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 241 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
| 242 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
| 243 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 244 | - } else if (preg_match('/airwhere/i',$host)) { |
|
| 245 | - $globalSources[$id]['format'] = 'airwhere'; |
|
| 246 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 247 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 248 | - //$formats[$id] = 'pirepsjson'; |
|
| 249 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 250 | - //$last_exec['pirepsjson'] = 0; |
|
| 251 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 252 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 253 | - //$formats[$id] = 'fr24json'; |
|
| 254 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 255 | - //$last_exec['fr24json'] = 0; |
|
| 256 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 257 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 258 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 259 | - exit(0); |
|
| 260 | - } |
|
| 261 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 262 | - //$formats[$id] = 'fr24json'; |
|
| 263 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 264 | - //$last_exec['fr24json'] = 0; |
|
| 265 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 266 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 267 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 268 | - exit(0); |
|
| 269 | - } |
|
| 270 | - //} else if (preg_match('/10001/',$host)) { |
|
| 271 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 272 | - //$formats[$id] = 'tsv'; |
|
| 273 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 274 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 275 | - } |
|
| 276 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
| 277 | - if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
|
| 278 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 279 | - if ($idf !== false) { |
|
| 280 | - $httpfeeds[$id] = $idf; |
|
| 281 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 282 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 283 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 284 | - elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
| 285 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 286 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 287 | - $hostport = explode(':',$host); |
|
| 288 | - if (isset($hostport[1])) { |
|
| 213 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 214 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 215 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 216 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 217 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 218 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 219 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 220 | + exit(0); |
|
| 221 | + } |
|
| 222 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 223 | + //$formats[$id] = 'phpvmacars'; |
|
| 224 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 225 | + //$last_exec['phpvmacars'] = 0; |
|
| 226 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 227 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
| 228 | + //$formats[$id] = 'phpvmacars'; |
|
| 229 | + $globalSources[$id]['format'] = 'vaos'; |
|
| 230 | + //$last_exec['phpvmacars'] = 0; |
|
| 231 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 232 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 233 | + //$formats[$id] = 'phpvmacars'; |
|
| 234 | + $globalSources[$id]['format'] = 'vam'; |
|
| 235 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 236 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 237 | + //$formats[$id] = 'whazzup'; |
|
| 238 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 239 | + //$last_exec['whazzup'] = 0; |
|
| 240 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 241 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
| 242 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
| 243 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 244 | + } else if (preg_match('/airwhere/i',$host)) { |
|
| 245 | + $globalSources[$id]['format'] = 'airwhere'; |
|
| 246 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 247 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 248 | + //$formats[$id] = 'pirepsjson'; |
|
| 249 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 250 | + //$last_exec['pirepsjson'] = 0; |
|
| 251 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 252 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 253 | + //$formats[$id] = 'fr24json'; |
|
| 254 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 255 | + //$last_exec['fr24json'] = 0; |
|
| 256 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 257 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 258 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 259 | + exit(0); |
|
| 260 | + } |
|
| 261 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 262 | + //$formats[$id] = 'fr24json'; |
|
| 263 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 264 | + //$last_exec['fr24json'] = 0; |
|
| 265 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 266 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 267 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 268 | + exit(0); |
|
| 269 | + } |
|
| 270 | + //} else if (preg_match('/10001/',$host)) { |
|
| 271 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 272 | + //$formats[$id] = 'tsv'; |
|
| 273 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 274 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 275 | + } |
|
| 276 | + } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
| 277 | + if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
|
| 278 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 279 | + if ($idf !== false) { |
|
| 280 | + $httpfeeds[$id] = $idf; |
|
| 281 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 282 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 283 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 284 | + elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
| 285 | + elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 286 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 287 | + $hostport = explode(':',$host); |
|
| 288 | + if (isset($hostport[1])) { |
|
| 289 | 289 | $port = $hostport[1]; |
| 290 | 290 | $hostn = $hostport[0]; |
| 291 | - } else { |
|
| 291 | + } else { |
|
| 292 | 292 | $port = $globalSources[$id]['port']; |
| 293 | 293 | $hostn = $globalSources[$id]['host']; |
| 294 | - } |
|
| 295 | - $Common = new Common(); |
|
| 296 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 297 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 298 | - } else { |
|
| 299 | - $udp = true; |
|
| 300 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 301 | - } |
|
| 302 | - if ($s) { |
|
| 303 | - $sockets[$id] = $s; |
|
| 304 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 305 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 294 | + } |
|
| 295 | + $Common = new Common(); |
|
| 296 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 297 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 298 | + } else { |
|
| 299 | + $udp = true; |
|
| 300 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 301 | + } |
|
| 302 | + if ($s) { |
|
| 303 | + $sockets[$id] = $s; |
|
| 304 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 305 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 306 | 306 | //$formats[$id] = 'aprs'; |
| 307 | 307 | $globalSources[$id]['format'] = 'aprs'; |
| 308 | 308 | //$aprs_connect = 0; |
| 309 | 309 | //$use_aprs = true; |
| 310 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 310 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 311 | 311 | $globalSources[$id]['format'] = 'vrstcp'; |
| 312 | - } elseif ($port == '10001') { |
|
| 313 | - //$formats[$id] = 'tsv'; |
|
| 314 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 315 | - } elseif ($port == '30002') { |
|
| 316 | - //$formats[$id] = 'raw'; |
|
| 317 | - $globalSources[$id]['format'] = 'raw'; |
|
| 318 | - } elseif ($port == '5001') { |
|
| 319 | - //$formats[$id] = 'raw'; |
|
| 320 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 321 | - } elseif ($port == '30005') { |
|
| 312 | + } elseif ($port == '10001') { |
|
| 313 | + //$formats[$id] = 'tsv'; |
|
| 314 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 315 | + } elseif ($port == '30002') { |
|
| 316 | + //$formats[$id] = 'raw'; |
|
| 317 | + $globalSources[$id]['format'] = 'raw'; |
|
| 318 | + } elseif ($port == '5001') { |
|
| 319 | + //$formats[$id] = 'raw'; |
|
| 320 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 321 | + } elseif ($port == '30005') { |
|
| 322 | 322 | // Not yet supported |
| 323 | - //$formats[$id] = 'beast'; |
|
| 324 | - $globalSources[$id]['format'] = 'beast'; |
|
| 325 | - //} else $formats[$id] = 'sbs'; |
|
| 326 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 327 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 323 | + //$formats[$id] = 'beast'; |
|
| 324 | + $globalSources[$id]['format'] = 'beast'; |
|
| 325 | + //} else $formats[$id] = 'sbs'; |
|
| 326 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 327 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 328 | 328 | } |
| 329 | 329 | if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 330 | 330 | elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 331 | - } else { |
|
| 331 | + } else { |
|
| 332 | 332 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 333 | 333 | sleep(10); |
| 334 | 334 | connect_all($hosts); |
| 335 | - } |
|
| 336 | - } |
|
| 337 | - } |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | 338 | } |
| 339 | 339 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 340 | 340 | |
@@ -357,9 +357,9 @@ discard block |
||
| 357 | 357 | //connect_all($globalSources); |
| 358 | 358 | |
| 359 | 359 | if (isset($globalProxy) && $globalProxy) { |
| 360 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 360 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 361 | 361 | } else { |
| 362 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 362 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // APRS Configuration |
@@ -368,21 +368,21 @@ discard block |
||
| 368 | 368 | die; |
| 369 | 369 | } |
| 370 | 370 | foreach ($globalSources as $key => $source) { |
| 371 | - if (!isset($source['format'])) { |
|
| 372 | - $globalSources[$key]['format'] = 'auto'; |
|
| 373 | - } |
|
| 374 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 375 | - unset($globalSources[$key]); |
|
| 376 | - } |
|
| 371 | + if (!isset($source['format'])) { |
|
| 372 | + $globalSources[$key]['format'] = 'auto'; |
|
| 373 | + } |
|
| 374 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 375 | + unset($globalSources[$key]); |
|
| 376 | + } |
|
| 377 | 377 | } |
| 378 | 378 | connect_all($globalSources); |
| 379 | 379 | foreach ($globalSources as $key => $source) { |
| 380 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 380 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 381 | 381 | $aprs_connect = 0; |
| 382 | 382 | $use_aprs = true; |
| 383 | 383 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 384 | 384 | break; |
| 385 | - } |
|
| 385 | + } |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | if ($use_aprs) { |
@@ -423,173 +423,173 @@ discard block |
||
| 423 | 423 | |
| 424 | 424 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 425 | 425 | while ($i > 0) { |
| 426 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 426 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 427 | 427 | |
| 428 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 429 | - // Delete old ATC |
|
| 430 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 428 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 429 | + // Delete old ATC |
|
| 430 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 431 | 431 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 432 | - $ATC->deleteOldATC(); |
|
| 433 | - } |
|
| 432 | + $ATC->deleteOldATC(); |
|
| 433 | + } |
|
| 434 | 434 | |
| 435 | - if (count($last_exec) == count($globalSources)) { |
|
| 435 | + if (count($last_exec) == count($globalSources)) { |
|
| 436 | 436 | $max = $globalMinFetch; |
| 437 | 437 | foreach ($last_exec as $last) { |
| 438 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 438 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 439 | 439 | } |
| 440 | 440 | if ($max < $globalMinFetch) { |
| 441 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 442 | - sleep($globalMinFetch-$max+2); |
|
| 441 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 442 | + sleep($globalMinFetch-$max+2); |
|
| 443 | + } |
|
| 443 | 444 | } |
| 444 | - } |
|
| 445 | 445 | |
| 446 | 446 | |
| 447 | - //foreach ($formats as $id => $value) { |
|
| 448 | - foreach ($globalSources as $id => $value) { |
|
| 447 | + //foreach ($formats as $id => $value) { |
|
| 448 | + foreach ($globalSources as $id => $value) { |
|
| 449 | 449 | date_default_timezone_set('UTC'); |
| 450 | 450 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 451 | 451 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 452 | 452 | if ($value['format'] === 'deltadbtxt' && |
| 453 | - ( |
|
| 453 | + ( |
|
| 454 | 454 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 455 | 455 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 456 | - ) |
|
| 456 | + ) |
|
| 457 | 457 | ) { |
| 458 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 459 | - $buffer = $Common->getData($value['host']); |
|
| 460 | - if ($buffer != '') $reset = 0; |
|
| 461 | - $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 462 | - $buffer = explode('\n', $buffer); |
|
| 463 | - foreach ($buffer as $line) { |
|
| 464 | - if ($line != '' && count($line) > 7) { |
|
| 465 | - $line = explode(',', $line); |
|
| 466 | - $data = array(); |
|
| 467 | - $data['hex'] = $line[1]; // hex |
|
| 468 | - $data['ident'] = $line[2]; // ident |
|
| 469 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 470 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 471 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 472 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 473 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 474 | - $data['verticalrate'] = ''; // vertical rate |
|
| 475 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 476 | - $data['emergency'] = ''; // emergency |
|
| 477 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 478 | - $data['format_source'] = 'deltadbtxt'; |
|
| 479 | - $data['id_source'] = $id_source; |
|
| 480 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 481 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 482 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 483 | - $SI->add($data); |
|
| 484 | - unset($data); |
|
| 485 | - } |
|
| 486 | - } |
|
| 487 | - $last_exec[$id]['last'] = time(); |
|
| 488 | - } elseif ($value['format'] === 'radarcapejson' && |
|
| 489 | - ( |
|
| 490 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 491 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 492 | - ) |
|
| 493 | - ) { |
|
| 494 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 495 | - $buffer = $Common->getData($value['host']); |
|
| 496 | - if ($buffer != '') { |
|
| 497 | - $all_data = json_decode($buffer,true); |
|
| 498 | - foreach ($all_data as $line) { |
|
| 499 | - $data = array(); |
|
| 500 | - $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
| 501 | - $data['hex'] = $line['hex']; // hex |
|
| 502 | - $data['ident'] = $line['fli']; // ident |
|
| 503 | - $data['altitude'] = $line['alt']; // altitude |
|
| 504 | - $data['speed'] = $line['spd']; // speed |
|
| 505 | - $data['heading'] = $line['trk']; // heading |
|
| 506 | - $data['latitude'] = $line['lat']; // lat |
|
| 507 | - $data['longitude'] = $line['lon']; // long |
|
| 508 | - $data['verticalrate'] = $line['vrt']; // vertical rate |
|
| 509 | - $data['squawk'] = $line['squ']; // squawk |
|
| 510 | - $data['ground'] = $line['gda']; // ground |
|
| 511 | - $data['registration'] = $line['reg']; |
|
| 512 | - //$data['emergency'] = ''; // emergency |
|
| 513 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 514 | - $data['format_source'] = 'radarcapejson'; |
|
| 515 | - $data['id_source'] = $id_source; |
|
| 516 | - if (isset($value['name']) && $value['name'] != '') { |
|
| 517 | - if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
| 518 | - else $data['source_name'] = $value['name']; |
|
| 519 | - } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
| 520 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 521 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 458 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 459 | + $buffer = $Common->getData($value['host']); |
|
| 460 | + if ($buffer != '') $reset = 0; |
|
| 461 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 462 | + $buffer = explode('\n', $buffer); |
|
| 463 | + foreach ($buffer as $line) { |
|
| 464 | + if ($line != '' && count($line) > 7) { |
|
| 465 | + $line = explode(',', $line); |
|
| 466 | + $data = array(); |
|
| 467 | + $data['hex'] = $line[1]; // hex |
|
| 468 | + $data['ident'] = $line[2]; // ident |
|
| 469 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 470 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 471 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 472 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 473 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 474 | + $data['verticalrate'] = ''; // vertical rate |
|
| 475 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 476 | + $data['emergency'] = ''; // emergency |
|
| 477 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 478 | + $data['format_source'] = 'deltadbtxt'; |
|
| 479 | + $data['id_source'] = $id_source; |
|
| 480 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 481 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 482 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 483 | + $SI->add($data); |
|
| 484 | + unset($data); |
|
| 485 | + } |
|
| 486 | + } |
|
| 487 | + $last_exec[$id]['last'] = time(); |
|
| 488 | + } elseif ($value['format'] === 'radarcapejson' && |
|
| 489 | + ( |
|
| 490 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 491 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 492 | + ) |
|
| 493 | + ) { |
|
| 494 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 495 | + $buffer = $Common->getData($value['host']); |
|
| 496 | + if ($buffer != '') { |
|
| 497 | + $all_data = json_decode($buffer,true); |
|
| 498 | + foreach ($all_data as $line) { |
|
| 499 | + $data = array(); |
|
| 500 | + $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
| 501 | + $data['hex'] = $line['hex']; // hex |
|
| 502 | + $data['ident'] = $line['fli']; // ident |
|
| 503 | + $data['altitude'] = $line['alt']; // altitude |
|
| 504 | + $data['speed'] = $line['spd']; // speed |
|
| 505 | + $data['heading'] = $line['trk']; // heading |
|
| 506 | + $data['latitude'] = $line['lat']; // lat |
|
| 507 | + $data['longitude'] = $line['lon']; // long |
|
| 508 | + $data['verticalrate'] = $line['vrt']; // vertical rate |
|
| 509 | + $data['squawk'] = $line['squ']; // squawk |
|
| 510 | + $data['ground'] = $line['gda']; // ground |
|
| 511 | + $data['registration'] = $line['reg']; |
|
| 512 | + //$data['emergency'] = ''; // emergency |
|
| 513 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 514 | + $data['format_source'] = 'radarcapejson'; |
|
| 515 | + $data['id_source'] = $id_source; |
|
| 516 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 517 | + if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
| 518 | + else $data['source_name'] = $value['name']; |
|
| 519 | + } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
| 520 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 521 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 522 | 522 | |
| 523 | - $SI->add($data); |
|
| 524 | - unset($data); |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - $last_exec[$id]['last'] = time(); |
|
| 523 | + $SI->add($data); |
|
| 524 | + unset($data); |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + $last_exec[$id]['last'] = time(); |
|
| 528 | 528 | } elseif ($value['format'] === 'aisnmeatxt' && |
| 529 | - ( |
|
| 529 | + ( |
|
| 530 | 530 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 531 | 531 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 532 | - ) |
|
| 532 | + ) |
|
| 533 | 533 | ) { |
| 534 | - date_default_timezone_set('CET'); |
|
| 535 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 536 | - date_default_timezone_set('UTC'); |
|
| 537 | - if ($buffer != '') $reset = 0; |
|
| 538 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 539 | - $buffer = explode('\n',$buffer); |
|
| 540 | - foreach ($buffer as $line) { |
|
| 534 | + date_default_timezone_set('CET'); |
|
| 535 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 536 | + date_default_timezone_set('UTC'); |
|
| 537 | + if ($buffer != '') $reset = 0; |
|
| 538 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 539 | + $buffer = explode('\n',$buffer); |
|
| 540 | + foreach ($buffer as $line) { |
|
| 541 | 541 | if ($line != '') { |
| 542 | - //echo "'".$line."'\n"; |
|
| 543 | - $add = false; |
|
| 544 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 545 | - $data = array(); |
|
| 546 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 547 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 548 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 549 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 550 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 551 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 552 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 553 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 554 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 555 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 556 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 557 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 558 | - if (isset($ais_data['timestamp'])) { |
|
| 542 | + //echo "'".$line."'\n"; |
|
| 543 | + $add = false; |
|
| 544 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 545 | + $data = array(); |
|
| 546 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 547 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 548 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 549 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 550 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 551 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 552 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 553 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 554 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 555 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 556 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 557 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 558 | + if (isset($ais_data['timestamp'])) { |
|
| 559 | 559 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 560 | 560 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 561 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 562 | - $add = true; |
|
| 561 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 562 | + $add = true; |
|
| 563 | 563 | } |
| 564 | - } else { |
|
| 564 | + } else { |
|
| 565 | 565 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 566 | 566 | $add = true; |
| 567 | - } |
|
| 568 | - $data['format_source'] = 'aisnmeatxt'; |
|
| 569 | - $data['id_source'] = $id_source; |
|
| 570 | - //print_r($data); |
|
| 571 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 572 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 573 | - unset($data); |
|
| 567 | + } |
|
| 568 | + $data['format_source'] = 'aisnmeatxt'; |
|
| 569 | + $data['id_source'] = $id_source; |
|
| 570 | + //print_r($data); |
|
| 571 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 572 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 573 | + unset($data); |
|
| 574 | 574 | } |
| 575 | - } |
|
| 576 | - $last_exec[$id]['last'] = time(); |
|
| 575 | + } |
|
| 576 | + $last_exec[$id]['last'] = time(); |
|
| 577 | 577 | } elseif ($value['format'] === 'aisnmeahttp') { |
| 578 | - $arr = $httpfeeds; |
|
| 579 | - $w = $e = null; |
|
| 578 | + $arr = $httpfeeds; |
|
| 579 | + $w = $e = null; |
|
| 580 | 580 | |
| 581 | - if (isset($arr[$id])) { |
|
| 581 | + if (isset($arr[$id])) { |
|
| 582 | 582 | $nn = stream_select($arr,$w,$e,$timeout); |
| 583 | 583 | if ($nn > 0) { |
| 584 | - foreach ($httpfeeds as $feed) { |
|
| 584 | + foreach ($httpfeeds as $feed) { |
|
| 585 | 585 | $buffer = stream_get_line($feed,2000,"\n"); |
| 586 | 586 | if ($buffer === FALSE) { |
| 587 | - connect_all($globalSources); |
|
| 587 | + connect_all($globalSources); |
|
| 588 | 588 | } |
| 589 | 589 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 590 | 590 | $buffer = explode('\n',$buffer); |
| 591 | 591 | foreach ($buffer as $line) { |
| 592 | - if ($line != '') { |
|
| 592 | + if ($line != '') { |
|
| 593 | 593 | $ais_data = $AIS->parse_line(trim($line)); |
| 594 | 594 | $data = array(); |
| 595 | 595 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -607,117 +607,117 @@ discard block |
||
| 607 | 607 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 608 | 608 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
| 609 | 609 | if (isset($ais_data['timestamp'])) { |
| 610 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 610 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 611 | 611 | } else { |
| 612 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 612 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 613 | 613 | } |
| 614 | 614 | $data['format_source'] = 'aisnmeahttp'; |
| 615 | 615 | $data['id_source'] = $id_source; |
| 616 | 616 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 617 | 617 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
| 618 | 618 | unset($data); |
| 619 | - } |
|
| 619 | + } |
|
| 620 | + } |
|
| 620 | 621 | } |
| 621 | - } |
|
| 622 | 622 | } else { |
| 623 | - $format = $value['format']; |
|
| 624 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 625 | - else $tt[$format] = 0; |
|
| 626 | - if ($tt[$format] > 30) { |
|
| 623 | + $format = $value['format']; |
|
| 624 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 625 | + else $tt[$format] = 0; |
|
| 626 | + if ($tt[$format] > 30) { |
|
| 627 | 627 | if ($globalDebug) echo 'Reconnect...'."\n"; |
| 628 | 628 | sleep(2); |
| 629 | 629 | //$sourceeen[] = $value; |
| 630 | 630 | //connect_all($sourceeen); |
| 631 | 631 | //$sourceeen = array(); |
| 632 | 632 | connect_all($globalSources); |
| 633 | - } |
|
| 633 | + } |
|
| 634 | + } |
|
| 634 | 635 | } |
| 635 | - } |
|
| 636 | 636 | } elseif ($value['format'] === 'myshiptracking' && |
| 637 | - ( |
|
| 637 | + ( |
|
| 638 | 638 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 639 | 639 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 640 | - ) |
|
| 640 | + ) |
|
| 641 | 641 | ) { |
| 642 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 643 | - if ($buffer != '') { |
|
| 642 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 643 | + if ($buffer != '') { |
|
| 644 | 644 | //echo $buffer; |
| 645 | 645 | $all_data = json_decode($buffer,true); |
| 646 | 646 | //print_r($all_data); |
| 647 | 647 | if (isset($all_data[0]['DATA'])) { |
| 648 | - foreach ($all_data[0]['DATA'] as $line) { |
|
| 648 | + foreach ($all_data[0]['DATA'] as $line) { |
|
| 649 | 649 | if ($line != '') { |
| 650 | - $data = array(); |
|
| 651 | - $data['ident'] = $line['NAME']; |
|
| 652 | - $data['mmsi'] = $line['MMSI']; |
|
| 653 | - if (strlen($data['mmsi']) > 9) { |
|
| 650 | + $data = array(); |
|
| 651 | + $data['ident'] = $line['NAME']; |
|
| 652 | + $data['mmsi'] = $line['MMSI']; |
|
| 653 | + if (strlen($data['mmsi']) > 9) { |
|
| 654 | 654 | $data['mmsi'] = substr($data['mmsi'],-9); |
| 655 | - } |
|
| 656 | - $data['speed'] = $line['SOG']; |
|
| 657 | - $data['heading'] = $line['COG']; |
|
| 658 | - $data['latitude'] = $line['LAT']; |
|
| 659 | - $data['longitude'] = $line['LNG']; |
|
| 660 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 661 | - //$data['type_id'] = $line['TYPE']; |
|
| 662 | - $data['imo'] = $line['IMO']; |
|
| 663 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 664 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 665 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 666 | - $data['format_source'] = 'myshiptracking'; |
|
| 667 | - $data['id_source'] = $id_source; |
|
| 668 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 669 | - $MI->add($data); |
|
| 670 | - unset($data); |
|
| 655 | + } |
|
| 656 | + $data['speed'] = $line['SOG']; |
|
| 657 | + $data['heading'] = $line['COG']; |
|
| 658 | + $data['latitude'] = $line['LAT']; |
|
| 659 | + $data['longitude'] = $line['LNG']; |
|
| 660 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 661 | + //$data['type_id'] = $line['TYPE']; |
|
| 662 | + $data['imo'] = $line['IMO']; |
|
| 663 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 664 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 665 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 666 | + $data['format_source'] = 'myshiptracking'; |
|
| 667 | + $data['id_source'] = $id_source; |
|
| 668 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 669 | + $MI->add($data); |
|
| 670 | + unset($data); |
|
| 671 | + } |
|
| 671 | 672 | } |
| 672 | - } |
|
| 673 | 673 | } |
| 674 | - } |
|
| 675 | - $last_exec[$id]['last'] = time(); |
|
| 674 | + } |
|
| 675 | + $last_exec[$id]['last'] = time(); |
|
| 676 | 676 | } elseif ($value['format'] === 'boatbeaconapp' && |
| 677 | - ( |
|
| 677 | + ( |
|
| 678 | 678 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 679 | 679 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 680 | - ) |
|
| 680 | + ) |
|
| 681 | 681 | ) { |
| 682 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 683 | - if ($buffer != '') { |
|
| 682 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 683 | + if ($buffer != '') { |
|
| 684 | 684 | $all_data = json_decode($buffer,true); |
| 685 | 685 | if (isset($all_data[0]['mmsi'])) { |
| 686 | - foreach ($all_data as $line) { |
|
| 686 | + foreach ($all_data as $line) { |
|
| 687 | 687 | if ($line != '') { |
| 688 | - $data = array(); |
|
| 689 | - $data['ident'] = $line['shipname']; |
|
| 690 | - $data['callsign'] = $line['callsign']; |
|
| 691 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
| 692 | - $data['speed'] = $line['sog']; |
|
| 693 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 694 | - $data['latitude'] = $line['latitude']; |
|
| 695 | - $data['longitude'] = $line['longitude']; |
|
| 696 | - $data['type_id'] = $line['shiptype']; |
|
| 697 | - $data['arrival_code'] = $line['destination']; |
|
| 698 | - $data['datetime'] = $line['time']; |
|
| 699 | - $data['format_source'] = 'boatbeaconapp'; |
|
| 700 | - $data['id_source'] = $id_source; |
|
| 701 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 702 | - $MI->add($data); |
|
| 703 | - unset($data); |
|
| 688 | + $data = array(); |
|
| 689 | + $data['ident'] = $line['shipname']; |
|
| 690 | + $data['callsign'] = $line['callsign']; |
|
| 691 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
| 692 | + $data['speed'] = $line['sog']; |
|
| 693 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 694 | + $data['latitude'] = $line['latitude']; |
|
| 695 | + $data['longitude'] = $line['longitude']; |
|
| 696 | + $data['type_id'] = $line['shiptype']; |
|
| 697 | + $data['arrival_code'] = $line['destination']; |
|
| 698 | + $data['datetime'] = $line['time']; |
|
| 699 | + $data['format_source'] = 'boatbeaconapp'; |
|
| 700 | + $data['id_source'] = $id_source; |
|
| 701 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 702 | + $MI->add($data); |
|
| 703 | + unset($data); |
|
| 704 | + } |
|
| 704 | 705 | } |
| 705 | - } |
|
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - } |
|
| 709 | - $last_exec[$id]['last'] = time(); |
|
| 708 | + } |
|
| 709 | + $last_exec[$id]['last'] = time(); |
|
| 710 | 710 | } elseif ($value['format'] === 'boatnerd' && |
| 711 | - ( |
|
| 711 | + ( |
|
| 712 | 712 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 713 | 713 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 714 | - ) |
|
| 714 | + ) |
|
| 715 | 715 | ) { |
| 716 | - $buffer = $Common->getData($value['host']); |
|
| 717 | - if ($buffer != '') { |
|
| 716 | + $buffer = $Common->getData($value['host']); |
|
| 717 | + if ($buffer != '') { |
|
| 718 | 718 | $all_data = json_decode($buffer,true); |
| 719 | 719 | if (isset($all_data['features'][0]['id'])) { |
| 720 | - foreach ($all_data['features'] as $line) { |
|
| 720 | + foreach ($all_data['features'] as $line) { |
|
| 721 | 721 | print_r($line); |
| 722 | 722 | $data = array(); |
| 723 | 723 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -737,75 +737,75 @@ discard block |
||
| 737 | 737 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 738 | 738 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
| 739 | 739 | unset($data); |
| 740 | - } |
|
| 740 | + } |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - } |
|
| 744 | - $last_exec[$id]['last'] = time(); |
|
| 743 | + } |
|
| 744 | + $last_exec[$id]['last'] = time(); |
|
| 745 | 745 | } elseif ($value['format'] === 'shipplotter' && |
| 746 | - ( |
|
| 746 | + ( |
|
| 747 | 747 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 748 | 748 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 749 | - ) |
|
| 749 | + ) |
|
| 750 | 750 | ) { |
| 751 | - if ($globalDebug) echo 'download...'; |
|
| 752 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 753 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 754 | - // FIXME: Need more work |
|
| 755 | - if ($buffer != '') $reset = 0; |
|
| 756 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 757 | - $buffer = explode('\n',$buffer); |
|
| 758 | - foreach ($buffer as $line) { |
|
| 751 | + if ($globalDebug) echo 'download...'; |
|
| 752 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 753 | + if ($globalDebug) echo 'done !'."\n"; |
|
| 754 | + // FIXME: Need more work |
|
| 755 | + if ($buffer != '') $reset = 0; |
|
| 756 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 757 | + $buffer = explode('\n',$buffer); |
|
| 758 | + foreach ($buffer as $line) { |
|
| 759 | 759 | if ($line != '') { |
| 760 | - $data = array(); |
|
| 761 | - //echo $line."\n"; |
|
| 762 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 763 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 764 | - $data['status_id'] = substr($line,21,2); |
|
| 765 | - $data['type_id'] = substr($line,24,3); |
|
| 766 | - $data['latitude'] = substr($line,29,9); |
|
| 767 | - $data['longitude'] = substr($line,41,9); |
|
| 768 | - $data['speed'] = round(substr($line,51,5)); |
|
| 769 | - //$data['course'] = substr($line,57,5); |
|
| 770 | - $data['heading'] = round(substr($line,63,3)); |
|
| 771 | - //$data['draft'] = substr($line,67,4); |
|
| 772 | - //$data['length'] = substr($line,72,3); |
|
| 773 | - //$data['beam'] = substr($line,76,2); |
|
| 774 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
| 775 | - //$data['callsign'] = trim(substr($line,100,7); |
|
| 776 | - $data['arrival_code'] = substr($line,108,20); |
|
| 777 | - //$data['etaDate'] = substr($line,129,5); |
|
| 778 | - //$data['etaTime'] = substr($line,135,5); |
|
| 779 | - $data['format_source'] = 'shipplotter'; |
|
| 780 | - $data['id_source'] = $id_source; |
|
| 781 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 782 | - //print_r($data); |
|
| 783 | - //echo 'Add...'."\n"; |
|
| 784 | - $MI->add($data); |
|
| 785 | - unset($data); |
|
| 760 | + $data = array(); |
|
| 761 | + //echo $line."\n"; |
|
| 762 | + $data['mmsi'] = (int)substr($line,0,9); |
|
| 763 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 764 | + $data['status_id'] = substr($line,21,2); |
|
| 765 | + $data['type_id'] = substr($line,24,3); |
|
| 766 | + $data['latitude'] = substr($line,29,9); |
|
| 767 | + $data['longitude'] = substr($line,41,9); |
|
| 768 | + $data['speed'] = round(substr($line,51,5)); |
|
| 769 | + //$data['course'] = substr($line,57,5); |
|
| 770 | + $data['heading'] = round(substr($line,63,3)); |
|
| 771 | + //$data['draft'] = substr($line,67,4); |
|
| 772 | + //$data['length'] = substr($line,72,3); |
|
| 773 | + //$data['beam'] = substr($line,76,2); |
|
| 774 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
| 775 | + //$data['callsign'] = trim(substr($line,100,7); |
|
| 776 | + $data['arrival_code'] = substr($line,108,20); |
|
| 777 | + //$data['etaDate'] = substr($line,129,5); |
|
| 778 | + //$data['etaTime'] = substr($line,135,5); |
|
| 779 | + $data['format_source'] = 'shipplotter'; |
|
| 780 | + $data['id_source'] = $id_source; |
|
| 781 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 782 | + //print_r($data); |
|
| 783 | + //echo 'Add...'."\n"; |
|
| 784 | + $MI->add($data); |
|
| 785 | + unset($data); |
|
| 786 | 786 | } |
| 787 | - } |
|
| 788 | - $last_exec[$id]['last'] = time(); |
|
| 787 | + } |
|
| 788 | + $last_exec[$id]['last'] = time(); |
|
| 789 | 789 | } elseif ($value['format'] === 'sailawayfull' && |
| 790 | - ( |
|
| 790 | + ( |
|
| 791 | 791 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 5*60)) |
| 792 | - ) |
|
| 792 | + ) |
|
| 793 | 793 | ) { |
| 794 | - if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
| 794 | + if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
|
| 795 | 795 | $authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true); |
| 796 | 796 | //echo $authsailaway; |
| 797 | 797 | preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie); |
| 798 | 798 | if (isset($setcookie[1][0])) { |
| 799 | - $sailaway_authcookie = $setcookie[1][0]; |
|
| 799 | + $sailaway_authcookie = $setcookie[1][0]; |
|
| 800 | + } |
|
| 800 | 801 | } |
| 801 | - } |
|
| 802 | 802 | |
| 803 | - if ($globalDebug) echo '! Download... '; |
|
| 804 | - for ($i =0; $i <= 1; $i++) { |
|
| 803 | + if ($globalDebug) echo '! Download... '; |
|
| 804 | + for ($i =0; $i <= 1; $i++) { |
|
| 805 | 805 | if ($globalDebug) echo 'Racetype: '.$i.' '; |
| 806 | 806 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
| 807 | - if ($globalDebug) echo 'done'."\n"; |
|
| 808 | - if ($buffer != '') { |
|
| 807 | + if ($globalDebug) echo 'done'."\n"; |
|
| 808 | + if ($buffer != '') { |
|
| 809 | 809 | $all_data = json_decode($buffer,true); |
| 810 | 810 | if (isset($all_data['missions'])) { |
| 811 | 811 | foreach ($all_data['missions'] as $mission) { |
@@ -826,19 +826,19 @@ discard block |
||
| 826 | 826 | //print_r($race_data); |
| 827 | 827 | unset($racebuffer); |
| 828 | 828 | if (isset($race_data['mission'])) { |
| 829 | - $datar = array(); |
|
| 830 | - $datar['id'] = $mission['misnr']; |
|
| 831 | - $datar['desc'] = $race_data['mission']['misdescr']; |
|
| 832 | - $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
| 833 | - $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
| 834 | - $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
| 835 | - $markers = array(); |
|
| 836 | - foreach ($race_data['mission']['course'] as $course) { |
|
| 829 | + $datar = array(); |
|
| 830 | + $datar['id'] = $mission['misnr']; |
|
| 831 | + $datar['desc'] = $race_data['mission']['misdescr']; |
|
| 832 | + $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
| 833 | + $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
| 834 | + $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
|
| 835 | + $markers = array(); |
|
| 836 | + foreach ($race_data['mission']['course'] as $course) { |
|
| 837 | 837 | $markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']); |
| 838 | - } |
|
| 839 | - $datar['markers'] = json_encode($markers); |
|
| 840 | - //print_r($datar); |
|
| 841 | - $MI->race_add($datar); |
|
| 838 | + } |
|
| 839 | + $datar['markers'] = json_encode($markers); |
|
| 840 | + //print_r($datar); |
|
| 841 | + $MI->race_add($datar); |
|
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | if ($bufferm != '') { |
@@ -903,16 +903,16 @@ discard block |
||
| 903 | 903 | sleep(30); |
| 904 | 904 | } |
| 905 | 905 | } |
| 906 | - } |
|
| 907 | - sleep(5); |
|
| 908 | - } |
|
| 909 | - $last_exec[$id]['last'] = time(); |
|
| 906 | + } |
|
| 907 | + sleep(5); |
|
| 908 | + } |
|
| 909 | + $last_exec[$id]['last'] = time(); |
|
| 910 | 910 | } elseif ($value['format'] === 'sailaway' && |
| 911 | - ( |
|
| 911 | + ( |
|
| 912 | 912 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 5*60)) |
| 913 | - ) |
|
| 913 | + ) |
|
| 914 | 914 | ) { |
| 915 | - /* |
|
| 915 | + /* |
|
| 916 | 916 | if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
| 917 | 917 | $authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true); |
| 918 | 918 | //echo $authsailaway; |
@@ -923,17 +923,17 @@ discard block |
||
| 923 | 923 | } |
| 924 | 924 | } |
| 925 | 925 | */ |
| 926 | - if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') { |
|
| 926 | + if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') { |
|
| 927 | 927 | echo 'Sailaway API key MUST be defined'; |
| 928 | 928 | exit(0); |
| 929 | - } |
|
| 930 | - if ($globalDebug) echo '! Download... '; |
|
| 931 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key'],'get','','','','',30); |
|
| 932 | - if ($buffer != '') { |
|
| 929 | + } |
|
| 930 | + if ($globalDebug) echo '! Download... '; |
|
| 931 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key'],'get','','','','',30); |
|
| 932 | + if ($buffer != '') { |
|
| 933 | 933 | $data = json_decode($buffer,true); |
| 934 | 934 | //print_r($data); |
| 935 | 935 | if (isset($data['boats'])) { |
| 936 | - foreach ($data['boats'] as $sail) { |
|
| 936 | + foreach ($data['boats'] as $sail) { |
|
| 937 | 937 | $data = array(); |
| 938 | 938 | $data['id'] = $sail['ubtnr']; |
| 939 | 939 | $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -953,35 +953,35 @@ discard block |
||
| 953 | 953 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 954 | 954 | $MI->add($data); |
| 955 | 955 | unset($data); |
| 956 | - } |
|
| 956 | + } |
|
| 957 | 957 | } elseif ($globalDebug) echo 'Error in JSON parsing'; |
| 958 | - } elseif ($globalDebug) echo 'Empty result !'."\n"; |
|
| 959 | - $last_exec[$id]['last'] = time(); |
|
| 958 | + } elseif ($globalDebug) echo 'Empty result !'."\n"; |
|
| 959 | + $last_exec[$id]['last'] = time(); |
|
| 960 | 960 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 961 | 961 | } elseif ( |
| 962 | - ( |
|
| 962 | + ( |
|
| 963 | 963 | $value['format'] === 'whazzup' && |
| 964 | 964 | ( |
| 965 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 966 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 965 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 966 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 967 | 967 | ) |
| 968 | - ) || ( |
|
| 968 | + ) || ( |
|
| 969 | 969 | $value['format'] === 'vatsimtxt' && |
| 970 | 970 | ( |
| 971 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 972 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 971 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 972 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 973 | + ) |
|
| 973 | 974 | ) |
| 974 | - ) |
|
| 975 | 975 | ) { |
| 976 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 977 | - $buffer = $Common->getData($value['host']); |
|
| 978 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 979 | - $buffer = explode('\n',$buffer); |
|
| 980 | - $reset = 0; |
|
| 981 | - foreach ($buffer as $line) { |
|
| 982 | - if ($line != '') { |
|
| 983 | - $line = explode(':', $line); |
|
| 984 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 976 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 977 | + $buffer = $Common->getData($value['host']); |
|
| 978 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 979 | + $buffer = explode('\n',$buffer); |
|
| 980 | + $reset = 0; |
|
| 981 | + foreach ($buffer as $line) { |
|
| 982 | + if ($line != '') { |
|
| 983 | + $line = explode(':', $line); |
|
| 984 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 985 | 985 | $data = array(); |
| 986 | 986 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 987 | 987 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -994,37 +994,37 @@ discard block |
||
| 994 | 994 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 995 | 995 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 996 | 996 | $data['latitude'] = $line[5]; // lat |
| 997 | - $data['longitude'] = $line[6]; // long |
|
| 998 | - $data['verticalrate'] = ''; // vertical rate |
|
| 999 | - $data['squawk'] = ''; // squawk |
|
| 1000 | - $data['emergency'] = ''; // emergency |
|
| 1001 | - $data['waypoints'] = $line[30]; |
|
| 997 | + $data['longitude'] = $line[6]; // long |
|
| 998 | + $data['verticalrate'] = ''; // vertical rate |
|
| 999 | + $data['squawk'] = ''; // squawk |
|
| 1000 | + $data['emergency'] = ''; // emergency |
|
| 1001 | + $data['waypoints'] = $line[30]; |
|
| 1002 | 1002 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1003 | 1003 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 1004 | 1004 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 1005 | - $data['departure_airport_icao'] = $line[11]; |
|
| 1006 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 1007 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 1005 | + $data['departure_airport_icao'] = $line[11]; |
|
| 1006 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 1007 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 1008 | 1008 | $data['frequency'] = $line[4]; |
| 1009 | 1009 | $data['type'] = $line[18]; |
| 1010 | 1010 | $data['range'] = $line[19]; |
| 1011 | 1011 | if (isset($line[35])) $data['info'] = $line[35]; |
| 1012 | - $data['id_source'] = $id_source; |
|
| 1013 | - //$data['arrival_airport_time'] = ; |
|
| 1014 | - if ($line[9] != '') { |
|
| 1015 | - $aircraft_data = explode('/',$line[9]); |
|
| 1016 | - if (isset($aircraft_data[1])) { |
|
| 1017 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1018 | - } |
|
| 1019 | - } |
|
| 1020 | - /* |
|
| 1012 | + $data['id_source'] = $id_source; |
|
| 1013 | + //$data['arrival_airport_time'] = ; |
|
| 1014 | + if ($line[9] != '') { |
|
| 1015 | + $aircraft_data = explode('/',$line[9]); |
|
| 1016 | + if (isset($aircraft_data[1])) { |
|
| 1017 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1018 | + } |
|
| 1019 | + } |
|
| 1020 | + /* |
|
| 1021 | 1021 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
| 1022 | 1022 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 1023 | 1023 | */ |
| 1024 | - $data['format_source'] = $value['format']; |
|
| 1024 | + $data['format_source'] = $value['format']; |
|
| 1025 | 1025 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1026 | 1026 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1027 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 1027 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
| 1028 | 1028 | elseif ($line[3] === 'ATC') { |
| 1029 | 1029 | //print_r($data); |
| 1030 | 1030 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -1045,21 +1045,21 @@ discard block |
||
| 1045 | 1045 | 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']); |
| 1046 | 1046 | } |
| 1047 | 1047 | } |
| 1048 | - unset($data); |
|
| 1049 | - } |
|
| 1050 | - } |
|
| 1051 | - } |
|
| 1052 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
| 1053 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 1054 | - $last_exec[$id]['last'] = time(); |
|
| 1055 | - } elseif ($value['format'] === 'airwhere' && |
|
| 1056 | - ( |
|
| 1057 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1058 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1059 | - ) |
|
| 1060 | - ) { |
|
| 1061 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 1062 | - if ($buffer != '') { |
|
| 1048 | + unset($data); |
|
| 1049 | + } |
|
| 1050 | + } |
|
| 1051 | + } |
|
| 1052 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
| 1053 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 1054 | + $last_exec[$id]['last'] = time(); |
|
| 1055 | + } elseif ($value['format'] === 'airwhere' && |
|
| 1056 | + ( |
|
| 1057 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1058 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1059 | + ) |
|
| 1060 | + ) { |
|
| 1061 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 1062 | + if ($buffer != '') { |
|
| 1063 | 1063 | $all_data = simplexml_load_string($buffer); |
| 1064 | 1064 | foreach($all_data->children() as $childdata) { |
| 1065 | 1065 | $data = array(); |
@@ -1081,10 +1081,10 @@ discard block |
||
| 1081 | 1081 | $SI->add($data); |
| 1082 | 1082 | unset($data); |
| 1083 | 1083 | } |
| 1084 | - } |
|
| 1085 | - $Source->deleteOldLocationByType('gs'); |
|
| 1086 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 1087 | - if ($buffer != '') { |
|
| 1084 | + } |
|
| 1085 | + $Source->deleteOldLocationByType('gs'); |
|
| 1086 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 1087 | + if ($buffer != '') { |
|
| 1088 | 1088 | $all_data = simplexml_load_string($buffer); |
| 1089 | 1089 | foreach($all_data->children() as $childdata) { |
| 1090 | 1090 | $data = array(); |
@@ -1102,8 +1102,8 @@ discard block |
||
| 1102 | 1102 | } |
| 1103 | 1103 | unset($data); |
| 1104 | 1104 | } |
| 1105 | - } |
|
| 1106 | - $last_exec[$id]['last'] = time(); |
|
| 1105 | + } |
|
| 1106 | + $last_exec[$id]['last'] = time(); |
|
| 1107 | 1107 | /* |
| 1108 | 1108 | } if ($value['format'] === 'aircraftlistjson') { |
| 1109 | 1109 | print_r($globalSources); |
@@ -1111,17 +1111,17 @@ discard block |
||
| 1111 | 1111 | echo $globalMinFetch; |
| 1112 | 1112 | */ |
| 1113 | 1113 | } elseif ($value['format'] === 'aircraftlistjson' && |
| 1114 | - ( |
|
| 1114 | + ( |
|
| 1115 | 1115 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1116 | 1116 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1117 | - ) |
|
| 1117 | + ) |
|
| 1118 | 1118 | ) { |
| 1119 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 1120 | - if ($buffer != '') { |
|
| 1121 | - $all_data = json_decode($buffer,true); |
|
| 1119 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 1120 | + if ($buffer != '') { |
|
| 1121 | + $all_data = json_decode($buffer,true); |
|
| 1122 | 1122 | if (isset($all_data['acList'])) { |
| 1123 | - $reset = 0; |
|
| 1124 | - foreach ($all_data['acList'] as $line) { |
|
| 1123 | + $reset = 0; |
|
| 1124 | + foreach ($all_data['acList'] as $line) { |
|
| 1125 | 1125 | $data = array(); |
| 1126 | 1126 | $data['hex'] = $line['Icao']; // hex |
| 1127 | 1127 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1144,10 +1144,10 @@ discard block |
||
| 1144 | 1144 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1145 | 1145 | if (isset($data['latitude'])) $SI->add($data); |
| 1146 | 1146 | unset($data); |
| 1147 | - } |
|
| 1147 | + } |
|
| 1148 | 1148 | } elseif (is_array($all_data)) { |
| 1149 | - $reset = 0; |
|
| 1150 | - foreach ($all_data as $line) { |
|
| 1149 | + $reset = 0; |
|
| 1150 | + foreach ($all_data as $line) { |
|
| 1151 | 1151 | $data = array(); |
| 1152 | 1152 | $data['hex'] = $line['hex']; // hex |
| 1153 | 1153 | $data['ident'] = $line['flight']; // ident |
@@ -1167,291 +1167,291 @@ discard block |
||
| 1167 | 1167 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1168 | 1168 | $SI->add($data); |
| 1169 | 1169 | unset($data); |
| 1170 | - } |
|
| 1170 | + } |
|
| 1171 | 1171 | } |
| 1172 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1173 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 1174 | - $last_exec[$id]['last'] = time(); |
|
| 1175 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 1176 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
| 1177 | - ( |
|
| 1178 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1179 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1180 | - ) |
|
| 1181 | - ) { |
|
| 1182 | - $buffer = $Common->getData($value['host']); |
|
| 1183 | - $all_data = json_decode($buffer,true); |
|
| 1184 | - if (isset($all_data['planes'])) { |
|
| 1172 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1173 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 1174 | + $last_exec[$id]['last'] = time(); |
|
| 1175 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 1176 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
| 1177 | + ( |
|
| 1178 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1179 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1180 | + ) |
|
| 1181 | + ) { |
|
| 1182 | + $buffer = $Common->getData($value['host']); |
|
| 1183 | + $all_data = json_decode($buffer,true); |
|
| 1184 | + if (isset($all_data['planes'])) { |
|
| 1185 | 1185 | $reset = 0; |
| 1186 | 1186 | foreach ($all_data['planes'] as $key => $line) { |
| 1187 | - $data = array(); |
|
| 1188 | - $data['hex'] = $key; // hex |
|
| 1189 | - $data['ident'] = $line[3]; // ident |
|
| 1190 | - $data['altitude'] = $line[6]; // altitude |
|
| 1191 | - $data['speed'] = $line[8]; // speed |
|
| 1192 | - $data['heading'] = $line[7]; // heading |
|
| 1193 | - $data['latitude'] = $line[4]; // lat |
|
| 1194 | - $data['longitude'] = $line[5]; // long |
|
| 1195 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 1196 | - $data['squawk'] = $line[10]; // squawk |
|
| 1197 | - $data['emergency'] = ''; // emergency |
|
| 1198 | - $data['registration'] = $line[2]; |
|
| 1199 | - $data['aircraft_icao'] = $line[0]; |
|
| 1200 | - $deparr = explode('-',$line[1]); |
|
| 1201 | - if (count($deparr) === 2) { |
|
| 1187 | + $data = array(); |
|
| 1188 | + $data['hex'] = $key; // hex |
|
| 1189 | + $data['ident'] = $line[3]; // ident |
|
| 1190 | + $data['altitude'] = $line[6]; // altitude |
|
| 1191 | + $data['speed'] = $line[8]; // speed |
|
| 1192 | + $data['heading'] = $line[7]; // heading |
|
| 1193 | + $data['latitude'] = $line[4]; // lat |
|
| 1194 | + $data['longitude'] = $line[5]; // long |
|
| 1195 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 1196 | + $data['squawk'] = $line[10]; // squawk |
|
| 1197 | + $data['emergency'] = ''; // emergency |
|
| 1198 | + $data['registration'] = $line[2]; |
|
| 1199 | + $data['aircraft_icao'] = $line[0]; |
|
| 1200 | + $deparr = explode('-',$line[1]); |
|
| 1201 | + if (count($deparr) === 2) { |
|
| 1202 | 1202 | $data['departure_airport_icao'] = $deparr[0]; |
| 1203 | 1203 | $data['arrival_airport_icao'] = $deparr[1]; |
| 1204 | - } |
|
| 1205 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1206 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 1207 | - $data['id_source'] = $id_source; |
|
| 1208 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1209 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1210 | - $SI->add($data); |
|
| 1211 | - unset($data); |
|
| 1204 | + } |
|
| 1205 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1206 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 1207 | + $data['id_source'] = $id_source; |
|
| 1208 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1209 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1210 | + $SI->add($data); |
|
| 1211 | + unset($data); |
|
| 1212 | 1212 | } |
| 1213 | - } |
|
| 1214 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1215 | - $last_exec[$id]['last'] = time(); |
|
| 1213 | + } |
|
| 1214 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1215 | + $last_exec[$id]['last'] = time(); |
|
| 1216 | 1216 | } elseif ($value['format'] === 'opensky' && |
| 1217 | - ( |
|
| 1217 | + ( |
|
| 1218 | 1218 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1219 | 1219 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1220 | - ) |
|
| 1220 | + ) |
|
| 1221 | 1221 | ) { |
| 1222 | - $buffer = $Common->getData($value['host']); |
|
| 1223 | - $all_data = json_decode($buffer,true); |
|
| 1224 | - if (isset($all_data['states'])) { |
|
| 1222 | + $buffer = $Common->getData($value['host']); |
|
| 1223 | + $all_data = json_decode($buffer,true); |
|
| 1224 | + if (isset($all_data['states'])) { |
|
| 1225 | 1225 | $reset = 0; |
| 1226 | 1226 | foreach ($all_data['states'] as $key => $line) { |
| 1227 | - $data = array(); |
|
| 1228 | - $data['hex'] = $line[0]; // hex |
|
| 1229 | - $data['ident'] = trim($line[1]); // ident |
|
| 1230 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 1231 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 1232 | - $data['heading'] = round($line[10]); // heading |
|
| 1233 | - $data['latitude'] = $line[6]; // lat |
|
| 1234 | - $data['longitude'] = $line[5]; // long |
|
| 1235 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 1236 | - //$data['squawk'] = $line[10]; // squawk |
|
| 1237 | - //$data['emergency'] = ''; // emergency |
|
| 1238 | - //$data['registration'] = $line[2]; |
|
| 1239 | - //$data['aircraft_icao'] = $line[0]; |
|
| 1240 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1241 | - $data['format_source'] = 'opensky'; |
|
| 1242 | - $data['id_source'] = $id_source; |
|
| 1243 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1244 | - $SI->add($data); |
|
| 1245 | - unset($data); |
|
| 1227 | + $data = array(); |
|
| 1228 | + $data['hex'] = $line[0]; // hex |
|
| 1229 | + $data['ident'] = trim($line[1]); // ident |
|
| 1230 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 1231 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 1232 | + $data['heading'] = round($line[10]); // heading |
|
| 1233 | + $data['latitude'] = $line[6]; // lat |
|
| 1234 | + $data['longitude'] = $line[5]; // long |
|
| 1235 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 1236 | + //$data['squawk'] = $line[10]; // squawk |
|
| 1237 | + //$data['emergency'] = ''; // emergency |
|
| 1238 | + //$data['registration'] = $line[2]; |
|
| 1239 | + //$data['aircraft_icao'] = $line[0]; |
|
| 1240 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1241 | + $data['format_source'] = 'opensky'; |
|
| 1242 | + $data['id_source'] = $id_source; |
|
| 1243 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1244 | + $SI->add($data); |
|
| 1245 | + unset($data); |
|
| 1246 | 1246 | } |
| 1247 | - } |
|
| 1248 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1249 | - $last_exec[$id]['last'] = time(); |
|
| 1247 | + } |
|
| 1248 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1249 | + $last_exec[$id]['last'] = time(); |
|
| 1250 | 1250 | } elseif ($value['format'] === 'aircraftjson' && |
| 1251 | - ( |
|
| 1251 | + ( |
|
| 1252 | 1252 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1253 | 1253 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1254 | - ) |
|
| 1254 | + ) |
|
| 1255 | 1255 | ) { |
| 1256 | - $buffer = $Common->getData($value['host']); |
|
| 1257 | - $all_data = json_decode($buffer,true); |
|
| 1258 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1256 | + $buffer = $Common->getData($value['host']); |
|
| 1257 | + $all_data = json_decode($buffer,true); |
|
| 1258 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1259 | 1259 | $reset = 0; |
| 1260 | 1260 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1261 | - $data = array(); |
|
| 1262 | - // add support for ground vehicule with ~ in front of hex |
|
| 1263 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1264 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1265 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1266 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1267 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1268 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1269 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1270 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1271 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1272 | - //$data['emergency'] = ''; // emergency |
|
| 1273 | - //$data['registration'] = $line[2]; |
|
| 1274 | - //$data['aircraft_icao'] = $line[0]; |
|
| 1275 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1276 | - $data['format_source'] = 'aircraftjson'; |
|
| 1277 | - $data['id_source'] = $id_source; |
|
| 1278 | - if (isset($value['name']) && $value['name'] != '') { |
|
| 1279 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1280 | - else $data['source_name'] = $value['name']; |
|
| 1281 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1282 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1283 | - $SI->add($data); |
|
| 1284 | - unset($data); |
|
| 1261 | + $data = array(); |
|
| 1262 | + // add support for ground vehicule with ~ in front of hex |
|
| 1263 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1264 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1265 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1266 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1267 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1268 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1269 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1270 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1271 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1272 | + //$data['emergency'] = ''; // emergency |
|
| 1273 | + //$data['registration'] = $line[2]; |
|
| 1274 | + //$data['aircraft_icao'] = $line[0]; |
|
| 1275 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1276 | + $data['format_source'] = 'aircraftjson'; |
|
| 1277 | + $data['id_source'] = $id_source; |
|
| 1278 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1279 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1280 | + else $data['source_name'] = $value['name']; |
|
| 1281 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1282 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1283 | + $SI->add($data); |
|
| 1284 | + unset($data); |
|
| 1285 | 1285 | } |
| 1286 | - } |
|
| 1287 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1288 | - $last_exec[$id]['last'] = time(); |
|
| 1286 | + } |
|
| 1287 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1288 | + $last_exec[$id]['last'] = time(); |
|
| 1289 | 1289 | } elseif ($value['format'] === 'planefinderclient' && |
| 1290 | - ( |
|
| 1290 | + ( |
|
| 1291 | 1291 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1292 | 1292 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1293 | - ) |
|
| 1293 | + ) |
|
| 1294 | 1294 | ) { |
| 1295 | - $buffer = $Common->getData($value['host']); |
|
| 1296 | - $all_data = json_decode($buffer,true); |
|
| 1297 | - if (isset($all_data['aircraft'])) { |
|
| 1295 | + $buffer = $Common->getData($value['host']); |
|
| 1296 | + $all_data = json_decode($buffer,true); |
|
| 1297 | + if (isset($all_data['aircraft'])) { |
|
| 1298 | 1298 | $reset = 0; |
| 1299 | 1299 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1300 | - $data = array(); |
|
| 1301 | - $data['hex'] = $key; // hex |
|
| 1302 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1303 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1304 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1305 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1306 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1307 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1308 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1309 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1310 | - //$data['emergency'] = ''; // emergency |
|
| 1311 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1312 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1313 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1314 | - $data['format_source'] = 'planefinderclient'; |
|
| 1315 | - $data['id_source'] = $id_source; |
|
| 1316 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1317 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1318 | - $SI->add($data); |
|
| 1319 | - unset($data); |
|
| 1300 | + $data = array(); |
|
| 1301 | + $data['hex'] = $key; // hex |
|
| 1302 | + if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1303 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1304 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1305 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1306 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1307 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1308 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1309 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1310 | + //$data['emergency'] = ''; // emergency |
|
| 1311 | + if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1312 | + if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1313 | + $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1314 | + $data['format_source'] = 'planefinderclient'; |
|
| 1315 | + $data['id_source'] = $id_source; |
|
| 1316 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1317 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1318 | + $SI->add($data); |
|
| 1319 | + unset($data); |
|
| 1320 | 1320 | } |
| 1321 | - } |
|
| 1322 | - $last_exec[$id]['last'] = time(); |
|
| 1321 | + } |
|
| 1322 | + $last_exec[$id]['last'] = time(); |
|
| 1323 | 1323 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
| 1324 | 1324 | } elseif ($value['format'] === 'fr24json' && |
| 1325 | - ( |
|
| 1325 | + ( |
|
| 1326 | 1326 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1327 | 1327 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1328 | - ) |
|
| 1328 | + ) |
|
| 1329 | 1329 | ) { |
| 1330 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1331 | - $buffer = $Common->getData($value['host']); |
|
| 1332 | - $all_data = json_decode($buffer,true); |
|
| 1333 | - if (!empty($all_data)) $reset = 0; |
|
| 1334 | - foreach ($all_data as $key => $line) { |
|
| 1330 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1331 | + $buffer = $Common->getData($value['host']); |
|
| 1332 | + $all_data = json_decode($buffer,true); |
|
| 1333 | + if (!empty($all_data)) $reset = 0; |
|
| 1334 | + foreach ($all_data as $key => $line) { |
|
| 1335 | 1335 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1336 | - $data = array(); |
|
| 1337 | - $data['hex'] = $line[0]; |
|
| 1338 | - $data['ident'] = $line[16]; //$line[13] |
|
| 1339 | - $data['altitude'] = $line[4]; // altitude |
|
| 1340 | - $data['speed'] = $line[5]; // speed |
|
| 1341 | - $data['heading'] = $line[3]; // heading |
|
| 1342 | - $data['latitude'] = $line[1]; // lat |
|
| 1343 | - $data['longitude'] = $line[2]; // long |
|
| 1344 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1345 | - $data['squawk'] = $line[6]; // squawk |
|
| 1346 | - $data['aircraft_icao'] = $line[8]; |
|
| 1347 | - $data['registration'] = $line[9]; |
|
| 1348 | - $data['departure_airport_iata'] = $line[11]; |
|
| 1349 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 1350 | - $data['emergency'] = ''; // emergency |
|
| 1351 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1352 | - $data['format_source'] = 'fr24json'; |
|
| 1353 | - $data['id_source'] = $id_source; |
|
| 1354 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1355 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1356 | - $SI->add($data); |
|
| 1357 | - unset($data); |
|
| 1336 | + $data = array(); |
|
| 1337 | + $data['hex'] = $line[0]; |
|
| 1338 | + $data['ident'] = $line[16]; //$line[13] |
|
| 1339 | + $data['altitude'] = $line[4]; // altitude |
|
| 1340 | + $data['speed'] = $line[5]; // speed |
|
| 1341 | + $data['heading'] = $line[3]; // heading |
|
| 1342 | + $data['latitude'] = $line[1]; // lat |
|
| 1343 | + $data['longitude'] = $line[2]; // long |
|
| 1344 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1345 | + $data['squawk'] = $line[6]; // squawk |
|
| 1346 | + $data['aircraft_icao'] = $line[8]; |
|
| 1347 | + $data['registration'] = $line[9]; |
|
| 1348 | + $data['departure_airport_iata'] = $line[11]; |
|
| 1349 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 1350 | + $data['emergency'] = ''; // emergency |
|
| 1351 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1352 | + $data['format_source'] = 'fr24json'; |
|
| 1353 | + $data['id_source'] = $id_source; |
|
| 1354 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1355 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1356 | + $SI->add($data); |
|
| 1357 | + unset($data); |
|
| 1358 | 1358 | } |
| 1359 | - } |
|
| 1360 | - //$last_exec['fr24json'] = time(); |
|
| 1361 | - $last_exec[$id]['last'] = time(); |
|
| 1359 | + } |
|
| 1360 | + //$last_exec['fr24json'] = time(); |
|
| 1361 | + $last_exec[$id]['last'] = time(); |
|
| 1362 | 1362 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 1363 | 1363 | } elseif ($value['format'] === 'radarvirtueljson' && |
| 1364 | - ( |
|
| 1364 | + ( |
|
| 1365 | 1365 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1366 | 1366 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1367 | - ) |
|
| 1367 | + ) |
|
| 1368 | 1368 | ) { |
| 1369 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1370 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1371 | - //echo $buffer; |
|
| 1372 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1373 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1374 | - $all_data = json_decode($buffer,true); |
|
| 1375 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1369 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1370 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1371 | + //echo $buffer; |
|
| 1372 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1373 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1374 | + $all_data = json_decode($buffer,true); |
|
| 1375 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1376 | 1376 | die(json_last_error_msg()); |
| 1377 | - } |
|
| 1378 | - if (isset($all_data['mrkrs'])) { |
|
| 1377 | + } |
|
| 1378 | + if (isset($all_data['mrkrs'])) { |
|
| 1379 | 1379 | $reset = 0; |
| 1380 | 1380 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 1381 | - if (isset($line['inf'])) { |
|
| 1381 | + if (isset($line['inf'])) { |
|
| 1382 | 1382 | $data = array(); |
| 1383 | 1383 | $data['hex'] = $line['inf']['ia']; |
| 1384 | 1384 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 1385 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1386 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1387 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1388 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 1389 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 1390 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1391 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1392 | - //$data['aircraft_icao'] = $line[8]; |
|
| 1393 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1385 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1386 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1387 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1388 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 1389 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 1390 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1391 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1392 | + //$data['aircraft_icao'] = $line[8]; |
|
| 1393 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1394 | 1394 | //$data['departure_airport_iata'] = $line[11]; |
| 1395 | 1395 | //$data['arrival_airport_iata'] = $line[12]; |
| 1396 | - //$data['emergency'] = ''; // emergency |
|
| 1396 | + //$data['emergency'] = ''; // emergency |
|
| 1397 | 1397 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1398 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 1399 | - $data['id_source'] = $id_source; |
|
| 1398 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 1399 | + $data['id_source'] = $id_source; |
|
| 1400 | 1400 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1401 | 1401 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1402 | 1402 | $SI->add($data); |
| 1403 | 1403 | unset($data); |
| 1404 | - } |
|
| 1404 | + } |
|
| 1405 | 1405 | } |
| 1406 | - } |
|
| 1407 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 1408 | - $last_exec[$id]['last'] = time(); |
|
| 1406 | + } |
|
| 1407 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 1408 | + $last_exec[$id]['last'] = time(); |
|
| 1409 | 1409 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
| 1410 | 1410 | } elseif ($value['format'] === 'pirepsjson' && |
| 1411 | - ( |
|
| 1411 | + ( |
|
| 1412 | 1412 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1413 | 1413 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1414 | - ) |
|
| 1414 | + ) |
|
| 1415 | 1415 | ) { |
| 1416 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1417 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1418 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1416 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1417 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1418 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1419 | 1419 | |
| 1420 | - if (isset($all_data['pireps'])) { |
|
| 1420 | + if (isset($all_data['pireps'])) { |
|
| 1421 | 1421 | $reset = 0; |
| 1422 | - foreach ($all_data['pireps'] as $line) { |
|
| 1423 | - $data = array(); |
|
| 1424 | - $data['id'] = $line['id']; |
|
| 1425 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1426 | - $data['ident'] = $line['callsign']; // ident |
|
| 1427 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1428 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1429 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1430 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1431 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1432 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1433 | - $data['latitude'] = $line['lat']; // lat |
|
| 1434 | - $data['longitude'] = $line['lon']; // long |
|
| 1435 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1436 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 1437 | - //$data['emergency'] = ''; // emergency |
|
| 1438 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1439 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1440 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1441 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1442 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1443 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1444 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1445 | - else $data['info'] = ''; |
|
| 1446 | - $data['format_source'] = 'pireps'; |
|
| 1447 | - $data['id_source'] = $id_source; |
|
| 1448 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1449 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1450 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1451 | - if ($line['icon'] === 'plane') { |
|
| 1422 | + foreach ($all_data['pireps'] as $line) { |
|
| 1423 | + $data = array(); |
|
| 1424 | + $data['id'] = $line['id']; |
|
| 1425 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1426 | + $data['ident'] = $line['callsign']; // ident |
|
| 1427 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1428 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1429 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1430 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1431 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1432 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1433 | + $data['latitude'] = $line['lat']; // lat |
|
| 1434 | + $data['longitude'] = $line['lon']; // long |
|
| 1435 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1436 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 1437 | + //$data['emergency'] = ''; // emergency |
|
| 1438 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1439 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1440 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1441 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1442 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1443 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1444 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1445 | + else $data['info'] = ''; |
|
| 1446 | + $data['format_source'] = 'pireps'; |
|
| 1447 | + $data['id_source'] = $id_source; |
|
| 1448 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1449 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1450 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1451 | + if ($line['icon'] === 'plane') { |
|
| 1452 | 1452 | $SI->add($data); |
| 1453 | - // print_r($data); |
|
| 1454 | - } elseif ($line['icon'] === 'ct') { |
|
| 1453 | + // print_r($data); |
|
| 1454 | + } elseif ($line['icon'] === 'ct') { |
|
| 1455 | 1455 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 1456 | 1456 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1457 | 1457 | $typec = substr($data['ident'],-3); |
@@ -1466,209 +1466,209 @@ discard block |
||
| 1466 | 1466 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1467 | 1467 | else $data['type'] = 'Observer'; |
| 1468 | 1468 | 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']); |
| 1469 | - } |
|
| 1470 | - unset($data); |
|
| 1469 | + } |
|
| 1470 | + unset($data); |
|
| 1471 | 1471 | } |
| 1472 | - } |
|
| 1473 | - //$last_exec['pirepsjson'] = time(); |
|
| 1474 | - $last_exec[$id]['last'] = time(); |
|
| 1472 | + } |
|
| 1473 | + //$last_exec['pirepsjson'] = time(); |
|
| 1474 | + $last_exec[$id]['last'] = time(); |
|
| 1475 | 1475 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 1476 | 1476 | } elseif ($value['format'] === 'phpvmacars' && |
| 1477 | - ( |
|
| 1477 | + ( |
|
| 1478 | 1478 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1479 | 1479 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1480 | - ) |
|
| 1480 | + ) |
|
| 1481 | 1481 | ) { |
| 1482 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1483 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1484 | - $buffer = $Common->getData($value['host']); |
|
| 1485 | - $all_data = json_decode($buffer,true); |
|
| 1486 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1482 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1483 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1484 | + $buffer = $Common->getData($value['host']); |
|
| 1485 | + $all_data = json_decode($buffer,true); |
|
| 1486 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1487 | 1487 | $reset = 0; |
| 1488 | 1488 | foreach ($all_data as $line) { |
| 1489 | - $data = array(); |
|
| 1490 | - //$data['id'] = $line['id']; // id not usable |
|
| 1491 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1492 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1493 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1494 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1495 | - $data['ident'] = $line['flightnum']; // ident |
|
| 1496 | - $data['altitude'] = $line['alt']; // altitude |
|
| 1497 | - $data['speed'] = $line['gs']; // speed |
|
| 1498 | - $data['heading'] = $line['heading']; // heading |
|
| 1499 | - $data['latitude'] = $line['lat']; // lat |
|
| 1500 | - $data['longitude'] = $line['lng']; // long |
|
| 1501 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1502 | - $data['squawk'] = ''; // squawk |
|
| 1503 | - $data['emergency'] = ''; // emergency |
|
| 1504 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1505 | - //$data['last_update'] = $line['lastupdate']; |
|
| 1506 | - if (isset($value['timezone'])) { |
|
| 1507 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1508 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1509 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1510 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1511 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 1512 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 1513 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1514 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1515 | - if (isset($line['registration'])) { |
|
| 1516 | - $data['registration'] = $line['registration']; |
|
| 1517 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1518 | - } else $data['registration'] = $line['aircraft']; |
|
| 1519 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1520 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1521 | - if (isset($line['aircraftname'])) { |
|
| 1489 | + $data = array(); |
|
| 1490 | + //$data['id'] = $line['id']; // id not usable |
|
| 1491 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1492 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1493 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1494 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1495 | + $data['ident'] = $line['flightnum']; // ident |
|
| 1496 | + $data['altitude'] = $line['alt']; // altitude |
|
| 1497 | + $data['speed'] = $line['gs']; // speed |
|
| 1498 | + $data['heading'] = $line['heading']; // heading |
|
| 1499 | + $data['latitude'] = $line['lat']; // lat |
|
| 1500 | + $data['longitude'] = $line['lng']; // long |
|
| 1501 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1502 | + $data['squawk'] = ''; // squawk |
|
| 1503 | + $data['emergency'] = ''; // emergency |
|
| 1504 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1505 | + //$data['last_update'] = $line['lastupdate']; |
|
| 1506 | + if (isset($value['timezone'])) { |
|
| 1507 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1508 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1509 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1510 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1511 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1512 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1513 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1514 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1515 | + if (isset($line['registration'])) { |
|
| 1516 | + $data['registration'] = $line['registration']; |
|
| 1517 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1518 | + } else $data['registration'] = $line['aircraft']; |
|
| 1519 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1520 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1521 | + if (isset($line['aircraftname'])) { |
|
| 1522 | 1522 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1523 | 1523 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1524 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1525 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1526 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1527 | - else { |
|
| 1528 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1529 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1530 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1531 | - } |
|
| 1532 | - } |
|
| 1533 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1534 | - $data['id_source'] = $id_source; |
|
| 1535 | - $data['format_source'] = 'phpvmacars'; |
|
| 1536 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1537 | - $SI->add($data); |
|
| 1538 | - unset($data); |
|
| 1524 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1525 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1526 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1527 | + else { |
|
| 1528 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1529 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1530 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1531 | + } |
|
| 1532 | + } |
|
| 1533 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1534 | + $data['id_source'] = $id_source; |
|
| 1535 | + $data['format_source'] = 'phpvmacars'; |
|
| 1536 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1537 | + $SI->add($data); |
|
| 1538 | + unset($data); |
|
| 1539 | 1539 | } |
| 1540 | 1540 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1541 | 1541 | unset($buffer); |
| 1542 | 1542 | unset($all_data); |
| 1543 | - } |
|
| 1544 | - //$last_exec['phpvmacars'] = time(); |
|
| 1545 | - $last_exec[$id]['last'] = time(); |
|
| 1543 | + } |
|
| 1544 | + //$last_exec['phpvmacars'] = time(); |
|
| 1545 | + $last_exec[$id]['last'] = time(); |
|
| 1546 | 1546 | } elseif ($value['format'] === 'vaos' && |
| 1547 | - ( |
|
| 1547 | + ( |
|
| 1548 | 1548 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1549 | 1549 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1550 | - ) |
|
| 1550 | + ) |
|
| 1551 | 1551 | ) { |
| 1552 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1553 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1554 | - $buffer = $Common->getData($value['host']); |
|
| 1555 | - $all_data = json_decode($buffer,true); |
|
| 1556 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
| 1552 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1553 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1554 | + $buffer = $Common->getData($value['host']); |
|
| 1555 | + $all_data = json_decode($buffer,true); |
|
| 1556 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
| 1557 | 1557 | $reset = 0; |
| 1558 | 1558 | foreach ($all_data['ACARSData'] as $line) { |
| 1559 | - //print_r($line); |
|
| 1560 | - $data = array(); |
|
| 1561 | - //$data['id'] = $line['id']; // id not usable |
|
| 1562 | - $data['id'] = $line['id']; |
|
| 1563 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1564 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1565 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1566 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1567 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1568 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1569 | - $data['speed'] = $line['groundspeed']; // speed |
|
| 1570 | - $data['heading'] = $line['heading']; // heading |
|
| 1571 | - $data['latitude'] = $line['lat']; // lat |
|
| 1572 | - $data['longitude'] = $line['lon']; // long |
|
| 1573 | - //$data['verticalrate'] = ''; // verticale rate |
|
| 1574 | - //$data['squawk'] = ''; // squawk |
|
| 1575 | - //$data['emergency'] = ''; // emergency |
|
| 1576 | - if (isset($value['timezone'])) { |
|
| 1577 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1578 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1579 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1580 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1559 | + //print_r($line); |
|
| 1560 | + $data = array(); |
|
| 1561 | + //$data['id'] = $line['id']; // id not usable |
|
| 1562 | + $data['id'] = $line['id']; |
|
| 1563 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1564 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1565 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1566 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1567 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1568 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1569 | + $data['speed'] = $line['groundspeed']; // speed |
|
| 1570 | + $data['heading'] = $line['heading']; // heading |
|
| 1571 | + $data['latitude'] = $line['lat']; // lat |
|
| 1572 | + $data['longitude'] = $line['lon']; // long |
|
| 1573 | + //$data['verticalrate'] = ''; // verticale rate |
|
| 1574 | + //$data['squawk'] = ''; // squawk |
|
| 1575 | + //$data['emergency'] = ''; // emergency |
|
| 1576 | + if (isset($value['timezone'])) { |
|
| 1577 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1578 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1579 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1580 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1581 | 1581 | |
| 1582 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
| 1583 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
| 1584 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
| 1585 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
| 1586 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
| 1582 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
| 1583 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
| 1584 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
| 1585 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
| 1586 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
| 1587 | 1587 | |
| 1588 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1589 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1590 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
| 1588 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1589 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1590 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
| 1591 | 1591 | |
| 1592 | - $data['id_source'] = $id_source; |
|
| 1593 | - $data['format_source'] = 'vaos'; |
|
| 1594 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1595 | - $SI->add($data); |
|
| 1596 | - unset($data); |
|
| 1592 | + $data['id_source'] = $id_source; |
|
| 1593 | + $data['format_source'] = 'vaos'; |
|
| 1594 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1595 | + $SI->add($data); |
|
| 1596 | + unset($data); |
|
| 1597 | 1597 | } |
| 1598 | 1598 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1599 | 1599 | unset($buffer); |
| 1600 | 1600 | unset($all_data); |
| 1601 | - } |
|
| 1602 | - //$last_exec['phpvmacars'] = time(); |
|
| 1603 | - $last_exec[$id]['last'] = time(); |
|
| 1601 | + } |
|
| 1602 | + //$last_exec['phpvmacars'] = time(); |
|
| 1603 | + $last_exec[$id]['last'] = time(); |
|
| 1604 | 1604 | } elseif ($value['format'] === 'vam' && |
| 1605 | - ( |
|
| 1605 | + ( |
|
| 1606 | 1606 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1607 | 1607 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1608 | - ) |
|
| 1608 | + ) |
|
| 1609 | 1609 | ) { |
| 1610 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1611 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1612 | - $buffer = $Common->getData($value['host']); |
|
| 1613 | - $all_data = json_decode($buffer,true); |
|
| 1614 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1610 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1611 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1612 | + $buffer = $Common->getData($value['host']); |
|
| 1613 | + $all_data = json_decode($buffer,true); |
|
| 1614 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1615 | 1615 | $reset = 0; |
| 1616 | 1616 | foreach ($all_data as $line) { |
| 1617 | - $data = array(); |
|
| 1618 | - //$data['id'] = $line['id']; // id not usable |
|
| 1619 | - $data['id'] = trim($line['flight_id']); |
|
| 1620 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1621 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 1622 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 1623 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 1624 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1625 | - $data['speed'] = $line['gs']; // speed |
|
| 1626 | - $data['heading'] = $line['heading']; // heading |
|
| 1627 | - $data['latitude'] = $line['latitude']; // lat |
|
| 1628 | - $data['longitude'] = $line['longitude']; // long |
|
| 1629 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1630 | - $data['squawk'] = ''; // squawk |
|
| 1631 | - $data['emergency'] = ''; // emergency |
|
| 1632 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1633 | - $data['last_update'] = $line['last_update']; |
|
| 1634 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1635 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 1636 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1637 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1638 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1639 | - //$data['registration'] = $line['aircraft']; |
|
| 1640 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1641 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 1642 | - $data['id_source'] = $id_source; |
|
| 1643 | - $data['format_source'] = 'vam'; |
|
| 1644 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1645 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1646 | - $SI->add($data); |
|
| 1647 | - unset($data); |
|
| 1617 | + $data = array(); |
|
| 1618 | + //$data['id'] = $line['id']; // id not usable |
|
| 1619 | + $data['id'] = trim($line['flight_id']); |
|
| 1620 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1621 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 1622 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 1623 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 1624 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1625 | + $data['speed'] = $line['gs']; // speed |
|
| 1626 | + $data['heading'] = $line['heading']; // heading |
|
| 1627 | + $data['latitude'] = $line['latitude']; // lat |
|
| 1628 | + $data['longitude'] = $line['longitude']; // long |
|
| 1629 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1630 | + $data['squawk'] = ''; // squawk |
|
| 1631 | + $data['emergency'] = ''; // emergency |
|
| 1632 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1633 | + $data['last_update'] = $line['last_update']; |
|
| 1634 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1635 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 1636 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1637 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1638 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1639 | + //$data['registration'] = $line['aircraft']; |
|
| 1640 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1641 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 1642 | + $data['id_source'] = $id_source; |
|
| 1643 | + $data['format_source'] = 'vam'; |
|
| 1644 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1645 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1646 | + $SI->add($data); |
|
| 1647 | + unset($data); |
|
| 1648 | 1648 | } |
| 1649 | 1649 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1650 | 1650 | unset($buffer); |
| 1651 | 1651 | unset($all_data); |
| 1652 | - } |
|
| 1653 | - //$last_exec['phpvmacars'] = time(); |
|
| 1654 | - $last_exec[$id]['last'] = time(); |
|
| 1652 | + } |
|
| 1653 | + //$last_exec['phpvmacars'] = time(); |
|
| 1654 | + $last_exec[$id]['last'] = time(); |
|
| 1655 | 1655 | } elseif ($value['format'] === 'blitzortung' && |
| 1656 | - ( |
|
| 1656 | + ( |
|
| 1657 | 1657 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1658 | 1658 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1659 | - ) |
|
| 1659 | + ) |
|
| 1660 | 1660 | ) { |
| 1661 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1662 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1663 | - $buffer = $Common->getData($value['host']); |
|
| 1664 | - $all_data = json_decode($buffer,true); |
|
| 1665 | - if ($buffer != '') { |
|
| 1661 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1662 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1663 | + $buffer = $Common->getData($value['host']); |
|
| 1664 | + $all_data = json_decode($buffer,true); |
|
| 1665 | + if ($buffer != '') { |
|
| 1666 | 1666 | $Source->deleteLocationBySource('blitzortung'); |
| 1667 | 1667 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 1668 | 1668 | $buffer = explode('\n',$buffer); |
| 1669 | 1669 | foreach ($buffer as $buffer_line) { |
| 1670 | - $line = json_decode($buffer_line,true); |
|
| 1671 | - if (isset($line['time'])) { |
|
| 1670 | + $line = json_decode($buffer_line,true); |
|
| 1671 | + if (isset($line['time'])) { |
|
| 1672 | 1672 | $data = array(); |
| 1673 | 1673 | $data['altitude'] = $line['alt']; // altitude |
| 1674 | 1674 | $data['latitude'] = $line['lat']; // lat |
@@ -1680,92 +1680,92 @@ discard block |
||
| 1680 | 1680 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1681 | 1681 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1682 | 1682 | unset($data); |
| 1683 | - } |
|
| 1683 | + } |
|
| 1684 | 1684 | } |
| 1685 | 1685 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1686 | 1686 | unset($buffer); |
| 1687 | - } |
|
| 1688 | - $last_exec[$id]['last'] = time(); |
|
| 1687 | + } |
|
| 1688 | + $last_exec[$id]['last'] = time(); |
|
| 1689 | 1689 | } elseif ($value['format'] === 'acarsjson') { |
| 1690 | - $arr = $httpfeeds; |
|
| 1691 | - $w = $e = null; |
|
| 1692 | - if (isset($arr[$id])) { |
|
| 1693 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 1694 | - if ($nn > 0) { |
|
| 1695 | - foreach ($httpfeeds as $feed) { |
|
| 1696 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 1697 | - if ($buffer === FALSE) { |
|
| 1698 | - connect_all($globalSources); |
|
| 1699 | - } |
|
| 1700 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1701 | - $buffer = explode('\n',$buffer); |
|
| 1702 | - foreach ($buffer as $line) { |
|
| 1703 | - if ($line != '') { |
|
| 1704 | - $line = json_decode($line, true); |
|
| 1705 | - if (!empty($line)) { |
|
| 1706 | - $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
| 1707 | - $ACARS->deleteLiveAcarsData(); |
|
| 1708 | - } |
|
| 1709 | - } |
|
| 1710 | - } |
|
| 1711 | - } |
|
| 1712 | - } else { |
|
| 1713 | - $format = $value['format']; |
|
| 1714 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1715 | - else $tt[$format] = 0; |
|
| 1716 | - if ($tt[$format] > 30) { |
|
| 1717 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 1718 | - sleep(2); |
|
| 1719 | - //$sourceeen[] = $value; |
|
| 1720 | - //connect_all($sourceeen); |
|
| 1721 | - //$sourceeen = array(); |
|
| 1722 | - connect_all($globalSources); |
|
| 1723 | - } |
|
| 1724 | - } |
|
| 1725 | - } |
|
| 1690 | + $arr = $httpfeeds; |
|
| 1691 | + $w = $e = null; |
|
| 1692 | + if (isset($arr[$id])) { |
|
| 1693 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
| 1694 | + if ($nn > 0) { |
|
| 1695 | + foreach ($httpfeeds as $feed) { |
|
| 1696 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
| 1697 | + if ($buffer === FALSE) { |
|
| 1698 | + connect_all($globalSources); |
|
| 1699 | + } |
|
| 1700 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1701 | + $buffer = explode('\n',$buffer); |
|
| 1702 | + foreach ($buffer as $line) { |
|
| 1703 | + if ($line != '') { |
|
| 1704 | + $line = json_decode($line, true); |
|
| 1705 | + if (!empty($line)) { |
|
| 1706 | + $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
| 1707 | + $ACARS->deleteLiveAcarsData(); |
|
| 1708 | + } |
|
| 1709 | + } |
|
| 1710 | + } |
|
| 1711 | + } |
|
| 1712 | + } else { |
|
| 1713 | + $format = $value['format']; |
|
| 1714 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1715 | + else $tt[$format] = 0; |
|
| 1716 | + if ($tt[$format] > 30) { |
|
| 1717 | + if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 1718 | + sleep(2); |
|
| 1719 | + //$sourceeen[] = $value; |
|
| 1720 | + //connect_all($sourceeen); |
|
| 1721 | + //$sourceeen = array(); |
|
| 1722 | + connect_all($globalSources); |
|
| 1723 | + } |
|
| 1724 | + } |
|
| 1725 | + } |
|
| 1726 | 1726 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
| 1727 | 1727 | } elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarsjsonudp' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') { |
| 1728 | - //$last_exec[$id]['last'] = time(); |
|
| 1729 | - //$read = array( $sockets[$id] ); |
|
| 1730 | - $read = $sockets; |
|
| 1731 | - $write = NULL; |
|
| 1732 | - $e = NULL; |
|
| 1733 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 1734 | - if ($e != NULL) var_dump($e); |
|
| 1735 | - if ($n > 0) { |
|
| 1728 | + //$last_exec[$id]['last'] = time(); |
|
| 1729 | + //$read = array( $sockets[$id] ); |
|
| 1730 | + $read = $sockets; |
|
| 1731 | + $write = NULL; |
|
| 1732 | + $e = NULL; |
|
| 1733 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 1734 | + if ($e != NULL) var_dump($e); |
|
| 1735 | + if ($n > 0) { |
|
| 1736 | 1736 | $reset = 0; |
| 1737 | 1737 | foreach ($read as $nb => $r) { |
| 1738 | - //$value = $formats[$nb]; |
|
| 1739 | - $format = $globalSources[$nb]['format']; |
|
| 1740 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
| 1738 | + //$value = $formats[$nb]; |
|
| 1739 | + $format = $globalSources[$nb]['format']; |
|
| 1740 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
| 1741 | 1741 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
| 1742 | - } elseif ($format === 'vrstcp') { |
|
| 1742 | + } elseif ($format === 'vrstcp') { |
|
| 1743 | 1743 | $buffer = @socket_read($r, 6000); |
| 1744 | - } else { |
|
| 1744 | + } else { |
|
| 1745 | 1745 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
| 1746 | - } |
|
| 1747 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1748 | - //echo $buffer."\n"; |
|
| 1749 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1750 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1751 | - $error = false; |
|
| 1752 | - //$SI::del(); |
|
| 1753 | - if ($buffer !== FALSE) { |
|
| 1746 | + } |
|
| 1747 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1748 | + //echo $buffer."\n"; |
|
| 1749 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1750 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1751 | + $error = false; |
|
| 1752 | + //$SI::del(); |
|
| 1753 | + if ($buffer !== FALSE) { |
|
| 1754 | 1754 | if ($format === 'vrstcp') { |
| 1755 | - $buffer = explode('},{',$buffer); |
|
| 1755 | + $buffer = explode('},{',$buffer); |
|
| 1756 | 1756 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
| 1757 | - } |
|
| 1758 | - // SBS format is CSV format |
|
| 1759 | - if ($buffer !== FALSE && $buffer !== '') { |
|
| 1757 | + } |
|
| 1758 | + // SBS format is CSV format |
|
| 1759 | + if ($buffer !== FALSE && $buffer !== '') { |
|
| 1760 | 1760 | $tt[$format] = 0; |
| 1761 | 1761 | if ($format === 'acarssbs3') { |
| 1762 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1763 | - $ACARS->add(trim($buffer)); |
|
| 1764 | - $ACARS->deleteLiveAcarsData(); |
|
| 1762 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1763 | + $ACARS->add(trim($buffer)); |
|
| 1764 | + $ACARS->deleteLiveAcarsData(); |
|
| 1765 | 1765 | } elseif ($format === 'raw') { |
| 1766 | - // AVR format |
|
| 1767 | - $data = $SBS->parse($buffer); |
|
| 1768 | - if (is_array($data)) { |
|
| 1766 | + // AVR format |
|
| 1767 | + $data = $SBS->parse($buffer); |
|
| 1768 | + if (is_array($data)) { |
|
| 1769 | 1769 | //if (!empty($data)) print_r($data); |
| 1770 | 1770 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1771 | 1771 | $data['format_source'] = 'raw'; |
@@ -1775,39 +1775,39 @@ discard block |
||
| 1775 | 1775 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1776 | 1776 | $SI->add($data); |
| 1777 | 1777 | unset($data); |
| 1778 | - } |
|
| 1778 | + } |
|
| 1779 | 1779 | } elseif ($format === 'ais') { |
| 1780 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1781 | - $data = array(); |
|
| 1782 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1783 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1784 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1785 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1786 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1787 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1788 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1789 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1790 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1791 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1792 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1793 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1794 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1795 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1796 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1797 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1780 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1781 | + $data = array(); |
|
| 1782 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1783 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1784 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1785 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1786 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1787 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1788 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1789 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1790 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1791 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1792 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1793 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1794 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1795 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1796 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1797 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1798 | 1798 | |
| 1799 | - if (isset($ais_data['timestamp'])) { |
|
| 1799 | + if (isset($ais_data['timestamp'])) { |
|
| 1800 | 1800 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 1801 | - } else { |
|
| 1801 | + } else { |
|
| 1802 | 1802 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1803 | - } |
|
| 1804 | - $data['format_source'] = 'aisnmea'; |
|
| 1805 | - $data['id_source'] = $id_source; |
|
| 1806 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 1807 | - unset($data); |
|
| 1808 | - } elseif ($format === 'flightgearsp') { |
|
| 1809 | - //echo $buffer."\n"; |
|
| 1810 | - if (strlen($buffer) > 5) { |
|
| 1803 | + } |
|
| 1804 | + $data['format_source'] = 'aisnmea'; |
|
| 1805 | + $data['id_source'] = $id_source; |
|
| 1806 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 1807 | + unset($data); |
|
| 1808 | + } elseif ($format === 'flightgearsp') { |
|
| 1809 | + //echo $buffer."\n"; |
|
| 1810 | + if (strlen($buffer) > 5) { |
|
| 1811 | 1811 | $line = explode(',',$buffer); |
| 1812 | 1812 | $data = array(); |
| 1813 | 1813 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1824,47 +1824,47 @@ discard block |
||
| 1824 | 1824 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1825 | 1825 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1826 | 1826 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1827 | - } |
|
| 1828 | - } elseif ($format === 'acars') { |
|
| 1829 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1830 | - $ACARS->add(trim($buffer)); |
|
| 1831 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1832 | - $ACARS->deleteLiveAcarsData(); |
|
| 1827 | + } |
|
| 1828 | + } elseif ($format === 'acars') { |
|
| 1829 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1830 | + $ACARS->add(trim($buffer)); |
|
| 1831 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1832 | + $ACARS->deleteLiveAcarsData(); |
|
| 1833 | 1833 | } elseif ($format === 'acarsjsonudp') { |
| 1834 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1835 | - $line = json_decode(trim($buffer), true); |
|
| 1836 | - if (!empty($line)) { |
|
| 1834 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1835 | + $line = json_decode(trim($buffer), true); |
|
| 1836 | + if (!empty($line)) { |
|
| 1837 | 1837 | $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
| 1838 | - $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
| 1839 | - $ACARS->deleteLiveAcarsData(); |
|
| 1840 | - } |
|
| 1841 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1838 | + $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
|
| 1839 | + $ACARS->deleteLiveAcarsData(); |
|
| 1840 | + } |
|
| 1841 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1842 | 1842 | } elseif ($format === 'flightgearmp') { |
| 1843 | - if (substr($buffer,0,1) != '#') { |
|
| 1843 | + if (substr($buffer,0,1) != '#') { |
|
| 1844 | 1844 | $data = array(); |
| 1845 | 1845 | //echo $buffer."\n"; |
| 1846 | 1846 | $line = explode(' ',$buffer); |
| 1847 | 1847 | if (count($line) === 11) { |
| 1848 | - $userserver = explode('@',$line[0]); |
|
| 1849 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1850 | - $data['ident'] = $userserver[0]; |
|
| 1851 | - $data['registration'] = $userserver[0]; |
|
| 1852 | - $data['latitude'] = $line[4]; |
|
| 1853 | - $data['longitude'] = $line[5]; |
|
| 1854 | - $data['altitude'] = $line[6]; |
|
| 1855 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1856 | - $aircraft_type = $line[10]; |
|
| 1857 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1858 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1859 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1860 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1848 | + $userserver = explode('@',$line[0]); |
|
| 1849 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1850 | + $data['ident'] = $userserver[0]; |
|
| 1851 | + $data['registration'] = $userserver[0]; |
|
| 1852 | + $data['latitude'] = $line[4]; |
|
| 1853 | + $data['longitude'] = $line[5]; |
|
| 1854 | + $data['altitude'] = $line[6]; |
|
| 1855 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1856 | + $aircraft_type = $line[10]; |
|
| 1857 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1858 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1859 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1860 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1861 | + } |
|
| 1861 | 1862 | } |
| 1862 | - } |
|
| 1863 | 1863 | } elseif ($format === 'beast') { |
| 1864 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1865 | - die; |
|
| 1864 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1865 | + die; |
|
| 1866 | 1866 | } elseif ($format === 'vrstcp') { |
| 1867 | - foreach($buffer as $all_data) { |
|
| 1867 | + foreach($buffer as $all_data) { |
|
| 1868 | 1868 | $line = json_decode('{'.$all_data.'}',true); |
| 1869 | 1869 | $data = array(); |
| 1870 | 1870 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1884,158 +1884,158 @@ discard block |
||
| 1884 | 1884 | */ |
| 1885 | 1885 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1886 | 1886 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
| 1887 | - $data['format_source'] = 'vrstcp'; |
|
| 1887 | + $data['format_source'] = 'vrstcp'; |
|
| 1888 | 1888 | $data['id_source'] = $id_source; |
| 1889 | 1889 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1890 | 1890 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1891 | 1891 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1892 | 1892 | unset($data); |
| 1893 | - } |
|
| 1893 | + } |
|
| 1894 | 1894 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
| 1895 | - $line = explode("\t", $buffer); |
|
| 1896 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1895 | + $line = explode("\t", $buffer); |
|
| 1896 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1897 | 1897 | $key = $line[$k]; |
| 1898 | - $lined[$key] = $line[$k+1]; |
|
| 1899 | - } |
|
| 1900 | - if (count($lined) > 3) { |
|
| 1901 | - $data['hex'] = $lined['hexid']; |
|
| 1902 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1903 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1904 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1905 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1906 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1907 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1908 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1909 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1910 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1911 | - $data['id_source'] = $id_source; |
|
| 1912 | - $data['format_source'] = 'tsv'; |
|
| 1913 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1914 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1898 | + $lined[$key] = $line[$k+1]; |
|
| 1899 | + } |
|
| 1900 | + if (count($lined) > 3) { |
|
| 1901 | + $data['hex'] = $lined['hexid']; |
|
| 1902 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1903 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1904 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1905 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1906 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1907 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1908 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1909 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1910 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1911 | + $data['id_source'] = $id_source; |
|
| 1912 | + $data['format_source'] = 'tsv'; |
|
| 1913 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1914 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1915 | 1915 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1916 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1917 | - unset($lined); |
|
| 1918 | - unset($data); |
|
| 1919 | - } else $error = true; |
|
| 1916 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1917 | + unset($lined); |
|
| 1918 | + unset($data); |
|
| 1919 | + } else $error = true; |
|
| 1920 | 1920 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1921 | - if ($aprs_connect === 0) { |
|
| 1921 | + if ($aprs_connect === 0) { |
|
| 1922 | 1922 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 1923 | 1923 | $aprs_connect = 1; |
| 1924 | - } |
|
| 1924 | + } |
|
| 1925 | 1925 | |
| 1926 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1926 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1927 | 1927 | $aprs_last_tx = time(); |
| 1928 | 1928 | $data_aprs = "# Keep alive"; |
| 1929 | 1929 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1930 | - } |
|
| 1930 | + } |
|
| 1931 | 1931 | |
| 1932 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1933 | - //echo 'APRS data : '.$buffer."\n"; |
|
| 1934 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1935 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1936 | - //echo $buffer."\n"; |
|
| 1937 | - date_default_timezone_set('UTC'); |
|
| 1938 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1932 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1933 | + //echo 'APRS data : '.$buffer."\n"; |
|
| 1934 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1935 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1936 | + //echo $buffer."\n"; |
|
| 1937 | + date_default_timezone_set('UTC'); |
|
| 1938 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1939 | 1939 | $line = $APRS->parse($buffer); |
| 1940 | 1940 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1941 | 1941 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
| 1942 | - $aprs_last_tx = time(); |
|
| 1943 | - $data = array(); |
|
| 1944 | - //print_r($line); |
|
| 1945 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1946 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1947 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1948 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1949 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1950 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1951 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1952 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1953 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1954 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1955 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1956 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1957 | - $data['latitude'] = $line['latitude']; |
|
| 1958 | - $data['longitude'] = $line['longitude']; |
|
| 1959 | - //$data['verticalrate'] = $line[16]; |
|
| 1960 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1961 | - //else $data['speed'] = 0; |
|
| 1962 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1963 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1964 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1965 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1942 | + $aprs_last_tx = time(); |
|
| 1943 | + $data = array(); |
|
| 1944 | + //print_r($line); |
|
| 1945 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1946 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1947 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1948 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1949 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1950 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1951 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1952 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1953 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1954 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1955 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1956 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1957 | + $data['latitude'] = $line['latitude']; |
|
| 1958 | + $data['longitude'] = $line['longitude']; |
|
| 1959 | + //$data['verticalrate'] = $line[16]; |
|
| 1960 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1961 | + //else $data['speed'] = 0; |
|
| 1962 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1963 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1964 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1965 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1966 | 1966 | |
| 1967 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1968 | - //else echo 'No heading...'."\n"; |
|
| 1969 | - //else $data['heading'] = 0; |
|
| 1970 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1971 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1972 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1973 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1974 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1975 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1976 | - $data['id_source'] = $id_source; |
|
| 1977 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1978 | - else $data['format_source'] = 'aprs'; |
|
| 1979 | - $data['source_name'] = $line['source']; |
|
| 1980 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1981 | - else $data['source_type'] = 'flarm'; |
|
| 1982 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1983 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 1984 | - $aprsdate = strtotime($data['datetime']); |
|
| 1985 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1986 | - // Accept data if time <= system time + 20s |
|
| 1987 | - //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'])))) { |
|
| 1988 | - if ( |
|
| 1967 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1968 | + //else echo 'No heading...'."\n"; |
|
| 1969 | + //else $data['heading'] = 0; |
|
| 1970 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1971 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1972 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1973 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1974 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1975 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1976 | + $data['id_source'] = $id_source; |
|
| 1977 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1978 | + else $data['format_source'] = 'aprs'; |
|
| 1979 | + $data['source_name'] = $line['source']; |
|
| 1980 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1981 | + else $data['source_type'] = 'flarm'; |
|
| 1982 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1983 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 1984 | + $aprsdate = strtotime($data['datetime']); |
|
| 1985 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1986 | + // Accept data if time <= system time + 20s |
|
| 1987 | + //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'])))) { |
|
| 1988 | + if ( |
|
| 1989 | 1989 | ($data['source_type'] === 'modes') || |
| 1990 | 1990 | isset($line['stealth']) && |
| 1991 | 1991 | (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && |
| 1992 | 1992 | ($line['stealth'] === 0 || $line['stealth'] == '') && |
| 1993 | 1993 | (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1994 | 1994 | $send = $SI->add($data); |
| 1995 | - } elseif ($data['source_type'] === 'ais') { |
|
| 1995 | + } elseif ($data['source_type'] === 'ais') { |
|
| 1996 | 1996 | $data['type'] = ''; |
| 1997 | 1997 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
| 1998 | - } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
| 1998 | + } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
| 1999 | 1999 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 2000 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 2001 | - //$line['symbol'] === 'Balloon' || |
|
| 2002 | - $line['symbol'] === 'Glider' || |
|
| 2003 | - $line['symbol'] === 'No. Plane' || |
|
| 2004 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
| 2005 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 2006 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2007 | - $send = $SI->add($data); |
|
| 2008 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 2009 | - $line['symbol'] === 'Yacht (Sail)' || |
|
| 2010 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
| 2011 | - $send = $MI->add($data); |
|
| 2012 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 2013 | - $line['symbol'] === 'Car' || |
|
| 2014 | - $line['symbol'] === 'Ambulance' || |
|
| 2015 | - $line['symbol'] === 'Van' || |
|
| 2016 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
| 2017 | - $line['symbol'] === 'Motorcycle' || |
|
| 2018 | - $line['symbol'] === 'Tractor' || |
|
| 2019 | - $line['symbol'] === 'Police' || |
|
| 2020 | - $line['symbol'] === 'Bike' || |
|
| 2021 | - $line['symbol'] === 'Jogger' || |
|
| 2022 | - $line['symbol'] === 'Horse' || |
|
| 2023 | - $line['symbol'] === 'Bus' || |
|
| 2024 | - $line['symbol'] === 'Jeep' || |
|
| 2025 | - $line['symbol'] === 'Recreational Vehicle' || |
|
| 2026 | - $line['symbol'] === 'Yacht (Sail)' || |
|
| 2027 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
| 2028 | - $line['symbol'] === 'Firetruck' || |
|
| 2029 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
| 2030 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
| 2031 | - $line['symbol'] === 'SUV' || |
|
| 2032 | - $line['symbol'] === 'Snowmobile' || |
|
| 2033 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
| 2034 | - //} 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') { |
|
| 2000 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 2001 | + //$line['symbol'] === 'Balloon' || |
|
| 2002 | + $line['symbol'] === 'Glider' || |
|
| 2003 | + $line['symbol'] === 'No. Plane' || |
|
| 2004 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
| 2005 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 2006 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2007 | + $send = $SI->add($data); |
|
| 2008 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 2009 | + $line['symbol'] === 'Yacht (Sail)' || |
|
| 2010 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
| 2011 | + $send = $MI->add($data); |
|
| 2012 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 2013 | + $line['symbol'] === 'Car' || |
|
| 2014 | + $line['symbol'] === 'Ambulance' || |
|
| 2015 | + $line['symbol'] === 'Van' || |
|
| 2016 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
| 2017 | + $line['symbol'] === 'Motorcycle' || |
|
| 2018 | + $line['symbol'] === 'Tractor' || |
|
| 2019 | + $line['symbol'] === 'Police' || |
|
| 2020 | + $line['symbol'] === 'Bike' || |
|
| 2021 | + $line['symbol'] === 'Jogger' || |
|
| 2022 | + $line['symbol'] === 'Horse' || |
|
| 2023 | + $line['symbol'] === 'Bus' || |
|
| 2024 | + $line['symbol'] === 'Jeep' || |
|
| 2025 | + $line['symbol'] === 'Recreational Vehicle' || |
|
| 2026 | + $line['symbol'] === 'Yacht (Sail)' || |
|
| 2027 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
| 2028 | + $line['symbol'] === 'Firetruck' || |
|
| 2029 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
| 2030 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
| 2031 | + $line['symbol'] === 'SUV' || |
|
| 2032 | + $line['symbol'] === 'Snowmobile' || |
|
| 2033 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
| 2034 | + //} 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') { |
|
| 2035 | 2035 | // } 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') { |
| 2036 | 2036 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 2037 | 2037 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
| 2038 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 2038 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 2039 | 2039 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 2040 | 2040 | $Source->deleteOldLocationByType('gs'); |
| 2041 | 2041 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -2043,7 +2043,7 @@ discard block |
||
| 2043 | 2043 | } else { |
| 2044 | 2044 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
| 2045 | 2045 | } |
| 2046 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
| 2046 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
| 2047 | 2047 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2048 | 2048 | if ($globalDebug) echo '# Weather Station added'."\n"; |
| 2049 | 2049 | $Source->deleteOldLocationByType('wx'); |
@@ -2053,7 +2053,7 @@ discard block |
||
| 2053 | 2053 | } else { |
| 2054 | 2054 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
| 2055 | 2055 | } |
| 2056 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
| 2056 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
| 2057 | 2057 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2058 | 2058 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 2059 | 2059 | $Source->deleteOldLocationByType('lightning'); |
@@ -2062,11 +2062,11 @@ discard block |
||
| 2062 | 2062 | } else { |
| 2063 | 2063 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
| 2064 | 2064 | } |
| 2065 | - } elseif ($globalDebug) { |
|
| 2066 | - echo '/!\ Not added: '.$buffer."\n"; |
|
| 2067 | - print_r($line); |
|
| 2068 | - } |
|
| 2069 | - unset($data); |
|
| 2065 | + } elseif ($globalDebug) { |
|
| 2066 | + echo '/!\ Not added: '.$buffer."\n"; |
|
| 2067 | + print_r($line); |
|
| 2068 | + } |
|
| 2069 | + unset($data); |
|
| 2070 | 2070 | } |
| 2071 | 2071 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
| 2072 | 2072 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -2085,13 +2085,13 @@ discard block |
||
| 2085 | 2085 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
| 2086 | 2086 | $globalSources[$nb]['last_weather_clean'] = time(); |
| 2087 | 2087 | } |
| 2088 | - } |
|
| 2088 | + } |
|
| 2089 | 2089 | } else { |
| 2090 | - $line = explode(',', $buffer); |
|
| 2091 | - //print_r($line); |
|
| 2092 | - if (count($line) > 20) { |
|
| 2093 | - $data['hex'] = $line[4]; |
|
| 2094 | - /* |
|
| 2090 | + $line = explode(',', $buffer); |
|
| 2091 | + //print_r($line); |
|
| 2092 | + if (count($line) > 20) { |
|
| 2093 | + $data['hex'] = $line[4]; |
|
| 2094 | + /* |
|
| 2095 | 2095 | $data['datetime'] = $line[6].' '.$line[7]; |
| 2096 | 2096 | date_default_timezone_set($globalTimezone); |
| 2097 | 2097 | $datetime = new DateTime($data['datetime']); |
@@ -2099,31 +2099,31 @@ discard block |
||
| 2099 | 2099 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 2100 | 2100 | date_default_timezone_set('UTC'); |
| 2101 | 2101 | */ |
| 2102 | - // Force datetime to current UTC datetime |
|
| 2103 | - date_default_timezone_set('UTC'); |
|
| 2104 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2105 | - $data['ident'] = trim($line[10]); |
|
| 2106 | - $data['latitude'] = $line[14]; |
|
| 2107 | - $data['longitude'] = $line[15]; |
|
| 2108 | - $data['verticalrate'] = $line[16]; |
|
| 2109 | - $data['emergency'] = $line[20]; |
|
| 2110 | - $data['speed'] = $line[12]; |
|
| 2111 | - $data['squawk'] = $line[17]; |
|
| 2112 | - $data['altitude'] = $line[11]; |
|
| 2113 | - $data['heading'] = $line[13]; |
|
| 2114 | - $data['ground'] = $line[21]; |
|
| 2115 | - $data['emergency'] = $line[19]; |
|
| 2116 | - $data['format_source'] = 'sbs'; |
|
| 2102 | + // Force datetime to current UTC datetime |
|
| 2103 | + date_default_timezone_set('UTC'); |
|
| 2104 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2105 | + $data['ident'] = trim($line[10]); |
|
| 2106 | + $data['latitude'] = $line[14]; |
|
| 2107 | + $data['longitude'] = $line[15]; |
|
| 2108 | + $data['verticalrate'] = $line[16]; |
|
| 2109 | + $data['emergency'] = $line[20]; |
|
| 2110 | + $data['speed'] = $line[12]; |
|
| 2111 | + $data['squawk'] = $line[17]; |
|
| 2112 | + $data['altitude'] = $line[11]; |
|
| 2113 | + $data['heading'] = $line[13]; |
|
| 2114 | + $data['ground'] = $line[21]; |
|
| 2115 | + $data['emergency'] = $line[19]; |
|
| 2116 | + $data['format_source'] = 'sbs'; |
|
| 2117 | 2117 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 2118 | 2118 | elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
| 2119 | 2119 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 2120 | 2120 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 2121 | - $data['id_source'] = $id_source; |
|
| 2122 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 2123 | - else $error = true; |
|
| 2124 | - unset($data); |
|
| 2125 | - } else $error = true; |
|
| 2126 | - if ($error) { |
|
| 2121 | + $data['id_source'] = $id_source; |
|
| 2122 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 2123 | + else $error = true; |
|
| 2124 | + unset($data); |
|
| 2125 | + } else $error = true; |
|
| 2126 | + if ($error) { |
|
| 2127 | 2127 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 2128 | 2128 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 2129 | 2129 | } else { |
@@ -2139,13 +2139,13 @@ discard block |
||
| 2139 | 2139 | connect_all($sourceer); |
| 2140 | 2140 | $sourceer = array(); |
| 2141 | 2141 | } |
| 2142 | - } |
|
| 2142 | + } |
|
| 2143 | 2143 | } |
| 2144 | 2144 | // Sleep for xxx microseconds |
| 2145 | 2145 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 2146 | - } else { |
|
| 2146 | + } else { |
|
| 2147 | 2147 | if ($format === 'flightgearmp') { |
| 2148 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2148 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2149 | 2149 | //@socket_close($r); |
| 2150 | 2150 | sleep($globalMinFetch); |
| 2151 | 2151 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2154,9 +2154,9 @@ discard block |
||
| 2154 | 2154 | break; |
| 2155 | 2155 | |
| 2156 | 2156 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 2157 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 2158 | - else $tt[$format] = 0; |
|
| 2159 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 2157 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 2158 | + else $tt[$format] = 0; |
|
| 2159 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 2160 | 2160 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 2161 | 2161 | //@socket_close($r); |
| 2162 | 2162 | sleep(2); |
@@ -2167,24 +2167,24 @@ discard block |
||
| 2167 | 2167 | //connect_all($globalSources); |
| 2168 | 2168 | $tt[$format]=0; |
| 2169 | 2169 | break; |
| 2170 | - } |
|
| 2171 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 2170 | + } |
|
| 2171 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 2172 | + } |
|
| 2172 | 2173 | } |
| 2173 | - } |
|
| 2174 | 2174 | } |
| 2175 | - } else { |
|
| 2175 | + } else { |
|
| 2176 | 2176 | $error = socket_strerror(socket_last_error()); |
| 2177 | 2177 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2178 | 2178 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 2179 | 2179 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 2180 | 2180 | // Restart the script if possible |
| 2181 | 2181 | if (is_array($sockets)) { |
| 2182 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2182 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2183 | 2183 | |
| 2184 | - foreach ($sockets as $sock) { |
|
| 2184 | + foreach ($sockets as $sock) { |
|
| 2185 | 2185 | @socket_shutdown($sock,2); |
| 2186 | 2186 | @socket_close($sock); |
| 2187 | - } |
|
| 2187 | + } |
|
| 2188 | 2188 | |
| 2189 | 2189 | } |
| 2190 | 2190 | if ($globalDebug) echo "Waiting..."; |
@@ -2199,15 +2199,15 @@ discard block |
||
| 2199 | 2199 | if ($globalDebug) echo "Restart all connections..."; |
| 2200 | 2200 | connect_all($globalSources); |
| 2201 | 2201 | } |
| 2202 | - } |
|
| 2202 | + } |
|
| 2203 | 2203 | } |
| 2204 | 2204 | if ($globalDaemon === false) { |
| 2205 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2206 | - if (isset($SI)) $SI->checkAll(); |
|
| 2207 | - if (isset($TI)) $TI->checkAll(); |
|
| 2208 | - if (isset($MI)) $MI->checkAll(); |
|
| 2205 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2206 | + if (isset($SI)) $SI->checkAll(); |
|
| 2207 | + if (isset($TI)) $TI->checkAll(); |
|
| 2208 | + if (isset($MI)) $MI->checkAll(); |
|
| 2209 | + } |
|
| 2209 | 2210 | } |
| 2210 | - } |
|
| 2211 | 2211 | } |
| 2212 | 2212 | |
| 2213 | 2213 | ?> |
@@ -59,20 +59,20 @@ discard block |
||
| 59 | 59 | die; |
| 60 | 60 | } |
| 61 | 61 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 62 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
| 62 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
|
| 66 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine')); |
|
| 67 | 67 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 68 | 68 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 69 | 69 | if (isset($options['s'])) { |
| 70 | 70 | $globalSources = array(); |
| 71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 71 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
| 72 | 72 | else $globalSources[] = array('host' => $options['s']); |
| 73 | 73 | } elseif (isset($options['source'])) { |
| 74 | 74 | $globalSources = array(); |
| 75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 75 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
| 76 | 76 | else $globalSources[] = array('host' => $options['source']); |
| 77 | 77 | } |
| 78 | 78 | if (isset($options['aprsserverhost'])) { |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | else $id_source = 1; |
| 114 | 114 | if (isset($globalServer) && $globalServer) { |
| 115 | 115 | if ($globalDebug) echo "Using Server Mode\n"; |
| 116 | - $SI=new SpotterServer(); |
|
| 116 | + $SI = new SpotterServer(); |
|
| 117 | 117 | /* |
| 118 | 118 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 119 | 119 | $SI = new adsb2aprs(); |
| 120 | 120 | $SI->connect(); |
| 121 | 121 | */ |
| 122 | -} else $SI=new SpotterImport($Connection->db); |
|
| 122 | +} else $SI = new SpotterImport($Connection->db); |
|
| 123 | 123 | |
| 124 | 124 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 125 | 125 | if (isset($globalMarine) && $globalMarine) { |
@@ -133,17 +133,17 @@ discard block |
||
| 133 | 133 | $MI = new MarineImport($Connection->db); |
| 134 | 134 | } |
| 135 | 135 | //$APRS=new APRS($Connection->db); |
| 136 | -$SBS=new SBS(); |
|
| 136 | +$SBS = new SBS(); |
|
| 137 | 137 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 138 | - $ACARS=new ACARS($Connection->db,true); |
|
| 139 | - $Source=new Source($Connection->db); |
|
| 138 | + $ACARS = new ACARS($Connection->db, true); |
|
| 139 | + $Source = new Source($Connection->db); |
|
| 140 | 140 | } |
| 141 | -$Common=new Common(); |
|
| 141 | +$Common = new Common(); |
|
| 142 | 142 | date_default_timezone_set('UTC'); |
| 143 | 143 | //$servertz = system('date +%Z'); |
| 144 | 144 | // signal handler - playing nice with sockets and dump1090 |
| 145 | 145 | if (function_exists('pcntl_fork')) { |
| 146 | - pcntl_signal(SIGINT, function() { |
|
| 146 | + pcntl_signal(SIGINT, function() { |
|
| 147 | 147 | global $sockets; |
| 148 | 148 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 149 | 149 | die("Bye!\n"); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | function connect_all($hosts) { |
| 161 | 161 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 162 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 162 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
| 163 | 163 | $reset++; |
| 164 | 164 | if ($globalDebug) echo 'Connect to all...'."\n"; |
| 165 | 165 | foreach ($hosts as $id => $value) { |
@@ -167,33 +167,33 @@ discard block |
||
| 167 | 167 | $udp = false; |
| 168 | 168 | $globalSources[$id]['last_exec'] = 0; |
| 169 | 169 | // Here we check type of source(s) |
| 170 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 171 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 170 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 171 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
| 172 | 172 | //$formats[$id] = 'deltadbtxt'; |
| 173 | 173 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 174 | 174 | //$last_exec['deltadbtxt'] = 0; |
| 175 | 175 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 176 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 176 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 177 | 177 | //$formats[$id] = 'vatsimtxt'; |
| 178 | 178 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 179 | 179 | //$last_exec['vatsimtxt'] = 0; |
| 180 | 180 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 181 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 181 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 182 | 182 | //$formats[$id] = 'aircraftlistjson'; |
| 183 | 183 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 184 | 184 | //$last_exec['aircraftlistjson'] = 0; |
| 185 | 185 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 186 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
| 186 | + } else if (preg_match('/aircraft.json$/i', $host)) { |
|
| 187 | 187 | //$formats[$id] = 'aircraftjson'; |
| 188 | 188 | $globalSources[$id]['format'] = 'aircraftjson'; |
| 189 | 189 | //$last_exec['aircraftlistjson'] = 0; |
| 190 | 190 | if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
| 191 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
| 191 | + } else if (preg_match('/aircraft$/i', $host)) { |
|
| 192 | 192 | //$formats[$id] = 'planefinderclient'; |
| 193 | 193 | $globalSources[$id]['format'] = 'planefinderclient'; |
| 194 | 194 | //$last_exec['aircraftlistjson'] = 0; |
| 195 | 195 | if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
| 196 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 196 | + } else if (preg_match('/opensky/i', $host)) { |
|
| 197 | 197 | //$formats[$id] = 'aircraftlistjson'; |
| 198 | 198 | $globalSources[$id]['format'] = 'opensky'; |
| 199 | 199 | //$last_exec['aircraftlistjson'] = 0; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | exit(0); |
| 211 | 211 | } |
| 212 | 212 | */ |
| 213 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 213 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 214 | 214 | //$formats[$id] = 'planeupdatefaa'; |
| 215 | 215 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 216 | 216 | //$last_exec['planeupdatefaa'] = 0; |
@@ -219,37 +219,37 @@ discard block |
||
| 219 | 219 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 220 | 220 | exit(0); |
| 221 | 221 | } |
| 222 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 222 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 223 | 223 | //$formats[$id] = 'phpvmacars'; |
| 224 | 224 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 225 | 225 | //$last_exec['phpvmacars'] = 0; |
| 226 | 226 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 227 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
| 227 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) { |
|
| 228 | 228 | //$formats[$id] = 'phpvmacars'; |
| 229 | 229 | $globalSources[$id]['format'] = 'vaos'; |
| 230 | 230 | //$last_exec['phpvmacars'] = 0; |
| 231 | 231 | if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
| 232 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 232 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
| 233 | 233 | //$formats[$id] = 'phpvmacars'; |
| 234 | 234 | $globalSources[$id]['format'] = 'vam'; |
| 235 | 235 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
| 236 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 236 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 237 | 237 | //$formats[$id] = 'whazzup'; |
| 238 | 238 | $globalSources[$id]['format'] = 'whazzup'; |
| 239 | 239 | //$last_exec['whazzup'] = 0; |
| 240 | 240 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 241 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
| 241 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
| 242 | 242 | $globalSources[$id]['format'] = 'blitzortung'; |
| 243 | 243 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
| 244 | - } else if (preg_match('/airwhere/i',$host)) { |
|
| 244 | + } else if (preg_match('/airwhere/i', $host)) { |
|
| 245 | 245 | $globalSources[$id]['format'] = 'airwhere'; |
| 246 | 246 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
| 247 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 247 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 248 | 248 | //$formats[$id] = 'pirepsjson'; |
| 249 | 249 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 250 | 250 | //$last_exec['pirepsjson'] = 0; |
| 251 | 251 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 252 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 252 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 253 | 253 | //$formats[$id] = 'fr24json'; |
| 254 | 254 | $globalSources[$id]['format'] = 'fr24json'; |
| 255 | 255 | //$last_exec['fr24json'] = 0; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 259 | 259 | exit(0); |
| 260 | 260 | } |
| 261 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 261 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
| 262 | 262 | //$formats[$id] = 'fr24json'; |
| 263 | 263 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 264 | 264 | //$last_exec['fr24json'] = 0; |
@@ -268,14 +268,14 @@ discard block |
||
| 268 | 268 | exit(0); |
| 269 | 269 | } |
| 270 | 270 | //} else if (preg_match('/10001/',$host)) { |
| 271 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 271 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 272 | 272 | //$formats[$id] = 'tsv'; |
| 273 | 273 | $globalSources[$id]['format'] = 'tsv'; |
| 274 | 274 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 275 | 275 | } |
| 276 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
| 276 | + } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
| 277 | 277 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
| 278 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 278 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
| 279 | 279 | if ($idf !== false) { |
| 280 | 280 | $httpfeeds[$id] = $idf; |
| 281 | 281 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
| 284 | 284 | elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
| 285 | 285 | elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 286 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 287 | - $hostport = explode(':',$host); |
|
| 286 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 287 | + $hostport = explode(':', $host); |
|
| 288 | 288 | if (isset($hostport[1])) { |
| 289 | 289 | $port = $hostport[1]; |
| 290 | 290 | $hostn = $hostport[0]; |
@@ -294,20 +294,20 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | $Common = new Common(); |
| 296 | 296 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
| 297 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 297 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
| 298 | 298 | } else { |
| 299 | 299 | $udp = true; |
| 300 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 300 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
| 301 | 301 | } |
| 302 | 302 | if ($s) { |
| 303 | 303 | $sockets[$id] = $s; |
| 304 | 304 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 305 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 305 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
| 306 | 306 | //$formats[$id] = 'aprs'; |
| 307 | 307 | $globalSources[$id]['format'] = 'aprs'; |
| 308 | 308 | //$aprs_connect = 0; |
| 309 | 309 | //$use_aprs = true; |
| 310 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 310 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 311 | 311 | $globalSources[$id]['format'] = 'vrstcp'; |
| 312 | 312 | } elseif ($port == '10001') { |
| 313 | 313 | //$formats[$id] = 'tsv'; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 350 | 350 | else $timeout = 20; |
| 351 | 351 | $errno = ''; |
| 352 | -$errstr=''; |
|
| 352 | +$errstr = ''; |
|
| 353 | 353 | |
| 354 | 354 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 355 | 355 | /* Initiate connections to all the hosts simultaneously */ |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | //connect_all($globalSources); |
| 358 | 358 | |
| 359 | 359 | if (isset($globalProxy) && $globalProxy) { |
| 360 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 360 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
| 361 | 361 | } else { |
| 362 | 362 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
| 363 | 363 | } |
@@ -387,16 +387,16 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | if ($use_aprs) { |
| 389 | 389 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 390 | - $APRS=new APRS(); |
|
| 390 | + $APRS = new APRS(); |
|
| 391 | 391 | $aprs_connect = 0; |
| 392 | 392 | $aprs_keep = 120; |
| 393 | 393 | $aprs_last_tx = time(); |
| 394 | 394 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 395 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 395 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 396 | 396 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
| 397 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 397 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 398 | 398 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 399 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 399 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 400 | 400 | if ($aprs_full) $aprs_filter = ''; |
| 401 | 401 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
| 402 | 402 | else $aprs_pass = '-1'; |
@@ -410,12 +410,12 @@ discard block |
||
| 410 | 410 | sleep(1); |
| 411 | 411 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 412 | 412 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 413 | -$endtime = time()+$globalCronEnd; |
|
| 413 | +$endtime = time() + $globalCronEnd; |
|
| 414 | 414 | $i = 1; |
| 415 | 415 | $tt = array(); |
| 416 | 416 | // Delete all ATC |
| 417 | 417 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 418 | - $ATC=new ATC($Connection->db); |
|
| 418 | + $ATC = new ATC($Connection->db); |
|
| 419 | 419 | } |
| 420 | 420 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 421 | 421 | $ATC->deleteAll(); |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | while ($i > 0) { |
| 426 | 426 | if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
| 427 | 427 | |
| 428 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 428 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 429 | 429 | // Delete old ATC |
| 430 | 430 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 431 | 431 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | if ($max < $globalMinFetch) { |
| 441 | 441 | if ($globalDebug) echo 'Sleeping...'."\n"; |
| 442 | - sleep($globalMinFetch-$max+2); |
|
| 442 | + sleep($globalMinFetch - $max + 2); |
|
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | |
@@ -494,10 +494,10 @@ discard block |
||
| 494 | 494 | //$buffer = $Common->getData($hosts[$id]); |
| 495 | 495 | $buffer = $Common->getData($value['host']); |
| 496 | 496 | if ($buffer != '') { |
| 497 | - $all_data = json_decode($buffer,true); |
|
| 497 | + $all_data = json_decode($buffer, true); |
|
| 498 | 498 | foreach ($all_data as $line) { |
| 499 | 499 | $data = array(); |
| 500 | - $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
| 500 | + $data['datetime'] = date('Y-m-d H:i:s', $line['uti']); |
|
| 501 | 501 | $data['hex'] = $line['hex']; // hex |
| 502 | 502 | $data['ident'] = $line['fli']; // ident |
| 503 | 503 | $data['altitude'] = $line['alt']; // altitude |
@@ -532,11 +532,11 @@ discard block |
||
| 532 | 532 | ) |
| 533 | 533 | ) { |
| 534 | 534 | date_default_timezone_set('CET'); |
| 535 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 535 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
| 536 | 536 | date_default_timezone_set('UTC'); |
| 537 | 537 | if ($buffer != '') $reset = 0; |
| 538 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 539 | - $buffer = explode('\n',$buffer); |
|
| 538 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 539 | + $buffer = explode('\n', $buffer); |
|
| 540 | 540 | foreach ($buffer as $line) { |
| 541 | 541 | if ($line != '') { |
| 542 | 542 | //echo "'".$line."'\n"; |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | $ais_data = $AIS->parse_line(trim($line)); |
| 545 | 545 | $data = array(); |
| 546 | 546 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
| 547 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 547 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
| 548 | 548 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
| 549 | 549 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
| 550 | 550 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 557 | 557 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 558 | 558 | if (isset($ais_data['timestamp'])) { |
| 559 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 559 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 560 | 560 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 561 | 561 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
| 562 | 562 | $add = true; |
@@ -579,21 +579,21 @@ discard block |
||
| 579 | 579 | $w = $e = null; |
| 580 | 580 | |
| 581 | 581 | if (isset($arr[$id])) { |
| 582 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 582 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
| 583 | 583 | if ($nn > 0) { |
| 584 | 584 | foreach ($httpfeeds as $feed) { |
| 585 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 585 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
| 586 | 586 | if ($buffer === FALSE) { |
| 587 | 587 | connect_all($globalSources); |
| 588 | 588 | } |
| 589 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 590 | - $buffer = explode('\n',$buffer); |
|
| 589 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 590 | + $buffer = explode('\n', $buffer); |
|
| 591 | 591 | foreach ($buffer as $line) { |
| 592 | 592 | if ($line != '') { |
| 593 | 593 | $ais_data = $AIS->parse_line(trim($line)); |
| 594 | 594 | $data = array(); |
| 595 | 595 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
| 596 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 596 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
| 597 | 597 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
| 598 | 598 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
| 599 | 599 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -605,9 +605,9 @@ discard block |
||
| 605 | 605 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 606 | 606 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 607 | 607 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 608 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 608 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 609 | 609 | if (isset($ais_data['timestamp'])) { |
| 610 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 610 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 611 | 611 | } else { |
| 612 | 612 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 613 | 613 | } |
@@ -639,10 +639,10 @@ discard block |
||
| 639 | 639 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 640 | 640 | ) |
| 641 | 641 | ) { |
| 642 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 642 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 643 | 643 | if ($buffer != '') { |
| 644 | 644 | //echo $buffer; |
| 645 | - $all_data = json_decode($buffer,true); |
|
| 645 | + $all_data = json_decode($buffer, true); |
|
| 646 | 646 | //print_r($all_data); |
| 647 | 647 | if (isset($all_data[0]['DATA'])) { |
| 648 | 648 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | $data['ident'] = $line['NAME']; |
| 652 | 652 | $data['mmsi'] = $line['MMSI']; |
| 653 | 653 | if (strlen($data['mmsi']) > 9) { |
| 654 | - $data['mmsi'] = substr($data['mmsi'],-9); |
|
| 654 | + $data['mmsi'] = substr($data['mmsi'], -9); |
|
| 655 | 655 | } |
| 656 | 656 | $data['speed'] = $line['SOG']; |
| 657 | 657 | $data['heading'] = $line['COG']; |
@@ -661,8 +661,8 @@ discard block |
||
| 661 | 661 | //$data['type_id'] = $line['TYPE']; |
| 662 | 662 | $data['imo'] = $line['IMO']; |
| 663 | 663 | if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
| 664 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 665 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 664 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV'])); |
|
| 665 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
| 666 | 666 | $data['format_source'] = 'myshiptracking'; |
| 667 | 667 | $data['id_source'] = $id_source; |
| 668 | 668 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -679,16 +679,16 @@ discard block |
||
| 679 | 679 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 680 | 680 | ) |
| 681 | 681 | ) { |
| 682 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 682 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
| 683 | 683 | if ($buffer != '') { |
| 684 | - $all_data = json_decode($buffer,true); |
|
| 684 | + $all_data = json_decode($buffer, true); |
|
| 685 | 685 | if (isset($all_data[0]['mmsi'])) { |
| 686 | 686 | foreach ($all_data as $line) { |
| 687 | 687 | if ($line != '') { |
| 688 | 688 | $data = array(); |
| 689 | 689 | $data['ident'] = $line['shipname']; |
| 690 | 690 | $data['callsign'] = $line['callsign']; |
| 691 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
| 691 | + $data['mmsi'] = substr($line['mmsi'], -9); |
|
| 692 | 692 | $data['speed'] = $line['sog']; |
| 693 | 693 | if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
| 694 | 694 | $data['latitude'] = $line['latitude']; |
@@ -715,14 +715,14 @@ discard block |
||
| 715 | 715 | ) { |
| 716 | 716 | $buffer = $Common->getData($value['host']); |
| 717 | 717 | if ($buffer != '') { |
| 718 | - $all_data = json_decode($buffer,true); |
|
| 718 | + $all_data = json_decode($buffer, true); |
|
| 719 | 719 | if (isset($all_data['features'][0]['id'])) { |
| 720 | 720 | foreach ($all_data['features'] as $line) { |
| 721 | 721 | print_r($line); |
| 722 | 722 | $data = array(); |
| 723 | 723 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
| 724 | 724 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
| 725 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 725 | + if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9); |
|
| 726 | 726 | if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
| 727 | 727 | if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
| 728 | 728 | if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
@@ -749,31 +749,31 @@ discard block |
||
| 749 | 749 | ) |
| 750 | 750 | ) { |
| 751 | 751 | if ($globalDebug) echo 'download...'; |
| 752 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 752 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
| 753 | 753 | if ($globalDebug) echo 'done !'."\n"; |
| 754 | 754 | // FIXME: Need more work |
| 755 | 755 | if ($buffer != '') $reset = 0; |
| 756 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 757 | - $buffer = explode('\n',$buffer); |
|
| 756 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 757 | + $buffer = explode('\n', $buffer); |
|
| 758 | 758 | foreach ($buffer as $line) { |
| 759 | 759 | if ($line != '') { |
| 760 | 760 | $data = array(); |
| 761 | 761 | //echo $line."\n"; |
| 762 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 763 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 764 | - $data['status_id'] = substr($line,21,2); |
|
| 765 | - $data['type_id'] = substr($line,24,3); |
|
| 766 | - $data['latitude'] = substr($line,29,9); |
|
| 767 | - $data['longitude'] = substr($line,41,9); |
|
| 768 | - $data['speed'] = round(substr($line,51,5)); |
|
| 762 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
| 763 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
| 764 | + $data['status_id'] = substr($line, 21, 2); |
|
| 765 | + $data['type_id'] = substr($line, 24, 3); |
|
| 766 | + $data['latitude'] = substr($line, 29, 9); |
|
| 767 | + $data['longitude'] = substr($line, 41, 9); |
|
| 768 | + $data['speed'] = round(substr($line, 51, 5)); |
|
| 769 | 769 | //$data['course'] = substr($line,57,5); |
| 770 | - $data['heading'] = round(substr($line,63,3)); |
|
| 770 | + $data['heading'] = round(substr($line, 63, 3)); |
|
| 771 | 771 | //$data['draft'] = substr($line,67,4); |
| 772 | 772 | //$data['length'] = substr($line,72,3); |
| 773 | 773 | //$data['beam'] = substr($line,76,2); |
| 774 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
| 774 | + $data['ident'] = trim(utf8_encode(substr($line, 78, 20))); |
|
| 775 | 775 | //$data['callsign'] = trim(substr($line,100,7); |
| 776 | - $data['arrival_code'] = substr($line,108,20); |
|
| 776 | + $data['arrival_code'] = substr($line, 108, 20); |
|
| 777 | 777 | //$data['etaDate'] = substr($line,129,5); |
| 778 | 778 | //$data['etaTime'] = substr($line,135,5); |
| 779 | 779 | $data['format_source'] = 'shipplotter'; |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | ) |
| 793 | 793 | ) { |
| 794 | 794 | if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
| 795 | - $authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true); |
|
| 795 | + $authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true); |
|
| 796 | 796 | //echo $authsailaway; |
| 797 | 797 | preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie); |
| 798 | 798 | if (isset($setcookie[1][0])) { |
@@ -801,19 +801,19 @@ discard block |
||
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | if ($globalDebug) echo '! Download... '; |
| 804 | - for ($i =0; $i <= 1; $i++) { |
|
| 804 | + for ($i = 0; $i <= 1; $i++) { |
|
| 805 | 805 | if ($globalDebug) echo 'Racetype: '.$i.' '; |
| 806 | 806 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
| 807 | 807 | if ($globalDebug) echo 'done'."\n"; |
| 808 | 808 | if ($buffer != '') { |
| 809 | - $all_data = json_decode($buffer,true); |
|
| 809 | + $all_data = json_decode($buffer, true); |
|
| 810 | 810 | if (isset($all_data['missions'])) { |
| 811 | 811 | foreach ($all_data['missions'] as $mission) { |
| 812 | 812 | $mission_user = $mission['usrname']; |
| 813 | - $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
|
| 814 | - if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
|
| 813 | + $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle'])); |
|
| 814 | + if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) { |
|
| 815 | 815 | if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { |
| 816 | - $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
| 816 | + $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie); |
|
| 817 | 817 | sleep(30); |
| 818 | 818 | } else $racebuffer = ''; |
| 819 | 819 | $bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
@@ -822,19 +822,19 @@ discard block |
||
| 822 | 822 | $racebuffer = ''; |
| 823 | 823 | } |
| 824 | 824 | if ($racebuffer != '') { |
| 825 | - $race_data = json_decode($racebuffer,true); |
|
| 825 | + $race_data = json_decode($racebuffer, true); |
|
| 826 | 826 | //print_r($race_data); |
| 827 | 827 | unset($racebuffer); |
| 828 | 828 | if (isset($race_data['mission'])) { |
| 829 | 829 | $datar = array(); |
| 830 | 830 | $datar['id'] = $mission['misnr']; |
| 831 | 831 | $datar['desc'] = $race_data['mission']['misdescr']; |
| 832 | - $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); |
|
| 833 | - $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); |
|
| 832 | + $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname']))); |
|
| 833 | + $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle']))); |
|
| 834 | 834 | $datar['startdate'] = $race_data['mission']['misstartdatetime']; |
| 835 | 835 | $markers = array(); |
| 836 | 836 | foreach ($race_data['mission']['course'] as $course) { |
| 837 | - $markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']); |
|
| 837 | + $markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']); |
|
| 838 | 838 | } |
| 839 | 839 | $datar['markers'] = json_encode($markers); |
| 840 | 840 | //print_r($datar); |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | if ($bufferm != '') { |
| 845 | - $mission_data = json_decode($bufferm,true); |
|
| 845 | + $mission_data = json_decode($bufferm, true); |
|
| 846 | 846 | unset($bufferm); |
| 847 | 847 | if (isset($mission_data['leaderboard'][0]['results'])) { |
| 848 | 848 | foreach ($mission_data['leaderboard'][0]['results'] as $sail) { |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | //$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr']; |
| 856 | 856 | $data['id'] = $sail['misnr'].'-'.$sail['usrnr']; |
| 857 | 857 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 858 | - $data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart'])); |
|
| 858 | + $data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart'])); |
|
| 859 | 859 | $data['last_update'] = date('Y-m-d H:i:s'); |
| 860 | 860 | $data['status'] = $sail['status']; |
| 861 | 861 | $data['type'] = $sail['btptype']; |
@@ -866,16 +866,16 @@ discard block |
||
| 866 | 866 | $data['longitude'] = $pos['longitude']; |
| 867 | 867 | } |
| 868 | 868 | if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') { |
| 869 | - $resultdescr = explode(',',$sail['resultdescr']); |
|
| 869 | + $resultdescr = explode(',', $sail['resultdescr']); |
|
| 870 | 870 | if (count($resultdescr) > 2) { |
| 871 | - $data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2); |
|
| 872 | - $data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1])); |
|
| 871 | + $data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2); |
|
| 872 | + $data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1])); |
|
| 873 | 873 | if (isset($resultdescr[3])) { |
| 874 | - $data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3); |
|
| 874 | + $data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3); |
|
| 875 | 875 | } |
| 876 | 876 | } |
| 877 | 877 | } |
| 878 | - $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname']))); |
|
| 878 | + $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname']))); |
|
| 879 | 879 | $data['captain_id'] = $sail['usrnr']; |
| 880 | 880 | $data['captain_name'] = $sail['usrname']; |
| 881 | 881 | $data['race_id'] = $sail['misnr']; |
@@ -928,9 +928,9 @@ discard block |
||
| 928 | 928 | exit(0); |
| 929 | 929 | } |
| 930 | 930 | if ($globalDebug) echo '! Download... '; |
| 931 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key'],'get','','','','',30); |
|
| 931 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key'], 'get', '', '', '', '', 30); |
|
| 932 | 932 | if ($buffer != '') { |
| 933 | - $data = json_decode($buffer,true); |
|
| 933 | + $data = json_decode($buffer, true); |
|
| 934 | 934 | //print_r($data); |
| 935 | 935 | if (isset($data['boats'])) { |
| 936 | 936 | foreach ($data['boats'] as $sail) { |
@@ -942,12 +942,12 @@ discard block |
||
| 942 | 942 | $data['longitude'] = $sail['ubtlon']; |
| 943 | 943 | $data['type_id'] = 36; |
| 944 | 944 | $data['heading'] = $sail['ubtheading']; |
| 945 | - $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname']))); |
|
| 945 | + $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname']))); |
|
| 946 | 946 | $data['captain_name'] = $sail['usrname']; |
| 947 | - $allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat'); |
|
| 947 | + $allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52' Cruising Cat', '50' Performance Cruiser', 'Nordic Folkboat'); |
|
| 948 | 948 | $boattype = $sail['ubtbtpnr']; |
| 949 | - $data['type'] = $allboats[$boattype-1]; |
|
| 950 | - $data['speed'] = round($sail['ubtspeed']*3.6,2); |
|
| 949 | + $data['type'] = $allboats[$boattype - 1]; |
|
| 950 | + $data['speed'] = round($sail['ubtspeed']*3.6, 2); |
|
| 951 | 951 | $data['format_source'] = 'sailaway'; |
| 952 | 952 | $data['id_source'] = $id_source; |
| 953 | 953 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -975,8 +975,8 @@ discard block |
||
| 975 | 975 | ) { |
| 976 | 976 | //$buffer = $Common->getData($hosts[$id]); |
| 977 | 977 | $buffer = $Common->getData($value['host']); |
| 978 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 979 | - $buffer = explode('\n',$buffer); |
|
| 978 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 979 | + $buffer = explode('\n', $buffer); |
|
| 980 | 980 | $reset = 0; |
| 981 | 981 | foreach ($buffer as $line) { |
| 982 | 982 | if ($line != '') { |
@@ -987,7 +987,7 @@ discard block |
||
| 987 | 987 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 988 | 988 | $data['pilot_id'] = $line[1]; |
| 989 | 989 | $data['pilot_name'] = $line[2]; |
| 990 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
| 990 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
| 991 | 991 | $data['ident'] = $line[0]; // ident |
| 992 | 992 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 993 | 993 | $data['speed'] = $line[8]; // speed |
@@ -1003,7 +1003,7 @@ discard block |
||
| 1003 | 1003 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 1004 | 1004 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 1005 | 1005 | $data['departure_airport_icao'] = $line[11]; |
| 1006 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 1006 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 1007 | 1007 | $data['arrival_airport_icao'] = $line[13]; |
| 1008 | 1008 | $data['frequency'] = $line[4]; |
| 1009 | 1009 | $data['type'] = $line[18]; |
@@ -1012,7 +1012,7 @@ discard block |
||
| 1012 | 1012 | $data['id_source'] = $id_source; |
| 1013 | 1013 | //$data['arrival_airport_time'] = ; |
| 1014 | 1014 | if ($line[9] != '') { |
| 1015 | - $aircraft_data = explode('/',$line[9]); |
|
| 1015 | + $aircraft_data = explode('/', $line[9]); |
|
| 1016 | 1016 | if (isset($aircraft_data[1])) { |
| 1017 | 1017 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 1018 | 1018 | } |
@@ -1027,9 +1027,9 @@ discard block |
||
| 1027 | 1027 | if ($line[3] === 'PILOT') $SI->add($data); |
| 1028 | 1028 | elseif ($line[3] === 'ATC') { |
| 1029 | 1029 | //print_r($data); |
| 1030 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 1031 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 1032 | - $typec = substr($data['ident'],-3); |
|
| 1030 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 1031 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 1032 | + $typec = substr($data['ident'], -3); |
|
| 1033 | 1033 | if ($typec === 'APP') $data['type'] = 'Approach'; |
| 1034 | 1034 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
| 1035 | 1035 | elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
@@ -1041,8 +1041,8 @@ discard block |
||
| 1041 | 1041 | elseif ($data['type'] === '') $data['type'] = 'Observer'; |
| 1042 | 1042 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 1043 | 1043 | if (isset($ATC)) { |
| 1044 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($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']); |
|
| 1045 | - 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']); |
|
| 1044 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($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']); |
|
| 1045 | + 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']); |
|
| 1046 | 1046 | } |
| 1047 | 1047 | } |
| 1048 | 1048 | unset($data); |
@@ -1058,24 +1058,24 @@ discard block |
||
| 1058 | 1058 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1059 | 1059 | ) |
| 1060 | 1060 | ) { |
| 1061 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 1061 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
| 1062 | 1062 | if ($buffer != '') { |
| 1063 | 1063 | $all_data = simplexml_load_string($buffer); |
| 1064 | - foreach($all_data->children() as $childdata) { |
|
| 1064 | + foreach ($all_data->children() as $childdata) { |
|
| 1065 | 1065 | $data = array(); |
| 1066 | 1066 | $line = $childdata; |
| 1067 | 1067 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
| 1068 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
| 1069 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
| 1070 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
| 1071 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
| 1072 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 1073 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1074 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
| 1068 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
| 1069 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
| 1070 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
| 1071 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
| 1072 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
| 1073 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
| 1074 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
| 1075 | 1075 | $data['altitude_relative'] = 'AMSL'; |
| 1076 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
| 1076 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
| 1077 | 1077 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 1078 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
| 1078 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
| 1079 | 1079 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
| 1080 | 1080 | $data['format_source'] = $value['format']; |
| 1081 | 1081 | $SI->add($data); |
@@ -1083,22 +1083,22 @@ discard block |
||
| 1083 | 1083 | } |
| 1084 | 1084 | } |
| 1085 | 1085 | $Source->deleteOldLocationByType('gs'); |
| 1086 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 1086 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
| 1087 | 1087 | if ($buffer != '') { |
| 1088 | 1088 | $all_data = simplexml_load_string($buffer); |
| 1089 | - foreach($all_data->children() as $childdata) { |
|
| 1089 | + foreach ($all_data->children() as $childdata) { |
|
| 1090 | 1090 | $data = array(); |
| 1091 | 1091 | $line = $childdata; |
| 1092 | - $data['id'] = (int)$line['gsID']; |
|
| 1093 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
| 1094 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
| 1095 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
| 1092 | + $data['id'] = (int) $line['gsID']; |
|
| 1093 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
| 1094 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
| 1095 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
| 1096 | 1096 | $data['altitude_relative'] = 'AMSL'; |
| 1097 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
| 1097 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
| 1098 | 1098 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
| 1099 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
| 1099 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
| 1100 | 1100 | } else { |
| 1101 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
| 1101 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
| 1102 | 1102 | } |
| 1103 | 1103 | unset($data); |
| 1104 | 1104 | } |
@@ -1116,9 +1116,9 @@ discard block |
||
| 1116 | 1116 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1117 | 1117 | ) |
| 1118 | 1118 | ) { |
| 1119 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 1119 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 1120 | 1120 | if ($buffer != '') { |
| 1121 | - $all_data = json_decode($buffer,true); |
|
| 1121 | + $all_data = json_decode($buffer, true); |
|
| 1122 | 1122 | if (isset($all_data['acList'])) { |
| 1123 | 1123 | $reset = 0; |
| 1124 | 1124 | foreach ($all_data['acList'] as $line) { |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
| 1135 | 1135 | $data['emergency'] = ''; // emergency |
| 1136 | 1136 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
| 1137 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1137 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
| 1138 | 1138 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1139 | 1139 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1140 | 1140 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1160 | 1160 | $data['squawk'] = $line['squawk']; // squawk |
| 1161 | 1161 | $data['emergency'] = ''; // emergency |
| 1162 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1162 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
| 1163 | 1163 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1164 | 1164 | $data['format_source'] = 'aircraftlistjson'; |
| 1165 | 1165 | $data['id_source'] = $id_source; |
@@ -1180,7 +1180,7 @@ discard block |
||
| 1180 | 1180 | ) |
| 1181 | 1181 | ) { |
| 1182 | 1182 | $buffer = $Common->getData($value['host']); |
| 1183 | - $all_data = json_decode($buffer,true); |
|
| 1183 | + $all_data = json_decode($buffer, true); |
|
| 1184 | 1184 | if (isset($all_data['planes'])) { |
| 1185 | 1185 | $reset = 0; |
| 1186 | 1186 | foreach ($all_data['planes'] as $key => $line) { |
@@ -1197,12 +1197,12 @@ discard block |
||
| 1197 | 1197 | $data['emergency'] = ''; // emergency |
| 1198 | 1198 | $data['registration'] = $line[2]; |
| 1199 | 1199 | $data['aircraft_icao'] = $line[0]; |
| 1200 | - $deparr = explode('-',$line[1]); |
|
| 1200 | + $deparr = explode('-', $line[1]); |
|
| 1201 | 1201 | if (count($deparr) === 2) { |
| 1202 | 1202 | $data['departure_airport_icao'] = $deparr[0]; |
| 1203 | 1203 | $data['arrival_airport_icao'] = $deparr[1]; |
| 1204 | 1204 | } |
| 1205 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1205 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 1206 | 1206 | $data['format_source'] = 'planeupdatefaa'; |
| 1207 | 1207 | $data['id_source'] = $id_source; |
| 1208 | 1208 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1220,7 +1220,7 @@ discard block |
||
| 1220 | 1220 | ) |
| 1221 | 1221 | ) { |
| 1222 | 1222 | $buffer = $Common->getData($value['host']); |
| 1223 | - $all_data = json_decode($buffer,true); |
|
| 1223 | + $all_data = json_decode($buffer, true); |
|
| 1224 | 1224 | if (isset($all_data['states'])) { |
| 1225 | 1225 | $reset = 0; |
| 1226 | 1226 | foreach ($all_data['states'] as $key => $line) { |
@@ -1237,7 +1237,7 @@ discard block |
||
| 1237 | 1237 | //$data['emergency'] = ''; // emergency |
| 1238 | 1238 | //$data['registration'] = $line[2]; |
| 1239 | 1239 | //$data['aircraft_icao'] = $line[0]; |
| 1240 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1240 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 1241 | 1241 | $data['format_source'] = 'opensky'; |
| 1242 | 1242 | $data['id_source'] = $id_source; |
| 1243 | 1243 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1254,8 +1254,8 @@ discard block |
||
| 1254 | 1254 | ) |
| 1255 | 1255 | ) { |
| 1256 | 1256 | $buffer = $Common->getData($value['host']); |
| 1257 | - $all_data = json_decode($buffer,true); |
|
| 1258 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1257 | + $all_data = json_decode($buffer, true); |
|
| 1258 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) { |
|
| 1259 | 1259 | $reset = 0; |
| 1260 | 1260 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1261 | 1261 | $data = array(); |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | ) |
| 1294 | 1294 | ) { |
| 1295 | 1295 | $buffer = $Common->getData($value['host']); |
| 1296 | - $all_data = json_decode($buffer,true); |
|
| 1296 | + $all_data = json_decode($buffer, true); |
|
| 1297 | 1297 | if (isset($all_data['aircraft'])) { |
| 1298 | 1298 | $reset = 0; |
| 1299 | 1299 | foreach ($all_data['aircraft'] as $key => $line) { |
@@ -1310,7 +1310,7 @@ discard block |
||
| 1310 | 1310 | //$data['emergency'] = ''; // emergency |
| 1311 | 1311 | if (isset($line['reg'])) $data['registration'] = $line['reg']; |
| 1312 | 1312 | if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
| 1313 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1313 | + $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']); |
|
| 1314 | 1314 | $data['format_source'] = 'planefinderclient'; |
| 1315 | 1315 | $data['id_source'] = $id_source; |
| 1316 | 1316 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -1329,7 +1329,7 @@ discard block |
||
| 1329 | 1329 | ) { |
| 1330 | 1330 | //$buffer = $Common->getData($hosts[$id]); |
| 1331 | 1331 | $buffer = $Common->getData($value['host']); |
| 1332 | - $all_data = json_decode($buffer,true); |
|
| 1332 | + $all_data = json_decode($buffer, true); |
|
| 1333 | 1333 | if (!empty($all_data)) $reset = 0; |
| 1334 | 1334 | foreach ($all_data as $key => $line) { |
| 1335 | 1335 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1367,11 +1367,11 @@ discard block |
||
| 1367 | 1367 | ) |
| 1368 | 1368 | ) { |
| 1369 | 1369 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 1370 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1370 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 1371 | 1371 | //echo $buffer; |
| 1372 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1373 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1374 | - $all_data = json_decode($buffer,true); |
|
| 1372 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 1373 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 1374 | + $all_data = json_decode($buffer, true); |
|
| 1375 | 1375 | if (json_last_error() != JSON_ERROR_NONE) { |
| 1376 | 1376 | die(json_last_error_msg()); |
| 1377 | 1377 | } |
@@ -1394,7 +1394,7 @@ discard block |
||
| 1394 | 1394 | //$data['departure_airport_iata'] = $line[11]; |
| 1395 | 1395 | //$data['arrival_airport_iata'] = $line[12]; |
| 1396 | 1396 | //$data['emergency'] = ''; // emergency |
| 1397 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 1397 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 1398 | 1398 | $data['format_source'] = 'radarvirtueljson'; |
| 1399 | 1399 | $data['id_source'] = $id_source; |
| 1400 | 1400 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1415,14 +1415,14 @@ discard block |
||
| 1415 | 1415 | ) { |
| 1416 | 1416 | //$buffer = $Common->getData($hosts[$id]); |
| 1417 | 1417 | $buffer = $Common->getData($value['host'].'?'.time()); |
| 1418 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1418 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 1419 | 1419 | |
| 1420 | 1420 | if (isset($all_data['pireps'])) { |
| 1421 | 1421 | $reset = 0; |
| 1422 | 1422 | foreach ($all_data['pireps'] as $line) { |
| 1423 | 1423 | $data = array(); |
| 1424 | 1424 | $data['id'] = $line['id']; |
| 1425 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1425 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1426 | 1426 | $data['ident'] = $line['callsign']; // ident |
| 1427 | 1427 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 1428 | 1428 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1452,9 +1452,9 @@ discard block |
||
| 1452 | 1452 | $SI->add($data); |
| 1453 | 1453 | // print_r($data); |
| 1454 | 1454 | } elseif ($line['icon'] === 'ct') { |
| 1455 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 1456 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 1457 | - $typec = substr($data['ident'],-3); |
|
| 1455 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 1456 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 1457 | + $typec = substr($data['ident'], -3); |
|
| 1458 | 1458 | $data['type'] = ''; |
| 1459 | 1459 | if ($typec === 'APP') $data['type'] = 'Approach'; |
| 1460 | 1460 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
@@ -1465,7 +1465,7 @@ discard block |
||
| 1465 | 1465 | elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
| 1466 | 1466 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1467 | 1467 | else $data['type'] = 'Observer'; |
| 1468 | - 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']); |
|
| 1468 | + 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']); |
|
| 1469 | 1469 | } |
| 1470 | 1470 | unset($data); |
| 1471 | 1471 | } |
@@ -1482,14 +1482,14 @@ discard block |
||
| 1482 | 1482 | //$buffer = $Common->getData($hosts[$id]); |
| 1483 | 1483 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1484 | 1484 | $buffer = $Common->getData($value['host']); |
| 1485 | - $all_data = json_decode($buffer,true); |
|
| 1485 | + $all_data = json_decode($buffer, true); |
|
| 1486 | 1486 | if ($buffer != '' && is_array($all_data)) { |
| 1487 | 1487 | $reset = 0; |
| 1488 | 1488 | foreach ($all_data as $line) { |
| 1489 | 1489 | $data = array(); |
| 1490 | 1490 | //$data['id'] = $line['id']; // id not usable |
| 1491 | 1491 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
| 1492 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1492 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 1493 | 1493 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 1494 | 1494 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 1495 | 1495 | $data['ident'] = $line['flightnum']; // ident |
@@ -1504,7 +1504,7 @@ discard block |
||
| 1504 | 1504 | //$data['datetime'] = $line['lastupdate']; |
| 1505 | 1505 | //$data['last_update'] = $line['lastupdate']; |
| 1506 | 1506 | if (isset($value['timezone'])) { |
| 1507 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1507 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
| 1508 | 1508 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1509 | 1509 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1510 | 1510 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1520,14 +1520,14 @@ discard block |
||
| 1520 | 1520 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 1521 | 1521 | if (isset($line['aircraftname'])) { |
| 1522 | 1522 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1523 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 1524 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1523 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 1524 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 1525 | 1525 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
| 1526 | 1526 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
| 1527 | 1527 | else { |
| 1528 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1529 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1530 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1528 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 1529 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
| 1530 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
| 1531 | 1531 | } |
| 1532 | 1532 | } |
| 1533 | 1533 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1552,7 +1552,7 @@ discard block |
||
| 1552 | 1552 | //$buffer = $Common->getData($hosts[$id]); |
| 1553 | 1553 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1554 | 1554 | $buffer = $Common->getData($value['host']); |
| 1555 | - $all_data = json_decode($buffer,true); |
|
| 1555 | + $all_data = json_decode($buffer, true); |
|
| 1556 | 1556 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
| 1557 | 1557 | $reset = 0; |
| 1558 | 1558 | foreach ($all_data['ACARSData'] as $line) { |
@@ -1563,7 +1563,7 @@ discard block |
||
| 1563 | 1563 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1564 | 1564 | if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
| 1565 | 1565 | if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
| 1566 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1566 | + $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident |
|
| 1567 | 1567 | if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
| 1568 | 1568 | $data['altitude'] = $line['altitude']; // altitude |
| 1569 | 1569 | $data['speed'] = $line['groundspeed']; // speed |
@@ -1574,7 +1574,7 @@ discard block |
||
| 1574 | 1574 | //$data['squawk'] = ''; // squawk |
| 1575 | 1575 | //$data['emergency'] = ''; // emergency |
| 1576 | 1576 | if (isset($value['timezone'])) { |
| 1577 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1577 | + $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); |
|
| 1578 | 1578 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1579 | 1579 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1580 | 1580 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1610,14 +1610,14 @@ discard block |
||
| 1610 | 1610 | //$buffer = $Common->getData($hosts[$id]); |
| 1611 | 1611 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1612 | 1612 | $buffer = $Common->getData($value['host']); |
| 1613 | - $all_data = json_decode($buffer,true); |
|
| 1613 | + $all_data = json_decode($buffer, true); |
|
| 1614 | 1614 | if ($buffer != '' && is_array($all_data)) { |
| 1615 | 1615 | $reset = 0; |
| 1616 | 1616 | foreach ($all_data as $line) { |
| 1617 | 1617 | $data = array(); |
| 1618 | 1618 | //$data['id'] = $line['id']; // id not usable |
| 1619 | 1619 | $data['id'] = trim($line['flight_id']); |
| 1620 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1620 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 1621 | 1621 | $data['pilot_name'] = $line['pilot_name']; |
| 1622 | 1622 | $data['pilot_id'] = $line['pilot_id']; |
| 1623 | 1623 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1661,24 +1661,24 @@ discard block |
||
| 1661 | 1661 | //$buffer = $Common->getData($hosts[$id]); |
| 1662 | 1662 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1663 | 1663 | $buffer = $Common->getData($value['host']); |
| 1664 | - $all_data = json_decode($buffer,true); |
|
| 1664 | + $all_data = json_decode($buffer, true); |
|
| 1665 | 1665 | if ($buffer != '') { |
| 1666 | 1666 | $Source->deleteLocationBySource('blitzortung'); |
| 1667 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1668 | - $buffer = explode('\n',$buffer); |
|
| 1667 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 1668 | + $buffer = explode('\n', $buffer); |
|
| 1669 | 1669 | foreach ($buffer as $buffer_line) { |
| 1670 | - $line = json_decode($buffer_line,true); |
|
| 1670 | + $line = json_decode($buffer_line, true); |
|
| 1671 | 1671 | if (isset($line['time'])) { |
| 1672 | 1672 | $data = array(); |
| 1673 | 1673 | $data['altitude'] = $line['alt']; // altitude |
| 1674 | 1674 | $data['latitude'] = $line['lat']; // lat |
| 1675 | 1675 | $data['longitude'] = $line['lon']; // long |
| 1676 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
| 1676 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
| 1677 | 1677 | $data['id_source'] = $id_source; |
| 1678 | 1678 | $data['format_source'] = 'blitzortung'; |
| 1679 | 1679 | $SI->add($data); |
| 1680 | 1680 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1681 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
| 1681 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
| 1682 | 1682 | unset($data); |
| 1683 | 1683 | } |
| 1684 | 1684 | } |
@@ -1690,15 +1690,15 @@ discard block |
||
| 1690 | 1690 | $arr = $httpfeeds; |
| 1691 | 1691 | $w = $e = null; |
| 1692 | 1692 | if (isset($arr[$id])) { |
| 1693 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 1693 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
| 1694 | 1694 | if ($nn > 0) { |
| 1695 | 1695 | foreach ($httpfeeds as $feed) { |
| 1696 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 1696 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
| 1697 | 1697 | if ($buffer === FALSE) { |
| 1698 | 1698 | connect_all($globalSources); |
| 1699 | 1699 | } |
| 1700 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1701 | - $buffer = explode('\n',$buffer); |
|
| 1700 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 1701 | + $buffer = explode('\n', $buffer); |
|
| 1702 | 1702 | foreach ($buffer as $line) { |
| 1703 | 1703 | if ($line != '') { |
| 1704 | 1704 | $line = json_decode($line, true); |
@@ -1738,11 +1738,11 @@ discard block |
||
| 1738 | 1738 | //$value = $formats[$nb]; |
| 1739 | 1739 | $format = $globalSources[$nb]['format']; |
| 1740 | 1740 | if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
| 1741 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 1741 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 1742 | 1742 | } elseif ($format === 'vrstcp') { |
| 1743 | 1743 | $buffer = @socket_read($r, 6000); |
| 1744 | 1744 | } else { |
| 1745 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 1745 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 1746 | 1746 | } |
| 1747 | 1747 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 1748 | 1748 | //echo $buffer."\n"; |
@@ -1752,8 +1752,8 @@ discard block |
||
| 1752 | 1752 | //$SI::del(); |
| 1753 | 1753 | if ($buffer !== FALSE) { |
| 1754 | 1754 | if ($format === 'vrstcp') { |
| 1755 | - $buffer = explode('},{',$buffer); |
|
| 1756 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1755 | + $buffer = explode('},{', $buffer); |
|
| 1756 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 1757 | 1757 | } |
| 1758 | 1758 | // SBS format is CSV format |
| 1759 | 1759 | if ($buffer !== FALSE && $buffer !== '') { |
@@ -1780,7 +1780,7 @@ discard block |
||
| 1780 | 1780 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1781 | 1781 | $data = array(); |
| 1782 | 1782 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
| 1783 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1783 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
| 1784 | 1784 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
| 1785 | 1785 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
| 1786 | 1786 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -1791,13 +1791,13 @@ discard block |
||
| 1791 | 1791 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 1792 | 1792 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 1793 | 1793 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 1794 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1794 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 1795 | 1795 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1796 | 1796 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1797 | 1797 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 1798 | 1798 | |
| 1799 | 1799 | if (isset($ais_data['timestamp'])) { |
| 1800 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 1800 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 1801 | 1801 | } else { |
| 1802 | 1802 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1803 | 1803 | } |
@@ -1808,10 +1808,10 @@ discard block |
||
| 1808 | 1808 | } elseif ($format === 'flightgearsp') { |
| 1809 | 1809 | //echo $buffer."\n"; |
| 1810 | 1810 | if (strlen($buffer) > 5) { |
| 1811 | - $line = explode(',',$buffer); |
|
| 1811 | + $line = explode(',', $buffer); |
|
| 1812 | 1812 | $data = array(); |
| 1813 | 1813 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 1814 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1814 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1815 | 1815 | $data['ident'] = $line[6]; |
| 1816 | 1816 | $data['aircraft_name'] = $line[7]; |
| 1817 | 1817 | $data['longitude'] = $line[1]; |
@@ -1828,25 +1828,25 @@ discard block |
||
| 1828 | 1828 | } elseif ($format === 'acars') { |
| 1829 | 1829 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1830 | 1830 | $ACARS->add(trim($buffer)); |
| 1831 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1831 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1832 | 1832 | $ACARS->deleteLiveAcarsData(); |
| 1833 | 1833 | } elseif ($format === 'acarsjsonudp') { |
| 1834 | 1834 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1835 | 1835 | $line = json_decode(trim($buffer), true); |
| 1836 | 1836 | if (!empty($line)) { |
| 1837 | - $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
|
| 1837 | + $line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line); |
|
| 1838 | 1838 | $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
| 1839 | 1839 | $ACARS->deleteLiveAcarsData(); |
| 1840 | 1840 | } |
| 1841 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1841 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1842 | 1842 | } elseif ($format === 'flightgearmp') { |
| 1843 | - if (substr($buffer,0,1) != '#') { |
|
| 1843 | + if (substr($buffer, 0, 1) != '#') { |
|
| 1844 | 1844 | $data = array(); |
| 1845 | 1845 | //echo $buffer."\n"; |
| 1846 | - $line = explode(' ',$buffer); |
|
| 1846 | + $line = explode(' ', $buffer); |
|
| 1847 | 1847 | if (count($line) === 11) { |
| 1848 | - $userserver = explode('@',$line[0]); |
|
| 1849 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1848 | + $userserver = explode('@', $line[0]); |
|
| 1849 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 1850 | 1850 | $data['ident'] = $userserver[0]; |
| 1851 | 1851 | $data['registration'] = $userserver[0]; |
| 1852 | 1852 | $data['latitude'] = $line[4]; |
@@ -1854,8 +1854,8 @@ discard block |
||
| 1854 | 1854 | $data['altitude'] = $line[6]; |
| 1855 | 1855 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1856 | 1856 | $aircraft_type = $line[10]; |
| 1857 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1858 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1857 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 1858 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 1859 | 1859 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1860 | 1860 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1861 | 1861 | } |
@@ -1864,8 +1864,8 @@ discard block |
||
| 1864 | 1864 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 1865 | 1865 | die; |
| 1866 | 1866 | } elseif ($format === 'vrstcp') { |
| 1867 | - foreach($buffer as $all_data) { |
|
| 1868 | - $line = json_decode('{'.$all_data.'}',true); |
|
| 1867 | + foreach ($buffer as $all_data) { |
|
| 1868 | + $line = json_decode('{'.$all_data.'}', true); |
|
| 1869 | 1869 | $data = array(); |
| 1870 | 1870 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
| 1871 | 1871 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1891,16 +1891,16 @@ discard block |
||
| 1891 | 1891 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1892 | 1892 | unset($data); |
| 1893 | 1893 | } |
| 1894 | - } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
|
| 1894 | + } elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') { |
|
| 1895 | 1895 | $line = explode("\t", $buffer); |
| 1896 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1896 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 1897 | 1897 | $key = $line[$k]; |
| 1898 | - $lined[$key] = $line[$k+1]; |
|
| 1898 | + $lined[$key] = $line[$k + 1]; |
|
| 1899 | 1899 | } |
| 1900 | 1900 | if (count($lined) > 3) { |
| 1901 | 1901 | $data['hex'] = $lined['hexid']; |
| 1902 | 1902 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1903 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1903 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 1904 | 1904 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 1905 | 1905 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 1906 | 1906 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1919,23 +1919,23 @@ discard block |
||
| 1919 | 1919 | } else $error = true; |
| 1920 | 1920 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1921 | 1921 | if ($aprs_connect === 0) { |
| 1922 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 1922 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 1923 | 1923 | $aprs_connect = 1; |
| 1924 | 1924 | } |
| 1925 | 1925 | |
| 1926 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1926 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 1927 | 1927 | $aprs_last_tx = time(); |
| 1928 | 1928 | $data_aprs = "# Keep alive"; |
| 1929 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1929 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | 1932 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 1933 | 1933 | //echo 'APRS data : '.$buffer."\n"; |
| 1934 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1935 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1934 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 1935 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 1936 | 1936 | //echo $buffer."\n"; |
| 1937 | 1937 | date_default_timezone_set('UTC'); |
| 1938 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1938 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 1939 | 1939 | $line = $APRS->parse($buffer); |
| 1940 | 1940 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1941 | 1941 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1950,7 +1950,7 @@ discard block |
||
| 1950 | 1950 | if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
| 1951 | 1951 | if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
| 1952 | 1952 | if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
| 1953 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1953 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 1954 | 1954 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1955 | 1955 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1956 | 1956 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -2038,29 +2038,29 @@ discard block |
||
| 2038 | 2038 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 2039 | 2039 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 2040 | 2040 | $Source->deleteOldLocationByType('gs'); |
| 2041 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
| 2042 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
| 2041 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
| 2042 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
| 2043 | 2043 | } else { |
| 2044 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
| 2044 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
| 2045 | 2045 | } |
| 2046 | 2046 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 2047 | 2047 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2048 | 2048 | if ($globalDebug) echo '# Weather Station added'."\n"; |
| 2049 | 2049 | $Source->deleteOldLocationByType('wx'); |
| 2050 | 2050 | $weather_data = json_encode($line); |
| 2051 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
| 2052 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
| 2051 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
| 2052 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
| 2053 | 2053 | } else { |
| 2054 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
| 2054 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
| 2055 | 2055 | } |
| 2056 | 2056 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 2057 | 2057 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2058 | 2058 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 2059 | 2059 | $Source->deleteOldLocationByType('lightning'); |
| 2060 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
| 2061 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
| 2060 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
| 2061 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
| 2062 | 2062 | } else { |
| 2063 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
| 2063 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
| 2064 | 2064 | } |
| 2065 | 2065 | } elseif ($globalDebug) { |
| 2066 | 2066 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -2069,7 +2069,7 @@ discard block |
||
| 2069 | 2069 | unset($data); |
| 2070 | 2070 | } |
| 2071 | 2071 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
| 2072 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
| 2072 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
| 2073 | 2073 | } |
| 2074 | 2074 | /* |
| 2075 | 2075 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) { |
@@ -2078,7 +2078,7 @@ discard block |
||
| 2078 | 2078 | */ |
| 2079 | 2079 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 2080 | 2080 | elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 2081 | - if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
| 2081 | + if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
| 2082 | 2082 | $Source->deleteOldLocationByType('lightning'); |
| 2083 | 2083 | $Source->deleteOldLocationByType('wx'); |
| 2084 | 2084 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -2165,7 +2165,7 @@ discard block |
||
| 2165 | 2165 | connect_all($sourceee); |
| 2166 | 2166 | $sourceee = array(); |
| 2167 | 2167 | //connect_all($globalSources); |
| 2168 | - $tt[$format]=0; |
|
| 2168 | + $tt[$format] = 0; |
|
| 2169 | 2169 | break; |
| 2170 | 2170 | } |
| 2171 | 2171 | //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
@@ -2175,14 +2175,14 @@ discard block |
||
| 2175 | 2175 | } else { |
| 2176 | 2176 | $error = socket_strerror(socket_last_error()); |
| 2177 | 2177 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2178 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2178 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 2179 | 2179 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 2180 | 2180 | // Restart the script if possible |
| 2181 | 2181 | if (is_array($sockets)) { |
| 2182 | 2182 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 2183 | 2183 | |
| 2184 | 2184 | foreach ($sockets as $sock) { |
| 2185 | - @socket_shutdown($sock,2); |
|
| 2185 | + @socket_shutdown($sock, 2); |
|
| 2186 | 2186 | @socket_close($sock); |
| 2187 | 2187 | } |
| 2188 | 2188 | |
@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 25 | +if (!isset($globalDebug)) { |
|
| 26 | + $globalDebug = FALSE; |
|
| 27 | +} |
|
| 26 | 28 | |
| 27 | 29 | if ($globalInstalled === FALSE) { |
| 28 | 30 | echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
@@ -68,66 +70,107 @@ discard block |
||
| 68 | 70 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 69 | 71 | if (isset($options['s'])) { |
| 70 | 72 | $globalSources = array(); |
| 71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 72 | - else $globalSources[] = array('host' => $options['s']); |
|
| 73 | -} elseif (isset($options['source'])) { |
|
| 73 | + if (isset($options['format'])) { |
|
| 74 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 75 | + } else { |
|
| 76 | + $globalSources[] = array('host' => $options['s']); |
|
| 77 | + } |
|
| 78 | + } elseif (isset($options['source'])) { |
|
| 74 | 79 | $globalSources = array(); |
| 75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 76 | - else $globalSources[] = array('host' => $options['source']); |
|
| 77 | -} |
|
| 80 | + if (isset($options['format'])) { |
|
| 81 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 82 | + } else { |
|
| 83 | + $globalSources[] = array('host' => $options['source']); |
|
| 84 | + } |
|
| 85 | + } |
|
| 78 | 86 | if (isset($options['aprsserverhost'])) { |
| 79 | 87 | $globalServerAPRS = TRUE; |
| 80 | 88 | $globalServerAPRShost = $options['aprsserverhost']; |
| 81 | 89 | } |
| 82 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 83 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 84 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 85 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 90 | +if (isset($options['aprsserverport'])) { |
|
| 91 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 92 | +} |
|
| 93 | +if (isset($options['aprsserverssid'])) { |
|
| 94 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 95 | +} |
|
| 96 | +if (isset($options['aprsserverpass'])) { |
|
| 97 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 98 | +} |
|
| 99 | +if (isset($options['noaprsserver'])) { |
|
| 100 | + $globalServerAPRS = FALSE; |
|
| 101 | +} |
|
| 86 | 102 | if (isset($options['enable-aircraft'])) { |
| 87 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
| 103 | + if ($globalDebug) { |
|
| 104 | + echo 'Enable Aircraft mode'."\n"; |
|
| 105 | + } |
|
| 88 | 106 | $globalAircraft = TRUE; |
| 89 | 107 | } |
| 90 | 108 | if (isset($options['disable-aircraft'])) { |
| 91 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
| 109 | + if ($globalDebug) { |
|
| 110 | + echo 'Disable Aircraft mode'."\n"; |
|
| 111 | + } |
|
| 92 | 112 | $globalAircraft = FALSE; |
| 93 | 113 | } |
| 94 | 114 | if (isset($options['enable-tracker'])) { |
| 95 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
| 115 | + if ($globalDebug) { |
|
| 116 | + echo 'Enable Tracker mode'."\n"; |
|
| 117 | + } |
|
| 96 | 118 | $globalTracker = TRUE; |
| 97 | 119 | } |
| 98 | 120 | if (isset($options['disable-tracker'])) { |
| 99 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
| 121 | + if ($globalDebug) { |
|
| 122 | + echo 'Disable Tracker mode'."\n"; |
|
| 123 | + } |
|
| 100 | 124 | $globalTracker = FALSE; |
| 101 | 125 | } |
| 102 | 126 | if (isset($options['enable-marine'])) { |
| 103 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
| 127 | + if ($globalDebug) { |
|
| 128 | + echo 'Enable Marine mode'."\n"; |
|
| 129 | + } |
|
| 104 | 130 | $globalMarine = TRUE; |
| 105 | 131 | } |
| 106 | 132 | if (isset($options['disable-marine'])) { |
| 107 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
| 133 | + if ($globalDebug) { |
|
| 134 | + echo 'Disable Marine mode'."\n"; |
|
| 135 | + } |
|
| 108 | 136 | $globalMarine = FALSE; |
| 109 | 137 | } |
| 110 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 111 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 112 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 113 | -else $id_source = 1; |
|
| 138 | +if (isset($options['nodaemon'])) { |
|
| 139 | + $globalDaemon = FALSE; |
|
| 140 | +} |
|
| 141 | +if (isset($options['server'])) { |
|
| 142 | + $globalServer = TRUE; |
|
| 143 | +} |
|
| 144 | +if (isset($options['idsource'])) { |
|
| 145 | + $id_source = $options['idsource']; |
|
| 146 | +} else { |
|
| 147 | + $id_source = 1; |
|
| 148 | +} |
|
| 114 | 149 | if (isset($globalServer) && $globalServer) { |
| 115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 150 | + if ($globalDebug) { |
|
| 151 | + echo "Using Server Mode\n"; |
|
| 152 | + } |
|
| 116 | 153 | $SI=new SpotterServer(); |
| 117 | 154 | /* |
| 118 | 155 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 119 | 156 | $SI = new adsb2aprs(); |
| 120 | 157 | $SI->connect(); |
| 121 | 158 | */ |
| 122 | -} else $SI=new SpotterImport($Connection->db); |
|
| 159 | +} else { |
|
| 160 | + $SI=new SpotterImport($Connection->db); |
|
| 161 | +} |
|
| 123 | 162 | |
| 124 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 163 | +if (isset($globalTracker) && $globalTracker) { |
|
| 164 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 165 | +} |
|
| 125 | 166 | if (isset($globalMarine) && $globalMarine) { |
| 126 | 167 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 127 | 168 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 128 | 169 | } |
| 129 | 170 | |
| 130 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 171 | +if (isset($globalTracker) && $globalTracker) { |
|
| 172 | + $TI = new TrackerImport($Connection->db); |
|
| 173 | +} |
|
| 131 | 174 | if (isset($globalMarine) && $globalMarine) { |
| 132 | 175 | $AIS = new AIS(); |
| 133 | 176 | $MI = new MarineImport($Connection->db); |
@@ -152,7 +195,9 @@ discard block |
||
| 152 | 195 | } |
| 153 | 196 | |
| 154 | 197 | // let's try and connect |
| 155 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 198 | +if ($globalDebug) { |
|
| 199 | + echo "Connecting...\n"; |
|
| 200 | +} |
|
| 156 | 201 | $use_aprs = false; |
| 157 | 202 | $aprs_full = false; |
| 158 | 203 | $reset = 0; |
@@ -161,7 +206,9 @@ discard block |
||
| 161 | 206 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 162 | 207 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 163 | 208 | $reset++; |
| 164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 209 | + if ($globalDebug) { |
|
| 210 | + echo 'Connect to all...'."\n"; |
|
| 211 | + } |
|
| 165 | 212 | foreach ($hosts as $id => $value) { |
| 166 | 213 | $host = $value['host']; |
| 167 | 214 | $udp = false; |
@@ -172,32 +219,44 @@ discard block |
||
| 172 | 219 | //$formats[$id] = 'deltadbtxt'; |
| 173 | 220 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 174 | 221 | //$last_exec['deltadbtxt'] = 0; |
| 175 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 222 | + if ($globalDebug) { |
|
| 223 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 224 | + } |
|
| 176 | 225 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 177 | 226 | //$formats[$id] = 'vatsimtxt'; |
| 178 | 227 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 179 | 228 | //$last_exec['vatsimtxt'] = 0; |
| 180 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 229 | + if ($globalDebug) { |
|
| 230 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 231 | + } |
|
| 181 | 232 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 182 | 233 | //$formats[$id] = 'aircraftlistjson'; |
| 183 | 234 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 184 | 235 | //$last_exec['aircraftlistjson'] = 0; |
| 185 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 236 | + if ($globalDebug) { |
|
| 237 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 238 | + } |
|
| 186 | 239 | } else if (preg_match('/aircraft.json$/i',$host)) { |
| 187 | 240 | //$formats[$id] = 'aircraftjson'; |
| 188 | 241 | $globalSources[$id]['format'] = 'aircraftjson'; |
| 189 | 242 | //$last_exec['aircraftlistjson'] = 0; |
| 190 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 243 | + if ($globalDebug) { |
|
| 244 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 245 | + } |
|
| 191 | 246 | } else if (preg_match('/aircraft$/i',$host)) { |
| 192 | 247 | //$formats[$id] = 'planefinderclient'; |
| 193 | 248 | $globalSources[$id]['format'] = 'planefinderclient'; |
| 194 | 249 | //$last_exec['aircraftlistjson'] = 0; |
| 195 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 250 | + if ($globalDebug) { |
|
| 251 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 252 | + } |
|
| 196 | 253 | } else if (preg_match('/opensky/i',$host)) { |
| 197 | 254 | //$formats[$id] = 'aircraftlistjson'; |
| 198 | 255 | $globalSources[$id]['format'] = 'opensky'; |
| 199 | 256 | //$last_exec['aircraftlistjson'] = 0; |
| 200 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 257 | + if ($globalDebug) { |
|
| 258 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 259 | + } |
|
| 201 | 260 | /* |
| 202 | 261 | // Disabled for now, site change source format |
| 203 | 262 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -214,7 +273,9 @@ discard block |
||
| 214 | 273 | //$formats[$id] = 'planeupdatefaa'; |
| 215 | 274 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 216 | 275 | //$last_exec['planeupdatefaa'] = 0; |
| 217 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 276 | + if ($globalDebug) { |
|
| 277 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 278 | + } |
|
| 218 | 279 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 219 | 280 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 220 | 281 | exit(0); |
@@ -223,37 +284,53 @@ discard block |
||
| 223 | 284 | //$formats[$id] = 'phpvmacars'; |
| 224 | 285 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 225 | 286 | //$last_exec['phpvmacars'] = 0; |
| 226 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 287 | + if ($globalDebug) { |
|
| 288 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 289 | + } |
|
| 227 | 290 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
| 228 | 291 | //$formats[$id] = 'phpvmacars'; |
| 229 | 292 | $globalSources[$id]['format'] = 'vaos'; |
| 230 | 293 | //$last_exec['phpvmacars'] = 0; |
| 231 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 294 | + if ($globalDebug) { |
|
| 295 | + echo "Connect to vaos source (".$host.")...\n"; |
|
| 296 | + } |
|
| 232 | 297 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 233 | 298 | //$formats[$id] = 'phpvmacars'; |
| 234 | 299 | $globalSources[$id]['format'] = 'vam'; |
| 235 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 300 | + if ($globalDebug) { |
|
| 301 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 302 | + } |
|
| 236 | 303 | } else if (preg_match('/whazzup/i',$host)) { |
| 237 | 304 | //$formats[$id] = 'whazzup'; |
| 238 | 305 | $globalSources[$id]['format'] = 'whazzup'; |
| 239 | 306 | //$last_exec['whazzup'] = 0; |
| 240 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 307 | + if ($globalDebug) { |
|
| 308 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 309 | + } |
|
| 241 | 310 | } else if (preg_match('/blitzortung/i',$host)) { |
| 242 | 311 | $globalSources[$id]['format'] = 'blitzortung'; |
| 243 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 312 | + if ($globalDebug) { |
|
| 313 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 314 | + } |
|
| 244 | 315 | } else if (preg_match('/airwhere/i',$host)) { |
| 245 | 316 | $globalSources[$id]['format'] = 'airwhere'; |
| 246 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 317 | + if ($globalDebug) { |
|
| 318 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 319 | + } |
|
| 247 | 320 | } else if (preg_match('/recentpireps/i',$host)) { |
| 248 | 321 | //$formats[$id] = 'pirepsjson'; |
| 249 | 322 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 250 | 323 | //$last_exec['pirepsjson'] = 0; |
| 251 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 324 | + if ($globalDebug) { |
|
| 325 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 326 | + } |
|
| 252 | 327 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 253 | 328 | //$formats[$id] = 'fr24json'; |
| 254 | 329 | $globalSources[$id]['format'] = 'fr24json'; |
| 255 | 330 | //$last_exec['fr24json'] = 0; |
| 256 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 331 | + if ($globalDebug) { |
|
| 332 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 333 | + } |
|
| 257 | 334 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 258 | 335 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 259 | 336 | exit(0); |
@@ -262,7 +339,9 @@ discard block |
||
| 262 | 339 | //$formats[$id] = 'fr24json'; |
| 263 | 340 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 264 | 341 | //$last_exec['fr24json'] = 0; |
| 265 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 342 | + if ($globalDebug) { |
|
| 343 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 344 | + } |
|
| 266 | 345 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 267 | 346 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 268 | 347 | exit(0); |
@@ -271,18 +350,28 @@ discard block |
||
| 271 | 350 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 272 | 351 | //$formats[$id] = 'tsv'; |
| 273 | 352 | $globalSources[$id]['format'] = 'tsv'; |
| 274 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 353 | + if ($globalDebug) { |
|
| 354 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 355 | + } |
|
| 275 | 356 | } |
| 276 | 357 | } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
| 277 | 358 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
| 278 | 359 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 279 | 360 | if ($idf !== false) { |
| 280 | 361 | $httpfeeds[$id] = $idf; |
| 281 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 282 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 283 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 284 | - elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
| 285 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 362 | + if ($globalDebug) { |
|
| 363 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 364 | + } |
|
| 365 | + } elseif ($globalDebug) { |
|
| 366 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 367 | + } |
|
| 368 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { |
|
| 369 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 370 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') { |
|
| 371 | + echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
| 372 | + } elseif ($globalDebug) { |
|
| 373 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 374 | + } |
|
| 286 | 375 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 287 | 376 | $hostport = explode(':',$host); |
| 288 | 377 | if (isset($hostport[1])) { |
@@ -323,20 +412,29 @@ discard block |
||
| 323 | 412 | //$formats[$id] = 'beast'; |
| 324 | 413 | $globalSources[$id]['format'] = 'beast'; |
| 325 | 414 | //} else $formats[$id] = 'sbs'; |
| 326 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 415 | + } else { |
|
| 416 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 417 | + } |
|
| 327 | 418 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 328 | 419 | } |
| 329 | - if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 330 | - elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 420 | + if ($globalDebug && $udp) { |
|
| 421 | + echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 422 | + } elseif ($globalDebug) { |
|
| 423 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 424 | + } |
|
| 331 | 425 | } else { |
| 332 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 426 | + if ($globalDebug) { |
|
| 427 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 428 | + } |
|
| 333 | 429 | sleep(10); |
| 334 | 430 | connect_all($hosts); |
| 335 | 431 | } |
| 336 | 432 | } |
| 337 | 433 | } |
| 338 | 434 | } |
| 339 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 435 | +if (!isset($globalMinFetch)) { |
|
| 436 | + $globalMinFetch = 15; |
|
| 437 | +} |
|
| 340 | 438 | |
| 341 | 439 | // Initialize all |
| 342 | 440 | $status = array(); |
@@ -345,13 +443,19 @@ discard block |
||
| 345 | 443 | $formats = array(); |
| 346 | 444 | $last_exec = array(); |
| 347 | 445 | $time = time(); |
| 348 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 349 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 350 | -else $timeout = 20; |
|
| 446 | +if (isset($globalSourcesTimeout)) { |
|
| 447 | + $timeout = $globalSourcesTimeOut; |
|
| 448 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 449 | + $timeout = $globalSBS1TimeOut; |
|
| 450 | +} else { |
|
| 451 | + $timeout = 20; |
|
| 452 | +} |
|
| 351 | 453 | $errno = ''; |
| 352 | 454 | $errstr=''; |
| 353 | 455 | |
| 354 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 456 | +if (!isset($globalDaemon)) { |
|
| 457 | + $globalDaemon = TRUE; |
|
| 458 | +} |
|
| 355 | 459 | /* Initiate connections to all the hosts simultaneously */ |
| 356 | 460 | //connect_all($hosts); |
| 357 | 461 | //connect_all($globalSources); |
@@ -380,7 +484,9 @@ discard block |
||
| 380 | 484 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 381 | 485 | $aprs_connect = 0; |
| 382 | 486 | $use_aprs = true; |
| 383 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 487 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 488 | + $aprs_full = true; |
|
| 489 | + } |
|
| 384 | 490 | break; |
| 385 | 491 | } |
| 386 | 492 | } |
@@ -391,25 +497,46 @@ discard block |
||
| 391 | 497 | $aprs_connect = 0; |
| 392 | 498 | $aprs_keep = 120; |
| 393 | 499 | $aprs_last_tx = time(); |
| 394 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 395 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 396 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 397 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 398 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 399 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 400 | - if ($aprs_full) $aprs_filter = ''; |
|
| 401 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 402 | - else $aprs_pass = '-1'; |
|
| 500 | + if (isset($globalAPRSversion)) { |
|
| 501 | + $aprs_version = $globalAPRSversion; |
|
| 502 | + } else { |
|
| 503 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 504 | + } |
|
| 505 | + if (isset($globalAPRSssid)) { |
|
| 506 | + $aprs_ssid = $globalAPRSssid; |
|
| 507 | + } else { |
|
| 508 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 509 | + } |
|
| 510 | + if (isset($globalAPRSfilter)) { |
|
| 511 | + $aprs_filter = $globalAPRSfilter; |
|
| 512 | + } else { |
|
| 513 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 514 | + } |
|
| 515 | + if ($aprs_full) { |
|
| 516 | + $aprs_filter = ''; |
|
| 517 | + } |
|
| 518 | + if (isset($globalAPRSpass)) { |
|
| 519 | + $aprs_pass = $globalAPRSpass; |
|
| 520 | + } else { |
|
| 521 | + $aprs_pass = '-1'; |
|
| 522 | + } |
|
| 403 | 523 | |
| 404 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 405 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 406 | -} |
|
| 524 | + if ($aprs_filter != '') { |
|
| 525 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 526 | + } else { |
|
| 527 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 528 | + } |
|
| 529 | + } |
|
| 407 | 530 | |
| 408 | 531 | // connected - lets do some work |
| 409 | 532 | //if ($globalDebug) echo "Connected!\n"; |
| 410 | 533 | sleep(1); |
| 411 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 412 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 534 | +if ($globalDebug) { |
|
| 535 | + echo "SCAN MODE \n\n"; |
|
| 536 | +} |
|
| 537 | +if (!isset($globalCronEnd)) { |
|
| 538 | + $globalCronEnd = 60; |
|
| 539 | +} |
|
| 413 | 540 | $endtime = time()+$globalCronEnd; |
| 414 | 541 | $i = 1; |
| 415 | 542 | $tt = array(); |
@@ -423,22 +550,32 @@ discard block |
||
| 423 | 550 | |
| 424 | 551 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 425 | 552 | while ($i > 0) { |
| 426 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 553 | + if (function_exists('pcntl_fork')) { |
|
| 554 | + pcntl_signal_dispatch(); |
|
| 555 | + } |
|
| 427 | 556 | |
| 428 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 557 | + if (!$globalDaemon) { |
|
| 558 | + $i = $endtime-time(); |
|
| 559 | + } |
|
| 429 | 560 | // Delete old ATC |
| 430 | 561 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 431 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 562 | + if ($globalDebug) { |
|
| 563 | + echo 'Delete old ATC...'."\n"; |
|
| 564 | + } |
|
| 432 | 565 | $ATC->deleteOldATC(); |
| 433 | 566 | } |
| 434 | 567 | |
| 435 | 568 | if (count($last_exec) == count($globalSources)) { |
| 436 | 569 | $max = $globalMinFetch; |
| 437 | 570 | foreach ($last_exec as $last) { |
| 438 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 571 | + if ((time() - $last['last']) < $max) { |
|
| 572 | + $max = time() - $last['last']; |
|
| 573 | + } |
|
| 439 | 574 | } |
| 440 | 575 | if ($max < $globalMinFetch) { |
| 441 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 576 | + if ($globalDebug) { |
|
| 577 | + echo 'Sleeping...'."\n"; |
|
| 578 | + } |
|
| 442 | 579 | sleep($globalMinFetch-$max+2); |
| 443 | 580 | } |
| 444 | 581 | } |
@@ -448,7 +585,9 @@ discard block |
||
| 448 | 585 | foreach ($globalSources as $id => $value) { |
| 449 | 586 | date_default_timezone_set('UTC'); |
| 450 | 587 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 451 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 588 | + if (!isset($last_exec[$id]['last'])) { |
|
| 589 | + $last_exec[$id]['last'] = 0; |
|
| 590 | + } |
|
| 452 | 591 | if ($value['format'] === 'deltadbtxt' && |
| 453 | 592 | ( |
| 454 | 593 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -457,7 +596,9 @@ discard block |
||
| 457 | 596 | ) { |
| 458 | 597 | //$buffer = $Common->getData($hosts[$id]); |
| 459 | 598 | $buffer = $Common->getData($value['host']); |
| 460 | - if ($buffer != '') $reset = 0; |
|
| 599 | + if ($buffer != '') { |
|
| 600 | + $reset = 0; |
|
| 601 | + } |
|
| 461 | 602 | $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
| 462 | 603 | $buffer = explode('\n', $buffer); |
| 463 | 604 | foreach ($buffer as $line) { |
@@ -466,20 +607,41 @@ discard block |
||
| 466 | 607 | $data = array(); |
| 467 | 608 | $data['hex'] = $line[1]; // hex |
| 468 | 609 | $data['ident'] = $line[2]; // ident |
| 469 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 470 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 471 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 472 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 473 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 610 | + if (isset($line[3])) { |
|
| 611 | + $data['altitude'] = $line[3]; |
|
| 612 | + } |
|
| 613 | + // altitude |
|
| 614 | + if (isset($line[4])) { |
|
| 615 | + $data['speed'] = $line[4]; |
|
| 616 | + } |
|
| 617 | + // speed |
|
| 618 | + if (isset($line[5])) { |
|
| 619 | + $data['heading'] = $line[5]; |
|
| 620 | + } |
|
| 621 | + // heading |
|
| 622 | + if (isset($line[6])) { |
|
| 623 | + $data['latitude'] = $line[6]; |
|
| 624 | + } |
|
| 625 | + // lat |
|
| 626 | + if (isset($line[7])) { |
|
| 627 | + $data['longitude'] = $line[7]; |
|
| 628 | + } |
|
| 629 | + // long |
|
| 474 | 630 | $data['verticalrate'] = ''; // vertical rate |
| 475 | 631 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 476 | 632 | $data['emergency'] = ''; // emergency |
| 477 | 633 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 478 | 634 | $data['format_source'] = 'deltadbtxt'; |
| 479 | 635 | $data['id_source'] = $id_source; |
| 480 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 481 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 482 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 636 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 637 | + $data['source_name'] = $value['name']; |
|
| 638 | + } |
|
| 639 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 640 | + $data['noarchive'] = true; |
|
| 641 | + } |
|
| 642 | + if (isset($value['sourcestats'])) { |
|
| 643 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 644 | + } |
|
| 483 | 645 | $SI->add($data); |
| 484 | 646 | unset($data); |
| 485 | 647 | } |
@@ -514,11 +676,20 @@ discard block |
||
| 514 | 676 | $data['format_source'] = 'radarcapejson'; |
| 515 | 677 | $data['id_source'] = $id_source; |
| 516 | 678 | if (isset($value['name']) && $value['name'] != '') { |
| 517 | - if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
| 518 | - else $data['source_name'] = $value['name']; |
|
| 519 | - } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
| 520 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 521 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 679 | + if (isset($line['src']) && !$line['src'] == 'M') { |
|
| 680 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
| 681 | + } else { |
|
| 682 | + $data['source_name'] = $value['name']; |
|
| 683 | + } |
|
| 684 | + } elseif (isset($line['src']) && $line['src'] == 'M') { |
|
| 685 | + $data['source_name'] = 'MLAT'; |
|
| 686 | + } |
|
| 687 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 688 | + $data['noarchive'] = true; |
|
| 689 | + } |
|
| 690 | + if (isset($value['sourcestats'])) { |
|
| 691 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 692 | + } |
|
| 522 | 693 | |
| 523 | 694 | $SI->add($data); |
| 524 | 695 | unset($data); |
@@ -534,7 +705,9 @@ discard block |
||
| 534 | 705 | date_default_timezone_set('CET'); |
| 535 | 706 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 536 | 707 | date_default_timezone_set('UTC'); |
| 537 | - if ($buffer != '') $reset = 0; |
|
| 708 | + if ($buffer != '') { |
|
| 709 | + $reset = 0; |
|
| 710 | + } |
|
| 538 | 711 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 539 | 712 | $buffer = explode('\n',$buffer); |
| 540 | 713 | foreach ($buffer as $line) { |
@@ -543,18 +716,42 @@ discard block |
||
| 543 | 716 | $add = false; |
| 544 | 717 | $ais_data = $AIS->parse_line(trim($line)); |
| 545 | 718 | $data = array(); |
| 546 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 547 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 548 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 549 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 550 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 551 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 552 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 553 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 554 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 555 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 556 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 557 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 719 | + if (isset($ais_data['ident'])) { |
|
| 720 | + $data['ident'] = $ais_data['ident']; |
|
| 721 | + } |
|
| 722 | + if (isset($ais_data['mmsi'])) { |
|
| 723 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 724 | + } |
|
| 725 | + if (isset($ais_data['speed'])) { |
|
| 726 | + $data['speed'] = $ais_data['speed']; |
|
| 727 | + } |
|
| 728 | + if (isset($ais_data['heading'])) { |
|
| 729 | + $data['heading'] = $ais_data['heading']; |
|
| 730 | + } |
|
| 731 | + if (isset($ais_data['latitude'])) { |
|
| 732 | + $data['latitude'] = $ais_data['latitude']; |
|
| 733 | + } |
|
| 734 | + if (isset($ais_data['longitude'])) { |
|
| 735 | + $data['longitude'] = $ais_data['longitude']; |
|
| 736 | + } |
|
| 737 | + if (isset($ais_data['status'])) { |
|
| 738 | + $data['status'] = $ais_data['status']; |
|
| 739 | + } |
|
| 740 | + if (isset($ais_data['statusid'])) { |
|
| 741 | + $data['status_id'] = $ais_data['statusid']; |
|
| 742 | + } |
|
| 743 | + if (isset($ais_data['type'])) { |
|
| 744 | + $data['type'] = $ais_data['type']; |
|
| 745 | + } |
|
| 746 | + if (isset($ais_data['typeid'])) { |
|
| 747 | + $data['type_id'] = $ais_data['typeid']; |
|
| 748 | + } |
|
| 749 | + if (isset($ais_data['imo'])) { |
|
| 750 | + $data['imo'] = $ais_data['imo']; |
|
| 751 | + } |
|
| 752 | + if (isset($ais_data['callsign'])) { |
|
| 753 | + $data['callsign'] = $ais_data['callsign']; |
|
| 754 | + } |
|
| 558 | 755 | if (isset($ais_data['timestamp'])) { |
| 559 | 756 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 560 | 757 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -568,8 +765,12 @@ discard block |
||
| 568 | 765 | $data['format_source'] = 'aisnmeatxt'; |
| 569 | 766 | $data['id_source'] = $id_source; |
| 570 | 767 | //print_r($data); |
| 571 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 572 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 768 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 769 | + $data['noarchive'] = true; |
|
| 770 | + } |
|
| 771 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 772 | + $MI->add($data); |
|
| 773 | + } |
|
| 573 | 774 | unset($data); |
| 574 | 775 | } |
| 575 | 776 | } |
@@ -592,20 +793,48 @@ discard block |
||
| 592 | 793 | if ($line != '') { |
| 593 | 794 | $ais_data = $AIS->parse_line(trim($line)); |
| 594 | 795 | $data = array(); |
| 595 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 596 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 597 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 598 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 599 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 600 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 601 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 602 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 603 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 604 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 605 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 606 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 607 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 608 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 796 | + if (isset($ais_data['ident'])) { |
|
| 797 | + $data['ident'] = $ais_data['ident']; |
|
| 798 | + } |
|
| 799 | + if (isset($ais_data['mmsi'])) { |
|
| 800 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 801 | + } |
|
| 802 | + if (isset($ais_data['speed'])) { |
|
| 803 | + $data['speed'] = $ais_data['speed']; |
|
| 804 | + } |
|
| 805 | + if (isset($ais_data['heading'])) { |
|
| 806 | + $data['heading'] = $ais_data['heading']; |
|
| 807 | + } |
|
| 808 | + if (isset($ais_data['latitude'])) { |
|
| 809 | + $data['latitude'] = $ais_data['latitude']; |
|
| 810 | + } |
|
| 811 | + if (isset($ais_data['longitude'])) { |
|
| 812 | + $data['longitude'] = $ais_data['longitude']; |
|
| 813 | + } |
|
| 814 | + if (isset($ais_data['status'])) { |
|
| 815 | + $data['status'] = $ais_data['status']; |
|
| 816 | + } |
|
| 817 | + if (isset($ais_data['statusid'])) { |
|
| 818 | + $data['status_id'] = $ais_data['statusid']; |
|
| 819 | + } |
|
| 820 | + if (isset($ais_data['type'])) { |
|
| 821 | + $data['type'] = $ais_data['type']; |
|
| 822 | + } |
|
| 823 | + if (isset($ais_data['typeid'])) { |
|
| 824 | + $data['type_id'] = $ais_data['typeid']; |
|
| 825 | + } |
|
| 826 | + if (isset($ais_data['imo'])) { |
|
| 827 | + $data['imo'] = $ais_data['imo']; |
|
| 828 | + } |
|
| 829 | + if (isset($ais_data['callsign'])) { |
|
| 830 | + $data['callsign'] = $ais_data['callsign']; |
|
| 831 | + } |
|
| 832 | + if (isset($ais_data['destination'])) { |
|
| 833 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 834 | + } |
|
| 835 | + if (isset($ais_data['eta_ts'])) { |
|
| 836 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 837 | + } |
|
| 609 | 838 | if (isset($ais_data['timestamp'])) { |
| 610 | 839 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 611 | 840 | } else { |
@@ -613,18 +842,27 @@ discard block |
||
| 613 | 842 | } |
| 614 | 843 | $data['format_source'] = 'aisnmeahttp'; |
| 615 | 844 | $data['id_source'] = $id_source; |
| 616 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 617 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 845 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 846 | + $data['noarchive'] = true; |
|
| 847 | + } |
|
| 848 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 849 | + $MI->add($data); |
|
| 850 | + } |
|
| 618 | 851 | unset($data); |
| 619 | 852 | } |
| 620 | 853 | } |
| 621 | 854 | } |
| 622 | 855 | } else { |
| 623 | 856 | $format = $value['format']; |
| 624 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 625 | - else $tt[$format] = 0; |
|
| 857 | + if (isset($tt[$format])) { |
|
| 858 | + $tt[$format]++; |
|
| 859 | + } else { |
|
| 860 | + $tt[$format] = 0; |
|
| 861 | + } |
|
| 626 | 862 | if ($tt[$format] > 30) { |
| 627 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 863 | + if ($globalDebug) { |
|
| 864 | + echo 'Reconnect...'."\n"; |
|
| 865 | + } |
|
| 628 | 866 | sleep(2); |
| 629 | 867 | //$sourceeen[] = $value; |
| 630 | 868 | //connect_all($sourceeen); |
@@ -660,12 +898,18 @@ discard block |
||
| 660 | 898 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 661 | 899 | //$data['type_id'] = $line['TYPE']; |
| 662 | 900 | $data['imo'] = $line['IMO']; |
| 663 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 664 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 901 | + if ($line['DEST'] != '') { |
|
| 902 | + $data['arrival_code'] = $line['DEST']; |
|
| 903 | + } |
|
| 904 | + if ($line['ARV'] != '') { |
|
| 905 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 906 | + } |
|
| 665 | 907 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 666 | 908 | $data['format_source'] = 'myshiptracking'; |
| 667 | 909 | $data['id_source'] = $id_source; |
| 668 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 910 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 911 | + $data['noarchive'] = true; |
|
| 912 | + } |
|
| 669 | 913 | $MI->add($data); |
| 670 | 914 | unset($data); |
| 671 | 915 | } |
@@ -690,7 +934,9 @@ discard block |
||
| 690 | 934 | $data['callsign'] = $line['callsign']; |
| 691 | 935 | $data['mmsi'] = substr($line['mmsi'],-9); |
| 692 | 936 | $data['speed'] = $line['sog']; |
| 693 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 937 | + if ($line['heading'] != '511') { |
|
| 938 | + $data['heading'] = $line['heading']; |
|
| 939 | + } |
|
| 694 | 940 | $data['latitude'] = $line['latitude']; |
| 695 | 941 | $data['longitude'] = $line['longitude']; |
| 696 | 942 | $data['type_id'] = $line['shiptype']; |
@@ -698,7 +944,9 @@ discard block |
||
| 698 | 944 | $data['datetime'] = $line['time']; |
| 699 | 945 | $data['format_source'] = 'boatbeaconapp'; |
| 700 | 946 | $data['id_source'] = $id_source; |
| 701 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 947 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 948 | + $data['noarchive'] = true; |
|
| 949 | + } |
|
| 702 | 950 | $MI->add($data); |
| 703 | 951 | unset($data); |
| 704 | 952 | } |
@@ -720,22 +968,44 @@ discard block |
||
| 720 | 968 | foreach ($all_data['features'] as $line) { |
| 721 | 969 | print_r($line); |
| 722 | 970 | $data = array(); |
| 723 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 724 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 725 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 726 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
| 727 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 728 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
| 971 | + if (isset($line['properties']['name'])) { |
|
| 972 | + $data['ident'] = $line['properties']['name']; |
|
| 973 | + } |
|
| 974 | + if (isset($line['properties']['callsign'])) { |
|
| 975 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 976 | + } |
|
| 977 | + if (isset($line['properties']['mmsi'])) { |
|
| 978 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 979 | + } |
|
| 980 | + if (isset($line['properties']['imo'])) { |
|
| 981 | + $data['imo'] = $line['properties']['imo']; |
|
| 982 | + } |
|
| 983 | + if (isset($line['properties']['speed'])) { |
|
| 984 | + $data['speed'] = $line['properties']['speed']; |
|
| 985 | + } |
|
| 986 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
| 987 | + $data['heading'] = $line['properties']['heading']; |
|
| 988 | + } |
|
| 729 | 989 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 730 | 990 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 731 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 732 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 733 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 991 | + if (isset($line['properties']['vesselType'])) { |
|
| 992 | + $data['type'] = $line['properties']['vesselType']; |
|
| 993 | + } |
|
| 994 | + if (isset($line['properties']['destination'])) { |
|
| 995 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 996 | + } |
|
| 997 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 998 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 999 | + } |
|
| 734 | 1000 | $data['format_source'] = 'boatnerd'; |
| 735 | 1001 | $data['id_source'] = $id_source; |
| 736 | 1002 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 737 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 738 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 1003 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1004 | + $data['noarchive'] = true; |
|
| 1005 | + } |
|
| 1006 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 1007 | + $MI->add($data); |
|
| 1008 | + } |
|
| 739 | 1009 | unset($data); |
| 740 | 1010 | } |
| 741 | 1011 | } |
@@ -748,11 +1018,17 @@ discard block |
||
| 748 | 1018 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 749 | 1019 | ) |
| 750 | 1020 | ) { |
| 751 | - if ($globalDebug) echo 'download...'; |
|
| 1021 | + if ($globalDebug) { |
|
| 1022 | + echo 'download...'; |
|
| 1023 | + } |
|
| 752 | 1024 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 753 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 1025 | + if ($globalDebug) { |
|
| 1026 | + echo 'done !'."\n"; |
|
| 1027 | + } |
|
| 754 | 1028 | // FIXME: Need more work |
| 755 | - if ($buffer != '') $reset = 0; |
|
| 1029 | + if ($buffer != '') { |
|
| 1030 | + $reset = 0; |
|
| 1031 | + } |
|
| 756 | 1032 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 757 | 1033 | $buffer = explode('\n',$buffer); |
| 758 | 1034 | foreach ($buffer as $line) { |
@@ -778,7 +1054,9 @@ discard block |
||
| 778 | 1054 | //$data['etaTime'] = substr($line,135,5); |
| 779 | 1055 | $data['format_source'] = 'shipplotter'; |
| 780 | 1056 | $data['id_source'] = $id_source; |
| 781 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1057 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1058 | + $data['noarchive'] = true; |
|
| 1059 | + } |
|
| 782 | 1060 | //print_r($data); |
| 783 | 1061 | //echo 'Add...'."\n"; |
| 784 | 1062 | $MI->add($data); |
@@ -800,11 +1078,17 @@ discard block |
||
| 800 | 1078 | } |
| 801 | 1079 | } |
| 802 | 1080 | |
| 803 | - if ($globalDebug) echo '! Download... '; |
|
| 1081 | + if ($globalDebug) { |
|
| 1082 | + echo '! Download... '; |
|
| 1083 | + } |
|
| 804 | 1084 | for ($i =0; $i <= 1; $i++) { |
| 805 | - if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
| 1085 | + if ($globalDebug) { |
|
| 1086 | + echo 'Racetype: '.$i.' '; |
|
| 1087 | + } |
|
| 806 | 1088 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
| 807 | - if ($globalDebug) echo 'done'."\n"; |
|
| 1089 | + if ($globalDebug) { |
|
| 1090 | + echo 'done'."\n"; |
|
| 1091 | + } |
|
| 808 | 1092 | if ($buffer != '') { |
| 809 | 1093 | $all_data = json_decode($buffer,true); |
| 810 | 1094 | if (isset($all_data['missions'])) { |
@@ -815,7 +1099,9 @@ discard block |
||
| 815 | 1099 | if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { |
| 816 | 1100 | $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
| 817 | 1101 | sleep(30); |
| 818 | - } else $racebuffer = ''; |
|
| 1102 | + } else { |
|
| 1103 | + $racebuffer = ''; |
|
| 1104 | + } |
|
| 819 | 1105 | $bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
| 820 | 1106 | } else { |
| 821 | 1107 | $bufferm = ''; |
@@ -879,7 +1165,9 @@ discard block |
||
| 879 | 1165 | $data['captain_id'] = $sail['usrnr']; |
| 880 | 1166 | $data['captain_name'] = $sail['usrname']; |
| 881 | 1167 | $data['race_id'] = $sail['misnr']; |
| 882 | - if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank']; |
|
| 1168 | + if ($sail['rank'] != 'DNF') { |
|
| 1169 | + $data['race_rank'] = $sail['rank']; |
|
| 1170 | + } |
|
| 883 | 1171 | $data['race_time'] = $sail['racetime']; |
| 884 | 1172 | if ($mission_user != '') { |
| 885 | 1173 | $data['race_name'] = $mission_name.' ('.$mission_user.')'; |
@@ -889,7 +1177,9 @@ discard block |
||
| 889 | 1177 | //$data['callsign'] = trim(substr($line,100,7); |
| 890 | 1178 | $data['format_source'] = 'sailawayfull'; |
| 891 | 1179 | $data['id_source'] = $id_source; |
| 892 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1180 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1181 | + $data['noarchive'] = true; |
|
| 1182 | + } |
|
| 893 | 1183 | //print_r($data); |
| 894 | 1184 | //if ($data['race_id'] == '48') print_r($data); |
| 895 | 1185 | //echo 'Add...'."\n"; |
@@ -927,7 +1217,9 @@ discard block |
||
| 927 | 1217 | echo 'Sailaway API key MUST be defined'; |
| 928 | 1218 | exit(0); |
| 929 | 1219 | } |
| 930 | - if ($globalDebug) echo '! Download... '; |
|
| 1220 | + if ($globalDebug) { |
|
| 1221 | + echo '! Download... '; |
|
| 1222 | + } |
|
| 931 | 1223 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key'],'get','','','','',30); |
| 932 | 1224 | if ($buffer != '') { |
| 933 | 1225 | $data = json_decode($buffer,true); |
@@ -937,7 +1229,9 @@ discard block |
||
| 937 | 1229 | $data = array(); |
| 938 | 1230 | $data['id'] = $sail['ubtnr']; |
| 939 | 1231 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 940 | - if ($sail['online'] == '1') $data['last_update'] = date('Y-m-d H:i:s'); |
|
| 1232 | + if ($sail['online'] == '1') { |
|
| 1233 | + $data['last_update'] = date('Y-m-d H:i:s'); |
|
| 1234 | + } |
|
| 941 | 1235 | $data['latitude'] = $sail['ubtlat']; |
| 942 | 1236 | $data['longitude'] = $sail['ubtlon']; |
| 943 | 1237 | $data['type_id'] = 36; |
@@ -950,12 +1244,18 @@ discard block |
||
| 950 | 1244 | $data['speed'] = round($sail['ubtspeed']*3.6,2); |
| 951 | 1245 | $data['format_source'] = 'sailaway'; |
| 952 | 1246 | $data['id_source'] = $id_source; |
| 953 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1247 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1248 | + $data['noarchive'] = true; |
|
| 1249 | + } |
|
| 954 | 1250 | $MI->add($data); |
| 955 | 1251 | unset($data); |
| 956 | 1252 | } |
| 957 | - } elseif ($globalDebug) echo 'Error in JSON parsing'; |
|
| 958 | - } elseif ($globalDebug) echo 'Empty result !'."\n"; |
|
| 1253 | + } elseif ($globalDebug) { |
|
| 1254 | + echo 'Error in JSON parsing'; |
|
| 1255 | + } |
|
| 1256 | + } elseif ($globalDebug) { |
|
| 1257 | + echo 'Empty result !'."\n"; |
|
| 1258 | + } |
|
| 959 | 1259 | $last_exec[$id]['last'] = time(); |
| 960 | 1260 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 961 | 1261 | } elseif ( |
@@ -983,16 +1283,28 @@ discard block |
||
| 983 | 1283 | $line = explode(':', $line); |
| 984 | 1284 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 985 | 1285 | $data = array(); |
| 986 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 987 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1286 | + if (isset($line[37]) && $line[37] != '') { |
|
| 1287 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 1288 | + } else { |
|
| 1289 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1290 | + } |
|
| 988 | 1291 | $data['pilot_id'] = $line[1]; |
| 989 | 1292 | $data['pilot_name'] = $line[2]; |
| 990 | 1293 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 991 | 1294 | $data['ident'] = $line[0]; // ident |
| 992 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 1295 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 1296 | + $data['altitude'] = $line[7]; |
|
| 1297 | + } |
|
| 1298 | + // altitude |
|
| 993 | 1299 | $data['speed'] = $line[8]; // speed |
| 994 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 995 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 1300 | + if (isset($line[45])) { |
|
| 1301 | + $data['heading'] = $line[45]; |
|
| 1302 | + } |
|
| 1303 | + // heading |
|
| 1304 | + elseif (isset($line[38])) { |
|
| 1305 | + $data['heading'] = $line[38]; |
|
| 1306 | + } |
|
| 1307 | + // heading |
|
| 996 | 1308 | $data['latitude'] = $line[5]; // lat |
| 997 | 1309 | $data['longitude'] = $line[6]; // long |
| 998 | 1310 | $data['verticalrate'] = ''; // vertical rate |
@@ -1008,7 +1320,9 @@ discard block |
||
| 1008 | 1320 | $data['frequency'] = $line[4]; |
| 1009 | 1321 | $data['type'] = $line[18]; |
| 1010 | 1322 | $data['range'] = $line[19]; |
| 1011 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 1323 | + if (isset($line[35])) { |
|
| 1324 | + $data['info'] = $line[35]; |
|
| 1325 | + } |
|
| 1012 | 1326 | $data['id_source'] = $id_source; |
| 1013 | 1327 | //$data['arrival_airport_time'] = ; |
| 1014 | 1328 | if ($line[9] != '') { |
@@ -1022,27 +1336,47 @@ discard block |
||
| 1022 | 1336 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 1023 | 1337 | */ |
| 1024 | 1338 | $data['format_source'] = $value['format']; |
| 1025 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1026 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1027 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 1028 | - elseif ($line[3] === 'ATC') { |
|
| 1339 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1340 | + $data['noarchive'] = true; |
|
| 1341 | + } |
|
| 1342 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1343 | + $data['source_name'] = $value['name']; |
|
| 1344 | + } |
|
| 1345 | + if ($line[3] === 'PILOT') { |
|
| 1346 | + $SI->add($data); |
|
| 1347 | + } elseif ($line[3] === 'ATC') { |
|
| 1029 | 1348 | //print_r($data); |
| 1030 | 1349 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 1031 | 1350 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1032 | 1351 | $typec = substr($data['ident'],-3); |
| 1033 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 1034 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 1035 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 1036 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 1037 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 1038 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 1039 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1040 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1041 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
| 1042 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 1352 | + if ($typec === 'APP') { |
|
| 1353 | + $data['type'] = 'Approach'; |
|
| 1354 | + } elseif ($typec === 'TWR') { |
|
| 1355 | + $data['type'] = 'Tower'; |
|
| 1356 | + } elseif ($typec === 'OBS') { |
|
| 1357 | + $data['type'] = 'Observer'; |
|
| 1358 | + } elseif ($typec === 'GND') { |
|
| 1359 | + $data['type'] = 'Ground'; |
|
| 1360 | + } elseif ($typec === 'DEL') { |
|
| 1361 | + $data['type'] = 'Delivery'; |
|
| 1362 | + } elseif ($typec === 'DEP') { |
|
| 1363 | + $data['type'] = 'Departure'; |
|
| 1364 | + } elseif ($typec === 'FSS') { |
|
| 1365 | + $data['type'] = 'Flight Service Station'; |
|
| 1366 | + } elseif ($typec === 'CTR') { |
|
| 1367 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1368 | + } elseif ($data['type'] === '') { |
|
| 1369 | + $data['type'] = 'Observer'; |
|
| 1370 | + } |
|
| 1371 | + if (!isset($data['source_name'])) { |
|
| 1372 | + $data['source_name'] = ''; |
|
| 1373 | + } |
|
| 1043 | 1374 | if (isset($ATC)) { |
| 1044 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($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']); |
|
| 1045 | - 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']); |
|
| 1375 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 1376 | + echo $ATC->update($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']); |
|
| 1377 | + } else { |
|
| 1378 | + 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']); |
|
| 1379 | + } |
|
| 1046 | 1380 | } |
| 1047 | 1381 | } |
| 1048 | 1382 | unset($data); |
@@ -1069,14 +1403,20 @@ discard block |
||
| 1069 | 1403 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 1070 | 1404 | $data['latitude'] = (float)$line['pktLatitude']; |
| 1071 | 1405 | $data['longitude'] = (float)$line['pktLongitude']; |
| 1072 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 1073 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1406 | + if ((float)$line['pktTrack'] != 0) { |
|
| 1407 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 1408 | + } |
|
| 1409 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 1410 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 1411 | + } |
|
| 1074 | 1412 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 1075 | 1413 | $data['altitude_relative'] = 'AMSL'; |
| 1076 | 1414 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 1077 | 1415 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 1078 | 1416 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 1079 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 1417 | + if (isset($pilot_data[4])) { |
|
| 1418 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1419 | + } |
|
| 1080 | 1420 | $data['format_source'] = $value['format']; |
| 1081 | 1421 | $SI->add($data); |
| 1082 | 1422 | unset($data); |
@@ -1124,25 +1464,59 @@ discard block |
||
| 1124 | 1464 | foreach ($all_data['acList'] as $line) { |
| 1125 | 1465 | $data = array(); |
| 1126 | 1466 | $data['hex'] = $line['Icao']; // hex |
| 1127 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1128 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1129 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1130 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1131 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1132 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1467 | + if (isset($line['Call'])) { |
|
| 1468 | + $data['ident'] = $line['Call']; |
|
| 1469 | + } |
|
| 1470 | + // ident |
|
| 1471 | + if (isset($line['Alt'])) { |
|
| 1472 | + $data['altitude'] = $line['Alt']; |
|
| 1473 | + } |
|
| 1474 | + // altitude |
|
| 1475 | + if (isset($line['Spd'])) { |
|
| 1476 | + $data['speed'] = $line['Spd']; |
|
| 1477 | + } |
|
| 1478 | + // speed |
|
| 1479 | + if (isset($line['Trak'])) { |
|
| 1480 | + $data['heading'] = $line['Trak']; |
|
| 1481 | + } |
|
| 1482 | + // heading |
|
| 1483 | + if (isset($line['Lat'])) { |
|
| 1484 | + $data['latitude'] = $line['Lat']; |
|
| 1485 | + } |
|
| 1486 | + // lat |
|
| 1487 | + if (isset($line['Long'])) { |
|
| 1488 | + $data['longitude'] = $line['Long']; |
|
| 1489 | + } |
|
| 1490 | + // long |
|
| 1133 | 1491 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1134 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1492 | + if (isset($line['Sqk'])) { |
|
| 1493 | + $data['squawk'] = $line['Sqk']; |
|
| 1494 | + } |
|
| 1495 | + // squawk |
|
| 1135 | 1496 | $data['emergency'] = ''; // emergency |
| 1136 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1137 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1138 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1497 | + if (isset($line['Reg'])) { |
|
| 1498 | + $data['registration'] = $line['Reg']; |
|
| 1499 | + } |
|
| 1500 | + if (isset($line['PosTime'])) { |
|
| 1501 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1502 | + } else { |
|
| 1503 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1504 | + } |
|
| 1139 | 1505 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1140 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1506 | + if (isset($line['Type'])) { |
|
| 1507 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1508 | + } |
|
| 1141 | 1509 | $data['format_source'] = 'aircraftlistjson'; |
| 1142 | 1510 | $data['id_source'] = $id_source; |
| 1143 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1144 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1145 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1511 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1512 | + $data['source_name'] = $value['name']; |
|
| 1513 | + } |
|
| 1514 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1515 | + $data['noarchive'] = true; |
|
| 1516 | + } |
|
| 1517 | + if (isset($data['latitude'])) { |
|
| 1518 | + $SI->add($data); |
|
| 1519 | + } |
|
| 1146 | 1520 | unset($data); |
| 1147 | 1521 | } |
| 1148 | 1522 | } elseif (is_array($all_data)) { |
@@ -1159,17 +1533,26 @@ discard block |
||
| 1159 | 1533 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1160 | 1534 | $data['squawk'] = $line['squawk']; // squawk |
| 1161 | 1535 | $data['emergency'] = ''; // emergency |
| 1162 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1163 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1536 | + if (isset($line['PosTime'])) { |
|
| 1537 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1538 | + } else { |
|
| 1539 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1540 | + } |
|
| 1164 | 1541 | $data['format_source'] = 'aircraftlistjson'; |
| 1165 | 1542 | $data['id_source'] = $id_source; |
| 1166 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1167 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1543 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1544 | + $data['noarchive'] = true; |
|
| 1545 | + } |
|
| 1546 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1547 | + $data['source_name'] = $value['name']; |
|
| 1548 | + } |
|
| 1168 | 1549 | $SI->add($data); |
| 1169 | 1550 | unset($data); |
| 1170 | 1551 | } |
| 1171 | 1552 | } |
| 1172 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1553 | + } elseif ($globalDebug) { |
|
| 1554 | + echo 'No data'."\n"; |
|
| 1555 | + } |
|
| 1173 | 1556 | //$last_exec['aircraftlistjson'] = time(); |
| 1174 | 1557 | $last_exec[$id]['last'] = time(); |
| 1175 | 1558 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -1205,8 +1588,12 @@ discard block |
||
| 1205 | 1588 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 1206 | 1589 | $data['format_source'] = 'planeupdatefaa'; |
| 1207 | 1590 | $data['id_source'] = $id_source; |
| 1208 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1209 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1591 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1592 | + $data['noarchive'] = true; |
|
| 1593 | + } |
|
| 1594 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1595 | + $data['source_name'] = $value['name']; |
|
| 1596 | + } |
|
| 1210 | 1597 | $SI->add($data); |
| 1211 | 1598 | unset($data); |
| 1212 | 1599 | } |
@@ -1240,7 +1627,9 @@ discard block |
||
| 1240 | 1627 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 1241 | 1628 | $data['format_source'] = 'opensky'; |
| 1242 | 1629 | $data['id_source'] = $id_source; |
| 1243 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1630 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1631 | + $data['noarchive'] = true; |
|
| 1632 | + } |
|
| 1244 | 1633 | $SI->add($data); |
| 1245 | 1634 | unset($data); |
| 1246 | 1635 | } |
@@ -1260,15 +1649,42 @@ discard block |
||
| 1260 | 1649 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1261 | 1650 | $data = array(); |
| 1262 | 1651 | // add support for ground vehicule with ~ in front of hex |
| 1263 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1264 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1265 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1266 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1267 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1268 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1269 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1270 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1271 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1652 | + if (isset($line['hex'])) { |
|
| 1653 | + $data['hex'] = $line['hex']; |
|
| 1654 | + } |
|
| 1655 | + // hex |
|
| 1656 | + if (isset($line['flight'])) { |
|
| 1657 | + $data['ident'] = trim($line['flight']); |
|
| 1658 | + } |
|
| 1659 | + // ident |
|
| 1660 | + if (isset($line['altitude'])) { |
|
| 1661 | + $data['altitude'] = $line['altitude']; |
|
| 1662 | + } |
|
| 1663 | + // altitude |
|
| 1664 | + if (isset($line['speed'])) { |
|
| 1665 | + $data['speed'] = $line['speed']; |
|
| 1666 | + } |
|
| 1667 | + // speed |
|
| 1668 | + if (isset($line['track'])) { |
|
| 1669 | + $data['heading'] = $line['track']; |
|
| 1670 | + } |
|
| 1671 | + // heading |
|
| 1672 | + if (isset($line['lat'])) { |
|
| 1673 | + $data['latitude'] = $line['lat']; |
|
| 1674 | + } |
|
| 1675 | + // lat |
|
| 1676 | + if (isset($line['lon'])) { |
|
| 1677 | + $data['longitude'] = $line['lon']; |
|
| 1678 | + } |
|
| 1679 | + // long |
|
| 1680 | + if (isset($line['vert_rate'])) { |
|
| 1681 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1682 | + } |
|
| 1683 | + // verticale rate |
|
| 1684 | + if (isset($line['squawk'])) { |
|
| 1685 | + $data['squawk'] = $line['squawk']; |
|
| 1686 | + } |
|
| 1687 | + // squawk |
|
| 1272 | 1688 | //$data['emergency'] = ''; // emergency |
| 1273 | 1689 | //$data['registration'] = $line[2]; |
| 1274 | 1690 | //$data['aircraft_icao'] = $line[0]; |
@@ -1276,10 +1692,17 @@ discard block |
||
| 1276 | 1692 | $data['format_source'] = 'aircraftjson'; |
| 1277 | 1693 | $data['id_source'] = $id_source; |
| 1278 | 1694 | if (isset($value['name']) && $value['name'] != '') { |
| 1279 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1280 | - else $data['source_name'] = $value['name']; |
|
| 1281 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1282 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1695 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1696 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1697 | + } else { |
|
| 1698 | + $data['source_name'] = $value['name']; |
|
| 1699 | + } |
|
| 1700 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1701 | + $data['source_name'] = 'MLAT'; |
|
| 1702 | + } |
|
| 1703 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1704 | + $data['noarchive'] = true; |
|
| 1705 | + } |
|
| 1283 | 1706 | $SI->add($data); |
| 1284 | 1707 | unset($data); |
| 1285 | 1708 | } |
@@ -1299,22 +1722,54 @@ discard block |
||
| 1299 | 1722 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1300 | 1723 | $data = array(); |
| 1301 | 1724 | $data['hex'] = $key; // hex |
| 1302 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1303 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1304 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1305 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1306 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1307 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1308 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1309 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1725 | + if (isset($line['callsign'])) { |
|
| 1726 | + $data['ident'] = trim($line['callsign']); |
|
| 1727 | + } |
|
| 1728 | + // ident |
|
| 1729 | + if (isset($line['altitude'])) { |
|
| 1730 | + $data['altitude'] = $line['altitude']; |
|
| 1731 | + } |
|
| 1732 | + // altitude |
|
| 1733 | + if (isset($line['speed'])) { |
|
| 1734 | + $data['speed'] = $line['speed']; |
|
| 1735 | + } |
|
| 1736 | + // speed |
|
| 1737 | + if (isset($line['heading'])) { |
|
| 1738 | + $data['heading'] = $line['heading']; |
|
| 1739 | + } |
|
| 1740 | + // heading |
|
| 1741 | + if (isset($line['lat'])) { |
|
| 1742 | + $data['latitude'] = $line['lat']; |
|
| 1743 | + } |
|
| 1744 | + // lat |
|
| 1745 | + if (isset($line['lon'])) { |
|
| 1746 | + $data['longitude'] = $line['lon']; |
|
| 1747 | + } |
|
| 1748 | + // long |
|
| 1749 | + if (isset($line['vert_rate'])) { |
|
| 1750 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1751 | + } |
|
| 1752 | + // verticale rate |
|
| 1753 | + if (isset($line['squawk'])) { |
|
| 1754 | + $data['squawk'] = $line['squawk']; |
|
| 1755 | + } |
|
| 1756 | + // squawk |
|
| 1310 | 1757 | //$data['emergency'] = ''; // emergency |
| 1311 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1312 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1758 | + if (isset($line['reg'])) { |
|
| 1759 | + $data['registration'] = $line['reg']; |
|
| 1760 | + } |
|
| 1761 | + if (isset($line['type'])) { |
|
| 1762 | + $data['aircraft_icao'] = $line['type']; |
|
| 1763 | + } |
|
| 1313 | 1764 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
| 1314 | 1765 | $data['format_source'] = 'planefinderclient'; |
| 1315 | 1766 | $data['id_source'] = $id_source; |
| 1316 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1317 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1767 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1768 | + $data['source_name'] = $value['name']; |
|
| 1769 | + } |
|
| 1770 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1771 | + $data['noarchive'] = true; |
|
| 1772 | + } |
|
| 1318 | 1773 | $SI->add($data); |
| 1319 | 1774 | unset($data); |
| 1320 | 1775 | } |
@@ -1330,7 +1785,9 @@ discard block |
||
| 1330 | 1785 | //$buffer = $Common->getData($hosts[$id]); |
| 1331 | 1786 | $buffer = $Common->getData($value['host']); |
| 1332 | 1787 | $all_data = json_decode($buffer,true); |
| 1333 | - if (!empty($all_data)) $reset = 0; |
|
| 1788 | + if (!empty($all_data)) { |
|
| 1789 | + $reset = 0; |
|
| 1790 | + } |
|
| 1334 | 1791 | foreach ($all_data as $key => $line) { |
| 1335 | 1792 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1336 | 1793 | $data = array(); |
@@ -1351,8 +1808,12 @@ discard block |
||
| 1351 | 1808 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 1352 | 1809 | $data['format_source'] = 'fr24json'; |
| 1353 | 1810 | $data['id_source'] = $id_source; |
| 1354 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1355 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1811 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1812 | + $data['noarchive'] = true; |
|
| 1813 | + } |
|
| 1814 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1815 | + $data['source_name'] = $value['name']; |
|
| 1816 | + } |
|
| 1356 | 1817 | $SI->add($data); |
| 1357 | 1818 | unset($data); |
| 1358 | 1819 | } |
@@ -1381,24 +1842,42 @@ discard block |
||
| 1381 | 1842 | if (isset($line['inf'])) { |
| 1382 | 1843 | $data = array(); |
| 1383 | 1844 | $data['hex'] = $line['inf']['ia']; |
| 1384 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1845 | + if (isset($line['inf']['cs'])) { |
|
| 1846 | + $data['ident'] = $line['inf']['cs']; |
|
| 1847 | + } |
|
| 1848 | + //$line[13] |
|
| 1385 | 1849 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 1386 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1387 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1850 | + if (isset($line['inf']['gs'])) { |
|
| 1851 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1852 | + } |
|
| 1853 | + // speed |
|
| 1854 | + if (isset($line['inf']['tr'])) { |
|
| 1855 | + $data['heading'] = $line['inf']['tr']; |
|
| 1856 | + } |
|
| 1857 | + // heading |
|
| 1388 | 1858 | $data['latitude'] = $line['pt'][0]; // lat |
| 1389 | 1859 | $data['longitude'] = $line['pt'][1]; // long |
| 1390 | 1860 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 1391 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1861 | + if (isset($line['inf']['sq'])) { |
|
| 1862 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1863 | + } |
|
| 1864 | + // squawk |
|
| 1392 | 1865 | //$data['aircraft_icao'] = $line[8]; |
| 1393 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1866 | + if (isset($line['inf']['rc'])) { |
|
| 1867 | + $data['registration'] = $line['inf']['rc']; |
|
| 1868 | + } |
|
| 1394 | 1869 | //$data['departure_airport_iata'] = $line[11]; |
| 1395 | 1870 | //$data['arrival_airport_iata'] = $line[12]; |
| 1396 | 1871 | //$data['emergency'] = ''; // emergency |
| 1397 | 1872 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1398 | 1873 | $data['format_source'] = 'radarvirtueljson'; |
| 1399 | 1874 | $data['id_source'] = $id_source; |
| 1400 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1401 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1875 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1876 | + $data['noarchive'] = true; |
|
| 1877 | + } |
|
| 1878 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1879 | + $data['source_name'] = $value['name']; |
|
| 1880 | + } |
|
| 1402 | 1881 | $SI->add($data); |
| 1403 | 1882 | unset($data); |
| 1404 | 1883 | } |
@@ -1424,30 +1903,65 @@ discard block |
||
| 1424 | 1903 | $data['id'] = $line['id']; |
| 1425 | 1904 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 1426 | 1905 | $data['ident'] = $line['callsign']; // ident |
| 1427 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1428 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1429 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1430 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1431 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1432 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1906 | + if (isset($line['pilotid'])) { |
|
| 1907 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1908 | + } |
|
| 1909 | + // pilot id |
|
| 1910 | + if (isset($line['name'])) { |
|
| 1911 | + $data['pilot_name'] = $line['name']; |
|
| 1912 | + } |
|
| 1913 | + // pilot name |
|
| 1914 | + if (isset($line['alt'])) { |
|
| 1915 | + $data['altitude'] = $line['alt']; |
|
| 1916 | + } |
|
| 1917 | + // altitude |
|
| 1918 | + if (isset($line['gs'])) { |
|
| 1919 | + $data['speed'] = $line['gs']; |
|
| 1920 | + } |
|
| 1921 | + // speed |
|
| 1922 | + if (isset($line['heading'])) { |
|
| 1923 | + $data['heading'] = $line['heading']; |
|
| 1924 | + } |
|
| 1925 | + // heading |
|
| 1926 | + if (isset($line['route'])) { |
|
| 1927 | + $data['waypoints'] = $line['route']; |
|
| 1928 | + } |
|
| 1929 | + // route |
|
| 1433 | 1930 | $data['latitude'] = $line['lat']; // lat |
| 1434 | 1931 | $data['longitude'] = $line['lon']; // long |
| 1435 | 1932 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 1436 | 1933 | //$data['squawk'] = $line['squawk']; // squawk |
| 1437 | 1934 | //$data['emergency'] = ''; // emergency |
| 1438 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1439 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1440 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1935 | + if (isset($line['depicao'])) { |
|
| 1936 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1937 | + } |
|
| 1938 | + if (isset($line['deptime'])) { |
|
| 1939 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1940 | + } |
|
| 1941 | + if (isset($line['arricao'])) { |
|
| 1942 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1943 | + } |
|
| 1441 | 1944 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 1442 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1443 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1444 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1445 | - else $data['info'] = ''; |
|
| 1945 | + if (isset($line['aircraft'])) { |
|
| 1946 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1947 | + } |
|
| 1948 | + if (isset($line['transponder'])) { |
|
| 1949 | + $data['squawk'] = $line['transponder']; |
|
| 1950 | + } |
|
| 1951 | + if (isset($line['atis'])) { |
|
| 1952 | + $data['info'] = $line['atis']; |
|
| 1953 | + } else { |
|
| 1954 | + $data['info'] = ''; |
|
| 1955 | + } |
|
| 1446 | 1956 | $data['format_source'] = 'pireps'; |
| 1447 | 1957 | $data['id_source'] = $id_source; |
| 1448 | 1958 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1449 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1450 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1959 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1960 | + $data['noarchive'] = true; |
|
| 1961 | + } |
|
| 1962 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1963 | + $data['source_name'] = $value['name']; |
|
| 1964 | + } |
|
| 1451 | 1965 | if ($line['icon'] === 'plane') { |
| 1452 | 1966 | $SI->add($data); |
| 1453 | 1967 | // print_r($data); |
@@ -1456,16 +1970,28 @@ discard block |
||
| 1456 | 1970 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1457 | 1971 | $typec = substr($data['ident'],-3); |
| 1458 | 1972 | $data['type'] = ''; |
| 1459 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 1460 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 1461 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 1462 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 1463 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 1464 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 1465 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1466 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1467 | - else $data['type'] = 'Observer'; |
|
| 1468 | - 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']); |
|
| 1973 | + if ($typec === 'APP') { |
|
| 1974 | + $data['type'] = 'Approach'; |
|
| 1975 | + } elseif ($typec === 'TWR') { |
|
| 1976 | + $data['type'] = 'Tower'; |
|
| 1977 | + } elseif ($typec === 'OBS') { |
|
| 1978 | + $data['type'] = 'Observer'; |
|
| 1979 | + } elseif ($typec === 'GND') { |
|
| 1980 | + $data['type'] = 'Ground'; |
|
| 1981 | + } elseif ($typec === 'DEL') { |
|
| 1982 | + $data['type'] = 'Delivery'; |
|
| 1983 | + } elseif ($typec === 'DEP') { |
|
| 1984 | + $data['type'] = 'Departure'; |
|
| 1985 | + } elseif ($typec === 'FSS') { |
|
| 1986 | + $data['type'] = 'Flight Service Station'; |
|
| 1987 | + } elseif ($typec === 'CTR') { |
|
| 1988 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1989 | + } else { |
|
| 1990 | + $data['type'] = 'Observer'; |
|
| 1991 | + } |
|
| 1992 | + if (isset($ATC)) { |
|
| 1993 | + 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']); |
|
| 1994 | + } |
|
| 1469 | 1995 | } |
| 1470 | 1996 | unset($data); |
| 1471 | 1997 | } |
@@ -1480,7 +2006,9 @@ discard block |
||
| 1480 | 2006 | ) |
| 1481 | 2007 | ) { |
| 1482 | 2008 | //$buffer = $Common->getData($hosts[$id]); |
| 1483 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2009 | + if ($globalDebug) { |
|
| 2010 | + echo 'Get Data...'."\n"; |
|
| 2011 | + } |
|
| 1484 | 2012 | $buffer = $Common->getData($value['host']); |
| 1485 | 2013 | $all_data = json_decode($buffer,true); |
| 1486 | 2014 | if ($buffer != '' && is_array($all_data)) { |
@@ -1488,10 +2016,16 @@ discard block |
||
| 1488 | 2016 | foreach ($all_data as $line) { |
| 1489 | 2017 | $data = array(); |
| 1490 | 2018 | //$data['id'] = $line['id']; // id not usable |
| 1491 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 2019 | + if (isset($line['pilotid'])) { |
|
| 2020 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 2021 | + } |
|
| 1492 | 2022 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1493 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1494 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 2023 | + if (isset($line['pilotname'])) { |
|
| 2024 | + $data['pilot_name'] = $line['pilotname']; |
|
| 2025 | + } |
|
| 2026 | + if (isset($line['pilotid'])) { |
|
| 2027 | + $data['pilot_id'] = $line['pilotid']; |
|
| 2028 | + } |
|
| 1495 | 2029 | $data['ident'] = $line['flightnum']; // ident |
| 1496 | 2030 | $data['altitude'] = $line['alt']; // altitude |
| 1497 | 2031 | $data['speed'] = $line['gs']; // speed |
@@ -1507,7 +2041,9 @@ discard block |
||
| 1507 | 2041 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
| 1508 | 2042 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1509 | 2043 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1510 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2044 | + } else { |
|
| 2045 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2046 | + } |
|
| 1511 | 2047 | $data['departure_airport_icao'] = $line['depicao']; |
| 1512 | 2048 | $data['departure_airport_time'] = $line['deptime']; |
| 1513 | 2049 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1515,29 +2051,47 @@ discard block |
||
| 1515 | 2051 | if (isset($line['registration'])) { |
| 1516 | 2052 | $data['registration'] = $line['registration']; |
| 1517 | 2053 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
| 1518 | - } else $data['registration'] = $line['aircraft']; |
|
| 1519 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1520 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 2054 | + } else { |
|
| 2055 | + $data['registration'] = $line['aircraft']; |
|
| 2056 | + } |
|
| 2057 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2058 | + $data['noarchive'] = true; |
|
| 2059 | + } |
|
| 2060 | + if (isset($line['route'])) { |
|
| 2061 | + $data['waypoints'] = $line['route']; |
|
| 2062 | + } |
|
| 2063 | + // route |
|
| 1521 | 2064 | if (isset($line['aircraftname'])) { |
| 1522 | 2065 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1523 | 2066 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1524 | 2067 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1525 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1526 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1527 | - else { |
|
| 2068 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 2069 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 2070 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 2071 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 2072 | + } else { |
|
| 1528 | 2073 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1529 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1530 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 2074 | + if (isset($aircraft_data[1])) { |
|
| 2075 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 2076 | + } else { |
|
| 2077 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 2078 | + } |
|
| 1531 | 2079 | } |
| 1532 | 2080 | } |
| 1533 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 2081 | + if (isset($line['route'])) { |
|
| 2082 | + $data['waypoints'] = $line['route']; |
|
| 2083 | + } |
|
| 1534 | 2084 | $data['id_source'] = $id_source; |
| 1535 | 2085 | $data['format_source'] = 'phpvmacars'; |
| 1536 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2086 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2087 | + $data['source_name'] = $value['name']; |
|
| 2088 | + } |
|
| 1537 | 2089 | $SI->add($data); |
| 1538 | 2090 | unset($data); |
| 1539 | 2091 | } |
| 1540 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2092 | + if ($globalDebug) { |
|
| 2093 | + echo 'No more data...'."\n"; |
|
| 2094 | + } |
|
| 1541 | 2095 | unset($buffer); |
| 1542 | 2096 | unset($all_data); |
| 1543 | 2097 | } |
@@ -1550,7 +2104,9 @@ discard block |
||
| 1550 | 2104 | ) |
| 1551 | 2105 | ) { |
| 1552 | 2106 | //$buffer = $Common->getData($hosts[$id]); |
| 1553 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2107 | + if ($globalDebug) { |
|
| 2108 | + echo 'Get Data...'."\n"; |
|
| 2109 | + } |
|
| 1554 | 2110 | $buffer = $Common->getData($value['host']); |
| 1555 | 2111 | $all_data = json_decode($buffer,true); |
| 1556 | 2112 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1561,10 +2117,16 @@ discard block |
||
| 1561 | 2117 | //$data['id'] = $line['id']; // id not usable |
| 1562 | 2118 | $data['id'] = $line['id']; |
| 1563 | 2119 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1564 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1565 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 2120 | + if (isset($line['user']['username'])) { |
|
| 2121 | + $data['pilot_name'] = $line['user']['username']; |
|
| 2122 | + } |
|
| 2123 | + if (isset($line['user_id'])) { |
|
| 2124 | + $data['pilot_id'] = $line['user_id']; |
|
| 2125 | + } |
|
| 1566 | 2126 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
| 1567 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2127 | + if (is_numeric($data['ident'])) { |
|
| 2128 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2129 | + } |
|
| 1568 | 2130 | $data['altitude'] = $line['altitude']; // altitude |
| 1569 | 2131 | $data['speed'] = $line['groundspeed']; // speed |
| 1570 | 2132 | $data['heading'] = $line['heading']; // heading |
@@ -1577,7 +2139,9 @@ discard block |
||
| 1577 | 2139 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
| 1578 | 2140 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1579 | 2141 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1580 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2142 | + } else { |
|
| 2143 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2144 | + } |
|
| 1581 | 2145 | |
| 1582 | 2146 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
| 1583 | 2147 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1585,17 +2149,26 @@ discard block |
||
| 1585 | 2149 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
| 1586 | 2150 | $data['registration'] = $line['bid']['aircraft']['registration']; |
| 1587 | 2151 | |
| 1588 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1589 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 2152 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2153 | + $data['noarchive'] = true; |
|
| 2154 | + } |
|
| 2155 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
| 2156 | + $data['waypoints'] = $line['bid']['route']; |
|
| 2157 | + } |
|
| 2158 | + // route |
|
| 1590 | 2159 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
| 1591 | 2160 | |
| 1592 | 2161 | $data['id_source'] = $id_source; |
| 1593 | 2162 | $data['format_source'] = 'vaos'; |
| 1594 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2163 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2164 | + $data['source_name'] = $value['name']; |
|
| 2165 | + } |
|
| 1595 | 2166 | $SI->add($data); |
| 1596 | 2167 | unset($data); |
| 1597 | 2168 | } |
| 1598 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2169 | + if ($globalDebug) { |
|
| 2170 | + echo 'No more data...'."\n"; |
|
| 2171 | + } |
|
| 1599 | 2172 | unset($buffer); |
| 1600 | 2173 | unset($all_data); |
| 1601 | 2174 | } |
@@ -1608,7 +2181,9 @@ discard block |
||
| 1608 | 2181 | ) |
| 1609 | 2182 | ) { |
| 1610 | 2183 | //$buffer = $Common->getData($hosts[$id]); |
| 1611 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2184 | + if ($globalDebug) { |
|
| 2185 | + echo 'Get Data...'."\n"; |
|
| 2186 | + } |
|
| 1612 | 2187 | $buffer = $Common->getData($value['host']); |
| 1613 | 2188 | $all_data = json_decode($buffer,true); |
| 1614 | 2189 | if ($buffer != '' && is_array($all_data)) { |
@@ -1637,16 +2212,25 @@ discard block |
||
| 1637 | 2212 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1638 | 2213 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1639 | 2214 | //$data['registration'] = $line['aircraft']; |
| 1640 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 2215 | + if (isset($line['route'])) { |
|
| 2216 | + $data['waypoints'] = $line['route']; |
|
| 2217 | + } |
|
| 2218 | + // route |
|
| 1641 | 2219 | $data['aircraft_icao'] = $line['plane_type']; |
| 1642 | 2220 | $data['id_source'] = $id_source; |
| 1643 | 2221 | $data['format_source'] = 'vam'; |
| 1644 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1645 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2222 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2223 | + $data['noarchive'] = true; |
|
| 2224 | + } |
|
| 2225 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2226 | + $data['source_name'] = $value['name']; |
|
| 2227 | + } |
|
| 1646 | 2228 | $SI->add($data); |
| 1647 | 2229 | unset($data); |
| 1648 | 2230 | } |
| 1649 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2231 | + if ($globalDebug) { |
|
| 2232 | + echo 'No more data...'."\n"; |
|
| 2233 | + } |
|
| 1650 | 2234 | unset($buffer); |
| 1651 | 2235 | unset($all_data); |
| 1652 | 2236 | } |
@@ -1659,7 +2243,9 @@ discard block |
||
| 1659 | 2243 | ) |
| 1660 | 2244 | ) { |
| 1661 | 2245 | //$buffer = $Common->getData($hosts[$id]); |
| 1662 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2246 | + if ($globalDebug) { |
|
| 2247 | + echo 'Get Data...'."\n"; |
|
| 2248 | + } |
|
| 1663 | 2249 | $buffer = $Common->getData($value['host']); |
| 1664 | 2250 | $all_data = json_decode($buffer,true); |
| 1665 | 2251 | if ($buffer != '') { |
@@ -1677,12 +2263,16 @@ discard block |
||
| 1677 | 2263 | $data['id_source'] = $id_source; |
| 1678 | 2264 | $data['format_source'] = 'blitzortung'; |
| 1679 | 2265 | $SI->add($data); |
| 1680 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2266 | + if ($globalDebug) { |
|
| 2267 | + echo '☈ Lightning added'."\n"; |
|
| 2268 | + } |
|
| 1681 | 2269 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1682 | 2270 | unset($data); |
| 1683 | 2271 | } |
| 1684 | 2272 | } |
| 1685 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2273 | + if ($globalDebug) { |
|
| 2274 | + echo 'No more data...'."\n"; |
|
| 2275 | + } |
|
| 1686 | 2276 | unset($buffer); |
| 1687 | 2277 | } |
| 1688 | 2278 | $last_exec[$id]['last'] = time(); |
@@ -1711,10 +2301,15 @@ discard block |
||
| 1711 | 2301 | } |
| 1712 | 2302 | } else { |
| 1713 | 2303 | $format = $value['format']; |
| 1714 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1715 | - else $tt[$format] = 0; |
|
| 2304 | + if (isset($tt[$format])) { |
|
| 2305 | + $tt[$format]++; |
|
| 2306 | + } else { |
|
| 2307 | + $tt[$format] = 0; |
|
| 2308 | + } |
|
| 1716 | 2309 | if ($tt[$format] > 30) { |
| 1717 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 2310 | + if ($globalDebug) { |
|
| 2311 | + echo 'Reconnect...'."\n"; |
|
| 2312 | + } |
|
| 1718 | 2313 | sleep(2); |
| 1719 | 2314 | //$sourceeen[] = $value; |
| 1720 | 2315 | //connect_all($sourceeen); |
@@ -1731,7 +2326,9 @@ discard block |
||
| 1731 | 2326 | $write = NULL; |
| 1732 | 2327 | $e = NULL; |
| 1733 | 2328 | $n = socket_select($read, $write, $e, $timeout); |
| 1734 | - if ($e != NULL) var_dump($e); |
|
| 2329 | + if ($e != NULL) { |
|
| 2330 | + var_dump($e); |
|
| 2331 | + } |
|
| 1735 | 2332 | if ($n > 0) { |
| 1736 | 2333 | $reset = 0; |
| 1737 | 2334 | foreach ($read as $nb => $r) { |
@@ -1753,13 +2350,17 @@ discard block |
||
| 1753 | 2350 | if ($buffer !== FALSE) { |
| 1754 | 2351 | if ($format === 'vrstcp') { |
| 1755 | 2352 | $buffer = explode('},{',$buffer); |
| 1756 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2353 | + } else { |
|
| 2354 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2355 | + } |
|
| 1757 | 2356 | } |
| 1758 | 2357 | // SBS format is CSV format |
| 1759 | 2358 | if ($buffer !== FALSE && $buffer !== '') { |
| 1760 | 2359 | $tt[$format] = 0; |
| 1761 | 2360 | if ($format === 'acarssbs3') { |
| 1762 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2361 | + if ($globalDebug) { |
|
| 2362 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2363 | + } |
|
| 1763 | 2364 | $ACARS->add(trim($buffer)); |
| 1764 | 2365 | $ACARS->deleteLiveAcarsData(); |
| 1765 | 2366 | } elseif ($format === 'raw') { |
@@ -1769,9 +2370,15 @@ discard block |
||
| 1769 | 2370 | //if (!empty($data)) print_r($data); |
| 1770 | 2371 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1771 | 2372 | $data['format_source'] = 'raw'; |
| 1772 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1773 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1774 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2373 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2374 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2375 | + } |
|
| 2376 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2377 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2378 | + } |
|
| 2379 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2380 | + $data['noarchive'] = true; |
|
| 2381 | + } |
|
| 1775 | 2382 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1776 | 2383 | $SI->add($data); |
| 1777 | 2384 | unset($data); |
@@ -1779,22 +2386,54 @@ discard block |
||
| 1779 | 2386 | } elseif ($format === 'ais') { |
| 1780 | 2387 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1781 | 2388 | $data = array(); |
| 1782 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1783 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1784 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1785 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1786 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1787 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1788 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1789 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1790 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1791 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1792 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1793 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1794 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1795 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1796 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1797 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2389 | + if (isset($ais_data['ident'])) { |
|
| 2390 | + $data['ident'] = $ais_data['ident']; |
|
| 2391 | + } |
|
| 2392 | + if (isset($ais_data['mmsi'])) { |
|
| 2393 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 2394 | + } |
|
| 2395 | + if (isset($ais_data['speed'])) { |
|
| 2396 | + $data['speed'] = $ais_data['speed']; |
|
| 2397 | + } |
|
| 2398 | + if (isset($ais_data['heading'])) { |
|
| 2399 | + $data['heading'] = $ais_data['heading']; |
|
| 2400 | + } |
|
| 2401 | + if (isset($ais_data['latitude'])) { |
|
| 2402 | + $data['latitude'] = $ais_data['latitude']; |
|
| 2403 | + } |
|
| 2404 | + if (isset($ais_data['longitude'])) { |
|
| 2405 | + $data['longitude'] = $ais_data['longitude']; |
|
| 2406 | + } |
|
| 2407 | + if (isset($ais_data['status'])) { |
|
| 2408 | + $data['status'] = $ais_data['status']; |
|
| 2409 | + } |
|
| 2410 | + if (isset($ais_data['statusid'])) { |
|
| 2411 | + $data['status_id'] = $ais_data['statusid']; |
|
| 2412 | + } |
|
| 2413 | + if (isset($ais_data['type'])) { |
|
| 2414 | + $data['type'] = $ais_data['type']; |
|
| 2415 | + } |
|
| 2416 | + if (isset($ais_data['imo'])) { |
|
| 2417 | + $data['imo'] = $ais_data['imo']; |
|
| 2418 | + } |
|
| 2419 | + if (isset($ais_data['callsign'])) { |
|
| 2420 | + $data['callsign'] = $ais_data['callsign']; |
|
| 2421 | + } |
|
| 2422 | + if (isset($ais_data['destination'])) { |
|
| 2423 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 2424 | + } |
|
| 2425 | + if (isset($ais_data['eta_ts'])) { |
|
| 2426 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 2427 | + } |
|
| 2428 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2429 | + $data['noarchive'] = true; |
|
| 2430 | + } |
|
| 2431 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2432 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2433 | + } |
|
| 2434 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2435 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2436 | + } |
|
| 1798 | 2437 | |
| 1799 | 2438 | if (isset($ais_data['timestamp'])) { |
| 1800 | 2439 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1803,7 +2442,9 @@ discard block |
||
| 1803 | 2442 | } |
| 1804 | 2443 | $data['format_source'] = 'aisnmea'; |
| 1805 | 2444 | $data['id_source'] = $id_source; |
| 1806 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 2445 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 2446 | + $MI->add($data); |
|
| 2447 | + } |
|
| 1807 | 2448 | unset($data); |
| 1808 | 2449 | } elseif ($format === 'flightgearsp') { |
| 1809 | 2450 | //echo $buffer."\n"; |
@@ -1821,17 +2462,25 @@ discard block |
||
| 1821 | 2462 | $data['speed'] = round($line[5]*1.94384); |
| 1822 | 2463 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1823 | 2464 | $data['format_source'] = 'flightgearsp'; |
| 1824 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1825 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2465 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2466 | + $data['noarchive'] = true; |
|
| 2467 | + } |
|
| 2468 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2469 | + $SI->add($data); |
|
| 2470 | + } |
|
| 1826 | 2471 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1827 | 2472 | } |
| 1828 | 2473 | } elseif ($format === 'acars') { |
| 1829 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2474 | + if ($globalDebug) { |
|
| 2475 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2476 | + } |
|
| 1830 | 2477 | $ACARS->add(trim($buffer)); |
| 1831 | 2478 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1832 | 2479 | $ACARS->deleteLiveAcarsData(); |
| 1833 | 2480 | } elseif ($format === 'acarsjsonudp') { |
| 1834 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2481 | + if ($globalDebug) { |
|
| 2482 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2483 | + } |
|
| 1835 | 2484 | $line = json_decode(trim($buffer), true); |
| 1836 | 2485 | if (!empty($line)) { |
| 1837 | 2486 | $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
@@ -1856,8 +2505,12 @@ discard block |
||
| 1856 | 2505 | $aircraft_type = $line[10]; |
| 1857 | 2506 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1858 | 2507 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1859 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1860 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2508 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2509 | + $data['noarchive'] = true; |
|
| 2510 | + } |
|
| 2511 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2512 | + $SI->add($data); |
|
| 2513 | + } |
|
| 1861 | 2514 | } |
| 1862 | 2515 | } |
| 1863 | 2516 | } elseif ($format === 'beast') { |
@@ -1867,28 +2520,62 @@ discard block |
||
| 1867 | 2520 | foreach($buffer as $all_data) { |
| 1868 | 2521 | $line = json_decode('{'.$all_data.'}',true); |
| 1869 | 2522 | $data = array(); |
| 1870 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1871 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1872 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1873 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1874 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1875 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1876 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 2523 | + if (isset($line['Icao'])) { |
|
| 2524 | + $data['hex'] = $line['Icao']; |
|
| 2525 | + } |
|
| 2526 | + // hex |
|
| 2527 | + if (isset($line['Call'])) { |
|
| 2528 | + $data['ident'] = $line['Call']; |
|
| 2529 | + } |
|
| 2530 | + // ident |
|
| 2531 | + if (isset($line['Alt'])) { |
|
| 2532 | + $data['altitude'] = $line['Alt']; |
|
| 2533 | + } |
|
| 2534 | + // altitude |
|
| 2535 | + if (isset($line['Spd'])) { |
|
| 2536 | + $data['speed'] = $line['Spd']; |
|
| 2537 | + } |
|
| 2538 | + // speed |
|
| 2539 | + if (isset($line['Trak'])) { |
|
| 2540 | + $data['heading'] = $line['Trak']; |
|
| 2541 | + } |
|
| 2542 | + // heading |
|
| 2543 | + if (isset($line['Lat'])) { |
|
| 2544 | + $data['latitude'] = $line['Lat']; |
|
| 2545 | + } |
|
| 2546 | + // lat |
|
| 2547 | + if (isset($line['Long'])) { |
|
| 2548 | + $data['longitude'] = $line['Long']; |
|
| 2549 | + } |
|
| 2550 | + // long |
|
| 1877 | 2551 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1878 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 2552 | + if (isset($line['Sqk'])) { |
|
| 2553 | + $data['squawk'] = $line['Sqk']; |
|
| 2554 | + } |
|
| 2555 | + // squawk |
|
| 1879 | 2556 | $data['emergency'] = ''; // emergency |
| 1880 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 2557 | + if (isset($line['Reg'])) { |
|
| 2558 | + $data['registration'] = $line['Reg']; |
|
| 2559 | + } |
|
| 1881 | 2560 | /* |
| 1882 | 2561 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1883 | 2562 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1884 | 2563 | */ |
| 1885 | 2564 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1886 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 2565 | + if (isset($line['Type'])) { |
|
| 2566 | + $data['aircraft_icao'] = $line['Type']; |
|
| 2567 | + } |
|
| 1887 | 2568 | $data['format_source'] = 'vrstcp'; |
| 1888 | 2569 | $data['id_source'] = $id_source; |
| 1889 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1890 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1891 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 2570 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2571 | + $data['noarchive'] = true; |
|
| 2572 | + } |
|
| 2573 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2574 | + $data['source_name'] = $value['name']; |
|
| 2575 | + } |
|
| 2576 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 2577 | + $SI->add($data); |
|
| 2578 | + } |
|
| 1892 | 2579 | unset($data); |
| 1893 | 2580 | } |
| 1894 | 2581 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1901,22 +2588,46 @@ discard block |
||
| 1901 | 2588 | $data['hex'] = $lined['hexid']; |
| 1902 | 2589 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1903 | 2590 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1904 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1905 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1906 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1907 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1908 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1909 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1910 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 2591 | + if (isset($lined['ident'])) { |
|
| 2592 | + $data['ident'] = $lined['ident']; |
|
| 2593 | + } |
|
| 2594 | + if (isset($lined['lat'])) { |
|
| 2595 | + $data['latitude'] = $lined['lat']; |
|
| 2596 | + } |
|
| 2597 | + if (isset($lined['lon'])) { |
|
| 2598 | + $data['longitude'] = $lined['lon']; |
|
| 2599 | + } |
|
| 2600 | + if (isset($lined['speed'])) { |
|
| 2601 | + $data['speed'] = $lined['speed']; |
|
| 2602 | + } |
|
| 2603 | + if (isset($lined['squawk'])) { |
|
| 2604 | + $data['squawk'] = $lined['squawk']; |
|
| 2605 | + } |
|
| 2606 | + if (isset($lined['alt'])) { |
|
| 2607 | + $data['altitude'] = $lined['alt']; |
|
| 2608 | + } |
|
| 2609 | + if (isset($lined['heading'])) { |
|
| 2610 | + $data['heading'] = $lined['heading']; |
|
| 2611 | + } |
|
| 1911 | 2612 | $data['id_source'] = $id_source; |
| 1912 | 2613 | $data['format_source'] = 'tsv'; |
| 1913 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1914 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1915 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1916 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2614 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2615 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2616 | + } |
|
| 2617 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2618 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2619 | + } |
|
| 2620 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2621 | + $data['noarchive'] = true; |
|
| 2622 | + } |
|
| 2623 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2624 | + $SI->add($data); |
|
| 2625 | + } |
|
| 1917 | 2626 | unset($lined); |
| 1918 | 2627 | unset($data); |
| 1919 | - } else $error = true; |
|
| 2628 | + } else { |
|
| 2629 | + $error = true; |
|
| 2630 | + } |
|
| 1920 | 2631 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1921 | 2632 | if ($aprs_connect === 0) { |
| 1922 | 2633 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1942,47 +2653,96 @@ discard block |
||
| 1942 | 2653 | $aprs_last_tx = time(); |
| 1943 | 2654 | $data = array(); |
| 1944 | 2655 | //print_r($line); |
| 1945 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1946 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1947 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1948 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1949 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1950 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1951 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1952 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1953 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1954 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2656 | + if (isset($line['address'])) { |
|
| 2657 | + $data['hex'] = $line['address']; |
|
| 2658 | + } |
|
| 2659 | + if (isset($line['mmsi'])) { |
|
| 2660 | + $data['mmsi'] = $line['mmsi']; |
|
| 2661 | + } |
|
| 2662 | + if (isset($line['imo'])) { |
|
| 2663 | + $data['imo'] = $line['imo']; |
|
| 2664 | + } |
|
| 2665 | + if (isset($line['squawk'])) { |
|
| 2666 | + $data['squawk'] = $line['squawk']; |
|
| 2667 | + } |
|
| 2668 | + if (isset($line['arrival_code'])) { |
|
| 2669 | + $data['arrival_code'] = $line['arrival_code']; |
|
| 2670 | + } |
|
| 2671 | + if (isset($line['arrival_date'])) { |
|
| 2672 | + $data['arrival_date'] = $line['arrival_date']; |
|
| 2673 | + } |
|
| 2674 | + if (isset($line['typeid'])) { |
|
| 2675 | + $data['type_id'] = $line['typeid']; |
|
| 2676 | + } |
|
| 2677 | + if (isset($line['statusid'])) { |
|
| 2678 | + $data['status_id'] = $line['statusid']; |
|
| 2679 | + } |
|
| 2680 | + if (isset($line['timestamp'])) { |
|
| 2681 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 2682 | + } else { |
|
| 2683 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2684 | + } |
|
| 1955 | 2685 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1956 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 2686 | + if (isset($line['ident'])) { |
|
| 2687 | + $data['ident'] = $line['ident']; |
|
| 2688 | + } |
|
| 1957 | 2689 | $data['latitude'] = $line['latitude']; |
| 1958 | 2690 | $data['longitude'] = $line['longitude']; |
| 1959 | 2691 | //$data['verticalrate'] = $line[16]; |
| 1960 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 2692 | + if (isset($line['speed'])) { |
|
| 2693 | + $data['speed'] = $line['speed']; |
|
| 2694 | + } |
|
| 1961 | 2695 | //else $data['speed'] = 0; |
| 1962 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1963 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1964 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 2696 | + if (isset($line['altitude'])) { |
|
| 2697 | + $data['altitude'] = $line['altitude']; |
|
| 2698 | + } |
|
| 2699 | + if (isset($line['comment'])) { |
|
| 2700 | + $data['comment'] = $line['comment']; |
|
| 2701 | + } |
|
| 2702 | + if (isset($line['symbol'])) { |
|
| 2703 | + $data['type'] = $line['symbol']; |
|
| 2704 | + } |
|
| 1965 | 2705 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
| 1966 | 2706 | |
| 1967 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 2707 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
| 2708 | + $data['heading'] = $line['heading']; |
|
| 2709 | + } |
|
| 1968 | 2710 | //else echo 'No heading...'."\n"; |
| 1969 | 2711 | //else $data['heading'] = 0; |
| 1970 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 2712 | + if (isset($line['stealth'])) { |
|
| 2713 | + $data['aircraft_type'] = $line['stealth']; |
|
| 2714 | + } |
|
| 1971 | 2715 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1972 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1973 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1974 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1975 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 2716 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 2717 | + $data['noarchive'] = true; |
|
| 2718 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 2719 | + $data['noarchive'] = false; |
|
| 2720 | + } |
|
| 2721 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2722 | + $data['noarchive'] = true; |
|
| 2723 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 2724 | + $data['noarchive'] = false; |
|
| 2725 | + } |
|
| 1976 | 2726 | $data['id_source'] = $id_source; |
| 1977 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1978 | - else $data['format_source'] = 'aprs'; |
|
| 2727 | + if (isset($line['format_source'])) { |
|
| 2728 | + $data['format_source'] = $line['format_source']; |
|
| 2729 | + } else { |
|
| 2730 | + $data['format_source'] = 'aprs'; |
|
| 2731 | + } |
|
| 1979 | 2732 | $data['source_name'] = $line['source']; |
| 1980 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1981 | - else $data['source_type'] = 'flarm'; |
|
| 1982 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2733 | + if (isset($line['source_type'])) { |
|
| 2734 | + $data['source_type'] = $line['source_type']; |
|
| 2735 | + } else { |
|
| 2736 | + $data['source_type'] = 'flarm'; |
|
| 2737 | + } |
|
| 2738 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2739 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2740 | + } |
|
| 1983 | 2741 | $currentdate = date('Y-m-d H:i:s'); |
| 1984 | 2742 | $aprsdate = strtotime($data['datetime']); |
| 1985 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 2743 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
| 2744 | + $data['altitude_relative'] = 'AMSL'; |
|
| 2745 | + } |
|
| 1986 | 2746 | // Accept data if time <= system time + 20s |
| 1987 | 2747 | //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'])))) { |
| 1988 | 2748 | if ( |
@@ -1994,7 +2754,9 @@ discard block |
||
| 1994 | 2754 | $send = $SI->add($data); |
| 1995 | 2755 | } elseif ($data['source_type'] === 'ais') { |
| 1996 | 2756 | $data['type'] = ''; |
| 1997 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 2757 | + if (isset($globalMarine) && $globalMarine) { |
|
| 2758 | + $send = $MI->add($data); |
|
| 2759 | + } |
|
| 1998 | 2760 | } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
| 1999 | 2761 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 2000 | 2762 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
@@ -2002,8 +2764,12 @@ discard block |
||
| 2002 | 2764 | $line['symbol'] === 'Glider' || |
| 2003 | 2765 | $line['symbol'] === 'No. Plane' || |
| 2004 | 2766 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
| 2005 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 2006 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2767 | + if ($line['symbol'] === 'Ballon') { |
|
| 2768 | + $data['aircraft_icao'] = 'BALL'; |
|
| 2769 | + } |
|
| 2770 | + if ($line['symbol'] === 'Glider') { |
|
| 2771 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2772 | + } |
|
| 2007 | 2773 | $send = $SI->add($data); |
| 2008 | 2774 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 2009 | 2775 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -2034,9 +2800,13 @@ discard block |
||
| 2034 | 2800 | //} 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') { |
| 2035 | 2801 | // } 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') { |
| 2036 | 2802 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 2037 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 2803 | + if (isset($globalTracker) && $globalTracker) { |
|
| 2804 | + $send = $TI->add($data); |
|
| 2805 | + } |
|
| 2038 | 2806 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 2039 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
| 2807 | + if (!isset($data['altitude'])) { |
|
| 2808 | + $data['altitude'] = 0; |
|
| 2809 | + } |
|
| 2040 | 2810 | $Source->deleteOldLocationByType('gs'); |
| 2041 | 2811 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
| 2042 | 2812 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -2045,7 +2815,9 @@ discard block |
||
| 2045 | 2815 | } |
| 2046 | 2816 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 2047 | 2817 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2048 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
| 2818 | + if ($globalDebug) { |
|
| 2819 | + echo '# Weather Station added'."\n"; |
|
| 2820 | + } |
|
| 2049 | 2821 | $Source->deleteOldLocationByType('wx'); |
| 2050 | 2822 | $weather_data = json_encode($line); |
| 2051 | 2823 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -2055,7 +2827,9 @@ discard block |
||
| 2055 | 2827 | } |
| 2056 | 2828 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 2057 | 2829 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2058 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2830 | + if ($globalDebug) { |
|
| 2831 | + echo '☈ Lightning added'."\n"; |
|
| 2832 | + } |
|
| 2059 | 2833 | $Source->deleteOldLocationByType('lightning'); |
| 2060 | 2834 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
| 2061 | 2835 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -2067,8 +2841,7 @@ discard block |
||
| 2067 | 2841 | print_r($line); |
| 2068 | 2842 | } |
| 2069 | 2843 | unset($data); |
| 2070 | - } |
|
| 2071 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2844 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2072 | 2845 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 2073 | 2846 | } |
| 2074 | 2847 | /* |
@@ -2077,7 +2850,9 @@ discard block |
||
| 2077 | 2850 | } |
| 2078 | 2851 | */ |
| 2079 | 2852 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 2080 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 2853 | + elseif ($line === true && $globalDebug) { |
|
| 2854 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2855 | + } |
|
| 2081 | 2856 | if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
| 2082 | 2857 | $Source->deleteOldLocationByType('lightning'); |
| 2083 | 2858 | $Source->deleteOldLocationByType('wx'); |
@@ -2114,27 +2889,47 @@ discard block |
||
| 2114 | 2889 | $data['ground'] = $line[21]; |
| 2115 | 2890 | $data['emergency'] = $line[19]; |
| 2116 | 2891 | $data['format_source'] = 'sbs'; |
| 2117 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2118 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
| 2119 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2120 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2892 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2893 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2894 | + } elseif ($line[0] == 'MLAT') { |
|
| 2895 | + $data['source_name'] = 'MLAT'; |
|
| 2896 | + } |
|
| 2897 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2898 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2899 | + } |
|
| 2900 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2901 | + $data['noarchive'] = true; |
|
| 2902 | + } |
|
| 2121 | 2903 | $data['id_source'] = $id_source; |
| 2122 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 2123 | - else $error = true; |
|
| 2904 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2905 | + $send = $SI->add($data); |
|
| 2906 | + } else { |
|
| 2907 | + $error = true; |
|
| 2908 | + } |
|
| 2124 | 2909 | unset($data); |
| 2125 | - } else $error = true; |
|
| 2910 | + } else { |
|
| 2911 | + $error = true; |
|
| 2912 | + } |
|
| 2126 | 2913 | if ($error) { |
| 2127 | 2914 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 2128 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2915 | + if ($globalDebug) { |
|
| 2916 | + echo "Not a message. Ignoring... \n"; |
|
| 2917 | + } |
|
| 2129 | 2918 | } else { |
| 2130 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2919 | + if ($globalDebug) { |
|
| 2920 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2921 | + } |
|
| 2131 | 2922 | if ($globalDebug) { |
| 2132 | 2923 | echo $buffer; |
| 2133 | 2924 | //print_r($line); |
| 2134 | 2925 | } |
| 2135 | 2926 | //socket_close($r); |
| 2136 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 2137 | - if ($format === 'aprs') $aprs_connect = 0; |
|
| 2927 | + if ($globalDebug) { |
|
| 2928 | + echo "Reconnect after an error...\n"; |
|
| 2929 | + } |
|
| 2930 | + if ($format === 'aprs') { |
|
| 2931 | + $aprs_connect = 0; |
|
| 2932 | + } |
|
| 2138 | 2933 | $sourceer[$nb] = $globalSources[$nb]; |
| 2139 | 2934 | connect_all($sourceer); |
| 2140 | 2935 | $sourceer = array(); |
@@ -2142,10 +2937,14 @@ discard block |
||
| 2142 | 2937 | } |
| 2143 | 2938 | } |
| 2144 | 2939 | // Sleep for xxx microseconds |
| 2145 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2940 | + if (isset($globalSBSSleep)) { |
|
| 2941 | + usleep($globalSBSSleep); |
|
| 2942 | + } |
|
| 2146 | 2943 | } else { |
| 2147 | 2944 | if ($format === 'flightgearmp') { |
| 2148 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2945 | + if ($globalDebug) { |
|
| 2946 | + echo "Reconnect FlightGear MP..."; |
|
| 2947 | + } |
|
| 2149 | 2948 | //@socket_close($r); |
| 2150 | 2949 | sleep($globalMinFetch); |
| 2151 | 2950 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2154,10 +2953,15 @@ discard block |
||
| 2154 | 2953 | break; |
| 2155 | 2954 | |
| 2156 | 2955 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 2157 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 2158 | - else $tt[$format] = 0; |
|
| 2956 | + if (isset($tt[$format])) { |
|
| 2957 | + $tt[$format]++; |
|
| 2958 | + } else { |
|
| 2959 | + $tt[$format] = 0; |
|
| 2960 | + } |
|
| 2159 | 2961 | if ($tt[$format] > 30 || $buffer === FALSE) { |
| 2160 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2962 | + if ($globalDebug) { |
|
| 2963 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2964 | + } |
|
| 2161 | 2965 | //@socket_close($r); |
| 2162 | 2966 | sleep(2); |
| 2163 | 2967 | $aprs_connect = 0; |
@@ -2175,11 +2979,17 @@ discard block |
||
| 2175 | 2979 | } else { |
| 2176 | 2980 | $error = socket_strerror(socket_last_error()); |
| 2177 | 2981 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2178 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2179 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2982 | + if ($globalDebug) { |
|
| 2983 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2984 | + } |
|
| 2985 | + if (isset($globalDebug)) { |
|
| 2986 | + echo "Restarting...\n"; |
|
| 2987 | + } |
|
| 2180 | 2988 | // Restart the script if possible |
| 2181 | 2989 | if (is_array($sockets)) { |
| 2182 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2990 | + if ($globalDebug) { |
|
| 2991 | + echo "Shutdown all sockets..."; |
|
| 2992 | + } |
|
| 2183 | 2993 | |
| 2184 | 2994 | foreach ($sockets as $sock) { |
| 2185 | 2995 | @socket_shutdown($sock,2); |
@@ -2187,25 +2997,45 @@ discard block |
||
| 2187 | 2997 | } |
| 2188 | 2998 | |
| 2189 | 2999 | } |
| 2190 | - if ($globalDebug) echo "Waiting..."; |
|
| 3000 | + if ($globalDebug) { |
|
| 3001 | + echo "Waiting..."; |
|
| 3002 | + } |
|
| 2191 | 3003 | sleep(2); |
| 2192 | 3004 | $time = time(); |
| 2193 | 3005 | //connect_all($hosts); |
| 2194 | 3006 | $aprs_connect = 0; |
| 2195 | - if ($reset%5 === 0) sleep(20); |
|
| 2196 | - if ($reset%10 === 0) sleep(100); |
|
| 2197 | - if ($reset%20 === 0) sleep(200); |
|
| 2198 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 2199 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 3007 | + if ($reset%5 === 0) { |
|
| 3008 | + sleep(20); |
|
| 3009 | + } |
|
| 3010 | + if ($reset%10 === 0) { |
|
| 3011 | + sleep(100); |
|
| 3012 | + } |
|
| 3013 | + if ($reset%20 === 0) { |
|
| 3014 | + sleep(200); |
|
| 3015 | + } |
|
| 3016 | + if ($reset > 100) { |
|
| 3017 | + exit('Too many attempts...'); |
|
| 3018 | + } |
|
| 3019 | + if ($globalDebug) { |
|
| 3020 | + echo "Restart all connections..."; |
|
| 3021 | + } |
|
| 2200 | 3022 | connect_all($globalSources); |
| 2201 | 3023 | } |
| 2202 | 3024 | } |
| 2203 | 3025 | } |
| 2204 | 3026 | if ($globalDaemon === false) { |
| 2205 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2206 | - if (isset($SI)) $SI->checkAll(); |
|
| 2207 | - if (isset($TI)) $TI->checkAll(); |
|
| 2208 | - if (isset($MI)) $MI->checkAll(); |
|
| 3027 | + if ($globalDebug) { |
|
| 3028 | + echo 'Check all...'."\n"; |
|
| 3029 | + } |
|
| 3030 | + if (isset($SI)) { |
|
| 3031 | + $SI->checkAll(); |
|
| 3032 | + } |
|
| 3033 | + if (isset($TI)) { |
|
| 3034 | + $TI->checkAll(); |
|
| 3035 | + } |
|
| 3036 | + if (isset($MI)) { |
|
| 3037 | + $MI->checkAll(); |
|
| 3038 | + } |
|
| 2209 | 3039 | } |
| 2210 | 3040 | } |
| 2211 | 3041 | } |