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