@@ -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'] > 10*60)) |
| 792 | - ) |
|
| 792 | + ) |
|
| 793 | 793 | ) { |
| 794 | - if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') { |
|
| 794 | + if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') { |
|
| 795 | 795 | echo 'Sailaway API key MUST be defined'; |
| 796 | 796 | exit(0); |
| 797 | - } |
|
| 798 | - $sailawayoption = array('key' => $globalSailaway['key']); |
|
| 799 | - if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
| 800 | - if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 797 | + } |
|
| 798 | + $sailawayoption = array('key' => $globalSailaway['key']); |
|
| 799 | + if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
| 800 | + if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 801 | 801 | |
| 802 | - for ($i = 0; $i <= 1; $i++) { |
|
| 802 | + for ($i = 0; $i <= 1; $i++) { |
|
| 803 | 803 | if ($globalDebug) echo '! Download... '; |
| 804 | 804 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2','get','','','','',30); |
| 805 | 805 | if ($globalDebug) echo 'done'."\n"; |
| 806 | 806 | if ($buffer != '') { |
| 807 | - $all_data = json_decode($buffer,true); |
|
| 808 | - if (isset($all_data['missions'])) { |
|
| 807 | + $all_data = json_decode($buffer,true); |
|
| 808 | + if (isset($all_data['missions'])) { |
|
| 809 | 809 | foreach ($all_data['missions'] as $mission) { |
| 810 | 810 | $mission_user = $mission['usrname']; |
| 811 | 811 | $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
@@ -832,17 +832,17 @@ discard block |
||
| 832 | 832 | unset($datar); |
| 833 | 833 | } |
| 834 | 834 | } |
| 835 | - } |
|
| 835 | + } |
|
| 836 | 836 | } |
| 837 | 837 | if ($globalDebug) echo '=== Wait... ==='; |
| 838 | 838 | sleep(10*60); |
| 839 | - } |
|
| 840 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
|
| 841 | - if ($buffer != '') { |
|
| 839 | + } |
|
| 840 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
|
| 841 | + if ($buffer != '') { |
|
| 842 | 842 | $data = json_decode($buffer,true); |
| 843 | 843 | //print_r($data); |
| 844 | 844 | if (isset($data['boats'])) { |
| 845 | - foreach ($data['boats'] as $sail) { |
|
| 845 | + foreach ($data['boats'] as $sail) { |
|
| 846 | 846 | $data = array(); |
| 847 | 847 | $data['id'] = $sail['ubtnr']; |
| 848 | 848 | $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -862,17 +862,17 @@ discard block |
||
| 862 | 862 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 863 | 863 | $MI->add($data); |
| 864 | 864 | unset($data); |
| 865 | - } |
|
| 865 | + } |
|
| 866 | 866 | } elseif ($globalDebug) echo 'Error in JSON parsing'; |
| 867 | - } elseif ($globalDebug) echo 'Empty result !'."\n"; |
|
| 867 | + } elseif ($globalDebug) echo 'Empty result !'."\n"; |
|
| 868 | 868 | |
| 869 | - $last_exec[$id]['last'] = time(); |
|
| 869 | + $last_exec[$id]['last'] = time(); |
|
| 870 | 870 | } elseif ($value['format'] === 'sailaway' && |
| 871 | - ( |
|
| 871 | + ( |
|
| 872 | 872 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 10*60)) |
| 873 | - ) |
|
| 873 | + ) |
|
| 874 | 874 | ) { |
| 875 | - /* |
|
| 875 | + /* |
|
| 876 | 876 | if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { |
| 877 | 877 | $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); |
| 878 | 878 | //echo $authsailaway; |
@@ -883,20 +883,20 @@ discard block |
||
| 883 | 883 | } |
| 884 | 884 | } |
| 885 | 885 | */ |
| 886 | - if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') { |
|
| 886 | + if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') { |
|
| 887 | 887 | echo 'Sailaway API key MUST be defined'; |
| 888 | 888 | exit(0); |
| 889 | - } |
|
| 890 | - if ($globalDebug) echo '! Download... '; |
|
| 891 | - $sailawayoption = array('key' => $globalSailaway['key']); |
|
| 892 | - if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
| 893 | - if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 894 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
|
| 895 | - if ($buffer != '') { |
|
| 889 | + } |
|
| 890 | + if ($globalDebug) echo '! Download... '; |
|
| 891 | + $sailawayoption = array('key' => $globalSailaway['key']); |
|
| 892 | + if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
| 893 | + if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 894 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
|
| 895 | + if ($buffer != '') { |
|
| 896 | 896 | $data = json_decode($buffer,true); |
| 897 | 897 | //print_r($data); |
| 898 | 898 | if (isset($data['boats'])) { |
| 899 | - foreach ($data['boats'] as $sail) { |
|
| 899 | + foreach ($data['boats'] as $sail) { |
|
| 900 | 900 | $data = array(); |
| 901 | 901 | $data['id'] = $sail['ubtnr']; |
| 902 | 902 | $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -916,35 +916,35 @@ discard block |
||
| 916 | 916 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 917 | 917 | $MI->add($data); |
| 918 | 918 | unset($data); |
| 919 | - } |
|
| 919 | + } |
|
| 920 | 920 | } elseif ($globalDebug) echo 'Error in JSON parsing'; |
| 921 | - } elseif ($globalDebug) echo 'Empty result !'."\n"; |
|
| 922 | - $last_exec[$id]['last'] = time(); |
|
| 921 | + } elseif ($globalDebug) echo 'Empty result !'."\n"; |
|
| 922 | + $last_exec[$id]['last'] = time(); |
|
| 923 | 923 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 924 | 924 | } elseif ( |
| 925 | - ( |
|
| 925 | + ( |
|
| 926 | 926 | $value['format'] === 'whazzup' && |
| 927 | 927 | ( |
| 928 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 929 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 928 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 929 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 930 | 930 | ) |
| 931 | - ) || ( |
|
| 931 | + ) || ( |
|
| 932 | 932 | $value['format'] === 'vatsimtxt' && |
| 933 | 933 | ( |
| 934 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 935 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 934 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 935 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 936 | + ) |
|
| 936 | 937 | ) |
| 937 | - ) |
|
| 938 | 938 | ) { |
| 939 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 940 | - $buffer = $Common->getData($value['host']); |
|
| 941 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 942 | - $buffer = explode('\n',$buffer); |
|
| 943 | - $reset = 0; |
|
| 944 | - foreach ($buffer as $line) { |
|
| 945 | - if ($line != '') { |
|
| 946 | - $line = explode(':', $line); |
|
| 947 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 939 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 940 | + $buffer = $Common->getData($value['host']); |
|
| 941 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 942 | + $buffer = explode('\n',$buffer); |
|
| 943 | + $reset = 0; |
|
| 944 | + foreach ($buffer as $line) { |
|
| 945 | + if ($line != '') { |
|
| 946 | + $line = explode(':', $line); |
|
| 947 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 948 | 948 | $data = array(); |
| 949 | 949 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 950 | 950 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -957,41 +957,41 @@ discard block |
||
| 957 | 957 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 958 | 958 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 959 | 959 | $data['latitude'] = $line[5]; // lat |
| 960 | - $data['longitude'] = $line[6]; // long |
|
| 961 | - $data['verticalrate'] = ''; // vertical rate |
|
| 962 | - $data['squawk'] = ''; // squawk |
|
| 963 | - $data['emergency'] = ''; // emergency |
|
| 964 | - $data['waypoints'] = $line[30]; |
|
| 960 | + $data['longitude'] = $line[6]; // long |
|
| 961 | + $data['verticalrate'] = ''; // vertical rate |
|
| 962 | + $data['squawk'] = ''; // squawk |
|
| 963 | + $data['emergency'] = ''; // emergency |
|
| 964 | + $data['waypoints'] = $line[30]; |
|
| 965 | 965 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 966 | 966 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 967 | 967 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 968 | - $data['departure_airport_icao'] = $line[11]; |
|
| 969 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 970 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 968 | + $data['departure_airport_icao'] = $line[11]; |
|
| 969 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 970 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 971 | 971 | $data['frequency'] = $line[4]; |
| 972 | 972 | $data['type'] = $line[18]; |
| 973 | 973 | $data['range'] = $line[19]; |
| 974 | 974 | if (isset($line[35])) $data['info'] = $line[35]; |
| 975 | - $data['id_source'] = $id_source; |
|
| 976 | - //$data['arrival_airport_time'] = ; |
|
| 977 | - if ($line[9] != '') { |
|
| 978 | - $aircraft_data = explode('/',$line[9]); |
|
| 979 | - if (count($aircraft_data) == 2) { |
|
| 975 | + $data['id_source'] = $id_source; |
|
| 976 | + //$data['arrival_airport_time'] = ; |
|
| 977 | + if ($line[9] != '') { |
|
| 978 | + $aircraft_data = explode('/',$line[9]); |
|
| 979 | + if (count($aircraft_data) == 2) { |
|
| 980 | 980 | //line[9] may equal to something like 'B738/L' in old FSD server's whazzup.txt file |
| 981 | - $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 982 | - } else if (count($aircraft_data) > 2) { |
|
| 981 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 982 | + } else if (count($aircraft_data) > 2) { |
|
| 983 | 983 | //line[9] may equal to something like 'H/B748/L' |
| 984 | 984 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 985 | - } |
|
| 986 | - } |
|
| 987 | - /* |
|
| 985 | + } |
|
| 986 | + } |
|
| 987 | + /* |
|
| 988 | 988 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
| 989 | 989 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 990 | 990 | */ |
| 991 | - $data['format_source'] = $value['format']; |
|
| 991 | + $data['format_source'] = $value['format']; |
|
| 992 | 992 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 993 | 993 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 994 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 994 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
| 995 | 995 | elseif ($line[3] === 'ATC') { |
| 996 | 996 | //print_r($data); |
| 997 | 997 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -1012,21 +1012,21 @@ discard block |
||
| 1012 | 1012 | 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']); |
| 1013 | 1013 | } |
| 1014 | 1014 | } |
| 1015 | - unset($data); |
|
| 1016 | - } |
|
| 1017 | - } |
|
| 1018 | - } |
|
| 1019 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
| 1020 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 1021 | - $last_exec[$id]['last'] = time(); |
|
| 1022 | - } elseif ($value['format'] === 'airwhere' && |
|
| 1023 | - ( |
|
| 1024 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1025 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1026 | - ) |
|
| 1027 | - ) { |
|
| 1028 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 1029 | - if ($buffer != '') { |
|
| 1015 | + unset($data); |
|
| 1016 | + } |
|
| 1017 | + } |
|
| 1018 | + } |
|
| 1019 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
| 1020 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 1021 | + $last_exec[$id]['last'] = time(); |
|
| 1022 | + } elseif ($value['format'] === 'airwhere' && |
|
| 1023 | + ( |
|
| 1024 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1025 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1026 | + ) |
|
| 1027 | + ) { |
|
| 1028 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 1029 | + if ($buffer != '') { |
|
| 1030 | 1030 | $all_data = simplexml_load_string($buffer); |
| 1031 | 1031 | foreach($all_data->children() as $childdata) { |
| 1032 | 1032 | $data = array(); |
@@ -1048,10 +1048,10 @@ discard block |
||
| 1048 | 1048 | $SI->add($data); |
| 1049 | 1049 | unset($data); |
| 1050 | 1050 | } |
| 1051 | - } |
|
| 1052 | - $Source->deleteOldLocationByType('gs'); |
|
| 1053 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 1054 | - if ($buffer != '') { |
|
| 1051 | + } |
|
| 1052 | + $Source->deleteOldLocationByType('gs'); |
|
| 1053 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 1054 | + if ($buffer != '') { |
|
| 1055 | 1055 | $all_data = simplexml_load_string($buffer); |
| 1056 | 1056 | foreach($all_data->children() as $childdata) { |
| 1057 | 1057 | $data = array(); |
@@ -1069,8 +1069,8 @@ discard block |
||
| 1069 | 1069 | } |
| 1070 | 1070 | unset($data); |
| 1071 | 1071 | } |
| 1072 | - } |
|
| 1073 | - $last_exec[$id]['last'] = time(); |
|
| 1072 | + } |
|
| 1073 | + $last_exec[$id]['last'] = time(); |
|
| 1074 | 1074 | /* |
| 1075 | 1075 | } if ($value['format'] === 'aircraftlistjson') { |
| 1076 | 1076 | print_r($globalSources); |
@@ -1078,17 +1078,17 @@ discard block |
||
| 1078 | 1078 | echo $globalMinFetch; |
| 1079 | 1079 | */ |
| 1080 | 1080 | } elseif ($value['format'] === 'aircraftlistjson' && |
| 1081 | - ( |
|
| 1081 | + ( |
|
| 1082 | 1082 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1083 | 1083 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1084 | - ) |
|
| 1084 | + ) |
|
| 1085 | 1085 | ) { |
| 1086 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 1087 | - if ($buffer != '') { |
|
| 1088 | - $all_data = json_decode($buffer,true); |
|
| 1086 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 1087 | + if ($buffer != '') { |
|
| 1088 | + $all_data = json_decode($buffer,true); |
|
| 1089 | 1089 | if (isset($all_data['acList'])) { |
| 1090 | - $reset = 0; |
|
| 1091 | - foreach ($all_data['acList'] as $line) { |
|
| 1090 | + $reset = 0; |
|
| 1091 | + foreach ($all_data['acList'] as $line) { |
|
| 1092 | 1092 | $data = array(); |
| 1093 | 1093 | $data['hex'] = $line['Icao']; // hex |
| 1094 | 1094 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1111,10 +1111,10 @@ discard block |
||
| 1111 | 1111 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1112 | 1112 | if (isset($data['latitude'])) $SI->add($data); |
| 1113 | 1113 | unset($data); |
| 1114 | - } |
|
| 1114 | + } |
|
| 1115 | 1115 | } elseif (is_array($all_data)) { |
| 1116 | - $reset = 0; |
|
| 1117 | - foreach ($all_data as $line) { |
|
| 1116 | + $reset = 0; |
|
| 1117 | + foreach ($all_data as $line) { |
|
| 1118 | 1118 | $data = array(); |
| 1119 | 1119 | $data['hex'] = $line['hex']; // hex |
| 1120 | 1120 | $data['ident'] = $line['flight']; // ident |
@@ -1134,291 +1134,291 @@ discard block |
||
| 1134 | 1134 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1135 | 1135 | $SI->add($data); |
| 1136 | 1136 | unset($data); |
| 1137 | - } |
|
| 1137 | + } |
|
| 1138 | 1138 | } |
| 1139 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1140 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 1141 | - $last_exec[$id]['last'] = time(); |
|
| 1142 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 1143 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
| 1144 | - ( |
|
| 1145 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1146 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1147 | - ) |
|
| 1148 | - ) { |
|
| 1149 | - $buffer = $Common->getData($value['host']); |
|
| 1150 | - $all_data = json_decode($buffer,true); |
|
| 1151 | - if (isset($all_data['planes'])) { |
|
| 1139 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1140 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 1141 | + $last_exec[$id]['last'] = time(); |
|
| 1142 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 1143 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
| 1144 | + ( |
|
| 1145 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1146 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1147 | + ) |
|
| 1148 | + ) { |
|
| 1149 | + $buffer = $Common->getData($value['host']); |
|
| 1150 | + $all_data = json_decode($buffer,true); |
|
| 1151 | + if (isset($all_data['planes'])) { |
|
| 1152 | 1152 | $reset = 0; |
| 1153 | 1153 | foreach ($all_data['planes'] as $key => $line) { |
| 1154 | - $data = array(); |
|
| 1155 | - $data['hex'] = $key; // hex |
|
| 1156 | - $data['ident'] = $line[3]; // ident |
|
| 1157 | - $data['altitude'] = $line[6]; // altitude |
|
| 1158 | - $data['speed'] = $line[8]; // speed |
|
| 1159 | - $data['heading'] = $line[7]; // heading |
|
| 1160 | - $data['latitude'] = $line[4]; // lat |
|
| 1161 | - $data['longitude'] = $line[5]; // long |
|
| 1162 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 1163 | - $data['squawk'] = $line[10]; // squawk |
|
| 1164 | - $data['emergency'] = ''; // emergency |
|
| 1165 | - $data['registration'] = $line[2]; |
|
| 1166 | - $data['aircraft_icao'] = $line[0]; |
|
| 1167 | - $deparr = explode('-',$line[1]); |
|
| 1168 | - if (count($deparr) === 2) { |
|
| 1154 | + $data = array(); |
|
| 1155 | + $data['hex'] = $key; // hex |
|
| 1156 | + $data['ident'] = $line[3]; // ident |
|
| 1157 | + $data['altitude'] = $line[6]; // altitude |
|
| 1158 | + $data['speed'] = $line[8]; // speed |
|
| 1159 | + $data['heading'] = $line[7]; // heading |
|
| 1160 | + $data['latitude'] = $line[4]; // lat |
|
| 1161 | + $data['longitude'] = $line[5]; // long |
|
| 1162 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 1163 | + $data['squawk'] = $line[10]; // squawk |
|
| 1164 | + $data['emergency'] = ''; // emergency |
|
| 1165 | + $data['registration'] = $line[2]; |
|
| 1166 | + $data['aircraft_icao'] = $line[0]; |
|
| 1167 | + $deparr = explode('-',$line[1]); |
|
| 1168 | + if (count($deparr) === 2) { |
|
| 1169 | 1169 | $data['departure_airport_icao'] = $deparr[0]; |
| 1170 | 1170 | $data['arrival_airport_icao'] = $deparr[1]; |
| 1171 | - } |
|
| 1172 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1173 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 1174 | - $data['id_source'] = $id_source; |
|
| 1175 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1176 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1177 | - $SI->add($data); |
|
| 1178 | - unset($data); |
|
| 1171 | + } |
|
| 1172 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1173 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 1174 | + $data['id_source'] = $id_source; |
|
| 1175 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1176 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1177 | + $SI->add($data); |
|
| 1178 | + unset($data); |
|
| 1179 | 1179 | } |
| 1180 | - } |
|
| 1181 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1182 | - $last_exec[$id]['last'] = time(); |
|
| 1180 | + } |
|
| 1181 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1182 | + $last_exec[$id]['last'] = time(); |
|
| 1183 | 1183 | } elseif ($value['format'] === 'opensky' && |
| 1184 | - ( |
|
| 1184 | + ( |
|
| 1185 | 1185 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1186 | 1186 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1187 | - ) |
|
| 1187 | + ) |
|
| 1188 | 1188 | ) { |
| 1189 | - $buffer = $Common->getData($value['host']); |
|
| 1190 | - $all_data = json_decode($buffer,true); |
|
| 1191 | - if (isset($all_data['states'])) { |
|
| 1189 | + $buffer = $Common->getData($value['host']); |
|
| 1190 | + $all_data = json_decode($buffer,true); |
|
| 1191 | + if (isset($all_data['states'])) { |
|
| 1192 | 1192 | $reset = 0; |
| 1193 | 1193 | foreach ($all_data['states'] as $key => $line) { |
| 1194 | - $data = array(); |
|
| 1195 | - $data['hex'] = $line[0]; // hex |
|
| 1196 | - $data['ident'] = trim($line[1]); // ident |
|
| 1197 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 1198 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 1199 | - $data['heading'] = round($line[10]); // heading |
|
| 1200 | - $data['latitude'] = $line[6]; // lat |
|
| 1201 | - $data['longitude'] = $line[5]; // long |
|
| 1202 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 1203 | - //$data['squawk'] = $line[10]; // squawk |
|
| 1204 | - //$data['emergency'] = ''; // emergency |
|
| 1205 | - //$data['registration'] = $line[2]; |
|
| 1206 | - //$data['aircraft_icao'] = $line[0]; |
|
| 1207 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1208 | - $data['format_source'] = 'opensky'; |
|
| 1209 | - $data['id_source'] = $id_source; |
|
| 1210 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1211 | - $SI->add($data); |
|
| 1212 | - unset($data); |
|
| 1194 | + $data = array(); |
|
| 1195 | + $data['hex'] = $line[0]; // hex |
|
| 1196 | + $data['ident'] = trim($line[1]); // ident |
|
| 1197 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 1198 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 1199 | + $data['heading'] = round($line[10]); // heading |
|
| 1200 | + $data['latitude'] = $line[6]; // lat |
|
| 1201 | + $data['longitude'] = $line[5]; // long |
|
| 1202 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 1203 | + //$data['squawk'] = $line[10]; // squawk |
|
| 1204 | + //$data['emergency'] = ''; // emergency |
|
| 1205 | + //$data['registration'] = $line[2]; |
|
| 1206 | + //$data['aircraft_icao'] = $line[0]; |
|
| 1207 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1208 | + $data['format_source'] = 'opensky'; |
|
| 1209 | + $data['id_source'] = $id_source; |
|
| 1210 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1211 | + $SI->add($data); |
|
| 1212 | + unset($data); |
|
| 1213 | 1213 | } |
| 1214 | - } |
|
| 1215 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1216 | - $last_exec[$id]['last'] = time(); |
|
| 1214 | + } |
|
| 1215 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1216 | + $last_exec[$id]['last'] = time(); |
|
| 1217 | 1217 | } elseif ($value['format'] === 'aircraftjson' && |
| 1218 | - ( |
|
| 1218 | + ( |
|
| 1219 | 1219 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1220 | 1220 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1221 | - ) |
|
| 1221 | + ) |
|
| 1222 | 1222 | ) { |
| 1223 | - $buffer = $Common->getData($value['host']); |
|
| 1224 | - $all_data = json_decode($buffer,true); |
|
| 1225 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1223 | + $buffer = $Common->getData($value['host']); |
|
| 1224 | + $all_data = json_decode($buffer,true); |
|
| 1225 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1226 | 1226 | $reset = 0; |
| 1227 | 1227 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1228 | - $data = array(); |
|
| 1229 | - // add support for ground vehicule with ~ in front of hex |
|
| 1230 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1231 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1232 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1233 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1234 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1235 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1236 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1237 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1238 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1239 | - //$data['emergency'] = ''; // emergency |
|
| 1240 | - //$data['registration'] = $line[2]; |
|
| 1241 | - //$data['aircraft_icao'] = $line[0]; |
|
| 1242 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1243 | - $data['format_source'] = 'aircraftjson'; |
|
| 1244 | - $data['id_source'] = $id_source; |
|
| 1245 | - if (isset($value['name']) && $value['name'] != '') { |
|
| 1246 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1247 | - else $data['source_name'] = $value['name']; |
|
| 1248 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1249 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1250 | - $SI->add($data); |
|
| 1251 | - unset($data); |
|
| 1228 | + $data = array(); |
|
| 1229 | + // add support for ground vehicule with ~ in front of hex |
|
| 1230 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1231 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1232 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1233 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1234 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1235 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1236 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1237 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1238 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1239 | + //$data['emergency'] = ''; // emergency |
|
| 1240 | + //$data['registration'] = $line[2]; |
|
| 1241 | + //$data['aircraft_icao'] = $line[0]; |
|
| 1242 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1243 | + $data['format_source'] = 'aircraftjson'; |
|
| 1244 | + $data['id_source'] = $id_source; |
|
| 1245 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1246 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1247 | + else $data['source_name'] = $value['name']; |
|
| 1248 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1249 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1250 | + $SI->add($data); |
|
| 1251 | + unset($data); |
|
| 1252 | 1252 | } |
| 1253 | - } |
|
| 1254 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1255 | - $last_exec[$id]['last'] = time(); |
|
| 1253 | + } |
|
| 1254 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1255 | + $last_exec[$id]['last'] = time(); |
|
| 1256 | 1256 | } elseif ($value['format'] === 'planefinderclient' && |
| 1257 | - ( |
|
| 1257 | + ( |
|
| 1258 | 1258 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1259 | 1259 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1260 | - ) |
|
| 1260 | + ) |
|
| 1261 | 1261 | ) { |
| 1262 | - $buffer = $Common->getData($value['host']); |
|
| 1263 | - $all_data = json_decode($buffer,true); |
|
| 1264 | - if (isset($all_data['aircraft'])) { |
|
| 1262 | + $buffer = $Common->getData($value['host']); |
|
| 1263 | + $all_data = json_decode($buffer,true); |
|
| 1264 | + if (isset($all_data['aircraft'])) { |
|
| 1265 | 1265 | $reset = 0; |
| 1266 | 1266 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1267 | - $data = array(); |
|
| 1268 | - $data['hex'] = $key; // hex |
|
| 1269 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1270 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1271 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1272 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1273 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1274 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1275 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1276 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1277 | - //$data['emergency'] = ''; // emergency |
|
| 1278 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1279 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1280 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1281 | - $data['format_source'] = 'planefinderclient'; |
|
| 1282 | - $data['id_source'] = $id_source; |
|
| 1283 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1284 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1285 | - $SI->add($data); |
|
| 1286 | - unset($data); |
|
| 1267 | + $data = array(); |
|
| 1268 | + $data['hex'] = $key; // hex |
|
| 1269 | + if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1270 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1271 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1272 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1273 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1274 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1275 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1276 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1277 | + //$data['emergency'] = ''; // emergency |
|
| 1278 | + if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1279 | + if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1280 | + $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1281 | + $data['format_source'] = 'planefinderclient'; |
|
| 1282 | + $data['id_source'] = $id_source; |
|
| 1283 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1284 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1285 | + $SI->add($data); |
|
| 1286 | + unset($data); |
|
| 1287 | 1287 | } |
| 1288 | - } |
|
| 1289 | - $last_exec[$id]['last'] = time(); |
|
| 1288 | + } |
|
| 1289 | + $last_exec[$id]['last'] = time(); |
|
| 1290 | 1290 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
| 1291 | 1291 | } elseif ($value['format'] === 'fr24json' && |
| 1292 | - ( |
|
| 1292 | + ( |
|
| 1293 | 1293 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1294 | 1294 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1295 | - ) |
|
| 1295 | + ) |
|
| 1296 | 1296 | ) { |
| 1297 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1298 | - $buffer = $Common->getData($value['host']); |
|
| 1299 | - $all_data = json_decode($buffer,true); |
|
| 1300 | - if (!empty($all_data)) $reset = 0; |
|
| 1301 | - foreach ($all_data as $key => $line) { |
|
| 1297 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1298 | + $buffer = $Common->getData($value['host']); |
|
| 1299 | + $all_data = json_decode($buffer,true); |
|
| 1300 | + if (!empty($all_data)) $reset = 0; |
|
| 1301 | + foreach ($all_data as $key => $line) { |
|
| 1302 | 1302 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1303 | - $data = array(); |
|
| 1304 | - $data['hex'] = $line[0]; |
|
| 1305 | - $data['ident'] = $line[16]; //$line[13] |
|
| 1306 | - $data['altitude'] = $line[4]; // altitude |
|
| 1307 | - $data['speed'] = $line[5]; // speed |
|
| 1308 | - $data['heading'] = $line[3]; // heading |
|
| 1309 | - $data['latitude'] = $line[1]; // lat |
|
| 1310 | - $data['longitude'] = $line[2]; // long |
|
| 1311 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1312 | - $data['squawk'] = $line[6]; // squawk |
|
| 1313 | - $data['aircraft_icao'] = $line[8]; |
|
| 1314 | - $data['registration'] = $line[9]; |
|
| 1315 | - $data['departure_airport_iata'] = $line[11]; |
|
| 1316 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 1317 | - $data['emergency'] = ''; // emergency |
|
| 1318 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1319 | - $data['format_source'] = 'fr24json'; |
|
| 1320 | - $data['id_source'] = $id_source; |
|
| 1321 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1322 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1323 | - $SI->add($data); |
|
| 1324 | - unset($data); |
|
| 1303 | + $data = array(); |
|
| 1304 | + $data['hex'] = $line[0]; |
|
| 1305 | + $data['ident'] = $line[16]; //$line[13] |
|
| 1306 | + $data['altitude'] = $line[4]; // altitude |
|
| 1307 | + $data['speed'] = $line[5]; // speed |
|
| 1308 | + $data['heading'] = $line[3]; // heading |
|
| 1309 | + $data['latitude'] = $line[1]; // lat |
|
| 1310 | + $data['longitude'] = $line[2]; // long |
|
| 1311 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1312 | + $data['squawk'] = $line[6]; // squawk |
|
| 1313 | + $data['aircraft_icao'] = $line[8]; |
|
| 1314 | + $data['registration'] = $line[9]; |
|
| 1315 | + $data['departure_airport_iata'] = $line[11]; |
|
| 1316 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 1317 | + $data['emergency'] = ''; // emergency |
|
| 1318 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1319 | + $data['format_source'] = 'fr24json'; |
|
| 1320 | + $data['id_source'] = $id_source; |
|
| 1321 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1322 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1323 | + $SI->add($data); |
|
| 1324 | + unset($data); |
|
| 1325 | 1325 | } |
| 1326 | - } |
|
| 1327 | - //$last_exec['fr24json'] = time(); |
|
| 1328 | - $last_exec[$id]['last'] = time(); |
|
| 1326 | + } |
|
| 1327 | + //$last_exec['fr24json'] = time(); |
|
| 1328 | + $last_exec[$id]['last'] = time(); |
|
| 1329 | 1329 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 1330 | 1330 | } elseif ($value['format'] === 'radarvirtueljson' && |
| 1331 | - ( |
|
| 1331 | + ( |
|
| 1332 | 1332 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1333 | 1333 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1334 | - ) |
|
| 1334 | + ) |
|
| 1335 | 1335 | ) { |
| 1336 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1337 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1338 | - //echo $buffer; |
|
| 1339 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1340 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1341 | - $all_data = json_decode($buffer,true); |
|
| 1342 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1336 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1337 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1338 | + //echo $buffer; |
|
| 1339 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1340 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1341 | + $all_data = json_decode($buffer,true); |
|
| 1342 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1343 | 1343 | die(json_last_error_msg()); |
| 1344 | - } |
|
| 1345 | - if (isset($all_data['mrkrs'])) { |
|
| 1344 | + } |
|
| 1345 | + if (isset($all_data['mrkrs'])) { |
|
| 1346 | 1346 | $reset = 0; |
| 1347 | 1347 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 1348 | - if (isset($line['inf'])) { |
|
| 1348 | + if (isset($line['inf'])) { |
|
| 1349 | 1349 | $data = array(); |
| 1350 | 1350 | $data['hex'] = $line['inf']['ia']; |
| 1351 | 1351 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 1352 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1353 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1354 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1355 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 1356 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 1357 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1358 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1359 | - //$data['aircraft_icao'] = $line[8]; |
|
| 1360 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1352 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1353 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1354 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1355 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 1356 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 1357 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1358 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1359 | + //$data['aircraft_icao'] = $line[8]; |
|
| 1360 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1361 | 1361 | //$data['departure_airport_iata'] = $line[11]; |
| 1362 | 1362 | //$data['arrival_airport_iata'] = $line[12]; |
| 1363 | - //$data['emergency'] = ''; // emergency |
|
| 1363 | + //$data['emergency'] = ''; // emergency |
|
| 1364 | 1364 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1365 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 1366 | - $data['id_source'] = $id_source; |
|
| 1365 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 1366 | + $data['id_source'] = $id_source; |
|
| 1367 | 1367 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1368 | 1368 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1369 | 1369 | $SI->add($data); |
| 1370 | 1370 | unset($data); |
| 1371 | - } |
|
| 1371 | + } |
|
| 1372 | 1372 | } |
| 1373 | - } |
|
| 1374 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 1375 | - $last_exec[$id]['last'] = time(); |
|
| 1373 | + } |
|
| 1374 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 1375 | + $last_exec[$id]['last'] = time(); |
|
| 1376 | 1376 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
| 1377 | 1377 | } elseif ($value['format'] === 'pirepsjson' && |
| 1378 | - ( |
|
| 1378 | + ( |
|
| 1379 | 1379 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1380 | 1380 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1381 | - ) |
|
| 1381 | + ) |
|
| 1382 | 1382 | ) { |
| 1383 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1384 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1385 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1383 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1384 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1385 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1386 | 1386 | |
| 1387 | - if (isset($all_data['pireps'])) { |
|
| 1387 | + if (isset($all_data['pireps'])) { |
|
| 1388 | 1388 | $reset = 0; |
| 1389 | - foreach ($all_data['pireps'] as $line) { |
|
| 1390 | - $data = array(); |
|
| 1391 | - $data['id'] = $line['id']; |
|
| 1392 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1393 | - $data['ident'] = $line['callsign']; // ident |
|
| 1394 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1395 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1396 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1397 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1398 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1399 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1400 | - $data['latitude'] = $line['lat']; // lat |
|
| 1401 | - $data['longitude'] = $line['lon']; // long |
|
| 1402 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1403 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 1404 | - //$data['emergency'] = ''; // emergency |
|
| 1405 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1406 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1407 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1408 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1409 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1410 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1411 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1412 | - else $data['info'] = ''; |
|
| 1413 | - $data['format_source'] = 'pireps'; |
|
| 1414 | - $data['id_source'] = $id_source; |
|
| 1415 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1416 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1417 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1418 | - if ($line['icon'] === 'plane') { |
|
| 1389 | + foreach ($all_data['pireps'] as $line) { |
|
| 1390 | + $data = array(); |
|
| 1391 | + $data['id'] = $line['id']; |
|
| 1392 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1393 | + $data['ident'] = $line['callsign']; // ident |
|
| 1394 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1395 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1396 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1397 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1398 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1399 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1400 | + $data['latitude'] = $line['lat']; // lat |
|
| 1401 | + $data['longitude'] = $line['lon']; // long |
|
| 1402 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1403 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 1404 | + //$data['emergency'] = ''; // emergency |
|
| 1405 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1406 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1407 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1408 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1409 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1410 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1411 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1412 | + else $data['info'] = ''; |
|
| 1413 | + $data['format_source'] = 'pireps'; |
|
| 1414 | + $data['id_source'] = $id_source; |
|
| 1415 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1416 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1417 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1418 | + if ($line['icon'] === 'plane') { |
|
| 1419 | 1419 | $SI->add($data); |
| 1420 | - // print_r($data); |
|
| 1421 | - } elseif ($line['icon'] === 'ct') { |
|
| 1420 | + // print_r($data); |
|
| 1421 | + } elseif ($line['icon'] === 'ct') { |
|
| 1422 | 1422 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 1423 | 1423 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1424 | 1424 | $typec = substr($data['ident'],-3); |
@@ -1433,210 +1433,210 @@ discard block |
||
| 1433 | 1433 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1434 | 1434 | else $data['type'] = 'Observer'; |
| 1435 | 1435 | 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']); |
| 1436 | - } |
|
| 1437 | - unset($data); |
|
| 1436 | + } |
|
| 1437 | + unset($data); |
|
| 1438 | 1438 | } |
| 1439 | - } |
|
| 1440 | - //$last_exec['pirepsjson'] = time(); |
|
| 1441 | - $last_exec[$id]['last'] = time(); |
|
| 1439 | + } |
|
| 1440 | + //$last_exec['pirepsjson'] = time(); |
|
| 1441 | + $last_exec[$id]['last'] = time(); |
|
| 1442 | 1442 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 1443 | 1443 | } elseif ($value['format'] === 'phpvmacars' && |
| 1444 | - ( |
|
| 1444 | + ( |
|
| 1445 | 1445 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1446 | 1446 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1447 | - ) |
|
| 1447 | + ) |
|
| 1448 | 1448 | ) { |
| 1449 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1450 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1451 | - $buffer = $Common->getData($value['host']); |
|
| 1452 | - $all_data = json_decode($buffer,true); |
|
| 1453 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1449 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1450 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1451 | + $buffer = $Common->getData($value['host']); |
|
| 1452 | + $all_data = json_decode($buffer,true); |
|
| 1453 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1454 | 1454 | $reset = 0; |
| 1455 | 1455 | foreach ($all_data as $line) { |
| 1456 | - $data = array(); |
|
| 1457 | - //$data['id'] = $line['id']; // id not usable |
|
| 1458 | - if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']); |
|
| 1459 | - elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1460 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1461 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1462 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1463 | - $data['ident'] = $line['flightnum']; // ident |
|
| 1464 | - $data['altitude'] = $line['alt']; // altitude |
|
| 1465 | - $data['speed'] = $line['gs']; // speed |
|
| 1466 | - $data['heading'] = $line['heading']; // heading |
|
| 1467 | - $data['latitude'] = $line['lat']; // lat |
|
| 1468 | - $data['longitude'] = $line['lng']; // long |
|
| 1469 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1470 | - $data['squawk'] = ''; // squawk |
|
| 1471 | - $data['emergency'] = ''; // emergency |
|
| 1472 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1473 | - //$data['last_update'] = $line['lastupdate']; |
|
| 1474 | - if (isset($value['timezone'])) { |
|
| 1475 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1476 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1477 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1478 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1479 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 1480 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 1481 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1482 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1483 | - if (isset($line['registration'])) { |
|
| 1484 | - $data['registration'] = trim($line['registration']); |
|
| 1485 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1486 | - } else $data['registration'] = $line['aircraft']; |
|
| 1487 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1488 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1489 | - if (isset($line['aircraftname'])) { |
|
| 1456 | + $data = array(); |
|
| 1457 | + //$data['id'] = $line['id']; // id not usable |
|
| 1458 | + if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']); |
|
| 1459 | + elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1460 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1461 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1462 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1463 | + $data['ident'] = $line['flightnum']; // ident |
|
| 1464 | + $data['altitude'] = $line['alt']; // altitude |
|
| 1465 | + $data['speed'] = $line['gs']; // speed |
|
| 1466 | + $data['heading'] = $line['heading']; // heading |
|
| 1467 | + $data['latitude'] = $line['lat']; // lat |
|
| 1468 | + $data['longitude'] = $line['lng']; // long |
|
| 1469 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1470 | + $data['squawk'] = ''; // squawk |
|
| 1471 | + $data['emergency'] = ''; // emergency |
|
| 1472 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1473 | + //$data['last_update'] = $line['lastupdate']; |
|
| 1474 | + if (isset($value['timezone'])) { |
|
| 1475 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1476 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1477 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1478 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1479 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1480 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1481 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1482 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1483 | + if (isset($line['registration'])) { |
|
| 1484 | + $data['registration'] = trim($line['registration']); |
|
| 1485 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1486 | + } else $data['registration'] = $line['aircraft']; |
|
| 1487 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1488 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1489 | + if (isset($line['aircraftname'])) { |
|
| 1490 | 1490 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1491 | 1491 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1492 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1493 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1494 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1495 | - else { |
|
| 1496 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1497 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1498 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1499 | - } |
|
| 1500 | - } |
|
| 1501 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1502 | - $data['id_source'] = $id_source; |
|
| 1503 | - $data['format_source'] = 'phpvmacars'; |
|
| 1504 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1505 | - $SI->add($data); |
|
| 1506 | - unset($data); |
|
| 1492 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1493 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1494 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1495 | + else { |
|
| 1496 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1497 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1498 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1499 | + } |
|
| 1500 | + } |
|
| 1501 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1502 | + $data['id_source'] = $id_source; |
|
| 1503 | + $data['format_source'] = 'phpvmacars'; |
|
| 1504 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1505 | + $SI->add($data); |
|
| 1506 | + unset($data); |
|
| 1507 | 1507 | } |
| 1508 | 1508 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1509 | 1509 | unset($buffer); |
| 1510 | 1510 | unset($all_data); |
| 1511 | - } |
|
| 1512 | - //$last_exec['phpvmacars'] = time(); |
|
| 1513 | - $last_exec[$id]['last'] = time(); |
|
| 1511 | + } |
|
| 1512 | + //$last_exec['phpvmacars'] = time(); |
|
| 1513 | + $last_exec[$id]['last'] = time(); |
|
| 1514 | 1514 | } elseif ($value['format'] === 'vaos' && |
| 1515 | - ( |
|
| 1515 | + ( |
|
| 1516 | 1516 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1517 | 1517 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1518 | - ) |
|
| 1518 | + ) |
|
| 1519 | 1519 | ) { |
| 1520 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1521 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1522 | - $buffer = $Common->getData($value['host']); |
|
| 1523 | - $all_data = json_decode($buffer,true); |
|
| 1524 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
| 1520 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1521 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1522 | + $buffer = $Common->getData($value['host']); |
|
| 1523 | + $all_data = json_decode($buffer,true); |
|
| 1524 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
| 1525 | 1525 | $reset = 0; |
| 1526 | 1526 | foreach ($all_data['ACARSData'] as $line) { |
| 1527 | - //print_r($line); |
|
| 1528 | - $data = array(); |
|
| 1529 | - //$data['id'] = $line['id']; // id not usable |
|
| 1530 | - $data['id'] = $line['id']; |
|
| 1531 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1532 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1533 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1534 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1535 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1536 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1537 | - $data['speed'] = $line['groundspeed']; // speed |
|
| 1538 | - $data['heading'] = $line['heading']; // heading |
|
| 1539 | - $data['latitude'] = $line['lat']; // lat |
|
| 1540 | - $data['longitude'] = $line['lon']; // long |
|
| 1541 | - //$data['verticalrate'] = ''; // verticale rate |
|
| 1542 | - //$data['squawk'] = ''; // squawk |
|
| 1543 | - //$data['emergency'] = ''; // emergency |
|
| 1544 | - if (isset($value['timezone'])) { |
|
| 1545 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1546 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1547 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1548 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1527 | + //print_r($line); |
|
| 1528 | + $data = array(); |
|
| 1529 | + //$data['id'] = $line['id']; // id not usable |
|
| 1530 | + $data['id'] = $line['id']; |
|
| 1531 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1532 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1533 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1534 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1535 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1536 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1537 | + $data['speed'] = $line['groundspeed']; // speed |
|
| 1538 | + $data['heading'] = $line['heading']; // heading |
|
| 1539 | + $data['latitude'] = $line['lat']; // lat |
|
| 1540 | + $data['longitude'] = $line['lon']; // long |
|
| 1541 | + //$data['verticalrate'] = ''; // verticale rate |
|
| 1542 | + //$data['squawk'] = ''; // squawk |
|
| 1543 | + //$data['emergency'] = ''; // emergency |
|
| 1544 | + if (isset($value['timezone'])) { |
|
| 1545 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1546 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1547 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1548 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1549 | 1549 | |
| 1550 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
| 1551 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
| 1552 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
| 1553 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
| 1554 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
| 1550 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
| 1551 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
| 1552 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
| 1553 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
| 1554 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
| 1555 | 1555 | |
| 1556 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1557 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1558 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
| 1556 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1557 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1558 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
| 1559 | 1559 | |
| 1560 | - $data['id_source'] = $id_source; |
|
| 1561 | - $data['format_source'] = 'vaos'; |
|
| 1562 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1563 | - $SI->add($data); |
|
| 1564 | - unset($data); |
|
| 1560 | + $data['id_source'] = $id_source; |
|
| 1561 | + $data['format_source'] = 'vaos'; |
|
| 1562 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1563 | + $SI->add($data); |
|
| 1564 | + unset($data); |
|
| 1565 | 1565 | } |
| 1566 | 1566 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1567 | 1567 | unset($buffer); |
| 1568 | 1568 | unset($all_data); |
| 1569 | - } |
|
| 1570 | - //$last_exec['phpvmacars'] = time(); |
|
| 1571 | - $last_exec[$id]['last'] = time(); |
|
| 1569 | + } |
|
| 1570 | + //$last_exec['phpvmacars'] = time(); |
|
| 1571 | + $last_exec[$id]['last'] = time(); |
|
| 1572 | 1572 | } elseif ($value['format'] === 'vam' && |
| 1573 | - ( |
|
| 1573 | + ( |
|
| 1574 | 1574 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1575 | 1575 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1576 | - ) |
|
| 1576 | + ) |
|
| 1577 | 1577 | ) { |
| 1578 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1579 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1580 | - $buffer = $Common->getData($value['host']); |
|
| 1581 | - $all_data = json_decode($buffer,true); |
|
| 1582 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1578 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1579 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1580 | + $buffer = $Common->getData($value['host']); |
|
| 1581 | + $all_data = json_decode($buffer,true); |
|
| 1582 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1583 | 1583 | $reset = 0; |
| 1584 | 1584 | foreach ($all_data as $line) { |
| 1585 | - $data = array(); |
|
| 1586 | - //$data['id'] = $line['id']; // id not usable |
|
| 1587 | - $data['id'] = trim($line['flight_id']); |
|
| 1588 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1589 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 1590 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 1591 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 1592 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1593 | - $data['speed'] = $line['gs']; // speed |
|
| 1594 | - $data['heading'] = $line['heading']; // heading |
|
| 1595 | - $data['latitude'] = $line['latitude']; // lat |
|
| 1596 | - $data['longitude'] = $line['longitude']; // long |
|
| 1597 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1598 | - $data['squawk'] = ''; // squawk |
|
| 1599 | - $data['emergency'] = ''; // emergency |
|
| 1600 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1601 | - $data['last_update'] = $line['last_update']; |
|
| 1602 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1603 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 1604 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1605 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1606 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1607 | - //$data['registration'] = $line['aircraft']; |
|
| 1608 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1609 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 1610 | - $data['id_source'] = $id_source; |
|
| 1611 | - $data['format_source'] = 'vam'; |
|
| 1612 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1613 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1614 | - $SI->add($data); |
|
| 1615 | - unset($data); |
|
| 1585 | + $data = array(); |
|
| 1586 | + //$data['id'] = $line['id']; // id not usable |
|
| 1587 | + $data['id'] = trim($line['flight_id']); |
|
| 1588 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1589 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 1590 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 1591 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 1592 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1593 | + $data['speed'] = $line['gs']; // speed |
|
| 1594 | + $data['heading'] = $line['heading']; // heading |
|
| 1595 | + $data['latitude'] = $line['latitude']; // lat |
|
| 1596 | + $data['longitude'] = $line['longitude']; // long |
|
| 1597 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1598 | + $data['squawk'] = ''; // squawk |
|
| 1599 | + $data['emergency'] = ''; // emergency |
|
| 1600 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1601 | + $data['last_update'] = $line['last_update']; |
|
| 1602 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1603 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 1604 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1605 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1606 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1607 | + //$data['registration'] = $line['aircraft']; |
|
| 1608 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1609 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 1610 | + $data['id_source'] = $id_source; |
|
| 1611 | + $data['format_source'] = 'vam'; |
|
| 1612 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1613 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1614 | + $SI->add($data); |
|
| 1615 | + unset($data); |
|
| 1616 | 1616 | } |
| 1617 | 1617 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1618 | 1618 | unset($buffer); |
| 1619 | 1619 | unset($all_data); |
| 1620 | - } |
|
| 1621 | - //$last_exec['phpvmacars'] = time(); |
|
| 1622 | - $last_exec[$id]['last'] = time(); |
|
| 1620 | + } |
|
| 1621 | + //$last_exec['phpvmacars'] = time(); |
|
| 1622 | + $last_exec[$id]['last'] = time(); |
|
| 1623 | 1623 | } elseif ($value['format'] === 'blitzortung' && |
| 1624 | - ( |
|
| 1624 | + ( |
|
| 1625 | 1625 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1626 | 1626 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1627 | - ) |
|
| 1627 | + ) |
|
| 1628 | 1628 | ) { |
| 1629 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1630 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1631 | - $buffer = $Common->getData($value['host']); |
|
| 1632 | - $all_data = json_decode($buffer,true); |
|
| 1633 | - if ($buffer != '') { |
|
| 1629 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1630 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1631 | + $buffer = $Common->getData($value['host']); |
|
| 1632 | + $all_data = json_decode($buffer,true); |
|
| 1633 | + if ($buffer != '') { |
|
| 1634 | 1634 | $Source->deleteLocationBySource('blitzortung'); |
| 1635 | 1635 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 1636 | 1636 | $buffer = explode('\n',$buffer); |
| 1637 | 1637 | foreach ($buffer as $buffer_line) { |
| 1638 | - $line = json_decode($buffer_line,true); |
|
| 1639 | - if (isset($line['time'])) { |
|
| 1638 | + $line = json_decode($buffer_line,true); |
|
| 1639 | + if (isset($line['time'])) { |
|
| 1640 | 1640 | $data = array(); |
| 1641 | 1641 | $data['altitude'] = $line['alt']; // altitude |
| 1642 | 1642 | $data['latitude'] = $line['lat']; // lat |
@@ -1648,92 +1648,92 @@ discard block |
||
| 1648 | 1648 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1649 | 1649 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1650 | 1650 | unset($data); |
| 1651 | - } |
|
| 1651 | + } |
|
| 1652 | 1652 | } |
| 1653 | 1653 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1654 | 1654 | unset($buffer); |
| 1655 | - } |
|
| 1656 | - $last_exec[$id]['last'] = time(); |
|
| 1655 | + } |
|
| 1656 | + $last_exec[$id]['last'] = time(); |
|
| 1657 | 1657 | } elseif ($value['format'] === 'acarsjson') { |
| 1658 | - $arr = $httpfeeds; |
|
| 1659 | - $w = $e = null; |
|
| 1660 | - if (isset($arr[$id])) { |
|
| 1661 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 1662 | - if ($nn > 0) { |
|
| 1663 | - foreach ($httpfeeds as $feed) { |
|
| 1664 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 1665 | - if ($buffer === FALSE) { |
|
| 1666 | - connect_all($globalSources); |
|
| 1667 | - } |
|
| 1668 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1669 | - $buffer = explode('\n',$buffer); |
|
| 1670 | - foreach ($buffer as $line) { |
|
| 1671 | - if ($line != '') { |
|
| 1672 | - $line = json_decode($line, true); |
|
| 1673 | - if (!empty($line)) { |
|
| 1674 | - $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'] : ''))); |
|
| 1675 | - $ACARS->deleteLiveAcarsData(); |
|
| 1676 | - } |
|
| 1677 | - } |
|
| 1678 | - } |
|
| 1679 | - } |
|
| 1680 | - } else { |
|
| 1681 | - $format = $value['format']; |
|
| 1682 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1683 | - else $tt[$format] = 0; |
|
| 1684 | - if ($tt[$format] > 30) { |
|
| 1685 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 1686 | - sleep(2); |
|
| 1687 | - //$sourceeen[] = $value; |
|
| 1688 | - //connect_all($sourceeen); |
|
| 1689 | - //$sourceeen = array(); |
|
| 1690 | - connect_all($globalSources); |
|
| 1691 | - } |
|
| 1692 | - } |
|
| 1693 | - } |
|
| 1658 | + $arr = $httpfeeds; |
|
| 1659 | + $w = $e = null; |
|
| 1660 | + if (isset($arr[$id])) { |
|
| 1661 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
| 1662 | + if ($nn > 0) { |
|
| 1663 | + foreach ($httpfeeds as $feed) { |
|
| 1664 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
| 1665 | + if ($buffer === FALSE) { |
|
| 1666 | + connect_all($globalSources); |
|
| 1667 | + } |
|
| 1668 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1669 | + $buffer = explode('\n',$buffer); |
|
| 1670 | + foreach ($buffer as $line) { |
|
| 1671 | + if ($line != '') { |
|
| 1672 | + $line = json_decode($line, true); |
|
| 1673 | + if (!empty($line)) { |
|
| 1674 | + $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'] : ''))); |
|
| 1675 | + $ACARS->deleteLiveAcarsData(); |
|
| 1676 | + } |
|
| 1677 | + } |
|
| 1678 | + } |
|
| 1679 | + } |
|
| 1680 | + } else { |
|
| 1681 | + $format = $value['format']; |
|
| 1682 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1683 | + else $tt[$format] = 0; |
|
| 1684 | + if ($tt[$format] > 30) { |
|
| 1685 | + if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 1686 | + sleep(2); |
|
| 1687 | + //$sourceeen[] = $value; |
|
| 1688 | + //connect_all($sourceeen); |
|
| 1689 | + //$sourceeen = array(); |
|
| 1690 | + connect_all($globalSources); |
|
| 1691 | + } |
|
| 1692 | + } |
|
| 1693 | + } |
|
| 1694 | 1694 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
| 1695 | 1695 | } 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') { |
| 1696 | - //$last_exec[$id]['last'] = time(); |
|
| 1697 | - //$read = array( $sockets[$id] ); |
|
| 1698 | - $read = $sockets; |
|
| 1699 | - $write = NULL; |
|
| 1700 | - $e = NULL; |
|
| 1701 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 1702 | - if ($e != NULL) var_dump($e); |
|
| 1703 | - if ($n > 0) { |
|
| 1696 | + //$last_exec[$id]['last'] = time(); |
|
| 1697 | + //$read = array( $sockets[$id] ); |
|
| 1698 | + $read = $sockets; |
|
| 1699 | + $write = NULL; |
|
| 1700 | + $e = NULL; |
|
| 1701 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 1702 | + if ($e != NULL) var_dump($e); |
|
| 1703 | + if ($n > 0) { |
|
| 1704 | 1704 | $reset = 0; |
| 1705 | 1705 | foreach ($read as $nb => $r) { |
| 1706 | - //$value = $formats[$nb]; |
|
| 1707 | - $format = $globalSources[$nb]['format']; |
|
| 1708 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
| 1706 | + //$value = $formats[$nb]; |
|
| 1707 | + $format = $globalSources[$nb]['format']; |
|
| 1708 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
| 1709 | 1709 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
| 1710 | - } elseif ($format === 'vrstcp') { |
|
| 1710 | + } elseif ($format === 'vrstcp') { |
|
| 1711 | 1711 | $buffer = @socket_read($r, 6000); |
| 1712 | - } else { |
|
| 1712 | + } else { |
|
| 1713 | 1713 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
| 1714 | - } |
|
| 1715 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1716 | - //echo $buffer."\n"; |
|
| 1717 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1718 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1719 | - $error = false; |
|
| 1720 | - //$SI::del(); |
|
| 1721 | - if ($buffer !== FALSE) { |
|
| 1714 | + } |
|
| 1715 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1716 | + //echo $buffer."\n"; |
|
| 1717 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1718 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1719 | + $error = false; |
|
| 1720 | + //$SI::del(); |
|
| 1721 | + if ($buffer !== FALSE) { |
|
| 1722 | 1722 | if ($format === 'vrstcp') { |
| 1723 | - $buffer = explode('},{',$buffer); |
|
| 1723 | + $buffer = explode('},{',$buffer); |
|
| 1724 | 1724 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
| 1725 | - } |
|
| 1726 | - // SBS format is CSV format |
|
| 1727 | - if ($buffer !== FALSE && $buffer !== '') { |
|
| 1725 | + } |
|
| 1726 | + // SBS format is CSV format |
|
| 1727 | + if ($buffer !== FALSE && $buffer !== '') { |
|
| 1728 | 1728 | $tt[$format] = 0; |
| 1729 | 1729 | if ($format === 'acarssbs3') { |
| 1730 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1731 | - $ACARS->add(trim($buffer)); |
|
| 1732 | - $ACARS->deleteLiveAcarsData(); |
|
| 1730 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1731 | + $ACARS->add(trim($buffer)); |
|
| 1732 | + $ACARS->deleteLiveAcarsData(); |
|
| 1733 | 1733 | } elseif ($format === 'raw') { |
| 1734 | - // AVR format |
|
| 1735 | - $data = $SBS->parse($buffer); |
|
| 1736 | - if (is_array($data)) { |
|
| 1734 | + // AVR format |
|
| 1735 | + $data = $SBS->parse($buffer); |
|
| 1736 | + if (is_array($data)) { |
|
| 1737 | 1737 | //if (!empty($data)) print_r($data); |
| 1738 | 1738 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1739 | 1739 | $data['format_source'] = 'raw'; |
@@ -1743,39 +1743,39 @@ discard block |
||
| 1743 | 1743 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1744 | 1744 | $SI->add($data); |
| 1745 | 1745 | unset($data); |
| 1746 | - } |
|
| 1746 | + } |
|
| 1747 | 1747 | } elseif ($format === 'ais') { |
| 1748 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1749 | - $data = array(); |
|
| 1750 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1751 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1752 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1753 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1754 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1755 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1756 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1757 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1758 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1759 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1760 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1761 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1762 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1763 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1764 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1765 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1748 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1749 | + $data = array(); |
|
| 1750 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1751 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1752 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1753 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1754 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1755 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1756 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1757 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1758 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1759 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1760 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1761 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1762 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1763 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1764 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1765 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1766 | 1766 | |
| 1767 | - if (isset($ais_data['timestamp'])) { |
|
| 1767 | + if (isset($ais_data['timestamp'])) { |
|
| 1768 | 1768 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 1769 | - } else { |
|
| 1769 | + } else { |
|
| 1770 | 1770 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1771 | - } |
|
| 1772 | - $data['format_source'] = 'aisnmea'; |
|
| 1773 | - $data['id_source'] = $id_source; |
|
| 1774 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 1775 | - unset($data); |
|
| 1776 | - } elseif ($format === 'flightgearsp') { |
|
| 1777 | - //echo $buffer."\n"; |
|
| 1778 | - if (strlen($buffer) > 5) { |
|
| 1771 | + } |
|
| 1772 | + $data['format_source'] = 'aisnmea'; |
|
| 1773 | + $data['id_source'] = $id_source; |
|
| 1774 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 1775 | + unset($data); |
|
| 1776 | + } elseif ($format === 'flightgearsp') { |
|
| 1777 | + //echo $buffer."\n"; |
|
| 1778 | + if (strlen($buffer) > 5) { |
|
| 1779 | 1779 | $line = explode(',',$buffer); |
| 1780 | 1780 | $data = array(); |
| 1781 | 1781 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1792,47 +1792,47 @@ discard block |
||
| 1792 | 1792 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1793 | 1793 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1794 | 1794 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1795 | - } |
|
| 1796 | - } elseif ($format === 'acars') { |
|
| 1797 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1798 | - $ACARS->add(trim($buffer)); |
|
| 1799 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1800 | - $ACARS->deleteLiveAcarsData(); |
|
| 1795 | + } |
|
| 1796 | + } elseif ($format === 'acars') { |
|
| 1797 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1798 | + $ACARS->add(trim($buffer)); |
|
| 1799 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1800 | + $ACARS->deleteLiveAcarsData(); |
|
| 1801 | 1801 | } elseif ($format === 'acarsjsonudp') { |
| 1802 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1803 | - $line = json_decode(trim($buffer), true); |
|
| 1804 | - if (!empty($line)) { |
|
| 1802 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1803 | + $line = json_decode(trim($buffer), true); |
|
| 1804 | + if (!empty($line)) { |
|
| 1805 | 1805 | $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
| 1806 | - $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'] : ''))); |
|
| 1807 | - $ACARS->deleteLiveAcarsData(); |
|
| 1808 | - } |
|
| 1809 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1806 | + $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'] : ''))); |
|
| 1807 | + $ACARS->deleteLiveAcarsData(); |
|
| 1808 | + } |
|
| 1809 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1810 | 1810 | } elseif ($format === 'flightgearmp') { |
| 1811 | - if (substr($buffer,0,1) != '#') { |
|
| 1811 | + if (substr($buffer,0,1) != '#') { |
|
| 1812 | 1812 | $data = array(); |
| 1813 | 1813 | //echo $buffer."\n"; |
| 1814 | 1814 | $line = explode(' ',$buffer); |
| 1815 | 1815 | if (count($line) === 11) { |
| 1816 | - $userserver = explode('@',$line[0]); |
|
| 1817 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1818 | - $data['ident'] = $userserver[0]; |
|
| 1819 | - $data['registration'] = $userserver[0]; |
|
| 1820 | - $data['latitude'] = $line[4]; |
|
| 1821 | - $data['longitude'] = $line[5]; |
|
| 1822 | - $data['altitude'] = $line[6]; |
|
| 1823 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1824 | - $aircraft_type = $line[10]; |
|
| 1825 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1826 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1827 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1828 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1816 | + $userserver = explode('@',$line[0]); |
|
| 1817 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1818 | + $data['ident'] = $userserver[0]; |
|
| 1819 | + $data['registration'] = $userserver[0]; |
|
| 1820 | + $data['latitude'] = $line[4]; |
|
| 1821 | + $data['longitude'] = $line[5]; |
|
| 1822 | + $data['altitude'] = $line[6]; |
|
| 1823 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1824 | + $aircraft_type = $line[10]; |
|
| 1825 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1826 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1827 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1828 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1829 | + } |
|
| 1829 | 1830 | } |
| 1830 | - } |
|
| 1831 | 1831 | } elseif ($format === 'beast') { |
| 1832 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1833 | - die; |
|
| 1832 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1833 | + die; |
|
| 1834 | 1834 | } elseif ($format === 'vrstcp') { |
| 1835 | - foreach($buffer as $all_data) { |
|
| 1835 | + foreach($buffer as $all_data) { |
|
| 1836 | 1836 | $line = json_decode('{'.$all_data.'}',true); |
| 1837 | 1837 | $data = array(); |
| 1838 | 1838 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1852,158 +1852,158 @@ discard block |
||
| 1852 | 1852 | */ |
| 1853 | 1853 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1854 | 1854 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
| 1855 | - $data['format_source'] = 'vrstcp'; |
|
| 1855 | + $data['format_source'] = 'vrstcp'; |
|
| 1856 | 1856 | $data['id_source'] = $id_source; |
| 1857 | 1857 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1858 | 1858 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1859 | 1859 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1860 | 1860 | unset($data); |
| 1861 | - } |
|
| 1861 | + } |
|
| 1862 | 1862 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
| 1863 | - $line = explode("\t", $buffer); |
|
| 1864 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1863 | + $line = explode("\t", $buffer); |
|
| 1864 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1865 | 1865 | $key = $line[$k]; |
| 1866 | - $lined[$key] = $line[$k+1]; |
|
| 1867 | - } |
|
| 1868 | - if (count($lined) > 3) { |
|
| 1869 | - $data['hex'] = $lined['hexid']; |
|
| 1870 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1871 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1872 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1873 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1874 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1875 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1876 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1877 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1878 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1879 | - $data['id_source'] = $id_source; |
|
| 1880 | - $data['format_source'] = 'tsv'; |
|
| 1881 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1882 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1866 | + $lined[$key] = $line[$k+1]; |
|
| 1867 | + } |
|
| 1868 | + if (count($lined) > 3) { |
|
| 1869 | + $data['hex'] = $lined['hexid']; |
|
| 1870 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1871 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1872 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1873 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1874 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1875 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1876 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1877 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1878 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1879 | + $data['id_source'] = $id_source; |
|
| 1880 | + $data['format_source'] = 'tsv'; |
|
| 1881 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1882 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1883 | 1883 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1884 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1885 | - unset($lined); |
|
| 1886 | - unset($data); |
|
| 1887 | - } else $error = true; |
|
| 1884 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1885 | + unset($lined); |
|
| 1886 | + unset($data); |
|
| 1887 | + } else $error = true; |
|
| 1888 | 1888 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1889 | - if ($aprs_connect === 0) { |
|
| 1889 | + if ($aprs_connect === 0) { |
|
| 1890 | 1890 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 1891 | 1891 | $aprs_connect = 1; |
| 1892 | - } |
|
| 1892 | + } |
|
| 1893 | 1893 | |
| 1894 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1894 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1895 | 1895 | $aprs_last_tx = time(); |
| 1896 | 1896 | $data_aprs = "# Keep alive"; |
| 1897 | 1897 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1898 | - } |
|
| 1898 | + } |
|
| 1899 | 1899 | |
| 1900 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1901 | - //echo 'APRS data : '.$buffer."\n"; |
|
| 1902 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1903 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1904 | - //echo $buffer."\n"; |
|
| 1905 | - date_default_timezone_set('UTC'); |
|
| 1906 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1900 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1901 | + //echo 'APRS data : '.$buffer."\n"; |
|
| 1902 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1903 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1904 | + //echo $buffer."\n"; |
|
| 1905 | + date_default_timezone_set('UTC'); |
|
| 1906 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1907 | 1907 | $line = $APRS->parse($buffer); |
| 1908 | 1908 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1909 | 1909 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
| 1910 | - $aprs_last_tx = time(); |
|
| 1911 | - $data = array(); |
|
| 1912 | - //print_r($line); |
|
| 1913 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1914 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1915 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1916 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1917 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1918 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1919 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1920 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1921 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1922 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1923 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1924 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1925 | - $data['latitude'] = $line['latitude']; |
|
| 1926 | - $data['longitude'] = $line['longitude']; |
|
| 1927 | - //$data['verticalrate'] = $line[16]; |
|
| 1928 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1929 | - //else $data['speed'] = 0; |
|
| 1930 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1931 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1932 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1933 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1910 | + $aprs_last_tx = time(); |
|
| 1911 | + $data = array(); |
|
| 1912 | + //print_r($line); |
|
| 1913 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1914 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1915 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1916 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1917 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1918 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1919 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1920 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1921 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1922 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1923 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1924 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1925 | + $data['latitude'] = $line['latitude']; |
|
| 1926 | + $data['longitude'] = $line['longitude']; |
|
| 1927 | + //$data['verticalrate'] = $line[16]; |
|
| 1928 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1929 | + //else $data['speed'] = 0; |
|
| 1930 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1931 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1932 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1933 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1934 | 1934 | |
| 1935 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1936 | - //else echo 'No heading...'."\n"; |
|
| 1937 | - //else $data['heading'] = 0; |
|
| 1938 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1939 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1940 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1941 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1942 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1943 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1944 | - $data['id_source'] = $id_source; |
|
| 1945 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1946 | - else $data['format_source'] = 'aprs'; |
|
| 1947 | - $data['source_name'] = $line['source']; |
|
| 1948 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1949 | - else $data['source_type'] = 'flarm'; |
|
| 1950 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1951 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 1952 | - $aprsdate = strtotime($data['datetime']); |
|
| 1953 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1954 | - // Accept data if time <= system time + 20s |
|
| 1955 | - //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'])))) { |
|
| 1956 | - if ( |
|
| 1935 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1936 | + //else echo 'No heading...'."\n"; |
|
| 1937 | + //else $data['heading'] = 0; |
|
| 1938 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1939 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1940 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1941 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1942 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1943 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1944 | + $data['id_source'] = $id_source; |
|
| 1945 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1946 | + else $data['format_source'] = 'aprs'; |
|
| 1947 | + $data['source_name'] = $line['source']; |
|
| 1948 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1949 | + else $data['source_type'] = 'flarm'; |
|
| 1950 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1951 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 1952 | + $aprsdate = strtotime($data['datetime']); |
|
| 1953 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1954 | + // Accept data if time <= system time + 20s |
|
| 1955 | + //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'])))) { |
|
| 1956 | + if ( |
|
| 1957 | 1957 | ($data['source_type'] === 'modes') || |
| 1958 | 1958 | isset($line['stealth']) && |
| 1959 | 1959 | (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && |
| 1960 | 1960 | ($line['stealth'] === 0 || $line['stealth'] == '') && |
| 1961 | 1961 | (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1962 | 1962 | $send = $SI->add($data); |
| 1963 | - } elseif ($data['source_type'] === 'ais') { |
|
| 1963 | + } elseif ($data['source_type'] === 'ais') { |
|
| 1964 | 1964 | $data['type'] = ''; |
| 1965 | 1965 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
| 1966 | - } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
| 1966 | + } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
| 1967 | 1967 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1968 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1969 | - //$line['symbol'] === 'Balloon' || |
|
| 1970 | - $line['symbol'] === 'Glider' || |
|
| 1971 | - $line['symbol'] === 'No. Plane' || |
|
| 1972 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
| 1973 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1974 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1975 | - $send = $SI->add($data); |
|
| 1976 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1977 | - $line['symbol'] === 'Yacht (Sail)' || |
|
| 1978 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
| 1979 | - $send = $MI->add($data); |
|
| 1980 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1981 | - $line['symbol'] === 'Car' || |
|
| 1982 | - $line['symbol'] === 'Ambulance' || |
|
| 1983 | - $line['symbol'] === 'Van' || |
|
| 1984 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
| 1985 | - $line['symbol'] === 'Motorcycle' || |
|
| 1986 | - $line['symbol'] === 'Tractor' || |
|
| 1987 | - $line['symbol'] === 'Police' || |
|
| 1988 | - $line['symbol'] === 'Bike' || |
|
| 1989 | - $line['symbol'] === 'Jogger' || |
|
| 1990 | - $line['symbol'] === 'Horse' || |
|
| 1991 | - $line['symbol'] === 'Bus' || |
|
| 1992 | - $line['symbol'] === 'Jeep' || |
|
| 1993 | - $line['symbol'] === 'Recreational Vehicle' || |
|
| 1994 | - $line['symbol'] === 'Yacht (Sail)' || |
|
| 1995 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
| 1996 | - $line['symbol'] === 'Firetruck' || |
|
| 1997 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
| 1998 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
| 1999 | - $line['symbol'] === 'SUV' || |
|
| 2000 | - $line['symbol'] === 'Snowmobile' || |
|
| 2001 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
| 2002 | - //} 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') { |
|
| 1968 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1969 | + //$line['symbol'] === 'Balloon' || |
|
| 1970 | + $line['symbol'] === 'Glider' || |
|
| 1971 | + $line['symbol'] === 'No. Plane' || |
|
| 1972 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
| 1973 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1974 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1975 | + $send = $SI->add($data); |
|
| 1976 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1977 | + $line['symbol'] === 'Yacht (Sail)' || |
|
| 1978 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
| 1979 | + $send = $MI->add($data); |
|
| 1980 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1981 | + $line['symbol'] === 'Car' || |
|
| 1982 | + $line['symbol'] === 'Ambulance' || |
|
| 1983 | + $line['symbol'] === 'Van' || |
|
| 1984 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
| 1985 | + $line['symbol'] === 'Motorcycle' || |
|
| 1986 | + $line['symbol'] === 'Tractor' || |
|
| 1987 | + $line['symbol'] === 'Police' || |
|
| 1988 | + $line['symbol'] === 'Bike' || |
|
| 1989 | + $line['symbol'] === 'Jogger' || |
|
| 1990 | + $line['symbol'] === 'Horse' || |
|
| 1991 | + $line['symbol'] === 'Bus' || |
|
| 1992 | + $line['symbol'] === 'Jeep' || |
|
| 1993 | + $line['symbol'] === 'Recreational Vehicle' || |
|
| 1994 | + $line['symbol'] === 'Yacht (Sail)' || |
|
| 1995 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
| 1996 | + $line['symbol'] === 'Firetruck' || |
|
| 1997 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
| 1998 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
| 1999 | + $line['symbol'] === 'SUV' || |
|
| 2000 | + $line['symbol'] === 'Snowmobile' || |
|
| 2001 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
| 2002 | + //} 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') { |
|
| 2003 | 2003 | // } 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') { |
| 2004 | 2004 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 2005 | 2005 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
| 2006 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 2006 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 2007 | 2007 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 2008 | 2008 | $Source->deleteOldLocationByType('gs'); |
| 2009 | 2009 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -2011,7 +2011,7 @@ discard block |
||
| 2011 | 2011 | } else { |
| 2012 | 2012 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
| 2013 | 2013 | } |
| 2014 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
| 2014 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
| 2015 | 2015 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2016 | 2016 | if ($globalDebug) echo '# Weather Station added'."\n"; |
| 2017 | 2017 | $Source->deleteOldLocationByType('wx'); |
@@ -2021,7 +2021,7 @@ discard block |
||
| 2021 | 2021 | } else { |
| 2022 | 2022 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
| 2023 | 2023 | } |
| 2024 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
| 2024 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
| 2025 | 2025 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2026 | 2026 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 2027 | 2027 | $Source->deleteOldLocationByType('lightning'); |
@@ -2030,11 +2030,11 @@ discard block |
||
| 2030 | 2030 | } else { |
| 2031 | 2031 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
| 2032 | 2032 | } |
| 2033 | - } elseif ($globalDebug) { |
|
| 2034 | - echo '/!\ Not added: '.$buffer."\n"; |
|
| 2035 | - print_r($line); |
|
| 2036 | - } |
|
| 2037 | - unset($data); |
|
| 2033 | + } elseif ($globalDebug) { |
|
| 2034 | + echo '/!\ Not added: '.$buffer."\n"; |
|
| 2035 | + print_r($line); |
|
| 2036 | + } |
|
| 2037 | + unset($data); |
|
| 2038 | 2038 | } |
| 2039 | 2039 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
| 2040 | 2040 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -2053,13 +2053,13 @@ discard block |
||
| 2053 | 2053 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
| 2054 | 2054 | $globalSources[$nb]['last_weather_clean'] = time(); |
| 2055 | 2055 | } |
| 2056 | - } |
|
| 2056 | + } |
|
| 2057 | 2057 | } else { |
| 2058 | - $line = explode(',', $buffer); |
|
| 2059 | - //print_r($line); |
|
| 2060 | - if (count($line) > 20) { |
|
| 2061 | - $data['hex'] = $line[4]; |
|
| 2062 | - /* |
|
| 2058 | + $line = explode(',', $buffer); |
|
| 2059 | + //print_r($line); |
|
| 2060 | + if (count($line) > 20) { |
|
| 2061 | + $data['hex'] = $line[4]; |
|
| 2062 | + /* |
|
| 2063 | 2063 | $data['datetime'] = $line[6].' '.$line[7]; |
| 2064 | 2064 | date_default_timezone_set($globalTimezone); |
| 2065 | 2065 | $datetime = new DateTime($data['datetime']); |
@@ -2067,31 +2067,31 @@ discard block |
||
| 2067 | 2067 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 2068 | 2068 | date_default_timezone_set('UTC'); |
| 2069 | 2069 | */ |
| 2070 | - // Force datetime to current UTC datetime |
|
| 2071 | - date_default_timezone_set('UTC'); |
|
| 2072 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2073 | - $data['ident'] = trim($line[10]); |
|
| 2074 | - $data['latitude'] = $line[14]; |
|
| 2075 | - $data['longitude'] = $line[15]; |
|
| 2076 | - $data['verticalrate'] = $line[16]; |
|
| 2077 | - $data['emergency'] = $line[20]; |
|
| 2078 | - $data['speed'] = $line[12]; |
|
| 2079 | - $data['squawk'] = $line[17]; |
|
| 2080 | - $data['altitude'] = $line[11]; |
|
| 2081 | - $data['heading'] = $line[13]; |
|
| 2082 | - $data['ground'] = $line[21]; |
|
| 2083 | - $data['emergency'] = $line[19]; |
|
| 2084 | - $data['format_source'] = 'sbs'; |
|
| 2070 | + // Force datetime to current UTC datetime |
|
| 2071 | + date_default_timezone_set('UTC'); |
|
| 2072 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2073 | + $data['ident'] = trim($line[10]); |
|
| 2074 | + $data['latitude'] = $line[14]; |
|
| 2075 | + $data['longitude'] = $line[15]; |
|
| 2076 | + $data['verticalrate'] = $line[16]; |
|
| 2077 | + $data['emergency'] = $line[20]; |
|
| 2078 | + $data['speed'] = $line[12]; |
|
| 2079 | + $data['squawk'] = $line[17]; |
|
| 2080 | + $data['altitude'] = $line[11]; |
|
| 2081 | + $data['heading'] = $line[13]; |
|
| 2082 | + $data['ground'] = $line[21]; |
|
| 2083 | + $data['emergency'] = $line[19]; |
|
| 2084 | + $data['format_source'] = 'sbs'; |
|
| 2085 | 2085 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 2086 | 2086 | elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
| 2087 | 2087 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 2088 | 2088 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 2089 | - $data['id_source'] = $id_source; |
|
| 2090 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 2091 | - else $error = true; |
|
| 2092 | - unset($data); |
|
| 2093 | - } else $error = true; |
|
| 2094 | - if ($error) { |
|
| 2089 | + $data['id_source'] = $id_source; |
|
| 2090 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 2091 | + else $error = true; |
|
| 2092 | + unset($data); |
|
| 2093 | + } else $error = true; |
|
| 2094 | + if ($error) { |
|
| 2095 | 2095 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 2096 | 2096 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 2097 | 2097 | } else { |
@@ -2107,13 +2107,13 @@ discard block |
||
| 2107 | 2107 | connect_all($sourceer); |
| 2108 | 2108 | $sourceer = array(); |
| 2109 | 2109 | } |
| 2110 | - } |
|
| 2110 | + } |
|
| 2111 | 2111 | } |
| 2112 | 2112 | // Sleep for xxx microseconds |
| 2113 | 2113 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 2114 | - } else { |
|
| 2114 | + } else { |
|
| 2115 | 2115 | if ($format === 'flightgearmp') { |
| 2116 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2116 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2117 | 2117 | //@socket_close($r); |
| 2118 | 2118 | sleep($globalMinFetch); |
| 2119 | 2119 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2122,9 +2122,9 @@ discard block |
||
| 2122 | 2122 | break; |
| 2123 | 2123 | |
| 2124 | 2124 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 2125 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 2126 | - else $tt[$format] = 0; |
|
| 2127 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 2125 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 2126 | + else $tt[$format] = 0; |
|
| 2127 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 2128 | 2128 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 2129 | 2129 | //@socket_close($r); |
| 2130 | 2130 | sleep(2); |
@@ -2135,24 +2135,24 @@ discard block |
||
| 2135 | 2135 | //connect_all($globalSources); |
| 2136 | 2136 | $tt[$format]=0; |
| 2137 | 2137 | break; |
| 2138 | - } |
|
| 2139 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 2138 | + } |
|
| 2139 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 2140 | + } |
|
| 2140 | 2141 | } |
| 2141 | - } |
|
| 2142 | 2142 | } |
| 2143 | - } else { |
|
| 2143 | + } else { |
|
| 2144 | 2144 | $error = socket_strerror(socket_last_error()); |
| 2145 | 2145 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2146 | 2146 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 2147 | 2147 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 2148 | 2148 | // Restart the script if possible |
| 2149 | 2149 | if (is_array($sockets)) { |
| 2150 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2150 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2151 | 2151 | |
| 2152 | - foreach ($sockets as $sock) { |
|
| 2152 | + foreach ($sockets as $sock) { |
|
| 2153 | 2153 | @socket_shutdown($sock,2); |
| 2154 | 2154 | @socket_close($sock); |
| 2155 | - } |
|
| 2155 | + } |
|
| 2156 | 2156 | |
| 2157 | 2157 | } |
| 2158 | 2158 | if ($globalDebug) echo "Waiting..."; |
@@ -2165,15 +2165,15 @@ discard block |
||
| 2165 | 2165 | if ($globalDebug) echo "Restart all connections..."; |
| 2166 | 2166 | connect_all($globalSources); |
| 2167 | 2167 | } |
| 2168 | - } |
|
| 2168 | + } |
|
| 2169 | 2169 | } |
| 2170 | 2170 | if ($globalDaemon === false) { |
| 2171 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2172 | - if (isset($SI)) $SI->checkAll(); |
|
| 2173 | - if (isset($TI)) $TI->checkAll(); |
|
| 2174 | - if (isset($MI)) $MI->checkAll(); |
|
| 2171 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2172 | + if (isset($SI)) $SI->checkAll(); |
|
| 2173 | + if (isset($TI)) $TI->checkAll(); |
|
| 2174 | + if (isset($MI)) $MI->checkAll(); |
|
| 2175 | + } |
|
| 2175 | 2176 | } |
| 2176 | - } |
|
| 2177 | 2177 | } |
| 2178 | 2178 | |
| 2179 | 2179 | ?> |
@@ -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'; |
@@ -796,28 +796,28 @@ discard block |
||
| 796 | 796 | exit(0); |
| 797 | 797 | } |
| 798 | 798 | $sailawayoption = array('key' => $globalSailaway['key']); |
| 799 | - if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
| 800 | - if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 799 | + if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption, array('usrnr' => $globalSailaway['usrnr'])); |
|
| 800 | + if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption, array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 801 | 801 | |
| 802 | 802 | for ($i = 0; $i <= 1; $i++) { |
| 803 | 803 | if ($globalDebug) echo '! Download... '; |
| 804 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2','get','','','','',30); |
|
| 804 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2', 'get', '', '', '', '', 30); |
|
| 805 | 805 | if ($globalDebug) echo 'done'."\n"; |
| 806 | 806 | if ($buffer != '') { |
| 807 | - $all_data = json_decode($buffer,true); |
|
| 807 | + $all_data = json_decode($buffer, true); |
|
| 808 | 808 | if (isset($all_data['missions'])) { |
| 809 | 809 | foreach ($all_data['missions'] as $mission) { |
| 810 | 810 | $mission_user = $mission['usrname']; |
| 811 | - $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
|
| 812 | - if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
|
| 811 | + $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle'])); |
|
| 812 | + if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) { |
|
| 813 | 813 | //print_r($mission); |
| 814 | 814 | $datar = array(); |
| 815 | 815 | $datar['id'] = $mission['misnr']; |
| 816 | 816 | $datar['desc'] = $mission['misdescr']; |
| 817 | 817 | //$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['usrname']))); |
| 818 | 818 | $datar['creator'] = ''; |
| 819 | - $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']))); |
|
| 820 | - if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s',strtotime($mission['misstart'])); |
|
| 819 | + $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']))); |
|
| 820 | + if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s', strtotime($mission['misstart'])); |
|
| 821 | 821 | else $datar['startdate'] = '1970-01-01 00:00:00'; |
| 822 | 822 | /* |
| 823 | 823 | $markers = array(); |
@@ -837,9 +837,9 @@ discard block |
||
| 837 | 837 | if ($globalDebug) echo '=== Wait... ==='; |
| 838 | 838 | sleep(10*60); |
| 839 | 839 | } |
| 840 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
|
| 840 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption), 'get', '', '', '', '', 30); |
|
| 841 | 841 | if ($buffer != '') { |
| 842 | - $data = json_decode($buffer,true); |
|
| 842 | + $data = json_decode($buffer, true); |
|
| 843 | 843 | //print_r($data); |
| 844 | 844 | if (isset($data['boats'])) { |
| 845 | 845 | foreach ($data['boats'] as $sail) { |
@@ -851,12 +851,12 @@ discard block |
||
| 851 | 851 | $data['longitude'] = $sail['ubtlon']; |
| 852 | 852 | $data['type_id'] = 36; |
| 853 | 853 | $data['heading'] = $sail['ubtheading']; |
| 854 | - $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname']))); |
|
| 854 | + $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname']))); |
|
| 855 | 855 | $data['captain_name'] = $sail['usrname']; |
| 856 | - $allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat','32' Offshore Racer'); |
|
| 856 | + $allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52' Cruising Cat', '50' Performance Cruiser', 'Nordic Folkboat', '32' Offshore Racer'); |
|
| 857 | 857 | $boattype = $sail['ubtbtpnr']; |
| 858 | - if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1]; |
|
| 859 | - $data['speed'] = round($sail['ubtspeed']*3.6,2); |
|
| 858 | + if (isset($allboats[$boattype - 1])) $data['type'] = $allboats[$boattype - 1]; |
|
| 859 | + $data['speed'] = round($sail['ubtspeed']*3.6, 2); |
|
| 860 | 860 | $data['format_source'] = 'sailaway'; |
| 861 | 861 | $data['id_source'] = $id_source; |
| 862 | 862 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -889,11 +889,11 @@ discard block |
||
| 889 | 889 | } |
| 890 | 890 | if ($globalDebug) echo '! Download... '; |
| 891 | 891 | $sailawayoption = array('key' => $globalSailaway['key']); |
| 892 | - if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
| 893 | - if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 894 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
|
| 892 | + if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption, array('usrnr' => $globalSailaway['usrnr'])); |
|
| 893 | + if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption, array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 894 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption), 'get', '', '', '', '', 30); |
|
| 895 | 895 | if ($buffer != '') { |
| 896 | - $data = json_decode($buffer,true); |
|
| 896 | + $data = json_decode($buffer, true); |
|
| 897 | 897 | //print_r($data); |
| 898 | 898 | if (isset($data['boats'])) { |
| 899 | 899 | foreach ($data['boats'] as $sail) { |
@@ -905,12 +905,12 @@ discard block |
||
| 905 | 905 | $data['longitude'] = $sail['ubtlon']; |
| 906 | 906 | $data['type_id'] = 36; |
| 907 | 907 | $data['heading'] = $sail['ubtheading']; |
| 908 | - $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname']))); |
|
| 908 | + $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname']))); |
|
| 909 | 909 | $data['captain_name'] = $sail['usrname']; |
| 910 | - $allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat','32' Offshore Racer'); |
|
| 910 | + $allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52' Cruising Cat', '50' Performance Cruiser', 'Nordic Folkboat', '32' Offshore Racer'); |
|
| 911 | 911 | $boattype = $sail['ubtbtpnr']; |
| 912 | - if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1]; |
|
| 913 | - $data['speed'] = round($sail['ubtspeed']*3.6,2); |
|
| 912 | + if (isset($allboats[$boattype - 1])) $data['type'] = $allboats[$boattype - 1]; |
|
| 913 | + $data['speed'] = round($sail['ubtspeed']*3.6, 2); |
|
| 914 | 914 | $data['format_source'] = 'sailaway'; |
| 915 | 915 | $data['id_source'] = $id_source; |
| 916 | 916 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -938,8 +938,8 @@ discard block |
||
| 938 | 938 | ) { |
| 939 | 939 | //$buffer = $Common->getData($hosts[$id]); |
| 940 | 940 | $buffer = $Common->getData($value['host']); |
| 941 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 942 | - $buffer = explode('\n',$buffer); |
|
| 941 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 942 | + $buffer = explode('\n', $buffer); |
|
| 943 | 943 | $reset = 0; |
| 944 | 944 | foreach ($buffer as $line) { |
| 945 | 945 | if ($line != '') { |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 951 | 951 | $data['pilot_id'] = $line[1]; |
| 952 | 952 | $data['pilot_name'] = $line[2]; |
| 953 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
| 953 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
| 954 | 954 | $data['ident'] = $line[0]; // ident |
| 955 | 955 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 956 | 956 | $data['speed'] = $line[8]; // speed |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 967 | 967 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 968 | 968 | $data['departure_airport_icao'] = $line[11]; |
| 969 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 969 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 970 | 970 | $data['arrival_airport_icao'] = $line[13]; |
| 971 | 971 | $data['frequency'] = $line[4]; |
| 972 | 972 | $data['type'] = $line[18]; |
@@ -975,7 +975,7 @@ discard block |
||
| 975 | 975 | $data['id_source'] = $id_source; |
| 976 | 976 | //$data['arrival_airport_time'] = ; |
| 977 | 977 | if ($line[9] != '') { |
| 978 | - $aircraft_data = explode('/',$line[9]); |
|
| 978 | + $aircraft_data = explode('/', $line[9]); |
|
| 979 | 979 | if (count($aircraft_data) == 2) { |
| 980 | 980 | //line[9] may equal to something like 'B738/L' in old FSD server's whazzup.txt file |
| 981 | 981 | $data['aircraft_icao'] = $aircraft_data[0]; |
@@ -994,9 +994,9 @@ discard block |
||
| 994 | 994 | if ($line[3] === 'PILOT') $SI->add($data); |
| 995 | 995 | elseif ($line[3] === 'ATC') { |
| 996 | 996 | //print_r($data); |
| 997 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 998 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 999 | - $typec = substr($data['ident'],-3); |
|
| 997 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 998 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 999 | + $typec = substr($data['ident'], -3); |
|
| 1000 | 1000 | if ($typec === 'APP') $data['type'] = 'Approach'; |
| 1001 | 1001 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
| 1002 | 1002 | elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
@@ -1008,8 +1008,8 @@ discard block |
||
| 1008 | 1008 | elseif ($data['type'] === '') $data['type'] = 'Observer'; |
| 1009 | 1009 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 1010 | 1010 | if (isset($ATC)) { |
| 1011 | - 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']); |
|
| 1012 | - 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']); |
|
| 1011 | + 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']); |
|
| 1012 | + 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']); |
|
| 1013 | 1013 | } |
| 1014 | 1014 | } |
| 1015 | 1015 | unset($data); |
@@ -1025,24 +1025,24 @@ discard block |
||
| 1025 | 1025 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1026 | 1026 | ) |
| 1027 | 1027 | ) { |
| 1028 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 1028 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
| 1029 | 1029 | if ($buffer != '') { |
| 1030 | 1030 | $all_data = simplexml_load_string($buffer); |
| 1031 | - foreach($all_data->children() as $childdata) { |
|
| 1031 | + foreach ($all_data->children() as $childdata) { |
|
| 1032 | 1032 | $data = array(); |
| 1033 | 1033 | $line = $childdata; |
| 1034 | 1034 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
| 1035 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
| 1036 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
| 1037 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
| 1038 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
| 1039 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 1040 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1041 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
| 1035 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
| 1036 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
| 1037 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
| 1038 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
| 1039 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
| 1040 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
| 1041 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
| 1042 | 1042 | $data['altitude_relative'] = 'AMSL'; |
| 1043 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
| 1043 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
| 1044 | 1044 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 1045 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
| 1045 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
| 1046 | 1046 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
| 1047 | 1047 | $data['format_source'] = $value['format']; |
| 1048 | 1048 | $SI->add($data); |
@@ -1050,22 +1050,22 @@ discard block |
||
| 1050 | 1050 | } |
| 1051 | 1051 | } |
| 1052 | 1052 | $Source->deleteOldLocationByType('gs'); |
| 1053 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 1053 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
| 1054 | 1054 | if ($buffer != '') { |
| 1055 | 1055 | $all_data = simplexml_load_string($buffer); |
| 1056 | - foreach($all_data->children() as $childdata) { |
|
| 1056 | + foreach ($all_data->children() as $childdata) { |
|
| 1057 | 1057 | $data = array(); |
| 1058 | 1058 | $line = $childdata; |
| 1059 | - $data['id'] = (int)$line['gsID']; |
|
| 1060 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
| 1061 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
| 1062 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
| 1059 | + $data['id'] = (int) $line['gsID']; |
|
| 1060 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
| 1061 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
| 1062 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
| 1063 | 1063 | $data['altitude_relative'] = 'AMSL'; |
| 1064 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
| 1064 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
| 1065 | 1065 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
| 1066 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
| 1066 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
| 1067 | 1067 | } else { |
| 1068 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
| 1068 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
| 1069 | 1069 | } |
| 1070 | 1070 | unset($data); |
| 1071 | 1071 | } |
@@ -1083,9 +1083,9 @@ discard block |
||
| 1083 | 1083 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1084 | 1084 | ) |
| 1085 | 1085 | ) { |
| 1086 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 1086 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 1087 | 1087 | if ($buffer != '') { |
| 1088 | - $all_data = json_decode($buffer,true); |
|
| 1088 | + $all_data = json_decode($buffer, true); |
|
| 1089 | 1089 | if (isset($all_data['acList'])) { |
| 1090 | 1090 | $reset = 0; |
| 1091 | 1091 | foreach ($all_data['acList'] as $line) { |
@@ -1101,7 +1101,7 @@ discard block |
||
| 1101 | 1101 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
| 1102 | 1102 | $data['emergency'] = ''; // emergency |
| 1103 | 1103 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
| 1104 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1104 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
| 1105 | 1105 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1106 | 1106 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1107 | 1107 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1127 | 1127 | $data['squawk'] = $line['squawk']; // squawk |
| 1128 | 1128 | $data['emergency'] = ''; // emergency |
| 1129 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1129 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
| 1130 | 1130 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1131 | 1131 | $data['format_source'] = 'aircraftlistjson'; |
| 1132 | 1132 | $data['id_source'] = $id_source; |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | ) |
| 1148 | 1148 | ) { |
| 1149 | 1149 | $buffer = $Common->getData($value['host']); |
| 1150 | - $all_data = json_decode($buffer,true); |
|
| 1150 | + $all_data = json_decode($buffer, true); |
|
| 1151 | 1151 | if (isset($all_data['planes'])) { |
| 1152 | 1152 | $reset = 0; |
| 1153 | 1153 | foreach ($all_data['planes'] as $key => $line) { |
@@ -1164,12 +1164,12 @@ discard block |
||
| 1164 | 1164 | $data['emergency'] = ''; // emergency |
| 1165 | 1165 | $data['registration'] = $line[2]; |
| 1166 | 1166 | $data['aircraft_icao'] = $line[0]; |
| 1167 | - $deparr = explode('-',$line[1]); |
|
| 1167 | + $deparr = explode('-', $line[1]); |
|
| 1168 | 1168 | if (count($deparr) === 2) { |
| 1169 | 1169 | $data['departure_airport_icao'] = $deparr[0]; |
| 1170 | 1170 | $data['arrival_airport_icao'] = $deparr[1]; |
| 1171 | 1171 | } |
| 1172 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1172 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 1173 | 1173 | $data['format_source'] = 'planeupdatefaa'; |
| 1174 | 1174 | $data['id_source'] = $id_source; |
| 1175 | 1175 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | ) |
| 1188 | 1188 | ) { |
| 1189 | 1189 | $buffer = $Common->getData($value['host']); |
| 1190 | - $all_data = json_decode($buffer,true); |
|
| 1190 | + $all_data = json_decode($buffer, true); |
|
| 1191 | 1191 | if (isset($all_data['states'])) { |
| 1192 | 1192 | $reset = 0; |
| 1193 | 1193 | foreach ($all_data['states'] as $key => $line) { |
@@ -1204,7 +1204,7 @@ discard block |
||
| 1204 | 1204 | //$data['emergency'] = ''; // emergency |
| 1205 | 1205 | //$data['registration'] = $line[2]; |
| 1206 | 1206 | //$data['aircraft_icao'] = $line[0]; |
| 1207 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1207 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 1208 | 1208 | $data['format_source'] = 'opensky'; |
| 1209 | 1209 | $data['id_source'] = $id_source; |
| 1210 | 1210 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1221,8 +1221,8 @@ discard block |
||
| 1221 | 1221 | ) |
| 1222 | 1222 | ) { |
| 1223 | 1223 | $buffer = $Common->getData($value['host']); |
| 1224 | - $all_data = json_decode($buffer,true); |
|
| 1225 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1224 | + $all_data = json_decode($buffer, true); |
|
| 1225 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) { |
|
| 1226 | 1226 | $reset = 0; |
| 1227 | 1227 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1228 | 1228 | $data = array(); |
@@ -1260,7 +1260,7 @@ discard block |
||
| 1260 | 1260 | ) |
| 1261 | 1261 | ) { |
| 1262 | 1262 | $buffer = $Common->getData($value['host']); |
| 1263 | - $all_data = json_decode($buffer,true); |
|
| 1263 | + $all_data = json_decode($buffer, true); |
|
| 1264 | 1264 | if (isset($all_data['aircraft'])) { |
| 1265 | 1265 | $reset = 0; |
| 1266 | 1266 | foreach ($all_data['aircraft'] as $key => $line) { |
@@ -1277,7 +1277,7 @@ discard block |
||
| 1277 | 1277 | //$data['emergency'] = ''; // emergency |
| 1278 | 1278 | if (isset($line['reg'])) $data['registration'] = $line['reg']; |
| 1279 | 1279 | if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
| 1280 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1280 | + $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']); |
|
| 1281 | 1281 | $data['format_source'] = 'planefinderclient'; |
| 1282 | 1282 | $data['id_source'] = $id_source; |
| 1283 | 1283 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -1296,7 +1296,7 @@ discard block |
||
| 1296 | 1296 | ) { |
| 1297 | 1297 | //$buffer = $Common->getData($hosts[$id]); |
| 1298 | 1298 | $buffer = $Common->getData($value['host']); |
| 1299 | - $all_data = json_decode($buffer,true); |
|
| 1299 | + $all_data = json_decode($buffer, true); |
|
| 1300 | 1300 | if (!empty($all_data)) $reset = 0; |
| 1301 | 1301 | foreach ($all_data as $key => $line) { |
| 1302 | 1302 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1334,11 +1334,11 @@ discard block |
||
| 1334 | 1334 | ) |
| 1335 | 1335 | ) { |
| 1336 | 1336 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 1337 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1337 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 1338 | 1338 | //echo $buffer; |
| 1339 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1340 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1341 | - $all_data = json_decode($buffer,true); |
|
| 1339 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 1340 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 1341 | + $all_data = json_decode($buffer, true); |
|
| 1342 | 1342 | if (json_last_error() != JSON_ERROR_NONE) { |
| 1343 | 1343 | die(json_last_error_msg()); |
| 1344 | 1344 | } |
@@ -1361,7 +1361,7 @@ discard block |
||
| 1361 | 1361 | //$data['departure_airport_iata'] = $line[11]; |
| 1362 | 1362 | //$data['arrival_airport_iata'] = $line[12]; |
| 1363 | 1363 | //$data['emergency'] = ''; // emergency |
| 1364 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 1364 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 1365 | 1365 | $data['format_source'] = 'radarvirtueljson'; |
| 1366 | 1366 | $data['id_source'] = $id_source; |
| 1367 | 1367 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1382,14 +1382,14 @@ discard block |
||
| 1382 | 1382 | ) { |
| 1383 | 1383 | //$buffer = $Common->getData($hosts[$id]); |
| 1384 | 1384 | $buffer = $Common->getData($value['host'].'?'.time()); |
| 1385 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1385 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 1386 | 1386 | |
| 1387 | 1387 | if (isset($all_data['pireps'])) { |
| 1388 | 1388 | $reset = 0; |
| 1389 | 1389 | foreach ($all_data['pireps'] as $line) { |
| 1390 | 1390 | $data = array(); |
| 1391 | 1391 | $data['id'] = $line['id']; |
| 1392 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1392 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1393 | 1393 | $data['ident'] = $line['callsign']; // ident |
| 1394 | 1394 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 1395 | 1395 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1419,9 +1419,9 @@ discard block |
||
| 1419 | 1419 | $SI->add($data); |
| 1420 | 1420 | // print_r($data); |
| 1421 | 1421 | } elseif ($line['icon'] === 'ct') { |
| 1422 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 1423 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 1424 | - $typec = substr($data['ident'],-3); |
|
| 1422 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 1423 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 1424 | + $typec = substr($data['ident'], -3); |
|
| 1425 | 1425 | $data['type'] = ''; |
| 1426 | 1426 | if ($typec === 'APP') $data['type'] = 'Approach'; |
| 1427 | 1427 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
@@ -1432,7 +1432,7 @@ discard block |
||
| 1432 | 1432 | elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
| 1433 | 1433 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1434 | 1434 | else $data['type'] = 'Observer'; |
| 1435 | - 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']); |
|
| 1435 | + 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']); |
|
| 1436 | 1436 | } |
| 1437 | 1437 | unset($data); |
| 1438 | 1438 | } |
@@ -1449,7 +1449,7 @@ discard block |
||
| 1449 | 1449 | //$buffer = $Common->getData($hosts[$id]); |
| 1450 | 1450 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1451 | 1451 | $buffer = $Common->getData($value['host']); |
| 1452 | - $all_data = json_decode($buffer,true); |
|
| 1452 | + $all_data = json_decode($buffer, true); |
|
| 1453 | 1453 | if ($buffer != '' && is_array($all_data)) { |
| 1454 | 1454 | $reset = 0; |
| 1455 | 1455 | foreach ($all_data as $line) { |
@@ -1457,7 +1457,7 @@ discard block |
||
| 1457 | 1457 | //$data['id'] = $line['id']; // id not usable |
| 1458 | 1458 | if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']); |
| 1459 | 1459 | elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
| 1460 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1460 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 1461 | 1461 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 1462 | 1462 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 1463 | 1463 | $data['ident'] = $line['flightnum']; // ident |
@@ -1472,7 +1472,7 @@ discard block |
||
| 1472 | 1472 | //$data['datetime'] = $line['lastupdate']; |
| 1473 | 1473 | //$data['last_update'] = $line['lastupdate']; |
| 1474 | 1474 | if (isset($value['timezone'])) { |
| 1475 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1475 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
| 1476 | 1476 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1477 | 1477 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1478 | 1478 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1488,14 +1488,14 @@ discard block |
||
| 1488 | 1488 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 1489 | 1489 | if (isset($line['aircraftname'])) { |
| 1490 | 1490 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1491 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 1492 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1491 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 1492 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 1493 | 1493 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
| 1494 | 1494 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
| 1495 | 1495 | else { |
| 1496 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1497 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1498 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1496 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 1497 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
| 1498 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
| 1499 | 1499 | } |
| 1500 | 1500 | } |
| 1501 | 1501 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1520,7 +1520,7 @@ discard block |
||
| 1520 | 1520 | //$buffer = $Common->getData($hosts[$id]); |
| 1521 | 1521 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1522 | 1522 | $buffer = $Common->getData($value['host']); |
| 1523 | - $all_data = json_decode($buffer,true); |
|
| 1523 | + $all_data = json_decode($buffer, true); |
|
| 1524 | 1524 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
| 1525 | 1525 | $reset = 0; |
| 1526 | 1526 | foreach ($all_data['ACARSData'] as $line) { |
@@ -1531,7 +1531,7 @@ discard block |
||
| 1531 | 1531 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1532 | 1532 | if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
| 1533 | 1533 | if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
| 1534 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1534 | + $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident |
|
| 1535 | 1535 | if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
| 1536 | 1536 | $data['altitude'] = $line['altitude']; // altitude |
| 1537 | 1537 | $data['speed'] = $line['groundspeed']; // speed |
@@ -1542,7 +1542,7 @@ discard block |
||
| 1542 | 1542 | //$data['squawk'] = ''; // squawk |
| 1543 | 1543 | //$data['emergency'] = ''; // emergency |
| 1544 | 1544 | if (isset($value['timezone'])) { |
| 1545 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1545 | + $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); |
|
| 1546 | 1546 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1547 | 1547 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1548 | 1548 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1578,14 +1578,14 @@ discard block |
||
| 1578 | 1578 | //$buffer = $Common->getData($hosts[$id]); |
| 1579 | 1579 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1580 | 1580 | $buffer = $Common->getData($value['host']); |
| 1581 | - $all_data = json_decode($buffer,true); |
|
| 1581 | + $all_data = json_decode($buffer, true); |
|
| 1582 | 1582 | if ($buffer != '' && is_array($all_data)) { |
| 1583 | 1583 | $reset = 0; |
| 1584 | 1584 | foreach ($all_data as $line) { |
| 1585 | 1585 | $data = array(); |
| 1586 | 1586 | //$data['id'] = $line['id']; // id not usable |
| 1587 | 1587 | $data['id'] = trim($line['flight_id']); |
| 1588 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1588 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 1589 | 1589 | $data['pilot_name'] = $line['pilot_name']; |
| 1590 | 1590 | $data['pilot_id'] = $line['pilot_id']; |
| 1591 | 1591 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1629,24 +1629,24 @@ discard block |
||
| 1629 | 1629 | //$buffer = $Common->getData($hosts[$id]); |
| 1630 | 1630 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1631 | 1631 | $buffer = $Common->getData($value['host']); |
| 1632 | - $all_data = json_decode($buffer,true); |
|
| 1632 | + $all_data = json_decode($buffer, true); |
|
| 1633 | 1633 | if ($buffer != '') { |
| 1634 | 1634 | $Source->deleteLocationBySource('blitzortung'); |
| 1635 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1636 | - $buffer = explode('\n',$buffer); |
|
| 1635 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 1636 | + $buffer = explode('\n', $buffer); |
|
| 1637 | 1637 | foreach ($buffer as $buffer_line) { |
| 1638 | - $line = json_decode($buffer_line,true); |
|
| 1638 | + $line = json_decode($buffer_line, true); |
|
| 1639 | 1639 | if (isset($line['time'])) { |
| 1640 | 1640 | $data = array(); |
| 1641 | 1641 | $data['altitude'] = $line['alt']; // altitude |
| 1642 | 1642 | $data['latitude'] = $line['lat']; // lat |
| 1643 | 1643 | $data['longitude'] = $line['lon']; // long |
| 1644 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
| 1644 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
| 1645 | 1645 | $data['id_source'] = $id_source; |
| 1646 | 1646 | $data['format_source'] = 'blitzortung'; |
| 1647 | 1647 | $SI->add($data); |
| 1648 | 1648 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1649 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
| 1649 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
| 1650 | 1650 | unset($data); |
| 1651 | 1651 | } |
| 1652 | 1652 | } |
@@ -1658,15 +1658,15 @@ discard block |
||
| 1658 | 1658 | $arr = $httpfeeds; |
| 1659 | 1659 | $w = $e = null; |
| 1660 | 1660 | if (isset($arr[$id])) { |
| 1661 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 1661 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
| 1662 | 1662 | if ($nn > 0) { |
| 1663 | 1663 | foreach ($httpfeeds as $feed) { |
| 1664 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 1664 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
| 1665 | 1665 | if ($buffer === FALSE) { |
| 1666 | 1666 | connect_all($globalSources); |
| 1667 | 1667 | } |
| 1668 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1669 | - $buffer = explode('\n',$buffer); |
|
| 1668 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 1669 | + $buffer = explode('\n', $buffer); |
|
| 1670 | 1670 | foreach ($buffer as $line) { |
| 1671 | 1671 | if ($line != '') { |
| 1672 | 1672 | $line = json_decode($line, true); |
@@ -1706,11 +1706,11 @@ discard block |
||
| 1706 | 1706 | //$value = $formats[$nb]; |
| 1707 | 1707 | $format = $globalSources[$nb]['format']; |
| 1708 | 1708 | if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
| 1709 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 1709 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 1710 | 1710 | } elseif ($format === 'vrstcp') { |
| 1711 | 1711 | $buffer = @socket_read($r, 6000); |
| 1712 | 1712 | } else { |
| 1713 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 1713 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 1714 | 1714 | } |
| 1715 | 1715 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 1716 | 1716 | //echo $buffer."\n"; |
@@ -1720,8 +1720,8 @@ discard block |
||
| 1720 | 1720 | //$SI::del(); |
| 1721 | 1721 | if ($buffer !== FALSE) { |
| 1722 | 1722 | if ($format === 'vrstcp') { |
| 1723 | - $buffer = explode('},{',$buffer); |
|
| 1724 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1723 | + $buffer = explode('},{', $buffer); |
|
| 1724 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 1725 | 1725 | } |
| 1726 | 1726 | // SBS format is CSV format |
| 1727 | 1727 | if ($buffer !== FALSE && $buffer !== '') { |
@@ -1748,7 +1748,7 @@ discard block |
||
| 1748 | 1748 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1749 | 1749 | $data = array(); |
| 1750 | 1750 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
| 1751 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1751 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
| 1752 | 1752 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
| 1753 | 1753 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
| 1754 | 1754 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -1759,13 +1759,13 @@ discard block |
||
| 1759 | 1759 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 1760 | 1760 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 1761 | 1761 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 1762 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1762 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 1763 | 1763 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1764 | 1764 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1765 | 1765 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 1766 | 1766 | |
| 1767 | 1767 | if (isset($ais_data['timestamp'])) { |
| 1768 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 1768 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 1769 | 1769 | } else { |
| 1770 | 1770 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1771 | 1771 | } |
@@ -1776,10 +1776,10 @@ discard block |
||
| 1776 | 1776 | } elseif ($format === 'flightgearsp') { |
| 1777 | 1777 | //echo $buffer."\n"; |
| 1778 | 1778 | if (strlen($buffer) > 5) { |
| 1779 | - $line = explode(',',$buffer); |
|
| 1779 | + $line = explode(',', $buffer); |
|
| 1780 | 1780 | $data = array(); |
| 1781 | 1781 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 1782 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1782 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1783 | 1783 | $data['ident'] = $line[6]; |
| 1784 | 1784 | $data['aircraft_name'] = $line[7]; |
| 1785 | 1785 | $data['longitude'] = $line[1]; |
@@ -1796,25 +1796,25 @@ discard block |
||
| 1796 | 1796 | } elseif ($format === 'acars') { |
| 1797 | 1797 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1798 | 1798 | $ACARS->add(trim($buffer)); |
| 1799 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1799 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1800 | 1800 | $ACARS->deleteLiveAcarsData(); |
| 1801 | 1801 | } elseif ($format === 'acarsjsonudp') { |
| 1802 | 1802 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1803 | 1803 | $line = json_decode(trim($buffer), true); |
| 1804 | 1804 | if (!empty($line)) { |
| 1805 | - $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
|
| 1805 | + $line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line); |
|
| 1806 | 1806 | $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'] : ''))); |
| 1807 | 1807 | $ACARS->deleteLiveAcarsData(); |
| 1808 | 1808 | } |
| 1809 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1809 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1810 | 1810 | } elseif ($format === 'flightgearmp') { |
| 1811 | - if (substr($buffer,0,1) != '#') { |
|
| 1811 | + if (substr($buffer, 0, 1) != '#') { |
|
| 1812 | 1812 | $data = array(); |
| 1813 | 1813 | //echo $buffer."\n"; |
| 1814 | - $line = explode(' ',$buffer); |
|
| 1814 | + $line = explode(' ', $buffer); |
|
| 1815 | 1815 | if (count($line) === 11) { |
| 1816 | - $userserver = explode('@',$line[0]); |
|
| 1817 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1816 | + $userserver = explode('@', $line[0]); |
|
| 1817 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 1818 | 1818 | $data['ident'] = $userserver[0]; |
| 1819 | 1819 | $data['registration'] = $userserver[0]; |
| 1820 | 1820 | $data['latitude'] = $line[4]; |
@@ -1822,8 +1822,8 @@ discard block |
||
| 1822 | 1822 | $data['altitude'] = $line[6]; |
| 1823 | 1823 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1824 | 1824 | $aircraft_type = $line[10]; |
| 1825 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1826 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1825 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 1826 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 1827 | 1827 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1828 | 1828 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1829 | 1829 | } |
@@ -1832,8 +1832,8 @@ discard block |
||
| 1832 | 1832 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 1833 | 1833 | die; |
| 1834 | 1834 | } elseif ($format === 'vrstcp') { |
| 1835 | - foreach($buffer as $all_data) { |
|
| 1836 | - $line = json_decode('{'.$all_data.'}',true); |
|
| 1835 | + foreach ($buffer as $all_data) { |
|
| 1836 | + $line = json_decode('{'.$all_data.'}', true); |
|
| 1837 | 1837 | $data = array(); |
| 1838 | 1838 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
| 1839 | 1839 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1859,16 +1859,16 @@ discard block |
||
| 1859 | 1859 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1860 | 1860 | unset($data); |
| 1861 | 1861 | } |
| 1862 | - } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
|
| 1862 | + } elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') { |
|
| 1863 | 1863 | $line = explode("\t", $buffer); |
| 1864 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1864 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 1865 | 1865 | $key = $line[$k]; |
| 1866 | - $lined[$key] = $line[$k+1]; |
|
| 1866 | + $lined[$key] = $line[$k + 1]; |
|
| 1867 | 1867 | } |
| 1868 | 1868 | if (count($lined) > 3) { |
| 1869 | 1869 | $data['hex'] = $lined['hexid']; |
| 1870 | 1870 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1871 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1871 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 1872 | 1872 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 1873 | 1873 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 1874 | 1874 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1887,23 +1887,23 @@ discard block |
||
| 1887 | 1887 | } else $error = true; |
| 1888 | 1888 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1889 | 1889 | if ($aprs_connect === 0) { |
| 1890 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 1890 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 1891 | 1891 | $aprs_connect = 1; |
| 1892 | 1892 | } |
| 1893 | 1893 | |
| 1894 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1894 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 1895 | 1895 | $aprs_last_tx = time(); |
| 1896 | 1896 | $data_aprs = "# Keep alive"; |
| 1897 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1897 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | 1900 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 1901 | 1901 | //echo 'APRS data : '.$buffer."\n"; |
| 1902 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1903 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1902 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 1903 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 1904 | 1904 | //echo $buffer."\n"; |
| 1905 | 1905 | date_default_timezone_set('UTC'); |
| 1906 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1906 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 1907 | 1907 | $line = $APRS->parse($buffer); |
| 1908 | 1908 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1909 | 1909 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1918,7 +1918,7 @@ discard block |
||
| 1918 | 1918 | if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
| 1919 | 1919 | if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
| 1920 | 1920 | if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
| 1921 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1921 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 1922 | 1922 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1923 | 1923 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1924 | 1924 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -2006,29 +2006,29 @@ discard block |
||
| 2006 | 2006 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 2007 | 2007 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 2008 | 2008 | $Source->deleteOldLocationByType('gs'); |
| 2009 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
| 2010 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
| 2009 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
| 2010 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
| 2011 | 2011 | } else { |
| 2012 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
| 2012 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
| 2013 | 2013 | } |
| 2014 | 2014 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 2015 | 2015 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2016 | 2016 | if ($globalDebug) echo '# Weather Station added'."\n"; |
| 2017 | 2017 | $Source->deleteOldLocationByType('wx'); |
| 2018 | 2018 | $weather_data = json_encode($line); |
| 2019 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
| 2020 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
| 2019 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
| 2020 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
| 2021 | 2021 | } else { |
| 2022 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
| 2022 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
| 2023 | 2023 | } |
| 2024 | 2024 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 2025 | 2025 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2026 | 2026 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 2027 | 2027 | $Source->deleteOldLocationByType('lightning'); |
| 2028 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
| 2029 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
| 2028 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
| 2029 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
| 2030 | 2030 | } else { |
| 2031 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
| 2031 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
| 2032 | 2032 | } |
| 2033 | 2033 | } elseif ($globalDebug) { |
| 2034 | 2034 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -2037,7 +2037,7 @@ discard block |
||
| 2037 | 2037 | unset($data); |
| 2038 | 2038 | } |
| 2039 | 2039 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
| 2040 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
| 2040 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
| 2041 | 2041 | } |
| 2042 | 2042 | /* |
| 2043 | 2043 | 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')) { |
@@ -2046,7 +2046,7 @@ discard block |
||
| 2046 | 2046 | */ |
| 2047 | 2047 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 2048 | 2048 | elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 2049 | - if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
| 2049 | + if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
| 2050 | 2050 | $Source->deleteOldLocationByType('lightning'); |
| 2051 | 2051 | $Source->deleteOldLocationByType('wx'); |
| 2052 | 2052 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -2133,7 +2133,7 @@ discard block |
||
| 2133 | 2133 | connect_all($sourceee); |
| 2134 | 2134 | $sourceee = array(); |
| 2135 | 2135 | //connect_all($globalSources); |
| 2136 | - $tt[$format]=0; |
|
| 2136 | + $tt[$format] = 0; |
|
| 2137 | 2137 | break; |
| 2138 | 2138 | } |
| 2139 | 2139 | //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
@@ -2143,14 +2143,14 @@ discard block |
||
| 2143 | 2143 | } else { |
| 2144 | 2144 | $error = socket_strerror(socket_last_error()); |
| 2145 | 2145 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2146 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2146 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 2147 | 2147 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 2148 | 2148 | // Restart the script if possible |
| 2149 | 2149 | if (is_array($sockets)) { |
| 2150 | 2150 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 2151 | 2151 | |
| 2152 | 2152 | foreach ($sockets as $sock) { |
| 2153 | - @socket_shutdown($sock,2); |
|
| 2153 | + @socket_shutdown($sock, 2); |
|
| 2154 | 2154 | @socket_close($sock); |
| 2155 | 2155 | } |
| 2156 | 2156 | |