@@ -14,13 +14,17 @@ discard block |
||
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 17 | +if (isset($globalTracker) && $globalTracker) { |
|
| 18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 19 | +} |
|
| 18 | 20 | if (isset($globalMarine) && $globalMarine) { |
| 19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 25 | +if (!isset($globalDebug)) { |
|
| 26 | + $globalDebug = FALSE; |
|
| 27 | +} |
|
| 24 | 28 | |
| 25 | 29 | // Check if schema is at latest version |
| 26 | 30 | $Connection = new Connection(); |
@@ -59,66 +63,107 @@ discard block |
||
| 59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 60 | 64 | if (isset($options['s'])) { |
| 61 | 65 | $globalSources = array(); |
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['s']); |
|
| 64 | -} elseif (isset($options['source'])) { |
|
| 66 | + if (isset($options['format'])) { |
|
| 67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 68 | + } else { |
|
| 69 | + $globalSources[] = array('host' => $options['s']); |
|
| 70 | + } |
|
| 71 | + } elseif (isset($options['source'])) { |
|
| 65 | 72 | $globalSources = array(); |
| 66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | - else $globalSources[] = array('host' => $options['source']); |
|
| 68 | -} |
|
| 73 | + if (isset($options['format'])) { |
|
| 74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 75 | + } else { |
|
| 76 | + $globalSources[] = array('host' => $options['source']); |
|
| 77 | + } |
|
| 78 | + } |
|
| 69 | 79 | if (isset($options['aprsserverhost'])) { |
| 70 | 80 | $globalServerAPRS = TRUE; |
| 71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
| 72 | 82 | } |
| 73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 83 | +if (isset($options['aprsserverport'])) { |
|
| 84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 85 | +} |
|
| 86 | +if (isset($options['aprsserverssid'])) { |
|
| 87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 88 | +} |
|
| 89 | +if (isset($options['aprsserverpass'])) { |
|
| 90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 91 | +} |
|
| 92 | +if (isset($options['noaprsserver'])) { |
|
| 93 | + $globalServerAPRS = FALSE; |
|
| 94 | +} |
|
| 77 | 95 | if (isset($options['enable-aircraft'])) { |
| 78 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
| 96 | + if ($globalDebug) { |
|
| 97 | + echo 'Enable Aircraft mode'."\n"; |
|
| 98 | + } |
|
| 79 | 99 | $globalAircraft = TRUE; |
| 80 | 100 | } |
| 81 | 101 | if (isset($options['disable-aircraft'])) { |
| 82 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
| 102 | + if ($globalDebug) { |
|
| 103 | + echo 'Disable Aircraft mode'."\n"; |
|
| 104 | + } |
|
| 83 | 105 | $globalAircraft = FALSE; |
| 84 | 106 | } |
| 85 | 107 | if (isset($options['enable-tracker'])) { |
| 86 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
| 108 | + if ($globalDebug) { |
|
| 109 | + echo 'Enable Tracker mode'."\n"; |
|
| 110 | + } |
|
| 87 | 111 | $globalTracker = TRUE; |
| 88 | 112 | } |
| 89 | 113 | if (isset($options['disable-tracker'])) { |
| 90 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
| 114 | + if ($globalDebug) { |
|
| 115 | + echo 'Disable Tracker mode'."\n"; |
|
| 116 | + } |
|
| 91 | 117 | $globalTracker = FALSE; |
| 92 | 118 | } |
| 93 | 119 | if (isset($options['enable-marine'])) { |
| 94 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
| 120 | + if ($globalDebug) { |
|
| 121 | + echo 'Enable Marine mode'."\n"; |
|
| 122 | + } |
|
| 95 | 123 | $globalMarine = TRUE; |
| 96 | 124 | } |
| 97 | 125 | if (isset($options['disable-marine'])) { |
| 98 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
| 126 | + if ($globalDebug) { |
|
| 127 | + echo 'Disable Marine mode'."\n"; |
|
| 128 | + } |
|
| 99 | 129 | $globalMarine = FALSE; |
| 100 | 130 | } |
| 101 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 102 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 103 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 104 | -else $id_source = 1; |
|
| 131 | +if (isset($options['nodaemon'])) { |
|
| 132 | + $globalDaemon = FALSE; |
|
| 133 | +} |
|
| 134 | +if (isset($options['server'])) { |
|
| 135 | + $globalServer = TRUE; |
|
| 136 | +} |
|
| 137 | +if (isset($options['idsource'])) { |
|
| 138 | + $id_source = $options['idsource']; |
|
| 139 | +} else { |
|
| 140 | + $id_source = 1; |
|
| 141 | +} |
|
| 105 | 142 | if (isset($globalServer) && $globalServer) { |
| 106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 143 | + if ($globalDebug) { |
|
| 144 | + echo "Using Server Mode\n"; |
|
| 145 | + } |
|
| 107 | 146 | $SI=new SpotterServer(); |
| 108 | 147 | /* |
| 109 | 148 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 110 | 149 | $SI = new adsb2aprs(); |
| 111 | 150 | $SI->connect(); |
| 112 | 151 | */ |
| 113 | -} else $SI=new SpotterImport($Connection->db); |
|
| 152 | +} else { |
|
| 153 | + $SI=new SpotterImport($Connection->db); |
|
| 154 | +} |
|
| 114 | 155 | |
| 115 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 156 | +if (isset($globalTracker) && $globalTracker) { |
|
| 157 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 158 | +} |
|
| 116 | 159 | if (isset($globalMarine) && $globalMarine) { |
| 117 | 160 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 118 | 161 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 119 | 162 | } |
| 120 | 163 | |
| 121 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 164 | +if (isset($globalTracker) && $globalTracker) { |
|
| 165 | + $TI = new TrackerImport($Connection->db); |
|
| 166 | +} |
|
| 122 | 167 | if (isset($globalMarine) && $globalMarine) { |
| 123 | 168 | $AIS = new AIS(); |
| 124 | 169 | $MI = new MarineImport($Connection->db); |
@@ -143,7 +188,9 @@ discard block |
||
| 143 | 188 | } |
| 144 | 189 | |
| 145 | 190 | // let's try and connect |
| 146 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 191 | +if ($globalDebug) { |
|
| 192 | + echo "Connecting...\n"; |
|
| 193 | +} |
|
| 147 | 194 | $use_aprs = false; |
| 148 | 195 | $aprs_full = false; |
| 149 | 196 | $reset = 0; |
@@ -152,7 +199,9 @@ discard block |
||
| 152 | 199 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 153 | 200 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 154 | 201 | $reset++; |
| 155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 202 | + if ($globalDebug) { |
|
| 203 | + echo 'Connect to all...'."\n"; |
|
| 204 | + } |
|
| 156 | 205 | foreach ($hosts as $id => $value) { |
| 157 | 206 | $host = $value['host']; |
| 158 | 207 | $globalSources[$id]['last_exec'] = 0; |
@@ -162,32 +211,44 @@ discard block |
||
| 162 | 211 | //$formats[$id] = 'deltadbtxt'; |
| 163 | 212 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 164 | 213 | //$last_exec['deltadbtxt'] = 0; |
| 165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 214 | + if ($globalDebug) { |
|
| 215 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 216 | + } |
|
| 166 | 217 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 167 | 218 | //$formats[$id] = 'vatsimtxt'; |
| 168 | 219 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 169 | 220 | //$last_exec['vatsimtxt'] = 0; |
| 170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 221 | + if ($globalDebug) { |
|
| 222 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 223 | + } |
|
| 171 | 224 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 172 | 225 | //$formats[$id] = 'aircraftlistjson'; |
| 173 | 226 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 174 | 227 | //$last_exec['aircraftlistjson'] = 0; |
| 175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 228 | + if ($globalDebug) { |
|
| 229 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 230 | + } |
|
| 176 | 231 | } else if (preg_match('/aircraft.json$/i',$host)) { |
| 177 | 232 | //$formats[$id] = 'aircraftjson'; |
| 178 | 233 | $globalSources[$id]['format'] = 'aircraftjson'; |
| 179 | 234 | //$last_exec['aircraftlistjson'] = 0; |
| 180 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 235 | + if ($globalDebug) { |
|
| 236 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 237 | + } |
|
| 181 | 238 | } else if (preg_match('/aircraft$/i',$host)) { |
| 182 | 239 | //$formats[$id] = 'planefinderclient'; |
| 183 | 240 | $globalSources[$id]['format'] = 'planefinderclient'; |
| 184 | 241 | //$last_exec['aircraftlistjson'] = 0; |
| 185 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 242 | + if ($globalDebug) { |
|
| 243 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 244 | + } |
|
| 186 | 245 | } else if (preg_match('/opensky/i',$host)) { |
| 187 | 246 | //$formats[$id] = 'aircraftlistjson'; |
| 188 | 247 | $globalSources[$id]['format'] = 'opensky'; |
| 189 | 248 | //$last_exec['aircraftlistjson'] = 0; |
| 190 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 249 | + if ($globalDebug) { |
|
| 250 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 251 | + } |
|
| 191 | 252 | /* |
| 192 | 253 | // Disabled for now, site change source format |
| 193 | 254 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -204,7 +265,9 @@ discard block |
||
| 204 | 265 | //$formats[$id] = 'planeupdatefaa'; |
| 205 | 266 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 206 | 267 | //$last_exec['planeupdatefaa'] = 0; |
| 207 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 268 | + if ($globalDebug) { |
|
| 269 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 270 | + } |
|
| 208 | 271 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 209 | 272 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 210 | 273 | exit(0); |
@@ -213,37 +276,53 @@ discard block |
||
| 213 | 276 | //$formats[$id] = 'phpvmacars'; |
| 214 | 277 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 215 | 278 | //$last_exec['phpvmacars'] = 0; |
| 216 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 279 | + if ($globalDebug) { |
|
| 280 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 281 | + } |
|
| 217 | 282 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
| 218 | 283 | //$formats[$id] = 'phpvmacars'; |
| 219 | 284 | $globalSources[$id]['format'] = 'vaos'; |
| 220 | 285 | //$last_exec['phpvmacars'] = 0; |
| 221 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 286 | + if ($globalDebug) { |
|
| 287 | + echo "Connect to vaos source (".$host.")...\n"; |
|
| 288 | + } |
|
| 222 | 289 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 223 | 290 | //$formats[$id] = 'phpvmacars'; |
| 224 | 291 | $globalSources[$id]['format'] = 'vam'; |
| 225 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 292 | + if ($globalDebug) { |
|
| 293 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 294 | + } |
|
| 226 | 295 | } else if (preg_match('/whazzup/i',$host)) { |
| 227 | 296 | //$formats[$id] = 'whazzup'; |
| 228 | 297 | $globalSources[$id]['format'] = 'whazzup'; |
| 229 | 298 | //$last_exec['whazzup'] = 0; |
| 230 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 299 | + if ($globalDebug) { |
|
| 300 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 301 | + } |
|
| 231 | 302 | } else if (preg_match('/blitzortung/i',$host)) { |
| 232 | 303 | $globalSources[$id]['format'] = 'blitzortung'; |
| 233 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 304 | + if ($globalDebug) { |
|
| 305 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 306 | + } |
|
| 234 | 307 | } else if (preg_match('/airwhere/i',$host)) { |
| 235 | 308 | $globalSources[$id]['format'] = 'airwhere'; |
| 236 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 309 | + if ($globalDebug) { |
|
| 310 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 311 | + } |
|
| 237 | 312 | } else if (preg_match('/recentpireps/i',$host)) { |
| 238 | 313 | //$formats[$id] = 'pirepsjson'; |
| 239 | 314 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 240 | 315 | //$last_exec['pirepsjson'] = 0; |
| 241 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 316 | + if ($globalDebug) { |
|
| 317 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 318 | + } |
|
| 242 | 319 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 243 | 320 | //$formats[$id] = 'fr24json'; |
| 244 | 321 | $globalSources[$id]['format'] = 'fr24json'; |
| 245 | 322 | //$last_exec['fr24json'] = 0; |
| 246 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 323 | + if ($globalDebug) { |
|
| 324 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 325 | + } |
|
| 247 | 326 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 248 | 327 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 249 | 328 | exit(0); |
@@ -252,7 +331,9 @@ discard block |
||
| 252 | 331 | //$formats[$id] = 'fr24json'; |
| 253 | 332 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 254 | 333 | //$last_exec['fr24json'] = 0; |
| 255 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 334 | + if ($globalDebug) { |
|
| 335 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 336 | + } |
|
| 256 | 337 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 257 | 338 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 258 | 339 | exit(0); |
@@ -261,17 +342,26 @@ discard block |
||
| 261 | 342 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 262 | 343 | //$formats[$id] = 'tsv'; |
| 263 | 344 | $globalSources[$id]['format'] = 'tsv'; |
| 264 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 345 | + if ($globalDebug) { |
|
| 346 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 347 | + } |
|
| 265 | 348 | } |
| 266 | 349 | } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) { |
| 267 | 350 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 268 | 351 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 269 | 352 | if ($idf !== false) { |
| 270 | 353 | $httpfeeds[$id] = $idf; |
| 271 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 272 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 273 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 274 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 354 | + if ($globalDebug) { |
|
| 355 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 356 | + } |
|
| 357 | + } elseif ($globalDebug) { |
|
| 358 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 359 | + } |
|
| 360 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { |
|
| 361 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 362 | + } elseif ($globalDebug) { |
|
| 363 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 364 | + } |
|
| 275 | 365 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 276 | 366 | $hostport = explode(':',$host); |
| 277 | 367 | if (isset($hostport[1])) { |
@@ -311,19 +401,27 @@ discard block |
||
| 311 | 401 | //$formats[$id] = 'beast'; |
| 312 | 402 | $globalSources[$id]['format'] = 'beast'; |
| 313 | 403 | //} else $formats[$id] = 'sbs'; |
| 314 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 404 | + } else { |
|
| 405 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 406 | + } |
|
| 315 | 407 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 316 | 408 | } |
| 317 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 409 | + if ($globalDebug) { |
|
| 410 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 411 | + } |
|
| 318 | 412 | } else { |
| 319 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 413 | + if ($globalDebug) { |
|
| 414 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 415 | + } |
|
| 320 | 416 | sleep(10); |
| 321 | 417 | connect_all($hosts); |
| 322 | 418 | } |
| 323 | 419 | } |
| 324 | 420 | } |
| 325 | 421 | } |
| 326 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 422 | +if (!isset($globalMinFetch)) { |
|
| 423 | + $globalMinFetch = 15; |
|
| 424 | +} |
|
| 327 | 425 | |
| 328 | 426 | // Initialize all |
| 329 | 427 | $status = array(); |
@@ -332,13 +430,19 @@ discard block |
||
| 332 | 430 | $formats = array(); |
| 333 | 431 | $last_exec = array(); |
| 334 | 432 | $time = time(); |
| 335 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 336 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 337 | -else $timeout = 20; |
|
| 433 | +if (isset($globalSourcesTimeout)) { |
|
| 434 | + $timeout = $globalSourcesTimeOut; |
|
| 435 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 436 | + $timeout = $globalSBS1TimeOut; |
|
| 437 | +} else { |
|
| 438 | + $timeout = 20; |
|
| 439 | +} |
|
| 338 | 440 | $errno = ''; |
| 339 | 441 | $errstr=''; |
| 340 | 442 | |
| 341 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 443 | +if (!isset($globalDaemon)) { |
|
| 444 | + $globalDaemon = TRUE; |
|
| 445 | +} |
|
| 342 | 446 | /* Initiate connections to all the hosts simultaneously */ |
| 343 | 447 | //connect_all($hosts); |
| 344 | 448 | //connect_all($globalSources); |
@@ -367,7 +471,9 @@ discard block |
||
| 367 | 471 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 368 | 472 | $aprs_connect = 0; |
| 369 | 473 | $use_aprs = true; |
| 370 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 474 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 475 | + $aprs_full = true; |
|
| 476 | + } |
|
| 371 | 477 | break; |
| 372 | 478 | } |
| 373 | 479 | } |
@@ -378,25 +484,46 @@ discard block |
||
| 378 | 484 | $aprs_connect = 0; |
| 379 | 485 | $aprs_keep = 120; |
| 380 | 486 | $aprs_last_tx = time(); |
| 381 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 382 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 383 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 384 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 385 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 386 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 387 | - if ($aprs_full) $aprs_filter = ''; |
|
| 388 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 389 | - else $aprs_pass = '-1'; |
|
| 487 | + if (isset($globalAPRSversion)) { |
|
| 488 | + $aprs_version = $globalAPRSversion; |
|
| 489 | + } else { |
|
| 490 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 491 | + } |
|
| 492 | + if (isset($globalAPRSssid)) { |
|
| 493 | + $aprs_ssid = $globalAPRSssid; |
|
| 494 | + } else { |
|
| 495 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 496 | + } |
|
| 497 | + if (isset($globalAPRSfilter)) { |
|
| 498 | + $aprs_filter = $globalAPRSfilter; |
|
| 499 | + } else { |
|
| 500 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 501 | + } |
|
| 502 | + if ($aprs_full) { |
|
| 503 | + $aprs_filter = ''; |
|
| 504 | + } |
|
| 505 | + if (isset($globalAPRSpass)) { |
|
| 506 | + $aprs_pass = $globalAPRSpass; |
|
| 507 | + } else { |
|
| 508 | + $aprs_pass = '-1'; |
|
| 509 | + } |
|
| 390 | 510 | |
| 391 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 392 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 393 | -} |
|
| 511 | + if ($aprs_filter != '') { |
|
| 512 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 513 | + } else { |
|
| 514 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 515 | + } |
|
| 516 | + } |
|
| 394 | 517 | |
| 395 | 518 | // connected - lets do some work |
| 396 | 519 | //if ($globalDebug) echo "Connected!\n"; |
| 397 | 520 | sleep(1); |
| 398 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 399 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 521 | +if ($globalDebug) { |
|
| 522 | + echo "SCAN MODE \n\n"; |
|
| 523 | +} |
|
| 524 | +if (!isset($globalCronEnd)) { |
|
| 525 | + $globalCronEnd = 60; |
|
| 526 | +} |
|
| 400 | 527 | $endtime = time()+$globalCronEnd; |
| 401 | 528 | $i = 1; |
| 402 | 529 | $tt = array(); |
@@ -410,22 +537,32 @@ discard block |
||
| 410 | 537 | |
| 411 | 538 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 412 | 539 | while ($i > 0) { |
| 413 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 540 | + if (function_exists('pcntl_fork')) { |
|
| 541 | + pcntl_signal_dispatch(); |
|
| 542 | + } |
|
| 414 | 543 | |
| 415 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 544 | + if (!$globalDaemon) { |
|
| 545 | + $i = $endtime-time(); |
|
| 546 | + } |
|
| 416 | 547 | // Delete old ATC |
| 417 | 548 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 418 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 549 | + if ($globalDebug) { |
|
| 550 | + echo 'Delete old ATC...'."\n"; |
|
| 551 | + } |
|
| 419 | 552 | $ATC->deleteOldATC(); |
| 420 | 553 | } |
| 421 | 554 | |
| 422 | 555 | if (count($last_exec) == count($globalSources)) { |
| 423 | 556 | $max = $globalMinFetch; |
| 424 | 557 | foreach ($last_exec as $last) { |
| 425 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 558 | + if ((time() - $last['last']) < $max) { |
|
| 559 | + $max = time() - $last['last']; |
|
| 560 | + } |
|
| 426 | 561 | } |
| 427 | 562 | if ($max < $globalMinFetch) { |
| 428 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 563 | + if ($globalDebug) { |
|
| 564 | + echo 'Sleeping...'."\n"; |
|
| 565 | + } |
|
| 429 | 566 | sleep($globalMinFetch-$max+2); |
| 430 | 567 | } |
| 431 | 568 | } |
@@ -435,7 +572,9 @@ discard block |
||
| 435 | 572 | foreach ($globalSources as $id => $value) { |
| 436 | 573 | date_default_timezone_set('UTC'); |
| 437 | 574 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 438 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 575 | + if (!isset($last_exec[$id]['last'])) { |
|
| 576 | + $last_exec[$id]['last'] = 0; |
|
| 577 | + } |
|
| 439 | 578 | if ($value['format'] === 'deltadbtxt' && |
| 440 | 579 | ( |
| 441 | 580 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -444,7 +583,9 @@ discard block |
||
| 444 | 583 | ) { |
| 445 | 584 | //$buffer = $Common->getData($hosts[$id]); |
| 446 | 585 | $buffer = $Common->getData($value['host']); |
| 447 | - if ($buffer != '') $reset = 0; |
|
| 586 | + if ($buffer != '') { |
|
| 587 | + $reset = 0; |
|
| 588 | + } |
|
| 448 | 589 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 449 | 590 | $buffer = explode('\n',$buffer); |
| 450 | 591 | foreach ($buffer as $line) { |
@@ -453,20 +594,41 @@ discard block |
||
| 453 | 594 | $data = array(); |
| 454 | 595 | $data['hex'] = $line[1]; // hex |
| 455 | 596 | $data['ident'] = $line[2]; // ident |
| 456 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 457 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 458 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 459 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 460 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 597 | + if (isset($line[3])) { |
|
| 598 | + $data['altitude'] = $line[3]; |
|
| 599 | + } |
|
| 600 | + // altitude |
|
| 601 | + if (isset($line[4])) { |
|
| 602 | + $data['speed'] = $line[4]; |
|
| 603 | + } |
|
| 604 | + // speed |
|
| 605 | + if (isset($line[5])) { |
|
| 606 | + $data['heading'] = $line[5]; |
|
| 607 | + } |
|
| 608 | + // heading |
|
| 609 | + if (isset($line[6])) { |
|
| 610 | + $data['latitude'] = $line[6]; |
|
| 611 | + } |
|
| 612 | + // lat |
|
| 613 | + if (isset($line[7])) { |
|
| 614 | + $data['longitude'] = $line[7]; |
|
| 615 | + } |
|
| 616 | + // long |
|
| 461 | 617 | $data['verticalrate'] = ''; // vertical rate |
| 462 | 618 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 463 | 619 | $data['emergency'] = ''; // emergency |
| 464 | 620 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 465 | 621 | $data['format_source'] = 'deltadbtxt'; |
| 466 | 622 | $data['id_source'] = $id_source; |
| 467 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 468 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 469 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 623 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 624 | + $data['source_name'] = $value['name']; |
|
| 625 | + } |
|
| 626 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 627 | + $data['noarchive'] = true; |
|
| 628 | + } |
|
| 629 | + if (isset($value['sourcestats'])) { |
|
| 630 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 631 | + } |
|
| 470 | 632 | $SI->add($data); |
| 471 | 633 | unset($data); |
| 472 | 634 | } |
@@ -481,7 +643,9 @@ discard block |
||
| 481 | 643 | date_default_timezone_set('CET'); |
| 482 | 644 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 483 | 645 | date_default_timezone_set('UTC'); |
| 484 | - if ($buffer != '') $reset = 0; |
|
| 646 | + if ($buffer != '') { |
|
| 647 | + $reset = 0; |
|
| 648 | + } |
|
| 485 | 649 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 486 | 650 | $buffer = explode('\n',$buffer); |
| 487 | 651 | foreach ($buffer as $line) { |
@@ -490,18 +654,42 @@ discard block |
||
| 490 | 654 | $add = false; |
| 491 | 655 | $ais_data = $AIS->parse_line(trim($line)); |
| 492 | 656 | $data = array(); |
| 493 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 494 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 495 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 496 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 497 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 498 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 499 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 500 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 501 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 502 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 503 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 504 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 657 | + if (isset($ais_data['ident'])) { |
|
| 658 | + $data['ident'] = $ais_data['ident']; |
|
| 659 | + } |
|
| 660 | + if (isset($ais_data['mmsi'])) { |
|
| 661 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 662 | + } |
|
| 663 | + if (isset($ais_data['speed'])) { |
|
| 664 | + $data['speed'] = $ais_data['speed']; |
|
| 665 | + } |
|
| 666 | + if (isset($ais_data['heading'])) { |
|
| 667 | + $data['heading'] = $ais_data['heading']; |
|
| 668 | + } |
|
| 669 | + if (isset($ais_data['latitude'])) { |
|
| 670 | + $data['latitude'] = $ais_data['latitude']; |
|
| 671 | + } |
|
| 672 | + if (isset($ais_data['longitude'])) { |
|
| 673 | + $data['longitude'] = $ais_data['longitude']; |
|
| 674 | + } |
|
| 675 | + if (isset($ais_data['status'])) { |
|
| 676 | + $data['status'] = $ais_data['status']; |
|
| 677 | + } |
|
| 678 | + if (isset($ais_data['statusid'])) { |
|
| 679 | + $data['status_id'] = $ais_data['statusid']; |
|
| 680 | + } |
|
| 681 | + if (isset($ais_data['type'])) { |
|
| 682 | + $data['type'] = $ais_data['type']; |
|
| 683 | + } |
|
| 684 | + if (isset($ais_data['typeid'])) { |
|
| 685 | + $data['type_id'] = $ais_data['typeid']; |
|
| 686 | + } |
|
| 687 | + if (isset($ais_data['imo'])) { |
|
| 688 | + $data['imo'] = $ais_data['imo']; |
|
| 689 | + } |
|
| 690 | + if (isset($ais_data['callsign'])) { |
|
| 691 | + $data['callsign'] = $ais_data['callsign']; |
|
| 692 | + } |
|
| 505 | 693 | if (isset($ais_data['timestamp'])) { |
| 506 | 694 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 507 | 695 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -515,8 +703,12 @@ discard block |
||
| 515 | 703 | $data['format_source'] = 'aisnmeatxt'; |
| 516 | 704 | $data['id_source'] = $id_source; |
| 517 | 705 | //print_r($data); |
| 518 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 519 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 706 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 707 | + $data['noarchive'] = true; |
|
| 708 | + } |
|
| 709 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 710 | + $MI->add($data); |
|
| 711 | + } |
|
| 520 | 712 | unset($data); |
| 521 | 713 | } |
| 522 | 714 | } |
@@ -539,20 +731,48 @@ discard block |
||
| 539 | 731 | if ($line != '') { |
| 540 | 732 | $ais_data = $AIS->parse_line(trim($line)); |
| 541 | 733 | $data = array(); |
| 542 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 543 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 544 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 545 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 546 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 547 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 548 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 549 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 550 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 551 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 552 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 553 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 554 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 555 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 734 | + if (isset($ais_data['ident'])) { |
|
| 735 | + $data['ident'] = $ais_data['ident']; |
|
| 736 | + } |
|
| 737 | + if (isset($ais_data['mmsi'])) { |
|
| 738 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 739 | + } |
|
| 740 | + if (isset($ais_data['speed'])) { |
|
| 741 | + $data['speed'] = $ais_data['speed']; |
|
| 742 | + } |
|
| 743 | + if (isset($ais_data['heading'])) { |
|
| 744 | + $data['heading'] = $ais_data['heading']; |
|
| 745 | + } |
|
| 746 | + if (isset($ais_data['latitude'])) { |
|
| 747 | + $data['latitude'] = $ais_data['latitude']; |
|
| 748 | + } |
|
| 749 | + if (isset($ais_data['longitude'])) { |
|
| 750 | + $data['longitude'] = $ais_data['longitude']; |
|
| 751 | + } |
|
| 752 | + if (isset($ais_data['status'])) { |
|
| 753 | + $data['status'] = $ais_data['status']; |
|
| 754 | + } |
|
| 755 | + if (isset($ais_data['statusid'])) { |
|
| 756 | + $data['status_id'] = $ais_data['statusid']; |
|
| 757 | + } |
|
| 758 | + if (isset($ais_data['type'])) { |
|
| 759 | + $data['type'] = $ais_data['type']; |
|
| 760 | + } |
|
| 761 | + if (isset($ais_data['typeid'])) { |
|
| 762 | + $data['type_id'] = $ais_data['typeid']; |
|
| 763 | + } |
|
| 764 | + if (isset($ais_data['imo'])) { |
|
| 765 | + $data['imo'] = $ais_data['imo']; |
|
| 766 | + } |
|
| 767 | + if (isset($ais_data['callsign'])) { |
|
| 768 | + $data['callsign'] = $ais_data['callsign']; |
|
| 769 | + } |
|
| 770 | + if (isset($ais_data['destination'])) { |
|
| 771 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 772 | + } |
|
| 773 | + if (isset($ais_data['eta_ts'])) { |
|
| 774 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 775 | + } |
|
| 556 | 776 | if (isset($ais_data['timestamp'])) { |
| 557 | 777 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 558 | 778 | } else { |
@@ -560,18 +780,27 @@ discard block |
||
| 560 | 780 | } |
| 561 | 781 | $data['format_source'] = 'aisnmeahttp'; |
| 562 | 782 | $data['id_source'] = $id_source; |
| 563 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 564 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 783 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 784 | + $data['noarchive'] = true; |
|
| 785 | + } |
|
| 786 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 787 | + $MI->add($data); |
|
| 788 | + } |
|
| 565 | 789 | unset($data); |
| 566 | 790 | } |
| 567 | 791 | } |
| 568 | 792 | } |
| 569 | 793 | } else { |
| 570 | 794 | $format = $value['format']; |
| 571 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 572 | - else $tt[$format] = 0; |
|
| 795 | + if (isset($tt[$format])) { |
|
| 796 | + $tt[$format]++; |
|
| 797 | + } else { |
|
| 798 | + $tt[$format] = 0; |
|
| 799 | + } |
|
| 573 | 800 | if ($tt[$format] > 30) { |
| 574 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 801 | + if ($globalDebug) { |
|
| 802 | + echo 'Reconnect...'."\n"; |
|
| 803 | + } |
|
| 575 | 804 | sleep(2); |
| 576 | 805 | //$sourceeen[] = $value; |
| 577 | 806 | //connect_all($sourceeen); |
@@ -607,12 +836,18 @@ discard block |
||
| 607 | 836 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 608 | 837 | //$data['type_id'] = $line['TYPE']; |
| 609 | 838 | $data['imo'] = $line['IMO']; |
| 610 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 611 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 839 | + if ($line['DEST'] != '') { |
|
| 840 | + $data['arrival_code'] = $line['DEST']; |
|
| 841 | + } |
|
| 842 | + if ($line['ARV'] != '') { |
|
| 843 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 844 | + } |
|
| 612 | 845 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 613 | 846 | $data['format_source'] = 'myshiptracking'; |
| 614 | 847 | $data['id_source'] = $id_source; |
| 615 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 848 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 849 | + $data['noarchive'] = true; |
|
| 850 | + } |
|
| 616 | 851 | $MI->add($data); |
| 617 | 852 | unset($data); |
| 618 | 853 | } |
@@ -637,7 +872,9 @@ discard block |
||
| 637 | 872 | $data['callsign'] = $line['callsign']; |
| 638 | 873 | $data['mmsi'] = substr($line['mmsi'],-9); |
| 639 | 874 | $data['speed'] = $line['sog']; |
| 640 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 875 | + if ($line['heading'] != '511') { |
|
| 876 | + $data['heading'] = $line['heading']; |
|
| 877 | + } |
|
| 641 | 878 | $data['latitude'] = $line['latitude']; |
| 642 | 879 | $data['longitude'] = $line['longitude']; |
| 643 | 880 | $data['type_id'] = $line['shiptype']; |
@@ -645,7 +882,9 @@ discard block |
||
| 645 | 882 | $data['datetime'] = $line['time']; |
| 646 | 883 | $data['format_source'] = 'boatbeaconapp'; |
| 647 | 884 | $data['id_source'] = $id_source; |
| 648 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 885 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 886 | + $data['noarchive'] = true; |
|
| 887 | + } |
|
| 649 | 888 | $MI->add($data); |
| 650 | 889 | unset($data); |
| 651 | 890 | } |
@@ -667,22 +906,44 @@ discard block |
||
| 667 | 906 | foreach ($all_data['features'] as $line) { |
| 668 | 907 | print_r($line); |
| 669 | 908 | $data = array(); |
| 670 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 671 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 672 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 673 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
| 674 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 675 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
| 909 | + if (isset($line['properties']['name'])) { |
|
| 910 | + $data['ident'] = $line['properties']['name']; |
|
| 911 | + } |
|
| 912 | + if (isset($line['properties']['callsign'])) { |
|
| 913 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 914 | + } |
|
| 915 | + if (isset($line['properties']['mmsi'])) { |
|
| 916 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 917 | + } |
|
| 918 | + if (isset($line['properties']['imo'])) { |
|
| 919 | + $data['imo'] = $line['properties']['imo']; |
|
| 920 | + } |
|
| 921 | + if (isset($line['properties']['speed'])) { |
|
| 922 | + $data['speed'] = $line['properties']['speed']; |
|
| 923 | + } |
|
| 924 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
| 925 | + $data['heading'] = $line['properties']['heading']; |
|
| 926 | + } |
|
| 676 | 927 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 677 | 928 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 678 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 679 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 680 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 929 | + if (isset($line['properties']['vesselType'])) { |
|
| 930 | + $data['type'] = $line['properties']['vesselType']; |
|
| 931 | + } |
|
| 932 | + if (isset($line['properties']['destination'])) { |
|
| 933 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 934 | + } |
|
| 935 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 936 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 937 | + } |
|
| 681 | 938 | $data['format_source'] = 'boatnerd'; |
| 682 | 939 | $data['id_source'] = $id_source; |
| 683 | 940 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 684 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 685 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 941 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 942 | + $data['noarchive'] = true; |
|
| 943 | + } |
|
| 944 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 945 | + $MI->add($data); |
|
| 946 | + } |
|
| 686 | 947 | unset($data); |
| 687 | 948 | } |
| 688 | 949 | } |
@@ -695,11 +956,17 @@ discard block |
||
| 695 | 956 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 696 | 957 | ) |
| 697 | 958 | ) { |
| 698 | - if ($globalDebug) echo 'download...'; |
|
| 959 | + if ($globalDebug) { |
|
| 960 | + echo 'download...'; |
|
| 961 | + } |
|
| 699 | 962 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 700 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 963 | + if ($globalDebug) { |
|
| 964 | + echo 'done !'."\n"; |
|
| 965 | + } |
|
| 701 | 966 | // FIXME: Need more work |
| 702 | - if ($buffer != '') $reset = 0; |
|
| 967 | + if ($buffer != '') { |
|
| 968 | + $reset = 0; |
|
| 969 | + } |
|
| 703 | 970 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 704 | 971 | $buffer = explode('\n',$buffer); |
| 705 | 972 | foreach ($buffer as $line) { |
@@ -725,7 +992,9 @@ discard block |
||
| 725 | 992 | //$data['etaTime'] = substr($line,135,5); |
| 726 | 993 | $data['format_source'] = 'shipplotter'; |
| 727 | 994 | $data['id_source'] = $id_source; |
| 728 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 995 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 996 | + $data['noarchive'] = true; |
|
| 997 | + } |
|
| 729 | 998 | //print_r($data); |
| 730 | 999 | //echo 'Add...'."\n"; |
| 731 | 1000 | $MI->add($data); |
@@ -748,11 +1017,17 @@ discard block |
||
| 748 | 1017 | } |
| 749 | 1018 | } |
| 750 | 1019 | |
| 751 | - if ($globalDebug) echo '! Download... '; |
|
| 1020 | + if ($globalDebug) { |
|
| 1021 | + echo '! Download... '; |
|
| 1022 | + } |
|
| 752 | 1023 | for ($i =0; $i <= 1; $i++) { |
| 753 | - if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
| 1024 | + if ($globalDebug) { |
|
| 1025 | + echo 'Racetype: '.$i.' '; |
|
| 1026 | + } |
|
| 754 | 1027 | $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
| 755 | - if ($globalDebug) echo 'done'."\n"; |
|
| 1028 | + if ($globalDebug) { |
|
| 1029 | + echo 'done'."\n"; |
|
| 1030 | + } |
|
| 756 | 1031 | if ($buffer != '') { |
| 757 | 1032 | $all_data = json_decode($buffer,true); |
| 758 | 1033 | if (isset($all_data['missions'])) { |
@@ -760,8 +1035,11 @@ discard block |
||
| 760 | 1035 | $mission_user = $mission['usrname']; |
| 761 | 1036 | $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
| 762 | 1037 | if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
| 763 | - if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
| 764 | - else $racebuffer = ''; |
|
| 1038 | + if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { |
|
| 1039 | + $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
|
| 1040 | + } else { |
|
| 1041 | + $racebuffer = ''; |
|
| 1042 | + } |
|
| 765 | 1043 | $bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
| 766 | 1044 | } else { |
| 767 | 1045 | $bufferm = ''; |
@@ -825,7 +1103,9 @@ discard block |
||
| 825 | 1103 | $data['captain_id'] = $sail['usrnr']; |
| 826 | 1104 | $data['captain_name'] = $sail['usrname']; |
| 827 | 1105 | $data['race_id'] = $sail['misnr']; |
| 828 | - if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank']; |
|
| 1106 | + if ($sail['rank'] != 'DNF') { |
|
| 1107 | + $data['race_rank'] = $sail['rank']; |
|
| 1108 | + } |
|
| 829 | 1109 | $data['race_time'] = $sail['racetime']; |
| 830 | 1110 | if ($mission_user != '') { |
| 831 | 1111 | $data['race_name'] = $mission_name.' ('.$mission_user.')'; |
@@ -835,7 +1115,9 @@ discard block |
||
| 835 | 1115 | //$data['callsign'] = trim(substr($line,100,7); |
| 836 | 1116 | $data['format_source'] = 'sailaway'; |
| 837 | 1117 | $data['id_source'] = $id_source; |
| 838 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1118 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1119 | + $data['noarchive'] = true; |
|
| 1120 | + } |
|
| 839 | 1121 | //print_r($data); |
| 840 | 1122 | //echo 'Add...'."\n"; |
| 841 | 1123 | $MI->add($data); |
@@ -876,16 +1158,28 @@ discard block |
||
| 876 | 1158 | $line = explode(':', $line); |
| 877 | 1159 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 878 | 1160 | $data = array(); |
| 879 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 880 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1161 | + if (isset($line[37]) && $line[37] != '') { |
|
| 1162 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 1163 | + } else { |
|
| 1164 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1165 | + } |
|
| 881 | 1166 | $data['pilot_id'] = $line[1]; |
| 882 | 1167 | $data['pilot_name'] = $line[2]; |
| 883 | 1168 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 884 | 1169 | $data['ident'] = $line[0]; // ident |
| 885 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 1170 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 1171 | + $data['altitude'] = $line[7]; |
|
| 1172 | + } |
|
| 1173 | + // altitude |
|
| 886 | 1174 | $data['speed'] = $line[8]; // speed |
| 887 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 888 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 1175 | + if (isset($line[45])) { |
|
| 1176 | + $data['heading'] = $line[45]; |
|
| 1177 | + } |
|
| 1178 | + // heading |
|
| 1179 | + elseif (isset($line[38])) { |
|
| 1180 | + $data['heading'] = $line[38]; |
|
| 1181 | + } |
|
| 1182 | + // heading |
|
| 889 | 1183 | $data['latitude'] = $line[5]; // lat |
| 890 | 1184 | $data['longitude'] = $line[6]; // long |
| 891 | 1185 | $data['verticalrate'] = ''; // vertical rate |
@@ -901,7 +1195,9 @@ discard block |
||
| 901 | 1195 | $data['frequency'] = $line[4]; |
| 902 | 1196 | $data['type'] = $line[18]; |
| 903 | 1197 | $data['range'] = $line[19]; |
| 904 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 1198 | + if (isset($line[35])) { |
|
| 1199 | + $data['info'] = $line[35]; |
|
| 1200 | + } |
|
| 905 | 1201 | $data['id_source'] = $id_source; |
| 906 | 1202 | //$data['arrival_airport_time'] = ; |
| 907 | 1203 | if ($line[9] != '') { |
@@ -915,27 +1211,47 @@ discard block |
||
| 915 | 1211 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 916 | 1212 | */ |
| 917 | 1213 | $data['format_source'] = $value['format']; |
| 918 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 919 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 920 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 921 | - elseif ($line[3] === 'ATC') { |
|
| 1214 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1215 | + $data['noarchive'] = true; |
|
| 1216 | + } |
|
| 1217 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1218 | + $data['source_name'] = $value['name']; |
|
| 1219 | + } |
|
| 1220 | + if ($line[3] === 'PILOT') { |
|
| 1221 | + $SI->add($data); |
|
| 1222 | + } elseif ($line[3] === 'ATC') { |
|
| 922 | 1223 | //print_r($data); |
| 923 | 1224 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 924 | 1225 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 925 | 1226 | $typec = substr($data['ident'],-3); |
| 926 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 927 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 928 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 929 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 930 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 931 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 932 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 933 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 934 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
| 935 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 1227 | + if ($typec === 'APP') { |
|
| 1228 | + $data['type'] = 'Approach'; |
|
| 1229 | + } elseif ($typec === 'TWR') { |
|
| 1230 | + $data['type'] = 'Tower'; |
|
| 1231 | + } elseif ($typec === 'OBS') { |
|
| 1232 | + $data['type'] = 'Observer'; |
|
| 1233 | + } elseif ($typec === 'GND') { |
|
| 1234 | + $data['type'] = 'Ground'; |
|
| 1235 | + } elseif ($typec === 'DEL') { |
|
| 1236 | + $data['type'] = 'Delivery'; |
|
| 1237 | + } elseif ($typec === 'DEP') { |
|
| 1238 | + $data['type'] = 'Departure'; |
|
| 1239 | + } elseif ($typec === 'FSS') { |
|
| 1240 | + $data['type'] = 'Flight Service Station'; |
|
| 1241 | + } elseif ($typec === 'CTR') { |
|
| 1242 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1243 | + } elseif ($data['type'] === '') { |
|
| 1244 | + $data['type'] = 'Observer'; |
|
| 1245 | + } |
|
| 1246 | + if (!isset($data['source_name'])) { |
|
| 1247 | + $data['source_name'] = ''; |
|
| 1248 | + } |
|
| 936 | 1249 | if (isset($ATC)) { |
| 937 | - 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']); |
|
| 938 | - 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']); |
|
| 1250 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 1251 | + 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']); |
|
| 1252 | + } else { |
|
| 1253 | + 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']); |
|
| 1254 | + } |
|
| 939 | 1255 | } |
| 940 | 1256 | } |
| 941 | 1257 | unset($data); |
@@ -962,14 +1278,20 @@ discard block |
||
| 962 | 1278 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 963 | 1279 | $data['latitude'] = (float)$line['pktLatitude']; |
| 964 | 1280 | $data['longitude'] = (float)$line['pktLongitude']; |
| 965 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 966 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1281 | + if ((float)$line['pktTrack'] != 0) { |
|
| 1282 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 1283 | + } |
|
| 1284 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 1285 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 1286 | + } |
|
| 967 | 1287 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 968 | 1288 | $data['altitude_relative'] = 'AMSL'; |
| 969 | 1289 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 970 | 1290 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 971 | 1291 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 972 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 1292 | + if (isset($pilot_data[4])) { |
|
| 1293 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1294 | + } |
|
| 973 | 1295 | $data['format_source'] = $value['format']; |
| 974 | 1296 | $SI->add($data); |
| 975 | 1297 | unset($data); |
@@ -1017,25 +1339,59 @@ discard block |
||
| 1017 | 1339 | foreach ($all_data['acList'] as $line) { |
| 1018 | 1340 | $data = array(); |
| 1019 | 1341 | $data['hex'] = $line['Icao']; // hex |
| 1020 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1021 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1022 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1023 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1024 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1025 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1342 | + if (isset($line['Call'])) { |
|
| 1343 | + $data['ident'] = $line['Call']; |
|
| 1344 | + } |
|
| 1345 | + // ident |
|
| 1346 | + if (isset($line['Alt'])) { |
|
| 1347 | + $data['altitude'] = $line['Alt']; |
|
| 1348 | + } |
|
| 1349 | + // altitude |
|
| 1350 | + if (isset($line['Spd'])) { |
|
| 1351 | + $data['speed'] = $line['Spd']; |
|
| 1352 | + } |
|
| 1353 | + // speed |
|
| 1354 | + if (isset($line['Trak'])) { |
|
| 1355 | + $data['heading'] = $line['Trak']; |
|
| 1356 | + } |
|
| 1357 | + // heading |
|
| 1358 | + if (isset($line['Lat'])) { |
|
| 1359 | + $data['latitude'] = $line['Lat']; |
|
| 1360 | + } |
|
| 1361 | + // lat |
|
| 1362 | + if (isset($line['Long'])) { |
|
| 1363 | + $data['longitude'] = $line['Long']; |
|
| 1364 | + } |
|
| 1365 | + // long |
|
| 1026 | 1366 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1027 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1367 | + if (isset($line['Sqk'])) { |
|
| 1368 | + $data['squawk'] = $line['Sqk']; |
|
| 1369 | + } |
|
| 1370 | + // squawk |
|
| 1028 | 1371 | $data['emergency'] = ''; // emergency |
| 1029 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1030 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1031 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1372 | + if (isset($line['Reg'])) { |
|
| 1373 | + $data['registration'] = $line['Reg']; |
|
| 1374 | + } |
|
| 1375 | + if (isset($line['PosTime'])) { |
|
| 1376 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1377 | + } else { |
|
| 1378 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1379 | + } |
|
| 1032 | 1380 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1033 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1381 | + if (isset($line['Type'])) { |
|
| 1382 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1383 | + } |
|
| 1034 | 1384 | $data['format_source'] = 'aircraftlistjson'; |
| 1035 | 1385 | $data['id_source'] = $id_source; |
| 1036 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1037 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1038 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1386 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1387 | + $data['source_name'] = $value['name']; |
|
| 1388 | + } |
|
| 1389 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1390 | + $data['noarchive'] = true; |
|
| 1391 | + } |
|
| 1392 | + if (isset($data['latitude'])) { |
|
| 1393 | + $SI->add($data); |
|
| 1394 | + } |
|
| 1039 | 1395 | unset($data); |
| 1040 | 1396 | } |
| 1041 | 1397 | } elseif (is_array($all_data)) { |
@@ -1052,17 +1408,26 @@ discard block |
||
| 1052 | 1408 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1053 | 1409 | $data['squawk'] = $line['squawk']; // squawk |
| 1054 | 1410 | $data['emergency'] = ''; // emergency |
| 1055 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1056 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1411 | + if (isset($line['PosTime'])) { |
|
| 1412 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1413 | + } else { |
|
| 1414 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1415 | + } |
|
| 1057 | 1416 | $data['format_source'] = 'aircraftlistjson'; |
| 1058 | 1417 | $data['id_source'] = $id_source; |
| 1059 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1060 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1418 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1419 | + $data['noarchive'] = true; |
|
| 1420 | + } |
|
| 1421 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1422 | + $data['source_name'] = $value['name']; |
|
| 1423 | + } |
|
| 1061 | 1424 | $SI->add($data); |
| 1062 | 1425 | unset($data); |
| 1063 | 1426 | } |
| 1064 | 1427 | } |
| 1065 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1428 | + } elseif ($globalDebug) { |
|
| 1429 | + echo 'No data'."\n"; |
|
| 1430 | + } |
|
| 1066 | 1431 | //$last_exec['aircraftlistjson'] = time(); |
| 1067 | 1432 | $last_exec[$id]['last'] = time(); |
| 1068 | 1433 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -1098,8 +1463,12 @@ discard block |
||
| 1098 | 1463 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 1099 | 1464 | $data['format_source'] = 'planeupdatefaa'; |
| 1100 | 1465 | $data['id_source'] = $id_source; |
| 1101 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1102 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1466 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1467 | + $data['noarchive'] = true; |
|
| 1468 | + } |
|
| 1469 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1470 | + $data['source_name'] = $value['name']; |
|
| 1471 | + } |
|
| 1103 | 1472 | $SI->add($data); |
| 1104 | 1473 | unset($data); |
| 1105 | 1474 | } |
@@ -1133,7 +1502,9 @@ discard block |
||
| 1133 | 1502 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 1134 | 1503 | $data['format_source'] = 'opensky'; |
| 1135 | 1504 | $data['id_source'] = $id_source; |
| 1136 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1505 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1506 | + $data['noarchive'] = true; |
|
| 1507 | + } |
|
| 1137 | 1508 | $SI->add($data); |
| 1138 | 1509 | unset($data); |
| 1139 | 1510 | } |
@@ -1153,15 +1524,42 @@ discard block |
||
| 1153 | 1524 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1154 | 1525 | $data = array(); |
| 1155 | 1526 | // add support for ground vehicule with ~ in front of hex |
| 1156 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1157 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1158 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1159 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1160 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1161 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1162 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1163 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1164 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1527 | + if (isset($line['hex'])) { |
|
| 1528 | + $data['hex'] = $line['hex']; |
|
| 1529 | + } |
|
| 1530 | + // hex |
|
| 1531 | + if (isset($line['flight'])) { |
|
| 1532 | + $data['ident'] = trim($line['flight']); |
|
| 1533 | + } |
|
| 1534 | + // ident |
|
| 1535 | + if (isset($line['altitude'])) { |
|
| 1536 | + $data['altitude'] = $line['altitude']; |
|
| 1537 | + } |
|
| 1538 | + // altitude |
|
| 1539 | + if (isset($line['speed'])) { |
|
| 1540 | + $data['speed'] = $line['speed']; |
|
| 1541 | + } |
|
| 1542 | + // speed |
|
| 1543 | + if (isset($line['track'])) { |
|
| 1544 | + $data['heading'] = $line['track']; |
|
| 1545 | + } |
|
| 1546 | + // heading |
|
| 1547 | + if (isset($line['lat'])) { |
|
| 1548 | + $data['latitude'] = $line['lat']; |
|
| 1549 | + } |
|
| 1550 | + // lat |
|
| 1551 | + if (isset($line['lon'])) { |
|
| 1552 | + $data['longitude'] = $line['lon']; |
|
| 1553 | + } |
|
| 1554 | + // long |
|
| 1555 | + if (isset($line['vert_rate'])) { |
|
| 1556 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1557 | + } |
|
| 1558 | + // verticale rate |
|
| 1559 | + if (isset($line['squawk'])) { |
|
| 1560 | + $data['squawk'] = $line['squawk']; |
|
| 1561 | + } |
|
| 1562 | + // squawk |
|
| 1165 | 1563 | //$data['emergency'] = ''; // emergency |
| 1166 | 1564 | //$data['registration'] = $line[2]; |
| 1167 | 1565 | //$data['aircraft_icao'] = $line[0]; |
@@ -1169,10 +1567,17 @@ discard block |
||
| 1169 | 1567 | $data['format_source'] = 'aircraftjson'; |
| 1170 | 1568 | $data['id_source'] = $id_source; |
| 1171 | 1569 | if (isset($value['name']) && $value['name'] != '') { |
| 1172 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1173 | - else $data['source_name'] = $value['name']; |
|
| 1174 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1175 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1570 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1571 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1572 | + } else { |
|
| 1573 | + $data['source_name'] = $value['name']; |
|
| 1574 | + } |
|
| 1575 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1576 | + $data['source_name'] = 'MLAT'; |
|
| 1577 | + } |
|
| 1578 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1579 | + $data['noarchive'] = true; |
|
| 1580 | + } |
|
| 1176 | 1581 | $SI->add($data); |
| 1177 | 1582 | unset($data); |
| 1178 | 1583 | } |
@@ -1192,22 +1597,54 @@ discard block |
||
| 1192 | 1597 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1193 | 1598 | $data = array(); |
| 1194 | 1599 | $data['hex'] = $key; // hex |
| 1195 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1196 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1197 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1198 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1199 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1200 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1201 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1202 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1600 | + if (isset($line['callsign'])) { |
|
| 1601 | + $data['ident'] = trim($line['callsign']); |
|
| 1602 | + } |
|
| 1603 | + // ident |
|
| 1604 | + if (isset($line['altitude'])) { |
|
| 1605 | + $data['altitude'] = $line['altitude']; |
|
| 1606 | + } |
|
| 1607 | + // altitude |
|
| 1608 | + if (isset($line['speed'])) { |
|
| 1609 | + $data['speed'] = $line['speed']; |
|
| 1610 | + } |
|
| 1611 | + // speed |
|
| 1612 | + if (isset($line['heading'])) { |
|
| 1613 | + $data['heading'] = $line['heading']; |
|
| 1614 | + } |
|
| 1615 | + // heading |
|
| 1616 | + if (isset($line['lat'])) { |
|
| 1617 | + $data['latitude'] = $line['lat']; |
|
| 1618 | + } |
|
| 1619 | + // lat |
|
| 1620 | + if (isset($line['lon'])) { |
|
| 1621 | + $data['longitude'] = $line['lon']; |
|
| 1622 | + } |
|
| 1623 | + // long |
|
| 1624 | + if (isset($line['vert_rate'])) { |
|
| 1625 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1626 | + } |
|
| 1627 | + // verticale rate |
|
| 1628 | + if (isset($line['squawk'])) { |
|
| 1629 | + $data['squawk'] = $line['squawk']; |
|
| 1630 | + } |
|
| 1631 | + // squawk |
|
| 1203 | 1632 | //$data['emergency'] = ''; // emergency |
| 1204 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1205 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1633 | + if (isset($line['reg'])) { |
|
| 1634 | + $data['registration'] = $line['reg']; |
|
| 1635 | + } |
|
| 1636 | + if (isset($line['type'])) { |
|
| 1637 | + $data['aircraft_icao'] = $line['type']; |
|
| 1638 | + } |
|
| 1206 | 1639 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
| 1207 | 1640 | $data['format_source'] = 'planefinderclient'; |
| 1208 | 1641 | $data['id_source'] = $id_source; |
| 1209 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1210 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1642 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1643 | + $data['source_name'] = $value['name']; |
|
| 1644 | + } |
|
| 1645 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1646 | + $data['noarchive'] = true; |
|
| 1647 | + } |
|
| 1211 | 1648 | $SI->add($data); |
| 1212 | 1649 | unset($data); |
| 1213 | 1650 | } |
@@ -1223,7 +1660,9 @@ discard block |
||
| 1223 | 1660 | //$buffer = $Common->getData($hosts[$id]); |
| 1224 | 1661 | $buffer = $Common->getData($value['host']); |
| 1225 | 1662 | $all_data = json_decode($buffer,true); |
| 1226 | - if (!empty($all_data)) $reset = 0; |
|
| 1663 | + if (!empty($all_data)) { |
|
| 1664 | + $reset = 0; |
|
| 1665 | + } |
|
| 1227 | 1666 | foreach ($all_data as $key => $line) { |
| 1228 | 1667 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1229 | 1668 | $data = array(); |
@@ -1244,8 +1683,12 @@ discard block |
||
| 1244 | 1683 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 1245 | 1684 | $data['format_source'] = 'fr24json'; |
| 1246 | 1685 | $data['id_source'] = $id_source; |
| 1247 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1248 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1686 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1687 | + $data['noarchive'] = true; |
|
| 1688 | + } |
|
| 1689 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1690 | + $data['source_name'] = $value['name']; |
|
| 1691 | + } |
|
| 1249 | 1692 | $SI->add($data); |
| 1250 | 1693 | unset($data); |
| 1251 | 1694 | } |
@@ -1274,24 +1717,42 @@ discard block |
||
| 1274 | 1717 | if (isset($line['inf'])) { |
| 1275 | 1718 | $data = array(); |
| 1276 | 1719 | $data['hex'] = $line['inf']['ia']; |
| 1277 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1720 | + if (isset($line['inf']['cs'])) { |
|
| 1721 | + $data['ident'] = $line['inf']['cs']; |
|
| 1722 | + } |
|
| 1723 | + //$line[13] |
|
| 1278 | 1724 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 1279 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1280 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1725 | + if (isset($line['inf']['gs'])) { |
|
| 1726 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1727 | + } |
|
| 1728 | + // speed |
|
| 1729 | + if (isset($line['inf']['tr'])) { |
|
| 1730 | + $data['heading'] = $line['inf']['tr']; |
|
| 1731 | + } |
|
| 1732 | + // heading |
|
| 1281 | 1733 | $data['latitude'] = $line['pt'][0]; // lat |
| 1282 | 1734 | $data['longitude'] = $line['pt'][1]; // long |
| 1283 | 1735 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 1284 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1736 | + if (isset($line['inf']['sq'])) { |
|
| 1737 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1738 | + } |
|
| 1739 | + // squawk |
|
| 1285 | 1740 | //$data['aircraft_icao'] = $line[8]; |
| 1286 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1741 | + if (isset($line['inf']['rc'])) { |
|
| 1742 | + $data['registration'] = $line['inf']['rc']; |
|
| 1743 | + } |
|
| 1287 | 1744 | //$data['departure_airport_iata'] = $line[11]; |
| 1288 | 1745 | //$data['arrival_airport_iata'] = $line[12]; |
| 1289 | 1746 | //$data['emergency'] = ''; // emergency |
| 1290 | 1747 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1291 | 1748 | $data['format_source'] = 'radarvirtueljson'; |
| 1292 | 1749 | $data['id_source'] = $id_source; |
| 1293 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1294 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1750 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1751 | + $data['noarchive'] = true; |
|
| 1752 | + } |
|
| 1753 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1754 | + $data['source_name'] = $value['name']; |
|
| 1755 | + } |
|
| 1295 | 1756 | $SI->add($data); |
| 1296 | 1757 | unset($data); |
| 1297 | 1758 | } |
@@ -1317,30 +1778,65 @@ discard block |
||
| 1317 | 1778 | $data['id'] = $line['id']; |
| 1318 | 1779 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 1319 | 1780 | $data['ident'] = $line['callsign']; // ident |
| 1320 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1321 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1322 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1323 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1324 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1325 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1781 | + if (isset($line['pilotid'])) { |
|
| 1782 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1783 | + } |
|
| 1784 | + // pilot id |
|
| 1785 | + if (isset($line['name'])) { |
|
| 1786 | + $data['pilot_name'] = $line['name']; |
|
| 1787 | + } |
|
| 1788 | + // pilot name |
|
| 1789 | + if (isset($line['alt'])) { |
|
| 1790 | + $data['altitude'] = $line['alt']; |
|
| 1791 | + } |
|
| 1792 | + // altitude |
|
| 1793 | + if (isset($line['gs'])) { |
|
| 1794 | + $data['speed'] = $line['gs']; |
|
| 1795 | + } |
|
| 1796 | + // speed |
|
| 1797 | + if (isset($line['heading'])) { |
|
| 1798 | + $data['heading'] = $line['heading']; |
|
| 1799 | + } |
|
| 1800 | + // heading |
|
| 1801 | + if (isset($line['route'])) { |
|
| 1802 | + $data['waypoints'] = $line['route']; |
|
| 1803 | + } |
|
| 1804 | + // route |
|
| 1326 | 1805 | $data['latitude'] = $line['lat']; // lat |
| 1327 | 1806 | $data['longitude'] = $line['lon']; // long |
| 1328 | 1807 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 1329 | 1808 | //$data['squawk'] = $line['squawk']; // squawk |
| 1330 | 1809 | //$data['emergency'] = ''; // emergency |
| 1331 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1332 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1333 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1810 | + if (isset($line['depicao'])) { |
|
| 1811 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1812 | + } |
|
| 1813 | + if (isset($line['deptime'])) { |
|
| 1814 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1815 | + } |
|
| 1816 | + if (isset($line['arricao'])) { |
|
| 1817 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1818 | + } |
|
| 1334 | 1819 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 1335 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1336 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1337 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1338 | - else $data['info'] = ''; |
|
| 1820 | + if (isset($line['aircraft'])) { |
|
| 1821 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1822 | + } |
|
| 1823 | + if (isset($line['transponder'])) { |
|
| 1824 | + $data['squawk'] = $line['transponder']; |
|
| 1825 | + } |
|
| 1826 | + if (isset($line['atis'])) { |
|
| 1827 | + $data['info'] = $line['atis']; |
|
| 1828 | + } else { |
|
| 1829 | + $data['info'] = ''; |
|
| 1830 | + } |
|
| 1339 | 1831 | $data['format_source'] = 'pireps'; |
| 1340 | 1832 | $data['id_source'] = $id_source; |
| 1341 | 1833 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1342 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1343 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1834 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1835 | + $data['noarchive'] = true; |
|
| 1836 | + } |
|
| 1837 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1838 | + $data['source_name'] = $value['name']; |
|
| 1839 | + } |
|
| 1344 | 1840 | if ($line['icon'] === 'plane') { |
| 1345 | 1841 | $SI->add($data); |
| 1346 | 1842 | // print_r($data); |
@@ -1349,16 +1845,28 @@ discard block |
||
| 1349 | 1845 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1350 | 1846 | $typec = substr($data['ident'],-3); |
| 1351 | 1847 | $data['type'] = ''; |
| 1352 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 1353 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 1354 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 1355 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 1356 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 1357 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 1358 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1359 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1360 | - else $data['type'] = 'Observer'; |
|
| 1361 | - 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']); |
|
| 1848 | + if ($typec === 'APP') { |
|
| 1849 | + $data['type'] = 'Approach'; |
|
| 1850 | + } elseif ($typec === 'TWR') { |
|
| 1851 | + $data['type'] = 'Tower'; |
|
| 1852 | + } elseif ($typec === 'OBS') { |
|
| 1853 | + $data['type'] = 'Observer'; |
|
| 1854 | + } elseif ($typec === 'GND') { |
|
| 1855 | + $data['type'] = 'Ground'; |
|
| 1856 | + } elseif ($typec === 'DEL') { |
|
| 1857 | + $data['type'] = 'Delivery'; |
|
| 1858 | + } elseif ($typec === 'DEP') { |
|
| 1859 | + $data['type'] = 'Departure'; |
|
| 1860 | + } elseif ($typec === 'FSS') { |
|
| 1861 | + $data['type'] = 'Flight Service Station'; |
|
| 1862 | + } elseif ($typec === 'CTR') { |
|
| 1863 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1864 | + } else { |
|
| 1865 | + $data['type'] = 'Observer'; |
|
| 1866 | + } |
|
| 1867 | + if (isset($ATC)) { |
|
| 1868 | + 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']); |
|
| 1869 | + } |
|
| 1362 | 1870 | } |
| 1363 | 1871 | unset($data); |
| 1364 | 1872 | } |
@@ -1373,7 +1881,9 @@ discard block |
||
| 1373 | 1881 | ) |
| 1374 | 1882 | ) { |
| 1375 | 1883 | //$buffer = $Common->getData($hosts[$id]); |
| 1376 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1884 | + if ($globalDebug) { |
|
| 1885 | + echo 'Get Data...'."\n"; |
|
| 1886 | + } |
|
| 1377 | 1887 | $buffer = $Common->getData($value['host']); |
| 1378 | 1888 | $all_data = json_decode($buffer,true); |
| 1379 | 1889 | if ($buffer != '' && is_array($all_data)) { |
@@ -1381,10 +1891,16 @@ discard block |
||
| 1381 | 1891 | foreach ($all_data as $line) { |
| 1382 | 1892 | $data = array(); |
| 1383 | 1893 | //$data['id'] = $line['id']; // id not usable |
| 1384 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1894 | + if (isset($line['pilotid'])) { |
|
| 1895 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1896 | + } |
|
| 1385 | 1897 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1386 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1387 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1898 | + if (isset($line['pilotname'])) { |
|
| 1899 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1900 | + } |
|
| 1901 | + if (isset($line['pilotid'])) { |
|
| 1902 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1903 | + } |
|
| 1388 | 1904 | $data['ident'] = $line['flightnum']; // ident |
| 1389 | 1905 | $data['altitude'] = $line['alt']; // altitude |
| 1390 | 1906 | $data['speed'] = $line['gs']; // speed |
@@ -1400,7 +1916,9 @@ discard block |
||
| 1400 | 1916 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
| 1401 | 1917 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1402 | 1918 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1403 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1919 | + } else { |
|
| 1920 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1921 | + } |
|
| 1404 | 1922 | $data['departure_airport_icao'] = $line['depicao']; |
| 1405 | 1923 | $data['departure_airport_time'] = $line['deptime']; |
| 1406 | 1924 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1408,29 +1926,47 @@ discard block |
||
| 1408 | 1926 | if (isset($line['registration'])) { |
| 1409 | 1927 | $data['registration'] = $line['registration']; |
| 1410 | 1928 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
| 1411 | - } else $data['registration'] = $line['aircraft']; |
|
| 1412 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1413 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1929 | + } else { |
|
| 1930 | + $data['registration'] = $line['aircraft']; |
|
| 1931 | + } |
|
| 1932 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1933 | + $data['noarchive'] = true; |
|
| 1934 | + } |
|
| 1935 | + if (isset($line['route'])) { |
|
| 1936 | + $data['waypoints'] = $line['route']; |
|
| 1937 | + } |
|
| 1938 | + // route |
|
| 1414 | 1939 | if (isset($line['aircraftname'])) { |
| 1415 | 1940 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1416 | 1941 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1417 | 1942 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1418 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1419 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1420 | - else { |
|
| 1943 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1944 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1945 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1946 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1947 | + } else { |
|
| 1421 | 1948 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1422 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1423 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1949 | + if (isset($aircraft_data[1])) { |
|
| 1950 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1951 | + } else { |
|
| 1952 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1953 | + } |
|
| 1424 | 1954 | } |
| 1425 | 1955 | } |
| 1426 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1956 | + if (isset($line['route'])) { |
|
| 1957 | + $data['waypoints'] = $line['route']; |
|
| 1958 | + } |
|
| 1427 | 1959 | $data['id_source'] = $id_source; |
| 1428 | 1960 | $data['format_source'] = 'phpvmacars'; |
| 1429 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1961 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1962 | + $data['source_name'] = $value['name']; |
|
| 1963 | + } |
|
| 1430 | 1964 | $SI->add($data); |
| 1431 | 1965 | unset($data); |
| 1432 | 1966 | } |
| 1433 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1967 | + if ($globalDebug) { |
|
| 1968 | + echo 'No more data...'."\n"; |
|
| 1969 | + } |
|
| 1434 | 1970 | unset($buffer); |
| 1435 | 1971 | unset($all_data); |
| 1436 | 1972 | } |
@@ -1443,7 +1979,9 @@ discard block |
||
| 1443 | 1979 | ) |
| 1444 | 1980 | ) { |
| 1445 | 1981 | //$buffer = $Common->getData($hosts[$id]); |
| 1446 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1982 | + if ($globalDebug) { |
|
| 1983 | + echo 'Get Data...'."\n"; |
|
| 1984 | + } |
|
| 1447 | 1985 | $buffer = $Common->getData($value['host']); |
| 1448 | 1986 | $all_data = json_decode($buffer,true); |
| 1449 | 1987 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1454,10 +1992,16 @@ discard block |
||
| 1454 | 1992 | //$data['id'] = $line['id']; // id not usable |
| 1455 | 1993 | $data['id'] = $line['id']; |
| 1456 | 1994 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1457 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1458 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1995 | + if (isset($line['user']['username'])) { |
|
| 1996 | + $data['pilot_name'] = $line['user']['username']; |
|
| 1997 | + } |
|
| 1998 | + if (isset($line['user_id'])) { |
|
| 1999 | + $data['pilot_id'] = $line['user_id']; |
|
| 2000 | + } |
|
| 1459 | 2001 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
| 1460 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2002 | + if (is_numeric($data['ident'])) { |
|
| 2003 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2004 | + } |
|
| 1461 | 2005 | $data['altitude'] = $line['altitude']; // altitude |
| 1462 | 2006 | $data['speed'] = $line['groundspeed']; // speed |
| 1463 | 2007 | $data['heading'] = $line['heading']; // heading |
@@ -1470,7 +2014,9 @@ discard block |
||
| 1470 | 2014 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
| 1471 | 2015 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1472 | 2016 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1473 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2017 | + } else { |
|
| 2018 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2019 | + } |
|
| 1474 | 2020 | |
| 1475 | 2021 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
| 1476 | 2022 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1478,17 +2024,26 @@ discard block |
||
| 1478 | 2024 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
| 1479 | 2025 | $data['registration'] = $line['bid']['aircraft']['registration']; |
| 1480 | 2026 | |
| 1481 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1482 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 2027 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2028 | + $data['noarchive'] = true; |
|
| 2029 | + } |
|
| 2030 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
| 2031 | + $data['waypoints'] = $line['bid']['route']; |
|
| 2032 | + } |
|
| 2033 | + // route |
|
| 1483 | 2034 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
| 1484 | 2035 | |
| 1485 | 2036 | $data['id_source'] = $id_source; |
| 1486 | 2037 | $data['format_source'] = 'vaos'; |
| 1487 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2038 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2039 | + $data['source_name'] = $value['name']; |
|
| 2040 | + } |
|
| 1488 | 2041 | $SI->add($data); |
| 1489 | 2042 | unset($data); |
| 1490 | 2043 | } |
| 1491 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2044 | + if ($globalDebug) { |
|
| 2045 | + echo 'No more data...'."\n"; |
|
| 2046 | + } |
|
| 1492 | 2047 | unset($buffer); |
| 1493 | 2048 | unset($all_data); |
| 1494 | 2049 | } |
@@ -1501,7 +2056,9 @@ discard block |
||
| 1501 | 2056 | ) |
| 1502 | 2057 | ) { |
| 1503 | 2058 | //$buffer = $Common->getData($hosts[$id]); |
| 1504 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2059 | + if ($globalDebug) { |
|
| 2060 | + echo 'Get Data...'."\n"; |
|
| 2061 | + } |
|
| 1505 | 2062 | $buffer = $Common->getData($value['host']); |
| 1506 | 2063 | $all_data = json_decode($buffer,true); |
| 1507 | 2064 | if ($buffer != '' && is_array($all_data)) { |
@@ -1530,16 +2087,25 @@ discard block |
||
| 1530 | 2087 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1531 | 2088 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1532 | 2089 | //$data['registration'] = $line['aircraft']; |
| 1533 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 2090 | + if (isset($line['route'])) { |
|
| 2091 | + $data['waypoints'] = $line['route']; |
|
| 2092 | + } |
|
| 2093 | + // route |
|
| 1534 | 2094 | $data['aircraft_icao'] = $line['plane_type']; |
| 1535 | 2095 | $data['id_source'] = $id_source; |
| 1536 | 2096 | $data['format_source'] = 'vam'; |
| 1537 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1538 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2097 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2098 | + $data['noarchive'] = true; |
|
| 2099 | + } |
|
| 2100 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2101 | + $data['source_name'] = $value['name']; |
|
| 2102 | + } |
|
| 1539 | 2103 | $SI->add($data); |
| 1540 | 2104 | unset($data); |
| 1541 | 2105 | } |
| 1542 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2106 | + if ($globalDebug) { |
|
| 2107 | + echo 'No more data...'."\n"; |
|
| 2108 | + } |
|
| 1543 | 2109 | unset($buffer); |
| 1544 | 2110 | unset($all_data); |
| 1545 | 2111 | } |
@@ -1552,7 +2118,9 @@ discard block |
||
| 1552 | 2118 | ) |
| 1553 | 2119 | ) { |
| 1554 | 2120 | //$buffer = $Common->getData($hosts[$id]); |
| 1555 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2121 | + if ($globalDebug) { |
|
| 2122 | + echo 'Get Data...'."\n"; |
|
| 2123 | + } |
|
| 1556 | 2124 | $buffer = $Common->getData($value['host']); |
| 1557 | 2125 | $all_data = json_decode($buffer,true); |
| 1558 | 2126 | if ($buffer != '') { |
@@ -1570,12 +2138,16 @@ discard block |
||
| 1570 | 2138 | $data['id_source'] = $id_source; |
| 1571 | 2139 | $data['format_source'] = 'blitzortung'; |
| 1572 | 2140 | $SI->add($data); |
| 1573 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2141 | + if ($globalDebug) { |
|
| 2142 | + echo '☈ Lightning added'."\n"; |
|
| 2143 | + } |
|
| 1574 | 2144 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1575 | 2145 | unset($data); |
| 1576 | 2146 | } |
| 1577 | 2147 | } |
| 1578 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2148 | + if ($globalDebug) { |
|
| 2149 | + echo 'No more data...'."\n"; |
|
| 2150 | + } |
|
| 1579 | 2151 | unset($buffer); |
| 1580 | 2152 | } |
| 1581 | 2153 | $last_exec[$id]['last'] = time(); |
@@ -1587,7 +2159,9 @@ discard block |
||
| 1587 | 2159 | $write = NULL; |
| 1588 | 2160 | $e = NULL; |
| 1589 | 2161 | $n = socket_select($read, $write, $e, $timeout); |
| 1590 | - if ($e != NULL) var_dump($e); |
|
| 2162 | + if ($e != NULL) { |
|
| 2163 | + var_dump($e); |
|
| 2164 | + } |
|
| 1591 | 2165 | if ($n > 0) { |
| 1592 | 2166 | $reset = 0; |
| 1593 | 2167 | foreach ($read as $nb => $r) { |
@@ -1609,13 +2183,17 @@ discard block |
||
| 1609 | 2183 | if ($buffer !== FALSE) { |
| 1610 | 2184 | if ($format === 'vrstcp') { |
| 1611 | 2185 | $buffer = explode('},{',$buffer); |
| 1612 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2186 | + } else { |
|
| 2187 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2188 | + } |
|
| 1613 | 2189 | } |
| 1614 | 2190 | // SBS format is CSV format |
| 1615 | 2191 | if ($buffer !== FALSE && $buffer !== '') { |
| 1616 | 2192 | $tt[$format] = 0; |
| 1617 | 2193 | if ($format === 'acarssbs3') { |
| 1618 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2194 | + if ($globalDebug) { |
|
| 2195 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2196 | + } |
|
| 1619 | 2197 | $ACARS->add(trim($buffer)); |
| 1620 | 2198 | $ACARS->deleteLiveAcarsData(); |
| 1621 | 2199 | } elseif ($format === 'raw') { |
@@ -1624,30 +2202,70 @@ discard block |
||
| 1624 | 2202 | if (is_array($data)) { |
| 1625 | 2203 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1626 | 2204 | $data['format_source'] = 'raw'; |
| 1627 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1628 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1629 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1630 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2205 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2206 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2207 | + } |
|
| 2208 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2209 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2210 | + } |
|
| 2211 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2212 | + $data['noarchive'] = true; |
|
| 2213 | + } |
|
| 2214 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2215 | + $SI->add($data); |
|
| 2216 | + } |
|
| 1631 | 2217 | } |
| 1632 | 2218 | } elseif ($format === 'ais') { |
| 1633 | 2219 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1634 | 2220 | $data = array(); |
| 1635 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1636 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1637 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1638 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1639 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1640 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1641 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1642 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1643 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1644 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1645 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1646 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1647 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1648 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1649 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1650 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2221 | + if (isset($ais_data['ident'])) { |
|
| 2222 | + $data['ident'] = $ais_data['ident']; |
|
| 2223 | + } |
|
| 2224 | + if (isset($ais_data['mmsi'])) { |
|
| 2225 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 2226 | + } |
|
| 2227 | + if (isset($ais_data['speed'])) { |
|
| 2228 | + $data['speed'] = $ais_data['speed']; |
|
| 2229 | + } |
|
| 2230 | + if (isset($ais_data['heading'])) { |
|
| 2231 | + $data['heading'] = $ais_data['heading']; |
|
| 2232 | + } |
|
| 2233 | + if (isset($ais_data['latitude'])) { |
|
| 2234 | + $data['latitude'] = $ais_data['latitude']; |
|
| 2235 | + } |
|
| 2236 | + if (isset($ais_data['longitude'])) { |
|
| 2237 | + $data['longitude'] = $ais_data['longitude']; |
|
| 2238 | + } |
|
| 2239 | + if (isset($ais_data['status'])) { |
|
| 2240 | + $data['status'] = $ais_data['status']; |
|
| 2241 | + } |
|
| 2242 | + if (isset($ais_data['statusid'])) { |
|
| 2243 | + $data['status_id'] = $ais_data['statusid']; |
|
| 2244 | + } |
|
| 2245 | + if (isset($ais_data['type'])) { |
|
| 2246 | + $data['type'] = $ais_data['type']; |
|
| 2247 | + } |
|
| 2248 | + if (isset($ais_data['imo'])) { |
|
| 2249 | + $data['imo'] = $ais_data['imo']; |
|
| 2250 | + } |
|
| 2251 | + if (isset($ais_data['callsign'])) { |
|
| 2252 | + $data['callsign'] = $ais_data['callsign']; |
|
| 2253 | + } |
|
| 2254 | + if (isset($ais_data['destination'])) { |
|
| 2255 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 2256 | + } |
|
| 2257 | + if (isset($ais_data['eta_ts'])) { |
|
| 2258 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 2259 | + } |
|
| 2260 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2261 | + $data['noarchive'] = true; |
|
| 2262 | + } |
|
| 2263 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2264 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2265 | + } |
|
| 2266 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2267 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2268 | + } |
|
| 1651 | 2269 | |
| 1652 | 2270 | if (isset($ais_data['timestamp'])) { |
| 1653 | 2271 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1656,7 +2274,9 @@ discard block |
||
| 1656 | 2274 | } |
| 1657 | 2275 | $data['format_source'] = 'aisnmea'; |
| 1658 | 2276 | $data['id_source'] = $id_source; |
| 1659 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 2277 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 2278 | + $MI->add($data); |
|
| 2279 | + } |
|
| 1660 | 2280 | unset($data); |
| 1661 | 2281 | } elseif ($format === 'flightgearsp') { |
| 1662 | 2282 | //echo $buffer."\n"; |
@@ -1674,12 +2294,18 @@ discard block |
||
| 1674 | 2294 | $data['speed'] = round($line[5]*1.94384); |
| 1675 | 2295 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1676 | 2296 | $data['format_source'] = 'flightgearsp'; |
| 1677 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1678 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2297 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2298 | + $data['noarchive'] = true; |
|
| 2299 | + } |
|
| 2300 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2301 | + $SI->add($data); |
|
| 2302 | + } |
|
| 1679 | 2303 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1680 | 2304 | } |
| 1681 | 2305 | } elseif ($format === 'acars') { |
| 1682 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2306 | + if ($globalDebug) { |
|
| 2307 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2308 | + } |
|
| 1683 | 2309 | $ACARS->add(trim($buffer)); |
| 1684 | 2310 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1685 | 2311 | $ACARS->deleteLiveAcarsData(); |
@@ -1700,8 +2326,12 @@ discard block |
||
| 1700 | 2326 | $aircraft_type = $line[10]; |
| 1701 | 2327 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1702 | 2328 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1703 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1704 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2329 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2330 | + $data['noarchive'] = true; |
|
| 2331 | + } |
|
| 2332 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2333 | + $SI->add($data); |
|
| 2334 | + } |
|
| 1705 | 2335 | } |
| 1706 | 2336 | } |
| 1707 | 2337 | } elseif ($format === 'beast') { |
@@ -1711,28 +2341,62 @@ discard block |
||
| 1711 | 2341 | foreach($buffer as $all_data) { |
| 1712 | 2342 | $line = json_decode('{'.$all_data.'}',true); |
| 1713 | 2343 | $data = array(); |
| 1714 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1715 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1716 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1717 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1718 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1719 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1720 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 2344 | + if (isset($line['Icao'])) { |
|
| 2345 | + $data['hex'] = $line['Icao']; |
|
| 2346 | + } |
|
| 2347 | + // hex |
|
| 2348 | + if (isset($line['Call'])) { |
|
| 2349 | + $data['ident'] = $line['Call']; |
|
| 2350 | + } |
|
| 2351 | + // ident |
|
| 2352 | + if (isset($line['Alt'])) { |
|
| 2353 | + $data['altitude'] = $line['Alt']; |
|
| 2354 | + } |
|
| 2355 | + // altitude |
|
| 2356 | + if (isset($line['Spd'])) { |
|
| 2357 | + $data['speed'] = $line['Spd']; |
|
| 2358 | + } |
|
| 2359 | + // speed |
|
| 2360 | + if (isset($line['Trak'])) { |
|
| 2361 | + $data['heading'] = $line['Trak']; |
|
| 2362 | + } |
|
| 2363 | + // heading |
|
| 2364 | + if (isset($line['Lat'])) { |
|
| 2365 | + $data['latitude'] = $line['Lat']; |
|
| 2366 | + } |
|
| 2367 | + // lat |
|
| 2368 | + if (isset($line['Long'])) { |
|
| 2369 | + $data['longitude'] = $line['Long']; |
|
| 2370 | + } |
|
| 2371 | + // long |
|
| 1721 | 2372 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1722 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 2373 | + if (isset($line['Sqk'])) { |
|
| 2374 | + $data['squawk'] = $line['Sqk']; |
|
| 2375 | + } |
|
| 2376 | + // squawk |
|
| 1723 | 2377 | $data['emergency'] = ''; // emergency |
| 1724 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 2378 | + if (isset($line['Reg'])) { |
|
| 2379 | + $data['registration'] = $line['Reg']; |
|
| 2380 | + } |
|
| 1725 | 2381 | /* |
| 1726 | 2382 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1727 | 2383 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1728 | 2384 | */ |
| 1729 | 2385 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1730 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 2386 | + if (isset($line['Type'])) { |
|
| 2387 | + $data['aircraft_icao'] = $line['Type']; |
|
| 2388 | + } |
|
| 1731 | 2389 | $data['format_source'] = 'vrstcp'; |
| 1732 | 2390 | $data['id_source'] = $id_source; |
| 1733 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1734 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1735 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 2391 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2392 | + $data['noarchive'] = true; |
|
| 2393 | + } |
|
| 2394 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2395 | + $data['source_name'] = $value['name']; |
|
| 2396 | + } |
|
| 2397 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 2398 | + $SI->add($data); |
|
| 2399 | + } |
|
| 1736 | 2400 | unset($data); |
| 1737 | 2401 | } |
| 1738 | 2402 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1745,22 +2409,46 @@ discard block |
||
| 1745 | 2409 | $data['hex'] = $lined['hexid']; |
| 1746 | 2410 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1747 | 2411 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1748 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1749 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1750 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1751 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1752 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1753 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1754 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 2412 | + if (isset($lined['ident'])) { |
|
| 2413 | + $data['ident'] = $lined['ident']; |
|
| 2414 | + } |
|
| 2415 | + if (isset($lined['lat'])) { |
|
| 2416 | + $data['latitude'] = $lined['lat']; |
|
| 2417 | + } |
|
| 2418 | + if (isset($lined['lon'])) { |
|
| 2419 | + $data['longitude'] = $lined['lon']; |
|
| 2420 | + } |
|
| 2421 | + if (isset($lined['speed'])) { |
|
| 2422 | + $data['speed'] = $lined['speed']; |
|
| 2423 | + } |
|
| 2424 | + if (isset($lined['squawk'])) { |
|
| 2425 | + $data['squawk'] = $lined['squawk']; |
|
| 2426 | + } |
|
| 2427 | + if (isset($lined['alt'])) { |
|
| 2428 | + $data['altitude'] = $lined['alt']; |
|
| 2429 | + } |
|
| 2430 | + if (isset($lined['heading'])) { |
|
| 2431 | + $data['heading'] = $lined['heading']; |
|
| 2432 | + } |
|
| 1755 | 2433 | $data['id_source'] = $id_source; |
| 1756 | 2434 | $data['format_source'] = 'tsv'; |
| 1757 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1758 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1759 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1760 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2435 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2436 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2437 | + } |
|
| 2438 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2439 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2440 | + } |
|
| 2441 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2442 | + $data['noarchive'] = true; |
|
| 2443 | + } |
|
| 2444 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2445 | + $SI->add($data); |
|
| 2446 | + } |
|
| 1761 | 2447 | unset($lined); |
| 1762 | 2448 | unset($data); |
| 1763 | - } else $error = true; |
|
| 2449 | + } else { |
|
| 2450 | + $error = true; |
|
| 2451 | + } |
|
| 1764 | 2452 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1765 | 2453 | if ($aprs_connect === 0) { |
| 1766 | 2454 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1786,47 +2474,96 @@ discard block |
||
| 1786 | 2474 | $aprs_last_tx = time(); |
| 1787 | 2475 | $data = array(); |
| 1788 | 2476 | //print_r($line); |
| 1789 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1790 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1791 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1792 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1793 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1794 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1795 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1796 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1797 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1798 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2477 | + if (isset($line['address'])) { |
|
| 2478 | + $data['hex'] = $line['address']; |
|
| 2479 | + } |
|
| 2480 | + if (isset($line['mmsi'])) { |
|
| 2481 | + $data['mmsi'] = $line['mmsi']; |
|
| 2482 | + } |
|
| 2483 | + if (isset($line['imo'])) { |
|
| 2484 | + $data['imo'] = $line['imo']; |
|
| 2485 | + } |
|
| 2486 | + if (isset($line['squawk'])) { |
|
| 2487 | + $data['squawk'] = $line['squawk']; |
|
| 2488 | + } |
|
| 2489 | + if (isset($line['arrival_code'])) { |
|
| 2490 | + $data['arrival_code'] = $line['arrival_code']; |
|
| 2491 | + } |
|
| 2492 | + if (isset($line['arrival_date'])) { |
|
| 2493 | + $data['arrival_date'] = $line['arrival_date']; |
|
| 2494 | + } |
|
| 2495 | + if (isset($line['typeid'])) { |
|
| 2496 | + $data['type_id'] = $line['typeid']; |
|
| 2497 | + } |
|
| 2498 | + if (isset($line['statusid'])) { |
|
| 2499 | + $data['status_id'] = $line['statusid']; |
|
| 2500 | + } |
|
| 2501 | + if (isset($line['timestamp'])) { |
|
| 2502 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 2503 | + } else { |
|
| 2504 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2505 | + } |
|
| 1799 | 2506 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1800 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 2507 | + if (isset($line['ident'])) { |
|
| 2508 | + $data['ident'] = $line['ident']; |
|
| 2509 | + } |
|
| 1801 | 2510 | $data['latitude'] = $line['latitude']; |
| 1802 | 2511 | $data['longitude'] = $line['longitude']; |
| 1803 | 2512 | //$data['verticalrate'] = $line[16]; |
| 1804 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 2513 | + if (isset($line['speed'])) { |
|
| 2514 | + $data['speed'] = $line['speed']; |
|
| 2515 | + } |
|
| 1805 | 2516 | //else $data['speed'] = 0; |
| 1806 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1807 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1808 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 2517 | + if (isset($line['altitude'])) { |
|
| 2518 | + $data['altitude'] = $line['altitude']; |
|
| 2519 | + } |
|
| 2520 | + if (isset($line['comment'])) { |
|
| 2521 | + $data['comment'] = $line['comment']; |
|
| 2522 | + } |
|
| 2523 | + if (isset($line['symbol'])) { |
|
| 2524 | + $data['type'] = $line['symbol']; |
|
| 2525 | + } |
|
| 1809 | 2526 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
| 1810 | 2527 | |
| 1811 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 2528 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
| 2529 | + $data['heading'] = $line['heading']; |
|
| 2530 | + } |
|
| 1812 | 2531 | //else echo 'No heading...'."\n"; |
| 1813 | 2532 | //else $data['heading'] = 0; |
| 1814 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 2533 | + if (isset($line['stealth'])) { |
|
| 2534 | + $data['aircraft_type'] = $line['stealth']; |
|
| 2535 | + } |
|
| 1815 | 2536 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1816 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1817 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1818 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1819 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 2537 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 2538 | + $data['noarchive'] = true; |
|
| 2539 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 2540 | + $data['noarchive'] = false; |
|
| 2541 | + } |
|
| 2542 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2543 | + $data['noarchive'] = true; |
|
| 2544 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 2545 | + $data['noarchive'] = false; |
|
| 2546 | + } |
|
| 1820 | 2547 | $data['id_source'] = $id_source; |
| 1821 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1822 | - else $data['format_source'] = 'aprs'; |
|
| 2548 | + if (isset($line['format_source'])) { |
|
| 2549 | + $data['format_source'] = $line['format_source']; |
|
| 2550 | + } else { |
|
| 2551 | + $data['format_source'] = 'aprs'; |
|
| 2552 | + } |
|
| 1823 | 2553 | $data['source_name'] = $line['source']; |
| 1824 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1825 | - else $data['source_type'] = 'flarm'; |
|
| 1826 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2554 | + if (isset($line['source_type'])) { |
|
| 2555 | + $data['source_type'] = $line['source_type']; |
|
| 2556 | + } else { |
|
| 2557 | + $data['source_type'] = 'flarm'; |
|
| 2558 | + } |
|
| 2559 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2560 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2561 | + } |
|
| 1827 | 2562 | $currentdate = date('Y-m-d H:i:s'); |
| 1828 | 2563 | $aprsdate = strtotime($data['datetime']); |
| 1829 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 2564 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
| 2565 | + $data['altitude_relative'] = 'AMSL'; |
|
| 2566 | + } |
|
| 1830 | 2567 | // Accept data if time <= system time + 20s |
| 1831 | 2568 | //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'])))) { |
| 1832 | 2569 | if ( |
@@ -1838,7 +2575,9 @@ discard block |
||
| 1838 | 2575 | $send = $SI->add($data); |
| 1839 | 2576 | } elseif ($data['source_type'] === 'ais') { |
| 1840 | 2577 | $data['type'] = ''; |
| 1841 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 2578 | + if (isset($globalMarine) && $globalMarine) { |
|
| 2579 | + $send = $MI->add($data); |
|
| 2580 | + } |
|
| 1842 | 2581 | } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
| 1843 | 2582 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1844 | 2583 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
@@ -1846,8 +2585,12 @@ discard block |
||
| 1846 | 2585 | $line['symbol'] === 'Glider' || |
| 1847 | 2586 | $line['symbol'] === 'No. Plane' || |
| 1848 | 2587 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
| 1849 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1850 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2588 | + if ($line['symbol'] === 'Ballon') { |
|
| 2589 | + $data['aircraft_icao'] = 'BALL'; |
|
| 2590 | + } |
|
| 2591 | + if ($line['symbol'] === 'Glider') { |
|
| 2592 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2593 | + } |
|
| 1851 | 2594 | $send = $SI->add($data); |
| 1852 | 2595 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 1853 | 2596 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1878,9 +2621,13 @@ discard block |
||
| 1878 | 2621 | //} 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') { |
| 1879 | 2622 | // } 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') { |
| 1880 | 2623 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1881 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 2624 | + if (isset($globalTracker) && $globalTracker) { |
|
| 2625 | + $send = $TI->add($data); |
|
| 2626 | + } |
|
| 1882 | 2627 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 1883 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
| 2628 | + if (!isset($data['altitude'])) { |
|
| 2629 | + $data['altitude'] = 0; |
|
| 2630 | + } |
|
| 1884 | 2631 | $Source->deleteOldLocationByType('gs'); |
| 1885 | 2632 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
| 1886 | 2633 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1889,7 +2636,9 @@ discard block |
||
| 1889 | 2636 | } |
| 1890 | 2637 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 1891 | 2638 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1892 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
| 2639 | + if ($globalDebug) { |
|
| 2640 | + echo '# Weather Station added'."\n"; |
|
| 2641 | + } |
|
| 1893 | 2642 | $Source->deleteOldLocationByType('wx'); |
| 1894 | 2643 | $weather_data = json_encode($line); |
| 1895 | 2644 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1899,7 +2648,9 @@ discard block |
||
| 1899 | 2648 | } |
| 1900 | 2649 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 1901 | 2650 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1902 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2651 | + if ($globalDebug) { |
|
| 2652 | + echo '☈ Lightning added'."\n"; |
|
| 2653 | + } |
|
| 1903 | 2654 | $Source->deleteOldLocationByType('lightning'); |
| 1904 | 2655 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
| 1905 | 2656 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1911,8 +2662,7 @@ discard block |
||
| 1911 | 2662 | print_r($line); |
| 1912 | 2663 | } |
| 1913 | 2664 | unset($data); |
| 1914 | - } |
|
| 1915 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2665 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 1916 | 2666 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 1917 | 2667 | } |
| 1918 | 2668 | /* |
@@ -1921,7 +2671,9 @@ discard block |
||
| 1921 | 2671 | } |
| 1922 | 2672 | */ |
| 1923 | 2673 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1924 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 2674 | + elseif ($line === true && $globalDebug) { |
|
| 2675 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2676 | + } |
|
| 1925 | 2677 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
| 1926 | 2678 | $Source->deleteOldLocationByType('lightning'); |
| 1927 | 2679 | $Source->deleteOldLocationByType('wx'); |
@@ -1957,27 +2709,47 @@ discard block |
||
| 1957 | 2709 | $data['ground'] = $line[21]; |
| 1958 | 2710 | $data['emergency'] = $line[19]; |
| 1959 | 2711 | $data['format_source'] = 'sbs'; |
| 1960 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1961 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
| 1962 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1963 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2712 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2713 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2714 | + } elseif ($line[0] == 'MLAT') { |
|
| 2715 | + $data['source_name'] = 'MLAT'; |
|
| 2716 | + } |
|
| 2717 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2718 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2719 | + } |
|
| 2720 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2721 | + $data['noarchive'] = true; |
|
| 2722 | + } |
|
| 1964 | 2723 | $data['id_source'] = $id_source; |
| 1965 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1966 | - else $error = true; |
|
| 2724 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2725 | + $send = $SI->add($data); |
|
| 2726 | + } else { |
|
| 2727 | + $error = true; |
|
| 2728 | + } |
|
| 1967 | 2729 | unset($data); |
| 1968 | - } else $error = true; |
|
| 2730 | + } else { |
|
| 2731 | + $error = true; |
|
| 2732 | + } |
|
| 1969 | 2733 | if ($error) { |
| 1970 | 2734 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 1971 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2735 | + if ($globalDebug) { |
|
| 2736 | + echo "Not a message. Ignoring... \n"; |
|
| 2737 | + } |
|
| 1972 | 2738 | } else { |
| 1973 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2739 | + if ($globalDebug) { |
|
| 2740 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2741 | + } |
|
| 1974 | 2742 | if ($globalDebug) { |
| 1975 | 2743 | echo $buffer; |
| 1976 | 2744 | //print_r($line); |
| 1977 | 2745 | } |
| 1978 | 2746 | //socket_close($r); |
| 1979 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1980 | - if ($format === 'aprs') $aprs_connect = 0; |
|
| 2747 | + if ($globalDebug) { |
|
| 2748 | + echo "Reconnect after an error...\n"; |
|
| 2749 | + } |
|
| 2750 | + if ($format === 'aprs') { |
|
| 2751 | + $aprs_connect = 0; |
|
| 2752 | + } |
|
| 1981 | 2753 | $sourceer[$nb] = $globalSources[$nb]; |
| 1982 | 2754 | connect_all($sourceer); |
| 1983 | 2755 | $sourceer = array(); |
@@ -1985,10 +2757,14 @@ discard block |
||
| 1985 | 2757 | } |
| 1986 | 2758 | } |
| 1987 | 2759 | // Sleep for xxx microseconds |
| 1988 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2760 | + if (isset($globalSBSSleep)) { |
|
| 2761 | + usleep($globalSBSSleep); |
|
| 2762 | + } |
|
| 1989 | 2763 | } else { |
| 1990 | 2764 | if ($format === 'flightgearmp') { |
| 1991 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2765 | + if ($globalDebug) { |
|
| 2766 | + echo "Reconnect FlightGear MP..."; |
|
| 2767 | + } |
|
| 1992 | 2768 | //@socket_close($r); |
| 1993 | 2769 | sleep($globalMinFetch); |
| 1994 | 2770 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1997,10 +2773,15 @@ discard block |
||
| 1997 | 2773 | break; |
| 1998 | 2774 | |
| 1999 | 2775 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 2000 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 2001 | - else $tt[$format] = 0; |
|
| 2776 | + if (isset($tt[$format])) { |
|
| 2777 | + $tt[$format]++; |
|
| 2778 | + } else { |
|
| 2779 | + $tt[$format] = 0; |
|
| 2780 | + } |
|
| 2002 | 2781 | if ($tt[$format] > 30 || $buffer === FALSE) { |
| 2003 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2782 | + if ($globalDebug) { |
|
| 2783 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2784 | + } |
|
| 2004 | 2785 | //@socket_close($r); |
| 2005 | 2786 | sleep(2); |
| 2006 | 2787 | $aprs_connect = 0; |
@@ -2018,11 +2799,17 @@ discard block |
||
| 2018 | 2799 | } else { |
| 2019 | 2800 | $error = socket_strerror(socket_last_error()); |
| 2020 | 2801 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2021 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2022 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2802 | + if ($globalDebug) { |
|
| 2803 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2804 | + } |
|
| 2805 | + if (isset($globalDebug)) { |
|
| 2806 | + echo "Restarting...\n"; |
|
| 2807 | + } |
|
| 2023 | 2808 | // Restart the script if possible |
| 2024 | 2809 | if (is_array($sockets)) { |
| 2025 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2810 | + if ($globalDebug) { |
|
| 2811 | + echo "Shutdown all sockets..."; |
|
| 2812 | + } |
|
| 2026 | 2813 | |
| 2027 | 2814 | foreach ($sockets as $sock) { |
| 2028 | 2815 | @socket_shutdown($sock,2); |
@@ -2030,25 +2817,45 @@ discard block |
||
| 2030 | 2817 | } |
| 2031 | 2818 | |
| 2032 | 2819 | } |
| 2033 | - if ($globalDebug) echo "Waiting..."; |
|
| 2820 | + if ($globalDebug) { |
|
| 2821 | + echo "Waiting..."; |
|
| 2822 | + } |
|
| 2034 | 2823 | sleep(2); |
| 2035 | 2824 | $time = time(); |
| 2036 | 2825 | //connect_all($hosts); |
| 2037 | 2826 | $aprs_connect = 0; |
| 2038 | - if ($reset%5 === 0) sleep(20); |
|
| 2039 | - if ($reset%10 === 0) sleep(100); |
|
| 2040 | - if ($reset%20 === 0) sleep(200); |
|
| 2041 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 2042 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 2827 | + if ($reset%5 === 0) { |
|
| 2828 | + sleep(20); |
|
| 2829 | + } |
|
| 2830 | + if ($reset%10 === 0) { |
|
| 2831 | + sleep(100); |
|
| 2832 | + } |
|
| 2833 | + if ($reset%20 === 0) { |
|
| 2834 | + sleep(200); |
|
| 2835 | + } |
|
| 2836 | + if ($reset > 100) { |
|
| 2837 | + exit('Too many attempts...'); |
|
| 2838 | + } |
|
| 2839 | + if ($globalDebug) { |
|
| 2840 | + echo "Restart all connections..."; |
|
| 2841 | + } |
|
| 2043 | 2842 | connect_all($globalSources); |
| 2044 | 2843 | } |
| 2045 | 2844 | } |
| 2046 | 2845 | } |
| 2047 | 2846 | if ($globalDaemon === false) { |
| 2048 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2049 | - if (isset($SI)) $SI->checkAll(); |
|
| 2050 | - if (isset($TI)) $TI->checkAll(); |
|
| 2051 | - if (isset($MI)) $MI->checkAll(); |
|
| 2847 | + if ($globalDebug) { |
|
| 2848 | + echo 'Check all...'."\n"; |
|
| 2849 | + } |
|
| 2850 | + if (isset($SI)) { |
|
| 2851 | + $SI->checkAll(); |
|
| 2852 | + } |
|
| 2853 | + if (isset($TI)) { |
|
| 2854 | + $TI->checkAll(); |
|
| 2855 | + } |
|
| 2856 | + if (isset($MI)) { |
|
| 2857 | + $MI->checkAll(); |
|
| 2858 | + } |
|
| 2052 | 2859 | } |
| 2053 | 2860 | } |
| 2054 | 2861 | } |