@@ -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(); |
@@ -59,22 +63,39 @@ discard block |
||
| 59 | 63 | $globalSources = array(); |
| 60 | 64 | $globalSources[] = array('host' => $options['source']); |
| 61 | 65 | } |
| 62 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 63 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 64 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 65 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 66 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 67 | -else $id_source = 1; |
|
| 66 | +if (isset($options['aprsserverssid'])) { |
|
| 67 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 68 | +} |
|
| 69 | +if (isset($options['aprsserverpass'])) { |
|
| 70 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 71 | +} |
|
| 72 | +if (isset($options['nodaemon'])) { |
|
| 73 | + $globalDaemon = FALSE; |
|
| 74 | +} |
|
| 75 | +if (isset($options['server'])) { |
|
| 76 | + $globalServer = TRUE; |
|
| 77 | +} |
|
| 78 | +if (isset($options['idsource'])) { |
|
| 79 | + $id_source = $options['idsource']; |
|
| 80 | +} else { |
|
| 81 | + $id_source = 1; |
|
| 82 | +} |
|
| 68 | 83 | if (isset($globalServer) && $globalServer) { |
| 69 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 84 | + if ($globalDebug) { |
|
| 85 | + echo "Using Server Mode\n"; |
|
| 86 | + } |
|
| 70 | 87 | $SI=new SpotterServer(); |
| 71 | 88 | /* |
| 72 | 89 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 73 | 90 | $SI = new adsb2aprs(); |
| 74 | 91 | $SI->connect(); |
| 75 | 92 | */ |
| 76 | -} else $SI=new SpotterImport($Connection->db); |
|
| 77 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 93 | +} else { |
|
| 94 | + $SI=new SpotterImport($Connection->db); |
|
| 95 | +} |
|
| 96 | +if (isset($globalTracker) && $globalTracker) { |
|
| 97 | + $TI = new TrackerImport($Connection->db); |
|
| 98 | +} |
|
| 78 | 99 | if (isset($globalMarine) && $globalMarine) { |
| 79 | 100 | $AIS = new AIS(); |
| 80 | 101 | $MI = new MarineImport($Connection->db); |
@@ -96,7 +117,9 @@ discard block |
||
| 96 | 117 | } |
| 97 | 118 | |
| 98 | 119 | // let's try and connect |
| 99 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 120 | +if ($globalDebug) { |
|
| 121 | + echo "Connecting...\n"; |
|
| 122 | +} |
|
| 100 | 123 | $use_aprs = false; |
| 101 | 124 | $aprs_full = false; |
| 102 | 125 | $reset = 0; |
@@ -105,7 +128,9 @@ discard block |
||
| 105 | 128 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 106 | 129 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 107 | 130 | $reset++; |
| 108 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 131 | + if ($globalDebug) { |
|
| 132 | + echo 'Connect to all...'."\n"; |
|
| 133 | + } |
|
| 109 | 134 | foreach ($hosts as $id => $value) { |
| 110 | 135 | $host = $value['host']; |
| 111 | 136 | $globalSources[$id]['last_exec'] = 0; |
@@ -115,27 +140,37 @@ discard block |
||
| 115 | 140 | //$formats[$id] = 'deltadbtxt'; |
| 116 | 141 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 117 | 142 | //$last_exec['deltadbtxt'] = 0; |
| 118 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 143 | + if ($globalDebug) { |
|
| 144 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 145 | + } |
|
| 119 | 146 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 120 | 147 | //$formats[$id] = 'vatsimtxt'; |
| 121 | 148 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 122 | 149 | //$last_exec['vatsimtxt'] = 0; |
| 123 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 150 | + if ($globalDebug) { |
|
| 151 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 152 | + } |
|
| 124 | 153 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 125 | 154 | //$formats[$id] = 'aircraftlistjson'; |
| 126 | 155 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 127 | 156 | //$last_exec['aircraftlistjson'] = 0; |
| 128 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 157 | + if ($globalDebug) { |
|
| 158 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 159 | + } |
|
| 129 | 160 | } else if (preg_match('/opensky/i',$host)) { |
| 130 | 161 | //$formats[$id] = 'aircraftlistjson'; |
| 131 | 162 | $globalSources[$id]['format'] = 'opensky'; |
| 132 | 163 | //$last_exec['aircraftlistjson'] = 0; |
| 133 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 164 | + if ($globalDebug) { |
|
| 165 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 166 | + } |
|
| 134 | 167 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
| 135 | 168 | //$formats[$id] = 'radarvirtueljson'; |
| 136 | 169 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 137 | 170 | //$last_exec['radarvirtueljson'] = 0; |
| 138 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 171 | + if ($globalDebug) { |
|
| 172 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 173 | + } |
|
| 139 | 174 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 140 | 175 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 141 | 176 | exit(0); |
@@ -144,7 +179,9 @@ discard block |
||
| 144 | 179 | //$formats[$id] = 'planeupdatefaa'; |
| 145 | 180 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 146 | 181 | //$last_exec['planeupdatefaa'] = 0; |
| 147 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 182 | + if ($globalDebug) { |
|
| 183 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 184 | + } |
|
| 148 | 185 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 149 | 186 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 150 | 187 | exit(0); |
@@ -153,26 +190,36 @@ discard block |
||
| 153 | 190 | //$formats[$id] = 'phpvmacars'; |
| 154 | 191 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 155 | 192 | //$last_exec['phpvmacars'] = 0; |
| 156 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 193 | + if ($globalDebug) { |
|
| 194 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 195 | + } |
|
| 157 | 196 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 158 | 197 | //$formats[$id] = 'phpvmacars'; |
| 159 | 198 | $globalSources[$id]['format'] = 'vam'; |
| 160 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 199 | + if ($globalDebug) { |
|
| 200 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 201 | + } |
|
| 161 | 202 | } else if (preg_match('/whazzup/i',$host)) { |
| 162 | 203 | //$formats[$id] = 'whazzup'; |
| 163 | 204 | $globalSources[$id]['format'] = 'whazzup'; |
| 164 | 205 | //$last_exec['whazzup'] = 0; |
| 165 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 206 | + if ($globalDebug) { |
|
| 207 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 208 | + } |
|
| 166 | 209 | } else if (preg_match('/recentpireps/i',$host)) { |
| 167 | 210 | //$formats[$id] = 'pirepsjson'; |
| 168 | 211 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 169 | 212 | //$last_exec['pirepsjson'] = 0; |
| 170 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 213 | + if ($globalDebug) { |
|
| 214 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 215 | + } |
|
| 171 | 216 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 172 | 217 | //$formats[$id] = 'fr24json'; |
| 173 | 218 | $globalSources[$id]['format'] = 'fr24json'; |
| 174 | 219 | //$last_exec['fr24json'] = 0; |
| 175 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 220 | + if ($globalDebug) { |
|
| 221 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 222 | + } |
|
| 176 | 223 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 177 | 224 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 178 | 225 | exit(0); |
@@ -181,7 +228,9 @@ discard block |
||
| 181 | 228 | //$formats[$id] = 'fr24json'; |
| 182 | 229 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 183 | 230 | //$last_exec['fr24json'] = 0; |
| 184 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 231 | + if ($globalDebug) { |
|
| 232 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 233 | + } |
|
| 185 | 234 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 186 | 235 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 187 | 236 | exit(0); |
@@ -190,17 +239,24 @@ discard block |
||
| 190 | 239 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 191 | 240 | //$formats[$id] = 'tsv'; |
| 192 | 241 | $globalSources[$id]['format'] = 'tsv'; |
| 193 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 242 | + if ($globalDebug) { |
|
| 243 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 244 | + } |
|
| 194 | 245 | } |
| 195 | 246 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 196 | 247 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 197 | 248 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 198 | 249 | if ($idf !== false) { |
| 199 | 250 | $httpfeeds[$id] = $idf; |
| 200 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 251 | + if ($globalDebug) { |
|
| 252 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 253 | + } |
|
| 254 | + } elseif ($globalDebug) { |
|
| 255 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 201 | 256 | } |
| 202 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 203 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 257 | + } elseif ($globalDebug) { |
|
| 258 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 259 | + } |
|
| 204 | 260 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 205 | 261 | $hostport = explode(':',$host); |
| 206 | 262 | if (isset($hostport[1])) { |
@@ -240,17 +296,25 @@ discard block |
||
| 240 | 296 | //$formats[$id] = 'beast'; |
| 241 | 297 | $globalSources[$id]['format'] = 'beast'; |
| 242 | 298 | //} else $formats[$id] = 'sbs'; |
| 243 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 299 | + } else { |
|
| 300 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 301 | + } |
|
| 244 | 302 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 245 | 303 | } |
| 246 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 304 | + if ($globalDebug) { |
|
| 305 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 306 | + } |
|
| 247 | 307 | } else { |
| 248 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 308 | + if ($globalDebug) { |
|
| 309 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 310 | + } |
|
| 249 | 311 | } |
| 250 | 312 | } |
| 251 | 313 | } |
| 252 | 314 | } |
| 253 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 315 | +if (!isset($globalMinFetch)) { |
|
| 316 | + $globalMinFetch = 15; |
|
| 317 | +} |
|
| 254 | 318 | |
| 255 | 319 | // Initialize all |
| 256 | 320 | $status = array(); |
@@ -259,13 +323,19 @@ discard block |
||
| 259 | 323 | $formats = array(); |
| 260 | 324 | $last_exec = array(); |
| 261 | 325 | $time = time(); |
| 262 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 263 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 264 | -else $timeout = 20; |
|
| 326 | +if (isset($globalSourcesTimeout)) { |
|
| 327 | + $timeout = $globalSourcesTimeOut; |
|
| 328 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 329 | + $timeout = $globalSBS1TimeOut; |
|
| 330 | +} else { |
|
| 331 | + $timeout = 20; |
|
| 332 | +} |
|
| 265 | 333 | $errno = ''; |
| 266 | 334 | $errstr=''; |
| 267 | 335 | |
| 268 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 336 | +if (!isset($globalDaemon)) { |
|
| 337 | + $globalDaemon = TRUE; |
|
| 338 | +} |
|
| 269 | 339 | /* Initiate connections to all the hosts simultaneously */ |
| 270 | 340 | //connect_all($hosts); |
| 271 | 341 | //connect_all($globalSources); |
@@ -291,7 +361,9 @@ discard block |
||
| 291 | 361 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 292 | 362 | $aprs_connect = 0; |
| 293 | 363 | $use_aprs = true; |
| 294 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 364 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 365 | + $aprs_full = true; |
|
| 366 | + } |
|
| 295 | 367 | break; |
| 296 | 368 | } |
| 297 | 369 | } |
@@ -302,25 +374,48 @@ discard block |
||
| 302 | 374 | $aprs_connect = 0; |
| 303 | 375 | $aprs_keep = 120; |
| 304 | 376 | $aprs_last_tx = time(); |
| 305 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 306 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 307 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 308 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 309 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 310 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 311 | - if ($aprs_full) $aprs_filter = ''; |
|
| 312 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 313 | - else $aprs_pass = '-1'; |
|
| 377 | + if (isset($globalAPRSversion)) { |
|
| 378 | + $aprs_version = $globalAPRSversion; |
|
| 379 | + } else { |
|
| 380 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 381 | + } |
|
| 382 | + if (isset($globalAPRSssid)) { |
|
| 383 | + $aprs_ssid = $globalAPRSssid; |
|
| 384 | + } else { |
|
| 385 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 386 | + } |
|
| 387 | + if (isset($globalAPRSfilter)) { |
|
| 388 | + $aprs_filter = $globalAPRSfilter; |
|
| 389 | + } else { |
|
| 390 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 391 | + } |
|
| 392 | + if ($aprs_full) { |
|
| 393 | + $aprs_filter = ''; |
|
| 394 | + } |
|
| 395 | + if (isset($globalAPRSpass)) { |
|
| 396 | + $aprs_pass = $globalAPRSpass; |
|
| 397 | + } else { |
|
| 398 | + $aprs_pass = '-1'; |
|
| 399 | + } |
|
| 314 | 400 | |
| 315 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 316 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 317 | -} |
|
| 401 | + if ($aprs_filter != '') { |
|
| 402 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 403 | + } else { |
|
| 404 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 405 | + } |
|
| 406 | + } |
|
| 318 | 407 | |
| 319 | 408 | // connected - lets do some work |
| 320 | -if ($globalDebug) echo "Connected!\n"; |
|
| 409 | +if ($globalDebug) { |
|
| 410 | + echo "Connected!\n"; |
|
| 411 | +} |
|
| 321 | 412 | sleep(1); |
| 322 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 323 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 413 | +if ($globalDebug) { |
|
| 414 | + echo "SCAN MODE \n\n"; |
|
| 415 | +} |
|
| 416 | +if (!isset($globalCronEnd)) { |
|
| 417 | + $globalCronEnd = 60; |
|
| 418 | +} |
|
| 324 | 419 | $endtime = time()+$globalCronEnd; |
| 325 | 420 | $i = 1; |
| 326 | 421 | $tt = array(); |
@@ -334,10 +429,14 @@ discard block |
||
| 334 | 429 | |
| 335 | 430 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 336 | 431 | while ($i > 0) { |
| 337 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 432 | + if (!$globalDaemon) { |
|
| 433 | + $i = $endtime-time(); |
|
| 434 | + } |
|
| 338 | 435 | // Delete old ATC |
| 339 | 436 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 340 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 437 | + if ($globalDebug) { |
|
| 438 | + echo 'Delete old ATC...'."\n"; |
|
| 439 | + } |
|
| 341 | 440 | $ATC->deleteOldATC(); |
| 342 | 441 | } |
| 343 | 442 | |
@@ -345,10 +444,14 @@ discard block |
||
| 345 | 444 | if (count($last_exec) == count($globalSources)) { |
| 346 | 445 | $max = $globalMinFetch; |
| 347 | 446 | foreach ($last_exec as $last) { |
| 348 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 447 | + if ((time() - $last['last']) < $max) { |
|
| 448 | + $max = time() - $last['last']; |
|
| 449 | + } |
|
| 349 | 450 | } |
| 350 | 451 | if ($max != $globalMinFetch) { |
| 351 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 452 | + if ($globalDebug) { |
|
| 453 | + echo 'Sleeping...'."\n"; |
|
| 454 | + } |
|
| 352 | 455 | sleep($globalMinFetch-$max+2); |
| 353 | 456 | } |
| 354 | 457 | } |
@@ -357,11 +460,15 @@ discard block |
||
| 357 | 460 | //foreach ($formats as $id => $value) { |
| 358 | 461 | foreach ($globalSources as $id => $value) { |
| 359 | 462 | date_default_timezone_set('UTC'); |
| 360 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 463 | + if (!isset($last_exec[$id]['last'])) { |
|
| 464 | + $last_exec[$id]['last'] = 0; |
|
| 465 | + } |
|
| 361 | 466 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 362 | 467 | //$buffer = $Common->getData($hosts[$id]); |
| 363 | 468 | $buffer = $Common->getData($value['host']); |
| 364 | - if ($buffer != '') $reset = 0; |
|
| 469 | + if ($buffer != '') { |
|
| 470 | + $reset = 0; |
|
| 471 | + } |
|
| 365 | 472 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 366 | 473 | $buffer = explode('\n',$buffer); |
| 367 | 474 | foreach ($buffer as $line) { |
@@ -370,19 +477,38 @@ discard block |
||
| 370 | 477 | $data = array(); |
| 371 | 478 | $data['hex'] = $line[1]; // hex |
| 372 | 479 | $data['ident'] = $line[2]; // ident |
| 373 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 374 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 375 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 376 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 377 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 480 | + if (isset($line[3])) { |
|
| 481 | + $data['altitude'] = $line[3]; |
|
| 482 | + } |
|
| 483 | + // altitude |
|
| 484 | + if (isset($line[4])) { |
|
| 485 | + $data['speed'] = $line[4]; |
|
| 486 | + } |
|
| 487 | + // speed |
|
| 488 | + if (isset($line[5])) { |
|
| 489 | + $data['heading'] = $line[5]; |
|
| 490 | + } |
|
| 491 | + // heading |
|
| 492 | + if (isset($line[6])) { |
|
| 493 | + $data['latitude'] = $line[6]; |
|
| 494 | + } |
|
| 495 | + // lat |
|
| 496 | + if (isset($line[7])) { |
|
| 497 | + $data['longitude'] = $line[7]; |
|
| 498 | + } |
|
| 499 | + // long |
|
| 378 | 500 | $data['verticalrate'] = ''; // vertical rate |
| 379 | 501 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 380 | 502 | $data['emergency'] = ''; // emergency |
| 381 | 503 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 382 | 504 | $data['format_source'] = 'deltadbtxt'; |
| 383 | 505 | $data['id_source'] = $id_source; |
| 384 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 385 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 506 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 507 | + $data['source_name'] = $value['name']; |
|
| 508 | + } |
|
| 509 | + if (isset($value['sourcestats'])) { |
|
| 510 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 511 | + } |
|
| 386 | 512 | $SI->add($data); |
| 387 | 513 | unset($data); |
| 388 | 514 | } |
@@ -392,7 +518,9 @@ discard block |
||
| 392 | 518 | date_default_timezone_set('CET'); |
| 393 | 519 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 394 | 520 | date_default_timezone_set('UTC'); |
| 395 | - if ($buffer != '') $reset = 0; |
|
| 521 | + if ($buffer != '') { |
|
| 522 | + $reset = 0; |
|
| 523 | + } |
|
| 396 | 524 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 397 | 525 | $buffer = explode('\n',$buffer); |
| 398 | 526 | foreach ($buffer as $line) { |
@@ -401,16 +529,36 @@ discard block |
||
| 401 | 529 | $add = false; |
| 402 | 530 | $ais_data = $AIS->parse_line(trim($line)); |
| 403 | 531 | $data = array(); |
| 404 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 405 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 406 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 407 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 408 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 409 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 410 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 411 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 412 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 413 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 532 | + if (isset($ais_data['ident'])) { |
|
| 533 | + $data['ident'] = $ais_data['ident']; |
|
| 534 | + } |
|
| 535 | + if (isset($ais_data['mmsi'])) { |
|
| 536 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 537 | + } |
|
| 538 | + if (isset($ais_data['speed'])) { |
|
| 539 | + $data['speed'] = $ais_data['speed']; |
|
| 540 | + } |
|
| 541 | + if (isset($ais_data['heading'])) { |
|
| 542 | + $data['heading'] = $ais_data['heading']; |
|
| 543 | + } |
|
| 544 | + if (isset($ais_data['latitude'])) { |
|
| 545 | + $data['latitude'] = $ais_data['latitude']; |
|
| 546 | + } |
|
| 547 | + if (isset($ais_data['longitude'])) { |
|
| 548 | + $data['longitude'] = $ais_data['longitude']; |
|
| 549 | + } |
|
| 550 | + if (isset($ais_data['status'])) { |
|
| 551 | + $data['status'] = $ais_data['status']; |
|
| 552 | + } |
|
| 553 | + if (isset($ais_data['type'])) { |
|
| 554 | + $data['type'] = $ais_data['type']; |
|
| 555 | + } |
|
| 556 | + if (isset($ais_data['imo'])) { |
|
| 557 | + $data['imo'] = $ais_data['imo']; |
|
| 558 | + } |
|
| 559 | + if (isset($ais_data['callsign'])) { |
|
| 560 | + $data['callsign'] = $ais_data['callsign']; |
|
| 561 | + } |
|
| 414 | 562 | if (isset($ais_data['timestamp'])) { |
| 415 | 563 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 416 | 564 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -425,7 +573,9 @@ discard block |
||
| 425 | 573 | $data['id_source'] = $id_source; |
| 426 | 574 | print_r($data); |
| 427 | 575 | echo 'Add...'."\n"; |
| 428 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 576 | + if ($add && $ais_data['mmsi_type'] == 'Ship') { |
|
| 577 | + $MI->add($data); |
|
| 578 | + } |
|
| 429 | 579 | unset($data); |
| 430 | 580 | } |
| 431 | 581 | } |
@@ -445,18 +595,42 @@ discard block |
||
| 445 | 595 | if ($line != '') { |
| 446 | 596 | $ais_data = $AIS->parse_line(trim($line)); |
| 447 | 597 | $data = array(); |
| 448 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 449 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 450 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 451 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 452 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 453 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 454 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 455 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 456 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 457 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 458 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 459 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 598 | + if (isset($ais_data['ident'])) { |
|
| 599 | + $data['ident'] = $ais_data['ident']; |
|
| 600 | + } |
|
| 601 | + if (isset($ais_data['mmsi'])) { |
|
| 602 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 603 | + } |
|
| 604 | + if (isset($ais_data['speed'])) { |
|
| 605 | + $data['speed'] = $ais_data['speed']; |
|
| 606 | + } |
|
| 607 | + if (isset($ais_data['heading'])) { |
|
| 608 | + $data['heading'] = $ais_data['heading']; |
|
| 609 | + } |
|
| 610 | + if (isset($ais_data['latitude'])) { |
|
| 611 | + $data['latitude'] = $ais_data['latitude']; |
|
| 612 | + } |
|
| 613 | + if (isset($ais_data['longitude'])) { |
|
| 614 | + $data['longitude'] = $ais_data['longitude']; |
|
| 615 | + } |
|
| 616 | + if (isset($ais_data['status'])) { |
|
| 617 | + $data['status'] = $ais_data['status']; |
|
| 618 | + } |
|
| 619 | + if (isset($ais_data['type'])) { |
|
| 620 | + $data['type'] = $ais_data['type']; |
|
| 621 | + } |
|
| 622 | + if (isset($ais_data['imo'])) { |
|
| 623 | + $data['imo'] = $ais_data['imo']; |
|
| 624 | + } |
|
| 625 | + if (isset($ais_data['callsign'])) { |
|
| 626 | + $data['callsign'] = $ais_data['callsign']; |
|
| 627 | + } |
|
| 628 | + if (isset($ais_data['destination'])) { |
|
| 629 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 630 | + } |
|
| 631 | + if (isset($ais_data['eta_ts'])) { |
|
| 632 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 633 | + } |
|
| 460 | 634 | if (isset($ais_data['timestamp'])) { |
| 461 | 635 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 462 | 636 | } else { |
@@ -464,7 +638,9 @@ discard block |
||
| 464 | 638 | } |
| 465 | 639 | $data['format_source'] = 'aisnmeahttp'; |
| 466 | 640 | $data['id_source'] = $id_source; |
| 467 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 641 | + if ($ais_data['mmsi_type'] == 'Ship') { |
|
| 642 | + $MI->add($data); |
|
| 643 | + } |
|
| 468 | 644 | unset($data); |
| 469 | 645 | } |
| 470 | 646 | } |
@@ -513,7 +689,9 @@ discard block |
||
| 513 | 689 | $data['callsign'] = $line['callsign']; |
| 514 | 690 | $data['mmsi'] = $line['mmsi']; |
| 515 | 691 | $data['speed'] = $line['sog']; |
| 516 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 692 | + if ($line['heading'] != '511') { |
|
| 693 | + $data['heading'] = $line['heading']; |
|
| 694 | + } |
|
| 517 | 695 | $data['latitude'] = $line['latitude']; |
| 518 | 696 | $data['longitude'] = $line['longitude']; |
| 519 | 697 | $data['type_id'] = $line['shiptype']; |
@@ -533,7 +711,9 @@ discard block |
||
| 533 | 711 | echo 'download...'; |
| 534 | 712 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 535 | 713 | echo 'done !'."\n"; |
| 536 | - if ($buffer != '') $reset = 0; |
|
| 714 | + if ($buffer != '') { |
|
| 715 | + $reset = 0; |
|
| 716 | + } |
|
| 537 | 717 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 538 | 718 | $buffer = explode('\n',$buffer); |
| 539 | 719 | foreach ($buffer as $line) { |
@@ -577,16 +757,28 @@ discard block |
||
| 577 | 757 | $line = explode(':', $line); |
| 578 | 758 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 579 | 759 | $data = array(); |
| 580 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 581 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 760 | + if (isset($line[37]) && $line[37] != '') { |
|
| 761 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 762 | + } else { |
|
| 763 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 764 | + } |
|
| 582 | 765 | $data['pilot_id'] = $line[1]; |
| 583 | 766 | $data['pilot_name'] = $line[2]; |
| 584 | 767 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 585 | 768 | $data['ident'] = $line[0]; // ident |
| 586 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 769 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 770 | + $data['altitude'] = $line[7]; |
|
| 771 | + } |
|
| 772 | + // altitude |
|
| 587 | 773 | $data['speed'] = $line[8]; // speed |
| 588 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 589 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 774 | + if (isset($line[45])) { |
|
| 775 | + $data['heading'] = $line[45]; |
|
| 776 | + } |
|
| 777 | + // heading |
|
| 778 | + elseif (isset($line[38])) { |
|
| 779 | + $data['heading'] = $line[38]; |
|
| 780 | + } |
|
| 781 | + // heading |
|
| 590 | 782 | $data['latitude'] = $line[5]; // lat |
| 591 | 783 | $data['longitude'] = $line[6]; // long |
| 592 | 784 | $data['verticalrate'] = ''; // vertical rate |
@@ -602,7 +794,9 @@ discard block |
||
| 602 | 794 | $data['frequency'] = $line[4]; |
| 603 | 795 | $data['type'] = $line[18]; |
| 604 | 796 | $data['range'] = $line[19]; |
| 605 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 797 | + if (isset($line[35])) { |
|
| 798 | + $data['info'] = $line[35]; |
|
| 799 | + } |
|
| 606 | 800 | $data['id_source'] = $id_source; |
| 607 | 801 | //$data['arrival_airport_time'] = ; |
| 608 | 802 | if ($line[9] != '') { |
@@ -616,24 +810,41 @@ discard block |
||
| 616 | 810 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 617 | 811 | */ |
| 618 | 812 | $data['format_source'] = $value['format']; |
| 619 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 620 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 621 | - elseif ($line[3] == 'ATC') { |
|
| 813 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 814 | + $data['source_name'] = $value['name']; |
|
| 815 | + } |
|
| 816 | + if ($line[3] == 'PILOT') { |
|
| 817 | + $SI->add($data); |
|
| 818 | + } elseif ($line[3] == 'ATC') { |
|
| 622 | 819 | //print_r($data); |
| 623 | 820 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 624 | 821 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 625 | 822 | $typec = substr($data['ident'],-3); |
| 626 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 627 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 628 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 629 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 630 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 631 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 632 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 633 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 634 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 635 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 636 | - 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']); |
|
| 823 | + if ($typec == 'APP') { |
|
| 824 | + $data['type'] = 'Approach'; |
|
| 825 | + } elseif ($typec == 'TWR') { |
|
| 826 | + $data['type'] = 'Tower'; |
|
| 827 | + } elseif ($typec == 'OBS') { |
|
| 828 | + $data['type'] = 'Observer'; |
|
| 829 | + } elseif ($typec == 'GND') { |
|
| 830 | + $data['type'] = 'Ground'; |
|
| 831 | + } elseif ($typec == 'DEL') { |
|
| 832 | + $data['type'] = 'Delivery'; |
|
| 833 | + } elseif ($typec == 'DEP') { |
|
| 834 | + $data['type'] = 'Departure'; |
|
| 835 | + } elseif ($typec == 'FSS') { |
|
| 836 | + $data['type'] = 'Flight Service Station'; |
|
| 837 | + } elseif ($typec == 'CTR') { |
|
| 838 | + $data['type'] = 'Control Radar or Centre'; |
|
| 839 | + } elseif ($data['type'] == '') { |
|
| 840 | + $data['type'] = 'Observer'; |
|
| 841 | + } |
|
| 842 | + if (!isset($data['source_name'])) { |
|
| 843 | + $data['source_name'] = ''; |
|
| 844 | + } |
|
| 845 | + if (isset($ATC)) { |
|
| 846 | + 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']); |
|
| 847 | + } |
|
| 637 | 848 | } |
| 638 | 849 | unset($data); |
| 639 | 850 | } |
@@ -652,26 +863,55 @@ discard block |
||
| 652 | 863 | foreach ($all_data['acList'] as $line) { |
| 653 | 864 | $data = array(); |
| 654 | 865 | $data['hex'] = $line['Icao']; // hex |
| 655 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 656 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 657 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 658 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 659 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 660 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 866 | + if (isset($line['Call'])) { |
|
| 867 | + $data['ident'] = $line['Call']; |
|
| 868 | + } |
|
| 869 | + // ident |
|
| 870 | + if (isset($line['Alt'])) { |
|
| 871 | + $data['altitude'] = $line['Alt']; |
|
| 872 | + } |
|
| 873 | + // altitude |
|
| 874 | + if (isset($line['Spd'])) { |
|
| 875 | + $data['speed'] = $line['Spd']; |
|
| 876 | + } |
|
| 877 | + // speed |
|
| 878 | + if (isset($line['Trak'])) { |
|
| 879 | + $data['heading'] = $line['Trak']; |
|
| 880 | + } |
|
| 881 | + // heading |
|
| 882 | + if (isset($line['Lat'])) { |
|
| 883 | + $data['latitude'] = $line['Lat']; |
|
| 884 | + } |
|
| 885 | + // lat |
|
| 886 | + if (isset($line['Long'])) { |
|
| 887 | + $data['longitude'] = $line['Long']; |
|
| 888 | + } |
|
| 889 | + // long |
|
| 661 | 890 | //$data['verticalrate'] = $line['']; // verticale rate |
| 662 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 891 | + if (isset($line['Sqk'])) { |
|
| 892 | + $data['squawk'] = $line['Sqk']; |
|
| 893 | + } |
|
| 894 | + // squawk |
|
| 663 | 895 | $data['emergency'] = ''; // emergency |
| 664 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 896 | + if (isset($line['Reg'])) { |
|
| 897 | + $data['registration'] = $line['Reg']; |
|
| 898 | + } |
|
| 665 | 899 | /* |
| 666 | 900 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 667 | 901 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 668 | 902 | */ |
| 669 | 903 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 670 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 904 | + if (isset($line['Type'])) { |
|
| 905 | + $data['aircraft_icao'] = $line['Type']; |
|
| 906 | + } |
|
| 671 | 907 | $data['format_source'] = 'aircraftlistjson'; |
| 672 | 908 | $data['id_source'] = $id_source; |
| 673 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 674 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 909 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 910 | + $data['source_name'] = $value['name']; |
|
| 911 | + } |
|
| 912 | + if (isset($data['latitude'])) { |
|
| 913 | + $SI->add($data); |
|
| 914 | + } |
|
| 675 | 915 | unset($data); |
| 676 | 916 | } |
| 677 | 917 | } elseif (is_array($all_data)) { |
@@ -691,7 +931,9 @@ discard block |
||
| 691 | 931 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 692 | 932 | $data['format_source'] = 'aircraftlistjson'; |
| 693 | 933 | $data['id_source'] = $id_source; |
| 694 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 934 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 935 | + $data['source_name'] = $value['name']; |
|
| 936 | + } |
|
| 695 | 937 | $SI->add($data); |
| 696 | 938 | unset($data); |
| 697 | 939 | } |
@@ -727,7 +969,9 @@ discard block |
||
| 727 | 969 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 728 | 970 | $data['format_source'] = 'planeupdatefaa'; |
| 729 | 971 | $data['id_source'] = $id_source; |
| 730 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 972 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 973 | + $data['source_name'] = $value['name']; |
|
| 974 | + } |
|
| 731 | 975 | $SI->add($data); |
| 732 | 976 | unset($data); |
| 733 | 977 | } |
@@ -767,7 +1011,9 @@ discard block |
||
| 767 | 1011 | //$buffer = $Common->getData($hosts[$id]); |
| 768 | 1012 | $buffer = $Common->getData($value['host']); |
| 769 | 1013 | $all_data = json_decode($buffer,true); |
| 770 | - if (!empty($all_data)) $reset = 0; |
|
| 1014 | + if (!empty($all_data)) { |
|
| 1015 | + $reset = 0; |
|
| 1016 | + } |
|
| 771 | 1017 | foreach ($all_data as $key => $line) { |
| 772 | 1018 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 773 | 1019 | $data = array(); |
@@ -788,7 +1034,9 @@ discard block |
||
| 788 | 1034 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 789 | 1035 | $data['format_source'] = 'fr24json'; |
| 790 | 1036 | $data['id_source'] = $id_source; |
| 791 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1037 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1038 | + $data['source_name'] = $value['name']; |
|
| 1039 | + } |
|
| 792 | 1040 | $SI->add($data); |
| 793 | 1041 | unset($data); |
| 794 | 1042 | } |
@@ -812,23 +1060,39 @@ discard block |
||
| 812 | 1060 | if (isset($line['inf'])) { |
| 813 | 1061 | $data = array(); |
| 814 | 1062 | $data['hex'] = $line['inf']['ia']; |
| 815 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1063 | + if (isset($line['inf']['cs'])) { |
|
| 1064 | + $data['ident'] = $line['inf']['cs']; |
|
| 1065 | + } |
|
| 1066 | + //$line[13] |
|
| 816 | 1067 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 817 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 818 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1068 | + if (isset($line['inf']['gs'])) { |
|
| 1069 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1070 | + } |
|
| 1071 | + // speed |
|
| 1072 | + if (isset($line['inf']['tr'])) { |
|
| 1073 | + $data['heading'] = $line['inf']['tr']; |
|
| 1074 | + } |
|
| 1075 | + // heading |
|
| 819 | 1076 | $data['latitude'] = $line['pt'][0]; // lat |
| 820 | 1077 | $data['longitude'] = $line['pt'][1]; // long |
| 821 | 1078 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 822 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1079 | + if (isset($line['inf']['sq'])) { |
|
| 1080 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1081 | + } |
|
| 1082 | + // squawk |
|
| 823 | 1083 | //$data['aircraft_icao'] = $line[8]; |
| 824 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1084 | + if (isset($line['inf']['rc'])) { |
|
| 1085 | + $data['registration'] = $line['inf']['rc']; |
|
| 1086 | + } |
|
| 825 | 1087 | //$data['departure_airport_iata'] = $line[11]; |
| 826 | 1088 | //$data['arrival_airport_iata'] = $line[12]; |
| 827 | 1089 | //$data['emergency'] = ''; // emergency |
| 828 | 1090 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 829 | 1091 | $data['format_source'] = 'radarvirtueljson'; |
| 830 | 1092 | $data['id_source'] = $id_source; |
| 831 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1093 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1094 | + $data['source_name'] = $value['name']; |
|
| 1095 | + } |
|
| 832 | 1096 | $SI->add($data); |
| 833 | 1097 | unset($data); |
| 834 | 1098 | } |
@@ -849,29 +1113,62 @@ discard block |
||
| 849 | 1113 | $data['id'] = $line['id']; |
| 850 | 1114 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 851 | 1115 | $data['ident'] = $line['callsign']; // ident |
| 852 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 853 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 854 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 855 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 856 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 857 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1116 | + if (isset($line['pilotid'])) { |
|
| 1117 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1118 | + } |
|
| 1119 | + // pilot id |
|
| 1120 | + if (isset($line['name'])) { |
|
| 1121 | + $data['pilot_name'] = $line['name']; |
|
| 1122 | + } |
|
| 1123 | + // pilot name |
|
| 1124 | + if (isset($line['alt'])) { |
|
| 1125 | + $data['altitude'] = $line['alt']; |
|
| 1126 | + } |
|
| 1127 | + // altitude |
|
| 1128 | + if (isset($line['gs'])) { |
|
| 1129 | + $data['speed'] = $line['gs']; |
|
| 1130 | + } |
|
| 1131 | + // speed |
|
| 1132 | + if (isset($line['heading'])) { |
|
| 1133 | + $data['heading'] = $line['heading']; |
|
| 1134 | + } |
|
| 1135 | + // heading |
|
| 1136 | + if (isset($line['route'])) { |
|
| 1137 | + $data['waypoints'] = $line['route']; |
|
| 1138 | + } |
|
| 1139 | + // route |
|
| 858 | 1140 | $data['latitude'] = $line['lat']; // lat |
| 859 | 1141 | $data['longitude'] = $line['lon']; // long |
| 860 | 1142 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 861 | 1143 | //$data['squawk'] = $line['squawk']; // squawk |
| 862 | 1144 | //$data['emergency'] = ''; // emergency |
| 863 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 864 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 865 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1145 | + if (isset($line['depicao'])) { |
|
| 1146 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1147 | + } |
|
| 1148 | + if (isset($line['deptime'])) { |
|
| 1149 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1150 | + } |
|
| 1151 | + if (isset($line['arricao'])) { |
|
| 1152 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1153 | + } |
|
| 866 | 1154 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 867 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 868 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 869 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 870 | - else $data['info'] = ''; |
|
| 1155 | + if (isset($line['aircraft'])) { |
|
| 1156 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1157 | + } |
|
| 1158 | + if (isset($line['transponder'])) { |
|
| 1159 | + $data['squawk'] = $line['transponder']; |
|
| 1160 | + } |
|
| 1161 | + if (isset($line['atis'])) { |
|
| 1162 | + $data['info'] = $line['atis']; |
|
| 1163 | + } else { |
|
| 1164 | + $data['info'] = ''; |
|
| 1165 | + } |
|
| 871 | 1166 | $data['format_source'] = 'pireps'; |
| 872 | 1167 | $data['id_source'] = $id_source; |
| 873 | 1168 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 874 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1169 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1170 | + $data['source_name'] = $value['name']; |
|
| 1171 | + } |
|
| 875 | 1172 | if ($line['icon'] == 'plane') { |
| 876 | 1173 | $SI->add($data); |
| 877 | 1174 | // print_r($data); |
@@ -880,16 +1177,28 @@ discard block |
||
| 880 | 1177 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 881 | 1178 | $typec = substr($data['ident'],-3); |
| 882 | 1179 | $data['type'] = ''; |
| 883 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 884 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 885 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 886 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 887 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 888 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 889 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 890 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 891 | - else $data['type'] = 'Observer'; |
|
| 892 | - 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']); |
|
| 1180 | + if ($typec == 'APP') { |
|
| 1181 | + $data['type'] = 'Approach'; |
|
| 1182 | + } elseif ($typec == 'TWR') { |
|
| 1183 | + $data['type'] = 'Tower'; |
|
| 1184 | + } elseif ($typec == 'OBS') { |
|
| 1185 | + $data['type'] = 'Observer'; |
|
| 1186 | + } elseif ($typec == 'GND') { |
|
| 1187 | + $data['type'] = 'Ground'; |
|
| 1188 | + } elseif ($typec == 'DEL') { |
|
| 1189 | + $data['type'] = 'Delivery'; |
|
| 1190 | + } elseif ($typec == 'DEP') { |
|
| 1191 | + $data['type'] = 'Departure'; |
|
| 1192 | + } elseif ($typec == 'FSS') { |
|
| 1193 | + $data['type'] = 'Flight Service Station'; |
|
| 1194 | + } elseif ($typec == 'CTR') { |
|
| 1195 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1196 | + } else { |
|
| 1197 | + $data['type'] = 'Observer'; |
|
| 1198 | + } |
|
| 1199 | + if (isset($ATC)) { |
|
| 1200 | + 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']); |
|
| 1201 | + } |
|
| 893 | 1202 | } |
| 894 | 1203 | unset($data); |
| 895 | 1204 | } |
@@ -899,7 +1208,9 @@ discard block |
||
| 899 | 1208 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 900 | 1209 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 901 | 1210 | //$buffer = $Common->getData($hosts[$id]); |
| 902 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1211 | + if ($globalDebug) { |
|
| 1212 | + echo 'Get Data...'."\n"; |
|
| 1213 | + } |
|
| 903 | 1214 | $buffer = $Common->getData($value['host']); |
| 904 | 1215 | $all_data = json_decode($buffer,true); |
| 905 | 1216 | if ($buffer != '' && is_array($all_data)) { |
@@ -907,10 +1218,16 @@ discard block |
||
| 907 | 1218 | foreach ($all_data as $line) { |
| 908 | 1219 | $data = array(); |
| 909 | 1220 | //$data['id'] = $line['id']; // id not usable |
| 910 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1221 | + if (isset($line['pilotid'])) { |
|
| 1222 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1223 | + } |
|
| 911 | 1224 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 912 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 913 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1225 | + if (isset($line['pilotname'])) { |
|
| 1226 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1227 | + } |
|
| 1228 | + if (isset($line['pilotid'])) { |
|
| 1229 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1230 | + } |
|
| 914 | 1231 | $data['ident'] = $line['flightnum']; // ident |
| 915 | 1232 | $data['altitude'] = $line['alt']; // altitude |
| 916 | 1233 | $data['speed'] = $line['gs']; // speed |
@@ -928,27 +1245,41 @@ discard block |
||
| 928 | 1245 | $data['arrival_airport_icao'] = $line['arricao']; |
| 929 | 1246 | $data['arrival_airport_time'] = $line['arrtime']; |
| 930 | 1247 | $data['registration'] = $line['aircraft']; |
| 931 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1248 | + if (isset($line['route'])) { |
|
| 1249 | + $data['waypoints'] = $line['route']; |
|
| 1250 | + } |
|
| 1251 | + // route |
|
| 932 | 1252 | if (isset($line['aircraftname'])) { |
| 933 | 1253 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 934 | 1254 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 935 | 1255 | $aircraft_data = explode('-',$line['aircraftname']); |
| 936 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 937 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 938 | - else { |
|
| 1256 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1257 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1258 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1259 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1260 | + } else { |
|
| 939 | 1261 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 940 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 941 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1262 | + if (isset($aircraft_data[1])) { |
|
| 1263 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1264 | + } else { |
|
| 1265 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1266 | + } |
|
| 942 | 1267 | } |
| 943 | 1268 | } |
| 944 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1269 | + if (isset($line['route'])) { |
|
| 1270 | + $data['waypoints'] = $line['route']; |
|
| 1271 | + } |
|
| 945 | 1272 | $data['id_source'] = $id_source; |
| 946 | 1273 | $data['format_source'] = 'phpvmacars'; |
| 947 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1274 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1275 | + $data['source_name'] = $value['name']; |
|
| 1276 | + } |
|
| 948 | 1277 | $SI->add($data); |
| 949 | 1278 | unset($data); |
| 950 | 1279 | } |
| 951 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1280 | + if ($globalDebug) { |
|
| 1281 | + echo 'No more data...'."\n"; |
|
| 1282 | + } |
|
| 952 | 1283 | unset($buffer); |
| 953 | 1284 | unset($all_data); |
| 954 | 1285 | } |
@@ -956,7 +1287,9 @@ discard block |
||
| 956 | 1287 | $last_exec[$id]['last'] = time(); |
| 957 | 1288 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 958 | 1289 | //$buffer = $Common->getData($hosts[$id]); |
| 959 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1290 | + if ($globalDebug) { |
|
| 1291 | + echo 'Get Data...'."\n"; |
|
| 1292 | + } |
|
| 960 | 1293 | $buffer = $Common->getData($value['host']); |
| 961 | 1294 | $all_data = json_decode($buffer,true); |
| 962 | 1295 | if ($buffer != '' && is_array($all_data)) { |
@@ -985,15 +1318,22 @@ discard block |
||
| 985 | 1318 | $data['arrival_airport_icao'] = $line['arrival']; |
| 986 | 1319 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 987 | 1320 | //$data['registration'] = $line['aircraft']; |
| 988 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1321 | + if (isset($line['route'])) { |
|
| 1322 | + $data['waypoints'] = $line['route']; |
|
| 1323 | + } |
|
| 1324 | + // route |
|
| 989 | 1325 | $data['aircraft_icao'] = $line['plane_type']; |
| 990 | 1326 | $data['id_source'] = $id_source; |
| 991 | 1327 | $data['format_source'] = 'vam'; |
| 992 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1328 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1329 | + $data['source_name'] = $value['name']; |
|
| 1330 | + } |
|
| 993 | 1331 | $SI->add($data); |
| 994 | 1332 | unset($data); |
| 995 | 1333 | } |
| 996 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1334 | + if ($globalDebug) { |
|
| 1335 | + echo 'No more data...'."\n"; |
|
| 1336 | + } |
|
| 997 | 1337 | unset($buffer); |
| 998 | 1338 | unset($all_data); |
| 999 | 1339 | } |
@@ -1001,7 +1341,9 @@ discard block |
||
| 1001 | 1341 | $last_exec[$id]['last'] = time(); |
| 1002 | 1342 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1003 | 1343 | } 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') { |
| 1004 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1344 | + if (function_exists('pcntl_fork')) { |
|
| 1345 | + pcntl_signal_dispatch(); |
|
| 1346 | + } |
|
| 1005 | 1347 | //$last_exec[$id]['last'] = time(); |
| 1006 | 1348 | |
| 1007 | 1349 | //$read = array( $sockets[$id] ); |
@@ -1009,7 +1351,9 @@ discard block |
||
| 1009 | 1351 | $write = NULL; |
| 1010 | 1352 | $e = NULL; |
| 1011 | 1353 | $n = socket_select($read, $write, $e, $timeout); |
| 1012 | - if ($e != NULL) var_dump($e); |
|
| 1354 | + if ($e != NULL) { |
|
| 1355 | + var_dump($e); |
|
| 1356 | + } |
|
| 1013 | 1357 | if ($n > 0) { |
| 1014 | 1358 | $reset = 0; |
| 1015 | 1359 | foreach ($read as $nb => $r) { |
@@ -1030,12 +1374,16 @@ discard block |
||
| 1030 | 1374 | //$SI::del(); |
| 1031 | 1375 | if ($format == 'vrstcp') { |
| 1032 | 1376 | $buffer = explode('},{',$buffer); |
| 1033 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1377 | + } else { |
|
| 1378 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1379 | + } |
|
| 1034 | 1380 | // SBS format is CSV format |
| 1035 | 1381 | if ($buffer !== FALSE && $buffer != '') { |
| 1036 | 1382 | $tt[$format] = 0; |
| 1037 | 1383 | if ($format == 'acarssbs3') { |
| 1038 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1384 | + if ($globalDebug) { |
|
| 1385 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1386 | + } |
|
| 1039 | 1387 | $ACARS->add(trim($buffer)); |
| 1040 | 1388 | $ACARS->deleteLiveAcarsData(); |
| 1041 | 1389 | } elseif ($format == 'raw') { |
@@ -1044,25 +1392,55 @@ discard block |
||
| 1044 | 1392 | if (is_array($data)) { |
| 1045 | 1393 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1046 | 1394 | $data['format_source'] = 'raw'; |
| 1047 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1048 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1049 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1395 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1396 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1397 | + } |
|
| 1398 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1399 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1400 | + } |
|
| 1401 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1402 | + $SI->add($data); |
|
| 1403 | + } |
|
| 1050 | 1404 | } |
| 1051 | 1405 | } elseif ($format == 'ais') { |
| 1052 | 1406 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1053 | 1407 | $data = array(); |
| 1054 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1055 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1056 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1057 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1058 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1059 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1060 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1061 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1062 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1063 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1064 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1065 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1408 | + if (isset($ais_data['ident'])) { |
|
| 1409 | + $data['ident'] = $ais_data['ident']; |
|
| 1410 | + } |
|
| 1411 | + if (isset($ais_data['mmsi'])) { |
|
| 1412 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 1413 | + } |
|
| 1414 | + if (isset($ais_data['speed'])) { |
|
| 1415 | + $data['speed'] = $ais_data['speed']; |
|
| 1416 | + } |
|
| 1417 | + if (isset($ais_data['heading'])) { |
|
| 1418 | + $data['heading'] = $ais_data['heading']; |
|
| 1419 | + } |
|
| 1420 | + if (isset($ais_data['latitude'])) { |
|
| 1421 | + $data['latitude'] = $ais_data['latitude']; |
|
| 1422 | + } |
|
| 1423 | + if (isset($ais_data['longitude'])) { |
|
| 1424 | + $data['longitude'] = $ais_data['longitude']; |
|
| 1425 | + } |
|
| 1426 | + if (isset($ais_data['status'])) { |
|
| 1427 | + $data['status'] = $ais_data['status']; |
|
| 1428 | + } |
|
| 1429 | + if (isset($ais_data['type'])) { |
|
| 1430 | + $data['type'] = $ais_data['type']; |
|
| 1431 | + } |
|
| 1432 | + if (isset($ais_data['imo'])) { |
|
| 1433 | + $data['imo'] = $ais_data['imo']; |
|
| 1434 | + } |
|
| 1435 | + if (isset($ais_data['callsign'])) { |
|
| 1436 | + $data['callsign'] = $ais_data['callsign']; |
|
| 1437 | + } |
|
| 1438 | + if (isset($ais_data['destination'])) { |
|
| 1439 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 1440 | + } |
|
| 1441 | + if (isset($ais_data['eta_ts'])) { |
|
| 1442 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1443 | + } |
|
| 1066 | 1444 | |
| 1067 | 1445 | if (isset($ais_data['timestamp'])) { |
| 1068 | 1446 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1071,7 +1449,9 @@ discard block |
||
| 1071 | 1449 | } |
| 1072 | 1450 | $data['format_source'] = 'aisnmea'; |
| 1073 | 1451 | $data['id_source'] = $id_source; |
| 1074 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1452 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 1453 | + $MI->add($data); |
|
| 1454 | + } |
|
| 1075 | 1455 | unset($data); |
| 1076 | 1456 | } elseif ($format == 'flightgearsp') { |
| 1077 | 1457 | //echo $buffer."\n"; |
@@ -1089,11 +1469,15 @@ discard block |
||
| 1089 | 1469 | $data['speed'] = round($line[5]*1.94384); |
| 1090 | 1470 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1091 | 1471 | $data['format_source'] = 'flightgearsp'; |
| 1092 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1472 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1473 | + $SI->add($data); |
|
| 1474 | + } |
|
| 1093 | 1475 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1094 | 1476 | } |
| 1095 | 1477 | } elseif ($format == 'acars') { |
| 1096 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1478 | + if ($globalDebug) { |
|
| 1479 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1480 | + } |
|
| 1097 | 1481 | $ACARS->add(trim($buffer)); |
| 1098 | 1482 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1099 | 1483 | $ACARS->deleteLiveAcarsData(); |
@@ -1114,7 +1498,9 @@ discard block |
||
| 1114 | 1498 | $aircraft_type = $line[10]; |
| 1115 | 1499 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1116 | 1500 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1117 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1501 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1502 | + $SI->add($data); |
|
| 1503 | + } |
|
| 1118 | 1504 | } |
| 1119 | 1505 | } |
| 1120 | 1506 | } elseif ($format == 'beast') { |
@@ -1124,27 +1510,59 @@ discard block |
||
| 1124 | 1510 | foreach($buffer as $all_data) { |
| 1125 | 1511 | $line = json_decode('{'.$all_data.'}',true); |
| 1126 | 1512 | $data = array(); |
| 1127 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1128 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1129 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1130 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1131 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1132 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1133 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1513 | + if (isset($line['Icao'])) { |
|
| 1514 | + $data['hex'] = $line['Icao']; |
|
| 1515 | + } |
|
| 1516 | + // hex |
|
| 1517 | + if (isset($line['Call'])) { |
|
| 1518 | + $data['ident'] = $line['Call']; |
|
| 1519 | + } |
|
| 1520 | + // ident |
|
| 1521 | + if (isset($line['Alt'])) { |
|
| 1522 | + $data['altitude'] = $line['Alt']; |
|
| 1523 | + } |
|
| 1524 | + // altitude |
|
| 1525 | + if (isset($line['Spd'])) { |
|
| 1526 | + $data['speed'] = $line['Spd']; |
|
| 1527 | + } |
|
| 1528 | + // speed |
|
| 1529 | + if (isset($line['Trak'])) { |
|
| 1530 | + $data['heading'] = $line['Trak']; |
|
| 1531 | + } |
|
| 1532 | + // heading |
|
| 1533 | + if (isset($line['Lat'])) { |
|
| 1534 | + $data['latitude'] = $line['Lat']; |
|
| 1535 | + } |
|
| 1536 | + // lat |
|
| 1537 | + if (isset($line['Long'])) { |
|
| 1538 | + $data['longitude'] = $line['Long']; |
|
| 1539 | + } |
|
| 1540 | + // long |
|
| 1134 | 1541 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1135 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1542 | + if (isset($line['Sqk'])) { |
|
| 1543 | + $data['squawk'] = $line['Sqk']; |
|
| 1544 | + } |
|
| 1545 | + // squawk |
|
| 1136 | 1546 | $data['emergency'] = ''; // emergency |
| 1137 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1547 | + if (isset($line['Reg'])) { |
|
| 1548 | + $data['registration'] = $line['Reg']; |
|
| 1549 | + } |
|
| 1138 | 1550 | /* |
| 1139 | 1551 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1140 | 1552 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1141 | 1553 | */ |
| 1142 | 1554 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1143 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1555 | + if (isset($line['Type'])) { |
|
| 1556 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1557 | + } |
|
| 1144 | 1558 | $data['format_source'] = 'vrstcp'; |
| 1145 | 1559 | $data['id_source'] = $id_source; |
| 1146 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1147 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 1560 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1561 | + $data['source_name'] = $value['name']; |
|
| 1562 | + } |
|
| 1563 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 1564 | + $SI->add($data); |
|
| 1565 | + } |
|
| 1148 | 1566 | unset($data); |
| 1149 | 1567 | } |
| 1150 | 1568 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1157,21 +1575,43 @@ discard block |
||
| 1157 | 1575 | $data['hex'] = $lined['hexid']; |
| 1158 | 1576 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1159 | 1577 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1160 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1161 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1162 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1163 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1164 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1165 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1166 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1578 | + if (isset($lined['ident'])) { |
|
| 1579 | + $data['ident'] = $lined['ident']; |
|
| 1580 | + } |
|
| 1581 | + if (isset($lined['lat'])) { |
|
| 1582 | + $data['latitude'] = $lined['lat']; |
|
| 1583 | + } |
|
| 1584 | + if (isset($lined['lon'])) { |
|
| 1585 | + $data['longitude'] = $lined['lon']; |
|
| 1586 | + } |
|
| 1587 | + if (isset($lined['speed'])) { |
|
| 1588 | + $data['speed'] = $lined['speed']; |
|
| 1589 | + } |
|
| 1590 | + if (isset($lined['squawk'])) { |
|
| 1591 | + $data['squawk'] = $lined['squawk']; |
|
| 1592 | + } |
|
| 1593 | + if (isset($lined['alt'])) { |
|
| 1594 | + $data['altitude'] = $lined['alt']; |
|
| 1595 | + } |
|
| 1596 | + if (isset($lined['heading'])) { |
|
| 1597 | + $data['heading'] = $lined['heading']; |
|
| 1598 | + } |
|
| 1167 | 1599 | $data['id_source'] = $id_source; |
| 1168 | 1600 | $data['format_source'] = 'tsv'; |
| 1169 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1170 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1171 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1601 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1602 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1603 | + } |
|
| 1604 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1605 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1606 | + } |
|
| 1607 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1608 | + $SI->add($data); |
|
| 1609 | + } |
|
| 1172 | 1610 | unset($lined); |
| 1173 | 1611 | unset($data); |
| 1174 | - } else $error = true; |
|
| 1612 | + } else { |
|
| 1613 | + $error = true; |
|
| 1614 | + } |
|
| 1175 | 1615 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1176 | 1616 | if ($aprs_connect == 0) { |
| 1177 | 1617 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1197,49 +1637,82 @@ discard block |
||
| 1197 | 1637 | $aprs_last_tx = time(); |
| 1198 | 1638 | $data = array(); |
| 1199 | 1639 | //print_r($line); |
| 1200 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1201 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1202 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1640 | + if (isset($line['address'])) { |
|
| 1641 | + $data['hex'] = $line['address']; |
|
| 1642 | + } |
|
| 1643 | + if (isset($line['timestamp'])) { |
|
| 1644 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1645 | + } else { |
|
| 1646 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1647 | + } |
|
| 1203 | 1648 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1204 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1649 | + if (isset($line['ident'])) { |
|
| 1650 | + $data['ident'] = $line['ident']; |
|
| 1651 | + } |
|
| 1205 | 1652 | $data['latitude'] = $line['latitude']; |
| 1206 | 1653 | $data['longitude'] = $line['longitude']; |
| 1207 | 1654 | //$data['verticalrate'] = $line[16]; |
| 1208 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1209 | - else $data['speed'] = 0; |
|
| 1210 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1211 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1212 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1213 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1655 | + if (isset($line['speed'])) { |
|
| 1656 | + $data['speed'] = $line['speed']; |
|
| 1657 | + } else { |
|
| 1658 | + $data['speed'] = 0; |
|
| 1659 | + } |
|
| 1660 | + if (isset($line['altitude'])) { |
|
| 1661 | + $data['altitude'] = $line['altitude']; |
|
| 1662 | + } |
|
| 1663 | + if (isset($line['comment'])) { |
|
| 1664 | + $data['comment'] = $line['comment']; |
|
| 1665 | + } |
|
| 1666 | + if (isset($line['symbol'])) { |
|
| 1667 | + $data['type'] = $line['symbol']; |
|
| 1668 | + } |
|
| 1669 | + if (isset($line['heading'])) { |
|
| 1670 | + $data['heading'] = $line['heading']; |
|
| 1671 | + } |
|
| 1214 | 1672 | //else $data['heading'] = 0; |
| 1215 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1216 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 1673 | + if (isset($line['stealth'])) { |
|
| 1674 | + $data['aircraft_type'] = $line['stealth']; |
|
| 1675 | + } |
|
| 1676 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
| 1677 | + $data['noarchive'] = true; |
|
| 1678 | + } |
|
| 1217 | 1679 | $data['id_source'] = $id_source; |
| 1218 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1219 | - else $data['format_source'] = 'aprs'; |
|
| 1680 | + if (isset($line['format_source'])) { |
|
| 1681 | + $data['format_source'] = $line['format_source']; |
|
| 1682 | + } else { |
|
| 1683 | + $data['format_source'] = 'aprs'; |
|
| 1684 | + } |
|
| 1220 | 1685 | $data['source_name'] = $line['source']; |
| 1221 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1222 | - else $data['source_type'] = 'flarm'; |
|
| 1223 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1686 | + if (isset($line['source_type'])) { |
|
| 1687 | + $data['source_type'] = $line['source_type']; |
|
| 1688 | + } else { |
|
| 1689 | + $data['source_type'] = 'flarm'; |
|
| 1690 | + } |
|
| 1691 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1692 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1693 | + } |
|
| 1224 | 1694 | $currentdate = date('Y-m-d H:i:s'); |
| 1225 | 1695 | $aprsdate = strtotime($data['datetime']); |
| 1226 | 1696 | // Accept data if time <= system time + 20s |
| 1227 | 1697 | if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1228 | 1698 | $send = $SI->add($data); |
| 1229 | 1699 | } elseif (isset($line['stealth'])) { |
| 1230 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1231 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1700 | + if ($line['stealth'] != 0) { |
|
| 1701 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1702 | + } else { |
|
| 1703 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1704 | + } |
|
| 1232 | 1705 | //} 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')) { |
| 1233 | 1706 | } 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') { |
| 1234 | 1707 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1235 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 1708 | + if (isset($globalTracker) && $globalTracker) { |
|
| 1709 | + $send = $TI->add($data); |
|
| 1710 | + } |
|
| 1236 | 1711 | } |
| 1237 | 1712 | unset($data); |
| 1238 | - } |
|
| 1239 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1713 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1240 | 1714 | echo '!! Weather Station not yet supported'."\n"; |
| 1241 | - } |
|
| 1242 | - 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')) { |
|
| 1715 | + } 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')) { |
|
| 1243 | 1716 | echo '!! Car & Trucks not yet supported'."\n"; |
| 1244 | 1717 | } |
| 1245 | 1718 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
@@ -1272,25 +1745,42 @@ discard block |
||
| 1272 | 1745 | $data['ground'] = $line[21]; |
| 1273 | 1746 | $data['emergency'] = $line[19]; |
| 1274 | 1747 | $data['format_source'] = 'sbs'; |
| 1275 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1276 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1748 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1749 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1750 | + } |
|
| 1751 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1752 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1753 | + } |
|
| 1277 | 1754 | $data['id_source'] = $id_source; |
| 1278 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1279 | - else $error = true; |
|
| 1755 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1756 | + $send = $SI->add($data); |
|
| 1757 | + } else { |
|
| 1758 | + $error = true; |
|
| 1759 | + } |
|
| 1280 | 1760 | unset($data); |
| 1281 | - } else $error = true; |
|
| 1761 | + } else { |
|
| 1762 | + $error = true; |
|
| 1763 | + } |
|
| 1282 | 1764 | if ($error) { |
| 1283 | 1765 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1284 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 1766 | + if ($globalDebug) { |
|
| 1767 | + echo "Not a message. Ignoring... \n"; |
|
| 1768 | + } |
|
| 1285 | 1769 | } else { |
| 1286 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 1770 | + if ($globalDebug) { |
|
| 1771 | + echo "Wrong line format. Ignoring... \n"; |
|
| 1772 | + } |
|
| 1287 | 1773 | if ($globalDebug) { |
| 1288 | 1774 | echo $buffer; |
| 1289 | 1775 | print_r($line); |
| 1290 | 1776 | } |
| 1291 | 1777 | //socket_close($r); |
| 1292 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1293 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 1778 | + if ($globalDebug) { |
|
| 1779 | + echo "Reconnect after an error...\n"; |
|
| 1780 | + } |
|
| 1781 | + if ($format == 'aprs') { |
|
| 1782 | + $aprs_connect = 0; |
|
| 1783 | + } |
|
| 1294 | 1784 | $sourceer[$nb] = $globalSources[$nb]; |
| 1295 | 1785 | connect_all($sourceer); |
| 1296 | 1786 | $sourceer = array(); |
@@ -1298,10 +1788,14 @@ discard block |
||
| 1298 | 1788 | } |
| 1299 | 1789 | } |
| 1300 | 1790 | // Sleep for xxx microseconds |
| 1301 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 1791 | + if (isset($globalSBSSleep)) { |
|
| 1792 | + usleep($globalSBSSleep); |
|
| 1793 | + } |
|
| 1302 | 1794 | } else { |
| 1303 | 1795 | if ($format == 'flightgearmp') { |
| 1304 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1796 | + if ($globalDebug) { |
|
| 1797 | + echo "Reconnect FlightGear MP..."; |
|
| 1798 | + } |
|
| 1305 | 1799 | //@socket_close($r); |
| 1306 | 1800 | sleep($globalMinFetch); |
| 1307 | 1801 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1310,10 +1804,15 @@ discard block |
||
| 1310 | 1804 | break; |
| 1311 | 1805 | |
| 1312 | 1806 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1313 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1314 | - else $tt[$format] = 0; |
|
| 1807 | + if (isset($tt[$format])) { |
|
| 1808 | + $tt[$format]++; |
|
| 1809 | + } else { |
|
| 1810 | + $tt[$format] = 0; |
|
| 1811 | + } |
|
| 1315 | 1812 | if ($tt[$format] > 30) { |
| 1316 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 1813 | + if ($globalDebug) { |
|
| 1814 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 1815 | + } |
|
| 1317 | 1816 | //@socket_close($r); |
| 1318 | 1817 | sleep(2); |
| 1319 | 1818 | $aprs_connect = 0; |
@@ -1330,11 +1829,17 @@ discard block |
||
| 1330 | 1829 | } else { |
| 1331 | 1830 | $error = socket_strerror(socket_last_error()); |
| 1332 | 1831 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1333 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1334 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 1832 | + if ($globalDebug) { |
|
| 1833 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1834 | + } |
|
| 1835 | + if (isset($globalDebug)) { |
|
| 1836 | + echo "Restarting...\n"; |
|
| 1837 | + } |
|
| 1335 | 1838 | // Restart the script if possible |
| 1336 | 1839 | if (is_array($sockets)) { |
| 1337 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1840 | + if ($globalDebug) { |
|
| 1841 | + echo "Shutdown all sockets..."; |
|
| 1842 | + } |
|
| 1338 | 1843 | |
| 1339 | 1844 | foreach ($sockets as $sock) { |
| 1340 | 1845 | @socket_shutdown($sock,2); |
@@ -1342,18 +1847,24 @@ discard block |
||
| 1342 | 1847 | } |
| 1343 | 1848 | |
| 1344 | 1849 | } |
| 1345 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 1850 | + if ($globalDebug) { |
|
| 1851 | + echo "Restart all connections..."; |
|
| 1852 | + } |
|
| 1346 | 1853 | sleep(2); |
| 1347 | 1854 | $time = time(); |
| 1348 | 1855 | //connect_all($hosts); |
| 1349 | 1856 | $aprs_connect = 0; |
| 1350 | - if ($reset > 40) exit('Too many attempts...'); |
|
| 1857 | + if ($reset > 40) { |
|
| 1858 | + exit('Too many attempts...'); |
|
| 1859 | + } |
|
| 1351 | 1860 | connect_all($globalSources); |
| 1352 | 1861 | } |
| 1353 | 1862 | } |
| 1354 | 1863 | } |
| 1355 | 1864 | if ($globalDaemon === false) { |
| 1356 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1865 | + if ($globalDebug) { |
|
| 1866 | + echo 'Check all...'."\n"; |
|
| 1867 | + } |
|
| 1357 | 1868 | $SI->checkAll(); |
| 1358 | 1869 | } |
| 1359 | 1870 | } |