@@ -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,48 +63,89 @@ discard block |
||
59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 64 | if (isset($options['s'])) { |
61 | 65 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
64 | -} elseif (isset($options['source'])) { |
|
66 | + if (isset($options['format'])) { |
|
67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
68 | + } else { |
|
69 | + $globalSources[] = array('host' => $options['s']); |
|
70 | + } |
|
71 | + } elseif (isset($options['source'])) { |
|
65 | 72 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
68 | -} |
|
73 | + if (isset($options['format'])) { |
|
74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
75 | + } else { |
|
76 | + $globalSources[] = array('host' => $options['source']); |
|
77 | + } |
|
78 | + } |
|
69 | 79 | if (isset($options['aprsserverhost'])) { |
70 | 80 | $globalServerAPRS = TRUE; |
71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
72 | 82 | } |
73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
77 | -if (isset($options['enable_aircraft'])) $globalAircraft = TRUE; |
|
78 | -if (isset($options['disable_aircraft'])) $globalAircraft = FALSE; |
|
79 | -if (isset($options['enable_tracker'])) $globalTracker = TRUE; |
|
80 | -if (isset($options['disable_tracker'])) $globalTracker = FALSE; |
|
81 | -if (isset($options['enable_marine'])) $globalMarine = TRUE; |
|
82 | -if (isset($options['disable_marine'])) $globalMarine = FALSE; |
|
83 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
84 | -if (isset($options['server'])) $globalServer = TRUE; |
|
85 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
86 | -else $id_source = 1; |
|
83 | +if (isset($options['aprsserverport'])) { |
|
84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
85 | +} |
|
86 | +if (isset($options['aprsserverssid'])) { |
|
87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
88 | +} |
|
89 | +if (isset($options['aprsserverpass'])) { |
|
90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
91 | +} |
|
92 | +if (isset($options['noaprsserver'])) { |
|
93 | + $globalServerAPRS = FALSE; |
|
94 | +} |
|
95 | +if (isset($options['enable_aircraft'])) { |
|
96 | + $globalAircraft = TRUE; |
|
97 | +} |
|
98 | +if (isset($options['disable_aircraft'])) { |
|
99 | + $globalAircraft = FALSE; |
|
100 | +} |
|
101 | +if (isset($options['enable_tracker'])) { |
|
102 | + $globalTracker = TRUE; |
|
103 | +} |
|
104 | +if (isset($options['disable_tracker'])) { |
|
105 | + $globalTracker = FALSE; |
|
106 | +} |
|
107 | +if (isset($options['enable_marine'])) { |
|
108 | + $globalMarine = TRUE; |
|
109 | +} |
|
110 | +if (isset($options['disable_marine'])) { |
|
111 | + $globalMarine = FALSE; |
|
112 | +} |
|
113 | +if (isset($options['nodaemon'])) { |
|
114 | + $globalDaemon = FALSE; |
|
115 | +} |
|
116 | +if (isset($options['server'])) { |
|
117 | + $globalServer = TRUE; |
|
118 | +} |
|
119 | +if (isset($options['idsource'])) { |
|
120 | + $id_source = $options['idsource']; |
|
121 | +} else { |
|
122 | + $id_source = 1; |
|
123 | +} |
|
87 | 124 | if (isset($globalServer) && $globalServer) { |
88 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
125 | + if ($globalDebug) { |
|
126 | + echo "Using Server Mode\n"; |
|
127 | + } |
|
89 | 128 | $SI=new SpotterServer(); |
90 | 129 | /* |
91 | 130 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
92 | 131 | $SI = new adsb2aprs(); |
93 | 132 | $SI->connect(); |
94 | 133 | */ |
95 | -} else $SI=new SpotterImport($Connection->db); |
|
134 | +} else { |
|
135 | + $SI=new SpotterImport($Connection->db); |
|
136 | +} |
|
96 | 137 | |
97 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
138 | +if (isset($globalTracker) && $globalTracker) { |
|
139 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
140 | +} |
|
98 | 141 | if (isset($globalMarine) && $globalMarine) { |
99 | 142 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
100 | 143 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
101 | 144 | } |
102 | 145 | |
103 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
146 | +if (isset($globalTracker) && $globalTracker) { |
|
147 | + $TI = new TrackerImport($Connection->db); |
|
148 | +} |
|
104 | 149 | if (isset($globalMarine) && $globalMarine) { |
105 | 150 | $AIS = new AIS(); |
106 | 151 | $MI = new MarineImport($Connection->db); |
@@ -123,7 +168,9 @@ discard block |
||
123 | 168 | } |
124 | 169 | |
125 | 170 | // let's try and connect |
126 | -if ($globalDebug) echo "Connecting...\n"; |
|
171 | +if ($globalDebug) { |
|
172 | + echo "Connecting...\n"; |
|
173 | +} |
|
127 | 174 | $use_aprs = false; |
128 | 175 | $aprs_full = false; |
129 | 176 | $reset = 0; |
@@ -132,7 +179,9 @@ discard block |
||
132 | 179 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
133 | 180 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
134 | 181 | $reset++; |
135 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
182 | + if ($globalDebug) { |
|
183 | + echo 'Connect to all...'."\n"; |
|
184 | + } |
|
136 | 185 | foreach ($hosts as $id => $value) { |
137 | 186 | $host = $value['host']; |
138 | 187 | $globalSources[$id]['last_exec'] = 0; |
@@ -142,22 +191,30 @@ discard block |
||
142 | 191 | //$formats[$id] = 'deltadbtxt'; |
143 | 192 | $globalSources[$id]['format'] = 'deltadbtxt'; |
144 | 193 | //$last_exec['deltadbtxt'] = 0; |
145 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
194 | + if ($globalDebug) { |
|
195 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
196 | + } |
|
146 | 197 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
147 | 198 | //$formats[$id] = 'vatsimtxt'; |
148 | 199 | $globalSources[$id]['format'] = 'vatsimtxt'; |
149 | 200 | //$last_exec['vatsimtxt'] = 0; |
150 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
201 | + if ($globalDebug) { |
|
202 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
203 | + } |
|
151 | 204 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
152 | 205 | //$formats[$id] = 'aircraftlistjson'; |
153 | 206 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
154 | 207 | //$last_exec['aircraftlistjson'] = 0; |
155 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
208 | + if ($globalDebug) { |
|
209 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
210 | + } |
|
156 | 211 | } else if (preg_match('/opensky/i',$host)) { |
157 | 212 | //$formats[$id] = 'aircraftlistjson'; |
158 | 213 | $globalSources[$id]['format'] = 'opensky'; |
159 | 214 | //$last_exec['aircraftlistjson'] = 0; |
160 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
215 | + if ($globalDebug) { |
|
216 | + echo "Connect to opensky source (".$host.")...\n"; |
|
217 | + } |
|
161 | 218 | /* |
162 | 219 | // Disabled for now, site change source format |
163 | 220 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -174,7 +231,9 @@ discard block |
||
174 | 231 | //$formats[$id] = 'planeupdatefaa'; |
175 | 232 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
176 | 233 | //$last_exec['planeupdatefaa'] = 0; |
177 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
234 | + if ($globalDebug) { |
|
235 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
236 | + } |
|
178 | 237 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
179 | 238 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
180 | 239 | exit(0); |
@@ -183,32 +242,46 @@ discard block |
||
183 | 242 | //$formats[$id] = 'phpvmacars'; |
184 | 243 | $globalSources[$id]['format'] = 'phpvmacars'; |
185 | 244 | //$last_exec['phpvmacars'] = 0; |
186 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
245 | + if ($globalDebug) { |
|
246 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
247 | + } |
|
187 | 248 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
188 | 249 | //$formats[$id] = 'phpvmacars'; |
189 | 250 | $globalSources[$id]['format'] = 'vam'; |
190 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
251 | + if ($globalDebug) { |
|
252 | + echo "Connect to Vam source (".$host.")...\n"; |
|
253 | + } |
|
191 | 254 | } else if (preg_match('/whazzup/i',$host)) { |
192 | 255 | //$formats[$id] = 'whazzup'; |
193 | 256 | $globalSources[$id]['format'] = 'whazzup'; |
194 | 257 | //$last_exec['whazzup'] = 0; |
195 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
258 | + if ($globalDebug) { |
|
259 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
260 | + } |
|
196 | 261 | } else if (preg_match('/blitzortung/i',$host)) { |
197 | 262 | $globalSources[$id]['format'] = 'blitzortung'; |
198 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
263 | + if ($globalDebug) { |
|
264 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
265 | + } |
|
199 | 266 | } else if (preg_match('/airwhere/i',$host)) { |
200 | 267 | $globalSources[$id]['format'] = 'airwhere'; |
201 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
268 | + if ($globalDebug) { |
|
269 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
270 | + } |
|
202 | 271 | } else if (preg_match('/recentpireps/i',$host)) { |
203 | 272 | //$formats[$id] = 'pirepsjson'; |
204 | 273 | $globalSources[$id]['format'] = 'pirepsjson'; |
205 | 274 | //$last_exec['pirepsjson'] = 0; |
206 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
275 | + if ($globalDebug) { |
|
276 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
277 | + } |
|
207 | 278 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
208 | 279 | //$formats[$id] = 'fr24json'; |
209 | 280 | $globalSources[$id]['format'] = 'fr24json'; |
210 | 281 | //$last_exec['fr24json'] = 0; |
211 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
282 | + if ($globalDebug) { |
|
283 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
284 | + } |
|
212 | 285 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
213 | 286 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
214 | 287 | exit(0); |
@@ -217,7 +290,9 @@ discard block |
||
217 | 290 | //$formats[$id] = 'fr24json'; |
218 | 291 | $globalSources[$id]['format'] = 'myshiptracking'; |
219 | 292 | //$last_exec['fr24json'] = 0; |
220 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
293 | + if ($globalDebug) { |
|
294 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
295 | + } |
|
221 | 296 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
222 | 297 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
223 | 298 | exit(0); |
@@ -226,17 +301,24 @@ discard block |
||
226 | 301 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
227 | 302 | //$formats[$id] = 'tsv'; |
228 | 303 | $globalSources[$id]['format'] = 'tsv'; |
229 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
304 | + if ($globalDebug) { |
|
305 | + echo "Connect to tsv source (".$host.")...\n"; |
|
306 | + } |
|
230 | 307 | } |
231 | 308 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
232 | 309 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
233 | 310 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
234 | 311 | if ($idf !== false) { |
235 | 312 | $httpfeeds[$id] = $idf; |
236 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
313 | + if ($globalDebug) { |
|
314 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
315 | + } |
|
316 | + } elseif ($globalDebug) { |
|
317 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
237 | 318 | } |
238 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
239 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
319 | + } elseif ($globalDebug) { |
|
320 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
321 | + } |
|
240 | 322 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
241 | 323 | $hostport = explode(':',$host); |
242 | 324 | if (isset($hostport[1])) { |
@@ -276,17 +358,25 @@ discard block |
||
276 | 358 | //$formats[$id] = 'beast'; |
277 | 359 | $globalSources[$id]['format'] = 'beast'; |
278 | 360 | //} else $formats[$id] = 'sbs'; |
279 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
361 | + } else { |
|
362 | + $globalSources[$id]['format'] = 'sbs'; |
|
363 | + } |
|
280 | 364 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
281 | 365 | } |
282 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
366 | + if ($globalDebug) { |
|
367 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
368 | + } |
|
283 | 369 | } else { |
284 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
370 | + if ($globalDebug) { |
|
371 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
372 | + } |
|
285 | 373 | } |
286 | 374 | } |
287 | 375 | } |
288 | 376 | } |
289 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
377 | +if (!isset($globalMinFetch)) { |
|
378 | + $globalMinFetch = 15; |
|
379 | +} |
|
290 | 380 | |
291 | 381 | // Initialize all |
292 | 382 | $status = array(); |
@@ -295,13 +385,19 @@ discard block |
||
295 | 385 | $formats = array(); |
296 | 386 | $last_exec = array(); |
297 | 387 | $time = time(); |
298 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
299 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
300 | -else $timeout = 20; |
|
388 | +if (isset($globalSourcesTimeout)) { |
|
389 | + $timeout = $globalSourcesTimeOut; |
|
390 | +} else if (isset($globalSBS1TimeOut)) { |
|
391 | + $timeout = $globalSBS1TimeOut; |
|
392 | +} else { |
|
393 | + $timeout = 20; |
|
394 | +} |
|
301 | 395 | $errno = ''; |
302 | 396 | $errstr=''; |
303 | 397 | |
304 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
398 | +if (!isset($globalDaemon)) { |
|
399 | + $globalDaemon = TRUE; |
|
400 | +} |
|
305 | 401 | /* Initiate connections to all the hosts simultaneously */ |
306 | 402 | //connect_all($hosts); |
307 | 403 | //connect_all($globalSources); |
@@ -330,7 +426,9 @@ discard block |
||
330 | 426 | if (isset($source['format']) && $source['format'] == 'aprs') { |
331 | 427 | $aprs_connect = 0; |
332 | 428 | $use_aprs = true; |
333 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
429 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
430 | + $aprs_full = true; |
|
431 | + } |
|
334 | 432 | break; |
335 | 433 | } |
336 | 434 | } |
@@ -341,25 +439,48 @@ discard block |
||
341 | 439 | $aprs_connect = 0; |
342 | 440 | $aprs_keep = 120; |
343 | 441 | $aprs_last_tx = time(); |
344 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
345 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
346 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
347 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
348 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
349 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
350 | - if ($aprs_full) $aprs_filter = ''; |
|
351 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
352 | - else $aprs_pass = '-1'; |
|
442 | + if (isset($globalAPRSversion)) { |
|
443 | + $aprs_version = $globalAPRSversion; |
|
444 | + } else { |
|
445 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
446 | + } |
|
447 | + if (isset($globalAPRSssid)) { |
|
448 | + $aprs_ssid = $globalAPRSssid; |
|
449 | + } else { |
|
450 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
451 | + } |
|
452 | + if (isset($globalAPRSfilter)) { |
|
453 | + $aprs_filter = $globalAPRSfilter; |
|
454 | + } else { |
|
455 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
456 | + } |
|
457 | + if ($aprs_full) { |
|
458 | + $aprs_filter = ''; |
|
459 | + } |
|
460 | + if (isset($globalAPRSpass)) { |
|
461 | + $aprs_pass = $globalAPRSpass; |
|
462 | + } else { |
|
463 | + $aprs_pass = '-1'; |
|
464 | + } |
|
353 | 465 | |
354 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
355 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
356 | -} |
|
466 | + if ($aprs_filter != '') { |
|
467 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
468 | + } else { |
|
469 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
470 | + } |
|
471 | + } |
|
357 | 472 | |
358 | 473 | // connected - lets do some work |
359 | -if ($globalDebug) echo "Connected!\n"; |
|
474 | +if ($globalDebug) { |
|
475 | + echo "Connected!\n"; |
|
476 | +} |
|
360 | 477 | sleep(1); |
361 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
362 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
478 | +if ($globalDebug) { |
|
479 | + echo "SCAN MODE \n\n"; |
|
480 | +} |
|
481 | +if (!isset($globalCronEnd)) { |
|
482 | + $globalCronEnd = 60; |
|
483 | +} |
|
363 | 484 | $endtime = time()+$globalCronEnd; |
364 | 485 | $i = 1; |
365 | 486 | $tt = array(); |
@@ -373,20 +494,28 @@ discard block |
||
373 | 494 | |
374 | 495 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
375 | 496 | while ($i > 0) { |
376 | - if (!$globalDaemon) $i = $endtime-time(); |
|
497 | + if (!$globalDaemon) { |
|
498 | + $i = $endtime-time(); |
|
499 | + } |
|
377 | 500 | // Delete old ATC |
378 | 501 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
379 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
502 | + if ($globalDebug) { |
|
503 | + echo 'Delete old ATC...'."\n"; |
|
504 | + } |
|
380 | 505 | $ATC->deleteOldATC(); |
381 | 506 | } |
382 | 507 | |
383 | 508 | if (count($last_exec) == count($globalSources)) { |
384 | 509 | $max = $globalMinFetch; |
385 | 510 | foreach ($last_exec as $last) { |
386 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
511 | + if ((time() - $last['last']) < $max) { |
|
512 | + $max = time() - $last['last']; |
|
513 | + } |
|
387 | 514 | } |
388 | 515 | if ($max != $globalMinFetch) { |
389 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
516 | + if ($globalDebug) { |
|
517 | + echo 'Sleeping...'."\n"; |
|
518 | + } |
|
390 | 519 | sleep($globalMinFetch-$max+2); |
391 | 520 | } |
392 | 521 | } |
@@ -396,7 +525,9 @@ discard block |
||
396 | 525 | foreach ($globalSources as $id => $value) { |
397 | 526 | date_default_timezone_set('UTC'); |
398 | 527 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
399 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
528 | + if (!isset($last_exec[$id]['last'])) { |
|
529 | + $last_exec[$id]['last'] = 0; |
|
530 | + } |
|
400 | 531 | if ($value['format'] == 'deltadbtxt' && |
401 | 532 | ( |
402 | 533 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -405,7 +536,9 @@ discard block |
||
405 | 536 | ) { |
406 | 537 | //$buffer = $Common->getData($hosts[$id]); |
407 | 538 | $buffer = $Common->getData($value['host']); |
408 | - if ($buffer != '') $reset = 0; |
|
539 | + if ($buffer != '') { |
|
540 | + $reset = 0; |
|
541 | + } |
|
409 | 542 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
410 | 543 | $buffer = explode('\n',$buffer); |
411 | 544 | foreach ($buffer as $line) { |
@@ -414,20 +547,41 @@ discard block |
||
414 | 547 | $data = array(); |
415 | 548 | $data['hex'] = $line[1]; // hex |
416 | 549 | $data['ident'] = $line[2]; // ident |
417 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
418 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
419 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
420 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
421 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
550 | + if (isset($line[3])) { |
|
551 | + $data['altitude'] = $line[3]; |
|
552 | + } |
|
553 | + // altitude |
|
554 | + if (isset($line[4])) { |
|
555 | + $data['speed'] = $line[4]; |
|
556 | + } |
|
557 | + // speed |
|
558 | + if (isset($line[5])) { |
|
559 | + $data['heading'] = $line[5]; |
|
560 | + } |
|
561 | + // heading |
|
562 | + if (isset($line[6])) { |
|
563 | + $data['latitude'] = $line[6]; |
|
564 | + } |
|
565 | + // lat |
|
566 | + if (isset($line[7])) { |
|
567 | + $data['longitude'] = $line[7]; |
|
568 | + } |
|
569 | + // long |
|
422 | 570 | $data['verticalrate'] = ''; // vertical rate |
423 | 571 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
424 | 572 | $data['emergency'] = ''; // emergency |
425 | 573 | $data['datetime'] = date('Y-m-d H:i:s'); |
426 | 574 | $data['format_source'] = 'deltadbtxt'; |
427 | 575 | $data['id_source'] = $id_source; |
428 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
429 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
430 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
576 | + if (isset($value['name']) && $value['name'] != '') { |
|
577 | + $data['source_name'] = $value['name']; |
|
578 | + } |
|
579 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
580 | + $data['noarchive'] = true; |
|
581 | + } |
|
582 | + if (isset($value['sourcestats'])) { |
|
583 | + $data['sourcestats'] = $value['sourcestats']; |
|
584 | + } |
|
431 | 585 | $SI->add($data); |
432 | 586 | unset($data); |
433 | 587 | } |
@@ -442,7 +596,9 @@ discard block |
||
442 | 596 | date_default_timezone_set('CET'); |
443 | 597 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
444 | 598 | date_default_timezone_set('UTC'); |
445 | - if ($buffer != '') $reset = 0; |
|
599 | + if ($buffer != '') { |
|
600 | + $reset = 0; |
|
601 | + } |
|
446 | 602 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
447 | 603 | $buffer = explode('\n',$buffer); |
448 | 604 | foreach ($buffer as $line) { |
@@ -451,16 +607,36 @@ discard block |
||
451 | 607 | $add = false; |
452 | 608 | $ais_data = $AIS->parse_line(trim($line)); |
453 | 609 | $data = array(); |
454 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
455 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
456 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
457 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
458 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
459 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
460 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
461 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
462 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
463 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
610 | + if (isset($ais_data['ident'])) { |
|
611 | + $data['ident'] = $ais_data['ident']; |
|
612 | + } |
|
613 | + if (isset($ais_data['mmsi'])) { |
|
614 | + $data['mmsi'] = $ais_data['mmsi']; |
|
615 | + } |
|
616 | + if (isset($ais_data['speed'])) { |
|
617 | + $data['speed'] = $ais_data['speed']; |
|
618 | + } |
|
619 | + if (isset($ais_data['heading'])) { |
|
620 | + $data['heading'] = $ais_data['heading']; |
|
621 | + } |
|
622 | + if (isset($ais_data['latitude'])) { |
|
623 | + $data['latitude'] = $ais_data['latitude']; |
|
624 | + } |
|
625 | + if (isset($ais_data['longitude'])) { |
|
626 | + $data['longitude'] = $ais_data['longitude']; |
|
627 | + } |
|
628 | + if (isset($ais_data['status'])) { |
|
629 | + $data['status'] = $ais_data['status']; |
|
630 | + } |
|
631 | + if (isset($ais_data['type'])) { |
|
632 | + $data['type'] = $ais_data['type']; |
|
633 | + } |
|
634 | + if (isset($ais_data['imo'])) { |
|
635 | + $data['imo'] = $ais_data['imo']; |
|
636 | + } |
|
637 | + if (isset($ais_data['callsign'])) { |
|
638 | + $data['callsign'] = $ais_data['callsign']; |
|
639 | + } |
|
464 | 640 | if (isset($ais_data['timestamp'])) { |
465 | 641 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
466 | 642 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -474,8 +650,12 @@ discard block |
||
474 | 650 | $data['format_source'] = 'aisnmeatxt'; |
475 | 651 | $data['id_source'] = $id_source; |
476 | 652 | //print_r($data); |
477 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
478 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
653 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
654 | + $data['noarchive'] = true; |
|
655 | + } |
|
656 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
657 | + $MI->add($data); |
|
658 | + } |
|
479 | 659 | unset($data); |
480 | 660 | } |
481 | 661 | } |
@@ -495,20 +675,48 @@ discard block |
||
495 | 675 | if ($line != '') { |
496 | 676 | $ais_data = $AIS->parse_line(trim($line)); |
497 | 677 | $data = array(); |
498 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
499 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
500 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
501 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
502 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
503 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
504 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
505 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
506 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
507 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
508 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
509 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
510 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
511 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
678 | + if (isset($ais_data['ident'])) { |
|
679 | + $data['ident'] = $ais_data['ident']; |
|
680 | + } |
|
681 | + if (isset($ais_data['mmsi'])) { |
|
682 | + $data['mmsi'] = $ais_data['mmsi']; |
|
683 | + } |
|
684 | + if (isset($ais_data['speed'])) { |
|
685 | + $data['speed'] = $ais_data['speed']; |
|
686 | + } |
|
687 | + if (isset($ais_data['heading'])) { |
|
688 | + $data['heading'] = $ais_data['heading']; |
|
689 | + } |
|
690 | + if (isset($ais_data['latitude'])) { |
|
691 | + $data['latitude'] = $ais_data['latitude']; |
|
692 | + } |
|
693 | + if (isset($ais_data['longitude'])) { |
|
694 | + $data['longitude'] = $ais_data['longitude']; |
|
695 | + } |
|
696 | + if (isset($ais_data['status'])) { |
|
697 | + $data['status'] = $ais_data['status']; |
|
698 | + } |
|
699 | + if (isset($ais_data['statusid'])) { |
|
700 | + $data['status_id'] = $ais_data['statusid']; |
|
701 | + } |
|
702 | + if (isset($ais_data['type'])) { |
|
703 | + $data['type'] = $ais_data['type']; |
|
704 | + } |
|
705 | + if (isset($ais_data['typeid'])) { |
|
706 | + $data['type_id'] = $ais_data['typeid']; |
|
707 | + } |
|
708 | + if (isset($ais_data['imo'])) { |
|
709 | + $data['imo'] = $ais_data['imo']; |
|
710 | + } |
|
711 | + if (isset($ais_data['callsign'])) { |
|
712 | + $data['callsign'] = $ais_data['callsign']; |
|
713 | + } |
|
714 | + if (isset($ais_data['destination'])) { |
|
715 | + $data['arrival_code'] = $ais_data['destination']; |
|
716 | + } |
|
717 | + if (isset($ais_data['eta_ts'])) { |
|
718 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
719 | + } |
|
512 | 720 | if (isset($ais_data['timestamp'])) { |
513 | 721 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
514 | 722 | } else { |
@@ -516,18 +724,27 @@ discard block |
||
516 | 724 | } |
517 | 725 | $data['format_source'] = 'aisnmeahttp'; |
518 | 726 | $data['id_source'] = $id_source; |
519 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
520 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
727 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
728 | + $data['noarchive'] = true; |
|
729 | + } |
|
730 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
731 | + $MI->add($data); |
|
732 | + } |
|
521 | 733 | unset($data); |
522 | 734 | } |
523 | 735 | } |
524 | 736 | } |
525 | 737 | } else { |
526 | 738 | $format = $value['format']; |
527 | - if (isset($tt[$format])) $tt[$format]++; |
|
528 | - else $tt[$format] = 0; |
|
739 | + if (isset($tt[$format])) { |
|
740 | + $tt[$format]++; |
|
741 | + } else { |
|
742 | + $tt[$format] = 0; |
|
743 | + } |
|
529 | 744 | if ($tt[$format] > 30) { |
530 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
745 | + if ($globalDebug) { |
|
746 | + echo 'Reconnect...'."\n"; |
|
747 | + } |
|
531 | 748 | sleep(2); |
532 | 749 | $sourceeen[] = $value; |
533 | 750 | connect_all($sourceeen); |
@@ -562,7 +779,9 @@ discard block |
||
562 | 779 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
563 | 780 | $data['format_source'] = 'myshiptracking'; |
564 | 781 | $data['id_source'] = $id_source; |
565 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
782 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
783 | + $data['noarchive'] = true; |
|
784 | + } |
|
566 | 785 | $MI->add($data); |
567 | 786 | unset($data); |
568 | 787 | } |
@@ -587,7 +806,9 @@ discard block |
||
587 | 806 | $data['callsign'] = $line['callsign']; |
588 | 807 | $data['mmsi'] = $line['mmsi']; |
589 | 808 | $data['speed'] = $line['sog']; |
590 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
809 | + if ($line['heading'] != '511') { |
|
810 | + $data['heading'] = $line['heading']; |
|
811 | + } |
|
591 | 812 | $data['latitude'] = $line['latitude']; |
592 | 813 | $data['longitude'] = $line['longitude']; |
593 | 814 | $data['type_id'] = $line['shiptype']; |
@@ -595,7 +816,9 @@ discard block |
||
595 | 816 | $data['datetime'] = $line['time']; |
596 | 817 | $data['format_source'] = 'boatbeaconapp'; |
597 | 818 | $data['id_source'] = $id_source; |
598 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
819 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
820 | + $data['noarchive'] = true; |
|
821 | + } |
|
599 | 822 | $MI->add($data); |
600 | 823 | unset($data); |
601 | 824 | } |
@@ -616,22 +839,44 @@ discard block |
||
616 | 839 | if (isset($all_data['features'][0]['id'])) { |
617 | 840 | foreach ($all_data['features'] as $line) { |
618 | 841 | $data = array(); |
619 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
620 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
621 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi']; |
|
622 | - if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo']; |
|
623 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
624 | - if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading']; |
|
842 | + if (isset($line['properties']['name'])) { |
|
843 | + $data['ident'] = $line['properties']['name']; |
|
844 | + } |
|
845 | + if (isset($line['properties']['callsign'])) { |
|
846 | + $data['callsign'] = $line['properties']['callsign']; |
|
847 | + } |
|
848 | + if (isset($line['properties']['mmsi'])) { |
|
849 | + $data['mmsi'] = $line['properties']['mmsi']; |
|
850 | + } |
|
851 | + if (isset($line['properties']['imo'])) { |
|
852 | + $data['mmsi'] = $line['properties']['imo']; |
|
853 | + } |
|
854 | + if (isset($line['properties']['speed'])) { |
|
855 | + $data['speed'] = $line['properties']['speed']; |
|
856 | + } |
|
857 | + if (isset($line['properties']['heading'])) { |
|
858 | + $data['heading'] = $line['properties']['heading']; |
|
859 | + } |
|
625 | 860 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
626 | 861 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
627 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
628 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
629 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
862 | + if (isset($line['properties']['vesselType'])) { |
|
863 | + $data['type'] = $line['properties']['vesselType']; |
|
864 | + } |
|
865 | + if (isset($line['properties']['destination'])) { |
|
866 | + $data['arrival_code'] = $line['properties']['destination']; |
|
867 | + } |
|
868 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
869 | + $data['arrival_date'] = $line['properties']['eta']; |
|
870 | + } |
|
630 | 871 | $data['format_source'] = 'boatnerd'; |
631 | 872 | $data['id_source'] = $id_source; |
632 | 873 | $data['datetime'] = date('Y-m-d H:i:s'); |
633 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
634 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
874 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
875 | + $data['noarchive'] = true; |
|
876 | + } |
|
877 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
878 | + $MI->add($data); |
|
879 | + } |
|
635 | 880 | unset($data); |
636 | 881 | } |
637 | 882 | } |
@@ -647,7 +892,9 @@ discard block |
||
647 | 892 | echo 'download...'; |
648 | 893 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
649 | 894 | echo 'done !'."\n"; |
650 | - if ($buffer != '') $reset = 0; |
|
895 | + if ($buffer != '') { |
|
896 | + $reset = 0; |
|
897 | + } |
|
651 | 898 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
652 | 899 | $buffer = explode('\n',$buffer); |
653 | 900 | foreach ($buffer as $line) { |
@@ -672,7 +919,9 @@ discard block |
||
672 | 919 | //$data['etaTime'] = substr($line,135,5); |
673 | 920 | $data['format_source'] = 'shipplotter'; |
674 | 921 | $data['id_source'] = $id_source; |
675 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
922 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
923 | + $data['noarchive'] = true; |
|
924 | + } |
|
676 | 925 | //print_r($data); |
677 | 926 | echo 'Add...'."\n"; |
678 | 927 | $MI->add($data); |
@@ -706,16 +955,28 @@ discard block |
||
706 | 955 | $line = explode(':', $line); |
707 | 956 | if (count($line) > 30 && $line[0] != 'callsign') { |
708 | 957 | $data = array(); |
709 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
710 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
958 | + if (isset($line[37]) && $line[37] != '') { |
|
959 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
960 | + } else { |
|
961 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
962 | + } |
|
711 | 963 | $data['pilot_id'] = $line[1]; |
712 | 964 | $data['pilot_name'] = $line[2]; |
713 | 965 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
714 | 966 | $data['ident'] = $line[0]; // ident |
715 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
967 | + if ($line[7] != '' && $line[7] != 0) { |
|
968 | + $data['altitude'] = $line[7]; |
|
969 | + } |
|
970 | + // altitude |
|
716 | 971 | $data['speed'] = $line[8]; // speed |
717 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
718 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
972 | + if (isset($line[45])) { |
|
973 | + $data['heading'] = $line[45]; |
|
974 | + } |
|
975 | + // heading |
|
976 | + elseif (isset($line[38])) { |
|
977 | + $data['heading'] = $line[38]; |
|
978 | + } |
|
979 | + // heading |
|
719 | 980 | $data['latitude'] = $line[5]; // lat |
720 | 981 | $data['longitude'] = $line[6]; // long |
721 | 982 | $data['verticalrate'] = ''; // vertical rate |
@@ -731,7 +992,9 @@ discard block |
||
731 | 992 | $data['frequency'] = $line[4]; |
732 | 993 | $data['type'] = $line[18]; |
733 | 994 | $data['range'] = $line[19]; |
734 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
995 | + if (isset($line[35])) { |
|
996 | + $data['info'] = $line[35]; |
|
997 | + } |
|
735 | 998 | $data['id_source'] = $id_source; |
736 | 999 | //$data['arrival_airport_time'] = ; |
737 | 1000 | if ($line[9] != '') { |
@@ -745,27 +1008,47 @@ discard block |
||
745 | 1008 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
746 | 1009 | */ |
747 | 1010 | $data['format_source'] = $value['format']; |
748 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
749 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
750 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
751 | - elseif ($line[3] == 'ATC') { |
|
1011 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1012 | + $data['noarchive'] = true; |
|
1013 | + } |
|
1014 | + if (isset($value['name']) && $value['name'] != '') { |
|
1015 | + $data['source_name'] = $value['name']; |
|
1016 | + } |
|
1017 | + if ($line[3] == 'PILOT') { |
|
1018 | + $SI->add($data); |
|
1019 | + } elseif ($line[3] == 'ATC') { |
|
752 | 1020 | //print_r($data); |
753 | 1021 | $data['info'] = str_replace('^§','<br />',$data['info']); |
754 | 1022 | $data['info'] = str_replace('&sect;','',$data['info']); |
755 | 1023 | $typec = substr($data['ident'],-3); |
756 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
757 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
758 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
759 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
760 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
761 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
762 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
763 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
764 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
765 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
1024 | + if ($typec == 'APP') { |
|
1025 | + $data['type'] = 'Approach'; |
|
1026 | + } elseif ($typec == 'TWR') { |
|
1027 | + $data['type'] = 'Tower'; |
|
1028 | + } elseif ($typec == 'OBS') { |
|
1029 | + $data['type'] = 'Observer'; |
|
1030 | + } elseif ($typec == 'GND') { |
|
1031 | + $data['type'] = 'Ground'; |
|
1032 | + } elseif ($typec == 'DEL') { |
|
1033 | + $data['type'] = 'Delivery'; |
|
1034 | + } elseif ($typec == 'DEP') { |
|
1035 | + $data['type'] = 'Departure'; |
|
1036 | + } elseif ($typec == 'FSS') { |
|
1037 | + $data['type'] = 'Flight Service Station'; |
|
1038 | + } elseif ($typec == 'CTR') { |
|
1039 | + $data['type'] = 'Control Radar or Centre'; |
|
1040 | + } elseif ($data['type'] == '') { |
|
1041 | + $data['type'] = 'Observer'; |
|
1042 | + } |
|
1043 | + if (!isset($data['source_name'])) { |
|
1044 | + $data['source_name'] = ''; |
|
1045 | + } |
|
766 | 1046 | if (isset($ATC)) { |
767 | - 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']); |
|
768 | - 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']); |
|
1047 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1048 | + 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']); |
|
1049 | + } else { |
|
1050 | + 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']); |
|
1051 | + } |
|
769 | 1052 | } |
770 | 1053 | } |
771 | 1054 | unset($data); |
@@ -792,14 +1075,20 @@ discard block |
||
792 | 1075 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
793 | 1076 | $data['latitude'] = (float)$line['pktLatitude']; |
794 | 1077 | $data['longitude'] = (float)$line['pktLongitude']; |
795 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
796 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1078 | + if ((float)$line['pktTrack'] != 0) { |
|
1079 | + $data['heading'] = (float)$line['pktTrack']; |
|
1080 | + } |
|
1081 | + if ((int)$line['pktSpeed'] != 0) { |
|
1082 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1083 | + } |
|
797 | 1084 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
798 | 1085 | $data['altitude_relative'] = 'AMSL'; |
799 | 1086 | $data['pilot_id'] = (int)$line['pktPilotID']; |
800 | 1087 | $data['aircraft_icao'] = 'PARAGLIDER'; |
801 | 1088 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
802 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1089 | + if (isset($pilot_data[4])) { |
|
1090 | + $data['pilot_name'] = $pilot_data[4]; |
|
1091 | + } |
|
803 | 1092 | $data['format_source'] = $value['format']; |
804 | 1093 | $SI->add($data); |
805 | 1094 | unset($data); |
@@ -847,25 +1136,59 @@ discard block |
||
847 | 1136 | foreach ($all_data['acList'] as $line) { |
848 | 1137 | $data = array(); |
849 | 1138 | $data['hex'] = $line['Icao']; // hex |
850 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
851 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
852 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
853 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
854 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
855 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1139 | + if (isset($line['Call'])) { |
|
1140 | + $data['ident'] = $line['Call']; |
|
1141 | + } |
|
1142 | + // ident |
|
1143 | + if (isset($line['Alt'])) { |
|
1144 | + $data['altitude'] = $line['Alt']; |
|
1145 | + } |
|
1146 | + // altitude |
|
1147 | + if (isset($line['Spd'])) { |
|
1148 | + $data['speed'] = $line['Spd']; |
|
1149 | + } |
|
1150 | + // speed |
|
1151 | + if (isset($line['Trak'])) { |
|
1152 | + $data['heading'] = $line['Trak']; |
|
1153 | + } |
|
1154 | + // heading |
|
1155 | + if (isset($line['Lat'])) { |
|
1156 | + $data['latitude'] = $line['Lat']; |
|
1157 | + } |
|
1158 | + // lat |
|
1159 | + if (isset($line['Long'])) { |
|
1160 | + $data['longitude'] = $line['Long']; |
|
1161 | + } |
|
1162 | + // long |
|
856 | 1163 | //$data['verticalrate'] = $line['']; // verticale rate |
857 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1164 | + if (isset($line['Sqk'])) { |
|
1165 | + $data['squawk'] = $line['Sqk']; |
|
1166 | + } |
|
1167 | + // squawk |
|
858 | 1168 | $data['emergency'] = ''; // emergency |
859 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
860 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
861 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1169 | + if (isset($line['Reg'])) { |
|
1170 | + $data['registration'] = $line['Reg']; |
|
1171 | + } |
|
1172 | + if (isset($line['PosTime'])) { |
|
1173 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1174 | + } else { |
|
1175 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1176 | + } |
|
862 | 1177 | //$data['datetime'] = date('Y-m-d H:i:s'); |
863 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1178 | + if (isset($line['Type'])) { |
|
1179 | + $data['aircraft_icao'] = $line['Type']; |
|
1180 | + } |
|
864 | 1181 | $data['format_source'] = 'aircraftlistjson'; |
865 | 1182 | $data['id_source'] = $id_source; |
866 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
867 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
868 | - if (isset($data['latitude'])) $SI->add($data); |
|
1183 | + if (isset($value['name']) && $value['name'] != '') { |
|
1184 | + $data['source_name'] = $value['name']; |
|
1185 | + } |
|
1186 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1187 | + $data['noarchive'] = true; |
|
1188 | + } |
|
1189 | + if (isset($data['latitude'])) { |
|
1190 | + $SI->add($data); |
|
1191 | + } |
|
869 | 1192 | unset($data); |
870 | 1193 | } |
871 | 1194 | } elseif (is_array($all_data)) { |
@@ -882,17 +1205,26 @@ discard block |
||
882 | 1205 | $data['verticalrate'] = $line['vrt']; // verticale rate |
883 | 1206 | $data['squawk'] = $line['squawk']; // squawk |
884 | 1207 | $data['emergency'] = ''; // emergency |
885 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
886 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1208 | + if (isset($line['PosTime'])) { |
|
1209 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1210 | + } else { |
|
1211 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1212 | + } |
|
887 | 1213 | $data['format_source'] = 'aircraftlistjson'; |
888 | 1214 | $data['id_source'] = $id_source; |
889 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
890 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1215 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1216 | + $data['noarchive'] = true; |
|
1217 | + } |
|
1218 | + if (isset($value['name']) && $value['name'] != '') { |
|
1219 | + $data['source_name'] = $value['name']; |
|
1220 | + } |
|
891 | 1221 | $SI->add($data); |
892 | 1222 | unset($data); |
893 | 1223 | } |
894 | 1224 | } |
895 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1225 | + } elseif ($globalDebug) { |
|
1226 | + echo 'No data'."\n"; |
|
1227 | + } |
|
896 | 1228 | //$last_exec['aircraftlistjson'] = time(); |
897 | 1229 | $last_exec[$id]['last'] = time(); |
898 | 1230 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -928,8 +1260,12 @@ discard block |
||
928 | 1260 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
929 | 1261 | $data['format_source'] = 'planeupdatefaa'; |
930 | 1262 | $data['id_source'] = $id_source; |
931 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
932 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1263 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1264 | + $data['noarchive'] = true; |
|
1265 | + } |
|
1266 | + if (isset($value['name']) && $value['name'] != '') { |
|
1267 | + $data['source_name'] = $value['name']; |
|
1268 | + } |
|
933 | 1269 | $SI->add($data); |
934 | 1270 | unset($data); |
935 | 1271 | } |
@@ -963,7 +1299,9 @@ discard block |
||
963 | 1299 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
964 | 1300 | $data['format_source'] = 'opensky'; |
965 | 1301 | $data['id_source'] = $id_source; |
966 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1302 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1303 | + $data['noarchive'] = true; |
|
1304 | + } |
|
967 | 1305 | $SI->add($data); |
968 | 1306 | unset($data); |
969 | 1307 | } |
@@ -980,7 +1318,9 @@ discard block |
||
980 | 1318 | //$buffer = $Common->getData($hosts[$id]); |
981 | 1319 | $buffer = $Common->getData($value['host']); |
982 | 1320 | $all_data = json_decode($buffer,true); |
983 | - if (!empty($all_data)) $reset = 0; |
|
1321 | + if (!empty($all_data)) { |
|
1322 | + $reset = 0; |
|
1323 | + } |
|
984 | 1324 | foreach ($all_data as $key => $line) { |
985 | 1325 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
986 | 1326 | $data = array(); |
@@ -1001,8 +1341,12 @@ discard block |
||
1001 | 1341 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
1002 | 1342 | $data['format_source'] = 'fr24json'; |
1003 | 1343 | $data['id_source'] = $id_source; |
1004 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1005 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1344 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1345 | + $data['noarchive'] = true; |
|
1346 | + } |
|
1347 | + if (isset($value['name']) && $value['name'] != '') { |
|
1348 | + $data['source_name'] = $value['name']; |
|
1349 | + } |
|
1006 | 1350 | $SI->add($data); |
1007 | 1351 | unset($data); |
1008 | 1352 | } |
@@ -1031,24 +1375,42 @@ discard block |
||
1031 | 1375 | if (isset($line['inf'])) { |
1032 | 1376 | $data = array(); |
1033 | 1377 | $data['hex'] = $line['inf']['ia']; |
1034 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1378 | + if (isset($line['inf']['cs'])) { |
|
1379 | + $data['ident'] = $line['inf']['cs']; |
|
1380 | + } |
|
1381 | + //$line[13] |
|
1035 | 1382 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1036 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1037 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1383 | + if (isset($line['inf']['gs'])) { |
|
1384 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1385 | + } |
|
1386 | + // speed |
|
1387 | + if (isset($line['inf']['tr'])) { |
|
1388 | + $data['heading'] = $line['inf']['tr']; |
|
1389 | + } |
|
1390 | + // heading |
|
1038 | 1391 | $data['latitude'] = $line['pt'][0]; // lat |
1039 | 1392 | $data['longitude'] = $line['pt'][1]; // long |
1040 | 1393 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1041 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1394 | + if (isset($line['inf']['sq'])) { |
|
1395 | + $data['squawk'] = $line['inf']['sq']; |
|
1396 | + } |
|
1397 | + // squawk |
|
1042 | 1398 | //$data['aircraft_icao'] = $line[8]; |
1043 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1399 | + if (isset($line['inf']['rc'])) { |
|
1400 | + $data['registration'] = $line['inf']['rc']; |
|
1401 | + } |
|
1044 | 1402 | //$data['departure_airport_iata'] = $line[11]; |
1045 | 1403 | //$data['arrival_airport_iata'] = $line[12]; |
1046 | 1404 | //$data['emergency'] = ''; // emergency |
1047 | 1405 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1048 | 1406 | $data['format_source'] = 'radarvirtueljson'; |
1049 | 1407 | $data['id_source'] = $id_source; |
1050 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1051 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1408 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1409 | + $data['noarchive'] = true; |
|
1410 | + } |
|
1411 | + if (isset($value['name']) && $value['name'] != '') { |
|
1412 | + $data['source_name'] = $value['name']; |
|
1413 | + } |
|
1052 | 1414 | $SI->add($data); |
1053 | 1415 | unset($data); |
1054 | 1416 | } |
@@ -1074,30 +1436,65 @@ discard block |
||
1074 | 1436 | $data['id'] = $line['id']; |
1075 | 1437 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1076 | 1438 | $data['ident'] = $line['callsign']; // ident |
1077 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1078 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1079 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1080 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1081 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1082 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1439 | + if (isset($line['pilotid'])) { |
|
1440 | + $data['pilot_id'] = $line['pilotid']; |
|
1441 | + } |
|
1442 | + // pilot id |
|
1443 | + if (isset($line['name'])) { |
|
1444 | + $data['pilot_name'] = $line['name']; |
|
1445 | + } |
|
1446 | + // pilot name |
|
1447 | + if (isset($line['alt'])) { |
|
1448 | + $data['altitude'] = $line['alt']; |
|
1449 | + } |
|
1450 | + // altitude |
|
1451 | + if (isset($line['gs'])) { |
|
1452 | + $data['speed'] = $line['gs']; |
|
1453 | + } |
|
1454 | + // speed |
|
1455 | + if (isset($line['heading'])) { |
|
1456 | + $data['heading'] = $line['heading']; |
|
1457 | + } |
|
1458 | + // heading |
|
1459 | + if (isset($line['route'])) { |
|
1460 | + $data['waypoints'] = $line['route']; |
|
1461 | + } |
|
1462 | + // route |
|
1083 | 1463 | $data['latitude'] = $line['lat']; // lat |
1084 | 1464 | $data['longitude'] = $line['lon']; // long |
1085 | 1465 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1086 | 1466 | //$data['squawk'] = $line['squawk']; // squawk |
1087 | 1467 | //$data['emergency'] = ''; // emergency |
1088 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1089 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1090 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1468 | + if (isset($line['depicao'])) { |
|
1469 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1470 | + } |
|
1471 | + if (isset($line['deptime'])) { |
|
1472 | + $data['departure_airport_time'] = $line['deptime']; |
|
1473 | + } |
|
1474 | + if (isset($line['arricao'])) { |
|
1475 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1476 | + } |
|
1091 | 1477 | //$data['arrival_airport_time'] = $line['arrtime']; |
1092 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1093 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1094 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1095 | - else $data['info'] = ''; |
|
1478 | + if (isset($line['aircraft'])) { |
|
1479 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1480 | + } |
|
1481 | + if (isset($line['transponder'])) { |
|
1482 | + $data['squawk'] = $line['transponder']; |
|
1483 | + } |
|
1484 | + if (isset($line['atis'])) { |
|
1485 | + $data['info'] = $line['atis']; |
|
1486 | + } else { |
|
1487 | + $data['info'] = ''; |
|
1488 | + } |
|
1096 | 1489 | $data['format_source'] = 'pireps'; |
1097 | 1490 | $data['id_source'] = $id_source; |
1098 | 1491 | $data['datetime'] = date('Y-m-d H:i:s'); |
1099 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1100 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1492 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1493 | + $data['noarchive'] = true; |
|
1494 | + } |
|
1495 | + if (isset($value['name']) && $value['name'] != '') { |
|
1496 | + $data['source_name'] = $value['name']; |
|
1497 | + } |
|
1101 | 1498 | if ($line['icon'] == 'plane') { |
1102 | 1499 | $SI->add($data); |
1103 | 1500 | // print_r($data); |
@@ -1106,16 +1503,28 @@ discard block |
||
1106 | 1503 | $data['info'] = str_replace('&sect;','',$data['info']); |
1107 | 1504 | $typec = substr($data['ident'],-3); |
1108 | 1505 | $data['type'] = ''; |
1109 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
1110 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
1111 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
1112 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
1113 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
1114 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
1115 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
1116 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1117 | - else $data['type'] = 'Observer'; |
|
1118 | - 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']); |
|
1506 | + if ($typec == 'APP') { |
|
1507 | + $data['type'] = 'Approach'; |
|
1508 | + } elseif ($typec == 'TWR') { |
|
1509 | + $data['type'] = 'Tower'; |
|
1510 | + } elseif ($typec == 'OBS') { |
|
1511 | + $data['type'] = 'Observer'; |
|
1512 | + } elseif ($typec == 'GND') { |
|
1513 | + $data['type'] = 'Ground'; |
|
1514 | + } elseif ($typec == 'DEL') { |
|
1515 | + $data['type'] = 'Delivery'; |
|
1516 | + } elseif ($typec == 'DEP') { |
|
1517 | + $data['type'] = 'Departure'; |
|
1518 | + } elseif ($typec == 'FSS') { |
|
1519 | + $data['type'] = 'Flight Service Station'; |
|
1520 | + } elseif ($typec == 'CTR') { |
|
1521 | + $data['type'] = 'Control Radar or Centre'; |
|
1522 | + } else { |
|
1523 | + $data['type'] = 'Observer'; |
|
1524 | + } |
|
1525 | + if (isset($ATC)) { |
|
1526 | + 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']); |
|
1527 | + } |
|
1119 | 1528 | } |
1120 | 1529 | unset($data); |
1121 | 1530 | } |
@@ -1130,7 +1539,9 @@ discard block |
||
1130 | 1539 | ) |
1131 | 1540 | ) { |
1132 | 1541 | //$buffer = $Common->getData($hosts[$id]); |
1133 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1542 | + if ($globalDebug) { |
|
1543 | + echo 'Get Data...'."\n"; |
|
1544 | + } |
|
1134 | 1545 | $buffer = $Common->getData($value['host']); |
1135 | 1546 | $all_data = json_decode($buffer,true); |
1136 | 1547 | if ($buffer != '' && is_array($all_data)) { |
@@ -1138,10 +1549,16 @@ discard block |
||
1138 | 1549 | foreach ($all_data as $line) { |
1139 | 1550 | $data = array(); |
1140 | 1551 | //$data['id'] = $line['id']; // id not usable |
1141 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1552 | + if (isset($line['pilotid'])) { |
|
1553 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1554 | + } |
|
1142 | 1555 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1143 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1144 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1556 | + if (isset($line['pilotname'])) { |
|
1557 | + $data['pilot_name'] = $line['pilotname']; |
|
1558 | + } |
|
1559 | + if (isset($line['pilotid'])) { |
|
1560 | + $data['pilot_id'] = $line['pilotid']; |
|
1561 | + } |
|
1145 | 1562 | $data['ident'] = $line['flightnum']; // ident |
1146 | 1563 | $data['altitude'] = $line['alt']; // altitude |
1147 | 1564 | $data['speed'] = $line['gs']; // speed |
@@ -1157,34 +1574,52 @@ discard block |
||
1157 | 1574 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1158 | 1575 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1159 | 1576 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1160 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1577 | + } else { |
|
1578 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1579 | + } |
|
1161 | 1580 | $data['departure_airport_icao'] = $line['depicao']; |
1162 | 1581 | $data['departure_airport_time'] = $line['deptime']; |
1163 | 1582 | $data['arrival_airport_icao'] = $line['arricao']; |
1164 | 1583 | $data['arrival_airport_time'] = $line['arrtime']; |
1165 | 1584 | $data['registration'] = $line['aircraft']; |
1166 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1167 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1585 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1586 | + $data['noarchive'] = true; |
|
1587 | + } |
|
1588 | + if (isset($line['route'])) { |
|
1589 | + $data['waypoints'] = $line['route']; |
|
1590 | + } |
|
1591 | + // route |
|
1168 | 1592 | if (isset($line['aircraftname'])) { |
1169 | 1593 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1170 | 1594 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1171 | 1595 | $aircraft_data = explode('-',$line['aircraftname']); |
1172 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1173 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1174 | - else { |
|
1596 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1597 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1598 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1599 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1600 | + } else { |
|
1175 | 1601 | $aircraft_data = explode(' ',$line['aircraftname']); |
1176 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1177 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1602 | + if (isset($aircraft_data[1])) { |
|
1603 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1604 | + } else { |
|
1605 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1606 | + } |
|
1178 | 1607 | } |
1179 | 1608 | } |
1180 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1609 | + if (isset($line['route'])) { |
|
1610 | + $data['waypoints'] = $line['route']; |
|
1611 | + } |
|
1181 | 1612 | $data['id_source'] = $id_source; |
1182 | 1613 | $data['format_source'] = 'phpvmacars'; |
1183 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1614 | + if (isset($value['name']) && $value['name'] != '') { |
|
1615 | + $data['source_name'] = $value['name']; |
|
1616 | + } |
|
1184 | 1617 | $SI->add($data); |
1185 | 1618 | unset($data); |
1186 | 1619 | } |
1187 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1620 | + if ($globalDebug) { |
|
1621 | + echo 'No more data...'."\n"; |
|
1622 | + } |
|
1188 | 1623 | unset($buffer); |
1189 | 1624 | unset($all_data); |
1190 | 1625 | } |
@@ -1197,7 +1632,9 @@ discard block |
||
1197 | 1632 | ) |
1198 | 1633 | ) { |
1199 | 1634 | //$buffer = $Common->getData($hosts[$id]); |
1200 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1635 | + if ($globalDebug) { |
|
1636 | + echo 'Get Data...'."\n"; |
|
1637 | + } |
|
1201 | 1638 | $buffer = $Common->getData($value['host']); |
1202 | 1639 | $all_data = json_decode($buffer,true); |
1203 | 1640 | if ($buffer != '' && is_array($all_data)) { |
@@ -1226,16 +1663,25 @@ discard block |
||
1226 | 1663 | $data['arrival_airport_icao'] = $line['arrival']; |
1227 | 1664 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1228 | 1665 | //$data['registration'] = $line['aircraft']; |
1229 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1666 | + if (isset($line['route'])) { |
|
1667 | + $data['waypoints'] = $line['route']; |
|
1668 | + } |
|
1669 | + // route |
|
1230 | 1670 | $data['aircraft_icao'] = $line['plane_type']; |
1231 | 1671 | $data['id_source'] = $id_source; |
1232 | 1672 | $data['format_source'] = 'vam'; |
1233 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1234 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1673 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1674 | + $data['noarchive'] = true; |
|
1675 | + } |
|
1676 | + if (isset($value['name']) && $value['name'] != '') { |
|
1677 | + $data['source_name'] = $value['name']; |
|
1678 | + } |
|
1235 | 1679 | $SI->add($data); |
1236 | 1680 | unset($data); |
1237 | 1681 | } |
1238 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1682 | + if ($globalDebug) { |
|
1683 | + echo 'No more data...'."\n"; |
|
1684 | + } |
|
1239 | 1685 | unset($buffer); |
1240 | 1686 | unset($all_data); |
1241 | 1687 | } |
@@ -1248,7 +1694,9 @@ discard block |
||
1248 | 1694 | ) |
1249 | 1695 | ) { |
1250 | 1696 | //$buffer = $Common->getData($hosts[$id]); |
1251 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1697 | + if ($globalDebug) { |
|
1698 | + echo 'Get Data...'."\n"; |
|
1699 | + } |
|
1252 | 1700 | $buffer = $Common->getData($value['host']); |
1253 | 1701 | $all_data = json_decode($buffer,true); |
1254 | 1702 | if ($buffer != '') { |
@@ -1266,18 +1714,24 @@ discard block |
||
1266 | 1714 | $data['id_source'] = $id_source; |
1267 | 1715 | $data['format_source'] = 'blitzortung'; |
1268 | 1716 | $SI->add($data); |
1269 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1717 | + if ($globalDebug) { |
|
1718 | + echo '☈ Lightning added'."\n"; |
|
1719 | + } |
|
1270 | 1720 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1271 | 1721 | unset($data); |
1272 | 1722 | } |
1273 | 1723 | } |
1274 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1724 | + if ($globalDebug) { |
|
1725 | + echo 'No more data...'."\n"; |
|
1726 | + } |
|
1275 | 1727 | unset($buffer); |
1276 | 1728 | } |
1277 | 1729 | $last_exec[$id]['last'] = time(); |
1278 | 1730 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1279 | 1731 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1280 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1732 | + if (function_exists('pcntl_fork')) { |
|
1733 | + pcntl_signal_dispatch(); |
|
1734 | + } |
|
1281 | 1735 | //$last_exec[$id]['last'] = time(); |
1282 | 1736 | |
1283 | 1737 | //$read = array( $sockets[$id] ); |
@@ -1285,7 +1739,9 @@ discard block |
||
1285 | 1739 | $write = NULL; |
1286 | 1740 | $e = NULL; |
1287 | 1741 | $n = socket_select($read, $write, $e, $timeout); |
1288 | - if ($e != NULL) var_dump($e); |
|
1742 | + if ($e != NULL) { |
|
1743 | + var_dump($e); |
|
1744 | + } |
|
1289 | 1745 | if ($n > 0) { |
1290 | 1746 | $reset = 0; |
1291 | 1747 | foreach ($read as $nb => $r) { |
@@ -1306,12 +1762,16 @@ discard block |
||
1306 | 1762 | //$SI::del(); |
1307 | 1763 | if ($format == 'vrstcp') { |
1308 | 1764 | $buffer = explode('},{',$buffer); |
1309 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1765 | + } else { |
|
1766 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1767 | + } |
|
1310 | 1768 | // SBS format is CSV format |
1311 | 1769 | if ($buffer !== FALSE && $buffer != '') { |
1312 | 1770 | $tt[$format] = 0; |
1313 | 1771 | if ($format == 'acarssbs3') { |
1314 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1772 | + if ($globalDebug) { |
|
1773 | + echo 'ACARS : '.$buffer."\n"; |
|
1774 | + } |
|
1315 | 1775 | $ACARS->add(trim($buffer)); |
1316 | 1776 | $ACARS->deleteLiveAcarsData(); |
1317 | 1777 | } elseif ($format == 'raw') { |
@@ -1320,30 +1780,70 @@ discard block |
||
1320 | 1780 | if (is_array($data)) { |
1321 | 1781 | $data['datetime'] = date('Y-m-d H:i:s'); |
1322 | 1782 | $data['format_source'] = 'raw'; |
1323 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1324 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1325 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1326 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1783 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1784 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1785 | + } |
|
1786 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1787 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1788 | + } |
|
1789 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1790 | + $data['noarchive'] = true; |
|
1791 | + } |
|
1792 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1793 | + $SI->add($data); |
|
1794 | + } |
|
1327 | 1795 | } |
1328 | 1796 | } elseif ($format == 'ais') { |
1329 | 1797 | $ais_data = $AIS->parse_line(trim($buffer)); |
1330 | 1798 | $data = array(); |
1331 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1332 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1333 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1334 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1335 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1336 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1337 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1338 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1339 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1340 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1341 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1342 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1343 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1344 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1345 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1346 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1799 | + if (isset($ais_data['ident'])) { |
|
1800 | + $data['ident'] = $ais_data['ident']; |
|
1801 | + } |
|
1802 | + if (isset($ais_data['mmsi'])) { |
|
1803 | + $data['mmsi'] = $ais_data['mmsi']; |
|
1804 | + } |
|
1805 | + if (isset($ais_data['speed'])) { |
|
1806 | + $data['speed'] = $ais_data['speed']; |
|
1807 | + } |
|
1808 | + if (isset($ais_data['heading'])) { |
|
1809 | + $data['heading'] = $ais_data['heading']; |
|
1810 | + } |
|
1811 | + if (isset($ais_data['latitude'])) { |
|
1812 | + $data['latitude'] = $ais_data['latitude']; |
|
1813 | + } |
|
1814 | + if (isset($ais_data['longitude'])) { |
|
1815 | + $data['longitude'] = $ais_data['longitude']; |
|
1816 | + } |
|
1817 | + if (isset($ais_data['status'])) { |
|
1818 | + $data['status'] = $ais_data['status']; |
|
1819 | + } |
|
1820 | + if (isset($ais_data['statusid'])) { |
|
1821 | + $data['status_id'] = $ais_data['statusid']; |
|
1822 | + } |
|
1823 | + if (isset($ais_data['type'])) { |
|
1824 | + $data['type'] = $ais_data['type']; |
|
1825 | + } |
|
1826 | + if (isset($ais_data['imo'])) { |
|
1827 | + $data['imo'] = $ais_data['imo']; |
|
1828 | + } |
|
1829 | + if (isset($ais_data['callsign'])) { |
|
1830 | + $data['callsign'] = $ais_data['callsign']; |
|
1831 | + } |
|
1832 | + if (isset($ais_data['destination'])) { |
|
1833 | + $data['arrival_code'] = $ais_data['destination']; |
|
1834 | + } |
|
1835 | + if (isset($ais_data['eta_ts'])) { |
|
1836 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1837 | + } |
|
1838 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1839 | + $data['noarchive'] = true; |
|
1840 | + } |
|
1841 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1842 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1843 | + } |
|
1844 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1845 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1846 | + } |
|
1347 | 1847 | |
1348 | 1848 | if (isset($ais_data['timestamp'])) { |
1349 | 1849 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1352,7 +1852,9 @@ discard block |
||
1352 | 1852 | } |
1353 | 1853 | $data['format_source'] = 'aisnmea'; |
1354 | 1854 | $data['id_source'] = $id_source; |
1355 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1855 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
1856 | + $MI->add($data); |
|
1857 | + } |
|
1356 | 1858 | unset($data); |
1357 | 1859 | } elseif ($format == 'flightgearsp') { |
1358 | 1860 | //echo $buffer."\n"; |
@@ -1370,12 +1872,18 @@ discard block |
||
1370 | 1872 | $data['speed'] = round($line[5]*1.94384); |
1371 | 1873 | $data['datetime'] = date('Y-m-d H:i:s'); |
1372 | 1874 | $data['format_source'] = 'flightgearsp'; |
1373 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1374 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1875 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1876 | + $data['noarchive'] = true; |
|
1877 | + } |
|
1878 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1879 | + $SI->add($data); |
|
1880 | + } |
|
1375 | 1881 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1376 | 1882 | } |
1377 | 1883 | } elseif ($format == 'acars') { |
1378 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1884 | + if ($globalDebug) { |
|
1885 | + echo 'ACARS : '.$buffer."\n"; |
|
1886 | + } |
|
1379 | 1887 | $ACARS->add(trim($buffer)); |
1380 | 1888 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1381 | 1889 | $ACARS->deleteLiveAcarsData(); |
@@ -1396,8 +1904,12 @@ discard block |
||
1396 | 1904 | $aircraft_type = $line[10]; |
1397 | 1905 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1398 | 1906 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1399 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1400 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1907 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1908 | + $data['noarchive'] = true; |
|
1909 | + } |
|
1910 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1911 | + $SI->add($data); |
|
1912 | + } |
|
1401 | 1913 | } |
1402 | 1914 | } |
1403 | 1915 | } elseif ($format == 'beast') { |
@@ -1407,28 +1919,62 @@ discard block |
||
1407 | 1919 | foreach($buffer as $all_data) { |
1408 | 1920 | $line = json_decode('{'.$all_data.'}',true); |
1409 | 1921 | $data = array(); |
1410 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1411 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1412 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1413 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1414 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1415 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1416 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1922 | + if (isset($line['Icao'])) { |
|
1923 | + $data['hex'] = $line['Icao']; |
|
1924 | + } |
|
1925 | + // hex |
|
1926 | + if (isset($line['Call'])) { |
|
1927 | + $data['ident'] = $line['Call']; |
|
1928 | + } |
|
1929 | + // ident |
|
1930 | + if (isset($line['Alt'])) { |
|
1931 | + $data['altitude'] = $line['Alt']; |
|
1932 | + } |
|
1933 | + // altitude |
|
1934 | + if (isset($line['Spd'])) { |
|
1935 | + $data['speed'] = $line['Spd']; |
|
1936 | + } |
|
1937 | + // speed |
|
1938 | + if (isset($line['Trak'])) { |
|
1939 | + $data['heading'] = $line['Trak']; |
|
1940 | + } |
|
1941 | + // heading |
|
1942 | + if (isset($line['Lat'])) { |
|
1943 | + $data['latitude'] = $line['Lat']; |
|
1944 | + } |
|
1945 | + // lat |
|
1946 | + if (isset($line['Long'])) { |
|
1947 | + $data['longitude'] = $line['Long']; |
|
1948 | + } |
|
1949 | + // long |
|
1417 | 1950 | //$data['verticalrate'] = $line['']; // verticale rate |
1418 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1951 | + if (isset($line['Sqk'])) { |
|
1952 | + $data['squawk'] = $line['Sqk']; |
|
1953 | + } |
|
1954 | + // squawk |
|
1419 | 1955 | $data['emergency'] = ''; // emergency |
1420 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1956 | + if (isset($line['Reg'])) { |
|
1957 | + $data['registration'] = $line['Reg']; |
|
1958 | + } |
|
1421 | 1959 | /* |
1422 | 1960 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1423 | 1961 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1424 | 1962 | */ |
1425 | 1963 | $data['datetime'] = date('Y-m-d H:i:s'); |
1426 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1964 | + if (isset($line['Type'])) { |
|
1965 | + $data['aircraft_icao'] = $line['Type']; |
|
1966 | + } |
|
1427 | 1967 | $data['format_source'] = 'vrstcp'; |
1428 | 1968 | $data['id_source'] = $id_source; |
1429 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1430 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1431 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
1969 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1970 | + $data['noarchive'] = true; |
|
1971 | + } |
|
1972 | + if (isset($value['name']) && $value['name'] != '') { |
|
1973 | + $data['source_name'] = $value['name']; |
|
1974 | + } |
|
1975 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
1976 | + $SI->add($data); |
|
1977 | + } |
|
1432 | 1978 | unset($data); |
1433 | 1979 | } |
1434 | 1980 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1441,22 +1987,46 @@ discard block |
||
1441 | 1987 | $data['hex'] = $lined['hexid']; |
1442 | 1988 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1443 | 1989 | $data['datetime'] = date('Y-m-d H:i:s');; |
1444 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1445 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1446 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1447 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1448 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1449 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1450 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1990 | + if (isset($lined['ident'])) { |
|
1991 | + $data['ident'] = $lined['ident']; |
|
1992 | + } |
|
1993 | + if (isset($lined['lat'])) { |
|
1994 | + $data['latitude'] = $lined['lat']; |
|
1995 | + } |
|
1996 | + if (isset($lined['lon'])) { |
|
1997 | + $data['longitude'] = $lined['lon']; |
|
1998 | + } |
|
1999 | + if (isset($lined['speed'])) { |
|
2000 | + $data['speed'] = $lined['speed']; |
|
2001 | + } |
|
2002 | + if (isset($lined['squawk'])) { |
|
2003 | + $data['squawk'] = $lined['squawk']; |
|
2004 | + } |
|
2005 | + if (isset($lined['alt'])) { |
|
2006 | + $data['altitude'] = $lined['alt']; |
|
2007 | + } |
|
2008 | + if (isset($lined['heading'])) { |
|
2009 | + $data['heading'] = $lined['heading']; |
|
2010 | + } |
|
1451 | 2011 | $data['id_source'] = $id_source; |
1452 | 2012 | $data['format_source'] = 'tsv'; |
1453 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1454 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1455 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1456 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2013 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2014 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2015 | + } |
|
2016 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2017 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2018 | + } |
|
2019 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2020 | + $data['noarchive'] = true; |
|
2021 | + } |
|
2022 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2023 | + $SI->add($data); |
|
2024 | + } |
|
1457 | 2025 | unset($lined); |
1458 | 2026 | unset($data); |
1459 | - } else $error = true; |
|
2027 | + } else { |
|
2028 | + $error = true; |
|
2029 | + } |
|
1460 | 2030 | } elseif ($format == 'aprs' && $use_aprs) { |
1461 | 2031 | if ($aprs_connect == 0) { |
1462 | 2032 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1481,62 +2051,120 @@ discard block |
||
1481 | 2051 | $aprs_last_tx = time(); |
1482 | 2052 | $data = array(); |
1483 | 2053 | //print_r($line); |
1484 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1485 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1486 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1487 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1488 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1489 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1490 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1491 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1492 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1493 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2054 | + if (isset($line['address'])) { |
|
2055 | + $data['hex'] = $line['address']; |
|
2056 | + } |
|
2057 | + if (isset($line['mmsi'])) { |
|
2058 | + $data['mmsi'] = $line['mmsi']; |
|
2059 | + } |
|
2060 | + if (isset($line['imo'])) { |
|
2061 | + $data['imo'] = $line['imo']; |
|
2062 | + } |
|
2063 | + if (isset($line['squawk'])) { |
|
2064 | + $data['squawk'] = $line['squawk']; |
|
2065 | + } |
|
2066 | + if (isset($line['arrival_code'])) { |
|
2067 | + $data['arrical_code'] = $line['arrival_code']; |
|
2068 | + } |
|
2069 | + if (isset($line['arrival_date'])) { |
|
2070 | + $data['arrical_date'] = $line['arrival_date']; |
|
2071 | + } |
|
2072 | + if (isset($line['type_id'])) { |
|
2073 | + $data['type_id'] = $line['typeid']; |
|
2074 | + } |
|
2075 | + if (isset($line['status_id'])) { |
|
2076 | + $data['status_id'] = $line['statusid']; |
|
2077 | + } |
|
2078 | + if (isset($line['timestamp'])) { |
|
2079 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2080 | + } else { |
|
2081 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2082 | + } |
|
1494 | 2083 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1495 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2084 | + if (isset($line['ident'])) { |
|
2085 | + $data['ident'] = $line['ident']; |
|
2086 | + } |
|
1496 | 2087 | $data['latitude'] = $line['latitude']; |
1497 | 2088 | $data['longitude'] = $line['longitude']; |
1498 | 2089 | //$data['verticalrate'] = $line[16]; |
1499 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2090 | + if (isset($line['speed'])) { |
|
2091 | + $data['speed'] = $line['speed']; |
|
2092 | + } |
|
1500 | 2093 | //else $data['speed'] = 0; |
1501 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1502 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1503 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2094 | + if (isset($line['altitude'])) { |
|
2095 | + $data['altitude'] = $line['altitude']; |
|
2096 | + } |
|
2097 | + if (isset($line['comment'])) { |
|
2098 | + $data['comment'] = $line['comment']; |
|
2099 | + } |
|
2100 | + if (isset($line['symbol'])) { |
|
2101 | + $data['type'] = $line['symbol']; |
|
2102 | + } |
|
1504 | 2103 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1505 | 2104 | |
1506 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2105 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2106 | + $data['heading'] = $line['heading']; |
|
2107 | + } |
|
1507 | 2108 | //else echo 'No heading...'."\n"; |
1508 | 2109 | //else $data['heading'] = 0; |
1509 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2110 | + if (isset($line['stealth'])) { |
|
2111 | + $data['aircraft_type'] = $line['stealth']; |
|
2112 | + } |
|
1510 | 2113 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1511 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1512 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1513 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1514 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2114 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2115 | + $data['noarchive'] = true; |
|
2116 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2117 | + $data['noarchive'] = false; |
|
2118 | + } |
|
2119 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2120 | + $data['noarchive'] = true; |
|
2121 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2122 | + $data['noarchive'] = false; |
|
2123 | + } |
|
1515 | 2124 | $data['id_source'] = $id_source; |
1516 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1517 | - else $data['format_source'] = 'aprs'; |
|
2125 | + if (isset($line['format_source'])) { |
|
2126 | + $data['format_source'] = $line['format_source']; |
|
2127 | + } else { |
|
2128 | + $data['format_source'] = 'aprs'; |
|
2129 | + } |
|
1518 | 2130 | $data['source_name'] = $line['source']; |
1519 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1520 | - else $data['source_type'] = 'flarm'; |
|
1521 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2131 | + if (isset($line['source_type'])) { |
|
2132 | + $data['source_type'] = $line['source_type']; |
|
2133 | + } else { |
|
2134 | + $data['source_type'] = 'flarm'; |
|
2135 | + } |
|
2136 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2137 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2138 | + } |
|
1522 | 2139 | $currentdate = date('Y-m-d H:i:s'); |
1523 | 2140 | $aprsdate = strtotime($data['datetime']); |
1524 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2141 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2142 | + $data['altitude_relative'] = 'AMSL'; |
|
2143 | + } |
|
1525 | 2144 | // Accept data if time <= system time + 20s |
1526 | 2145 | //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'])))) { |
1527 | 2146 | if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1528 | 2147 | $send = $SI->add($data); |
1529 | 2148 | } elseif ($data['source_type'] == 'ais') { |
1530 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2149 | + if (isset($globalMarine) && $globalMarine) { |
|
2150 | + $send = $MI->add($data); |
|
2151 | + } |
|
1531 | 2152 | } elseif (isset($line['stealth'])) { |
1532 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1533 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2153 | + if ($line['stealth'] != 0) { |
|
2154 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
2155 | + } else { |
|
2156 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2157 | + } |
|
1534 | 2158 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1535 | 2159 | //$line['symbol'] == 'Balloon' || |
1536 | 2160 | $line['symbol'] == 'Glider' || |
1537 | 2161 | $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
1538 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1539 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2162 | + if ($line['symbol'] == 'Ballon') { |
|
2163 | + $data['aircraft_icao'] = 'BALL'; |
|
2164 | + } |
|
2165 | + if ($line['symbol'] == 'Glider') { |
|
2166 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2167 | + } |
|
1540 | 2168 | $send = $SI->add($data); |
1541 | 2169 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1542 | 2170 | $line['symbol'] == 'Yacht (Sail)' || |
@@ -1567,9 +2195,13 @@ discard block |
||
1567 | 2195 | //} 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') { |
1568 | 2196 | // } 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') { |
1569 | 2197 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1570 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2198 | + if (isset($globalTracker) && $globalTracker) { |
|
2199 | + $send = $TI->add($data); |
|
2200 | + } |
|
1571 | 2201 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1572 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2202 | + if (!isset($data['altitude'])) { |
|
2203 | + $data['altitude'] = 0; |
|
2204 | + } |
|
1573 | 2205 | $Source->deleteOldLocationByType('gs'); |
1574 | 2206 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
1575 | 2207 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1578,7 +2210,9 @@ discard block |
||
1578 | 2210 | } |
1579 | 2211 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1580 | 2212 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1581 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2213 | + if ($globalDebug) { |
|
2214 | + echo '# Weather Station added'."\n"; |
|
2215 | + } |
|
1582 | 2216 | $Source->deleteOldLocationByType('wx'); |
1583 | 2217 | $weather_data = json_encode($line); |
1584 | 2218 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1588,7 +2222,9 @@ discard block |
||
1588 | 2222 | } |
1589 | 2223 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
1590 | 2224 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1591 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2225 | + if ($globalDebug) { |
|
2226 | + echo '☈ Lightning added'."\n"; |
|
2227 | + } |
|
1592 | 2228 | $Source->deleteOldLocationByType('lightning'); |
1593 | 2229 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
1594 | 2230 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1600,8 +2236,7 @@ discard block |
||
1600 | 2236 | print_r($line); |
1601 | 2237 | } |
1602 | 2238 | unset($data); |
1603 | - } |
|
1604 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2239 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1605 | 2240 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
1606 | 2241 | } |
1607 | 2242 | /* |
@@ -1610,7 +2245,9 @@ discard block |
||
1610 | 2245 | } |
1611 | 2246 | */ |
1612 | 2247 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1613 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2248 | + elseif ($line == true && $globalDebug) { |
|
2249 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2250 | + } |
|
1614 | 2251 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
1615 | 2252 | $Source->deleteOldLocationByType('lightning'); |
1616 | 2253 | $Source->deleteOldLocationByType('wx'); |
@@ -1646,26 +2283,45 @@ discard block |
||
1646 | 2283 | $data['ground'] = $line[21]; |
1647 | 2284 | $data['emergency'] = $line[19]; |
1648 | 2285 | $data['format_source'] = 'sbs'; |
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']; |
|
1651 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2286 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2287 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2288 | + } |
|
2289 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2290 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2291 | + } |
|
2292 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2293 | + $data['noarchive'] = true; |
|
2294 | + } |
|
1652 | 2295 | $data['id_source'] = $id_source; |
1653 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1654 | - else $error = true; |
|
2296 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2297 | + $send = $SI->add($data); |
|
2298 | + } else { |
|
2299 | + $error = true; |
|
2300 | + } |
|
1655 | 2301 | unset($data); |
1656 | - } else $error = true; |
|
2302 | + } else { |
|
2303 | + $error = true; |
|
2304 | + } |
|
1657 | 2305 | if ($error) { |
1658 | 2306 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1659 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2307 | + if ($globalDebug) { |
|
2308 | + echo "Not a message. Ignoring... \n"; |
|
2309 | + } |
|
1660 | 2310 | } else { |
1661 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2311 | + if ($globalDebug) { |
|
2312 | + echo "Wrong line format. Ignoring... \n"; |
|
2313 | + } |
|
1662 | 2314 | if ($globalDebug) { |
1663 | 2315 | echo $buffer; |
1664 | 2316 | //print_r($line); |
1665 | 2317 | } |
1666 | 2318 | //socket_close($r); |
1667 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1668 | - if ($format == 'aprs') $aprs_connect = 0; |
|
2319 | + if ($globalDebug) { |
|
2320 | + echo "Reconnect after an error...\n"; |
|
2321 | + } |
|
2322 | + if ($format == 'aprs') { |
|
2323 | + $aprs_connect = 0; |
|
2324 | + } |
|
1669 | 2325 | $sourceer[$nb] = $globalSources[$nb]; |
1670 | 2326 | connect_all($sourceer); |
1671 | 2327 | $sourceer = array(); |
@@ -1673,10 +2329,14 @@ discard block |
||
1673 | 2329 | } |
1674 | 2330 | } |
1675 | 2331 | // Sleep for xxx microseconds |
1676 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2332 | + if (isset($globalSBSSleep)) { |
|
2333 | + usleep($globalSBSSleep); |
|
2334 | + } |
|
1677 | 2335 | } else { |
1678 | 2336 | if ($format == 'flightgearmp') { |
1679 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2337 | + if ($globalDebug) { |
|
2338 | + echo "Reconnect FlightGear MP..."; |
|
2339 | + } |
|
1680 | 2340 | //@socket_close($r); |
1681 | 2341 | sleep($globalMinFetch); |
1682 | 2342 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1685,10 +2345,15 @@ discard block |
||
1685 | 2345 | break; |
1686 | 2346 | |
1687 | 2347 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1688 | - if (isset($tt[$format])) $tt[$format]++; |
|
1689 | - else $tt[$format] = 0; |
|
2348 | + if (isset($tt[$format])) { |
|
2349 | + $tt[$format]++; |
|
2350 | + } else { |
|
2351 | + $tt[$format] = 0; |
|
2352 | + } |
|
1690 | 2353 | if ($tt[$format] > 30) { |
1691 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2354 | + if ($globalDebug) { |
|
2355 | + echo "ERROR : Reconnect ".$format."..."; |
|
2356 | + } |
|
1692 | 2357 | //@socket_close($r); |
1693 | 2358 | sleep(2); |
1694 | 2359 | $aprs_connect = 0; |
@@ -1705,11 +2370,17 @@ discard block |
||
1705 | 2370 | } else { |
1706 | 2371 | $error = socket_strerror(socket_last_error()); |
1707 | 2372 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1708 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1709 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2373 | + if ($globalDebug) { |
|
2374 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2375 | + } |
|
2376 | + if (isset($globalDebug)) { |
|
2377 | + echo "Restarting...\n"; |
|
2378 | + } |
|
1710 | 2379 | // Restart the script if possible |
1711 | 2380 | if (is_array($sockets)) { |
1712 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2381 | + if ($globalDebug) { |
|
2382 | + echo "Shutdown all sockets..."; |
|
2383 | + } |
|
1713 | 2384 | |
1714 | 2385 | foreach ($sockets as $sock) { |
1715 | 2386 | @socket_shutdown($sock,2); |
@@ -1717,25 +2388,45 @@ discard block |
||
1717 | 2388 | } |
1718 | 2389 | |
1719 | 2390 | } |
1720 | - if ($globalDebug) echo "Waiting..."; |
|
2391 | + if ($globalDebug) { |
|
2392 | + echo "Waiting..."; |
|
2393 | + } |
|
1721 | 2394 | sleep(2); |
1722 | 2395 | $time = time(); |
1723 | 2396 | //connect_all($hosts); |
1724 | 2397 | $aprs_connect = 0; |
1725 | - if ($reset%5 == 0) sleep(20); |
|
1726 | - if ($reset%10 == 0) sleep(100); |
|
1727 | - if ($reset%20 == 0) sleep(200); |
|
1728 | - if ($reset > 100) exit('Too many attempts...'); |
|
1729 | - if ($globalDebug) echo "Restart all connections..."; |
|
2398 | + if ($reset%5 == 0) { |
|
2399 | + sleep(20); |
|
2400 | + } |
|
2401 | + if ($reset%10 == 0) { |
|
2402 | + sleep(100); |
|
2403 | + } |
|
2404 | + if ($reset%20 == 0) { |
|
2405 | + sleep(200); |
|
2406 | + } |
|
2407 | + if ($reset > 100) { |
|
2408 | + exit('Too many attempts...'); |
|
2409 | + } |
|
2410 | + if ($globalDebug) { |
|
2411 | + echo "Restart all connections..."; |
|
2412 | + } |
|
1730 | 2413 | connect_all($globalSources); |
1731 | 2414 | } |
1732 | 2415 | } |
1733 | 2416 | } |
1734 | 2417 | if ($globalDaemon === false) { |
1735 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1736 | - if (isset($SI)) $SI->checkAll(); |
|
1737 | - if (isset($TI)) $TI->checkAll(); |
|
1738 | - if (isset($MI)) $MI->checkAll(); |
|
2418 | + if ($globalDebug) { |
|
2419 | + echo 'Check all...'."\n"; |
|
2420 | + } |
|
2421 | + if (isset($SI)) { |
|
2422 | + $SI->checkAll(); |
|
2423 | + } |
|
2424 | + if (isset($TI)) { |
|
2425 | + $TI->checkAll(); |
|
2426 | + } |
|
2427 | + if (isset($MI)) { |
|
2428 | + $MI->checkAll(); |
|
2429 | + } |
|
1739 | 2430 | } |
1740 | 2431 | } |
1741 | 2432 | } |