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