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