@@ -13,13 +13,17 @@ discard block |
||
| 13 | 13 | require_once(dirname(__FILE__).'/../require/class.SBS.php'); |
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 16 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 16 | +if (isset($globalTracker) && $globalTracker) { |
|
| 17 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 18 | +} |
|
| 17 | 19 | if (isset($globalMarine) && $globalMarine) { |
| 18 | 20 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 19 | 21 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 20 | 22 | } |
| 21 | 23 | |
| 22 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 24 | +if (!isset($globalDebug)) { |
|
| 25 | + $globalDebug = FALSE; |
|
| 26 | +} |
|
| 23 | 27 | |
| 24 | 28 | // Check if schema is at latest version |
| 25 | 29 | $Connection = new Connection(); |
@@ -54,35 +58,62 @@ discard block |
||
| 54 | 58 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 55 | 59 | if (isset($options['s'])) { |
| 56 | 60 | $globalSources = array(); |
| 57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 58 | - else $globalSources[] = array('host' => $options['s']); |
|
| 59 | -} elseif (isset($options['source'])) { |
|
| 61 | + if (isset($options['format'])) { |
|
| 62 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | + } else { |
|
| 64 | + $globalSources[] = array('host' => $options['s']); |
|
| 65 | + } |
|
| 66 | + } elseif (isset($options['source'])) { |
|
| 60 | 67 | $globalSources = array(); |
| 61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 62 | - else $globalSources[] = array('host' => $options['source']); |
|
| 63 | -} |
|
| 68 | + if (isset($options['format'])) { |
|
| 69 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 70 | + } else { |
|
| 71 | + $globalSources[] = array('host' => $options['source']); |
|
| 72 | + } |
|
| 73 | + } |
|
| 64 | 74 | if (isset($options['aprsserverhost'])) { |
| 65 | 75 | $globalServerAPRS = TRUE; |
| 66 | 76 | $globalServerAPRShost = $options['aprsserverhost']; |
| 67 | 77 | } |
| 68 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 69 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 70 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 71 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 72 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 73 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 74 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 75 | -else $id_source = 1; |
|
| 78 | +if (isset($options['aprsserverport'])) { |
|
| 79 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 80 | +} |
|
| 81 | +if (isset($options['aprsserverssid'])) { |
|
| 82 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 83 | +} |
|
| 84 | +if (isset($options['aprsserverpass'])) { |
|
| 85 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 86 | +} |
|
| 87 | +if (isset($options['noaprsserver'])) { |
|
| 88 | + $globalServerAPRS = FALSE; |
|
| 89 | +} |
|
| 90 | +if (isset($options['nodaemon'])) { |
|
| 91 | + $globalDaemon = FALSE; |
|
| 92 | +} |
|
| 93 | +if (isset($options['server'])) { |
|
| 94 | + $globalServer = TRUE; |
|
| 95 | +} |
|
| 96 | +if (isset($options['idsource'])) { |
|
| 97 | + $id_source = $options['idsource']; |
|
| 98 | +} else { |
|
| 99 | + $id_source = 1; |
|
| 100 | +} |
|
| 76 | 101 | if (isset($globalServer) && $globalServer) { |
| 77 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 102 | + if ($globalDebug) { |
|
| 103 | + echo "Using Server Mode\n"; |
|
| 104 | + } |
|
| 78 | 105 | $SI=new SpotterServer(); |
| 79 | 106 | /* |
| 80 | 107 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 81 | 108 | $SI = new adsb2aprs(); |
| 82 | 109 | $SI->connect(); |
| 83 | 110 | */ |
| 84 | -} else $SI=new SpotterImport($Connection->db); |
|
| 85 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 111 | +} else { |
|
| 112 | + $SI=new SpotterImport($Connection->db); |
|
| 113 | +} |
|
| 114 | +if (isset($globalTracker) && $globalTracker) { |
|
| 115 | + $TI = new TrackerImport($Connection->db); |
|
| 116 | +} |
|
| 86 | 117 | if (isset($globalMarine) && $globalMarine) { |
| 87 | 118 | $AIS = new AIS(); |
| 88 | 119 | $MI = new MarineImport($Connection->db); |
@@ -104,7 +135,9 @@ discard block |
||
| 104 | 135 | } |
| 105 | 136 | |
| 106 | 137 | // let's try and connect |
| 107 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 138 | +if ($globalDebug) { |
|
| 139 | + echo "Connecting...\n"; |
|
| 140 | +} |
|
| 108 | 141 | $use_aprs = false; |
| 109 | 142 | $aprs_full = false; |
| 110 | 143 | $reset = 0; |
@@ -113,7 +146,9 @@ discard block |
||
| 113 | 146 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 114 | 147 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 115 | 148 | $reset++; |
| 116 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 149 | + if ($globalDebug) { |
|
| 150 | + echo 'Connect to all...'."\n"; |
|
| 151 | + } |
|
| 117 | 152 | foreach ($hosts as $id => $value) { |
| 118 | 153 | $host = $value['host']; |
| 119 | 154 | $globalSources[$id]['last_exec'] = 0; |
@@ -123,27 +158,37 @@ discard block |
||
| 123 | 158 | //$formats[$id] = 'deltadbtxt'; |
| 124 | 159 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 125 | 160 | //$last_exec['deltadbtxt'] = 0; |
| 126 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 161 | + if ($globalDebug) { |
|
| 162 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 163 | + } |
|
| 127 | 164 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 128 | 165 | //$formats[$id] = 'vatsimtxt'; |
| 129 | 166 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 130 | 167 | //$last_exec['vatsimtxt'] = 0; |
| 131 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 168 | + if ($globalDebug) { |
|
| 169 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 170 | + } |
|
| 132 | 171 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 133 | 172 | //$formats[$id] = 'aircraftlistjson'; |
| 134 | 173 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 135 | 174 | //$last_exec['aircraftlistjson'] = 0; |
| 136 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 175 | + if ($globalDebug) { |
|
| 176 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 177 | + } |
|
| 137 | 178 | } else if (preg_match('/opensky/i',$host)) { |
| 138 | 179 | //$formats[$id] = 'aircraftlistjson'; |
| 139 | 180 | $globalSources[$id]['format'] = 'opensky'; |
| 140 | 181 | //$last_exec['aircraftlistjson'] = 0; |
| 141 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 182 | + if ($globalDebug) { |
|
| 183 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 184 | + } |
|
| 142 | 185 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
| 143 | 186 | //$formats[$id] = 'radarvirtueljson'; |
| 144 | 187 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 145 | 188 | //$last_exec['radarvirtueljson'] = 0; |
| 146 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 189 | + if ($globalDebug) { |
|
| 190 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 191 | + } |
|
| 147 | 192 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 148 | 193 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 149 | 194 | exit(0); |
@@ -152,7 +197,9 @@ discard block |
||
| 152 | 197 | //$formats[$id] = 'planeupdatefaa'; |
| 153 | 198 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 154 | 199 | //$last_exec['planeupdatefaa'] = 0; |
| 155 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 200 | + if ($globalDebug) { |
|
| 201 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 202 | + } |
|
| 156 | 203 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 157 | 204 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 158 | 205 | exit(0); |
@@ -161,26 +208,36 @@ discard block |
||
| 161 | 208 | //$formats[$id] = 'phpvmacars'; |
| 162 | 209 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 163 | 210 | //$last_exec['phpvmacars'] = 0; |
| 164 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 211 | + if ($globalDebug) { |
|
| 212 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 213 | + } |
|
| 165 | 214 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 166 | 215 | //$formats[$id] = 'phpvmacars'; |
| 167 | 216 | $globalSources[$id]['format'] = 'vam'; |
| 168 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 217 | + if ($globalDebug) { |
|
| 218 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 219 | + } |
|
| 169 | 220 | } else if (preg_match('/whazzup/i',$host)) { |
| 170 | 221 | //$formats[$id] = 'whazzup'; |
| 171 | 222 | $globalSources[$id]['format'] = 'whazzup'; |
| 172 | 223 | //$last_exec['whazzup'] = 0; |
| 173 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 224 | + if ($globalDebug) { |
|
| 225 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 226 | + } |
|
| 174 | 227 | } else if (preg_match('/recentpireps/i',$host)) { |
| 175 | 228 | //$formats[$id] = 'pirepsjson'; |
| 176 | 229 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 177 | 230 | //$last_exec['pirepsjson'] = 0; |
| 178 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 231 | + if ($globalDebug) { |
|
| 232 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 233 | + } |
|
| 179 | 234 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 180 | 235 | //$formats[$id] = 'fr24json'; |
| 181 | 236 | $globalSources[$id]['format'] = 'fr24json'; |
| 182 | 237 | //$last_exec['fr24json'] = 0; |
| 183 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 238 | + if ($globalDebug) { |
|
| 239 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 240 | + } |
|
| 184 | 241 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 185 | 242 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 186 | 243 | exit(0); |
@@ -189,7 +246,9 @@ discard block |
||
| 189 | 246 | //$formats[$id] = 'fr24json'; |
| 190 | 247 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 191 | 248 | //$last_exec['fr24json'] = 0; |
| 192 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 249 | + if ($globalDebug) { |
|
| 250 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 251 | + } |
|
| 193 | 252 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 194 | 253 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 195 | 254 | exit(0); |
@@ -198,17 +257,24 @@ discard block |
||
| 198 | 257 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 199 | 258 | //$formats[$id] = 'tsv'; |
| 200 | 259 | $globalSources[$id]['format'] = 'tsv'; |
| 201 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 260 | + if ($globalDebug) { |
|
| 261 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 262 | + } |
|
| 202 | 263 | } |
| 203 | 264 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 204 | 265 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 205 | 266 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 206 | 267 | if ($idf !== false) { |
| 207 | 268 | $httpfeeds[$id] = $idf; |
| 208 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 269 | + if ($globalDebug) { |
|
| 270 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 271 | + } |
|
| 272 | + } elseif ($globalDebug) { |
|
| 273 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 209 | 274 | } |
| 210 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 211 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 275 | + } elseif ($globalDebug) { |
|
| 276 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 277 | + } |
|
| 212 | 278 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 213 | 279 | $hostport = explode(':',$host); |
| 214 | 280 | if (isset($hostport[1])) { |
@@ -248,17 +314,25 @@ discard block |
||
| 248 | 314 | //$formats[$id] = 'beast'; |
| 249 | 315 | $globalSources[$id]['format'] = 'beast'; |
| 250 | 316 | //} else $formats[$id] = 'sbs'; |
| 251 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 317 | + } else { |
|
| 318 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 319 | + } |
|
| 252 | 320 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 253 | 321 | } |
| 254 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 322 | + if ($globalDebug) { |
|
| 323 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 324 | + } |
|
| 255 | 325 | } else { |
| 256 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 326 | + if ($globalDebug) { |
|
| 327 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 328 | + } |
|
| 257 | 329 | } |
| 258 | 330 | } |
| 259 | 331 | } |
| 260 | 332 | } |
| 261 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 333 | +if (!isset($globalMinFetch)) { |
|
| 334 | + $globalMinFetch = 15; |
|
| 335 | +} |
|
| 262 | 336 | |
| 263 | 337 | // Initialize all |
| 264 | 338 | $status = array(); |
@@ -267,13 +341,19 @@ discard block |
||
| 267 | 341 | $formats = array(); |
| 268 | 342 | $last_exec = array(); |
| 269 | 343 | $time = time(); |
| 270 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 271 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 272 | -else $timeout = 20; |
|
| 344 | +if (isset($globalSourcesTimeout)) { |
|
| 345 | + $timeout = $globalSourcesTimeOut; |
|
| 346 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 347 | + $timeout = $globalSBS1TimeOut; |
|
| 348 | +} else { |
|
| 349 | + $timeout = 20; |
|
| 350 | +} |
|
| 273 | 351 | $errno = ''; |
| 274 | 352 | $errstr=''; |
| 275 | 353 | |
| 276 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 354 | +if (!isset($globalDaemon)) { |
|
| 355 | + $globalDaemon = TRUE; |
|
| 356 | +} |
|
| 277 | 357 | /* Initiate connections to all the hosts simultaneously */ |
| 278 | 358 | //connect_all($hosts); |
| 279 | 359 | //connect_all($globalSources); |
@@ -299,7 +379,9 @@ discard block |
||
| 299 | 379 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 300 | 380 | $aprs_connect = 0; |
| 301 | 381 | $use_aprs = true; |
| 302 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 382 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 383 | + $aprs_full = true; |
|
| 384 | + } |
|
| 303 | 385 | break; |
| 304 | 386 | } |
| 305 | 387 | } |
@@ -310,25 +392,48 @@ discard block |
||
| 310 | 392 | $aprs_connect = 0; |
| 311 | 393 | $aprs_keep = 120; |
| 312 | 394 | $aprs_last_tx = time(); |
| 313 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 314 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 315 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 316 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 317 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 318 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 319 | - if ($aprs_full) $aprs_filter = ''; |
|
| 320 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 321 | - else $aprs_pass = '-1'; |
|
| 395 | + if (isset($globalAPRSversion)) { |
|
| 396 | + $aprs_version = $globalAPRSversion; |
|
| 397 | + } else { |
|
| 398 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 399 | + } |
|
| 400 | + if (isset($globalAPRSssid)) { |
|
| 401 | + $aprs_ssid = $globalAPRSssid; |
|
| 402 | + } else { |
|
| 403 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 404 | + } |
|
| 405 | + if (isset($globalAPRSfilter)) { |
|
| 406 | + $aprs_filter = $globalAPRSfilter; |
|
| 407 | + } else { |
|
| 408 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 409 | + } |
|
| 410 | + if ($aprs_full) { |
|
| 411 | + $aprs_filter = ''; |
|
| 412 | + } |
|
| 413 | + if (isset($globalAPRSpass)) { |
|
| 414 | + $aprs_pass = $globalAPRSpass; |
|
| 415 | + } else { |
|
| 416 | + $aprs_pass = '-1'; |
|
| 417 | + } |
|
| 322 | 418 | |
| 323 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 324 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 325 | -} |
|
| 419 | + if ($aprs_filter != '') { |
|
| 420 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 421 | + } else { |
|
| 422 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 423 | + } |
|
| 424 | + } |
|
| 326 | 425 | |
| 327 | 426 | // connected - lets do some work |
| 328 | -if ($globalDebug) echo "Connected!\n"; |
|
| 427 | +if ($globalDebug) { |
|
| 428 | + echo "Connected!\n"; |
|
| 429 | +} |
|
| 329 | 430 | sleep(1); |
| 330 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 331 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 431 | +if ($globalDebug) { |
|
| 432 | + echo "SCAN MODE \n\n"; |
|
| 433 | +} |
|
| 434 | +if (!isset($globalCronEnd)) { |
|
| 435 | + $globalCronEnd = 60; |
|
| 436 | +} |
|
| 332 | 437 | $endtime = time()+$globalCronEnd; |
| 333 | 438 | $i = 1; |
| 334 | 439 | $tt = array(); |
@@ -342,10 +447,14 @@ discard block |
||
| 342 | 447 | |
| 343 | 448 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 344 | 449 | while ($i > 0) { |
| 345 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 450 | + if (!$globalDaemon) { |
|
| 451 | + $i = $endtime-time(); |
|
| 452 | + } |
|
| 346 | 453 | // Delete old ATC |
| 347 | 454 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 348 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 455 | + if ($globalDebug) { |
|
| 456 | + echo 'Delete old ATC...'."\n"; |
|
| 457 | + } |
|
| 349 | 458 | $ATC->deleteOldATC(); |
| 350 | 459 | } |
| 351 | 460 | |
@@ -353,10 +462,14 @@ discard block |
||
| 353 | 462 | if (count($last_exec) == count($globalSources)) { |
| 354 | 463 | $max = $globalMinFetch; |
| 355 | 464 | foreach ($last_exec as $last) { |
| 356 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 465 | + if ((time() - $last['last']) < $max) { |
|
| 466 | + $max = time() - $last['last']; |
|
| 467 | + } |
|
| 357 | 468 | } |
| 358 | 469 | if ($max != $globalMinFetch) { |
| 359 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 470 | + if ($globalDebug) { |
|
| 471 | + echo 'Sleeping...'."\n"; |
|
| 472 | + } |
|
| 360 | 473 | sleep($globalMinFetch-$max+2); |
| 361 | 474 | } |
| 362 | 475 | } |
@@ -365,11 +478,15 @@ discard block |
||
| 365 | 478 | //foreach ($formats as $id => $value) { |
| 366 | 479 | foreach ($globalSources as $id => $value) { |
| 367 | 480 | date_default_timezone_set('UTC'); |
| 368 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 481 | + if (!isset($last_exec[$id]['last'])) { |
|
| 482 | + $last_exec[$id]['last'] = 0; |
|
| 483 | + } |
|
| 369 | 484 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 370 | 485 | //$buffer = $Common->getData($hosts[$id]); |
| 371 | 486 | $buffer = $Common->getData($value['host']); |
| 372 | - if ($buffer != '') $reset = 0; |
|
| 487 | + if ($buffer != '') { |
|
| 488 | + $reset = 0; |
|
| 489 | + } |
|
| 373 | 490 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 374 | 491 | $buffer = explode('\n',$buffer); |
| 375 | 492 | foreach ($buffer as $line) { |
@@ -378,20 +495,41 @@ discard block |
||
| 378 | 495 | $data = array(); |
| 379 | 496 | $data['hex'] = $line[1]; // hex |
| 380 | 497 | $data['ident'] = $line[2]; // ident |
| 381 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 382 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 383 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 384 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 385 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 498 | + if (isset($line[3])) { |
|
| 499 | + $data['altitude'] = $line[3]; |
|
| 500 | + } |
|
| 501 | + // altitude |
|
| 502 | + if (isset($line[4])) { |
|
| 503 | + $data['speed'] = $line[4]; |
|
| 504 | + } |
|
| 505 | + // speed |
|
| 506 | + if (isset($line[5])) { |
|
| 507 | + $data['heading'] = $line[5]; |
|
| 508 | + } |
|
| 509 | + // heading |
|
| 510 | + if (isset($line[6])) { |
|
| 511 | + $data['latitude'] = $line[6]; |
|
| 512 | + } |
|
| 513 | + // lat |
|
| 514 | + if (isset($line[7])) { |
|
| 515 | + $data['longitude'] = $line[7]; |
|
| 516 | + } |
|
| 517 | + // long |
|
| 386 | 518 | $data['verticalrate'] = ''; // vertical rate |
| 387 | 519 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 388 | 520 | $data['emergency'] = ''; // emergency |
| 389 | 521 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 390 | 522 | $data['format_source'] = 'deltadbtxt'; |
| 391 | 523 | $data['id_source'] = $id_source; |
| 392 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 393 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 394 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 524 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 525 | + $data['source_name'] = $value['name']; |
|
| 526 | + } |
|
| 527 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 528 | + $data['noarchive'] = true; |
|
| 529 | + } |
|
| 530 | + if (isset($value['sourcestats'])) { |
|
| 531 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 532 | + } |
|
| 395 | 533 | $SI->add($data); |
| 396 | 534 | unset($data); |
| 397 | 535 | } |
@@ -401,7 +539,9 @@ discard block |
||
| 401 | 539 | date_default_timezone_set('CET'); |
| 402 | 540 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 403 | 541 | date_default_timezone_set('UTC'); |
| 404 | - if ($buffer != '') $reset = 0; |
|
| 542 | + if ($buffer != '') { |
|
| 543 | + $reset = 0; |
|
| 544 | + } |
|
| 405 | 545 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 406 | 546 | $buffer = explode('\n',$buffer); |
| 407 | 547 | foreach ($buffer as $line) { |
@@ -410,16 +550,36 @@ discard block |
||
| 410 | 550 | $add = false; |
| 411 | 551 | $ais_data = $AIS->parse_line(trim($line)); |
| 412 | 552 | $data = array(); |
| 413 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 414 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 415 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 416 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 417 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 418 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 419 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 420 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 421 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 422 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 553 | + if (isset($ais_data['ident'])) { |
|
| 554 | + $data['ident'] = $ais_data['ident']; |
|
| 555 | + } |
|
| 556 | + if (isset($ais_data['mmsi'])) { |
|
| 557 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 558 | + } |
|
| 559 | + if (isset($ais_data['speed'])) { |
|
| 560 | + $data['speed'] = $ais_data['speed']; |
|
| 561 | + } |
|
| 562 | + if (isset($ais_data['heading'])) { |
|
| 563 | + $data['heading'] = $ais_data['heading']; |
|
| 564 | + } |
|
| 565 | + if (isset($ais_data['latitude'])) { |
|
| 566 | + $data['latitude'] = $ais_data['latitude']; |
|
| 567 | + } |
|
| 568 | + if (isset($ais_data['longitude'])) { |
|
| 569 | + $data['longitude'] = $ais_data['longitude']; |
|
| 570 | + } |
|
| 571 | + if (isset($ais_data['status'])) { |
|
| 572 | + $data['status'] = $ais_data['status']; |
|
| 573 | + } |
|
| 574 | + if (isset($ais_data['type'])) { |
|
| 575 | + $data['type'] = $ais_data['type']; |
|
| 576 | + } |
|
| 577 | + if (isset($ais_data['imo'])) { |
|
| 578 | + $data['imo'] = $ais_data['imo']; |
|
| 579 | + } |
|
| 580 | + if (isset($ais_data['callsign'])) { |
|
| 581 | + $data['callsign'] = $ais_data['callsign']; |
|
| 582 | + } |
|
| 423 | 583 | if (isset($ais_data['timestamp'])) { |
| 424 | 584 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 425 | 585 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -434,8 +594,12 @@ discard block |
||
| 434 | 594 | $data['id_source'] = $id_source; |
| 435 | 595 | //print_r($data); |
| 436 | 596 | echo 'Add...'."\n"; |
| 437 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 438 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 597 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 598 | + $data['noarchive'] = true; |
|
| 599 | + } |
|
| 600 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 601 | + $MI->add($data); |
|
| 602 | + } |
|
| 439 | 603 | unset($data); |
| 440 | 604 | } |
| 441 | 605 | } |
@@ -455,19 +619,45 @@ discard block |
||
| 455 | 619 | if ($line != '') { |
| 456 | 620 | $ais_data = $AIS->parse_line(trim($line)); |
| 457 | 621 | $data = array(); |
| 458 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 459 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 460 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 461 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 462 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 463 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 464 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 465 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 466 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 467 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 468 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 469 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 470 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 622 | + if (isset($ais_data['ident'])) { |
|
| 623 | + $data['ident'] = $ais_data['ident']; |
|
| 624 | + } |
|
| 625 | + if (isset($ais_data['mmsi'])) { |
|
| 626 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 627 | + } |
|
| 628 | + if (isset($ais_data['speed'])) { |
|
| 629 | + $data['speed'] = $ais_data['speed']; |
|
| 630 | + } |
|
| 631 | + if (isset($ais_data['heading'])) { |
|
| 632 | + $data['heading'] = $ais_data['heading']; |
|
| 633 | + } |
|
| 634 | + if (isset($ais_data['latitude'])) { |
|
| 635 | + $data['latitude'] = $ais_data['latitude']; |
|
| 636 | + } |
|
| 637 | + if (isset($ais_data['longitude'])) { |
|
| 638 | + $data['longitude'] = $ais_data['longitude']; |
|
| 639 | + } |
|
| 640 | + if (isset($ais_data['status'])) { |
|
| 641 | + $data['status'] = $ais_data['status']; |
|
| 642 | + } |
|
| 643 | + if (isset($ais_data['statusid'])) { |
|
| 644 | + $data['status_id'] = $ais_data['statusid']; |
|
| 645 | + } |
|
| 646 | + if (isset($ais_data['type'])) { |
|
| 647 | + $data['type'] = $ais_data['type']; |
|
| 648 | + } |
|
| 649 | + if (isset($ais_data['imo'])) { |
|
| 650 | + $data['imo'] = $ais_data['imo']; |
|
| 651 | + } |
|
| 652 | + if (isset($ais_data['callsign'])) { |
|
| 653 | + $data['callsign'] = $ais_data['callsign']; |
|
| 654 | + } |
|
| 655 | + if (isset($ais_data['destination'])) { |
|
| 656 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 657 | + } |
|
| 658 | + if (isset($ais_data['eta_ts'])) { |
|
| 659 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 660 | + } |
|
| 471 | 661 | if (isset($ais_data['timestamp'])) { |
| 472 | 662 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 473 | 663 | } else { |
@@ -475,16 +665,23 @@ discard block |
||
| 475 | 665 | } |
| 476 | 666 | $data['format_source'] = 'aisnmeahttp'; |
| 477 | 667 | $data['id_source'] = $id_source; |
| 478 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 479 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 668 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 669 | + $data['noarchive'] = true; |
|
| 670 | + } |
|
| 671 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 672 | + $MI->add($data); |
|
| 673 | + } |
|
| 480 | 674 | unset($data); |
| 481 | 675 | } |
| 482 | 676 | } |
| 483 | 677 | } |
| 484 | 678 | } else { |
| 485 | 679 | $format = $value['format']; |
| 486 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 487 | - else $tt[$format] = 0; |
|
| 680 | + if (isset($tt[$format])) { |
|
| 681 | + $tt[$format]++; |
|
| 682 | + } else { |
|
| 683 | + $tt[$format] = 0; |
|
| 684 | + } |
|
| 488 | 685 | if ($tt[$format] > 30) { |
| 489 | 686 | sleep(2); |
| 490 | 687 | $sourceeen[] = $value; |
@@ -515,7 +712,9 @@ discard block |
||
| 515 | 712 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 516 | 713 | $data['format_source'] = 'myshiptracking'; |
| 517 | 714 | $data['id_source'] = $id_source; |
| 518 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 715 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 716 | + $data['noarchive'] = true; |
|
| 717 | + } |
|
| 519 | 718 | $MI->add($data); |
| 520 | 719 | unset($data); |
| 521 | 720 | } |
@@ -536,7 +735,9 @@ discard block |
||
| 536 | 735 | $data['callsign'] = $line['callsign']; |
| 537 | 736 | $data['mmsi'] = $line['mmsi']; |
| 538 | 737 | $data['speed'] = $line['sog']; |
| 539 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 738 | + if ($line['heading'] != '511') { |
|
| 739 | + $data['heading'] = $line['heading']; |
|
| 740 | + } |
|
| 540 | 741 | $data['latitude'] = $line['latitude']; |
| 541 | 742 | $data['longitude'] = $line['longitude']; |
| 542 | 743 | $data['type_id'] = $line['shiptype']; |
@@ -544,7 +745,9 @@ discard block |
||
| 544 | 745 | $data['datetime'] = $line['time']; |
| 545 | 746 | $data['format_source'] = 'boatbeaconapp'; |
| 546 | 747 | $data['id_source'] = $id_source; |
| 547 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 748 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 749 | + $data['noarchive'] = true; |
|
| 750 | + } |
|
| 548 | 751 | $MI->add($data); |
| 549 | 752 | unset($data); |
| 550 | 753 | } |
@@ -557,7 +760,9 @@ discard block |
||
| 557 | 760 | echo 'download...'; |
| 558 | 761 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 559 | 762 | echo 'done !'."\n"; |
| 560 | - if ($buffer != '') $reset = 0; |
|
| 763 | + if ($buffer != '') { |
|
| 764 | + $reset = 0; |
|
| 765 | + } |
|
| 561 | 766 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 562 | 767 | $buffer = explode('\n',$buffer); |
| 563 | 768 | foreach ($buffer as $line) { |
@@ -582,7 +787,9 @@ discard block |
||
| 582 | 787 | //$data['etaTime'] = substr($line,135,5); |
| 583 | 788 | $data['format_source'] = 'shipplotter'; |
| 584 | 789 | $data['id_source'] = $id_source; |
| 585 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 790 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 791 | + $data['noarchive'] = true; |
|
| 792 | + } |
|
| 586 | 793 | //print_r($data); |
| 587 | 794 | echo 'Add...'."\n"; |
| 588 | 795 | $MI->add($data); |
@@ -602,16 +809,28 @@ discard block |
||
| 602 | 809 | $line = explode(':', $line); |
| 603 | 810 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 604 | 811 | $data = array(); |
| 605 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 606 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 812 | + if (isset($line[37]) && $line[37] != '') { |
|
| 813 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 814 | + } else { |
|
| 815 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 816 | + } |
|
| 607 | 817 | $data['pilot_id'] = $line[1]; |
| 608 | 818 | $data['pilot_name'] = $line[2]; |
| 609 | 819 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 610 | 820 | $data['ident'] = $line[0]; // ident |
| 611 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 821 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 822 | + $data['altitude'] = $line[7]; |
|
| 823 | + } |
|
| 824 | + // altitude |
|
| 612 | 825 | $data['speed'] = $line[8]; // speed |
| 613 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 614 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 826 | + if (isset($line[45])) { |
|
| 827 | + $data['heading'] = $line[45]; |
|
| 828 | + } |
|
| 829 | + // heading |
|
| 830 | + elseif (isset($line[38])) { |
|
| 831 | + $data['heading'] = $line[38]; |
|
| 832 | + } |
|
| 833 | + // heading |
|
| 615 | 834 | $data['latitude'] = $line[5]; // lat |
| 616 | 835 | $data['longitude'] = $line[6]; // long |
| 617 | 836 | $data['verticalrate'] = ''; // vertical rate |
@@ -627,7 +846,9 @@ discard block |
||
| 627 | 846 | $data['frequency'] = $line[4]; |
| 628 | 847 | $data['type'] = $line[18]; |
| 629 | 848 | $data['range'] = $line[19]; |
| 630 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 849 | + if (isset($line[35])) { |
|
| 850 | + $data['info'] = $line[35]; |
|
| 851 | + } |
|
| 631 | 852 | $data['id_source'] = $id_source; |
| 632 | 853 | //$data['arrival_airport_time'] = ; |
| 633 | 854 | if ($line[9] != '') { |
@@ -641,25 +862,44 @@ discard block |
||
| 641 | 862 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 642 | 863 | */ |
| 643 | 864 | $data['format_source'] = $value['format']; |
| 644 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 645 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 646 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 647 | - elseif ($line[3] == 'ATC') { |
|
| 865 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 866 | + $data['noarchive'] = true; |
|
| 867 | + } |
|
| 868 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 869 | + $data['source_name'] = $value['name']; |
|
| 870 | + } |
|
| 871 | + if ($line[3] == 'PILOT') { |
|
| 872 | + $SI->add($data); |
|
| 873 | + } elseif ($line[3] == 'ATC') { |
|
| 648 | 874 | //print_r($data); |
| 649 | 875 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 650 | 876 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 651 | 877 | $typec = substr($data['ident'],-3); |
| 652 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 653 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 654 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 655 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 656 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 657 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 658 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 659 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 660 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 661 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 662 | - if (isset($ATC)) 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']); |
|
| 878 | + if ($typec == 'APP') { |
|
| 879 | + $data['type'] = 'Approach'; |
|
| 880 | + } elseif ($typec == 'TWR') { |
|
| 881 | + $data['type'] = 'Tower'; |
|
| 882 | + } elseif ($typec == 'OBS') { |
|
| 883 | + $data['type'] = 'Observer'; |
|
| 884 | + } elseif ($typec == 'GND') { |
|
| 885 | + $data['type'] = 'Ground'; |
|
| 886 | + } elseif ($typec == 'DEL') { |
|
| 887 | + $data['type'] = 'Delivery'; |
|
| 888 | + } elseif ($typec == 'DEP') { |
|
| 889 | + $data['type'] = 'Departure'; |
|
| 890 | + } elseif ($typec == 'FSS') { |
|
| 891 | + $data['type'] = 'Flight Service Station'; |
|
| 892 | + } elseif ($typec == 'CTR') { |
|
| 893 | + $data['type'] = 'Control Radar or Centre'; |
|
| 894 | + } elseif ($data['type'] == '') { |
|
| 895 | + $data['type'] = 'Observer'; |
|
| 896 | + } |
|
| 897 | + if (!isset($data['source_name'])) { |
|
| 898 | + $data['source_name'] = ''; |
|
| 899 | + } |
|
| 900 | + if (isset($ATC)) { |
|
| 901 | + 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']); |
|
| 902 | + } |
|
| 663 | 903 | } |
| 664 | 904 | unset($data); |
| 665 | 905 | } |
@@ -678,27 +918,61 @@ discard block |
||
| 678 | 918 | foreach ($all_data['acList'] as $line) { |
| 679 | 919 | $data = array(); |
| 680 | 920 | $data['hex'] = $line['Icao']; // hex |
| 681 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 682 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 683 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 684 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 685 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 686 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 921 | + if (isset($line['Call'])) { |
|
| 922 | + $data['ident'] = $line['Call']; |
|
| 923 | + } |
|
| 924 | + // ident |
|
| 925 | + if (isset($line['Alt'])) { |
|
| 926 | + $data['altitude'] = $line['Alt']; |
|
| 927 | + } |
|
| 928 | + // altitude |
|
| 929 | + if (isset($line['Spd'])) { |
|
| 930 | + $data['speed'] = $line['Spd']; |
|
| 931 | + } |
|
| 932 | + // speed |
|
| 933 | + if (isset($line['Trak'])) { |
|
| 934 | + $data['heading'] = $line['Trak']; |
|
| 935 | + } |
|
| 936 | + // heading |
|
| 937 | + if (isset($line['Lat'])) { |
|
| 938 | + $data['latitude'] = $line['Lat']; |
|
| 939 | + } |
|
| 940 | + // lat |
|
| 941 | + if (isset($line['Long'])) { |
|
| 942 | + $data['longitude'] = $line['Long']; |
|
| 943 | + } |
|
| 944 | + // long |
|
| 687 | 945 | //$data['verticalrate'] = $line['']; // verticale rate |
| 688 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 946 | + if (isset($line['Sqk'])) { |
|
| 947 | + $data['squawk'] = $line['Sqk']; |
|
| 948 | + } |
|
| 949 | + // squawk |
|
| 689 | 950 | $data['emergency'] = ''; // emergency |
| 690 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 951 | + if (isset($line['Reg'])) { |
|
| 952 | + $data['registration'] = $line['Reg']; |
|
| 953 | + } |
|
| 691 | 954 | |
| 692 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 693 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 955 | + if (isset($line['PosTime'])) { |
|
| 956 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 957 | + } else { |
|
| 958 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 959 | + } |
|
| 694 | 960 | |
| 695 | 961 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 696 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 962 | + if (isset($line['Type'])) { |
|
| 963 | + $data['aircraft_icao'] = $line['Type']; |
|
| 964 | + } |
|
| 697 | 965 | $data['format_source'] = 'aircraftlistjson'; |
| 698 | 966 | $data['id_source'] = $id_source; |
| 699 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 700 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 701 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 967 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 968 | + $data['source_name'] = $value['name']; |
|
| 969 | + } |
|
| 970 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 971 | + $data['noarchive'] = true; |
|
| 972 | + } |
|
| 973 | + if (isset($data['latitude'])) { |
|
| 974 | + $SI->add($data); |
|
| 975 | + } |
|
| 702 | 976 | unset($data); |
| 703 | 977 | } |
| 704 | 978 | } elseif (is_array($all_data)) { |
@@ -715,12 +989,19 @@ discard block |
||
| 715 | 989 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 716 | 990 | $data['squawk'] = $line['squawk']; // squawk |
| 717 | 991 | $data['emergency'] = ''; // emergency |
| 718 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 719 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 992 | + if (isset($line['PosTime'])) { |
|
| 993 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 994 | + } else { |
|
| 995 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 996 | + } |
|
| 720 | 997 | $data['format_source'] = 'aircraftlistjson'; |
| 721 | 998 | $data['id_source'] = $id_source; |
| 722 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 723 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 999 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1000 | + $data['noarchive'] = true; |
|
| 1001 | + } |
|
| 1002 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1003 | + $data['source_name'] = $value['name']; |
|
| 1004 | + } |
|
| 724 | 1005 | $SI->add($data); |
| 725 | 1006 | unset($data); |
| 726 | 1007 | } |
@@ -756,8 +1037,12 @@ discard block |
||
| 756 | 1037 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 757 | 1038 | $data['format_source'] = 'planeupdatefaa'; |
| 758 | 1039 | $data['id_source'] = $id_source; |
| 759 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 760 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1040 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1041 | + $data['noarchive'] = true; |
|
| 1042 | + } |
|
| 1043 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1044 | + $data['source_name'] = $value['name']; |
|
| 1045 | + } |
|
| 761 | 1046 | $SI->add($data); |
| 762 | 1047 | unset($data); |
| 763 | 1048 | } |
@@ -786,7 +1071,9 @@ discard block |
||
| 786 | 1071 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 787 | 1072 | $data['format_source'] = 'opensky'; |
| 788 | 1073 | $data['id_source'] = $id_source; |
| 789 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1074 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1075 | + $data['noarchive'] = true; |
|
| 1076 | + } |
|
| 790 | 1077 | $SI->add($data); |
| 791 | 1078 | unset($data); |
| 792 | 1079 | } |
@@ -798,7 +1085,9 @@ discard block |
||
| 798 | 1085 | //$buffer = $Common->getData($hosts[$id]); |
| 799 | 1086 | $buffer = $Common->getData($value['host']); |
| 800 | 1087 | $all_data = json_decode($buffer,true); |
| 801 | - if (!empty($all_data)) $reset = 0; |
|
| 1088 | + if (!empty($all_data)) { |
|
| 1089 | + $reset = 0; |
|
| 1090 | + } |
|
| 802 | 1091 | foreach ($all_data as $key => $line) { |
| 803 | 1092 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 804 | 1093 | $data = array(); |
@@ -819,8 +1108,12 @@ discard block |
||
| 819 | 1108 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 820 | 1109 | $data['format_source'] = 'fr24json'; |
| 821 | 1110 | $data['id_source'] = $id_source; |
| 822 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 823 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1111 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1112 | + $data['noarchive'] = true; |
|
| 1113 | + } |
|
| 1114 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1115 | + $data['source_name'] = $value['name']; |
|
| 1116 | + } |
|
| 824 | 1117 | $SI->add($data); |
| 825 | 1118 | unset($data); |
| 826 | 1119 | } |
@@ -844,24 +1137,42 @@ discard block |
||
| 844 | 1137 | if (isset($line['inf'])) { |
| 845 | 1138 | $data = array(); |
| 846 | 1139 | $data['hex'] = $line['inf']['ia']; |
| 847 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1140 | + if (isset($line['inf']['cs'])) { |
|
| 1141 | + $data['ident'] = $line['inf']['cs']; |
|
| 1142 | + } |
|
| 1143 | + //$line[13] |
|
| 848 | 1144 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 849 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 850 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1145 | + if (isset($line['inf']['gs'])) { |
|
| 1146 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1147 | + } |
|
| 1148 | + // speed |
|
| 1149 | + if (isset($line['inf']['tr'])) { |
|
| 1150 | + $data['heading'] = $line['inf']['tr']; |
|
| 1151 | + } |
|
| 1152 | + // heading |
|
| 851 | 1153 | $data['latitude'] = $line['pt'][0]; // lat |
| 852 | 1154 | $data['longitude'] = $line['pt'][1]; // long |
| 853 | 1155 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 854 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1156 | + if (isset($line['inf']['sq'])) { |
|
| 1157 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1158 | + } |
|
| 1159 | + // squawk |
|
| 855 | 1160 | //$data['aircraft_icao'] = $line[8]; |
| 856 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1161 | + if (isset($line['inf']['rc'])) { |
|
| 1162 | + $data['registration'] = $line['inf']['rc']; |
|
| 1163 | + } |
|
| 857 | 1164 | //$data['departure_airport_iata'] = $line[11]; |
| 858 | 1165 | //$data['arrival_airport_iata'] = $line[12]; |
| 859 | 1166 | //$data['emergency'] = ''; // emergency |
| 860 | 1167 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 861 | 1168 | $data['format_source'] = 'radarvirtueljson'; |
| 862 | 1169 | $data['id_source'] = $id_source; |
| 863 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 864 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1170 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1171 | + $data['noarchive'] = true; |
|
| 1172 | + } |
|
| 1173 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1174 | + $data['source_name'] = $value['name']; |
|
| 1175 | + } |
|
| 865 | 1176 | $SI->add($data); |
| 866 | 1177 | unset($data); |
| 867 | 1178 | } |
@@ -882,30 +1193,65 @@ discard block |
||
| 882 | 1193 | $data['id'] = $line['id']; |
| 883 | 1194 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 884 | 1195 | $data['ident'] = $line['callsign']; // ident |
| 885 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 886 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 887 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 888 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 889 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 890 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1196 | + if (isset($line['pilotid'])) { |
|
| 1197 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1198 | + } |
|
| 1199 | + // pilot id |
|
| 1200 | + if (isset($line['name'])) { |
|
| 1201 | + $data['pilot_name'] = $line['name']; |
|
| 1202 | + } |
|
| 1203 | + // pilot name |
|
| 1204 | + if (isset($line['alt'])) { |
|
| 1205 | + $data['altitude'] = $line['alt']; |
|
| 1206 | + } |
|
| 1207 | + // altitude |
|
| 1208 | + if (isset($line['gs'])) { |
|
| 1209 | + $data['speed'] = $line['gs']; |
|
| 1210 | + } |
|
| 1211 | + // speed |
|
| 1212 | + if (isset($line['heading'])) { |
|
| 1213 | + $data['heading'] = $line['heading']; |
|
| 1214 | + } |
|
| 1215 | + // heading |
|
| 1216 | + if (isset($line['route'])) { |
|
| 1217 | + $data['waypoints'] = $line['route']; |
|
| 1218 | + } |
|
| 1219 | + // route |
|
| 891 | 1220 | $data['latitude'] = $line['lat']; // lat |
| 892 | 1221 | $data['longitude'] = $line['lon']; // long |
| 893 | 1222 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 894 | 1223 | //$data['squawk'] = $line['squawk']; // squawk |
| 895 | 1224 | //$data['emergency'] = ''; // emergency |
| 896 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 897 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 898 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1225 | + if (isset($line['depicao'])) { |
|
| 1226 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1227 | + } |
|
| 1228 | + if (isset($line['deptime'])) { |
|
| 1229 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1230 | + } |
|
| 1231 | + if (isset($line['arricao'])) { |
|
| 1232 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1233 | + } |
|
| 899 | 1234 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 900 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 901 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 902 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 903 | - else $data['info'] = ''; |
|
| 1235 | + if (isset($line['aircraft'])) { |
|
| 1236 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1237 | + } |
|
| 1238 | + if (isset($line['transponder'])) { |
|
| 1239 | + $data['squawk'] = $line['transponder']; |
|
| 1240 | + } |
|
| 1241 | + if (isset($line['atis'])) { |
|
| 1242 | + $data['info'] = $line['atis']; |
|
| 1243 | + } else { |
|
| 1244 | + $data['info'] = ''; |
|
| 1245 | + } |
|
| 904 | 1246 | $data['format_source'] = 'pireps'; |
| 905 | 1247 | $data['id_source'] = $id_source; |
| 906 | 1248 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 907 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 908 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1249 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1250 | + $data['noarchive'] = true; |
|
| 1251 | + } |
|
| 1252 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1253 | + $data['source_name'] = $value['name']; |
|
| 1254 | + } |
|
| 909 | 1255 | if ($line['icon'] == 'plane') { |
| 910 | 1256 | $SI->add($data); |
| 911 | 1257 | // print_r($data); |
@@ -914,16 +1260,28 @@ discard block |
||
| 914 | 1260 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 915 | 1261 | $typec = substr($data['ident'],-3); |
| 916 | 1262 | $data['type'] = ''; |
| 917 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 918 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 919 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 920 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 921 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 922 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 923 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 924 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 925 | - else $data['type'] = 'Observer'; |
|
| 926 | - 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']); |
|
| 1263 | + if ($typec == 'APP') { |
|
| 1264 | + $data['type'] = 'Approach'; |
|
| 1265 | + } elseif ($typec == 'TWR') { |
|
| 1266 | + $data['type'] = 'Tower'; |
|
| 1267 | + } elseif ($typec == 'OBS') { |
|
| 1268 | + $data['type'] = 'Observer'; |
|
| 1269 | + } elseif ($typec == 'GND') { |
|
| 1270 | + $data['type'] = 'Ground'; |
|
| 1271 | + } elseif ($typec == 'DEL') { |
|
| 1272 | + $data['type'] = 'Delivery'; |
|
| 1273 | + } elseif ($typec == 'DEP') { |
|
| 1274 | + $data['type'] = 'Departure'; |
|
| 1275 | + } elseif ($typec == 'FSS') { |
|
| 1276 | + $data['type'] = 'Flight Service Station'; |
|
| 1277 | + } elseif ($typec == 'CTR') { |
|
| 1278 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1279 | + } else { |
|
| 1280 | + $data['type'] = 'Observer'; |
|
| 1281 | + } |
|
| 1282 | + if (isset($ATC)) { |
|
| 1283 | + 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']); |
|
| 1284 | + } |
|
| 927 | 1285 | } |
| 928 | 1286 | unset($data); |
| 929 | 1287 | } |
@@ -933,7 +1291,9 @@ discard block |
||
| 933 | 1291 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 934 | 1292 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 935 | 1293 | //$buffer = $Common->getData($hosts[$id]); |
| 936 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1294 | + if ($globalDebug) { |
|
| 1295 | + echo 'Get Data...'."\n"; |
|
| 1296 | + } |
|
| 937 | 1297 | $buffer = $Common->getData($value['host']); |
| 938 | 1298 | $all_data = json_decode($buffer,true); |
| 939 | 1299 | if ($buffer != '' && is_array($all_data)) { |
@@ -941,10 +1301,16 @@ discard block |
||
| 941 | 1301 | foreach ($all_data as $line) { |
| 942 | 1302 | $data = array(); |
| 943 | 1303 | //$data['id'] = $line['id']; // id not usable |
| 944 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1304 | + if (isset($line['pilotid'])) { |
|
| 1305 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1306 | + } |
|
| 945 | 1307 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 946 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 947 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1308 | + if (isset($line['pilotname'])) { |
|
| 1309 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1310 | + } |
|
| 1311 | + if (isset($line['pilotid'])) { |
|
| 1312 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1313 | + } |
|
| 948 | 1314 | $data['ident'] = $line['flightnum']; // ident |
| 949 | 1315 | $data['altitude'] = $line['alt']; // altitude |
| 950 | 1316 | $data['speed'] = $line['gs']; // speed |
@@ -962,28 +1328,44 @@ discard block |
||
| 962 | 1328 | $data['arrival_airport_icao'] = $line['arricao']; |
| 963 | 1329 | $data['arrival_airport_time'] = $line['arrtime']; |
| 964 | 1330 | $data['registration'] = $line['aircraft']; |
| 965 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 966 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1331 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1332 | + $data['noarchive'] = true; |
|
| 1333 | + } |
|
| 1334 | + if (isset($line['route'])) { |
|
| 1335 | + $data['waypoints'] = $line['route']; |
|
| 1336 | + } |
|
| 1337 | + // route |
|
| 967 | 1338 | if (isset($line['aircraftname'])) { |
| 968 | 1339 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 969 | 1340 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 970 | 1341 | $aircraft_data = explode('-',$line['aircraftname']); |
| 971 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 972 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 973 | - else { |
|
| 1342 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1343 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1344 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1345 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1346 | + } else { |
|
| 974 | 1347 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 975 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 976 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1348 | + if (isset($aircraft_data[1])) { |
|
| 1349 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1350 | + } else { |
|
| 1351 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1352 | + } |
|
| 977 | 1353 | } |
| 978 | 1354 | } |
| 979 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1355 | + if (isset($line['route'])) { |
|
| 1356 | + $data['waypoints'] = $line['route']; |
|
| 1357 | + } |
|
| 980 | 1358 | $data['id_source'] = $id_source; |
| 981 | 1359 | $data['format_source'] = 'phpvmacars'; |
| 982 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1360 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1361 | + $data['source_name'] = $value['name']; |
|
| 1362 | + } |
|
| 983 | 1363 | $SI->add($data); |
| 984 | 1364 | unset($data); |
| 985 | 1365 | } |
| 986 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1366 | + if ($globalDebug) { |
|
| 1367 | + echo 'No more data...'."\n"; |
|
| 1368 | + } |
|
| 987 | 1369 | unset($buffer); |
| 988 | 1370 | unset($all_data); |
| 989 | 1371 | } |
@@ -991,7 +1373,9 @@ discard block |
||
| 991 | 1373 | $last_exec[$id]['last'] = time(); |
| 992 | 1374 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 993 | 1375 | //$buffer = $Common->getData($hosts[$id]); |
| 994 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1376 | + if ($globalDebug) { |
|
| 1377 | + echo 'Get Data...'."\n"; |
|
| 1378 | + } |
|
| 995 | 1379 | $buffer = $Common->getData($value['host']); |
| 996 | 1380 | $all_data = json_decode($buffer,true); |
| 997 | 1381 | if ($buffer != '' && is_array($all_data)) { |
@@ -1020,16 +1404,25 @@ discard block |
||
| 1020 | 1404 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1021 | 1405 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1022 | 1406 | //$data['registration'] = $line['aircraft']; |
| 1023 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1407 | + if (isset($line['route'])) { |
|
| 1408 | + $data['waypoints'] = $line['route']; |
|
| 1409 | + } |
|
| 1410 | + // route |
|
| 1024 | 1411 | $data['aircraft_icao'] = $line['plane_type']; |
| 1025 | 1412 | $data['id_source'] = $id_source; |
| 1026 | 1413 | $data['format_source'] = 'vam'; |
| 1027 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1028 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1414 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1415 | + $data['noarchive'] = true; |
|
| 1416 | + } |
|
| 1417 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1418 | + $data['source_name'] = $value['name']; |
|
| 1419 | + } |
|
| 1029 | 1420 | $SI->add($data); |
| 1030 | 1421 | unset($data); |
| 1031 | 1422 | } |
| 1032 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1423 | + if ($globalDebug) { |
|
| 1424 | + echo 'No more data...'."\n"; |
|
| 1425 | + } |
|
| 1033 | 1426 | unset($buffer); |
| 1034 | 1427 | unset($all_data); |
| 1035 | 1428 | } |
@@ -1037,7 +1430,9 @@ discard block |
||
| 1037 | 1430 | $last_exec[$id]['last'] = time(); |
| 1038 | 1431 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1039 | 1432 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1040 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1433 | + if (function_exists('pcntl_fork')) { |
|
| 1434 | + pcntl_signal_dispatch(); |
|
| 1435 | + } |
|
| 1041 | 1436 | //$last_exec[$id]['last'] = time(); |
| 1042 | 1437 | |
| 1043 | 1438 | //$read = array( $sockets[$id] ); |
@@ -1045,7 +1440,9 @@ discard block |
||
| 1045 | 1440 | $write = NULL; |
| 1046 | 1441 | $e = NULL; |
| 1047 | 1442 | $n = socket_select($read, $write, $e, $timeout); |
| 1048 | - if ($e != NULL) var_dump($e); |
|
| 1443 | + if ($e != NULL) { |
|
| 1444 | + var_dump($e); |
|
| 1445 | + } |
|
| 1049 | 1446 | if ($n > 0) { |
| 1050 | 1447 | $reset = 0; |
| 1051 | 1448 | foreach ($read as $nb => $r) { |
@@ -1066,12 +1463,16 @@ discard block |
||
| 1066 | 1463 | //$SI::del(); |
| 1067 | 1464 | if ($format == 'vrstcp') { |
| 1068 | 1465 | $buffer = explode('},{',$buffer); |
| 1069 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1466 | + } else { |
|
| 1467 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1468 | + } |
|
| 1070 | 1469 | // SBS format is CSV format |
| 1071 | 1470 | if ($buffer !== FALSE && $buffer != '') { |
| 1072 | 1471 | $tt[$format] = 0; |
| 1073 | 1472 | if ($format == 'acarssbs3') { |
| 1074 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1473 | + if ($globalDebug) { |
|
| 1474 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1475 | + } |
|
| 1075 | 1476 | $ACARS->add(trim($buffer)); |
| 1076 | 1477 | $ACARS->deleteLiveAcarsData(); |
| 1077 | 1478 | } elseif ($format == 'raw') { |
@@ -1080,28 +1481,64 @@ discard block |
||
| 1080 | 1481 | if (is_array($data)) { |
| 1081 | 1482 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1082 | 1483 | $data['format_source'] = 'raw'; |
| 1083 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1084 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1085 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1086 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1484 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1485 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1486 | + } |
|
| 1487 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1488 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1489 | + } |
|
| 1490 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1491 | + $data['noarchive'] = true; |
|
| 1492 | + } |
|
| 1493 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1494 | + $SI->add($data); |
|
| 1495 | + } |
|
| 1087 | 1496 | } |
| 1088 | 1497 | } elseif ($format == 'ais') { |
| 1089 | 1498 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1090 | 1499 | $data = array(); |
| 1091 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1092 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1093 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1094 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1095 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1096 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1097 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1098 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1099 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1100 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1101 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1102 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1103 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1104 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1500 | + if (isset($ais_data['ident'])) { |
|
| 1501 | + $data['ident'] = $ais_data['ident']; |
|
| 1502 | + } |
|
| 1503 | + if (isset($ais_data['mmsi'])) { |
|
| 1504 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 1505 | + } |
|
| 1506 | + if (isset($ais_data['speed'])) { |
|
| 1507 | + $data['speed'] = $ais_data['speed']; |
|
| 1508 | + } |
|
| 1509 | + if (isset($ais_data['heading'])) { |
|
| 1510 | + $data['heading'] = $ais_data['heading']; |
|
| 1511 | + } |
|
| 1512 | + if (isset($ais_data['latitude'])) { |
|
| 1513 | + $data['latitude'] = $ais_data['latitude']; |
|
| 1514 | + } |
|
| 1515 | + if (isset($ais_data['longitude'])) { |
|
| 1516 | + $data['longitude'] = $ais_data['longitude']; |
|
| 1517 | + } |
|
| 1518 | + if (isset($ais_data['status'])) { |
|
| 1519 | + $data['status'] = $ais_data['status']; |
|
| 1520 | + } |
|
| 1521 | + if (isset($ais_data['statusid'])) { |
|
| 1522 | + $data['status_id'] = $ais_data['statusid']; |
|
| 1523 | + } |
|
| 1524 | + if (isset($ais_data['type'])) { |
|
| 1525 | + $data['type'] = $ais_data['type']; |
|
| 1526 | + } |
|
| 1527 | + if (isset($ais_data['imo'])) { |
|
| 1528 | + $data['imo'] = $ais_data['imo']; |
|
| 1529 | + } |
|
| 1530 | + if (isset($ais_data['callsign'])) { |
|
| 1531 | + $data['callsign'] = $ais_data['callsign']; |
|
| 1532 | + } |
|
| 1533 | + if (isset($ais_data['destination'])) { |
|
| 1534 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 1535 | + } |
|
| 1536 | + if (isset($ais_data['eta_ts'])) { |
|
| 1537 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1538 | + } |
|
| 1539 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1540 | + $data['noarchive'] = true; |
|
| 1541 | + } |
|
| 1105 | 1542 | |
| 1106 | 1543 | if (isset($ais_data['timestamp'])) { |
| 1107 | 1544 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1110,7 +1547,9 @@ discard block |
||
| 1110 | 1547 | } |
| 1111 | 1548 | $data['format_source'] = 'aisnmea'; |
| 1112 | 1549 | $data['id_source'] = $id_source; |
| 1113 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1550 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 1551 | + $MI->add($data); |
|
| 1552 | + } |
|
| 1114 | 1553 | unset($data); |
| 1115 | 1554 | } elseif ($format == 'flightgearsp') { |
| 1116 | 1555 | //echo $buffer."\n"; |
@@ -1128,12 +1567,18 @@ discard block |
||
| 1128 | 1567 | $data['speed'] = round($line[5]*1.94384); |
| 1129 | 1568 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1130 | 1569 | $data['format_source'] = 'flightgearsp'; |
| 1131 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1132 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1570 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1571 | + $data['noarchive'] = true; |
|
| 1572 | + } |
|
| 1573 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1574 | + $SI->add($data); |
|
| 1575 | + } |
|
| 1133 | 1576 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1134 | 1577 | } |
| 1135 | 1578 | } elseif ($format == 'acars') { |
| 1136 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1579 | + if ($globalDebug) { |
|
| 1580 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1581 | + } |
|
| 1137 | 1582 | $ACARS->add(trim($buffer)); |
| 1138 | 1583 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1139 | 1584 | $ACARS->deleteLiveAcarsData(); |
@@ -1154,8 +1599,12 @@ discard block |
||
| 1154 | 1599 | $aircraft_type = $line[10]; |
| 1155 | 1600 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1156 | 1601 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1157 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1158 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1602 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1603 | + $data['noarchive'] = true; |
|
| 1604 | + } |
|
| 1605 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1606 | + $SI->add($data); |
|
| 1607 | + } |
|
| 1159 | 1608 | } |
| 1160 | 1609 | } |
| 1161 | 1610 | } elseif ($format == 'beast') { |
@@ -1165,28 +1614,62 @@ discard block |
||
| 1165 | 1614 | foreach($buffer as $all_data) { |
| 1166 | 1615 | $line = json_decode('{'.$all_data.'}',true); |
| 1167 | 1616 | $data = array(); |
| 1168 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1169 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1170 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1171 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1172 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1173 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1174 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1617 | + if (isset($line['Icao'])) { |
|
| 1618 | + $data['hex'] = $line['Icao']; |
|
| 1619 | + } |
|
| 1620 | + // hex |
|
| 1621 | + if (isset($line['Call'])) { |
|
| 1622 | + $data['ident'] = $line['Call']; |
|
| 1623 | + } |
|
| 1624 | + // ident |
|
| 1625 | + if (isset($line['Alt'])) { |
|
| 1626 | + $data['altitude'] = $line['Alt']; |
|
| 1627 | + } |
|
| 1628 | + // altitude |
|
| 1629 | + if (isset($line['Spd'])) { |
|
| 1630 | + $data['speed'] = $line['Spd']; |
|
| 1631 | + } |
|
| 1632 | + // speed |
|
| 1633 | + if (isset($line['Trak'])) { |
|
| 1634 | + $data['heading'] = $line['Trak']; |
|
| 1635 | + } |
|
| 1636 | + // heading |
|
| 1637 | + if (isset($line['Lat'])) { |
|
| 1638 | + $data['latitude'] = $line['Lat']; |
|
| 1639 | + } |
|
| 1640 | + // lat |
|
| 1641 | + if (isset($line['Long'])) { |
|
| 1642 | + $data['longitude'] = $line['Long']; |
|
| 1643 | + } |
|
| 1644 | + // long |
|
| 1175 | 1645 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1176 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1646 | + if (isset($line['Sqk'])) { |
|
| 1647 | + $data['squawk'] = $line['Sqk']; |
|
| 1648 | + } |
|
| 1649 | + // squawk |
|
| 1177 | 1650 | $data['emergency'] = ''; // emergency |
| 1178 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1651 | + if (isset($line['Reg'])) { |
|
| 1652 | + $data['registration'] = $line['Reg']; |
|
| 1653 | + } |
|
| 1179 | 1654 | /* |
| 1180 | 1655 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1181 | 1656 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1182 | 1657 | */ |
| 1183 | 1658 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1184 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1659 | + if (isset($line['Type'])) { |
|
| 1660 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1661 | + } |
|
| 1185 | 1662 | $data['format_source'] = 'vrstcp'; |
| 1186 | 1663 | $data['id_source'] = $id_source; |
| 1187 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1188 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1189 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 1664 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1665 | + $data['noarchive'] = true; |
|
| 1666 | + } |
|
| 1667 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1668 | + $data['source_name'] = $value['name']; |
|
| 1669 | + } |
|
| 1670 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 1671 | + $SI->add($data); |
|
| 1672 | + } |
|
| 1190 | 1673 | unset($data); |
| 1191 | 1674 | } |
| 1192 | 1675 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1199,22 +1682,46 @@ discard block |
||
| 1199 | 1682 | $data['hex'] = $lined['hexid']; |
| 1200 | 1683 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1201 | 1684 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1202 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1203 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1204 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1205 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1206 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1207 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1208 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1685 | + if (isset($lined['ident'])) { |
|
| 1686 | + $data['ident'] = $lined['ident']; |
|
| 1687 | + } |
|
| 1688 | + if (isset($lined['lat'])) { |
|
| 1689 | + $data['latitude'] = $lined['lat']; |
|
| 1690 | + } |
|
| 1691 | + if (isset($lined['lon'])) { |
|
| 1692 | + $data['longitude'] = $lined['lon']; |
|
| 1693 | + } |
|
| 1694 | + if (isset($lined['speed'])) { |
|
| 1695 | + $data['speed'] = $lined['speed']; |
|
| 1696 | + } |
|
| 1697 | + if (isset($lined['squawk'])) { |
|
| 1698 | + $data['squawk'] = $lined['squawk']; |
|
| 1699 | + } |
|
| 1700 | + if (isset($lined['alt'])) { |
|
| 1701 | + $data['altitude'] = $lined['alt']; |
|
| 1702 | + } |
|
| 1703 | + if (isset($lined['heading'])) { |
|
| 1704 | + $data['heading'] = $lined['heading']; |
|
| 1705 | + } |
|
| 1209 | 1706 | $data['id_source'] = $id_source; |
| 1210 | 1707 | $data['format_source'] = 'tsv'; |
| 1211 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1212 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1213 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1214 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1708 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1709 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1710 | + } |
|
| 1711 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1712 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1713 | + } |
|
| 1714 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1715 | + $data['noarchive'] = true; |
|
| 1716 | + } |
|
| 1717 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1718 | + $SI->add($data); |
|
| 1719 | + } |
|
| 1215 | 1720 | unset($lined); |
| 1216 | 1721 | unset($data); |
| 1217 | - } else $error = true; |
|
| 1722 | + } else { |
|
| 1723 | + $error = true; |
|
| 1724 | + } |
|
| 1218 | 1725 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1219 | 1726 | if ($aprs_connect == 0) { |
| 1220 | 1727 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1239,37 +1746,81 @@ discard block |
||
| 1239 | 1746 | $aprs_last_tx = time(); |
| 1240 | 1747 | $data = array(); |
| 1241 | 1748 | //print_r($line); |
| 1242 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1243 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1244 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1245 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1246 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1247 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1248 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1249 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1250 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1749 | + if (isset($line['address'])) { |
|
| 1750 | + $data['hex'] = $line['address']; |
|
| 1751 | + } |
|
| 1752 | + if (isset($line['mmsi'])) { |
|
| 1753 | + $data['mmsi'] = $line['mmsi']; |
|
| 1754 | + } |
|
| 1755 | + if (isset($line['imo'])) { |
|
| 1756 | + $data['imo'] = $line['imo']; |
|
| 1757 | + } |
|
| 1758 | + if (isset($line['arrival_code'])) { |
|
| 1759 | + $data['arrical_code'] = $line['arrival_code']; |
|
| 1760 | + } |
|
| 1761 | + if (isset($line['arrival_date'])) { |
|
| 1762 | + $data['arrical_date'] = $line['arrival_date']; |
|
| 1763 | + } |
|
| 1764 | + if (isset($line['type_id'])) { |
|
| 1765 | + $data['type_id'] = $line['typeid']; |
|
| 1766 | + } |
|
| 1767 | + if (isset($line['status_id'])) { |
|
| 1768 | + $data['status_id'] = $line['statusid']; |
|
| 1769 | + } |
|
| 1770 | + if (isset($line['timestamp'])) { |
|
| 1771 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1772 | + } else { |
|
| 1773 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1774 | + } |
|
| 1251 | 1775 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1252 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1776 | + if (isset($line['ident'])) { |
|
| 1777 | + $data['ident'] = $line['ident']; |
|
| 1778 | + } |
|
| 1253 | 1779 | $data['latitude'] = $line['latitude']; |
| 1254 | 1780 | $data['longitude'] = $line['longitude']; |
| 1255 | 1781 | //$data['verticalrate'] = $line[16]; |
| 1256 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1257 | - else $data['speed'] = 0; |
|
| 1258 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1259 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1260 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1261 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1782 | + if (isset($line['speed'])) { |
|
| 1783 | + $data['speed'] = $line['speed']; |
|
| 1784 | + } else { |
|
| 1785 | + $data['speed'] = 0; |
|
| 1786 | + } |
|
| 1787 | + if (isset($line['altitude'])) { |
|
| 1788 | + $data['altitude'] = $line['altitude']; |
|
| 1789 | + } |
|
| 1790 | + if (isset($line['comment'])) { |
|
| 1791 | + $data['comment'] = $line['comment']; |
|
| 1792 | + } |
|
| 1793 | + if (isset($line['symbol'])) { |
|
| 1794 | + $data['type'] = $line['symbol']; |
|
| 1795 | + } |
|
| 1796 | + if (isset($line['heading'])) { |
|
| 1797 | + $data['heading'] = $line['heading']; |
|
| 1798 | + } |
|
| 1262 | 1799 | //else $data['heading'] = 0; |
| 1263 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1264 | - if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1265 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1800 | + if (isset($line['stealth'])) { |
|
| 1801 | + $data['aircraft_type'] = $line['stealth']; |
|
| 1802 | + } |
|
| 1803 | + if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) { |
|
| 1804 | + $data['noarchive'] = true; |
|
| 1805 | + } |
|
| 1806 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1807 | + $data['noarchive'] = true; |
|
| 1808 | + } |
|
| 1266 | 1809 | $data['id_source'] = $id_source; |
| 1267 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1268 | - else $data['format_source'] = 'aprs'; |
|
| 1810 | + if (isset($line['format_source'])) { |
|
| 1811 | + $data['format_source'] = $line['format_source']; |
|
| 1812 | + } else { |
|
| 1813 | + $data['format_source'] = 'aprs'; |
|
| 1814 | + } |
|
| 1269 | 1815 | $data['source_name'] = $line['source']; |
| 1270 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1271 | - else $data['source_type'] = 'flarm'; |
|
| 1272 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1816 | + if (isset($line['source_type'])) { |
|
| 1817 | + $data['source_type'] = $line['source_type']; |
|
| 1818 | + } else { |
|
| 1819 | + $data['source_type'] = 'flarm'; |
|
| 1820 | + } |
|
| 1821 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1822 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1823 | + } |
|
| 1273 | 1824 | $currentdate = date('Y-m-d H:i:s'); |
| 1274 | 1825 | $aprsdate = strtotime($data['datetime']); |
| 1275 | 1826 | // Accept data if time <= system time + 20s |
@@ -1280,19 +1831,22 @@ discard block |
||
| 1280 | 1831 | echo 'add...'."\n"; |
| 1281 | 1832 | $send = $MI->add($data); |
| 1282 | 1833 | } elseif (isset($line['stealth'])) { |
| 1283 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1284 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1834 | + if ($line['stealth'] != 0) { |
|
| 1835 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1836 | + } else { |
|
| 1837 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1838 | + } |
|
| 1285 | 1839 | //} elseif (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' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
| 1286 | 1840 | } 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') { |
| 1287 | 1841 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1288 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 1842 | + if (isset($globalTracker) && $globalTracker) { |
|
| 1843 | + $send = $TI->add($data); |
|
| 1844 | + } |
|
| 1289 | 1845 | } |
| 1290 | 1846 | unset($data); |
| 1291 | - } |
|
| 1292 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1847 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1293 | 1848 | echo '!! Weather Station not yet supported'."\n"; |
| 1294 | - } |
|
| 1295 | - 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')) { |
|
| 1849 | + } 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')) { |
|
| 1296 | 1850 | echo '!! Car & Trucks not yet supported'."\n"; |
| 1297 | 1851 | } |
| 1298 | 1852 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
@@ -1325,26 +1879,45 @@ discard block |
||
| 1325 | 1879 | $data['ground'] = $line[21]; |
| 1326 | 1880 | $data['emergency'] = $line[19]; |
| 1327 | 1881 | $data['format_source'] = 'sbs'; |
| 1328 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1329 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1330 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1882 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1883 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1884 | + } |
|
| 1885 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1886 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1887 | + } |
|
| 1888 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1889 | + $data['noarchive'] = true; |
|
| 1890 | + } |
|
| 1331 | 1891 | $data['id_source'] = $id_source; |
| 1332 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1333 | - else $error = true; |
|
| 1892 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1893 | + $send = $SI->add($data); |
|
| 1894 | + } else { |
|
| 1895 | + $error = true; |
|
| 1896 | + } |
|
| 1334 | 1897 | unset($data); |
| 1335 | - } else $error = true; |
|
| 1898 | + } else { |
|
| 1899 | + $error = true; |
|
| 1900 | + } |
|
| 1336 | 1901 | if ($error) { |
| 1337 | 1902 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1338 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 1903 | + if ($globalDebug) { |
|
| 1904 | + echo "Not a message. Ignoring... \n"; |
|
| 1905 | + } |
|
| 1339 | 1906 | } else { |
| 1340 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 1907 | + if ($globalDebug) { |
|
| 1908 | + echo "Wrong line format. Ignoring... \n"; |
|
| 1909 | + } |
|
| 1341 | 1910 | if ($globalDebug) { |
| 1342 | 1911 | echo $buffer; |
| 1343 | 1912 | //print_r($line); |
| 1344 | 1913 | } |
| 1345 | 1914 | //socket_close($r); |
| 1346 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1347 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 1915 | + if ($globalDebug) { |
|
| 1916 | + echo "Reconnect after an error...\n"; |
|
| 1917 | + } |
|
| 1918 | + if ($format == 'aprs') { |
|
| 1919 | + $aprs_connect = 0; |
|
| 1920 | + } |
|
| 1348 | 1921 | $sourceer[$nb] = $globalSources[$nb]; |
| 1349 | 1922 | connect_all($sourceer); |
| 1350 | 1923 | $sourceer = array(); |
@@ -1352,10 +1925,14 @@ discard block |
||
| 1352 | 1925 | } |
| 1353 | 1926 | } |
| 1354 | 1927 | // Sleep for xxx microseconds |
| 1355 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 1928 | + if (isset($globalSBSSleep)) { |
|
| 1929 | + usleep($globalSBSSleep); |
|
| 1930 | + } |
|
| 1356 | 1931 | } else { |
| 1357 | 1932 | if ($format == 'flightgearmp') { |
| 1358 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1933 | + if ($globalDebug) { |
|
| 1934 | + echo "Reconnect FlightGear MP..."; |
|
| 1935 | + } |
|
| 1359 | 1936 | //@socket_close($r); |
| 1360 | 1937 | sleep($globalMinFetch); |
| 1361 | 1938 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1364,10 +1941,15 @@ discard block |
||
| 1364 | 1941 | break; |
| 1365 | 1942 | |
| 1366 | 1943 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1367 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1368 | - else $tt[$format] = 0; |
|
| 1944 | + if (isset($tt[$format])) { |
|
| 1945 | + $tt[$format]++; |
|
| 1946 | + } else { |
|
| 1947 | + $tt[$format] = 0; |
|
| 1948 | + } |
|
| 1369 | 1949 | if ($tt[$format] > 30) { |
| 1370 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 1950 | + if ($globalDebug) { |
|
| 1951 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 1952 | + } |
|
| 1371 | 1953 | //@socket_close($r); |
| 1372 | 1954 | sleep(2); |
| 1373 | 1955 | $aprs_connect = 0; |
@@ -1384,11 +1966,17 @@ discard block |
||
| 1384 | 1966 | } else { |
| 1385 | 1967 | $error = socket_strerror(socket_last_error()); |
| 1386 | 1968 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1387 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1388 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 1969 | + if ($globalDebug) { |
|
| 1970 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1971 | + } |
|
| 1972 | + if (isset($globalDebug)) { |
|
| 1973 | + echo "Restarting...\n"; |
|
| 1974 | + } |
|
| 1389 | 1975 | // Restart the script if possible |
| 1390 | 1976 | if (is_array($sockets)) { |
| 1391 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1977 | + if ($globalDebug) { |
|
| 1978 | + echo "Shutdown all sockets..."; |
|
| 1979 | + } |
|
| 1392 | 1980 | |
| 1393 | 1981 | foreach ($sockets as $sock) { |
| 1394 | 1982 | @socket_shutdown($sock,2); |
@@ -1396,22 +1984,36 @@ discard block |
||
| 1396 | 1984 | } |
| 1397 | 1985 | |
| 1398 | 1986 | } |
| 1399 | - if ($globalDebug) echo "Waiting..."; |
|
| 1987 | + if ($globalDebug) { |
|
| 1988 | + echo "Waiting..."; |
|
| 1989 | + } |
|
| 1400 | 1990 | sleep(2); |
| 1401 | 1991 | $time = time(); |
| 1402 | 1992 | //connect_all($hosts); |
| 1403 | 1993 | $aprs_connect = 0; |
| 1404 | - if ($reset%5 == 0) sleep(20); |
|
| 1405 | - if ($reset%10 == 0) sleep(100); |
|
| 1406 | - if ($reset%20 == 0) sleep(200); |
|
| 1407 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 1408 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 1994 | + if ($reset%5 == 0) { |
|
| 1995 | + sleep(20); |
|
| 1996 | + } |
|
| 1997 | + if ($reset%10 == 0) { |
|
| 1998 | + sleep(100); |
|
| 1999 | + } |
|
| 2000 | + if ($reset%20 == 0) { |
|
| 2001 | + sleep(200); |
|
| 2002 | + } |
|
| 2003 | + if ($reset > 100) { |
|
| 2004 | + exit('Too many attempts...'); |
|
| 2005 | + } |
|
| 2006 | + if ($globalDebug) { |
|
| 2007 | + echo "Restart all connections..."; |
|
| 2008 | + } |
|
| 1409 | 2009 | connect_all($globalSources); |
| 1410 | 2010 | } |
| 1411 | 2011 | } |
| 1412 | 2012 | } |
| 1413 | 2013 | if ($globalDaemon === false) { |
| 1414 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2014 | + if ($globalDebug) { |
|
| 2015 | + echo 'Check all...'."\n"; |
|
| 2016 | + } |
|
| 1415 | 2017 | $SI->checkAll(); |
| 1416 | 2018 | } |
| 1417 | 2019 | } |