@@ -14,13 +14,17 @@ discard block |
||
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 17 | +if (isset($globalTracker) && $globalTracker) { |
|
| 18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 19 | +} |
|
| 18 | 20 | if (isset($globalMarine) && $globalMarine) { |
| 19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 25 | +if (!isset($globalDebug)) { |
|
| 26 | + $globalDebug = FALSE; |
|
| 27 | +} |
|
| 24 | 28 | |
| 25 | 29 | // Check if schema is at latest version |
| 26 | 30 | $Connection = new Connection(); |
@@ -59,35 +63,62 @@ discard block |
||
| 59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 60 | 64 | if (isset($options['s'])) { |
| 61 | 65 | $globalSources = array(); |
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['s']); |
|
| 64 | -} elseif (isset($options['source'])) { |
|
| 66 | + if (isset($options['format'])) { |
|
| 67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 68 | + } else { |
|
| 69 | + $globalSources[] = array('host' => $options['s']); |
|
| 70 | + } |
|
| 71 | + } elseif (isset($options['source'])) { |
|
| 65 | 72 | $globalSources = array(); |
| 66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | - else $globalSources[] = array('host' => $options['source']); |
|
| 68 | -} |
|
| 73 | + if (isset($options['format'])) { |
|
| 74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 75 | + } else { |
|
| 76 | + $globalSources[] = array('host' => $options['source']); |
|
| 77 | + } |
|
| 78 | + } |
|
| 69 | 79 | if (isset($options['aprsserverhost'])) { |
| 70 | 80 | $globalServerAPRS = TRUE; |
| 71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
| 72 | 82 | } |
| 73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 77 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 78 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 79 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 80 | -else $id_source = 1; |
|
| 83 | +if (isset($options['aprsserverport'])) { |
|
| 84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 85 | +} |
|
| 86 | +if (isset($options['aprsserverssid'])) { |
|
| 87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 88 | +} |
|
| 89 | +if (isset($options['aprsserverpass'])) { |
|
| 90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 91 | +} |
|
| 92 | +if (isset($options['noaprsserver'])) { |
|
| 93 | + $globalServerAPRS = FALSE; |
|
| 94 | +} |
|
| 95 | +if (isset($options['nodaemon'])) { |
|
| 96 | + $globalDaemon = FALSE; |
|
| 97 | +} |
|
| 98 | +if (isset($options['server'])) { |
|
| 99 | + $globalServer = TRUE; |
|
| 100 | +} |
|
| 101 | +if (isset($options['idsource'])) { |
|
| 102 | + $id_source = $options['idsource']; |
|
| 103 | +} else { |
|
| 104 | + $id_source = 1; |
|
| 105 | +} |
|
| 81 | 106 | if (isset($globalServer) && $globalServer) { |
| 82 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 107 | + if ($globalDebug) { |
|
| 108 | + echo "Using Server Mode\n"; |
|
| 109 | + } |
|
| 83 | 110 | $SI=new SpotterServer(); |
| 84 | 111 | /* |
| 85 | 112 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 86 | 113 | $SI = new adsb2aprs(); |
| 87 | 114 | $SI->connect(); |
| 88 | 115 | */ |
| 89 | -} else $SI=new SpotterImport($Connection->db); |
|
| 90 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 116 | +} else { |
|
| 117 | + $SI=new SpotterImport($Connection->db); |
|
| 118 | +} |
|
| 119 | +if (isset($globalTracker) && $globalTracker) { |
|
| 120 | + $TI = new TrackerImport($Connection->db); |
|
| 121 | +} |
|
| 91 | 122 | if (isset($globalMarine) && $globalMarine) { |
| 92 | 123 | $AIS = new AIS(); |
| 93 | 124 | $MI = new MarineImport($Connection->db); |
@@ -110,7 +141,9 @@ discard block |
||
| 110 | 141 | } |
| 111 | 142 | |
| 112 | 143 | // let's try and connect |
| 113 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 144 | +if ($globalDebug) { |
|
| 145 | + echo "Connecting...\n"; |
|
| 146 | +} |
|
| 114 | 147 | $use_aprs = false; |
| 115 | 148 | $aprs_full = false; |
| 116 | 149 | $reset = 0; |
@@ -119,7 +152,9 @@ discard block |
||
| 119 | 152 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 120 | 153 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 121 | 154 | $reset++; |
| 122 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 155 | + if ($globalDebug) { |
|
| 156 | + echo 'Connect to all...'."\n"; |
|
| 157 | + } |
|
| 123 | 158 | foreach ($hosts as $id => $value) { |
| 124 | 159 | $host = $value['host']; |
| 125 | 160 | $globalSources[$id]['last_exec'] = 0; |
@@ -129,22 +164,30 @@ discard block |
||
| 129 | 164 | //$formats[$id] = 'deltadbtxt'; |
| 130 | 165 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 131 | 166 | //$last_exec['deltadbtxt'] = 0; |
| 132 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 167 | + if ($globalDebug) { |
|
| 168 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 169 | + } |
|
| 133 | 170 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 134 | 171 | //$formats[$id] = 'vatsimtxt'; |
| 135 | 172 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 136 | 173 | //$last_exec['vatsimtxt'] = 0; |
| 137 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 174 | + if ($globalDebug) { |
|
| 175 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 176 | + } |
|
| 138 | 177 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 139 | 178 | //$formats[$id] = 'aircraftlistjson'; |
| 140 | 179 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 141 | 180 | //$last_exec['aircraftlistjson'] = 0; |
| 142 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 181 | + if ($globalDebug) { |
|
| 182 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 183 | + } |
|
| 143 | 184 | } else if (preg_match('/opensky/i',$host)) { |
| 144 | 185 | //$formats[$id] = 'aircraftlistjson'; |
| 145 | 186 | $globalSources[$id]['format'] = 'opensky'; |
| 146 | 187 | //$last_exec['aircraftlistjson'] = 0; |
| 147 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 188 | + if ($globalDebug) { |
|
| 189 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 190 | + } |
|
| 148 | 191 | /* |
| 149 | 192 | // Disabled for now, site change source format |
| 150 | 193 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -161,7 +204,9 @@ discard block |
||
| 161 | 204 | //$formats[$id] = 'planeupdatefaa'; |
| 162 | 205 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 163 | 206 | //$last_exec['planeupdatefaa'] = 0; |
| 164 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 207 | + if ($globalDebug) { |
|
| 208 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 209 | + } |
|
| 165 | 210 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 166 | 211 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 167 | 212 | exit(0); |
@@ -170,32 +215,46 @@ discard block |
||
| 170 | 215 | //$formats[$id] = 'phpvmacars'; |
| 171 | 216 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 172 | 217 | //$last_exec['phpvmacars'] = 0; |
| 173 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 218 | + if ($globalDebug) { |
|
| 219 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 220 | + } |
|
| 174 | 221 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 175 | 222 | //$formats[$id] = 'phpvmacars'; |
| 176 | 223 | $globalSources[$id]['format'] = 'vam'; |
| 177 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 224 | + if ($globalDebug) { |
|
| 225 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 226 | + } |
|
| 178 | 227 | } else if (preg_match('/whazzup/i',$host)) { |
| 179 | 228 | //$formats[$id] = 'whazzup'; |
| 180 | 229 | $globalSources[$id]['format'] = 'whazzup'; |
| 181 | 230 | //$last_exec['whazzup'] = 0; |
| 182 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 231 | + if ($globalDebug) { |
|
| 232 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 233 | + } |
|
| 183 | 234 | } else if (preg_match('/blitzortung/i',$host)) { |
| 184 | 235 | $globalSources[$id]['format'] = 'blitzortung'; |
| 185 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 236 | + if ($globalDebug) { |
|
| 237 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 238 | + } |
|
| 186 | 239 | } else if (preg_match('/airwhere/i',$host)) { |
| 187 | 240 | $globalSources[$id]['format'] = 'airwhere'; |
| 188 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 241 | + if ($globalDebug) { |
|
| 242 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 243 | + } |
|
| 189 | 244 | } else if (preg_match('/recentpireps/i',$host)) { |
| 190 | 245 | //$formats[$id] = 'pirepsjson'; |
| 191 | 246 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 192 | 247 | //$last_exec['pirepsjson'] = 0; |
| 193 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 248 | + if ($globalDebug) { |
|
| 249 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 250 | + } |
|
| 194 | 251 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 195 | 252 | //$formats[$id] = 'fr24json'; |
| 196 | 253 | $globalSources[$id]['format'] = 'fr24json'; |
| 197 | 254 | //$last_exec['fr24json'] = 0; |
| 198 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 255 | + if ($globalDebug) { |
|
| 256 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 257 | + } |
|
| 199 | 258 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 200 | 259 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 201 | 260 | exit(0); |
@@ -204,7 +263,9 @@ discard block |
||
| 204 | 263 | //$formats[$id] = 'fr24json'; |
| 205 | 264 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 206 | 265 | //$last_exec['fr24json'] = 0; |
| 207 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 266 | + if ($globalDebug) { |
|
| 267 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 268 | + } |
|
| 208 | 269 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 209 | 270 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 210 | 271 | exit(0); |
@@ -213,17 +274,24 @@ discard block |
||
| 213 | 274 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 214 | 275 | //$formats[$id] = 'tsv'; |
| 215 | 276 | $globalSources[$id]['format'] = 'tsv'; |
| 216 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 277 | + if ($globalDebug) { |
|
| 278 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 279 | + } |
|
| 217 | 280 | } |
| 218 | 281 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 219 | 282 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 220 | 283 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 221 | 284 | if ($idf !== false) { |
| 222 | 285 | $httpfeeds[$id] = $idf; |
| 223 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 286 | + if ($globalDebug) { |
|
| 287 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 288 | + } |
|
| 289 | + } elseif ($globalDebug) { |
|
| 290 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 224 | 291 | } |
| 225 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 226 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 292 | + } elseif ($globalDebug) { |
|
| 293 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 294 | + } |
|
| 227 | 295 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 228 | 296 | $hostport = explode(':',$host); |
| 229 | 297 | if (isset($hostport[1])) { |
@@ -263,17 +331,25 @@ discard block |
||
| 263 | 331 | //$formats[$id] = 'beast'; |
| 264 | 332 | $globalSources[$id]['format'] = 'beast'; |
| 265 | 333 | //} else $formats[$id] = 'sbs'; |
| 266 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 334 | + } else { |
|
| 335 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 336 | + } |
|
| 267 | 337 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 268 | 338 | } |
| 269 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 339 | + if ($globalDebug) { |
|
| 340 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 341 | + } |
|
| 270 | 342 | } else { |
| 271 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 343 | + if ($globalDebug) { |
|
| 344 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 345 | + } |
|
| 272 | 346 | } |
| 273 | 347 | } |
| 274 | 348 | } |
| 275 | 349 | } |
| 276 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 350 | +if (!isset($globalMinFetch)) { |
|
| 351 | + $globalMinFetch = 15; |
|
| 352 | +} |
|
| 277 | 353 | |
| 278 | 354 | // Initialize all |
| 279 | 355 | $status = array(); |
@@ -282,13 +358,19 @@ discard block |
||
| 282 | 358 | $formats = array(); |
| 283 | 359 | $last_exec = array(); |
| 284 | 360 | $time = time(); |
| 285 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 286 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 287 | -else $timeout = 20; |
|
| 361 | +if (isset($globalSourcesTimeout)) { |
|
| 362 | + $timeout = $globalSourcesTimeOut; |
|
| 363 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 364 | + $timeout = $globalSBS1TimeOut; |
|
| 365 | +} else { |
|
| 366 | + $timeout = 20; |
|
| 367 | +} |
|
| 288 | 368 | $errno = ''; |
| 289 | 369 | $errstr=''; |
| 290 | 370 | |
| 291 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 371 | +if (!isset($globalDaemon)) { |
|
| 372 | + $globalDaemon = TRUE; |
|
| 373 | +} |
|
| 292 | 374 | /* Initiate connections to all the hosts simultaneously */ |
| 293 | 375 | //connect_all($hosts); |
| 294 | 376 | //connect_all($globalSources); |
@@ -317,7 +399,9 @@ discard block |
||
| 317 | 399 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 318 | 400 | $aprs_connect = 0; |
| 319 | 401 | $use_aprs = true; |
| 320 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 402 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 403 | + $aprs_full = true; |
|
| 404 | + } |
|
| 321 | 405 | break; |
| 322 | 406 | } |
| 323 | 407 | } |
@@ -328,25 +412,48 @@ discard block |
||
| 328 | 412 | $aprs_connect = 0; |
| 329 | 413 | $aprs_keep = 120; |
| 330 | 414 | $aprs_last_tx = time(); |
| 331 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 332 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 333 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 334 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 335 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 336 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 337 | - if ($aprs_full) $aprs_filter = ''; |
|
| 338 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 339 | - else $aprs_pass = '-1'; |
|
| 415 | + if (isset($globalAPRSversion)) { |
|
| 416 | + $aprs_version = $globalAPRSversion; |
|
| 417 | + } else { |
|
| 418 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 419 | + } |
|
| 420 | + if (isset($globalAPRSssid)) { |
|
| 421 | + $aprs_ssid = $globalAPRSssid; |
|
| 422 | + } else { |
|
| 423 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 424 | + } |
|
| 425 | + if (isset($globalAPRSfilter)) { |
|
| 426 | + $aprs_filter = $globalAPRSfilter; |
|
| 427 | + } else { |
|
| 428 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 429 | + } |
|
| 430 | + if ($aprs_full) { |
|
| 431 | + $aprs_filter = ''; |
|
| 432 | + } |
|
| 433 | + if (isset($globalAPRSpass)) { |
|
| 434 | + $aprs_pass = $globalAPRSpass; |
|
| 435 | + } else { |
|
| 436 | + $aprs_pass = '-1'; |
|
| 437 | + } |
|
| 340 | 438 | |
| 341 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 342 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 343 | -} |
|
| 439 | + if ($aprs_filter != '') { |
|
| 440 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 441 | + } else { |
|
| 442 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 443 | + } |
|
| 444 | + } |
|
| 344 | 445 | |
| 345 | 446 | // connected - lets do some work |
| 346 | -if ($globalDebug) echo "Connected!\n"; |
|
| 447 | +if ($globalDebug) { |
|
| 448 | + echo "Connected!\n"; |
|
| 449 | +} |
|
| 347 | 450 | sleep(1); |
| 348 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 349 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 451 | +if ($globalDebug) { |
|
| 452 | + echo "SCAN MODE \n\n"; |
|
| 453 | +} |
|
| 454 | +if (!isset($globalCronEnd)) { |
|
| 455 | + $globalCronEnd = 60; |
|
| 456 | +} |
|
| 350 | 457 | $endtime = time()+$globalCronEnd; |
| 351 | 458 | $i = 1; |
| 352 | 459 | $tt = array(); |
@@ -360,20 +467,28 @@ discard block |
||
| 360 | 467 | |
| 361 | 468 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 362 | 469 | while ($i > 0) { |
| 363 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 470 | + if (!$globalDaemon) { |
|
| 471 | + $i = $endtime-time(); |
|
| 472 | + } |
|
| 364 | 473 | // Delete old ATC |
| 365 | 474 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 366 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 475 | + if ($globalDebug) { |
|
| 476 | + echo 'Delete old ATC...'."\n"; |
|
| 477 | + } |
|
| 367 | 478 | $ATC->deleteOldATC(); |
| 368 | 479 | } |
| 369 | 480 | |
| 370 | 481 | if (count($last_exec) == count($globalSources)) { |
| 371 | 482 | $max = $globalMinFetch; |
| 372 | 483 | foreach ($last_exec as $last) { |
| 373 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 484 | + if ((time() - $last['last']) < $max) { |
|
| 485 | + $max = time() - $last['last']; |
|
| 486 | + } |
|
| 374 | 487 | } |
| 375 | 488 | if ($max != $globalMinFetch) { |
| 376 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 489 | + if ($globalDebug) { |
|
| 490 | + echo 'Sleeping...'."\n"; |
|
| 491 | + } |
|
| 377 | 492 | sleep($globalMinFetch-$max+2); |
| 378 | 493 | } |
| 379 | 494 | } |
@@ -383,7 +498,9 @@ discard block |
||
| 383 | 498 | foreach ($globalSources as $id => $value) { |
| 384 | 499 | date_default_timezone_set('UTC'); |
| 385 | 500 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 386 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 501 | + if (!isset($last_exec[$id]['last'])) { |
|
| 502 | + $last_exec[$id]['last'] = 0; |
|
| 503 | + } |
|
| 387 | 504 | if ($value['format'] == 'deltadbtxt' && |
| 388 | 505 | ( |
| 389 | 506 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -392,7 +509,9 @@ discard block |
||
| 392 | 509 | ) { |
| 393 | 510 | //$buffer = $Common->getData($hosts[$id]); |
| 394 | 511 | $buffer = $Common->getData($value['host']); |
| 395 | - if ($buffer != '') $reset = 0; |
|
| 512 | + if ($buffer != '') { |
|
| 513 | + $reset = 0; |
|
| 514 | + } |
|
| 396 | 515 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 397 | 516 | $buffer = explode('\n',$buffer); |
| 398 | 517 | foreach ($buffer as $line) { |
@@ -401,20 +520,41 @@ discard block |
||
| 401 | 520 | $data = array(); |
| 402 | 521 | $data['hex'] = $line[1]; // hex |
| 403 | 522 | $data['ident'] = $line[2]; // ident |
| 404 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 405 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 406 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 407 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 408 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 523 | + if (isset($line[3])) { |
|
| 524 | + $data['altitude'] = $line[3]; |
|
| 525 | + } |
|
| 526 | + // altitude |
|
| 527 | + if (isset($line[4])) { |
|
| 528 | + $data['speed'] = $line[4]; |
|
| 529 | + } |
|
| 530 | + // speed |
|
| 531 | + if (isset($line[5])) { |
|
| 532 | + $data['heading'] = $line[5]; |
|
| 533 | + } |
|
| 534 | + // heading |
|
| 535 | + if (isset($line[6])) { |
|
| 536 | + $data['latitude'] = $line[6]; |
|
| 537 | + } |
|
| 538 | + // lat |
|
| 539 | + if (isset($line[7])) { |
|
| 540 | + $data['longitude'] = $line[7]; |
|
| 541 | + } |
|
| 542 | + // long |
|
| 409 | 543 | $data['verticalrate'] = ''; // vertical rate |
| 410 | 544 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 411 | 545 | $data['emergency'] = ''; // emergency |
| 412 | 546 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 413 | 547 | $data['format_source'] = 'deltadbtxt'; |
| 414 | 548 | $data['id_source'] = $id_source; |
| 415 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 416 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 417 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 549 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 550 | + $data['source_name'] = $value['name']; |
|
| 551 | + } |
|
| 552 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 553 | + $data['noarchive'] = true; |
|
| 554 | + } |
|
| 555 | + if (isset($value['sourcestats'])) { |
|
| 556 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 557 | + } |
|
| 418 | 558 | $SI->add($data); |
| 419 | 559 | unset($data); |
| 420 | 560 | } |
@@ -429,7 +569,9 @@ discard block |
||
| 429 | 569 | date_default_timezone_set('CET'); |
| 430 | 570 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 431 | 571 | date_default_timezone_set('UTC'); |
| 432 | - if ($buffer != '') $reset = 0; |
|
| 572 | + if ($buffer != '') { |
|
| 573 | + $reset = 0; |
|
| 574 | + } |
|
| 433 | 575 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 434 | 576 | $buffer = explode('\n',$buffer); |
| 435 | 577 | foreach ($buffer as $line) { |
@@ -438,16 +580,36 @@ discard block |
||
| 438 | 580 | $add = false; |
| 439 | 581 | $ais_data = $AIS->parse_line(trim($line)); |
| 440 | 582 | $data = array(); |
| 441 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 442 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 443 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 444 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 445 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 446 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 447 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 448 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 449 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 450 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 583 | + if (isset($ais_data['ident'])) { |
|
| 584 | + $data['ident'] = $ais_data['ident']; |
|
| 585 | + } |
|
| 586 | + if (isset($ais_data['mmsi'])) { |
|
| 587 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 588 | + } |
|
| 589 | + if (isset($ais_data['speed'])) { |
|
| 590 | + $data['speed'] = $ais_data['speed']; |
|
| 591 | + } |
|
| 592 | + if (isset($ais_data['heading'])) { |
|
| 593 | + $data['heading'] = $ais_data['heading']; |
|
| 594 | + } |
|
| 595 | + if (isset($ais_data['latitude'])) { |
|
| 596 | + $data['latitude'] = $ais_data['latitude']; |
|
| 597 | + } |
|
| 598 | + if (isset($ais_data['longitude'])) { |
|
| 599 | + $data['longitude'] = $ais_data['longitude']; |
|
| 600 | + } |
|
| 601 | + if (isset($ais_data['status'])) { |
|
| 602 | + $data['status'] = $ais_data['status']; |
|
| 603 | + } |
|
| 604 | + if (isset($ais_data['type'])) { |
|
| 605 | + $data['type'] = $ais_data['type']; |
|
| 606 | + } |
|
| 607 | + if (isset($ais_data['imo'])) { |
|
| 608 | + $data['imo'] = $ais_data['imo']; |
|
| 609 | + } |
|
| 610 | + if (isset($ais_data['callsign'])) { |
|
| 611 | + $data['callsign'] = $ais_data['callsign']; |
|
| 612 | + } |
|
| 451 | 613 | if (isset($ais_data['timestamp'])) { |
| 452 | 614 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 453 | 615 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -461,8 +623,12 @@ discard block |
||
| 461 | 623 | $data['format_source'] = 'aisnmeatxt'; |
| 462 | 624 | $data['id_source'] = $id_source; |
| 463 | 625 | //print_r($data); |
| 464 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 465 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 626 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 627 | + $data['noarchive'] = true; |
|
| 628 | + } |
|
| 629 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 630 | + $MI->add($data); |
|
| 631 | + } |
|
| 466 | 632 | unset($data); |
| 467 | 633 | } |
| 468 | 634 | } |
@@ -482,20 +648,48 @@ discard block |
||
| 482 | 648 | if ($line != '') { |
| 483 | 649 | $ais_data = $AIS->parse_line(trim($line)); |
| 484 | 650 | $data = array(); |
| 485 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 486 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 487 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 488 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 489 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 490 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 491 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 492 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 493 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 494 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 495 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 496 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 497 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 498 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 651 | + if (isset($ais_data['ident'])) { |
|
| 652 | + $data['ident'] = $ais_data['ident']; |
|
| 653 | + } |
|
| 654 | + if (isset($ais_data['mmsi'])) { |
|
| 655 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 656 | + } |
|
| 657 | + if (isset($ais_data['speed'])) { |
|
| 658 | + $data['speed'] = $ais_data['speed']; |
|
| 659 | + } |
|
| 660 | + if (isset($ais_data['heading'])) { |
|
| 661 | + $data['heading'] = $ais_data['heading']; |
|
| 662 | + } |
|
| 663 | + if (isset($ais_data['latitude'])) { |
|
| 664 | + $data['latitude'] = $ais_data['latitude']; |
|
| 665 | + } |
|
| 666 | + if (isset($ais_data['longitude'])) { |
|
| 667 | + $data['longitude'] = $ais_data['longitude']; |
|
| 668 | + } |
|
| 669 | + if (isset($ais_data['status'])) { |
|
| 670 | + $data['status'] = $ais_data['status']; |
|
| 671 | + } |
|
| 672 | + if (isset($ais_data['statusid'])) { |
|
| 673 | + $data['status_id'] = $ais_data['statusid']; |
|
| 674 | + } |
|
| 675 | + if (isset($ais_data['type'])) { |
|
| 676 | + $data['type'] = $ais_data['type']; |
|
| 677 | + } |
|
| 678 | + if (isset($ais_data['typeid'])) { |
|
| 679 | + $data['type_id'] = $ais_data['typeid']; |
|
| 680 | + } |
|
| 681 | + if (isset($ais_data['imo'])) { |
|
| 682 | + $data['imo'] = $ais_data['imo']; |
|
| 683 | + } |
|
| 684 | + if (isset($ais_data['callsign'])) { |
|
| 685 | + $data['callsign'] = $ais_data['callsign']; |
|
| 686 | + } |
|
| 687 | + if (isset($ais_data['destination'])) { |
|
| 688 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 689 | + } |
|
| 690 | + if (isset($ais_data['eta_ts'])) { |
|
| 691 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 692 | + } |
|
| 499 | 693 | if (isset($ais_data['timestamp'])) { |
| 500 | 694 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 501 | 695 | } else { |
@@ -503,18 +697,27 @@ discard block |
||
| 503 | 697 | } |
| 504 | 698 | $data['format_source'] = 'aisnmeahttp'; |
| 505 | 699 | $data['id_source'] = $id_source; |
| 506 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 507 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 700 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 701 | + $data['noarchive'] = true; |
|
| 702 | + } |
|
| 703 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 704 | + $MI->add($data); |
|
| 705 | + } |
|
| 508 | 706 | unset($data); |
| 509 | 707 | } |
| 510 | 708 | } |
| 511 | 709 | } |
| 512 | 710 | } else { |
| 513 | 711 | $format = $value['format']; |
| 514 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 515 | - else $tt[$format] = 0; |
|
| 712 | + if (isset($tt[$format])) { |
|
| 713 | + $tt[$format]++; |
|
| 714 | + } else { |
|
| 715 | + $tt[$format] = 0; |
|
| 716 | + } |
|
| 516 | 717 | if ($tt[$format] > 30) { |
| 517 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 718 | + if ($globalDebug) { |
|
| 719 | + echo 'Reconnect...'."\n"; |
|
| 720 | + } |
|
| 518 | 721 | sleep(2); |
| 519 | 722 | $sourceeen[] = $value; |
| 520 | 723 | connect_all($sourceeen); |
@@ -549,7 +752,9 @@ discard block |
||
| 549 | 752 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 550 | 753 | $data['format_source'] = 'myshiptracking'; |
| 551 | 754 | $data['id_source'] = $id_source; |
| 552 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 755 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 756 | + $data['noarchive'] = true; |
|
| 757 | + } |
|
| 553 | 758 | $MI->add($data); |
| 554 | 759 | unset($data); |
| 555 | 760 | } |
@@ -574,7 +779,9 @@ discard block |
||
| 574 | 779 | $data['callsign'] = $line['callsign']; |
| 575 | 780 | $data['mmsi'] = $line['mmsi']; |
| 576 | 781 | $data['speed'] = $line['sog']; |
| 577 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 782 | + if ($line['heading'] != '511') { |
|
| 783 | + $data['heading'] = $line['heading']; |
|
| 784 | + } |
|
| 578 | 785 | $data['latitude'] = $line['latitude']; |
| 579 | 786 | $data['longitude'] = $line['longitude']; |
| 580 | 787 | $data['type_id'] = $line['shiptype']; |
@@ -582,7 +789,9 @@ discard block |
||
| 582 | 789 | $data['datetime'] = $line['time']; |
| 583 | 790 | $data['format_source'] = 'boatbeaconapp'; |
| 584 | 791 | $data['id_source'] = $id_source; |
| 585 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 792 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 793 | + $data['noarchive'] = true; |
|
| 794 | + } |
|
| 586 | 795 | $MI->add($data); |
| 587 | 796 | unset($data); |
| 588 | 797 | } |
@@ -603,22 +812,44 @@ discard block |
||
| 603 | 812 | if (isset($all_data['features'][0]['id'])) { |
| 604 | 813 | foreach ($all_data['features'] as $line) { |
| 605 | 814 | $data = array(); |
| 606 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 607 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 608 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi']; |
|
| 609 | - if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo']; |
|
| 610 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 611 | - if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading']; |
|
| 815 | + if (isset($line['properties']['name'])) { |
|
| 816 | + $data['ident'] = $line['properties']['name']; |
|
| 817 | + } |
|
| 818 | + if (isset($line['properties']['callsign'])) { |
|
| 819 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 820 | + } |
|
| 821 | + if (isset($line['properties']['mmsi'])) { |
|
| 822 | + $data['mmsi'] = $line['properties']['mmsi']; |
|
| 823 | + } |
|
| 824 | + if (isset($line['properties']['imo'])) { |
|
| 825 | + $data['mmsi'] = $line['properties']['imo']; |
|
| 826 | + } |
|
| 827 | + if (isset($line['properties']['speed'])) { |
|
| 828 | + $data['speed'] = $line['properties']['speed']; |
|
| 829 | + } |
|
| 830 | + if (isset($line['properties']['heading'])) { |
|
| 831 | + $data['heading'] = $line['properties']['heading']; |
|
| 832 | + } |
|
| 612 | 833 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 613 | 834 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 614 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 615 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 616 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 835 | + if (isset($line['properties']['vesselType'])) { |
|
| 836 | + $data['type'] = $line['properties']['vesselType']; |
|
| 837 | + } |
|
| 838 | + if (isset($line['properties']['destination'])) { |
|
| 839 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 840 | + } |
|
| 841 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 842 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 843 | + } |
|
| 617 | 844 | $data['format_source'] = 'boatnerd'; |
| 618 | 845 | $data['id_source'] = $id_source; |
| 619 | 846 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 620 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 621 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 847 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 848 | + $data['noarchive'] = true; |
|
| 849 | + } |
|
| 850 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 851 | + $MI->add($data); |
|
| 852 | + } |
|
| 622 | 853 | unset($data); |
| 623 | 854 | } |
| 624 | 855 | } |
@@ -634,7 +865,9 @@ discard block |
||
| 634 | 865 | echo 'download...'; |
| 635 | 866 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 636 | 867 | echo 'done !'."\n"; |
| 637 | - if ($buffer != '') $reset = 0; |
|
| 868 | + if ($buffer != '') { |
|
| 869 | + $reset = 0; |
|
| 870 | + } |
|
| 638 | 871 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 639 | 872 | $buffer = explode('\n',$buffer); |
| 640 | 873 | foreach ($buffer as $line) { |
@@ -659,7 +892,9 @@ discard block |
||
| 659 | 892 | //$data['etaTime'] = substr($line,135,5); |
| 660 | 893 | $data['format_source'] = 'shipplotter'; |
| 661 | 894 | $data['id_source'] = $id_source; |
| 662 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 895 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 896 | + $data['noarchive'] = true; |
|
| 897 | + } |
|
| 663 | 898 | //print_r($data); |
| 664 | 899 | echo 'Add...'."\n"; |
| 665 | 900 | $MI->add($data); |
@@ -693,16 +928,28 @@ discard block |
||
| 693 | 928 | $line = explode(':', $line); |
| 694 | 929 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 695 | 930 | $data = array(); |
| 696 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 697 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 931 | + if (isset($line[37]) && $line[37] != '') { |
|
| 932 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 933 | + } else { |
|
| 934 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 935 | + } |
|
| 698 | 936 | $data['pilot_id'] = $line[1]; |
| 699 | 937 | $data['pilot_name'] = $line[2]; |
| 700 | 938 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 701 | 939 | $data['ident'] = $line[0]; // ident |
| 702 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 940 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 941 | + $data['altitude'] = $line[7]; |
|
| 942 | + } |
|
| 943 | + // altitude |
|
| 703 | 944 | $data['speed'] = $line[8]; // speed |
| 704 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 705 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 945 | + if (isset($line[45])) { |
|
| 946 | + $data['heading'] = $line[45]; |
|
| 947 | + } |
|
| 948 | + // heading |
|
| 949 | + elseif (isset($line[38])) { |
|
| 950 | + $data['heading'] = $line[38]; |
|
| 951 | + } |
|
| 952 | + // heading |
|
| 706 | 953 | $data['latitude'] = $line[5]; // lat |
| 707 | 954 | $data['longitude'] = $line[6]; // long |
| 708 | 955 | $data['verticalrate'] = ''; // vertical rate |
@@ -718,7 +965,9 @@ discard block |
||
| 718 | 965 | $data['frequency'] = $line[4]; |
| 719 | 966 | $data['type'] = $line[18]; |
| 720 | 967 | $data['range'] = $line[19]; |
| 721 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 968 | + if (isset($line[35])) { |
|
| 969 | + $data['info'] = $line[35]; |
|
| 970 | + } |
|
| 722 | 971 | $data['id_source'] = $id_source; |
| 723 | 972 | //$data['arrival_airport_time'] = ; |
| 724 | 973 | if ($line[9] != '') { |
@@ -732,27 +981,47 @@ discard block |
||
| 732 | 981 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 733 | 982 | */ |
| 734 | 983 | $data['format_source'] = $value['format']; |
| 735 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 736 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 737 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 738 | - elseif ($line[3] == 'ATC') { |
|
| 984 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 985 | + $data['noarchive'] = true; |
|
| 986 | + } |
|
| 987 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 988 | + $data['source_name'] = $value['name']; |
|
| 989 | + } |
|
| 990 | + if ($line[3] == 'PILOT') { |
|
| 991 | + $SI->add($data); |
|
| 992 | + } elseif ($line[3] == 'ATC') { |
|
| 739 | 993 | //print_r($data); |
| 740 | 994 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 741 | 995 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 742 | 996 | $typec = substr($data['ident'],-3); |
| 743 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 744 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 745 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 746 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 747 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 748 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 749 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 750 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 751 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 752 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 997 | + if ($typec == 'APP') { |
|
| 998 | + $data['type'] = 'Approach'; |
|
| 999 | + } elseif ($typec == 'TWR') { |
|
| 1000 | + $data['type'] = 'Tower'; |
|
| 1001 | + } elseif ($typec == 'OBS') { |
|
| 1002 | + $data['type'] = 'Observer'; |
|
| 1003 | + } elseif ($typec == 'GND') { |
|
| 1004 | + $data['type'] = 'Ground'; |
|
| 1005 | + } elseif ($typec == 'DEL') { |
|
| 1006 | + $data['type'] = 'Delivery'; |
|
| 1007 | + } elseif ($typec == 'DEP') { |
|
| 1008 | + $data['type'] = 'Departure'; |
|
| 1009 | + } elseif ($typec == 'FSS') { |
|
| 1010 | + $data['type'] = 'Flight Service Station'; |
|
| 1011 | + } elseif ($typec == 'CTR') { |
|
| 1012 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1013 | + } elseif ($data['type'] == '') { |
|
| 1014 | + $data['type'] = 'Observer'; |
|
| 1015 | + } |
|
| 1016 | + if (!isset($data['source_name'])) { |
|
| 1017 | + $data['source_name'] = ''; |
|
| 1018 | + } |
|
| 753 | 1019 | if (isset($ATC)) { |
| 754 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 755 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1020 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 1021 | + echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1022 | + } else { |
|
| 1023 | + 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']); |
|
| 1024 | + } |
|
| 756 | 1025 | } |
| 757 | 1026 | } |
| 758 | 1027 | unset($data); |
@@ -779,14 +1048,20 @@ discard block |
||
| 779 | 1048 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 780 | 1049 | $data['latitude'] = (float)$line['pktLatitude']; |
| 781 | 1050 | $data['longitude'] = (float)$line['pktLongitude']; |
| 782 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 783 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1051 | + if ((float)$line['pktTrack'] != 0) { |
|
| 1052 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 1053 | + } |
|
| 1054 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 1055 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 1056 | + } |
|
| 784 | 1057 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 785 | 1058 | $data['altitude_relative'] = 'AMSL'; |
| 786 | 1059 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 787 | 1060 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 788 | 1061 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 789 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 1062 | + if (isset($pilot_data[4])) { |
|
| 1063 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1064 | + } |
|
| 790 | 1065 | $data['format_source'] = $value['format']; |
| 791 | 1066 | $SI->add($data); |
| 792 | 1067 | unset($data); |
@@ -834,25 +1109,59 @@ discard block |
||
| 834 | 1109 | foreach ($all_data['acList'] as $line) { |
| 835 | 1110 | $data = array(); |
| 836 | 1111 | $data['hex'] = $line['Icao']; // hex |
| 837 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 838 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 839 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 840 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 841 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 842 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1112 | + if (isset($line['Call'])) { |
|
| 1113 | + $data['ident'] = $line['Call']; |
|
| 1114 | + } |
|
| 1115 | + // ident |
|
| 1116 | + if (isset($line['Alt'])) { |
|
| 1117 | + $data['altitude'] = $line['Alt']; |
|
| 1118 | + } |
|
| 1119 | + // altitude |
|
| 1120 | + if (isset($line['Spd'])) { |
|
| 1121 | + $data['speed'] = $line['Spd']; |
|
| 1122 | + } |
|
| 1123 | + // speed |
|
| 1124 | + if (isset($line['Trak'])) { |
|
| 1125 | + $data['heading'] = $line['Trak']; |
|
| 1126 | + } |
|
| 1127 | + // heading |
|
| 1128 | + if (isset($line['Lat'])) { |
|
| 1129 | + $data['latitude'] = $line['Lat']; |
|
| 1130 | + } |
|
| 1131 | + // lat |
|
| 1132 | + if (isset($line['Long'])) { |
|
| 1133 | + $data['longitude'] = $line['Long']; |
|
| 1134 | + } |
|
| 1135 | + // long |
|
| 843 | 1136 | //$data['verticalrate'] = $line['']; // verticale rate |
| 844 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1137 | + if (isset($line['Sqk'])) { |
|
| 1138 | + $data['squawk'] = $line['Sqk']; |
|
| 1139 | + } |
|
| 1140 | + // squawk |
|
| 845 | 1141 | $data['emergency'] = ''; // emergency |
| 846 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 847 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 848 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1142 | + if (isset($line['Reg'])) { |
|
| 1143 | + $data['registration'] = $line['Reg']; |
|
| 1144 | + } |
|
| 1145 | + if (isset($line['PosTime'])) { |
|
| 1146 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1147 | + } else { |
|
| 1148 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1149 | + } |
|
| 849 | 1150 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 850 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1151 | + if (isset($line['Type'])) { |
|
| 1152 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1153 | + } |
|
| 851 | 1154 | $data['format_source'] = 'aircraftlistjson'; |
| 852 | 1155 | $data['id_source'] = $id_source; |
| 853 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 854 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 855 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1156 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1157 | + $data['source_name'] = $value['name']; |
|
| 1158 | + } |
|
| 1159 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1160 | + $data['noarchive'] = true; |
|
| 1161 | + } |
|
| 1162 | + if (isset($data['latitude'])) { |
|
| 1163 | + $SI->add($data); |
|
| 1164 | + } |
|
| 856 | 1165 | unset($data); |
| 857 | 1166 | } |
| 858 | 1167 | } elseif (is_array($all_data)) { |
@@ -869,17 +1178,26 @@ discard block |
||
| 869 | 1178 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 870 | 1179 | $data['squawk'] = $line['squawk']; // squawk |
| 871 | 1180 | $data['emergency'] = ''; // emergency |
| 872 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 873 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1181 | + if (isset($line['PosTime'])) { |
|
| 1182 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1183 | + } else { |
|
| 1184 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1185 | + } |
|
| 874 | 1186 | $data['format_source'] = 'aircraftlistjson'; |
| 875 | 1187 | $data['id_source'] = $id_source; |
| 876 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 877 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1188 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1189 | + $data['noarchive'] = true; |
|
| 1190 | + } |
|
| 1191 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1192 | + $data['source_name'] = $value['name']; |
|
| 1193 | + } |
|
| 878 | 1194 | $SI->add($data); |
| 879 | 1195 | unset($data); |
| 880 | 1196 | } |
| 881 | 1197 | } |
| 882 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1198 | + } elseif ($globalDebug) { |
|
| 1199 | + echo 'No data'."\n"; |
|
| 1200 | + } |
|
| 883 | 1201 | //$last_exec['aircraftlistjson'] = time(); |
| 884 | 1202 | $last_exec[$id]['last'] = time(); |
| 885 | 1203 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -915,8 +1233,12 @@ discard block |
||
| 915 | 1233 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 916 | 1234 | $data['format_source'] = 'planeupdatefaa'; |
| 917 | 1235 | $data['id_source'] = $id_source; |
| 918 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 919 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1236 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1237 | + $data['noarchive'] = true; |
|
| 1238 | + } |
|
| 1239 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1240 | + $data['source_name'] = $value['name']; |
|
| 1241 | + } |
|
| 920 | 1242 | $SI->add($data); |
| 921 | 1243 | unset($data); |
| 922 | 1244 | } |
@@ -950,7 +1272,9 @@ discard block |
||
| 950 | 1272 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 951 | 1273 | $data['format_source'] = 'opensky'; |
| 952 | 1274 | $data['id_source'] = $id_source; |
| 953 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1275 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1276 | + $data['noarchive'] = true; |
|
| 1277 | + } |
|
| 954 | 1278 | $SI->add($data); |
| 955 | 1279 | unset($data); |
| 956 | 1280 | } |
@@ -967,7 +1291,9 @@ discard block |
||
| 967 | 1291 | //$buffer = $Common->getData($hosts[$id]); |
| 968 | 1292 | $buffer = $Common->getData($value['host']); |
| 969 | 1293 | $all_data = json_decode($buffer,true); |
| 970 | - if (!empty($all_data)) $reset = 0; |
|
| 1294 | + if (!empty($all_data)) { |
|
| 1295 | + $reset = 0; |
|
| 1296 | + } |
|
| 971 | 1297 | foreach ($all_data as $key => $line) { |
| 972 | 1298 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 973 | 1299 | $data = array(); |
@@ -988,8 +1314,12 @@ discard block |
||
| 988 | 1314 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 989 | 1315 | $data['format_source'] = 'fr24json'; |
| 990 | 1316 | $data['id_source'] = $id_source; |
| 991 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 992 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1317 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1318 | + $data['noarchive'] = true; |
|
| 1319 | + } |
|
| 1320 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1321 | + $data['source_name'] = $value['name']; |
|
| 1322 | + } |
|
| 993 | 1323 | $SI->add($data); |
| 994 | 1324 | unset($data); |
| 995 | 1325 | } |
@@ -1018,24 +1348,42 @@ discard block |
||
| 1018 | 1348 | if (isset($line['inf'])) { |
| 1019 | 1349 | $data = array(); |
| 1020 | 1350 | $data['hex'] = $line['inf']['ia']; |
| 1021 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1351 | + if (isset($line['inf']['cs'])) { |
|
| 1352 | + $data['ident'] = $line['inf']['cs']; |
|
| 1353 | + } |
|
| 1354 | + //$line[13] |
|
| 1022 | 1355 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 1023 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1024 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1356 | + if (isset($line['inf']['gs'])) { |
|
| 1357 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1358 | + } |
|
| 1359 | + // speed |
|
| 1360 | + if (isset($line['inf']['tr'])) { |
|
| 1361 | + $data['heading'] = $line['inf']['tr']; |
|
| 1362 | + } |
|
| 1363 | + // heading |
|
| 1025 | 1364 | $data['latitude'] = $line['pt'][0]; // lat |
| 1026 | 1365 | $data['longitude'] = $line['pt'][1]; // long |
| 1027 | 1366 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 1028 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1367 | + if (isset($line['inf']['sq'])) { |
|
| 1368 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1369 | + } |
|
| 1370 | + // squawk |
|
| 1029 | 1371 | //$data['aircraft_icao'] = $line[8]; |
| 1030 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1372 | + if (isset($line['inf']['rc'])) { |
|
| 1373 | + $data['registration'] = $line['inf']['rc']; |
|
| 1374 | + } |
|
| 1031 | 1375 | //$data['departure_airport_iata'] = $line[11]; |
| 1032 | 1376 | //$data['arrival_airport_iata'] = $line[12]; |
| 1033 | 1377 | //$data['emergency'] = ''; // emergency |
| 1034 | 1378 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1035 | 1379 | $data['format_source'] = 'radarvirtueljson'; |
| 1036 | 1380 | $data['id_source'] = $id_source; |
| 1037 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1038 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1381 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1382 | + $data['noarchive'] = true; |
|
| 1383 | + } |
|
| 1384 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1385 | + $data['source_name'] = $value['name']; |
|
| 1386 | + } |
|
| 1039 | 1387 | $SI->add($data); |
| 1040 | 1388 | unset($data); |
| 1041 | 1389 | } |
@@ -1061,30 +1409,65 @@ discard block |
||
| 1061 | 1409 | $data['id'] = $line['id']; |
| 1062 | 1410 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 1063 | 1411 | $data['ident'] = $line['callsign']; // ident |
| 1064 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1065 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1066 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1067 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1068 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1069 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1412 | + if (isset($line['pilotid'])) { |
|
| 1413 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1414 | + } |
|
| 1415 | + // pilot id |
|
| 1416 | + if (isset($line['name'])) { |
|
| 1417 | + $data['pilot_name'] = $line['name']; |
|
| 1418 | + } |
|
| 1419 | + // pilot name |
|
| 1420 | + if (isset($line['alt'])) { |
|
| 1421 | + $data['altitude'] = $line['alt']; |
|
| 1422 | + } |
|
| 1423 | + // altitude |
|
| 1424 | + if (isset($line['gs'])) { |
|
| 1425 | + $data['speed'] = $line['gs']; |
|
| 1426 | + } |
|
| 1427 | + // speed |
|
| 1428 | + if (isset($line['heading'])) { |
|
| 1429 | + $data['heading'] = $line['heading']; |
|
| 1430 | + } |
|
| 1431 | + // heading |
|
| 1432 | + if (isset($line['route'])) { |
|
| 1433 | + $data['waypoints'] = $line['route']; |
|
| 1434 | + } |
|
| 1435 | + // route |
|
| 1070 | 1436 | $data['latitude'] = $line['lat']; // lat |
| 1071 | 1437 | $data['longitude'] = $line['lon']; // long |
| 1072 | 1438 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 1073 | 1439 | //$data['squawk'] = $line['squawk']; // squawk |
| 1074 | 1440 | //$data['emergency'] = ''; // emergency |
| 1075 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1076 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1077 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1441 | + if (isset($line['depicao'])) { |
|
| 1442 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1443 | + } |
|
| 1444 | + if (isset($line['deptime'])) { |
|
| 1445 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1446 | + } |
|
| 1447 | + if (isset($line['arricao'])) { |
|
| 1448 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1449 | + } |
|
| 1078 | 1450 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 1079 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1080 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1081 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1082 | - else $data['info'] = ''; |
|
| 1451 | + if (isset($line['aircraft'])) { |
|
| 1452 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1453 | + } |
|
| 1454 | + if (isset($line['transponder'])) { |
|
| 1455 | + $data['squawk'] = $line['transponder']; |
|
| 1456 | + } |
|
| 1457 | + if (isset($line['atis'])) { |
|
| 1458 | + $data['info'] = $line['atis']; |
|
| 1459 | + } else { |
|
| 1460 | + $data['info'] = ''; |
|
| 1461 | + } |
|
| 1083 | 1462 | $data['format_source'] = 'pireps'; |
| 1084 | 1463 | $data['id_source'] = $id_source; |
| 1085 | 1464 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1086 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1087 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1465 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1466 | + $data['noarchive'] = true; |
|
| 1467 | + } |
|
| 1468 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1469 | + $data['source_name'] = $value['name']; |
|
| 1470 | + } |
|
| 1088 | 1471 | if ($line['icon'] == 'plane') { |
| 1089 | 1472 | $SI->add($data); |
| 1090 | 1473 | // print_r($data); |
@@ -1093,16 +1476,28 @@ discard block |
||
| 1093 | 1476 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1094 | 1477 | $typec = substr($data['ident'],-3); |
| 1095 | 1478 | $data['type'] = ''; |
| 1096 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 1097 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 1098 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 1099 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 1100 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 1101 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 1102 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1103 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1104 | - else $data['type'] = 'Observer'; |
|
| 1105 | - 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']); |
|
| 1479 | + if ($typec == 'APP') { |
|
| 1480 | + $data['type'] = 'Approach'; |
|
| 1481 | + } elseif ($typec == 'TWR') { |
|
| 1482 | + $data['type'] = 'Tower'; |
|
| 1483 | + } elseif ($typec == 'OBS') { |
|
| 1484 | + $data['type'] = 'Observer'; |
|
| 1485 | + } elseif ($typec == 'GND') { |
|
| 1486 | + $data['type'] = 'Ground'; |
|
| 1487 | + } elseif ($typec == 'DEL') { |
|
| 1488 | + $data['type'] = 'Delivery'; |
|
| 1489 | + } elseif ($typec == 'DEP') { |
|
| 1490 | + $data['type'] = 'Departure'; |
|
| 1491 | + } elseif ($typec == 'FSS') { |
|
| 1492 | + $data['type'] = 'Flight Service Station'; |
|
| 1493 | + } elseif ($typec == 'CTR') { |
|
| 1494 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1495 | + } else { |
|
| 1496 | + $data['type'] = 'Observer'; |
|
| 1497 | + } |
|
| 1498 | + if (isset($ATC)) { |
|
| 1499 | + 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']); |
|
| 1500 | + } |
|
| 1106 | 1501 | } |
| 1107 | 1502 | unset($data); |
| 1108 | 1503 | } |
@@ -1117,7 +1512,9 @@ discard block |
||
| 1117 | 1512 | ) |
| 1118 | 1513 | ) { |
| 1119 | 1514 | //$buffer = $Common->getData($hosts[$id]); |
| 1120 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1515 | + if ($globalDebug) { |
|
| 1516 | + echo 'Get Data...'."\n"; |
|
| 1517 | + } |
|
| 1121 | 1518 | $buffer = $Common->getData($value['host']); |
| 1122 | 1519 | $all_data = json_decode($buffer,true); |
| 1123 | 1520 | if ($buffer != '' && is_array($all_data)) { |
@@ -1125,10 +1522,16 @@ discard block |
||
| 1125 | 1522 | foreach ($all_data as $line) { |
| 1126 | 1523 | $data = array(); |
| 1127 | 1524 | //$data['id'] = $line['id']; // id not usable |
| 1128 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1525 | + if (isset($line['pilotid'])) { |
|
| 1526 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1527 | + } |
|
| 1129 | 1528 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1130 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1131 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1529 | + if (isset($line['pilotname'])) { |
|
| 1530 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1531 | + } |
|
| 1532 | + if (isset($line['pilotid'])) { |
|
| 1533 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1534 | + } |
|
| 1132 | 1535 | $data['ident'] = $line['flightnum']; // ident |
| 1133 | 1536 | $data['altitude'] = $line['alt']; // altitude |
| 1134 | 1537 | $data['speed'] = $line['gs']; // speed |
@@ -1144,34 +1547,52 @@ discard block |
||
| 1144 | 1547 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
| 1145 | 1548 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1146 | 1549 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1147 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1550 | + } else { |
|
| 1551 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1552 | + } |
|
| 1148 | 1553 | $data['departure_airport_icao'] = $line['depicao']; |
| 1149 | 1554 | $data['departure_airport_time'] = $line['deptime']; |
| 1150 | 1555 | $data['arrival_airport_icao'] = $line['arricao']; |
| 1151 | 1556 | $data['arrival_airport_time'] = $line['arrtime']; |
| 1152 | 1557 | $data['registration'] = $line['aircraft']; |
| 1153 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1154 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1558 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1559 | + $data['noarchive'] = true; |
|
| 1560 | + } |
|
| 1561 | + if (isset($line['route'])) { |
|
| 1562 | + $data['waypoints'] = $line['route']; |
|
| 1563 | + } |
|
| 1564 | + // route |
|
| 1155 | 1565 | if (isset($line['aircraftname'])) { |
| 1156 | 1566 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1157 | 1567 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1158 | 1568 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1159 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1160 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1161 | - else { |
|
| 1569 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1570 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1571 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1572 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1573 | + } else { |
|
| 1162 | 1574 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1163 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1164 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1575 | + if (isset($aircraft_data[1])) { |
|
| 1576 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1577 | + } else { |
|
| 1578 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1579 | + } |
|
| 1165 | 1580 | } |
| 1166 | 1581 | } |
| 1167 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1582 | + if (isset($line['route'])) { |
|
| 1583 | + $data['waypoints'] = $line['route']; |
|
| 1584 | + } |
|
| 1168 | 1585 | $data['id_source'] = $id_source; |
| 1169 | 1586 | $data['format_source'] = 'phpvmacars'; |
| 1170 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1587 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1588 | + $data['source_name'] = $value['name']; |
|
| 1589 | + } |
|
| 1171 | 1590 | $SI->add($data); |
| 1172 | 1591 | unset($data); |
| 1173 | 1592 | } |
| 1174 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1593 | + if ($globalDebug) { |
|
| 1594 | + echo 'No more data...'."\n"; |
|
| 1595 | + } |
|
| 1175 | 1596 | unset($buffer); |
| 1176 | 1597 | unset($all_data); |
| 1177 | 1598 | } |
@@ -1184,7 +1605,9 @@ discard block |
||
| 1184 | 1605 | ) |
| 1185 | 1606 | ) { |
| 1186 | 1607 | //$buffer = $Common->getData($hosts[$id]); |
| 1187 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1608 | + if ($globalDebug) { |
|
| 1609 | + echo 'Get Data...'."\n"; |
|
| 1610 | + } |
|
| 1188 | 1611 | $buffer = $Common->getData($value['host']); |
| 1189 | 1612 | $all_data = json_decode($buffer,true); |
| 1190 | 1613 | if ($buffer != '' && is_array($all_data)) { |
@@ -1213,16 +1636,25 @@ discard block |
||
| 1213 | 1636 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1214 | 1637 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1215 | 1638 | //$data['registration'] = $line['aircraft']; |
| 1216 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1639 | + if (isset($line['route'])) { |
|
| 1640 | + $data['waypoints'] = $line['route']; |
|
| 1641 | + } |
|
| 1642 | + // route |
|
| 1217 | 1643 | $data['aircraft_icao'] = $line['plane_type']; |
| 1218 | 1644 | $data['id_source'] = $id_source; |
| 1219 | 1645 | $data['format_source'] = 'vam'; |
| 1220 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1221 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1646 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1647 | + $data['noarchive'] = true; |
|
| 1648 | + } |
|
| 1649 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1650 | + $data['source_name'] = $value['name']; |
|
| 1651 | + } |
|
| 1222 | 1652 | $SI->add($data); |
| 1223 | 1653 | unset($data); |
| 1224 | 1654 | } |
| 1225 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1655 | + if ($globalDebug) { |
|
| 1656 | + echo 'No more data...'."\n"; |
|
| 1657 | + } |
|
| 1226 | 1658 | unset($buffer); |
| 1227 | 1659 | unset($all_data); |
| 1228 | 1660 | } |
@@ -1235,7 +1667,9 @@ discard block |
||
| 1235 | 1667 | ) |
| 1236 | 1668 | ) { |
| 1237 | 1669 | //$buffer = $Common->getData($hosts[$id]); |
| 1238 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1670 | + if ($globalDebug) { |
|
| 1671 | + echo 'Get Data...'."\n"; |
|
| 1672 | + } |
|
| 1239 | 1673 | $buffer = $Common->getData($value['host']); |
| 1240 | 1674 | $all_data = json_decode($buffer,true); |
| 1241 | 1675 | if ($buffer != '') { |
@@ -1253,18 +1687,24 @@ discard block |
||
| 1253 | 1687 | $data['id_source'] = $id_source; |
| 1254 | 1688 | $data['format_source'] = 'blitzortung'; |
| 1255 | 1689 | $SI->add($data); |
| 1256 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 1690 | + if ($globalDebug) { |
|
| 1691 | + echo '☈ Lightning added'."\n"; |
|
| 1692 | + } |
|
| 1257 | 1693 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1258 | 1694 | unset($data); |
| 1259 | 1695 | } |
| 1260 | 1696 | } |
| 1261 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1697 | + if ($globalDebug) { |
|
| 1698 | + echo 'No more data...'."\n"; |
|
| 1699 | + } |
|
| 1262 | 1700 | unset($buffer); |
| 1263 | 1701 | } |
| 1264 | 1702 | $last_exec[$id]['last'] = time(); |
| 1265 | 1703 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1266 | 1704 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1267 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1705 | + if (function_exists('pcntl_fork')) { |
|
| 1706 | + pcntl_signal_dispatch(); |
|
| 1707 | + } |
|
| 1268 | 1708 | //$last_exec[$id]['last'] = time(); |
| 1269 | 1709 | |
| 1270 | 1710 | //$read = array( $sockets[$id] ); |
@@ -1272,7 +1712,9 @@ discard block |
||
| 1272 | 1712 | $write = NULL; |
| 1273 | 1713 | $e = NULL; |
| 1274 | 1714 | $n = socket_select($read, $write, $e, $timeout); |
| 1275 | - if ($e != NULL) var_dump($e); |
|
| 1715 | + if ($e != NULL) { |
|
| 1716 | + var_dump($e); |
|
| 1717 | + } |
|
| 1276 | 1718 | if ($n > 0) { |
| 1277 | 1719 | $reset = 0; |
| 1278 | 1720 | foreach ($read as $nb => $r) { |
@@ -1293,12 +1735,16 @@ discard block |
||
| 1293 | 1735 | //$SI::del(); |
| 1294 | 1736 | if ($format == 'vrstcp') { |
| 1295 | 1737 | $buffer = explode('},{',$buffer); |
| 1296 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1738 | + } else { |
|
| 1739 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1740 | + } |
|
| 1297 | 1741 | // SBS format is CSV format |
| 1298 | 1742 | if ($buffer !== FALSE && $buffer != '') { |
| 1299 | 1743 | $tt[$format] = 0; |
| 1300 | 1744 | if ($format == 'acarssbs3') { |
| 1301 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1745 | + if ($globalDebug) { |
|
| 1746 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1747 | + } |
|
| 1302 | 1748 | $ACARS->add(trim($buffer)); |
| 1303 | 1749 | $ACARS->deleteLiveAcarsData(); |
| 1304 | 1750 | } elseif ($format == 'raw') { |
@@ -1307,30 +1753,70 @@ discard block |
||
| 1307 | 1753 | if (is_array($data)) { |
| 1308 | 1754 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1309 | 1755 | $data['format_source'] = 'raw'; |
| 1310 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1311 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1312 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1313 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1756 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1757 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1758 | + } |
|
| 1759 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1760 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1761 | + } |
|
| 1762 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1763 | + $data['noarchive'] = true; |
|
| 1764 | + } |
|
| 1765 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1766 | + $SI->add($data); |
|
| 1767 | + } |
|
| 1314 | 1768 | } |
| 1315 | 1769 | } elseif ($format == 'ais') { |
| 1316 | 1770 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1317 | 1771 | $data = array(); |
| 1318 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1319 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1320 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1321 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1322 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1323 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1324 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1325 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1326 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1327 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1328 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1329 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1330 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1331 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1332 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1333 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1772 | + if (isset($ais_data['ident'])) { |
|
| 1773 | + $data['ident'] = $ais_data['ident']; |
|
| 1774 | + } |
|
| 1775 | + if (isset($ais_data['mmsi'])) { |
|
| 1776 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 1777 | + } |
|
| 1778 | + if (isset($ais_data['speed'])) { |
|
| 1779 | + $data['speed'] = $ais_data['speed']; |
|
| 1780 | + } |
|
| 1781 | + if (isset($ais_data['heading'])) { |
|
| 1782 | + $data['heading'] = $ais_data['heading']; |
|
| 1783 | + } |
|
| 1784 | + if (isset($ais_data['latitude'])) { |
|
| 1785 | + $data['latitude'] = $ais_data['latitude']; |
|
| 1786 | + } |
|
| 1787 | + if (isset($ais_data['longitude'])) { |
|
| 1788 | + $data['longitude'] = $ais_data['longitude']; |
|
| 1789 | + } |
|
| 1790 | + if (isset($ais_data['status'])) { |
|
| 1791 | + $data['status'] = $ais_data['status']; |
|
| 1792 | + } |
|
| 1793 | + if (isset($ais_data['statusid'])) { |
|
| 1794 | + $data['status_id'] = $ais_data['statusid']; |
|
| 1795 | + } |
|
| 1796 | + if (isset($ais_data['type'])) { |
|
| 1797 | + $data['type'] = $ais_data['type']; |
|
| 1798 | + } |
|
| 1799 | + if (isset($ais_data['imo'])) { |
|
| 1800 | + $data['imo'] = $ais_data['imo']; |
|
| 1801 | + } |
|
| 1802 | + if (isset($ais_data['callsign'])) { |
|
| 1803 | + $data['callsign'] = $ais_data['callsign']; |
|
| 1804 | + } |
|
| 1805 | + if (isset($ais_data['destination'])) { |
|
| 1806 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 1807 | + } |
|
| 1808 | + if (isset($ais_data['eta_ts'])) { |
|
| 1809 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1810 | + } |
|
| 1811 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1812 | + $data['noarchive'] = true; |
|
| 1813 | + } |
|
| 1814 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1815 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1816 | + } |
|
| 1817 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1818 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1819 | + } |
|
| 1334 | 1820 | |
| 1335 | 1821 | if (isset($ais_data['timestamp'])) { |
| 1336 | 1822 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1339,7 +1825,9 @@ discard block |
||
| 1339 | 1825 | } |
| 1340 | 1826 | $data['format_source'] = 'aisnmea'; |
| 1341 | 1827 | $data['id_source'] = $id_source; |
| 1342 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1828 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 1829 | + $MI->add($data); |
|
| 1830 | + } |
|
| 1343 | 1831 | unset($data); |
| 1344 | 1832 | } elseif ($format == 'flightgearsp') { |
| 1345 | 1833 | //echo $buffer."\n"; |
@@ -1357,12 +1845,18 @@ discard block |
||
| 1357 | 1845 | $data['speed'] = round($line[5]*1.94384); |
| 1358 | 1846 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1359 | 1847 | $data['format_source'] = 'flightgearsp'; |
| 1360 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1361 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1848 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1849 | + $data['noarchive'] = true; |
|
| 1850 | + } |
|
| 1851 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1852 | + $SI->add($data); |
|
| 1853 | + } |
|
| 1362 | 1854 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1363 | 1855 | } |
| 1364 | 1856 | } elseif ($format == 'acars') { |
| 1365 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1857 | + if ($globalDebug) { |
|
| 1858 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1859 | + } |
|
| 1366 | 1860 | $ACARS->add(trim($buffer)); |
| 1367 | 1861 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1368 | 1862 | $ACARS->deleteLiveAcarsData(); |
@@ -1383,8 +1877,12 @@ discard block |
||
| 1383 | 1877 | $aircraft_type = $line[10]; |
| 1384 | 1878 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1385 | 1879 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1386 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1387 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1880 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1881 | + $data['noarchive'] = true; |
|
| 1882 | + } |
|
| 1883 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1884 | + $SI->add($data); |
|
| 1885 | + } |
|
| 1388 | 1886 | } |
| 1389 | 1887 | } |
| 1390 | 1888 | } elseif ($format == 'beast') { |
@@ -1394,28 +1892,62 @@ discard block |
||
| 1394 | 1892 | foreach($buffer as $all_data) { |
| 1395 | 1893 | $line = json_decode('{'.$all_data.'}',true); |
| 1396 | 1894 | $data = array(); |
| 1397 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1398 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1399 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1400 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1401 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1402 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1403 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1895 | + if (isset($line['Icao'])) { |
|
| 1896 | + $data['hex'] = $line['Icao']; |
|
| 1897 | + } |
|
| 1898 | + // hex |
|
| 1899 | + if (isset($line['Call'])) { |
|
| 1900 | + $data['ident'] = $line['Call']; |
|
| 1901 | + } |
|
| 1902 | + // ident |
|
| 1903 | + if (isset($line['Alt'])) { |
|
| 1904 | + $data['altitude'] = $line['Alt']; |
|
| 1905 | + } |
|
| 1906 | + // altitude |
|
| 1907 | + if (isset($line['Spd'])) { |
|
| 1908 | + $data['speed'] = $line['Spd']; |
|
| 1909 | + } |
|
| 1910 | + // speed |
|
| 1911 | + if (isset($line['Trak'])) { |
|
| 1912 | + $data['heading'] = $line['Trak']; |
|
| 1913 | + } |
|
| 1914 | + // heading |
|
| 1915 | + if (isset($line['Lat'])) { |
|
| 1916 | + $data['latitude'] = $line['Lat']; |
|
| 1917 | + } |
|
| 1918 | + // lat |
|
| 1919 | + if (isset($line['Long'])) { |
|
| 1920 | + $data['longitude'] = $line['Long']; |
|
| 1921 | + } |
|
| 1922 | + // long |
|
| 1404 | 1923 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1405 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1924 | + if (isset($line['Sqk'])) { |
|
| 1925 | + $data['squawk'] = $line['Sqk']; |
|
| 1926 | + } |
|
| 1927 | + // squawk |
|
| 1406 | 1928 | $data['emergency'] = ''; // emergency |
| 1407 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1929 | + if (isset($line['Reg'])) { |
|
| 1930 | + $data['registration'] = $line['Reg']; |
|
| 1931 | + } |
|
| 1408 | 1932 | /* |
| 1409 | 1933 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1410 | 1934 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1411 | 1935 | */ |
| 1412 | 1936 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1413 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1937 | + if (isset($line['Type'])) { |
|
| 1938 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1939 | + } |
|
| 1414 | 1940 | $data['format_source'] = 'vrstcp'; |
| 1415 | 1941 | $data['id_source'] = $id_source; |
| 1416 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1417 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1418 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 1942 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1943 | + $data['noarchive'] = true; |
|
| 1944 | + } |
|
| 1945 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1946 | + $data['source_name'] = $value['name']; |
|
| 1947 | + } |
|
| 1948 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 1949 | + $SI->add($data); |
|
| 1950 | + } |
|
| 1419 | 1951 | unset($data); |
| 1420 | 1952 | } |
| 1421 | 1953 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1428,22 +1960,46 @@ discard block |
||
| 1428 | 1960 | $data['hex'] = $lined['hexid']; |
| 1429 | 1961 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1430 | 1962 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1431 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1432 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1433 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1434 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1435 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1436 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1437 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1963 | + if (isset($lined['ident'])) { |
|
| 1964 | + $data['ident'] = $lined['ident']; |
|
| 1965 | + } |
|
| 1966 | + if (isset($lined['lat'])) { |
|
| 1967 | + $data['latitude'] = $lined['lat']; |
|
| 1968 | + } |
|
| 1969 | + if (isset($lined['lon'])) { |
|
| 1970 | + $data['longitude'] = $lined['lon']; |
|
| 1971 | + } |
|
| 1972 | + if (isset($lined['speed'])) { |
|
| 1973 | + $data['speed'] = $lined['speed']; |
|
| 1974 | + } |
|
| 1975 | + if (isset($lined['squawk'])) { |
|
| 1976 | + $data['squawk'] = $lined['squawk']; |
|
| 1977 | + } |
|
| 1978 | + if (isset($lined['alt'])) { |
|
| 1979 | + $data['altitude'] = $lined['alt']; |
|
| 1980 | + } |
|
| 1981 | + if (isset($lined['heading'])) { |
|
| 1982 | + $data['heading'] = $lined['heading']; |
|
| 1983 | + } |
|
| 1438 | 1984 | $data['id_source'] = $id_source; |
| 1439 | 1985 | $data['format_source'] = 'tsv'; |
| 1440 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1441 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1442 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1443 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1986 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1987 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1988 | + } |
|
| 1989 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1990 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1991 | + } |
|
| 1992 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1993 | + $data['noarchive'] = true; |
|
| 1994 | + } |
|
| 1995 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1996 | + $SI->add($data); |
|
| 1997 | + } |
|
| 1444 | 1998 | unset($lined); |
| 1445 | 1999 | unset($data); |
| 1446 | - } else $error = true; |
|
| 2000 | + } else { |
|
| 2001 | + $error = true; |
|
| 2002 | + } |
|
| 1447 | 2003 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1448 | 2004 | if ($aprs_connect == 0) { |
| 1449 | 2005 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1468,62 +2024,120 @@ discard block |
||
| 1468 | 2024 | $aprs_last_tx = time(); |
| 1469 | 2025 | $data = array(); |
| 1470 | 2026 | //print_r($line); |
| 1471 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1472 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1473 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1474 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1475 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
| 1476 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
| 1477 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1478 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1479 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1480 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2027 | + if (isset($line['address'])) { |
|
| 2028 | + $data['hex'] = $line['address']; |
|
| 2029 | + } |
|
| 2030 | + if (isset($line['mmsi'])) { |
|
| 2031 | + $data['mmsi'] = $line['mmsi']; |
|
| 2032 | + } |
|
| 2033 | + if (isset($line['imo'])) { |
|
| 2034 | + $data['imo'] = $line['imo']; |
|
| 2035 | + } |
|
| 2036 | + if (isset($line['squawk'])) { |
|
| 2037 | + $data['squawk'] = $line['squawk']; |
|
| 2038 | + } |
|
| 2039 | + if (isset($line['arrival_code'])) { |
|
| 2040 | + $data['arrical_code'] = $line['arrival_code']; |
|
| 2041 | + } |
|
| 2042 | + if (isset($line['arrival_date'])) { |
|
| 2043 | + $data['arrical_date'] = $line['arrival_date']; |
|
| 2044 | + } |
|
| 2045 | + if (isset($line['type_id'])) { |
|
| 2046 | + $data['type_id'] = $line['typeid']; |
|
| 2047 | + } |
|
| 2048 | + if (isset($line['status_id'])) { |
|
| 2049 | + $data['status_id'] = $line['statusid']; |
|
| 2050 | + } |
|
| 2051 | + if (isset($line['timestamp'])) { |
|
| 2052 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 2053 | + } else { |
|
| 2054 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2055 | + } |
|
| 1481 | 2056 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1482 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 2057 | + if (isset($line['ident'])) { |
|
| 2058 | + $data['ident'] = $line['ident']; |
|
| 2059 | + } |
|
| 1483 | 2060 | $data['latitude'] = $line['latitude']; |
| 1484 | 2061 | $data['longitude'] = $line['longitude']; |
| 1485 | 2062 | //$data['verticalrate'] = $line[16]; |
| 1486 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 2063 | + if (isset($line['speed'])) { |
|
| 2064 | + $data['speed'] = $line['speed']; |
|
| 2065 | + } |
|
| 1487 | 2066 | //else $data['speed'] = 0; |
| 1488 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1489 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1490 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 2067 | + if (isset($line['altitude'])) { |
|
| 2068 | + $data['altitude'] = $line['altitude']; |
|
| 2069 | + } |
|
| 2070 | + if (isset($line['comment'])) { |
|
| 2071 | + $data['comment'] = $line['comment']; |
|
| 2072 | + } |
|
| 2073 | + if (isset($line['symbol'])) { |
|
| 2074 | + $data['type'] = $line['symbol']; |
|
| 2075 | + } |
|
| 1491 | 2076 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
| 1492 | 2077 | |
| 1493 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 2078 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
| 2079 | + $data['heading'] = $line['heading']; |
|
| 2080 | + } |
|
| 1494 | 2081 | //else echo 'No heading...'."\n"; |
| 1495 | 2082 | //else $data['heading'] = 0; |
| 1496 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 2083 | + if (isset($line['stealth'])) { |
|
| 2084 | + $data['aircraft_type'] = $line['stealth']; |
|
| 2085 | + } |
|
| 1497 | 2086 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1498 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1499 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1500 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1501 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 2087 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 2088 | + $data['noarchive'] = true; |
|
| 2089 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 2090 | + $data['noarchive'] = false; |
|
| 2091 | + } |
|
| 2092 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2093 | + $data['noarchive'] = true; |
|
| 2094 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 2095 | + $data['noarchive'] = false; |
|
| 2096 | + } |
|
| 1502 | 2097 | $data['id_source'] = $id_source; |
| 1503 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1504 | - else $data['format_source'] = 'aprs'; |
|
| 2098 | + if (isset($line['format_source'])) { |
|
| 2099 | + $data['format_source'] = $line['format_source']; |
|
| 2100 | + } else { |
|
| 2101 | + $data['format_source'] = 'aprs'; |
|
| 2102 | + } |
|
| 1505 | 2103 | $data['source_name'] = $line['source']; |
| 1506 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1507 | - else $data['source_type'] = 'flarm'; |
|
| 1508 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2104 | + if (isset($line['source_type'])) { |
|
| 2105 | + $data['source_type'] = $line['source_type']; |
|
| 2106 | + } else { |
|
| 2107 | + $data['source_type'] = 'flarm'; |
|
| 2108 | + } |
|
| 2109 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2110 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2111 | + } |
|
| 1509 | 2112 | $currentdate = date('Y-m-d H:i:s'); |
| 1510 | 2113 | $aprsdate = strtotime($data['datetime']); |
| 1511 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 2114 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
| 2115 | + $data['altitude_relative'] = 'AMSL'; |
|
| 2116 | + } |
|
| 1512 | 2117 | // Accept data if time <= system time + 20s |
| 1513 | 2118 | //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'])))) { |
| 1514 | 2119 | if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1515 | 2120 | $send = $SI->add($data); |
| 1516 | 2121 | } elseif ($data['source_type'] == 'ais') { |
| 1517 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 2122 | + if (isset($globalMarine) && $globalMarine) { |
|
| 2123 | + $send = $MI->add($data); |
|
| 2124 | + } |
|
| 1518 | 2125 | } elseif (isset($line['stealth'])) { |
| 1519 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1520 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 2126 | + if ($line['stealth'] != 0) { |
|
| 2127 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 2128 | + } else { |
|
| 2129 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 2130 | + } |
|
| 1521 | 2131 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 1522 | 2132 | //$line['symbol'] == 'Balloon' || |
| 1523 | 2133 | $line['symbol'] == 'Glider' || |
| 1524 | 2134 | $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
| 1525 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1526 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2135 | + if ($line['symbol'] == 'Ballon') { |
|
| 2136 | + $data['aircraft_icao'] = 'BALL'; |
|
| 2137 | + } |
|
| 2138 | + if ($line['symbol'] == 'Glider') { |
|
| 2139 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2140 | + } |
|
| 1527 | 2141 | $send = $SI->add($data); |
| 1528 | 2142 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 1529 | 2143 | $line['symbol'] == 'Yacht (Sail)' || |
@@ -1554,9 +2168,13 @@ discard block |
||
| 1554 | 2168 | //} 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') { |
| 1555 | 2169 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 1556 | 2170 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1557 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 2171 | + if (isset($globalTracker) && $globalTracker) { |
|
| 2172 | + $send = $TI->add($data); |
|
| 2173 | + } |
|
| 1558 | 2174 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 1559 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
| 2175 | + if (!isset($data['altitude'])) { |
|
| 2176 | + $data['altitude'] = 0; |
|
| 2177 | + } |
|
| 1560 | 2178 | $Source->deleteOldLocationByType('gs'); |
| 1561 | 2179 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
| 1562 | 2180 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1565,7 +2183,9 @@ discard block |
||
| 1565 | 2183 | } |
| 1566 | 2184 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
| 1567 | 2185 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1568 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
| 2186 | + if ($globalDebug) { |
|
| 2187 | + echo '# Weather Station added'."\n"; |
|
| 2188 | + } |
|
| 1569 | 2189 | $Source->deleteOldLocationByType('wx'); |
| 1570 | 2190 | $weather_data = json_encode($line); |
| 1571 | 2191 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1575,7 +2195,9 @@ discard block |
||
| 1575 | 2195 | } |
| 1576 | 2196 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
| 1577 | 2197 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1578 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2198 | + if ($globalDebug) { |
|
| 2199 | + echo '☈ Lightning added'."\n"; |
|
| 2200 | + } |
|
| 1579 | 2201 | $Source->deleteOldLocationByType('lightning'); |
| 1580 | 2202 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
| 1581 | 2203 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1587,8 +2209,7 @@ discard block |
||
| 1587 | 2209 | print_r($line); |
| 1588 | 2210 | } |
| 1589 | 2211 | unset($data); |
| 1590 | - } |
|
| 1591 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2212 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 1592 | 2213 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 1593 | 2214 | } |
| 1594 | 2215 | /* |
@@ -1597,7 +2218,9 @@ discard block |
||
| 1597 | 2218 | } |
| 1598 | 2219 | */ |
| 1599 | 2220 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1600 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 2221 | + elseif ($line == true && $globalDebug) { |
|
| 2222 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2223 | + } |
|
| 1601 | 2224 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
| 1602 | 2225 | $Source->deleteOldLocationByType('lightning'); |
| 1603 | 2226 | $Source->deleteOldLocationByType('wx'); |
@@ -1633,26 +2256,45 @@ discard block |
||
| 1633 | 2256 | $data['ground'] = $line[21]; |
| 1634 | 2257 | $data['emergency'] = $line[19]; |
| 1635 | 2258 | $data['format_source'] = 'sbs'; |
| 1636 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1637 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1638 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2259 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2260 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2261 | + } |
|
| 2262 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2263 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2264 | + } |
|
| 2265 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2266 | + $data['noarchive'] = true; |
|
| 2267 | + } |
|
| 1639 | 2268 | $data['id_source'] = $id_source; |
| 1640 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1641 | - else $error = true; |
|
| 2269 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2270 | + $send = $SI->add($data); |
|
| 2271 | + } else { |
|
| 2272 | + $error = true; |
|
| 2273 | + } |
|
| 1642 | 2274 | unset($data); |
| 1643 | - } else $error = true; |
|
| 2275 | + } else { |
|
| 2276 | + $error = true; |
|
| 2277 | + } |
|
| 1644 | 2278 | if ($error) { |
| 1645 | 2279 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1646 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2280 | + if ($globalDebug) { |
|
| 2281 | + echo "Not a message. Ignoring... \n"; |
|
| 2282 | + } |
|
| 1647 | 2283 | } else { |
| 1648 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2284 | + if ($globalDebug) { |
|
| 2285 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2286 | + } |
|
| 1649 | 2287 | if ($globalDebug) { |
| 1650 | 2288 | echo $buffer; |
| 1651 | 2289 | //print_r($line); |
| 1652 | 2290 | } |
| 1653 | 2291 | //socket_close($r); |
| 1654 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1655 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 2292 | + if ($globalDebug) { |
|
| 2293 | + echo "Reconnect after an error...\n"; |
|
| 2294 | + } |
|
| 2295 | + if ($format == 'aprs') { |
|
| 2296 | + $aprs_connect = 0; |
|
| 2297 | + } |
|
| 1656 | 2298 | $sourceer[$nb] = $globalSources[$nb]; |
| 1657 | 2299 | connect_all($sourceer); |
| 1658 | 2300 | $sourceer = array(); |
@@ -1660,10 +2302,14 @@ discard block |
||
| 1660 | 2302 | } |
| 1661 | 2303 | } |
| 1662 | 2304 | // Sleep for xxx microseconds |
| 1663 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2305 | + if (isset($globalSBSSleep)) { |
|
| 2306 | + usleep($globalSBSSleep); |
|
| 2307 | + } |
|
| 1664 | 2308 | } else { |
| 1665 | 2309 | if ($format == 'flightgearmp') { |
| 1666 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2310 | + if ($globalDebug) { |
|
| 2311 | + echo "Reconnect FlightGear MP..."; |
|
| 2312 | + } |
|
| 1667 | 2313 | //@socket_close($r); |
| 1668 | 2314 | sleep($globalMinFetch); |
| 1669 | 2315 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1672,10 +2318,15 @@ discard block |
||
| 1672 | 2318 | break; |
| 1673 | 2319 | |
| 1674 | 2320 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1675 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1676 | - else $tt[$format] = 0; |
|
| 2321 | + if (isset($tt[$format])) { |
|
| 2322 | + $tt[$format]++; |
|
| 2323 | + } else { |
|
| 2324 | + $tt[$format] = 0; |
|
| 2325 | + } |
|
| 1677 | 2326 | if ($tt[$format] > 30) { |
| 1678 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2327 | + if ($globalDebug) { |
|
| 2328 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2329 | + } |
|
| 1679 | 2330 | //@socket_close($r); |
| 1680 | 2331 | sleep(2); |
| 1681 | 2332 | $aprs_connect = 0; |
@@ -1692,11 +2343,17 @@ discard block |
||
| 1692 | 2343 | } else { |
| 1693 | 2344 | $error = socket_strerror(socket_last_error()); |
| 1694 | 2345 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1695 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1696 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2346 | + if ($globalDebug) { |
|
| 2347 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2348 | + } |
|
| 2349 | + if (isset($globalDebug)) { |
|
| 2350 | + echo "Restarting...\n"; |
|
| 2351 | + } |
|
| 1697 | 2352 | // Restart the script if possible |
| 1698 | 2353 | if (is_array($sockets)) { |
| 1699 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2354 | + if ($globalDebug) { |
|
| 2355 | + echo "Shutdown all sockets..."; |
|
| 2356 | + } |
|
| 1700 | 2357 | |
| 1701 | 2358 | foreach ($sockets as $sock) { |
| 1702 | 2359 | @socket_shutdown($sock,2); |
@@ -1704,25 +2361,45 @@ discard block |
||
| 1704 | 2361 | } |
| 1705 | 2362 | |
| 1706 | 2363 | } |
| 1707 | - if ($globalDebug) echo "Waiting..."; |
|
| 2364 | + if ($globalDebug) { |
|
| 2365 | + echo "Waiting..."; |
|
| 2366 | + } |
|
| 1708 | 2367 | sleep(2); |
| 1709 | 2368 | $time = time(); |
| 1710 | 2369 | //connect_all($hosts); |
| 1711 | 2370 | $aprs_connect = 0; |
| 1712 | - if ($reset%5 == 0) sleep(20); |
|
| 1713 | - if ($reset%10 == 0) sleep(100); |
|
| 1714 | - if ($reset%20 == 0) sleep(200); |
|
| 1715 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 1716 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 2371 | + if ($reset%5 == 0) { |
|
| 2372 | + sleep(20); |
|
| 2373 | + } |
|
| 2374 | + if ($reset%10 == 0) { |
|
| 2375 | + sleep(100); |
|
| 2376 | + } |
|
| 2377 | + if ($reset%20 == 0) { |
|
| 2378 | + sleep(200); |
|
| 2379 | + } |
|
| 2380 | + if ($reset > 100) { |
|
| 2381 | + exit('Too many attempts...'); |
|
| 2382 | + } |
|
| 2383 | + if ($globalDebug) { |
|
| 2384 | + echo "Restart all connections..."; |
|
| 2385 | + } |
|
| 1717 | 2386 | connect_all($globalSources); |
| 1718 | 2387 | } |
| 1719 | 2388 | } |
| 1720 | 2389 | } |
| 1721 | 2390 | if ($globalDaemon === false) { |
| 1722 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1723 | - if (isset($SI)) $SI->checkAll(); |
|
| 1724 | - if (isset($TI)) $TI->checkAll(); |
|
| 1725 | - if (isset($MI)) $MI->checkAll(); |
|
| 2391 | + if ($globalDebug) { |
|
| 2392 | + echo 'Check all...'."\n"; |
|
| 2393 | + } |
|
| 2394 | + if (isset($SI)) { |
|
| 2395 | + $SI->checkAll(); |
|
| 2396 | + } |
|
| 2397 | + if (isset($TI)) { |
|
| 2398 | + $TI->checkAll(); |
|
| 2399 | + } |
|
| 2400 | + if (isset($MI)) { |
|
| 2401 | + $MI->checkAll(); |
|
| 2402 | + } |
|
| 1726 | 2403 | } |
| 1727 | 2404 | } |
| 1728 | 2405 | } |