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