@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 25 | +if (!isset($globalDebug)) { |
|
| 26 | + $globalDebug = FALSE; |
|
| 27 | +} |
|
| 26 | 28 | |
| 27 | 29 | if ($globalInstalled === FALSE) { |
| 28 | 30 | echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
@@ -68,66 +70,107 @@ discard block |
||
| 68 | 70 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 69 | 71 | if (isset($options['s'])) { |
| 70 | 72 | $globalSources = array(); |
| 71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 72 | - else $globalSources[] = array('host' => $options['s']); |
|
| 73 | -} elseif (isset($options['source'])) { |
|
| 73 | + if (isset($options['format'])) { |
|
| 74 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 75 | + } else { |
|
| 76 | + $globalSources[] = array('host' => $options['s']); |
|
| 77 | + } |
|
| 78 | + } elseif (isset($options['source'])) { |
|
| 74 | 79 | $globalSources = array(); |
| 75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 76 | - else $globalSources[] = array('host' => $options['source']); |
|
| 77 | -} |
|
| 80 | + if (isset($options['format'])) { |
|
| 81 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 82 | + } else { |
|
| 83 | + $globalSources[] = array('host' => $options['source']); |
|
| 84 | + } |
|
| 85 | + } |
|
| 78 | 86 | if (isset($options['aprsserverhost'])) { |
| 79 | 87 | $globalServerAPRS = TRUE; |
| 80 | 88 | $globalServerAPRShost = $options['aprsserverhost']; |
| 81 | 89 | } |
| 82 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 83 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 84 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 85 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 90 | +if (isset($options['aprsserverport'])) { |
|
| 91 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 92 | +} |
|
| 93 | +if (isset($options['aprsserverssid'])) { |
|
| 94 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 95 | +} |
|
| 96 | +if (isset($options['aprsserverpass'])) { |
|
| 97 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 98 | +} |
|
| 99 | +if (isset($options['noaprsserver'])) { |
|
| 100 | + $globalServerAPRS = FALSE; |
|
| 101 | +} |
|
| 86 | 102 | if (isset($options['enable-aircraft'])) { |
| 87 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
| 103 | + if ($globalDebug) { |
|
| 104 | + echo 'Enable Aircraft mode'."\n"; |
|
| 105 | + } |
|
| 88 | 106 | $globalAircraft = TRUE; |
| 89 | 107 | } |
| 90 | 108 | if (isset($options['disable-aircraft'])) { |
| 91 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
| 109 | + if ($globalDebug) { |
|
| 110 | + echo 'Disable Aircraft mode'."\n"; |
|
| 111 | + } |
|
| 92 | 112 | $globalAircraft = FALSE; |
| 93 | 113 | } |
| 94 | 114 | if (isset($options['enable-tracker'])) { |
| 95 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
| 115 | + if ($globalDebug) { |
|
| 116 | + echo 'Enable Tracker mode'."\n"; |
|
| 117 | + } |
|
| 96 | 118 | $globalTracker = TRUE; |
| 97 | 119 | } |
| 98 | 120 | if (isset($options['disable-tracker'])) { |
| 99 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
| 121 | + if ($globalDebug) { |
|
| 122 | + echo 'Disable Tracker mode'."\n"; |
|
| 123 | + } |
|
| 100 | 124 | $globalTracker = FALSE; |
| 101 | 125 | } |
| 102 | 126 | if (isset($options['enable-marine'])) { |
| 103 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
| 127 | + if ($globalDebug) { |
|
| 128 | + echo 'Enable Marine mode'."\n"; |
|
| 129 | + } |
|
| 104 | 130 | $globalMarine = TRUE; |
| 105 | 131 | } |
| 106 | 132 | if (isset($options['disable-marine'])) { |
| 107 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
| 133 | + if ($globalDebug) { |
|
| 134 | + echo 'Disable Marine mode'."\n"; |
|
| 135 | + } |
|
| 108 | 136 | $globalMarine = FALSE; |
| 109 | 137 | } |
| 110 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 111 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 112 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 113 | -else $id_source = 1; |
|
| 138 | +if (isset($options['nodaemon'])) { |
|
| 139 | + $globalDaemon = FALSE; |
|
| 140 | +} |
|
| 141 | +if (isset($options['server'])) { |
|
| 142 | + $globalServer = TRUE; |
|
| 143 | +} |
|
| 144 | +if (isset($options['idsource'])) { |
|
| 145 | + $id_source = $options['idsource']; |
|
| 146 | +} else { |
|
| 147 | + $id_source = 1; |
|
| 148 | +} |
|
| 114 | 149 | if (isset($globalServer) && $globalServer) { |
| 115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 150 | + if ($globalDebug) { |
|
| 151 | + echo "Using Server Mode\n"; |
|
| 152 | + } |
|
| 116 | 153 | $SI=new SpotterServer(); |
| 117 | 154 | /* |
| 118 | 155 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 119 | 156 | $SI = new adsb2aprs(); |
| 120 | 157 | $SI->connect(); |
| 121 | 158 | */ |
| 122 | -} else $SI=new SpotterImport($Connection->db); |
|
| 159 | +} else { |
|
| 160 | + $SI=new SpotterImport($Connection->db); |
|
| 161 | +} |
|
| 123 | 162 | |
| 124 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 163 | +if (isset($globalTracker) && $globalTracker) { |
|
| 164 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 165 | +} |
|
| 125 | 166 | if (isset($globalMarine) && $globalMarine) { |
| 126 | 167 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 127 | 168 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 128 | 169 | } |
| 129 | 170 | |
| 130 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 171 | +if (isset($globalTracker) && $globalTracker) { |
|
| 172 | + $TI = new TrackerImport($Connection->db); |
|
| 173 | +} |
|
| 131 | 174 | if (isset($globalMarine) && $globalMarine) { |
| 132 | 175 | $AIS = new AIS(); |
| 133 | 176 | $MI = new MarineImport($Connection->db); |
@@ -152,7 +195,9 @@ discard block |
||
| 152 | 195 | } |
| 153 | 196 | |
| 154 | 197 | // let's try and connect |
| 155 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 198 | +if ($globalDebug) { |
|
| 199 | + echo "Connecting...\n"; |
|
| 200 | +} |
|
| 156 | 201 | $use_aprs = false; |
| 157 | 202 | $aprs_full = false; |
| 158 | 203 | $reset = 0; |
@@ -161,7 +206,9 @@ discard block |
||
| 161 | 206 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 162 | 207 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 163 | 208 | $reset++; |
| 164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 209 | + if ($globalDebug) { |
|
| 210 | + echo 'Connect to all...'."\n"; |
|
| 211 | + } |
|
| 165 | 212 | foreach ($hosts as $id => $value) { |
| 166 | 213 | $host = $value['host']; |
| 167 | 214 | $globalSources[$id]['last_exec'] = 0; |
@@ -171,32 +218,44 @@ discard block |
||
| 171 | 218 | //$formats[$id] = 'deltadbtxt'; |
| 172 | 219 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 173 | 220 | //$last_exec['deltadbtxt'] = 0; |
| 174 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 221 | + if ($globalDebug) { |
|
| 222 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 223 | + } |
|
| 175 | 224 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 176 | 225 | //$formats[$id] = 'vatsimtxt'; |
| 177 | 226 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 178 | 227 | //$last_exec['vatsimtxt'] = 0; |
| 179 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 228 | + if ($globalDebug) { |
|
| 229 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 230 | + } |
|
| 180 | 231 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 181 | 232 | //$formats[$id] = 'aircraftlistjson'; |
| 182 | 233 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 183 | 234 | //$last_exec['aircraftlistjson'] = 0; |
| 184 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 235 | + if ($globalDebug) { |
|
| 236 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 237 | + } |
|
| 185 | 238 | } else if (preg_match('/aircraft.json$/i',$host)) { |
| 186 | 239 | //$formats[$id] = 'aircraftjson'; |
| 187 | 240 | $globalSources[$id]['format'] = 'aircraftjson'; |
| 188 | 241 | //$last_exec['aircraftlistjson'] = 0; |
| 189 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 242 | + if ($globalDebug) { |
|
| 243 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 244 | + } |
|
| 190 | 245 | } else if (preg_match('/aircraft$/i',$host)) { |
| 191 | 246 | //$formats[$id] = 'planefinderclient'; |
| 192 | 247 | $globalSources[$id]['format'] = 'planefinderclient'; |
| 193 | 248 | //$last_exec['aircraftlistjson'] = 0; |
| 194 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 249 | + if ($globalDebug) { |
|
| 250 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 251 | + } |
|
| 195 | 252 | } else if (preg_match('/opensky/i',$host)) { |
| 196 | 253 | //$formats[$id] = 'aircraftlistjson'; |
| 197 | 254 | $globalSources[$id]['format'] = 'opensky'; |
| 198 | 255 | //$last_exec['aircraftlistjson'] = 0; |
| 199 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 256 | + if ($globalDebug) { |
|
| 257 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 258 | + } |
|
| 200 | 259 | /* |
| 201 | 260 | // Disabled for now, site change source format |
| 202 | 261 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -213,7 +272,9 @@ discard block |
||
| 213 | 272 | //$formats[$id] = 'planeupdatefaa'; |
| 214 | 273 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 215 | 274 | //$last_exec['planeupdatefaa'] = 0; |
| 216 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 275 | + if ($globalDebug) { |
|
| 276 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 277 | + } |
|
| 217 | 278 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 218 | 279 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 219 | 280 | exit(0); |
@@ -222,37 +283,53 @@ discard block |
||
| 222 | 283 | //$formats[$id] = 'phpvmacars'; |
| 223 | 284 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 224 | 285 | //$last_exec['phpvmacars'] = 0; |
| 225 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 286 | + if ($globalDebug) { |
|
| 287 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 288 | + } |
|
| 226 | 289 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
| 227 | 290 | //$formats[$id] = 'phpvmacars'; |
| 228 | 291 | $globalSources[$id]['format'] = 'vaos'; |
| 229 | 292 | //$last_exec['phpvmacars'] = 0; |
| 230 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 293 | + if ($globalDebug) { |
|
| 294 | + echo "Connect to vaos source (".$host.")...\n"; |
|
| 295 | + } |
|
| 231 | 296 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 232 | 297 | //$formats[$id] = 'phpvmacars'; |
| 233 | 298 | $globalSources[$id]['format'] = 'vam'; |
| 234 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 299 | + if ($globalDebug) { |
|
| 300 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 301 | + } |
|
| 235 | 302 | } else if (preg_match('/whazzup/i',$host)) { |
| 236 | 303 | //$formats[$id] = 'whazzup'; |
| 237 | 304 | $globalSources[$id]['format'] = 'whazzup'; |
| 238 | 305 | //$last_exec['whazzup'] = 0; |
| 239 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 306 | + if ($globalDebug) { |
|
| 307 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 308 | + } |
|
| 240 | 309 | } else if (preg_match('/blitzortung/i',$host)) { |
| 241 | 310 | $globalSources[$id]['format'] = 'blitzortung'; |
| 242 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 311 | + if ($globalDebug) { |
|
| 312 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 313 | + } |
|
| 243 | 314 | } else if (preg_match('/airwhere/i',$host)) { |
| 244 | 315 | $globalSources[$id]['format'] = 'airwhere'; |
| 245 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 316 | + if ($globalDebug) { |
|
| 317 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 318 | + } |
|
| 246 | 319 | } else if (preg_match('/recentpireps/i',$host)) { |
| 247 | 320 | //$formats[$id] = 'pirepsjson'; |
| 248 | 321 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 249 | 322 | //$last_exec['pirepsjson'] = 0; |
| 250 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 323 | + if ($globalDebug) { |
|
| 324 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 325 | + } |
|
| 251 | 326 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 252 | 327 | //$formats[$id] = 'fr24json'; |
| 253 | 328 | $globalSources[$id]['format'] = 'fr24json'; |
| 254 | 329 | //$last_exec['fr24json'] = 0; |
| 255 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 330 | + if ($globalDebug) { |
|
| 331 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 332 | + } |
|
| 256 | 333 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 257 | 334 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 258 | 335 | exit(0); |
@@ -261,7 +338,9 @@ discard block |
||
| 261 | 338 | //$formats[$id] = 'fr24json'; |
| 262 | 339 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 263 | 340 | //$last_exec['fr24json'] = 0; |
| 264 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 341 | + if ($globalDebug) { |
|
| 342 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 343 | + } |
|
| 265 | 344 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 266 | 345 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 267 | 346 | exit(0); |
@@ -270,17 +349,26 @@ discard block |
||
| 270 | 349 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 271 | 350 | //$formats[$id] = 'tsv'; |
| 272 | 351 | $globalSources[$id]['format'] = 'tsv'; |
| 273 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 352 | + if ($globalDebug) { |
|
| 353 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 354 | + } |
|
| 274 | 355 | } |
| 275 | 356 | } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
| 276 | 357 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
| 277 | 358 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 278 | 359 | if ($idf !== false) { |
| 279 | 360 | $httpfeeds[$id] = $idf; |
| 280 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 281 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 282 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 283 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 361 | + if ($globalDebug) { |
|
| 362 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 363 | + } |
|
| 364 | + } elseif ($globalDebug) { |
|
| 365 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 366 | + } |
|
| 367 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { |
|
| 368 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 369 | + } elseif ($globalDebug) { |
|
| 370 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 371 | + } |
|
| 284 | 372 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 285 | 373 | $hostport = explode(':',$host); |
| 286 | 374 | if (isset($hostport[1])) { |
@@ -320,19 +408,27 @@ discard block |
||
| 320 | 408 | //$formats[$id] = 'beast'; |
| 321 | 409 | $globalSources[$id]['format'] = 'beast'; |
| 322 | 410 | //} else $formats[$id] = 'sbs'; |
| 323 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 411 | + } else { |
|
| 412 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 413 | + } |
|
| 324 | 414 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 325 | 415 | } |
| 326 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 416 | + if ($globalDebug) { |
|
| 417 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 418 | + } |
|
| 327 | 419 | } else { |
| 328 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 420 | + if ($globalDebug) { |
|
| 421 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 422 | + } |
|
| 329 | 423 | sleep(10); |
| 330 | 424 | connect_all($hosts); |
| 331 | 425 | } |
| 332 | 426 | } |
| 333 | 427 | } |
| 334 | 428 | } |
| 335 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 429 | +if (!isset($globalMinFetch)) { |
|
| 430 | + $globalMinFetch = 15; |
|
| 431 | +} |
|
| 336 | 432 | |
| 337 | 433 | // Initialize all |
| 338 | 434 | $status = array(); |
@@ -341,13 +437,19 @@ discard block |
||
| 341 | 437 | $formats = array(); |
| 342 | 438 | $last_exec = array(); |
| 343 | 439 | $time = time(); |
| 344 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 345 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 346 | -else $timeout = 20; |
|
| 440 | +if (isset($globalSourcesTimeout)) { |
|
| 441 | + $timeout = $globalSourcesTimeOut; |
|
| 442 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 443 | + $timeout = $globalSBS1TimeOut; |
|
| 444 | +} else { |
|
| 445 | + $timeout = 20; |
|
| 446 | +} |
|
| 347 | 447 | $errno = ''; |
| 348 | 448 | $errstr=''; |
| 349 | 449 | |
| 350 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 450 | +if (!isset($globalDaemon)) { |
|
| 451 | + $globalDaemon = TRUE; |
|
| 452 | +} |
|
| 351 | 453 | /* Initiate connections to all the hosts simultaneously */ |
| 352 | 454 | //connect_all($hosts); |
| 353 | 455 | //connect_all($globalSources); |
@@ -376,7 +478,9 @@ discard block |
||
| 376 | 478 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 377 | 479 | $aprs_connect = 0; |
| 378 | 480 | $use_aprs = true; |
| 379 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 481 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 482 | + $aprs_full = true; |
|
| 483 | + } |
|
| 380 | 484 | break; |
| 381 | 485 | } |
| 382 | 486 | } |
@@ -387,25 +491,46 @@ discard block |
||
| 387 | 491 | $aprs_connect = 0; |
| 388 | 492 | $aprs_keep = 120; |
| 389 | 493 | $aprs_last_tx = time(); |
| 390 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 391 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 392 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 393 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 394 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 395 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 396 | - if ($aprs_full) $aprs_filter = ''; |
|
| 397 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 398 | - else $aprs_pass = '-1'; |
|
| 494 | + if (isset($globalAPRSversion)) { |
|
| 495 | + $aprs_version = $globalAPRSversion; |
|
| 496 | + } else { |
|
| 497 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 498 | + } |
|
| 499 | + if (isset($globalAPRSssid)) { |
|
| 500 | + $aprs_ssid = $globalAPRSssid; |
|
| 501 | + } else { |
|
| 502 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 503 | + } |
|
| 504 | + if (isset($globalAPRSfilter)) { |
|
| 505 | + $aprs_filter = $globalAPRSfilter; |
|
| 506 | + } else { |
|
| 507 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 508 | + } |
|
| 509 | + if ($aprs_full) { |
|
| 510 | + $aprs_filter = ''; |
|
| 511 | + } |
|
| 512 | + if (isset($globalAPRSpass)) { |
|
| 513 | + $aprs_pass = $globalAPRSpass; |
|
| 514 | + } else { |
|
| 515 | + $aprs_pass = '-1'; |
|
| 516 | + } |
|
| 399 | 517 | |
| 400 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 401 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 402 | -} |
|
| 518 | + if ($aprs_filter != '') { |
|
| 519 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 520 | + } else { |
|
| 521 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 522 | + } |
|
| 523 | + } |
|
| 403 | 524 | |
| 404 | 525 | // connected - lets do some work |
| 405 | 526 | //if ($globalDebug) echo "Connected!\n"; |
| 406 | 527 | sleep(1); |
| 407 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 408 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 528 | +if ($globalDebug) { |
|
| 529 | + echo "SCAN MODE \n\n"; |
|
| 530 | +} |
|
| 531 | +if (!isset($globalCronEnd)) { |
|
| 532 | + $globalCronEnd = 60; |
|
| 533 | +} |
|
| 409 | 534 | $endtime = time()+$globalCronEnd; |
| 410 | 535 | $i = 1; |
| 411 | 536 | $tt = array(); |
@@ -419,22 +544,32 @@ discard block |
||
| 419 | 544 | |
| 420 | 545 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 421 | 546 | while ($i > 0) { |
| 422 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 547 | + if (function_exists('pcntl_fork')) { |
|
| 548 | + pcntl_signal_dispatch(); |
|
| 549 | + } |
|
| 423 | 550 | |
| 424 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 551 | + if (!$globalDaemon) { |
|
| 552 | + $i = $endtime-time(); |
|
| 553 | + } |
|
| 425 | 554 | // Delete old ATC |
| 426 | 555 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 427 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 556 | + if ($globalDebug) { |
|
| 557 | + echo 'Delete old ATC...'."\n"; |
|
| 558 | + } |
|
| 428 | 559 | $ATC->deleteOldATC(); |
| 429 | 560 | } |
| 430 | 561 | |
| 431 | 562 | if (count($last_exec) == count($globalSources)) { |
| 432 | 563 | $max = $globalMinFetch; |
| 433 | 564 | foreach ($last_exec as $last) { |
| 434 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 565 | + if ((time() - $last['last']) < $max) { |
|
| 566 | + $max = time() - $last['last']; |
|
| 567 | + } |
|
| 435 | 568 | } |
| 436 | 569 | if ($max < $globalMinFetch) { |
| 437 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 570 | + if ($globalDebug) { |
|
| 571 | + echo 'Sleeping...'."\n"; |
|
| 572 | + } |
|
| 438 | 573 | sleep($globalMinFetch-$max+2); |
| 439 | 574 | } |
| 440 | 575 | } |
@@ -444,7 +579,9 @@ discard block |
||
| 444 | 579 | foreach ($globalSources as $id => $value) { |
| 445 | 580 | date_default_timezone_set('UTC'); |
| 446 | 581 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 447 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 582 | + if (!isset($last_exec[$id]['last'])) { |
|
| 583 | + $last_exec[$id]['last'] = 0; |
|
| 584 | + } |
|
| 448 | 585 | if ($value['format'] === 'deltadbtxt' && |
| 449 | 586 | ( |
| 450 | 587 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -453,7 +590,9 @@ discard block |
||
| 453 | 590 | ) { |
| 454 | 591 | //$buffer = $Common->getData($hosts[$id]); |
| 455 | 592 | $buffer = $Common->getData($value['host']); |
| 456 | - if ($buffer != '') $reset = 0; |
|
| 593 | + if ($buffer != '') { |
|
| 594 | + $reset = 0; |
|
| 595 | + } |
|
| 457 | 596 | $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
| 458 | 597 | $buffer = explode('\n', $buffer); |
| 459 | 598 | foreach ($buffer as $line) { |
@@ -462,20 +601,41 @@ discard block |
||
| 462 | 601 | $data = array(); |
| 463 | 602 | $data['hex'] = $line[1]; // hex |
| 464 | 603 | $data['ident'] = $line[2]; // ident |
| 465 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 466 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 467 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 468 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 469 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 604 | + if (isset($line[3])) { |
|
| 605 | + $data['altitude'] = $line[3]; |
|
| 606 | + } |
|
| 607 | + // altitude |
|
| 608 | + if (isset($line[4])) { |
|
| 609 | + $data['speed'] = $line[4]; |
|
| 610 | + } |
|
| 611 | + // speed |
|
| 612 | + if (isset($line[5])) { |
|
| 613 | + $data['heading'] = $line[5]; |
|
| 614 | + } |
|
| 615 | + // heading |
|
| 616 | + if (isset($line[6])) { |
|
| 617 | + $data['latitude'] = $line[6]; |
|
| 618 | + } |
|
| 619 | + // lat |
|
| 620 | + if (isset($line[7])) { |
|
| 621 | + $data['longitude'] = $line[7]; |
|
| 622 | + } |
|
| 623 | + // long |
|
| 470 | 624 | $data['verticalrate'] = ''; // vertical rate |
| 471 | 625 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 472 | 626 | $data['emergency'] = ''; // emergency |
| 473 | 627 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 474 | 628 | $data['format_source'] = 'deltadbtxt'; |
| 475 | 629 | $data['id_source'] = $id_source; |
| 476 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 477 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 478 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 630 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 631 | + $data['source_name'] = $value['name']; |
|
| 632 | + } |
|
| 633 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 634 | + $data['noarchive'] = true; |
|
| 635 | + } |
|
| 636 | + if (isset($value['sourcestats'])) { |
|
| 637 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 638 | + } |
|
| 479 | 639 | $SI->add($data); |
| 480 | 640 | unset($data); |
| 481 | 641 | } |
@@ -509,10 +669,17 @@ discard block |
||
| 509 | 669 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 510 | 670 | $data['format_source'] = 'radarcapejson'; |
| 511 | 671 | $data['id_source'] = $id_source; |
| 512 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 513 | - elseif($line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
| 514 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 515 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 672 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 673 | + $data['source_name'] = $value['name']; |
|
| 674 | + } elseif($line['src'] == 'M') { |
|
| 675 | + $data['source_name'] = 'MLAT'; |
|
| 676 | + } |
|
| 677 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 678 | + $data['noarchive'] = true; |
|
| 679 | + } |
|
| 680 | + if (isset($value['sourcestats'])) { |
|
| 681 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 682 | + } |
|
| 516 | 683 | |
| 517 | 684 | $SI->add($data); |
| 518 | 685 | unset($data); |
@@ -528,7 +695,9 @@ discard block |
||
| 528 | 695 | date_default_timezone_set('CET'); |
| 529 | 696 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 530 | 697 | date_default_timezone_set('UTC'); |
| 531 | - if ($buffer != '') $reset = 0; |
|
| 698 | + if ($buffer != '') { |
|
| 699 | + $reset = 0; |
|
| 700 | + } |
|
| 532 | 701 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 533 | 702 | $buffer = explode('\n',$buffer); |
| 534 | 703 | foreach ($buffer as $line) { |
@@ -537,18 +706,42 @@ discard block |
||
| 537 | 706 | $add = false; |
| 538 | 707 | $ais_data = $AIS->parse_line(trim($line)); |
| 539 | 708 | $data = array(); |
| 540 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 541 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 542 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 543 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 544 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 545 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 546 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 547 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 548 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 549 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 550 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 551 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 709 | + if (isset($ais_data['ident'])) { |
|
| 710 | + $data['ident'] = $ais_data['ident']; |
|
| 711 | + } |
|
| 712 | + if (isset($ais_data['mmsi'])) { |
|
| 713 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 714 | + } |
|
| 715 | + if (isset($ais_data['speed'])) { |
|
| 716 | + $data['speed'] = $ais_data['speed']; |
|
| 717 | + } |
|
| 718 | + if (isset($ais_data['heading'])) { |
|
| 719 | + $data['heading'] = $ais_data['heading']; |
|
| 720 | + } |
|
| 721 | + if (isset($ais_data['latitude'])) { |
|
| 722 | + $data['latitude'] = $ais_data['latitude']; |
|
| 723 | + } |
|
| 724 | + if (isset($ais_data['longitude'])) { |
|
| 725 | + $data['longitude'] = $ais_data['longitude']; |
|
| 726 | + } |
|
| 727 | + if (isset($ais_data['status'])) { |
|
| 728 | + $data['status'] = $ais_data['status']; |
|
| 729 | + } |
|
| 730 | + if (isset($ais_data['statusid'])) { |
|
| 731 | + $data['status_id'] = $ais_data['statusid']; |
|
| 732 | + } |
|
| 733 | + if (isset($ais_data['type'])) { |
|
| 734 | + $data['type'] = $ais_data['type']; |
|
| 735 | + } |
|
| 736 | + if (isset($ais_data['typeid'])) { |
|
| 737 | + $data['type_id'] = $ais_data['typeid']; |
|
| 738 | + } |
|
| 739 | + if (isset($ais_data['imo'])) { |
|
| 740 | + $data['imo'] = $ais_data['imo']; |
|
| 741 | + } |
|
| 742 | + if (isset($ais_data['callsign'])) { |
|
| 743 | + $data['callsign'] = $ais_data['callsign']; |
|
| 744 | + } |
|
| 552 | 745 | if (isset($ais_data['timestamp'])) { |
| 553 | 746 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 554 | 747 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -562,8 +755,12 @@ discard block |
||
| 562 | 755 | $data['format_source'] = 'aisnmeatxt'; |
| 563 | 756 | $data['id_source'] = $id_source; |
| 564 | 757 | //print_r($data); |
| 565 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 566 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 758 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 759 | + $data['noarchive'] = true; |
|
| 760 | + } |
|
| 761 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 762 | + $MI->add($data); |
|
| 763 | + } |
|
| 567 | 764 | unset($data); |
| 568 | 765 | } |
| 569 | 766 | } |
@@ -586,20 +783,48 @@ discard block |
||
| 586 | 783 | if ($line != '') { |
| 587 | 784 | $ais_data = $AIS->parse_line(trim($line)); |
| 588 | 785 | $data = array(); |
| 589 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 590 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 591 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 592 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 593 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 594 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 595 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 596 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 597 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 598 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 599 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 600 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 601 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 602 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 786 | + if (isset($ais_data['ident'])) { |
|
| 787 | + $data['ident'] = $ais_data['ident']; |
|
| 788 | + } |
|
| 789 | + if (isset($ais_data['mmsi'])) { |
|
| 790 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 791 | + } |
|
| 792 | + if (isset($ais_data['speed'])) { |
|
| 793 | + $data['speed'] = $ais_data['speed']; |
|
| 794 | + } |
|
| 795 | + if (isset($ais_data['heading'])) { |
|
| 796 | + $data['heading'] = $ais_data['heading']; |
|
| 797 | + } |
|
| 798 | + if (isset($ais_data['latitude'])) { |
|
| 799 | + $data['latitude'] = $ais_data['latitude']; |
|
| 800 | + } |
|
| 801 | + if (isset($ais_data['longitude'])) { |
|
| 802 | + $data['longitude'] = $ais_data['longitude']; |
|
| 803 | + } |
|
| 804 | + if (isset($ais_data['status'])) { |
|
| 805 | + $data['status'] = $ais_data['status']; |
|
| 806 | + } |
|
| 807 | + if (isset($ais_data['statusid'])) { |
|
| 808 | + $data['status_id'] = $ais_data['statusid']; |
|
| 809 | + } |
|
| 810 | + if (isset($ais_data['type'])) { |
|
| 811 | + $data['type'] = $ais_data['type']; |
|
| 812 | + } |
|
| 813 | + if (isset($ais_data['typeid'])) { |
|
| 814 | + $data['type_id'] = $ais_data['typeid']; |
|
| 815 | + } |
|
| 816 | + if (isset($ais_data['imo'])) { |
|
| 817 | + $data['imo'] = $ais_data['imo']; |
|
| 818 | + } |
|
| 819 | + if (isset($ais_data['callsign'])) { |
|
| 820 | + $data['callsign'] = $ais_data['callsign']; |
|
| 821 | + } |
|
| 822 | + if (isset($ais_data['destination'])) { |
|
| 823 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 824 | + } |
|
| 825 | + if (isset($ais_data['eta_ts'])) { |
|
| 826 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 827 | + } |
|
| 603 | 828 | if (isset($ais_data['timestamp'])) { |
| 604 | 829 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 605 | 830 | } else { |
@@ -607,18 +832,27 @@ discard block |
||
| 607 | 832 | } |
| 608 | 833 | $data['format_source'] = 'aisnmeahttp'; |
| 609 | 834 | $data['id_source'] = $id_source; |
| 610 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 611 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 835 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 836 | + $data['noarchive'] = true; |
|
| 837 | + } |
|
| 838 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 839 | + $MI->add($data); |
|
| 840 | + } |
|
| 612 | 841 | unset($data); |
| 613 | 842 | } |
| 614 | 843 | } |
| 615 | 844 | } |
| 616 | 845 | } else { |
| 617 | 846 | $format = $value['format']; |
| 618 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 619 | - else $tt[$format] = 0; |
|
| 847 | + if (isset($tt[$format])) { |
|
| 848 | + $tt[$format]++; |
|
| 849 | + } else { |
|
| 850 | + $tt[$format] = 0; |
|
| 851 | + } |
|
| 620 | 852 | if ($tt[$format] > 30) { |
| 621 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 853 | + if ($globalDebug) { |
|
| 854 | + echo 'Reconnect...'."\n"; |
|
| 855 | + } |
|
| 622 | 856 | sleep(2); |
| 623 | 857 | //$sourceeen[] = $value; |
| 624 | 858 | //connect_all($sourceeen); |
@@ -654,12 +888,18 @@ discard block |
||
| 654 | 888 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 655 | 889 | //$data['type_id'] = $line['TYPE']; |
| 656 | 890 | $data['imo'] = $line['IMO']; |
| 657 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 658 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 891 | + if ($line['DEST'] != '') { |
|
| 892 | + $data['arrival_code'] = $line['DEST']; |
|
| 893 | + } |
|
| 894 | + if ($line['ARV'] != '') { |
|
| 895 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 896 | + } |
|
| 659 | 897 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 660 | 898 | $data['format_source'] = 'myshiptracking'; |
| 661 | 899 | $data['id_source'] = $id_source; |
| 662 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 900 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 901 | + $data['noarchive'] = true; |
|
| 902 | + } |
|
| 663 | 903 | $MI->add($data); |
| 664 | 904 | unset($data); |
| 665 | 905 | } |
@@ -684,7 +924,9 @@ discard block |
||
| 684 | 924 | $data['callsign'] = $line['callsign']; |
| 685 | 925 | $data['mmsi'] = substr($line['mmsi'],-9); |
| 686 | 926 | $data['speed'] = $line['sog']; |
| 687 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 927 | + if ($line['heading'] != '511') { |
|
| 928 | + $data['heading'] = $line['heading']; |
|
| 929 | + } |
|
| 688 | 930 | $data['latitude'] = $line['latitude']; |
| 689 | 931 | $data['longitude'] = $line['longitude']; |
| 690 | 932 | $data['type_id'] = $line['shiptype']; |
@@ -692,7 +934,9 @@ discard block |
||
| 692 | 934 | $data['datetime'] = $line['time']; |
| 693 | 935 | $data['format_source'] = 'boatbeaconapp'; |
| 694 | 936 | $data['id_source'] = $id_source; |
| 695 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 937 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 938 | + $data['noarchive'] = true; |
|
| 939 | + } |
|
| 696 | 940 | $MI->add($data); |
| 697 | 941 | unset($data); |
| 698 | 942 | } |
@@ -714,22 +958,44 @@ discard block |
||
| 714 | 958 | foreach ($all_data['features'] as $line) { |
| 715 | 959 | print_r($line); |
| 716 | 960 | $data = array(); |
| 717 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 718 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 719 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 720 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
| 721 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 722 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
| 961 | + if (isset($line['properties']['name'])) { |
|
| 962 | + $data['ident'] = $line['properties']['name']; |
|
| 963 | + } |
|
| 964 | + if (isset($line['properties']['callsign'])) { |
|
| 965 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 966 | + } |
|
| 967 | + if (isset($line['properties']['mmsi'])) { |
|
| 968 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 969 | + } |
|
| 970 | + if (isset($line['properties']['imo'])) { |
|
| 971 | + $data['imo'] = $line['properties']['imo']; |
|
| 972 | + } |
|
| 973 | + if (isset($line['properties']['speed'])) { |
|
| 974 | + $data['speed'] = $line['properties']['speed']; |
|
| 975 | + } |
|
| 976 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
| 977 | + $data['heading'] = $line['properties']['heading']; |
|
| 978 | + } |
|
| 723 | 979 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 724 | 980 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 725 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 726 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 727 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 981 | + if (isset($line['properties']['vesselType'])) { |
|
| 982 | + $data['type'] = $line['properties']['vesselType']; |
|
| 983 | + } |
|
| 984 | + if (isset($line['properties']['destination'])) { |
|
| 985 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 986 | + } |
|
| 987 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 988 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 989 | + } |
|
| 728 | 990 | $data['format_source'] = 'boatnerd'; |
| 729 | 991 | $data['id_source'] = $id_source; |
| 730 | 992 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 731 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 732 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 993 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 994 | + $data['noarchive'] = true; |
|
| 995 | + } |
|
| 996 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 997 | + $MI->add($data); |
|
| 998 | + } |
|
| 733 | 999 | unset($data); |
| 734 | 1000 | } |
| 735 | 1001 | } |
@@ -742,11 +1008,17 @@ discard block |
||
| 742 | 1008 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 743 | 1009 | ) |
| 744 | 1010 | ) { |
| 745 | - if ($globalDebug) echo 'download...'; |
|
| 1011 | + if ($globalDebug) { |
|
| 1012 | + echo 'download...'; |
|
| 1013 | + } |
|
| 746 | 1014 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 747 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 1015 | + if ($globalDebug) { |
|
| 1016 | + echo 'done !'."\n"; |
|
| 1017 | + } |
|
| 748 | 1018 | // FIXME: Need more work |
| 749 | - if ($buffer != '') $reset = 0; |
|
| 1019 | + if ($buffer != '') { |
|
| 1020 | + $reset = 0; |
|
| 1021 | + } |
|
| 750 | 1022 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 751 | 1023 | $buffer = explode('\n',$buffer); |
| 752 | 1024 | foreach ($buffer as $line) { |
@@ -772,7 +1044,9 @@ discard block |
||
| 772 | 1044 | //$data['etaTime'] = substr($line,135,5); |
| 773 | 1045 | $data['format_source'] = 'shipplotter'; |
| 774 | 1046 | $data['id_source'] = $id_source; |
| 775 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1047 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1048 | + $data['noarchive'] = true; |
|
| 1049 | + } |
|
| 776 | 1050 | //print_r($data); |
| 777 | 1051 | //echo 'Add...'."\n"; |
| 778 | 1052 | $MI->add($data); |
@@ -795,11 +1069,17 @@ discard block |
||
| 795 | 1069 | } |
| 796 | 1070 | } |
| 797 | 1071 | |
| 798 | - if ($globalDebug) echo '! Download... '; |
|
| 1072 | + if ($globalDebug) { |
|
| 1073 | + echo '! Download... '; |
|
| 1074 | + } |
|
| 799 | 1075 | for ($i =0; $i <= 1; $i++) { |
| 800 | - if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
| 1076 | + if ($globalDebug) { |
|
| 1077 | + echo 'Racetype: '.$i.' '; |
|
| 1078 | + } |
|
| 801 | 1079 | $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
| 802 | - if ($globalDebug) echo 'done'."\n"; |
|
| 1080 | + if ($globalDebug) { |
|
| 1081 | + echo 'done'."\n"; |
|
| 1082 | + } |
|
| 803 | 1083 | if ($buffer != '') { |
| 804 | 1084 | $all_data = json_decode($buffer,true); |
| 805 | 1085 | if (isset($all_data['missions'])) { |
@@ -807,8 +1087,11 @@ discard block |
||
| 807 | 1087 | $mission_user = $mission['usrname']; |
| 808 | 1088 | $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
| 809 | 1089 | if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
| 810 | - if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
| 811 | - else $racebuffer = ''; |
|
| 1090 | + if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { |
|
| 1091 | + $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
| 1092 | + } else { |
|
| 1093 | + $racebuffer = ''; |
|
| 1094 | + } |
|
| 812 | 1095 | $bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
| 813 | 1096 | } else { |
| 814 | 1097 | $bufferm = ''; |
@@ -872,7 +1155,9 @@ discard block |
||
| 872 | 1155 | $data['captain_id'] = $sail['usrnr']; |
| 873 | 1156 | $data['captain_name'] = $sail['usrname']; |
| 874 | 1157 | $data['race_id'] = $sail['misnr']; |
| 875 | - if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank']; |
|
| 1158 | + if ($sail['rank'] != 'DNF') { |
|
| 1159 | + $data['race_rank'] = $sail['rank']; |
|
| 1160 | + } |
|
| 876 | 1161 | $data['race_time'] = $sail['racetime']; |
| 877 | 1162 | if ($mission_user != '') { |
| 878 | 1163 | $data['race_name'] = $mission_name.' ('.$mission_user.')'; |
@@ -882,7 +1167,9 @@ discard block |
||
| 882 | 1167 | //$data['callsign'] = trim(substr($line,100,7); |
| 883 | 1168 | $data['format_source'] = 'sailaway'; |
| 884 | 1169 | $data['id_source'] = $id_source; |
| 885 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1170 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1171 | + $data['noarchive'] = true; |
|
| 1172 | + } |
|
| 886 | 1173 | //print_r($data); |
| 887 | 1174 | //if ($data['race_id'] == '48') print_r($data); |
| 888 | 1175 | //echo 'Add...'."\n"; |
@@ -924,16 +1211,28 @@ discard block |
||
| 924 | 1211 | $line = explode(':', $line); |
| 925 | 1212 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 926 | 1213 | $data = array(); |
| 927 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 928 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1214 | + if (isset($line[37]) && $line[37] != '') { |
|
| 1215 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 1216 | + } else { |
|
| 1217 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1218 | + } |
|
| 929 | 1219 | $data['pilot_id'] = $line[1]; |
| 930 | 1220 | $data['pilot_name'] = $line[2]; |
| 931 | 1221 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 932 | 1222 | $data['ident'] = $line[0]; // ident |
| 933 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 1223 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 1224 | + $data['altitude'] = $line[7]; |
|
| 1225 | + } |
|
| 1226 | + // altitude |
|
| 934 | 1227 | $data['speed'] = $line[8]; // speed |
| 935 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 936 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 1228 | + if (isset($line[45])) { |
|
| 1229 | + $data['heading'] = $line[45]; |
|
| 1230 | + } |
|
| 1231 | + // heading |
|
| 1232 | + elseif (isset($line[38])) { |
|
| 1233 | + $data['heading'] = $line[38]; |
|
| 1234 | + } |
|
| 1235 | + // heading |
|
| 937 | 1236 | $data['latitude'] = $line[5]; // lat |
| 938 | 1237 | $data['longitude'] = $line[6]; // long |
| 939 | 1238 | $data['verticalrate'] = ''; // vertical rate |
@@ -949,7 +1248,9 @@ discard block |
||
| 949 | 1248 | $data['frequency'] = $line[4]; |
| 950 | 1249 | $data['type'] = $line[18]; |
| 951 | 1250 | $data['range'] = $line[19]; |
| 952 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 1251 | + if (isset($line[35])) { |
|
| 1252 | + $data['info'] = $line[35]; |
|
| 1253 | + } |
|
| 953 | 1254 | $data['id_source'] = $id_source; |
| 954 | 1255 | //$data['arrival_airport_time'] = ; |
| 955 | 1256 | if ($line[9] != '') { |
@@ -963,27 +1264,47 @@ discard block |
||
| 963 | 1264 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 964 | 1265 | */ |
| 965 | 1266 | $data['format_source'] = $value['format']; |
| 966 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 967 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 968 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 969 | - elseif ($line[3] === 'ATC') { |
|
| 1267 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1268 | + $data['noarchive'] = true; |
|
| 1269 | + } |
|
| 1270 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1271 | + $data['source_name'] = $value['name']; |
|
| 1272 | + } |
|
| 1273 | + if ($line[3] === 'PILOT') { |
|
| 1274 | + $SI->add($data); |
|
| 1275 | + } elseif ($line[3] === 'ATC') { |
|
| 970 | 1276 | //print_r($data); |
| 971 | 1277 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 972 | 1278 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 973 | 1279 | $typec = substr($data['ident'],-3); |
| 974 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 975 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 976 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 977 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 978 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 979 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 980 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 981 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 982 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
| 983 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 1280 | + if ($typec === 'APP') { |
|
| 1281 | + $data['type'] = 'Approach'; |
|
| 1282 | + } elseif ($typec === 'TWR') { |
|
| 1283 | + $data['type'] = 'Tower'; |
|
| 1284 | + } elseif ($typec === 'OBS') { |
|
| 1285 | + $data['type'] = 'Observer'; |
|
| 1286 | + } elseif ($typec === 'GND') { |
|
| 1287 | + $data['type'] = 'Ground'; |
|
| 1288 | + } elseif ($typec === 'DEL') { |
|
| 1289 | + $data['type'] = 'Delivery'; |
|
| 1290 | + } elseif ($typec === 'DEP') { |
|
| 1291 | + $data['type'] = 'Departure'; |
|
| 1292 | + } elseif ($typec === 'FSS') { |
|
| 1293 | + $data['type'] = 'Flight Service Station'; |
|
| 1294 | + } elseif ($typec === 'CTR') { |
|
| 1295 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1296 | + } elseif ($data['type'] === '') { |
|
| 1297 | + $data['type'] = 'Observer'; |
|
| 1298 | + } |
|
| 1299 | + if (!isset($data['source_name'])) { |
|
| 1300 | + $data['source_name'] = ''; |
|
| 1301 | + } |
|
| 984 | 1302 | if (isset($ATC)) { |
| 985 | - 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']); |
|
| 986 | - 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']); |
|
| 1303 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 1304 | + 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']); |
|
| 1305 | + } else { |
|
| 1306 | + 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']); |
|
| 1307 | + } |
|
| 987 | 1308 | } |
| 988 | 1309 | } |
| 989 | 1310 | unset($data); |
@@ -1010,14 +1331,20 @@ discard block |
||
| 1010 | 1331 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 1011 | 1332 | $data['latitude'] = (float)$line['pktLatitude']; |
| 1012 | 1333 | $data['longitude'] = (float)$line['pktLongitude']; |
| 1013 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 1014 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1334 | + if ((float)$line['pktTrack'] != 0) { |
|
| 1335 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 1336 | + } |
|
| 1337 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 1338 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 1339 | + } |
|
| 1015 | 1340 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 1016 | 1341 | $data['altitude_relative'] = 'AMSL'; |
| 1017 | 1342 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 1018 | 1343 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 1019 | 1344 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 1020 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 1345 | + if (isset($pilot_data[4])) { |
|
| 1346 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1347 | + } |
|
| 1021 | 1348 | $data['format_source'] = $value['format']; |
| 1022 | 1349 | $SI->add($data); |
| 1023 | 1350 | unset($data); |
@@ -1065,25 +1392,59 @@ discard block |
||
| 1065 | 1392 | foreach ($all_data['acList'] as $line) { |
| 1066 | 1393 | $data = array(); |
| 1067 | 1394 | $data['hex'] = $line['Icao']; // hex |
| 1068 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1069 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1070 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1071 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1072 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1073 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1395 | + if (isset($line['Call'])) { |
|
| 1396 | + $data['ident'] = $line['Call']; |
|
| 1397 | + } |
|
| 1398 | + // ident |
|
| 1399 | + if (isset($line['Alt'])) { |
|
| 1400 | + $data['altitude'] = $line['Alt']; |
|
| 1401 | + } |
|
| 1402 | + // altitude |
|
| 1403 | + if (isset($line['Spd'])) { |
|
| 1404 | + $data['speed'] = $line['Spd']; |
|
| 1405 | + } |
|
| 1406 | + // speed |
|
| 1407 | + if (isset($line['Trak'])) { |
|
| 1408 | + $data['heading'] = $line['Trak']; |
|
| 1409 | + } |
|
| 1410 | + // heading |
|
| 1411 | + if (isset($line['Lat'])) { |
|
| 1412 | + $data['latitude'] = $line['Lat']; |
|
| 1413 | + } |
|
| 1414 | + // lat |
|
| 1415 | + if (isset($line['Long'])) { |
|
| 1416 | + $data['longitude'] = $line['Long']; |
|
| 1417 | + } |
|
| 1418 | + // long |
|
| 1074 | 1419 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1075 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1420 | + if (isset($line['Sqk'])) { |
|
| 1421 | + $data['squawk'] = $line['Sqk']; |
|
| 1422 | + } |
|
| 1423 | + // squawk |
|
| 1076 | 1424 | $data['emergency'] = ''; // emergency |
| 1077 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1078 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1079 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1425 | + if (isset($line['Reg'])) { |
|
| 1426 | + $data['registration'] = $line['Reg']; |
|
| 1427 | + } |
|
| 1428 | + if (isset($line['PosTime'])) { |
|
| 1429 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1430 | + } else { |
|
| 1431 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1432 | + } |
|
| 1080 | 1433 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1081 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1434 | + if (isset($line['Type'])) { |
|
| 1435 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1436 | + } |
|
| 1082 | 1437 | $data['format_source'] = 'aircraftlistjson'; |
| 1083 | 1438 | $data['id_source'] = $id_source; |
| 1084 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1085 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1086 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1439 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1440 | + $data['source_name'] = $value['name']; |
|
| 1441 | + } |
|
| 1442 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1443 | + $data['noarchive'] = true; |
|
| 1444 | + } |
|
| 1445 | + if (isset($data['latitude'])) { |
|
| 1446 | + $SI->add($data); |
|
| 1447 | + } |
|
| 1087 | 1448 | unset($data); |
| 1088 | 1449 | } |
| 1089 | 1450 | } elseif (is_array($all_data)) { |
@@ -1100,17 +1461,26 @@ discard block |
||
| 1100 | 1461 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1101 | 1462 | $data['squawk'] = $line['squawk']; // squawk |
| 1102 | 1463 | $data['emergency'] = ''; // emergency |
| 1103 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1104 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1464 | + if (isset($line['PosTime'])) { |
|
| 1465 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1466 | + } else { |
|
| 1467 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1468 | + } |
|
| 1105 | 1469 | $data['format_source'] = 'aircraftlistjson'; |
| 1106 | 1470 | $data['id_source'] = $id_source; |
| 1107 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1108 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1471 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1472 | + $data['noarchive'] = true; |
|
| 1473 | + } |
|
| 1474 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1475 | + $data['source_name'] = $value['name']; |
|
| 1476 | + } |
|
| 1109 | 1477 | $SI->add($data); |
| 1110 | 1478 | unset($data); |
| 1111 | 1479 | } |
| 1112 | 1480 | } |
| 1113 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1481 | + } elseif ($globalDebug) { |
|
| 1482 | + echo 'No data'."\n"; |
|
| 1483 | + } |
|
| 1114 | 1484 | //$last_exec['aircraftlistjson'] = time(); |
| 1115 | 1485 | $last_exec[$id]['last'] = time(); |
| 1116 | 1486 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -1146,8 +1516,12 @@ discard block |
||
| 1146 | 1516 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 1147 | 1517 | $data['format_source'] = 'planeupdatefaa'; |
| 1148 | 1518 | $data['id_source'] = $id_source; |
| 1149 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1150 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1519 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1520 | + $data['noarchive'] = true; |
|
| 1521 | + } |
|
| 1522 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1523 | + $data['source_name'] = $value['name']; |
|
| 1524 | + } |
|
| 1151 | 1525 | $SI->add($data); |
| 1152 | 1526 | unset($data); |
| 1153 | 1527 | } |
@@ -1181,7 +1555,9 @@ discard block |
||
| 1181 | 1555 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 1182 | 1556 | $data['format_source'] = 'opensky'; |
| 1183 | 1557 | $data['id_source'] = $id_source; |
| 1184 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1558 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1559 | + $data['noarchive'] = true; |
|
| 1560 | + } |
|
| 1185 | 1561 | $SI->add($data); |
| 1186 | 1562 | unset($data); |
| 1187 | 1563 | } |
@@ -1201,15 +1577,42 @@ discard block |
||
| 1201 | 1577 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1202 | 1578 | $data = array(); |
| 1203 | 1579 | // add support for ground vehicule with ~ in front of hex |
| 1204 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1205 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1206 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1207 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1208 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1209 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1210 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1211 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1212 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1580 | + if (isset($line['hex'])) { |
|
| 1581 | + $data['hex'] = $line['hex']; |
|
| 1582 | + } |
|
| 1583 | + // hex |
|
| 1584 | + if (isset($line['flight'])) { |
|
| 1585 | + $data['ident'] = trim($line['flight']); |
|
| 1586 | + } |
|
| 1587 | + // ident |
|
| 1588 | + if (isset($line['altitude'])) { |
|
| 1589 | + $data['altitude'] = $line['altitude']; |
|
| 1590 | + } |
|
| 1591 | + // altitude |
|
| 1592 | + if (isset($line['speed'])) { |
|
| 1593 | + $data['speed'] = $line['speed']; |
|
| 1594 | + } |
|
| 1595 | + // speed |
|
| 1596 | + if (isset($line['track'])) { |
|
| 1597 | + $data['heading'] = $line['track']; |
|
| 1598 | + } |
|
| 1599 | + // heading |
|
| 1600 | + if (isset($line['lat'])) { |
|
| 1601 | + $data['latitude'] = $line['lat']; |
|
| 1602 | + } |
|
| 1603 | + // lat |
|
| 1604 | + if (isset($line['lon'])) { |
|
| 1605 | + $data['longitude'] = $line['lon']; |
|
| 1606 | + } |
|
| 1607 | + // long |
|
| 1608 | + if (isset($line['vert_rate'])) { |
|
| 1609 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1610 | + } |
|
| 1611 | + // verticale rate |
|
| 1612 | + if (isset($line['squawk'])) { |
|
| 1613 | + $data['squawk'] = $line['squawk']; |
|
| 1614 | + } |
|
| 1615 | + // squawk |
|
| 1213 | 1616 | //$data['emergency'] = ''; // emergency |
| 1214 | 1617 | //$data['registration'] = $line[2]; |
| 1215 | 1618 | //$data['aircraft_icao'] = $line[0]; |
@@ -1217,10 +1620,17 @@ discard block |
||
| 1217 | 1620 | $data['format_source'] = 'aircraftjson'; |
| 1218 | 1621 | $data['id_source'] = $id_source; |
| 1219 | 1622 | if (isset($value['name']) && $value['name'] != '') { |
| 1220 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1221 | - else $data['source_name'] = $value['name']; |
|
| 1222 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1223 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1623 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1624 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1625 | + } else { |
|
| 1626 | + $data['source_name'] = $value['name']; |
|
| 1627 | + } |
|
| 1628 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1629 | + $data['source_name'] = 'MLAT'; |
|
| 1630 | + } |
|
| 1631 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1632 | + $data['noarchive'] = true; |
|
| 1633 | + } |
|
| 1224 | 1634 | $SI->add($data); |
| 1225 | 1635 | unset($data); |
| 1226 | 1636 | } |
@@ -1240,22 +1650,54 @@ discard block |
||
| 1240 | 1650 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1241 | 1651 | $data = array(); |
| 1242 | 1652 | $data['hex'] = $key; // hex |
| 1243 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1244 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1245 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1246 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1247 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1248 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1249 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1250 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1653 | + if (isset($line['callsign'])) { |
|
| 1654 | + $data['ident'] = trim($line['callsign']); |
|
| 1655 | + } |
|
| 1656 | + // ident |
|
| 1657 | + if (isset($line['altitude'])) { |
|
| 1658 | + $data['altitude'] = $line['altitude']; |
|
| 1659 | + } |
|
| 1660 | + // altitude |
|
| 1661 | + if (isset($line['speed'])) { |
|
| 1662 | + $data['speed'] = $line['speed']; |
|
| 1663 | + } |
|
| 1664 | + // speed |
|
| 1665 | + if (isset($line['heading'])) { |
|
| 1666 | + $data['heading'] = $line['heading']; |
|
| 1667 | + } |
|
| 1668 | + // heading |
|
| 1669 | + if (isset($line['lat'])) { |
|
| 1670 | + $data['latitude'] = $line['lat']; |
|
| 1671 | + } |
|
| 1672 | + // lat |
|
| 1673 | + if (isset($line['lon'])) { |
|
| 1674 | + $data['longitude'] = $line['lon']; |
|
| 1675 | + } |
|
| 1676 | + // long |
|
| 1677 | + if (isset($line['vert_rate'])) { |
|
| 1678 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1679 | + } |
|
| 1680 | + // verticale rate |
|
| 1681 | + if (isset($line['squawk'])) { |
|
| 1682 | + $data['squawk'] = $line['squawk']; |
|
| 1683 | + } |
|
| 1684 | + // squawk |
|
| 1251 | 1685 | //$data['emergency'] = ''; // emergency |
| 1252 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1253 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1686 | + if (isset($line['reg'])) { |
|
| 1687 | + $data['registration'] = $line['reg']; |
|
| 1688 | + } |
|
| 1689 | + if (isset($line['type'])) { |
|
| 1690 | + $data['aircraft_icao'] = $line['type']; |
|
| 1691 | + } |
|
| 1254 | 1692 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
| 1255 | 1693 | $data['format_source'] = 'planefinderclient'; |
| 1256 | 1694 | $data['id_source'] = $id_source; |
| 1257 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1258 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1695 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1696 | + $data['source_name'] = $value['name']; |
|
| 1697 | + } |
|
| 1698 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1699 | + $data['noarchive'] = true; |
|
| 1700 | + } |
|
| 1259 | 1701 | $SI->add($data); |
| 1260 | 1702 | unset($data); |
| 1261 | 1703 | } |
@@ -1271,7 +1713,9 @@ discard block |
||
| 1271 | 1713 | //$buffer = $Common->getData($hosts[$id]); |
| 1272 | 1714 | $buffer = $Common->getData($value['host']); |
| 1273 | 1715 | $all_data = json_decode($buffer,true); |
| 1274 | - if (!empty($all_data)) $reset = 0; |
|
| 1716 | + if (!empty($all_data)) { |
|
| 1717 | + $reset = 0; |
|
| 1718 | + } |
|
| 1275 | 1719 | foreach ($all_data as $key => $line) { |
| 1276 | 1720 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1277 | 1721 | $data = array(); |
@@ -1292,8 +1736,12 @@ discard block |
||
| 1292 | 1736 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 1293 | 1737 | $data['format_source'] = 'fr24json'; |
| 1294 | 1738 | $data['id_source'] = $id_source; |
| 1295 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1296 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1739 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1740 | + $data['noarchive'] = true; |
|
| 1741 | + } |
|
| 1742 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1743 | + $data['source_name'] = $value['name']; |
|
| 1744 | + } |
|
| 1297 | 1745 | $SI->add($data); |
| 1298 | 1746 | unset($data); |
| 1299 | 1747 | } |
@@ -1322,24 +1770,42 @@ discard block |
||
| 1322 | 1770 | if (isset($line['inf'])) { |
| 1323 | 1771 | $data = array(); |
| 1324 | 1772 | $data['hex'] = $line['inf']['ia']; |
| 1325 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1773 | + if (isset($line['inf']['cs'])) { |
|
| 1774 | + $data['ident'] = $line['inf']['cs']; |
|
| 1775 | + } |
|
| 1776 | + //$line[13] |
|
| 1326 | 1777 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 1327 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1328 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1778 | + if (isset($line['inf']['gs'])) { |
|
| 1779 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1780 | + } |
|
| 1781 | + // speed |
|
| 1782 | + if (isset($line['inf']['tr'])) { |
|
| 1783 | + $data['heading'] = $line['inf']['tr']; |
|
| 1784 | + } |
|
| 1785 | + // heading |
|
| 1329 | 1786 | $data['latitude'] = $line['pt'][0]; // lat |
| 1330 | 1787 | $data['longitude'] = $line['pt'][1]; // long |
| 1331 | 1788 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 1332 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1789 | + if (isset($line['inf']['sq'])) { |
|
| 1790 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1791 | + } |
|
| 1792 | + // squawk |
|
| 1333 | 1793 | //$data['aircraft_icao'] = $line[8]; |
| 1334 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1794 | + if (isset($line['inf']['rc'])) { |
|
| 1795 | + $data['registration'] = $line['inf']['rc']; |
|
| 1796 | + } |
|
| 1335 | 1797 | //$data['departure_airport_iata'] = $line[11]; |
| 1336 | 1798 | //$data['arrival_airport_iata'] = $line[12]; |
| 1337 | 1799 | //$data['emergency'] = ''; // emergency |
| 1338 | 1800 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1339 | 1801 | $data['format_source'] = 'radarvirtueljson'; |
| 1340 | 1802 | $data['id_source'] = $id_source; |
| 1341 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1342 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1803 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1804 | + $data['noarchive'] = true; |
|
| 1805 | + } |
|
| 1806 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1807 | + $data['source_name'] = $value['name']; |
|
| 1808 | + } |
|
| 1343 | 1809 | $SI->add($data); |
| 1344 | 1810 | unset($data); |
| 1345 | 1811 | } |
@@ -1365,30 +1831,65 @@ discard block |
||
| 1365 | 1831 | $data['id'] = $line['id']; |
| 1366 | 1832 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 1367 | 1833 | $data['ident'] = $line['callsign']; // ident |
| 1368 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1369 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1370 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1371 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1372 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1373 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1834 | + if (isset($line['pilotid'])) { |
|
| 1835 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1836 | + } |
|
| 1837 | + // pilot id |
|
| 1838 | + if (isset($line['name'])) { |
|
| 1839 | + $data['pilot_name'] = $line['name']; |
|
| 1840 | + } |
|
| 1841 | + // pilot name |
|
| 1842 | + if (isset($line['alt'])) { |
|
| 1843 | + $data['altitude'] = $line['alt']; |
|
| 1844 | + } |
|
| 1845 | + // altitude |
|
| 1846 | + if (isset($line['gs'])) { |
|
| 1847 | + $data['speed'] = $line['gs']; |
|
| 1848 | + } |
|
| 1849 | + // speed |
|
| 1850 | + if (isset($line['heading'])) { |
|
| 1851 | + $data['heading'] = $line['heading']; |
|
| 1852 | + } |
|
| 1853 | + // heading |
|
| 1854 | + if (isset($line['route'])) { |
|
| 1855 | + $data['waypoints'] = $line['route']; |
|
| 1856 | + } |
|
| 1857 | + // route |
|
| 1374 | 1858 | $data['latitude'] = $line['lat']; // lat |
| 1375 | 1859 | $data['longitude'] = $line['lon']; // long |
| 1376 | 1860 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 1377 | 1861 | //$data['squawk'] = $line['squawk']; // squawk |
| 1378 | 1862 | //$data['emergency'] = ''; // emergency |
| 1379 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1380 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1381 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1863 | + if (isset($line['depicao'])) { |
|
| 1864 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1865 | + } |
|
| 1866 | + if (isset($line['deptime'])) { |
|
| 1867 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1868 | + } |
|
| 1869 | + if (isset($line['arricao'])) { |
|
| 1870 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1871 | + } |
|
| 1382 | 1872 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 1383 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1384 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1385 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1386 | - else $data['info'] = ''; |
|
| 1873 | + if (isset($line['aircraft'])) { |
|
| 1874 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1875 | + } |
|
| 1876 | + if (isset($line['transponder'])) { |
|
| 1877 | + $data['squawk'] = $line['transponder']; |
|
| 1878 | + } |
|
| 1879 | + if (isset($line['atis'])) { |
|
| 1880 | + $data['info'] = $line['atis']; |
|
| 1881 | + } else { |
|
| 1882 | + $data['info'] = ''; |
|
| 1883 | + } |
|
| 1387 | 1884 | $data['format_source'] = 'pireps'; |
| 1388 | 1885 | $data['id_source'] = $id_source; |
| 1389 | 1886 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1390 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1391 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1887 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1888 | + $data['noarchive'] = true; |
|
| 1889 | + } |
|
| 1890 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1891 | + $data['source_name'] = $value['name']; |
|
| 1892 | + } |
|
| 1392 | 1893 | if ($line['icon'] === 'plane') { |
| 1393 | 1894 | $SI->add($data); |
| 1394 | 1895 | // print_r($data); |
@@ -1397,16 +1898,28 @@ discard block |
||
| 1397 | 1898 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1398 | 1899 | $typec = substr($data['ident'],-3); |
| 1399 | 1900 | $data['type'] = ''; |
| 1400 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 1401 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 1402 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 1403 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 1404 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 1405 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 1406 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1407 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1408 | - else $data['type'] = 'Observer'; |
|
| 1409 | - 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']); |
|
| 1901 | + if ($typec === 'APP') { |
|
| 1902 | + $data['type'] = 'Approach'; |
|
| 1903 | + } elseif ($typec === 'TWR') { |
|
| 1904 | + $data['type'] = 'Tower'; |
|
| 1905 | + } elseif ($typec === 'OBS') { |
|
| 1906 | + $data['type'] = 'Observer'; |
|
| 1907 | + } elseif ($typec === 'GND') { |
|
| 1908 | + $data['type'] = 'Ground'; |
|
| 1909 | + } elseif ($typec === 'DEL') { |
|
| 1910 | + $data['type'] = 'Delivery'; |
|
| 1911 | + } elseif ($typec === 'DEP') { |
|
| 1912 | + $data['type'] = 'Departure'; |
|
| 1913 | + } elseif ($typec === 'FSS') { |
|
| 1914 | + $data['type'] = 'Flight Service Station'; |
|
| 1915 | + } elseif ($typec === 'CTR') { |
|
| 1916 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1917 | + } else { |
|
| 1918 | + $data['type'] = 'Observer'; |
|
| 1919 | + } |
|
| 1920 | + if (isset($ATC)) { |
|
| 1921 | + 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']); |
|
| 1922 | + } |
|
| 1410 | 1923 | } |
| 1411 | 1924 | unset($data); |
| 1412 | 1925 | } |
@@ -1421,7 +1934,9 @@ discard block |
||
| 1421 | 1934 | ) |
| 1422 | 1935 | ) { |
| 1423 | 1936 | //$buffer = $Common->getData($hosts[$id]); |
| 1424 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1937 | + if ($globalDebug) { |
|
| 1938 | + echo 'Get Data...'."\n"; |
|
| 1939 | + } |
|
| 1425 | 1940 | $buffer = $Common->getData($value['host']); |
| 1426 | 1941 | $all_data = json_decode($buffer,true); |
| 1427 | 1942 | if ($buffer != '' && is_array($all_data)) { |
@@ -1429,10 +1944,16 @@ discard block |
||
| 1429 | 1944 | foreach ($all_data as $line) { |
| 1430 | 1945 | $data = array(); |
| 1431 | 1946 | //$data['id'] = $line['id']; // id not usable |
| 1432 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1947 | + if (isset($line['pilotid'])) { |
|
| 1948 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1949 | + } |
|
| 1433 | 1950 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1434 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1435 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1951 | + if (isset($line['pilotname'])) { |
|
| 1952 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1953 | + } |
|
| 1954 | + if (isset($line['pilotid'])) { |
|
| 1955 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1956 | + } |
|
| 1436 | 1957 | $data['ident'] = $line['flightnum']; // ident |
| 1437 | 1958 | $data['altitude'] = $line['alt']; // altitude |
| 1438 | 1959 | $data['speed'] = $line['gs']; // speed |
@@ -1448,7 +1969,9 @@ discard block |
||
| 1448 | 1969 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
| 1449 | 1970 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1450 | 1971 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1451 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1972 | + } else { |
|
| 1973 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1974 | + } |
|
| 1452 | 1975 | $data['departure_airport_icao'] = $line['depicao']; |
| 1453 | 1976 | $data['departure_airport_time'] = $line['deptime']; |
| 1454 | 1977 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1456,29 +1979,47 @@ discard block |
||
| 1456 | 1979 | if (isset($line['registration'])) { |
| 1457 | 1980 | $data['registration'] = $line['registration']; |
| 1458 | 1981 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
| 1459 | - } else $data['registration'] = $line['aircraft']; |
|
| 1460 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1461 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1982 | + } else { |
|
| 1983 | + $data['registration'] = $line['aircraft']; |
|
| 1984 | + } |
|
| 1985 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1986 | + $data['noarchive'] = true; |
|
| 1987 | + } |
|
| 1988 | + if (isset($line['route'])) { |
|
| 1989 | + $data['waypoints'] = $line['route']; |
|
| 1990 | + } |
|
| 1991 | + // route |
|
| 1462 | 1992 | if (isset($line['aircraftname'])) { |
| 1463 | 1993 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1464 | 1994 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1465 | 1995 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1466 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1467 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1468 | - else { |
|
| 1996 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1997 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1998 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1999 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 2000 | + } else { |
|
| 1469 | 2001 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1470 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1471 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 2002 | + if (isset($aircraft_data[1])) { |
|
| 2003 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 2004 | + } else { |
|
| 2005 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 2006 | + } |
|
| 1472 | 2007 | } |
| 1473 | 2008 | } |
| 1474 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 2009 | + if (isset($line['route'])) { |
|
| 2010 | + $data['waypoints'] = $line['route']; |
|
| 2011 | + } |
|
| 1475 | 2012 | $data['id_source'] = $id_source; |
| 1476 | 2013 | $data['format_source'] = 'phpvmacars'; |
| 1477 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2014 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2015 | + $data['source_name'] = $value['name']; |
|
| 2016 | + } |
|
| 1478 | 2017 | $SI->add($data); |
| 1479 | 2018 | unset($data); |
| 1480 | 2019 | } |
| 1481 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2020 | + if ($globalDebug) { |
|
| 2021 | + echo 'No more data...'."\n"; |
|
| 2022 | + } |
|
| 1482 | 2023 | unset($buffer); |
| 1483 | 2024 | unset($all_data); |
| 1484 | 2025 | } |
@@ -1491,7 +2032,9 @@ discard block |
||
| 1491 | 2032 | ) |
| 1492 | 2033 | ) { |
| 1493 | 2034 | //$buffer = $Common->getData($hosts[$id]); |
| 1494 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2035 | + if ($globalDebug) { |
|
| 2036 | + echo 'Get Data...'."\n"; |
|
| 2037 | + } |
|
| 1495 | 2038 | $buffer = $Common->getData($value['host']); |
| 1496 | 2039 | $all_data = json_decode($buffer,true); |
| 1497 | 2040 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1502,10 +2045,16 @@ discard block |
||
| 1502 | 2045 | //$data['id'] = $line['id']; // id not usable |
| 1503 | 2046 | $data['id'] = $line['id']; |
| 1504 | 2047 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1505 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1506 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 2048 | + if (isset($line['user']['username'])) { |
|
| 2049 | + $data['pilot_name'] = $line['user']['username']; |
|
| 2050 | + } |
|
| 2051 | + if (isset($line['user_id'])) { |
|
| 2052 | + $data['pilot_id'] = $line['user_id']; |
|
| 2053 | + } |
|
| 1507 | 2054 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
| 1508 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2055 | + if (is_numeric($data['ident'])) { |
|
| 2056 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2057 | + } |
|
| 1509 | 2058 | $data['altitude'] = $line['altitude']; // altitude |
| 1510 | 2059 | $data['speed'] = $line['groundspeed']; // speed |
| 1511 | 2060 | $data['heading'] = $line['heading']; // heading |
@@ -1518,7 +2067,9 @@ discard block |
||
| 1518 | 2067 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
| 1519 | 2068 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1520 | 2069 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1521 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2070 | + } else { |
|
| 2071 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2072 | + } |
|
| 1522 | 2073 | |
| 1523 | 2074 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
| 1524 | 2075 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1526,17 +2077,26 @@ discard block |
||
| 1526 | 2077 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
| 1527 | 2078 | $data['registration'] = $line['bid']['aircraft']['registration']; |
| 1528 | 2079 | |
| 1529 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1530 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 2080 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2081 | + $data['noarchive'] = true; |
|
| 2082 | + } |
|
| 2083 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
| 2084 | + $data['waypoints'] = $line['bid']['route']; |
|
| 2085 | + } |
|
| 2086 | + // route |
|
| 1531 | 2087 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
| 1532 | 2088 | |
| 1533 | 2089 | $data['id_source'] = $id_source; |
| 1534 | 2090 | $data['format_source'] = 'vaos'; |
| 1535 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2091 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2092 | + $data['source_name'] = $value['name']; |
|
| 2093 | + } |
|
| 1536 | 2094 | $SI->add($data); |
| 1537 | 2095 | unset($data); |
| 1538 | 2096 | } |
| 1539 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2097 | + if ($globalDebug) { |
|
| 2098 | + echo 'No more data...'."\n"; |
|
| 2099 | + } |
|
| 1540 | 2100 | unset($buffer); |
| 1541 | 2101 | unset($all_data); |
| 1542 | 2102 | } |
@@ -1549,7 +2109,9 @@ discard block |
||
| 1549 | 2109 | ) |
| 1550 | 2110 | ) { |
| 1551 | 2111 | //$buffer = $Common->getData($hosts[$id]); |
| 1552 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2112 | + if ($globalDebug) { |
|
| 2113 | + echo 'Get Data...'."\n"; |
|
| 2114 | + } |
|
| 1553 | 2115 | $buffer = $Common->getData($value['host']); |
| 1554 | 2116 | $all_data = json_decode($buffer,true); |
| 1555 | 2117 | if ($buffer != '' && is_array($all_data)) { |
@@ -1578,16 +2140,25 @@ discard block |
||
| 1578 | 2140 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1579 | 2141 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1580 | 2142 | //$data['registration'] = $line['aircraft']; |
| 1581 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 2143 | + if (isset($line['route'])) { |
|
| 2144 | + $data['waypoints'] = $line['route']; |
|
| 2145 | + } |
|
| 2146 | + // route |
|
| 1582 | 2147 | $data['aircraft_icao'] = $line['plane_type']; |
| 1583 | 2148 | $data['id_source'] = $id_source; |
| 1584 | 2149 | $data['format_source'] = 'vam'; |
| 1585 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1586 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2150 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2151 | + $data['noarchive'] = true; |
|
| 2152 | + } |
|
| 2153 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2154 | + $data['source_name'] = $value['name']; |
|
| 2155 | + } |
|
| 1587 | 2156 | $SI->add($data); |
| 1588 | 2157 | unset($data); |
| 1589 | 2158 | } |
| 1590 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2159 | + if ($globalDebug) { |
|
| 2160 | + echo 'No more data...'."\n"; |
|
| 2161 | + } |
|
| 1591 | 2162 | unset($buffer); |
| 1592 | 2163 | unset($all_data); |
| 1593 | 2164 | } |
@@ -1600,7 +2171,9 @@ discard block |
||
| 1600 | 2171 | ) |
| 1601 | 2172 | ) { |
| 1602 | 2173 | //$buffer = $Common->getData($hosts[$id]); |
| 1603 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2174 | + if ($globalDebug) { |
|
| 2175 | + echo 'Get Data...'."\n"; |
|
| 2176 | + } |
|
| 1604 | 2177 | $buffer = $Common->getData($value['host']); |
| 1605 | 2178 | $all_data = json_decode($buffer,true); |
| 1606 | 2179 | if ($buffer != '') { |
@@ -1618,12 +2191,16 @@ discard block |
||
| 1618 | 2191 | $data['id_source'] = $id_source; |
| 1619 | 2192 | $data['format_source'] = 'blitzortung'; |
| 1620 | 2193 | $SI->add($data); |
| 1621 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2194 | + if ($globalDebug) { |
|
| 2195 | + echo '☈ Lightning added'."\n"; |
|
| 2196 | + } |
|
| 1622 | 2197 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1623 | 2198 | unset($data); |
| 1624 | 2199 | } |
| 1625 | 2200 | } |
| 1626 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2201 | + if ($globalDebug) { |
|
| 2202 | + echo 'No more data...'."\n"; |
|
| 2203 | + } |
|
| 1627 | 2204 | unset($buffer); |
| 1628 | 2205 | } |
| 1629 | 2206 | $last_exec[$id]['last'] = time(); |
@@ -1652,10 +2229,15 @@ discard block |
||
| 1652 | 2229 | } |
| 1653 | 2230 | } else { |
| 1654 | 2231 | $format = $value['format']; |
| 1655 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1656 | - else $tt[$format] = 0; |
|
| 2232 | + if (isset($tt[$format])) { |
|
| 2233 | + $tt[$format]++; |
|
| 2234 | + } else { |
|
| 2235 | + $tt[$format] = 0; |
|
| 2236 | + } |
|
| 1657 | 2237 | if ($tt[$format] > 30) { |
| 1658 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 2238 | + if ($globalDebug) { |
|
| 2239 | + echo 'Reconnect...'."\n"; |
|
| 2240 | + } |
|
| 1659 | 2241 | sleep(2); |
| 1660 | 2242 | //$sourceeen[] = $value; |
| 1661 | 2243 | //connect_all($sourceeen); |
@@ -1672,7 +2254,9 @@ discard block |
||
| 1672 | 2254 | $write = NULL; |
| 1673 | 2255 | $e = NULL; |
| 1674 | 2256 | $n = socket_select($read, $write, $e, $timeout); |
| 1675 | - if ($e != NULL) var_dump($e); |
|
| 2257 | + if ($e != NULL) { |
|
| 2258 | + var_dump($e); |
|
| 2259 | + } |
|
| 1676 | 2260 | if ($n > 0) { |
| 1677 | 2261 | $reset = 0; |
| 1678 | 2262 | foreach ($read as $nb => $r) { |
@@ -1694,13 +2278,17 @@ discard block |
||
| 1694 | 2278 | if ($buffer !== FALSE) { |
| 1695 | 2279 | if ($format === 'vrstcp') { |
| 1696 | 2280 | $buffer = explode('},{',$buffer); |
| 1697 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2281 | + } else { |
|
| 2282 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2283 | + } |
|
| 1698 | 2284 | } |
| 1699 | 2285 | // SBS format is CSV format |
| 1700 | 2286 | if ($buffer !== FALSE && $buffer !== '') { |
| 1701 | 2287 | $tt[$format] = 0; |
| 1702 | 2288 | if ($format === 'acarssbs3') { |
| 1703 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2289 | + if ($globalDebug) { |
|
| 2290 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2291 | + } |
|
| 1704 | 2292 | $ACARS->add(trim($buffer)); |
| 1705 | 2293 | $ACARS->deleteLiveAcarsData(); |
| 1706 | 2294 | } elseif ($format === 'raw') { |
@@ -1710,9 +2298,15 @@ discard block |
||
| 1710 | 2298 | //if (!empty($data)) print_r($data); |
| 1711 | 2299 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1712 | 2300 | $data['format_source'] = 'raw'; |
| 1713 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1714 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1715 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2301 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2302 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2303 | + } |
|
| 2304 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2305 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2306 | + } |
|
| 2307 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2308 | + $data['noarchive'] = true; |
|
| 2309 | + } |
|
| 1716 | 2310 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1717 | 2311 | $SI->add($data); |
| 1718 | 2312 | unset($data); |
@@ -1720,22 +2314,54 @@ discard block |
||
| 1720 | 2314 | } elseif ($format === 'ais') { |
| 1721 | 2315 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1722 | 2316 | $data = array(); |
| 1723 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1724 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1725 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1726 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1727 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1728 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1729 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1730 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1731 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1732 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1733 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1734 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1735 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1736 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1737 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1738 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2317 | + if (isset($ais_data['ident'])) { |
|
| 2318 | + $data['ident'] = $ais_data['ident']; |
|
| 2319 | + } |
|
| 2320 | + if (isset($ais_data['mmsi'])) { |
|
| 2321 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 2322 | + } |
|
| 2323 | + if (isset($ais_data['speed'])) { |
|
| 2324 | + $data['speed'] = $ais_data['speed']; |
|
| 2325 | + } |
|
| 2326 | + if (isset($ais_data['heading'])) { |
|
| 2327 | + $data['heading'] = $ais_data['heading']; |
|
| 2328 | + } |
|
| 2329 | + if (isset($ais_data['latitude'])) { |
|
| 2330 | + $data['latitude'] = $ais_data['latitude']; |
|
| 2331 | + } |
|
| 2332 | + if (isset($ais_data['longitude'])) { |
|
| 2333 | + $data['longitude'] = $ais_data['longitude']; |
|
| 2334 | + } |
|
| 2335 | + if (isset($ais_data['status'])) { |
|
| 2336 | + $data['status'] = $ais_data['status']; |
|
| 2337 | + } |
|
| 2338 | + if (isset($ais_data['statusid'])) { |
|
| 2339 | + $data['status_id'] = $ais_data['statusid']; |
|
| 2340 | + } |
|
| 2341 | + if (isset($ais_data['type'])) { |
|
| 2342 | + $data['type'] = $ais_data['type']; |
|
| 2343 | + } |
|
| 2344 | + if (isset($ais_data['imo'])) { |
|
| 2345 | + $data['imo'] = $ais_data['imo']; |
|
| 2346 | + } |
|
| 2347 | + if (isset($ais_data['callsign'])) { |
|
| 2348 | + $data['callsign'] = $ais_data['callsign']; |
|
| 2349 | + } |
|
| 2350 | + if (isset($ais_data['destination'])) { |
|
| 2351 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 2352 | + } |
|
| 2353 | + if (isset($ais_data['eta_ts'])) { |
|
| 2354 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 2355 | + } |
|
| 2356 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2357 | + $data['noarchive'] = true; |
|
| 2358 | + } |
|
| 2359 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2360 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2361 | + } |
|
| 2362 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2363 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2364 | + } |
|
| 1739 | 2365 | |
| 1740 | 2366 | if (isset($ais_data['timestamp'])) { |
| 1741 | 2367 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1744,7 +2370,9 @@ discard block |
||
| 1744 | 2370 | } |
| 1745 | 2371 | $data['format_source'] = 'aisnmea'; |
| 1746 | 2372 | $data['id_source'] = $id_source; |
| 1747 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 2373 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 2374 | + $MI->add($data); |
|
| 2375 | + } |
|
| 1748 | 2376 | unset($data); |
| 1749 | 2377 | } elseif ($format === 'flightgearsp') { |
| 1750 | 2378 | //echo $buffer."\n"; |
@@ -1762,12 +2390,18 @@ discard block |
||
| 1762 | 2390 | $data['speed'] = round($line[5]*1.94384); |
| 1763 | 2391 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1764 | 2392 | $data['format_source'] = 'flightgearsp'; |
| 1765 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1766 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2393 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2394 | + $data['noarchive'] = true; |
|
| 2395 | + } |
|
| 2396 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2397 | + $SI->add($data); |
|
| 2398 | + } |
|
| 1767 | 2399 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1768 | 2400 | } |
| 1769 | 2401 | } elseif ($format === 'acars') { |
| 1770 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2402 | + if ($globalDebug) { |
|
| 2403 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2404 | + } |
|
| 1771 | 2405 | $ACARS->add(trim($buffer)); |
| 1772 | 2406 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1773 | 2407 | $ACARS->deleteLiveAcarsData(); |
@@ -1788,8 +2422,12 @@ discard block |
||
| 1788 | 2422 | $aircraft_type = $line[10]; |
| 1789 | 2423 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1790 | 2424 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1791 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1792 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2425 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2426 | + $data['noarchive'] = true; |
|
| 2427 | + } |
|
| 2428 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2429 | + $SI->add($data); |
|
| 2430 | + } |
|
| 1793 | 2431 | } |
| 1794 | 2432 | } |
| 1795 | 2433 | } elseif ($format === 'beast') { |
@@ -1799,28 +2437,62 @@ discard block |
||
| 1799 | 2437 | foreach($buffer as $all_data) { |
| 1800 | 2438 | $line = json_decode('{'.$all_data.'}',true); |
| 1801 | 2439 | $data = array(); |
| 1802 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1803 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1804 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1805 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1806 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1807 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1808 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 2440 | + if (isset($line['Icao'])) { |
|
| 2441 | + $data['hex'] = $line['Icao']; |
|
| 2442 | + } |
|
| 2443 | + // hex |
|
| 2444 | + if (isset($line['Call'])) { |
|
| 2445 | + $data['ident'] = $line['Call']; |
|
| 2446 | + } |
|
| 2447 | + // ident |
|
| 2448 | + if (isset($line['Alt'])) { |
|
| 2449 | + $data['altitude'] = $line['Alt']; |
|
| 2450 | + } |
|
| 2451 | + // altitude |
|
| 2452 | + if (isset($line['Spd'])) { |
|
| 2453 | + $data['speed'] = $line['Spd']; |
|
| 2454 | + } |
|
| 2455 | + // speed |
|
| 2456 | + if (isset($line['Trak'])) { |
|
| 2457 | + $data['heading'] = $line['Trak']; |
|
| 2458 | + } |
|
| 2459 | + // heading |
|
| 2460 | + if (isset($line['Lat'])) { |
|
| 2461 | + $data['latitude'] = $line['Lat']; |
|
| 2462 | + } |
|
| 2463 | + // lat |
|
| 2464 | + if (isset($line['Long'])) { |
|
| 2465 | + $data['longitude'] = $line['Long']; |
|
| 2466 | + } |
|
| 2467 | + // long |
|
| 1809 | 2468 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1810 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 2469 | + if (isset($line['Sqk'])) { |
|
| 2470 | + $data['squawk'] = $line['Sqk']; |
|
| 2471 | + } |
|
| 2472 | + // squawk |
|
| 1811 | 2473 | $data['emergency'] = ''; // emergency |
| 1812 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 2474 | + if (isset($line['Reg'])) { |
|
| 2475 | + $data['registration'] = $line['Reg']; |
|
| 2476 | + } |
|
| 1813 | 2477 | /* |
| 1814 | 2478 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1815 | 2479 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1816 | 2480 | */ |
| 1817 | 2481 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1818 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 2482 | + if (isset($line['Type'])) { |
|
| 2483 | + $data['aircraft_icao'] = $line['Type']; |
|
| 2484 | + } |
|
| 1819 | 2485 | $data['format_source'] = 'vrstcp'; |
| 1820 | 2486 | $data['id_source'] = $id_source; |
| 1821 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1822 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1823 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 2487 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2488 | + $data['noarchive'] = true; |
|
| 2489 | + } |
|
| 2490 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2491 | + $data['source_name'] = $value['name']; |
|
| 2492 | + } |
|
| 2493 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 2494 | + $SI->add($data); |
|
| 2495 | + } |
|
| 1824 | 2496 | unset($data); |
| 1825 | 2497 | } |
| 1826 | 2498 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1833,22 +2505,46 @@ discard block |
||
| 1833 | 2505 | $data['hex'] = $lined['hexid']; |
| 1834 | 2506 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1835 | 2507 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1836 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1837 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1838 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1839 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1840 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1841 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1842 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 2508 | + if (isset($lined['ident'])) { |
|
| 2509 | + $data['ident'] = $lined['ident']; |
|
| 2510 | + } |
|
| 2511 | + if (isset($lined['lat'])) { |
|
| 2512 | + $data['latitude'] = $lined['lat']; |
|
| 2513 | + } |
|
| 2514 | + if (isset($lined['lon'])) { |
|
| 2515 | + $data['longitude'] = $lined['lon']; |
|
| 2516 | + } |
|
| 2517 | + if (isset($lined['speed'])) { |
|
| 2518 | + $data['speed'] = $lined['speed']; |
|
| 2519 | + } |
|
| 2520 | + if (isset($lined['squawk'])) { |
|
| 2521 | + $data['squawk'] = $lined['squawk']; |
|
| 2522 | + } |
|
| 2523 | + if (isset($lined['alt'])) { |
|
| 2524 | + $data['altitude'] = $lined['alt']; |
|
| 2525 | + } |
|
| 2526 | + if (isset($lined['heading'])) { |
|
| 2527 | + $data['heading'] = $lined['heading']; |
|
| 2528 | + } |
|
| 1843 | 2529 | $data['id_source'] = $id_source; |
| 1844 | 2530 | $data['format_source'] = 'tsv'; |
| 1845 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1846 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1847 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1848 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2531 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2532 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2533 | + } |
|
| 2534 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2535 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2536 | + } |
|
| 2537 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2538 | + $data['noarchive'] = true; |
|
| 2539 | + } |
|
| 2540 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2541 | + $SI->add($data); |
|
| 2542 | + } |
|
| 1849 | 2543 | unset($lined); |
| 1850 | 2544 | unset($data); |
| 1851 | - } else $error = true; |
|
| 2545 | + } else { |
|
| 2546 | + $error = true; |
|
| 2547 | + } |
|
| 1852 | 2548 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1853 | 2549 | if ($aprs_connect === 0) { |
| 1854 | 2550 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1874,47 +2570,96 @@ discard block |
||
| 1874 | 2570 | $aprs_last_tx = time(); |
| 1875 | 2571 | $data = array(); |
| 1876 | 2572 | //print_r($line); |
| 1877 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1878 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1879 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1880 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1881 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1882 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1883 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1884 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1885 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1886 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2573 | + if (isset($line['address'])) { |
|
| 2574 | + $data['hex'] = $line['address']; |
|
| 2575 | + } |
|
| 2576 | + if (isset($line['mmsi'])) { |
|
| 2577 | + $data['mmsi'] = $line['mmsi']; |
|
| 2578 | + } |
|
| 2579 | + if (isset($line['imo'])) { |
|
| 2580 | + $data['imo'] = $line['imo']; |
|
| 2581 | + } |
|
| 2582 | + if (isset($line['squawk'])) { |
|
| 2583 | + $data['squawk'] = $line['squawk']; |
|
| 2584 | + } |
|
| 2585 | + if (isset($line['arrival_code'])) { |
|
| 2586 | + $data['arrival_code'] = $line['arrival_code']; |
|
| 2587 | + } |
|
| 2588 | + if (isset($line['arrival_date'])) { |
|
| 2589 | + $data['arrival_date'] = $line['arrival_date']; |
|
| 2590 | + } |
|
| 2591 | + if (isset($line['typeid'])) { |
|
| 2592 | + $data['type_id'] = $line['typeid']; |
|
| 2593 | + } |
|
| 2594 | + if (isset($line['statusid'])) { |
|
| 2595 | + $data['status_id'] = $line['statusid']; |
|
| 2596 | + } |
|
| 2597 | + if (isset($line['timestamp'])) { |
|
| 2598 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 2599 | + } else { |
|
| 2600 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2601 | + } |
|
| 1887 | 2602 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1888 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 2603 | + if (isset($line['ident'])) { |
|
| 2604 | + $data['ident'] = $line['ident']; |
|
| 2605 | + } |
|
| 1889 | 2606 | $data['latitude'] = $line['latitude']; |
| 1890 | 2607 | $data['longitude'] = $line['longitude']; |
| 1891 | 2608 | //$data['verticalrate'] = $line[16]; |
| 1892 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 2609 | + if (isset($line['speed'])) { |
|
| 2610 | + $data['speed'] = $line['speed']; |
|
| 2611 | + } |
|
| 1893 | 2612 | //else $data['speed'] = 0; |
| 1894 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1895 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1896 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 2613 | + if (isset($line['altitude'])) { |
|
| 2614 | + $data['altitude'] = $line['altitude']; |
|
| 2615 | + } |
|
| 2616 | + if (isset($line['comment'])) { |
|
| 2617 | + $data['comment'] = $line['comment']; |
|
| 2618 | + } |
|
| 2619 | + if (isset($line['symbol'])) { |
|
| 2620 | + $data['type'] = $line['symbol']; |
|
| 2621 | + } |
|
| 1897 | 2622 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
| 1898 | 2623 | |
| 1899 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 2624 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
| 2625 | + $data['heading'] = $line['heading']; |
|
| 2626 | + } |
|
| 1900 | 2627 | //else echo 'No heading...'."\n"; |
| 1901 | 2628 | //else $data['heading'] = 0; |
| 1902 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 2629 | + if (isset($line['stealth'])) { |
|
| 2630 | + $data['aircraft_type'] = $line['stealth']; |
|
| 2631 | + } |
|
| 1903 | 2632 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1904 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1905 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1906 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1907 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 2633 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 2634 | + $data['noarchive'] = true; |
|
| 2635 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 2636 | + $data['noarchive'] = false; |
|
| 2637 | + } |
|
| 2638 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2639 | + $data['noarchive'] = true; |
|
| 2640 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 2641 | + $data['noarchive'] = false; |
|
| 2642 | + } |
|
| 1908 | 2643 | $data['id_source'] = $id_source; |
| 1909 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1910 | - else $data['format_source'] = 'aprs'; |
|
| 2644 | + if (isset($line['format_source'])) { |
|
| 2645 | + $data['format_source'] = $line['format_source']; |
|
| 2646 | + } else { |
|
| 2647 | + $data['format_source'] = 'aprs'; |
|
| 2648 | + } |
|
| 1911 | 2649 | $data['source_name'] = $line['source']; |
| 1912 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1913 | - else $data['source_type'] = 'flarm'; |
|
| 1914 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2650 | + if (isset($line['source_type'])) { |
|
| 2651 | + $data['source_type'] = $line['source_type']; |
|
| 2652 | + } else { |
|
| 2653 | + $data['source_type'] = 'flarm'; |
|
| 2654 | + } |
|
| 2655 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2656 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2657 | + } |
|
| 1915 | 2658 | $currentdate = date('Y-m-d H:i:s'); |
| 1916 | 2659 | $aprsdate = strtotime($data['datetime']); |
| 1917 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 2660 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
| 2661 | + $data['altitude_relative'] = 'AMSL'; |
|
| 2662 | + } |
|
| 1918 | 2663 | // Accept data if time <= system time + 20s |
| 1919 | 2664 | //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'])))) { |
| 1920 | 2665 | if ( |
@@ -1926,7 +2671,9 @@ discard block |
||
| 1926 | 2671 | $send = $SI->add($data); |
| 1927 | 2672 | } elseif ($data['source_type'] === 'ais') { |
| 1928 | 2673 | $data['type'] = ''; |
| 1929 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 2674 | + if (isset($globalMarine) && $globalMarine) { |
|
| 2675 | + $send = $MI->add($data); |
|
| 2676 | + } |
|
| 1930 | 2677 | } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
| 1931 | 2678 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1932 | 2679 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
@@ -1934,8 +2681,12 @@ discard block |
||
| 1934 | 2681 | $line['symbol'] === 'Glider' || |
| 1935 | 2682 | $line['symbol'] === 'No. Plane' || |
| 1936 | 2683 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
| 1937 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1938 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2684 | + if ($line['symbol'] === 'Ballon') { |
|
| 2685 | + $data['aircraft_icao'] = 'BALL'; |
|
| 2686 | + } |
|
| 2687 | + if ($line['symbol'] === 'Glider') { |
|
| 2688 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2689 | + } |
|
| 1939 | 2690 | $send = $SI->add($data); |
| 1940 | 2691 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 1941 | 2692 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1966,9 +2717,13 @@ discard block |
||
| 1966 | 2717 | //} 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') { |
| 1967 | 2718 | // } 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') { |
| 1968 | 2719 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1969 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 2720 | + if (isset($globalTracker) && $globalTracker) { |
|
| 2721 | + $send = $TI->add($data); |
|
| 2722 | + } |
|
| 1970 | 2723 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 1971 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
| 2724 | + if (!isset($data['altitude'])) { |
|
| 2725 | + $data['altitude'] = 0; |
|
| 2726 | + } |
|
| 1972 | 2727 | $Source->deleteOldLocationByType('gs'); |
| 1973 | 2728 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
| 1974 | 2729 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1977,7 +2732,9 @@ discard block |
||
| 1977 | 2732 | } |
| 1978 | 2733 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 1979 | 2734 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1980 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
| 2735 | + if ($globalDebug) { |
|
| 2736 | + echo '# Weather Station added'."\n"; |
|
| 2737 | + } |
|
| 1981 | 2738 | $Source->deleteOldLocationByType('wx'); |
| 1982 | 2739 | $weather_data = json_encode($line); |
| 1983 | 2740 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1987,7 +2744,9 @@ discard block |
||
| 1987 | 2744 | } |
| 1988 | 2745 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 1989 | 2746 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1990 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2747 | + if ($globalDebug) { |
|
| 2748 | + echo '☈ Lightning added'."\n"; |
|
| 2749 | + } |
|
| 1991 | 2750 | $Source->deleteOldLocationByType('lightning'); |
| 1992 | 2751 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
| 1993 | 2752 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1999,8 +2758,7 @@ discard block |
||
| 1999 | 2758 | print_r($line); |
| 2000 | 2759 | } |
| 2001 | 2760 | unset($data); |
| 2002 | - } |
|
| 2003 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2761 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2004 | 2762 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 2005 | 2763 | } |
| 2006 | 2764 | /* |
@@ -2009,7 +2767,9 @@ discard block |
||
| 2009 | 2767 | } |
| 2010 | 2768 | */ |
| 2011 | 2769 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 2012 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 2770 | + elseif ($line === true && $globalDebug) { |
|
| 2771 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2772 | + } |
|
| 2013 | 2773 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
| 2014 | 2774 | $Source->deleteOldLocationByType('lightning'); |
| 2015 | 2775 | $Source->deleteOldLocationByType('wx'); |
@@ -2046,27 +2806,47 @@ discard block |
||
| 2046 | 2806 | $data['ground'] = $line[21]; |
| 2047 | 2807 | $data['emergency'] = $line[19]; |
| 2048 | 2808 | $data['format_source'] = 'sbs'; |
| 2049 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2050 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
| 2051 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2052 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2809 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2810 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2811 | + } elseif ($line[0] == 'MLAT') { |
|
| 2812 | + $data['source_name'] = 'MLAT'; |
|
| 2813 | + } |
|
| 2814 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2815 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2816 | + } |
|
| 2817 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2818 | + $data['noarchive'] = true; |
|
| 2819 | + } |
|
| 2053 | 2820 | $data['id_source'] = $id_source; |
| 2054 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 2055 | - else $error = true; |
|
| 2821 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2822 | + $send = $SI->add($data); |
|
| 2823 | + } else { |
|
| 2824 | + $error = true; |
|
| 2825 | + } |
|
| 2056 | 2826 | unset($data); |
| 2057 | - } else $error = true; |
|
| 2827 | + } else { |
|
| 2828 | + $error = true; |
|
| 2829 | + } |
|
| 2058 | 2830 | if ($error) { |
| 2059 | 2831 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 2060 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2832 | + if ($globalDebug) { |
|
| 2833 | + echo "Not a message. Ignoring... \n"; |
|
| 2834 | + } |
|
| 2061 | 2835 | } else { |
| 2062 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2836 | + if ($globalDebug) { |
|
| 2837 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2838 | + } |
|
| 2063 | 2839 | if ($globalDebug) { |
| 2064 | 2840 | echo $buffer; |
| 2065 | 2841 | //print_r($line); |
| 2066 | 2842 | } |
| 2067 | 2843 | //socket_close($r); |
| 2068 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 2069 | - if ($format === 'aprs') $aprs_connect = 0; |
|
| 2844 | + if ($globalDebug) { |
|
| 2845 | + echo "Reconnect after an error...\n"; |
|
| 2846 | + } |
|
| 2847 | + if ($format === 'aprs') { |
|
| 2848 | + $aprs_connect = 0; |
|
| 2849 | + } |
|
| 2070 | 2850 | $sourceer[$nb] = $globalSources[$nb]; |
| 2071 | 2851 | connect_all($sourceer); |
| 2072 | 2852 | $sourceer = array(); |
@@ -2074,10 +2854,14 @@ discard block |
||
| 2074 | 2854 | } |
| 2075 | 2855 | } |
| 2076 | 2856 | // Sleep for xxx microseconds |
| 2077 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2857 | + if (isset($globalSBSSleep)) { |
|
| 2858 | + usleep($globalSBSSleep); |
|
| 2859 | + } |
|
| 2078 | 2860 | } else { |
| 2079 | 2861 | if ($format === 'flightgearmp') { |
| 2080 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2862 | + if ($globalDebug) { |
|
| 2863 | + echo "Reconnect FlightGear MP..."; |
|
| 2864 | + } |
|
| 2081 | 2865 | //@socket_close($r); |
| 2082 | 2866 | sleep($globalMinFetch); |
| 2083 | 2867 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2086,10 +2870,15 @@ discard block |
||
| 2086 | 2870 | break; |
| 2087 | 2871 | |
| 2088 | 2872 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 2089 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 2090 | - else $tt[$format] = 0; |
|
| 2873 | + if (isset($tt[$format])) { |
|
| 2874 | + $tt[$format]++; |
|
| 2875 | + } else { |
|
| 2876 | + $tt[$format] = 0; |
|
| 2877 | + } |
|
| 2091 | 2878 | if ($tt[$format] > 30 || $buffer === FALSE) { |
| 2092 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2879 | + if ($globalDebug) { |
|
| 2880 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2881 | + } |
|
| 2093 | 2882 | //@socket_close($r); |
| 2094 | 2883 | sleep(2); |
| 2095 | 2884 | $aprs_connect = 0; |
@@ -2107,11 +2896,17 @@ discard block |
||
| 2107 | 2896 | } else { |
| 2108 | 2897 | $error = socket_strerror(socket_last_error()); |
| 2109 | 2898 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2110 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2111 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2899 | + if ($globalDebug) { |
|
| 2900 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2901 | + } |
|
| 2902 | + if (isset($globalDebug)) { |
|
| 2903 | + echo "Restarting...\n"; |
|
| 2904 | + } |
|
| 2112 | 2905 | // Restart the script if possible |
| 2113 | 2906 | if (is_array($sockets)) { |
| 2114 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2907 | + if ($globalDebug) { |
|
| 2908 | + echo "Shutdown all sockets..."; |
|
| 2909 | + } |
|
| 2115 | 2910 | |
| 2116 | 2911 | foreach ($sockets as $sock) { |
| 2117 | 2912 | @socket_shutdown($sock,2); |
@@ -2119,25 +2914,45 @@ discard block |
||
| 2119 | 2914 | } |
| 2120 | 2915 | |
| 2121 | 2916 | } |
| 2122 | - if ($globalDebug) echo "Waiting..."; |
|
| 2917 | + if ($globalDebug) { |
|
| 2918 | + echo "Waiting..."; |
|
| 2919 | + } |
|
| 2123 | 2920 | sleep(2); |
| 2124 | 2921 | $time = time(); |
| 2125 | 2922 | //connect_all($hosts); |
| 2126 | 2923 | $aprs_connect = 0; |
| 2127 | - if ($reset%5 === 0) sleep(20); |
|
| 2128 | - if ($reset%10 === 0) sleep(100); |
|
| 2129 | - if ($reset%20 === 0) sleep(200); |
|
| 2130 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 2131 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 2924 | + if ($reset%5 === 0) { |
|
| 2925 | + sleep(20); |
|
| 2926 | + } |
|
| 2927 | + if ($reset%10 === 0) { |
|
| 2928 | + sleep(100); |
|
| 2929 | + } |
|
| 2930 | + if ($reset%20 === 0) { |
|
| 2931 | + sleep(200); |
|
| 2932 | + } |
|
| 2933 | + if ($reset > 100) { |
|
| 2934 | + exit('Too many attempts...'); |
|
| 2935 | + } |
|
| 2936 | + if ($globalDebug) { |
|
| 2937 | + echo "Restart all connections..."; |
|
| 2938 | + } |
|
| 2132 | 2939 | connect_all($globalSources); |
| 2133 | 2940 | } |
| 2134 | 2941 | } |
| 2135 | 2942 | } |
| 2136 | 2943 | if ($globalDaemon === false) { |
| 2137 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2138 | - if (isset($SI)) $SI->checkAll(); |
|
| 2139 | - if (isset($TI)) $TI->checkAll(); |
|
| 2140 | - if (isset($MI)) $MI->checkAll(); |
|
| 2944 | + if ($globalDebug) { |
|
| 2945 | + echo 'Check all...'."\n"; |
|
| 2946 | + } |
|
| 2947 | + if (isset($SI)) { |
|
| 2948 | + $SI->checkAll(); |
|
| 2949 | + } |
|
| 2950 | + if (isset($TI)) { |
|
| 2951 | + $TI->checkAll(); |
|
| 2952 | + } |
|
| 2953 | + if (isset($MI)) { |
|
| 2954 | + $MI->checkAll(); |
|
| 2955 | + } |
|
| 2141 | 2956 | } |
| 2142 | 2957 | } |
| 2143 | 2958 | } |