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