@@ -14,13 +14,17 @@ discard block |
||
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
17 | +if (isset($globalTracker) && $globalTracker) { |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | +} |
|
18 | 20 | if (isset($globalMarine) && $globalMarine) { |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
21 | 23 | } |
22 | 24 | |
23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
24 | 28 | |
25 | 29 | // Check if schema is at latest version |
26 | 30 | $Connection = new Connection(); |
@@ -59,66 +63,107 @@ discard block |
||
59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 64 | if (isset($options['s'])) { |
61 | 65 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
64 | -} elseif (isset($options['source'])) { |
|
66 | + if (isset($options['format'])) { |
|
67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
68 | + } else { |
|
69 | + $globalSources[] = array('host' => $options['s']); |
|
70 | + } |
|
71 | + } elseif (isset($options['source'])) { |
|
65 | 72 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
68 | -} |
|
73 | + if (isset($options['format'])) { |
|
74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
75 | + } else { |
|
76 | + $globalSources[] = array('host' => $options['source']); |
|
77 | + } |
|
78 | + } |
|
69 | 79 | if (isset($options['aprsserverhost'])) { |
70 | 80 | $globalServerAPRS = TRUE; |
71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
72 | 82 | } |
73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
83 | +if (isset($options['aprsserverport'])) { |
|
84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
85 | +} |
|
86 | +if (isset($options['aprsserverssid'])) { |
|
87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
88 | +} |
|
89 | +if (isset($options['aprsserverpass'])) { |
|
90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
91 | +} |
|
92 | +if (isset($options['noaprsserver'])) { |
|
93 | + $globalServerAPRS = FALSE; |
|
94 | +} |
|
77 | 95 | if (isset($options['enable-aircraft'])) { |
78 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
96 | + if ($globalDebug) { |
|
97 | + echo 'Enable Aircraft mode'."\n"; |
|
98 | + } |
|
79 | 99 | $globalAircraft = TRUE; |
80 | 100 | } |
81 | 101 | if (isset($options['disable-aircraft'])) { |
82 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
102 | + if ($globalDebug) { |
|
103 | + echo 'Disable Aircraft mode'."\n"; |
|
104 | + } |
|
83 | 105 | $globalAircraft = FALSE; |
84 | 106 | } |
85 | 107 | if (isset($options['enable-tracker'])) { |
86 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
108 | + if ($globalDebug) { |
|
109 | + echo 'Enable Tracker mode'."\n"; |
|
110 | + } |
|
87 | 111 | $globalTracker = TRUE; |
88 | 112 | } |
89 | 113 | if (isset($options['disable-tracker'])) { |
90 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
114 | + if ($globalDebug) { |
|
115 | + echo 'Disable Tracker mode'."\n"; |
|
116 | + } |
|
91 | 117 | $globalTracker = FALSE; |
92 | 118 | } |
93 | 119 | if (isset($options['enable-marine'])) { |
94 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
120 | + if ($globalDebug) { |
|
121 | + echo 'Enable Marine mode'."\n"; |
|
122 | + } |
|
95 | 123 | $globalMarine = TRUE; |
96 | 124 | } |
97 | 125 | if (isset($options['disable-marine'])) { |
98 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
126 | + if ($globalDebug) { |
|
127 | + echo 'Disable Marine mode'."\n"; |
|
128 | + } |
|
99 | 129 | $globalMarine = FALSE; |
100 | 130 | } |
101 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
102 | -if (isset($options['server'])) $globalServer = TRUE; |
|
103 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
104 | -else $id_source = 1; |
|
131 | +if (isset($options['nodaemon'])) { |
|
132 | + $globalDaemon = FALSE; |
|
133 | +} |
|
134 | +if (isset($options['server'])) { |
|
135 | + $globalServer = TRUE; |
|
136 | +} |
|
137 | +if (isset($options['idsource'])) { |
|
138 | + $id_source = $options['idsource']; |
|
139 | +} else { |
|
140 | + $id_source = 1; |
|
141 | +} |
|
105 | 142 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
143 | + if ($globalDebug) { |
|
144 | + echo "Using Server Mode\n"; |
|
145 | + } |
|
107 | 146 | $SI=new SpotterServer(); |
108 | 147 | /* |
109 | 148 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 149 | $SI = new adsb2aprs(); |
111 | 150 | $SI->connect(); |
112 | 151 | */ |
113 | -} else $SI=new SpotterImport($Connection->db); |
|
152 | +} else { |
|
153 | + $SI=new SpotterImport($Connection->db); |
|
154 | +} |
|
114 | 155 | |
115 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
156 | +if (isset($globalTracker) && $globalTracker) { |
|
157 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
158 | +} |
|
116 | 159 | if (isset($globalMarine) && $globalMarine) { |
117 | 160 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
118 | 161 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
119 | 162 | } |
120 | 163 | |
121 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
164 | +if (isset($globalTracker) && $globalTracker) { |
|
165 | + $TI = new TrackerImport($Connection->db); |
|
166 | +} |
|
122 | 167 | if (isset($globalMarine) && $globalMarine) { |
123 | 168 | $AIS = new AIS(); |
124 | 169 | $MI = new MarineImport($Connection->db); |
@@ -143,7 +188,9 @@ discard block |
||
143 | 188 | } |
144 | 189 | |
145 | 190 | // let's try and connect |
146 | -if ($globalDebug) echo "Connecting...\n"; |
|
191 | +if ($globalDebug) { |
|
192 | + echo "Connecting...\n"; |
|
193 | +} |
|
147 | 194 | $use_aprs = false; |
148 | 195 | $aprs_full = false; |
149 | 196 | $reset = 0; |
@@ -152,7 +199,9 @@ discard block |
||
152 | 199 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
153 | 200 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
154 | 201 | $reset++; |
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
202 | + if ($globalDebug) { |
|
203 | + echo 'Connect to all...'."\n"; |
|
204 | + } |
|
156 | 205 | foreach ($hosts as $id => $value) { |
157 | 206 | $host = $value['host']; |
158 | 207 | $globalSources[$id]['last_exec'] = 0; |
@@ -162,32 +211,44 @@ discard block |
||
162 | 211 | //$formats[$id] = 'deltadbtxt'; |
163 | 212 | $globalSources[$id]['format'] = 'deltadbtxt'; |
164 | 213 | //$last_exec['deltadbtxt'] = 0; |
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
216 | + } |
|
166 | 217 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
167 | 218 | //$formats[$id] = 'vatsimtxt'; |
168 | 219 | $globalSources[$id]['format'] = 'vatsimtxt'; |
169 | 220 | //$last_exec['vatsimtxt'] = 0; |
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
221 | + if ($globalDebug) { |
|
222 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
223 | + } |
|
171 | 224 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
172 | 225 | //$formats[$id] = 'aircraftlistjson'; |
173 | 226 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
174 | 227 | //$last_exec['aircraftlistjson'] = 0; |
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
228 | + if ($globalDebug) { |
|
229 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
230 | + } |
|
176 | 231 | } else if (preg_match('/aircraft.json$/i',$host)) { |
177 | 232 | //$formats[$id] = 'aircraftjson'; |
178 | 233 | $globalSources[$id]['format'] = 'aircraftjson'; |
179 | 234 | //$last_exec['aircraftlistjson'] = 0; |
180 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
235 | + if ($globalDebug) { |
|
236 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
237 | + } |
|
181 | 238 | } else if (preg_match('/aircraft$/i',$host)) { |
182 | 239 | //$formats[$id] = 'planefinderclient'; |
183 | 240 | $globalSources[$id]['format'] = 'planefinderclient'; |
184 | 241 | //$last_exec['aircraftlistjson'] = 0; |
185 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
244 | + } |
|
186 | 245 | } else if (preg_match('/opensky/i',$host)) { |
187 | 246 | //$formats[$id] = 'aircraftlistjson'; |
188 | 247 | $globalSources[$id]['format'] = 'opensky'; |
189 | 248 | //$last_exec['aircraftlistjson'] = 0; |
190 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
249 | + if ($globalDebug) { |
|
250 | + echo "Connect to opensky source (".$host.")...\n"; |
|
251 | + } |
|
191 | 252 | /* |
192 | 253 | // Disabled for now, site change source format |
193 | 254 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -204,7 +265,9 @@ discard block |
||
204 | 265 | //$formats[$id] = 'planeupdatefaa'; |
205 | 266 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
206 | 267 | //$last_exec['planeupdatefaa'] = 0; |
207 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
268 | + if ($globalDebug) { |
|
269 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
270 | + } |
|
208 | 271 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
209 | 272 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
210 | 273 | exit(0); |
@@ -213,37 +276,53 @@ discard block |
||
213 | 276 | //$formats[$id] = 'phpvmacars'; |
214 | 277 | $globalSources[$id]['format'] = 'phpvmacars'; |
215 | 278 | //$last_exec['phpvmacars'] = 0; |
216 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
279 | + if ($globalDebug) { |
|
280 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
281 | + } |
|
217 | 282 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
218 | 283 | //$formats[$id] = 'phpvmacars'; |
219 | 284 | $globalSources[$id]['format'] = 'vaos'; |
220 | 285 | //$last_exec['phpvmacars'] = 0; |
221 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
286 | + if ($globalDebug) { |
|
287 | + echo "Connect to vaos source (".$host.")...\n"; |
|
288 | + } |
|
222 | 289 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
223 | 290 | //$formats[$id] = 'phpvmacars'; |
224 | 291 | $globalSources[$id]['format'] = 'vam'; |
225 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
292 | + if ($globalDebug) { |
|
293 | + echo "Connect to Vam source (".$host.")...\n"; |
|
294 | + } |
|
226 | 295 | } else if (preg_match('/whazzup/i',$host)) { |
227 | 296 | //$formats[$id] = 'whazzup'; |
228 | 297 | $globalSources[$id]['format'] = 'whazzup'; |
229 | 298 | //$last_exec['whazzup'] = 0; |
230 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
299 | + if ($globalDebug) { |
|
300 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
301 | + } |
|
231 | 302 | } else if (preg_match('/blitzortung/i',$host)) { |
232 | 303 | $globalSources[$id]['format'] = 'blitzortung'; |
233 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
304 | + if ($globalDebug) { |
|
305 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
306 | + } |
|
234 | 307 | } else if (preg_match('/airwhere/i',$host)) { |
235 | 308 | $globalSources[$id]['format'] = 'airwhere'; |
236 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
309 | + if ($globalDebug) { |
|
310 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
311 | + } |
|
237 | 312 | } else if (preg_match('/recentpireps/i',$host)) { |
238 | 313 | //$formats[$id] = 'pirepsjson'; |
239 | 314 | $globalSources[$id]['format'] = 'pirepsjson'; |
240 | 315 | //$last_exec['pirepsjson'] = 0; |
241 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
316 | + if ($globalDebug) { |
|
317 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
318 | + } |
|
242 | 319 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
243 | 320 | //$formats[$id] = 'fr24json'; |
244 | 321 | $globalSources[$id]['format'] = 'fr24json'; |
245 | 322 | //$last_exec['fr24json'] = 0; |
246 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
323 | + if ($globalDebug) { |
|
324 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
325 | + } |
|
247 | 326 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
248 | 327 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
249 | 328 | exit(0); |
@@ -252,7 +331,9 @@ discard block |
||
252 | 331 | //$formats[$id] = 'fr24json'; |
253 | 332 | $globalSources[$id]['format'] = 'myshiptracking'; |
254 | 333 | //$last_exec['fr24json'] = 0; |
255 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
334 | + if ($globalDebug) { |
|
335 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
336 | + } |
|
256 | 337 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
257 | 338 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
258 | 339 | exit(0); |
@@ -261,16 +342,24 @@ discard block |
||
261 | 342 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
262 | 343 | //$formats[$id] = 'tsv'; |
263 | 344 | $globalSources[$id]['format'] = 'tsv'; |
264 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
345 | + if ($globalDebug) { |
|
346 | + echo "Connect to tsv source (".$host.")...\n"; |
|
347 | + } |
|
265 | 348 | } |
266 | 349 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
267 | 350 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
268 | 351 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
269 | 352 | if ($idf !== false) { |
270 | 353 | $httpfeeds[$id] = $idf; |
271 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
272 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
273 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
354 | + if ($globalDebug) { |
|
355 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
356 | + } |
|
357 | + } elseif ($globalDebug) { |
|
358 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
359 | + } |
|
360 | + } elseif ($globalDebug) { |
|
361 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
362 | + } |
|
274 | 363 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
275 | 364 | $hostport = explode(':',$host); |
276 | 365 | if (isset($hostport[1])) { |
@@ -310,19 +399,27 @@ discard block |
||
310 | 399 | //$formats[$id] = 'beast'; |
311 | 400 | $globalSources[$id]['format'] = 'beast'; |
312 | 401 | //} else $formats[$id] = 'sbs'; |
313 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
402 | + } else { |
|
403 | + $globalSources[$id]['format'] = 'sbs'; |
|
404 | + } |
|
314 | 405 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
315 | 406 | } |
316 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
407 | + if ($globalDebug) { |
|
408 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
409 | + } |
|
317 | 410 | } else { |
318 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
411 | + if ($globalDebug) { |
|
412 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
413 | + } |
|
319 | 414 | sleep(10); |
320 | 415 | connect_all($hosts); |
321 | 416 | } |
322 | 417 | } |
323 | 418 | } |
324 | 419 | } |
325 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
420 | +if (!isset($globalMinFetch)) { |
|
421 | + $globalMinFetch = 15; |
|
422 | +} |
|
326 | 423 | |
327 | 424 | // Initialize all |
328 | 425 | $status = array(); |
@@ -331,13 +428,19 @@ discard block |
||
331 | 428 | $formats = array(); |
332 | 429 | $last_exec = array(); |
333 | 430 | $time = time(); |
334 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
335 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
336 | -else $timeout = 20; |
|
431 | +if (isset($globalSourcesTimeout)) { |
|
432 | + $timeout = $globalSourcesTimeOut; |
|
433 | +} else if (isset($globalSBS1TimeOut)) { |
|
434 | + $timeout = $globalSBS1TimeOut; |
|
435 | +} else { |
|
436 | + $timeout = 20; |
|
437 | +} |
|
337 | 438 | $errno = ''; |
338 | 439 | $errstr=''; |
339 | 440 | |
340 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
441 | +if (!isset($globalDaemon)) { |
|
442 | + $globalDaemon = TRUE; |
|
443 | +} |
|
341 | 444 | /* Initiate connections to all the hosts simultaneously */ |
342 | 445 | //connect_all($hosts); |
343 | 446 | //connect_all($globalSources); |
@@ -366,7 +469,9 @@ discard block |
||
366 | 469 | if (isset($source['format']) && $source['format'] == 'aprs') { |
367 | 470 | $aprs_connect = 0; |
368 | 471 | $use_aprs = true; |
369 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
472 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
473 | + $aprs_full = true; |
|
474 | + } |
|
370 | 475 | break; |
371 | 476 | } |
372 | 477 | } |
@@ -377,25 +482,46 @@ discard block |
||
377 | 482 | $aprs_connect = 0; |
378 | 483 | $aprs_keep = 120; |
379 | 484 | $aprs_last_tx = time(); |
380 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
381 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
382 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
383 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
384 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
385 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
386 | - if ($aprs_full) $aprs_filter = ''; |
|
387 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
388 | - else $aprs_pass = '-1'; |
|
485 | + if (isset($globalAPRSversion)) { |
|
486 | + $aprs_version = $globalAPRSversion; |
|
487 | + } else { |
|
488 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
489 | + } |
|
490 | + if (isset($globalAPRSssid)) { |
|
491 | + $aprs_ssid = $globalAPRSssid; |
|
492 | + } else { |
|
493 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
494 | + } |
|
495 | + if (isset($globalAPRSfilter)) { |
|
496 | + $aprs_filter = $globalAPRSfilter; |
|
497 | + } else { |
|
498 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
499 | + } |
|
500 | + if ($aprs_full) { |
|
501 | + $aprs_filter = ''; |
|
502 | + } |
|
503 | + if (isset($globalAPRSpass)) { |
|
504 | + $aprs_pass = $globalAPRSpass; |
|
505 | + } else { |
|
506 | + $aprs_pass = '-1'; |
|
507 | + } |
|
389 | 508 | |
390 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
391 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
392 | -} |
|
509 | + if ($aprs_filter != '') { |
|
510 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
511 | + } else { |
|
512 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
513 | + } |
|
514 | + } |
|
393 | 515 | |
394 | 516 | // connected - lets do some work |
395 | 517 | //if ($globalDebug) echo "Connected!\n"; |
396 | 518 | sleep(1); |
397 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
398 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
519 | +if ($globalDebug) { |
|
520 | + echo "SCAN MODE \n\n"; |
|
521 | +} |
|
522 | +if (!isset($globalCronEnd)) { |
|
523 | + $globalCronEnd = 60; |
|
524 | +} |
|
399 | 525 | $endtime = time()+$globalCronEnd; |
400 | 526 | $i = 1; |
401 | 527 | $tt = array(); |
@@ -409,22 +535,32 @@ discard block |
||
409 | 535 | |
410 | 536 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
411 | 537 | while ($i > 0) { |
412 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
538 | + if (function_exists('pcntl_fork')) { |
|
539 | + pcntl_signal_dispatch(); |
|
540 | + } |
|
413 | 541 | |
414 | - if (!$globalDaemon) $i = $endtime-time(); |
|
542 | + if (!$globalDaemon) { |
|
543 | + $i = $endtime-time(); |
|
544 | + } |
|
415 | 545 | // Delete old ATC |
416 | 546 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
417 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
547 | + if ($globalDebug) { |
|
548 | + echo 'Delete old ATC...'."\n"; |
|
549 | + } |
|
418 | 550 | $ATC->deleteOldATC(); |
419 | 551 | } |
420 | 552 | |
421 | 553 | if (count($last_exec) == count($globalSources)) { |
422 | 554 | $max = $globalMinFetch; |
423 | 555 | foreach ($last_exec as $last) { |
424 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
556 | + if ((time() - $last['last']) < $max) { |
|
557 | + $max = time() - $last['last']; |
|
558 | + } |
|
425 | 559 | } |
426 | 560 | if ($max < $globalMinFetch) { |
427 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
561 | + if ($globalDebug) { |
|
562 | + echo 'Sleeping...'."\n"; |
|
563 | + } |
|
428 | 564 | sleep($globalMinFetch-$max+2); |
429 | 565 | } |
430 | 566 | } |
@@ -434,7 +570,9 @@ discard block |
||
434 | 570 | foreach ($globalSources as $id => $value) { |
435 | 571 | date_default_timezone_set('UTC'); |
436 | 572 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
437 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
573 | + if (!isset($last_exec[$id]['last'])) { |
|
574 | + $last_exec[$id]['last'] = 0; |
|
575 | + } |
|
438 | 576 | if ($value['format'] === 'deltadbtxt' && |
439 | 577 | ( |
440 | 578 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -443,7 +581,9 @@ discard block |
||
443 | 581 | ) { |
444 | 582 | //$buffer = $Common->getData($hosts[$id]); |
445 | 583 | $buffer = $Common->getData($value['host']); |
446 | - if ($buffer != '') $reset = 0; |
|
584 | + if ($buffer != '') { |
|
585 | + $reset = 0; |
|
586 | + } |
|
447 | 587 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
448 | 588 | $buffer = explode('\n',$buffer); |
449 | 589 | foreach ($buffer as $line) { |
@@ -452,20 +592,41 @@ discard block |
||
452 | 592 | $data = array(); |
453 | 593 | $data['hex'] = $line[1]; // hex |
454 | 594 | $data['ident'] = $line[2]; // ident |
455 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
456 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
457 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
458 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
459 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
595 | + if (isset($line[3])) { |
|
596 | + $data['altitude'] = $line[3]; |
|
597 | + } |
|
598 | + // altitude |
|
599 | + if (isset($line[4])) { |
|
600 | + $data['speed'] = $line[4]; |
|
601 | + } |
|
602 | + // speed |
|
603 | + if (isset($line[5])) { |
|
604 | + $data['heading'] = $line[5]; |
|
605 | + } |
|
606 | + // heading |
|
607 | + if (isset($line[6])) { |
|
608 | + $data['latitude'] = $line[6]; |
|
609 | + } |
|
610 | + // lat |
|
611 | + if (isset($line[7])) { |
|
612 | + $data['longitude'] = $line[7]; |
|
613 | + } |
|
614 | + // long |
|
460 | 615 | $data['verticalrate'] = ''; // vertical rate |
461 | 616 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
462 | 617 | $data['emergency'] = ''; // emergency |
463 | 618 | $data['datetime'] = date('Y-m-d H:i:s'); |
464 | 619 | $data['format_source'] = 'deltadbtxt'; |
465 | 620 | $data['id_source'] = $id_source; |
466 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
467 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
468 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
621 | + if (isset($value['name']) && $value['name'] != '') { |
|
622 | + $data['source_name'] = $value['name']; |
|
623 | + } |
|
624 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
625 | + $data['noarchive'] = true; |
|
626 | + } |
|
627 | + if (isset($value['sourcestats'])) { |
|
628 | + $data['sourcestats'] = $value['sourcestats']; |
|
629 | + } |
|
469 | 630 | $SI->add($data); |
470 | 631 | unset($data); |
471 | 632 | } |
@@ -480,7 +641,9 @@ discard block |
||
480 | 641 | date_default_timezone_set('CET'); |
481 | 642 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
482 | 643 | date_default_timezone_set('UTC'); |
483 | - if ($buffer != '') $reset = 0; |
|
644 | + if ($buffer != '') { |
|
645 | + $reset = 0; |
|
646 | + } |
|
484 | 647 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
485 | 648 | $buffer = explode('\n',$buffer); |
486 | 649 | foreach ($buffer as $line) { |
@@ -489,18 +652,42 @@ discard block |
||
489 | 652 | $add = false; |
490 | 653 | $ais_data = $AIS->parse_line(trim($line)); |
491 | 654 | $data = array(); |
492 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
493 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
494 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
495 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
496 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
497 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
498 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
499 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
500 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
501 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
502 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
503 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
655 | + if (isset($ais_data['ident'])) { |
|
656 | + $data['ident'] = $ais_data['ident']; |
|
657 | + } |
|
658 | + if (isset($ais_data['mmsi'])) { |
|
659 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
660 | + } |
|
661 | + if (isset($ais_data['speed'])) { |
|
662 | + $data['speed'] = $ais_data['speed']; |
|
663 | + } |
|
664 | + if (isset($ais_data['heading'])) { |
|
665 | + $data['heading'] = $ais_data['heading']; |
|
666 | + } |
|
667 | + if (isset($ais_data['latitude'])) { |
|
668 | + $data['latitude'] = $ais_data['latitude']; |
|
669 | + } |
|
670 | + if (isset($ais_data['longitude'])) { |
|
671 | + $data['longitude'] = $ais_data['longitude']; |
|
672 | + } |
|
673 | + if (isset($ais_data['status'])) { |
|
674 | + $data['status'] = $ais_data['status']; |
|
675 | + } |
|
676 | + if (isset($ais_data['statusid'])) { |
|
677 | + $data['status_id'] = $ais_data['statusid']; |
|
678 | + } |
|
679 | + if (isset($ais_data['type'])) { |
|
680 | + $data['type'] = $ais_data['type']; |
|
681 | + } |
|
682 | + if (isset($ais_data['typeid'])) { |
|
683 | + $data['type_id'] = $ais_data['typeid']; |
|
684 | + } |
|
685 | + if (isset($ais_data['imo'])) { |
|
686 | + $data['imo'] = $ais_data['imo']; |
|
687 | + } |
|
688 | + if (isset($ais_data['callsign'])) { |
|
689 | + $data['callsign'] = $ais_data['callsign']; |
|
690 | + } |
|
504 | 691 | if (isset($ais_data['timestamp'])) { |
505 | 692 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
506 | 693 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -514,8 +701,12 @@ discard block |
||
514 | 701 | $data['format_source'] = 'aisnmeatxt'; |
515 | 702 | $data['id_source'] = $id_source; |
516 | 703 | //print_r($data); |
517 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
518 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
704 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
705 | + $data['noarchive'] = true; |
|
706 | + } |
|
707 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
708 | + $MI->add($data); |
|
709 | + } |
|
519 | 710 | unset($data); |
520 | 711 | } |
521 | 712 | } |
@@ -538,20 +729,48 @@ discard block |
||
538 | 729 | if ($line != '') { |
539 | 730 | $ais_data = $AIS->parse_line(trim($line)); |
540 | 731 | $data = array(); |
541 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
542 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
543 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
544 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
545 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
546 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
547 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
548 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
549 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
550 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
551 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
552 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
553 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
554 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
732 | + if (isset($ais_data['ident'])) { |
|
733 | + $data['ident'] = $ais_data['ident']; |
|
734 | + } |
|
735 | + if (isset($ais_data['mmsi'])) { |
|
736 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
737 | + } |
|
738 | + if (isset($ais_data['speed'])) { |
|
739 | + $data['speed'] = $ais_data['speed']; |
|
740 | + } |
|
741 | + if (isset($ais_data['heading'])) { |
|
742 | + $data['heading'] = $ais_data['heading']; |
|
743 | + } |
|
744 | + if (isset($ais_data['latitude'])) { |
|
745 | + $data['latitude'] = $ais_data['latitude']; |
|
746 | + } |
|
747 | + if (isset($ais_data['longitude'])) { |
|
748 | + $data['longitude'] = $ais_data['longitude']; |
|
749 | + } |
|
750 | + if (isset($ais_data['status'])) { |
|
751 | + $data['status'] = $ais_data['status']; |
|
752 | + } |
|
753 | + if (isset($ais_data['statusid'])) { |
|
754 | + $data['status_id'] = $ais_data['statusid']; |
|
755 | + } |
|
756 | + if (isset($ais_data['type'])) { |
|
757 | + $data['type'] = $ais_data['type']; |
|
758 | + } |
|
759 | + if (isset($ais_data['typeid'])) { |
|
760 | + $data['type_id'] = $ais_data['typeid']; |
|
761 | + } |
|
762 | + if (isset($ais_data['imo'])) { |
|
763 | + $data['imo'] = $ais_data['imo']; |
|
764 | + } |
|
765 | + if (isset($ais_data['callsign'])) { |
|
766 | + $data['callsign'] = $ais_data['callsign']; |
|
767 | + } |
|
768 | + if (isset($ais_data['destination'])) { |
|
769 | + $data['arrival_code'] = $ais_data['destination']; |
|
770 | + } |
|
771 | + if (isset($ais_data['eta_ts'])) { |
|
772 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
773 | + } |
|
555 | 774 | if (isset($ais_data['timestamp'])) { |
556 | 775 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
557 | 776 | } else { |
@@ -559,18 +778,27 @@ discard block |
||
559 | 778 | } |
560 | 779 | $data['format_source'] = 'aisnmeahttp'; |
561 | 780 | $data['id_source'] = $id_source; |
562 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
563 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
781 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
782 | + $data['noarchive'] = true; |
|
783 | + } |
|
784 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
785 | + $MI->add($data); |
|
786 | + } |
|
564 | 787 | unset($data); |
565 | 788 | } |
566 | 789 | } |
567 | 790 | } |
568 | 791 | } else { |
569 | 792 | $format = $value['format']; |
570 | - if (isset($tt[$format])) $tt[$format]++; |
|
571 | - else $tt[$format] = 0; |
|
793 | + if (isset($tt[$format])) { |
|
794 | + $tt[$format]++; |
|
795 | + } else { |
|
796 | + $tt[$format] = 0; |
|
797 | + } |
|
572 | 798 | if ($tt[$format] > 30) { |
573 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
799 | + if ($globalDebug) { |
|
800 | + echo 'Reconnect...'."\n"; |
|
801 | + } |
|
574 | 802 | sleep(2); |
575 | 803 | //$sourceeen[] = $value; |
576 | 804 | //connect_all($sourceeen); |
@@ -606,12 +834,18 @@ discard block |
||
606 | 834 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
607 | 835 | //$data['type_id'] = $line['TYPE']; |
608 | 836 | $data['imo'] = $line['IMO']; |
609 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
610 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
837 | + if ($line['DEST'] != '') { |
|
838 | + $data['arrival_code'] = $line['DEST']; |
|
839 | + } |
|
840 | + if ($line['ARV'] != '') { |
|
841 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
842 | + } |
|
611 | 843 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
612 | 844 | $data['format_source'] = 'myshiptracking'; |
613 | 845 | $data['id_source'] = $id_source; |
614 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
846 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
847 | + $data['noarchive'] = true; |
|
848 | + } |
|
615 | 849 | $MI->add($data); |
616 | 850 | unset($data); |
617 | 851 | } |
@@ -636,7 +870,9 @@ discard block |
||
636 | 870 | $data['callsign'] = $line['callsign']; |
637 | 871 | $data['mmsi'] = substr($line['mmsi'],-9); |
638 | 872 | $data['speed'] = $line['sog']; |
639 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
873 | + if ($line['heading'] != '511') { |
|
874 | + $data['heading'] = $line['heading']; |
|
875 | + } |
|
640 | 876 | $data['latitude'] = $line['latitude']; |
641 | 877 | $data['longitude'] = $line['longitude']; |
642 | 878 | $data['type_id'] = $line['shiptype']; |
@@ -644,7 +880,9 @@ discard block |
||
644 | 880 | $data['datetime'] = $line['time']; |
645 | 881 | $data['format_source'] = 'boatbeaconapp'; |
646 | 882 | $data['id_source'] = $id_source; |
647 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
883 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
884 | + $data['noarchive'] = true; |
|
885 | + } |
|
648 | 886 | $MI->add($data); |
649 | 887 | unset($data); |
650 | 888 | } |
@@ -666,22 +904,44 @@ discard block |
||
666 | 904 | foreach ($all_data['features'] as $line) { |
667 | 905 | print_r($line); |
668 | 906 | $data = array(); |
669 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
670 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
671 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
672 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
673 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
674 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
907 | + if (isset($line['properties']['name'])) { |
|
908 | + $data['ident'] = $line['properties']['name']; |
|
909 | + } |
|
910 | + if (isset($line['properties']['callsign'])) { |
|
911 | + $data['callsign'] = $line['properties']['callsign']; |
|
912 | + } |
|
913 | + if (isset($line['properties']['mmsi'])) { |
|
914 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
915 | + } |
|
916 | + if (isset($line['properties']['imo'])) { |
|
917 | + $data['imo'] = $line['properties']['imo']; |
|
918 | + } |
|
919 | + if (isset($line['properties']['speed'])) { |
|
920 | + $data['speed'] = $line['properties']['speed']; |
|
921 | + } |
|
922 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
923 | + $data['heading'] = $line['properties']['heading']; |
|
924 | + } |
|
675 | 925 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
676 | 926 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
677 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
678 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
679 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
927 | + if (isset($line['properties']['vesselType'])) { |
|
928 | + $data['type'] = $line['properties']['vesselType']; |
|
929 | + } |
|
930 | + if (isset($line['properties']['destination'])) { |
|
931 | + $data['arrival_code'] = $line['properties']['destination']; |
|
932 | + } |
|
933 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
934 | + $data['arrival_date'] = $line['properties']['eta']; |
|
935 | + } |
|
680 | 936 | $data['format_source'] = 'boatnerd'; |
681 | 937 | $data['id_source'] = $id_source; |
682 | 938 | $data['datetime'] = date('Y-m-d H:i:s'); |
683 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
684 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
939 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
940 | + $data['noarchive'] = true; |
|
941 | + } |
|
942 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
943 | + $MI->add($data); |
|
944 | + } |
|
685 | 945 | unset($data); |
686 | 946 | } |
687 | 947 | } |
@@ -698,7 +958,9 @@ discard block |
||
698 | 958 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
699 | 959 | echo 'done !'."\n"; |
700 | 960 | // FIXME: Need more work |
701 | - if ($buffer != '') $reset = 0; |
|
961 | + if ($buffer != '') { |
|
962 | + $reset = 0; |
|
963 | + } |
|
702 | 964 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
703 | 965 | $buffer = explode('\n',$buffer); |
704 | 966 | foreach ($buffer as $line) { |
@@ -724,7 +986,9 @@ discard block |
||
724 | 986 | //$data['etaTime'] = substr($line,135,5); |
725 | 987 | $data['format_source'] = 'shipplotter'; |
726 | 988 | $data['id_source'] = $id_source; |
727 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
989 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
990 | + $data['noarchive'] = true; |
|
991 | + } |
|
728 | 992 | //print_r($data); |
729 | 993 | echo 'Add...'."\n"; |
730 | 994 | $MI->add($data); |
@@ -758,16 +1022,28 @@ discard block |
||
758 | 1022 | $line = explode(':', $line); |
759 | 1023 | if (count($line) > 30 && $line[0] != 'callsign') { |
760 | 1024 | $data = array(); |
761 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
762 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1025 | + if (isset($line[37]) && $line[37] != '') { |
|
1026 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
1027 | + } else { |
|
1028 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1029 | + } |
|
763 | 1030 | $data['pilot_id'] = $line[1]; |
764 | 1031 | $data['pilot_name'] = $line[2]; |
765 | 1032 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
766 | 1033 | $data['ident'] = $line[0]; // ident |
767 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
1034 | + if ($line[7] != '' && $line[7] != 0) { |
|
1035 | + $data['altitude'] = $line[7]; |
|
1036 | + } |
|
1037 | + // altitude |
|
768 | 1038 | $data['speed'] = $line[8]; // speed |
769 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
770 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
1039 | + if (isset($line[45])) { |
|
1040 | + $data['heading'] = $line[45]; |
|
1041 | + } |
|
1042 | + // heading |
|
1043 | + elseif (isset($line[38])) { |
|
1044 | + $data['heading'] = $line[38]; |
|
1045 | + } |
|
1046 | + // heading |
|
771 | 1047 | $data['latitude'] = $line[5]; // lat |
772 | 1048 | $data['longitude'] = $line[6]; // long |
773 | 1049 | $data['verticalrate'] = ''; // vertical rate |
@@ -783,7 +1059,9 @@ discard block |
||
783 | 1059 | $data['frequency'] = $line[4]; |
784 | 1060 | $data['type'] = $line[18]; |
785 | 1061 | $data['range'] = $line[19]; |
786 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
1062 | + if (isset($line[35])) { |
|
1063 | + $data['info'] = $line[35]; |
|
1064 | + } |
|
787 | 1065 | $data['id_source'] = $id_source; |
788 | 1066 | //$data['arrival_airport_time'] = ; |
789 | 1067 | if ($line[9] != '') { |
@@ -797,27 +1075,47 @@ discard block |
||
797 | 1075 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
798 | 1076 | */ |
799 | 1077 | $data['format_source'] = $value['format']; |
800 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
801 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
802 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
803 | - elseif ($line[3] === 'ATC') { |
|
1078 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1079 | + $data['noarchive'] = true; |
|
1080 | + } |
|
1081 | + if (isset($value['name']) && $value['name'] != '') { |
|
1082 | + $data['source_name'] = $value['name']; |
|
1083 | + } |
|
1084 | + if ($line[3] === 'PILOT') { |
|
1085 | + $SI->add($data); |
|
1086 | + } elseif ($line[3] === 'ATC') { |
|
804 | 1087 | //print_r($data); |
805 | 1088 | $data['info'] = str_replace('^§','<br />',$data['info']); |
806 | 1089 | $data['info'] = str_replace('&sect;','',$data['info']); |
807 | 1090 | $typec = substr($data['ident'],-3); |
808 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
809 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
810 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
811 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
812 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
813 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
814 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
815 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
816 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
817 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
1091 | + if ($typec === 'APP') { |
|
1092 | + $data['type'] = 'Approach'; |
|
1093 | + } elseif ($typec === 'TWR') { |
|
1094 | + $data['type'] = 'Tower'; |
|
1095 | + } elseif ($typec === 'OBS') { |
|
1096 | + $data['type'] = 'Observer'; |
|
1097 | + } elseif ($typec === 'GND') { |
|
1098 | + $data['type'] = 'Ground'; |
|
1099 | + } elseif ($typec === 'DEL') { |
|
1100 | + $data['type'] = 'Delivery'; |
|
1101 | + } elseif ($typec === 'DEP') { |
|
1102 | + $data['type'] = 'Departure'; |
|
1103 | + } elseif ($typec === 'FSS') { |
|
1104 | + $data['type'] = 'Flight Service Station'; |
|
1105 | + } elseif ($typec === 'CTR') { |
|
1106 | + $data['type'] = 'Control Radar or Centre'; |
|
1107 | + } elseif ($data['type'] === '') { |
|
1108 | + $data['type'] = 'Observer'; |
|
1109 | + } |
|
1110 | + if (!isset($data['source_name'])) { |
|
1111 | + $data['source_name'] = ''; |
|
1112 | + } |
|
818 | 1113 | if (isset($ATC)) { |
819 | - 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']); |
|
820 | - 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']); |
|
1114 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1115 | + 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']); |
|
1116 | + } else { |
|
1117 | + 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']); |
|
1118 | + } |
|
821 | 1119 | } |
822 | 1120 | } |
823 | 1121 | unset($data); |
@@ -844,14 +1142,20 @@ discard block |
||
844 | 1142 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
845 | 1143 | $data['latitude'] = (float)$line['pktLatitude']; |
846 | 1144 | $data['longitude'] = (float)$line['pktLongitude']; |
847 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
848 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1145 | + if ((float)$line['pktTrack'] != 0) { |
|
1146 | + $data['heading'] = (float)$line['pktTrack']; |
|
1147 | + } |
|
1148 | + if ((int)$line['pktSpeed'] != 0) { |
|
1149 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1150 | + } |
|
849 | 1151 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
850 | 1152 | $data['altitude_relative'] = 'AMSL'; |
851 | 1153 | $data['pilot_id'] = (int)$line['pktPilotID']; |
852 | 1154 | $data['aircraft_icao'] = 'PARAGLIDER'; |
853 | 1155 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
854 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1156 | + if (isset($pilot_data[4])) { |
|
1157 | + $data['pilot_name'] = $pilot_data[4]; |
|
1158 | + } |
|
855 | 1159 | $data['format_source'] = $value['format']; |
856 | 1160 | $SI->add($data); |
857 | 1161 | unset($data); |
@@ -899,25 +1203,59 @@ discard block |
||
899 | 1203 | foreach ($all_data['acList'] as $line) { |
900 | 1204 | $data = array(); |
901 | 1205 | $data['hex'] = $line['Icao']; // hex |
902 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
903 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
904 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
905 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
906 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
907 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1206 | + if (isset($line['Call'])) { |
|
1207 | + $data['ident'] = $line['Call']; |
|
1208 | + } |
|
1209 | + // ident |
|
1210 | + if (isset($line['Alt'])) { |
|
1211 | + $data['altitude'] = $line['Alt']; |
|
1212 | + } |
|
1213 | + // altitude |
|
1214 | + if (isset($line['Spd'])) { |
|
1215 | + $data['speed'] = $line['Spd']; |
|
1216 | + } |
|
1217 | + // speed |
|
1218 | + if (isset($line['Trak'])) { |
|
1219 | + $data['heading'] = $line['Trak']; |
|
1220 | + } |
|
1221 | + // heading |
|
1222 | + if (isset($line['Lat'])) { |
|
1223 | + $data['latitude'] = $line['Lat']; |
|
1224 | + } |
|
1225 | + // lat |
|
1226 | + if (isset($line['Long'])) { |
|
1227 | + $data['longitude'] = $line['Long']; |
|
1228 | + } |
|
1229 | + // long |
|
908 | 1230 | //$data['verticalrate'] = $line['']; // verticale rate |
909 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1231 | + if (isset($line['Sqk'])) { |
|
1232 | + $data['squawk'] = $line['Sqk']; |
|
1233 | + } |
|
1234 | + // squawk |
|
910 | 1235 | $data['emergency'] = ''; // emergency |
911 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
912 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
913 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1236 | + if (isset($line['Reg'])) { |
|
1237 | + $data['registration'] = $line['Reg']; |
|
1238 | + } |
|
1239 | + if (isset($line['PosTime'])) { |
|
1240 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1241 | + } else { |
|
1242 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1243 | + } |
|
914 | 1244 | //$data['datetime'] = date('Y-m-d H:i:s'); |
915 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1245 | + if (isset($line['Type'])) { |
|
1246 | + $data['aircraft_icao'] = $line['Type']; |
|
1247 | + } |
|
916 | 1248 | $data['format_source'] = 'aircraftlistjson'; |
917 | 1249 | $data['id_source'] = $id_source; |
918 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
919 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
920 | - if (isset($data['latitude'])) $SI->add($data); |
|
1250 | + if (isset($value['name']) && $value['name'] != '') { |
|
1251 | + $data['source_name'] = $value['name']; |
|
1252 | + } |
|
1253 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1254 | + $data['noarchive'] = true; |
|
1255 | + } |
|
1256 | + if (isset($data['latitude'])) { |
|
1257 | + $SI->add($data); |
|
1258 | + } |
|
921 | 1259 | unset($data); |
922 | 1260 | } |
923 | 1261 | } elseif (is_array($all_data)) { |
@@ -934,17 +1272,26 @@ discard block |
||
934 | 1272 | $data['verticalrate'] = $line['vrt']; // verticale rate |
935 | 1273 | $data['squawk'] = $line['squawk']; // squawk |
936 | 1274 | $data['emergency'] = ''; // emergency |
937 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
938 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1275 | + if (isset($line['PosTime'])) { |
|
1276 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1277 | + } else { |
|
1278 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1279 | + } |
|
939 | 1280 | $data['format_source'] = 'aircraftlistjson'; |
940 | 1281 | $data['id_source'] = $id_source; |
941 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
942 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1282 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1283 | + $data['noarchive'] = true; |
|
1284 | + } |
|
1285 | + if (isset($value['name']) && $value['name'] != '') { |
|
1286 | + $data['source_name'] = $value['name']; |
|
1287 | + } |
|
943 | 1288 | $SI->add($data); |
944 | 1289 | unset($data); |
945 | 1290 | } |
946 | 1291 | } |
947 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1292 | + } elseif ($globalDebug) { |
|
1293 | + echo 'No data'."\n"; |
|
1294 | + } |
|
948 | 1295 | //$last_exec['aircraftlistjson'] = time(); |
949 | 1296 | $last_exec[$id]['last'] = time(); |
950 | 1297 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -980,8 +1327,12 @@ discard block |
||
980 | 1327 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
981 | 1328 | $data['format_source'] = 'planeupdatefaa'; |
982 | 1329 | $data['id_source'] = $id_source; |
983 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
984 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1330 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1331 | + $data['noarchive'] = true; |
|
1332 | + } |
|
1333 | + if (isset($value['name']) && $value['name'] != '') { |
|
1334 | + $data['source_name'] = $value['name']; |
|
1335 | + } |
|
985 | 1336 | $SI->add($data); |
986 | 1337 | unset($data); |
987 | 1338 | } |
@@ -1015,7 +1366,9 @@ discard block |
||
1015 | 1366 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
1016 | 1367 | $data['format_source'] = 'opensky'; |
1017 | 1368 | $data['id_source'] = $id_source; |
1018 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1369 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1370 | + $data['noarchive'] = true; |
|
1371 | + } |
|
1019 | 1372 | $SI->add($data); |
1020 | 1373 | unset($data); |
1021 | 1374 | } |
@@ -1035,15 +1388,42 @@ discard block |
||
1035 | 1388 | foreach ($all_data['aircraft'] as $key => $line) { |
1036 | 1389 | $data = array(); |
1037 | 1390 | // add support for ground vehicule with ~ in front of hex |
1038 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1039 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1040 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1041 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1042 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1043 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1044 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1045 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1046 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1391 | + if (isset($line['hex'])) { |
|
1392 | + $data['hex'] = $line['hex']; |
|
1393 | + } |
|
1394 | + // hex |
|
1395 | + if (isset($line['flight'])) { |
|
1396 | + $data['ident'] = trim($line['flight']); |
|
1397 | + } |
|
1398 | + // ident |
|
1399 | + if (isset($line['altitude'])) { |
|
1400 | + $data['altitude'] = $line['altitude']; |
|
1401 | + } |
|
1402 | + // altitude |
|
1403 | + if (isset($line['speed'])) { |
|
1404 | + $data['speed'] = $line['speed']; |
|
1405 | + } |
|
1406 | + // speed |
|
1407 | + if (isset($line['track'])) { |
|
1408 | + $data['heading'] = $line['track']; |
|
1409 | + } |
|
1410 | + // heading |
|
1411 | + if (isset($line['lat'])) { |
|
1412 | + $data['latitude'] = $line['lat']; |
|
1413 | + } |
|
1414 | + // lat |
|
1415 | + if (isset($line['lon'])) { |
|
1416 | + $data['longitude'] = $line['lon']; |
|
1417 | + } |
|
1418 | + // long |
|
1419 | + if (isset($line['vert_rate'])) { |
|
1420 | + $data['verticalrate'] = $line['vert_rate']; |
|
1421 | + } |
|
1422 | + // verticale rate |
|
1423 | + if (isset($line['squawk'])) { |
|
1424 | + $data['squawk'] = $line['squawk']; |
|
1425 | + } |
|
1426 | + // squawk |
|
1047 | 1427 | //$data['emergency'] = ''; // emergency |
1048 | 1428 | //$data['registration'] = $line[2]; |
1049 | 1429 | //$data['aircraft_icao'] = $line[0]; |
@@ -1051,10 +1431,17 @@ discard block |
||
1051 | 1431 | $data['format_source'] = 'aircraftjson'; |
1052 | 1432 | $data['id_source'] = $id_source; |
1053 | 1433 | if (isset($value['name']) && $value['name'] != '') { |
1054 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1055 | - else $data['source_name'] = $value['name']; |
|
1056 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1057 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1434 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1435 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
1436 | + } else { |
|
1437 | + $data['source_name'] = $value['name']; |
|
1438 | + } |
|
1439 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1440 | + $data['source_name'] = 'MLAT'; |
|
1441 | + } |
|
1442 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1443 | + $data['noarchive'] = true; |
|
1444 | + } |
|
1058 | 1445 | $SI->add($data); |
1059 | 1446 | unset($data); |
1060 | 1447 | } |
@@ -1074,22 +1461,54 @@ discard block |
||
1074 | 1461 | foreach ($all_data['aircraft'] as $key => $line) { |
1075 | 1462 | $data = array(); |
1076 | 1463 | $data['hex'] = $key; // hex |
1077 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1078 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1079 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1080 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1081 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1082 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1083 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1084 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1464 | + if (isset($line['callsign'])) { |
|
1465 | + $data['ident'] = trim($line['callsign']); |
|
1466 | + } |
|
1467 | + // ident |
|
1468 | + if (isset($line['altitude'])) { |
|
1469 | + $data['altitude'] = $line['altitude']; |
|
1470 | + } |
|
1471 | + // altitude |
|
1472 | + if (isset($line['speed'])) { |
|
1473 | + $data['speed'] = $line['speed']; |
|
1474 | + } |
|
1475 | + // speed |
|
1476 | + if (isset($line['heading'])) { |
|
1477 | + $data['heading'] = $line['heading']; |
|
1478 | + } |
|
1479 | + // heading |
|
1480 | + if (isset($line['lat'])) { |
|
1481 | + $data['latitude'] = $line['lat']; |
|
1482 | + } |
|
1483 | + // lat |
|
1484 | + if (isset($line['lon'])) { |
|
1485 | + $data['longitude'] = $line['lon']; |
|
1486 | + } |
|
1487 | + // long |
|
1488 | + if (isset($line['vert_rate'])) { |
|
1489 | + $data['verticalrate'] = $line['vert_rate']; |
|
1490 | + } |
|
1491 | + // verticale rate |
|
1492 | + if (isset($line['squawk'])) { |
|
1493 | + $data['squawk'] = $line['squawk']; |
|
1494 | + } |
|
1495 | + // squawk |
|
1085 | 1496 | //$data['emergency'] = ''; // emergency |
1086 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1087 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1497 | + if (isset($line['reg'])) { |
|
1498 | + $data['registration'] = $line['reg']; |
|
1499 | + } |
|
1500 | + if (isset($line['type'])) { |
|
1501 | + $data['aircraft_icao'] = $line['type']; |
|
1502 | + } |
|
1088 | 1503 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
1089 | 1504 | $data['format_source'] = 'planefinderclient'; |
1090 | 1505 | $data['id_source'] = $id_source; |
1091 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1092 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1506 | + if (isset($value['name']) && $value['name'] != '') { |
|
1507 | + $data['source_name'] = $value['name']; |
|
1508 | + } |
|
1509 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1510 | + $data['noarchive'] = true; |
|
1511 | + } |
|
1093 | 1512 | $SI->add($data); |
1094 | 1513 | unset($data); |
1095 | 1514 | } |
@@ -1105,7 +1524,9 @@ discard block |
||
1105 | 1524 | //$buffer = $Common->getData($hosts[$id]); |
1106 | 1525 | $buffer = $Common->getData($value['host']); |
1107 | 1526 | $all_data = json_decode($buffer,true); |
1108 | - if (!empty($all_data)) $reset = 0; |
|
1527 | + if (!empty($all_data)) { |
|
1528 | + $reset = 0; |
|
1529 | + } |
|
1109 | 1530 | foreach ($all_data as $key => $line) { |
1110 | 1531 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1111 | 1532 | $data = array(); |
@@ -1126,8 +1547,12 @@ discard block |
||
1126 | 1547 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
1127 | 1548 | $data['format_source'] = 'fr24json'; |
1128 | 1549 | $data['id_source'] = $id_source; |
1129 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1130 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1550 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1551 | + $data['noarchive'] = true; |
|
1552 | + } |
|
1553 | + if (isset($value['name']) && $value['name'] != '') { |
|
1554 | + $data['source_name'] = $value['name']; |
|
1555 | + } |
|
1131 | 1556 | $SI->add($data); |
1132 | 1557 | unset($data); |
1133 | 1558 | } |
@@ -1156,24 +1581,42 @@ discard block |
||
1156 | 1581 | if (isset($line['inf'])) { |
1157 | 1582 | $data = array(); |
1158 | 1583 | $data['hex'] = $line['inf']['ia']; |
1159 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1584 | + if (isset($line['inf']['cs'])) { |
|
1585 | + $data['ident'] = $line['inf']['cs']; |
|
1586 | + } |
|
1587 | + //$line[13] |
|
1160 | 1588 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1161 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1162 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1589 | + if (isset($line['inf']['gs'])) { |
|
1590 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1591 | + } |
|
1592 | + // speed |
|
1593 | + if (isset($line['inf']['tr'])) { |
|
1594 | + $data['heading'] = $line['inf']['tr']; |
|
1595 | + } |
|
1596 | + // heading |
|
1163 | 1597 | $data['latitude'] = $line['pt'][0]; // lat |
1164 | 1598 | $data['longitude'] = $line['pt'][1]; // long |
1165 | 1599 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1166 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1600 | + if (isset($line['inf']['sq'])) { |
|
1601 | + $data['squawk'] = $line['inf']['sq']; |
|
1602 | + } |
|
1603 | + // squawk |
|
1167 | 1604 | //$data['aircraft_icao'] = $line[8]; |
1168 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1605 | + if (isset($line['inf']['rc'])) { |
|
1606 | + $data['registration'] = $line['inf']['rc']; |
|
1607 | + } |
|
1169 | 1608 | //$data['departure_airport_iata'] = $line[11]; |
1170 | 1609 | //$data['arrival_airport_iata'] = $line[12]; |
1171 | 1610 | //$data['emergency'] = ''; // emergency |
1172 | 1611 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1173 | 1612 | $data['format_source'] = 'radarvirtueljson'; |
1174 | 1613 | $data['id_source'] = $id_source; |
1175 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1176 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1614 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1615 | + $data['noarchive'] = true; |
|
1616 | + } |
|
1617 | + if (isset($value['name']) && $value['name'] != '') { |
|
1618 | + $data['source_name'] = $value['name']; |
|
1619 | + } |
|
1177 | 1620 | $SI->add($data); |
1178 | 1621 | unset($data); |
1179 | 1622 | } |
@@ -1199,30 +1642,65 @@ discard block |
||
1199 | 1642 | $data['id'] = $line['id']; |
1200 | 1643 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1201 | 1644 | $data['ident'] = $line['callsign']; // ident |
1202 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1203 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1204 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1205 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1206 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1207 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1645 | + if (isset($line['pilotid'])) { |
|
1646 | + $data['pilot_id'] = $line['pilotid']; |
|
1647 | + } |
|
1648 | + // pilot id |
|
1649 | + if (isset($line['name'])) { |
|
1650 | + $data['pilot_name'] = $line['name']; |
|
1651 | + } |
|
1652 | + // pilot name |
|
1653 | + if (isset($line['alt'])) { |
|
1654 | + $data['altitude'] = $line['alt']; |
|
1655 | + } |
|
1656 | + // altitude |
|
1657 | + if (isset($line['gs'])) { |
|
1658 | + $data['speed'] = $line['gs']; |
|
1659 | + } |
|
1660 | + // speed |
|
1661 | + if (isset($line['heading'])) { |
|
1662 | + $data['heading'] = $line['heading']; |
|
1663 | + } |
|
1664 | + // heading |
|
1665 | + if (isset($line['route'])) { |
|
1666 | + $data['waypoints'] = $line['route']; |
|
1667 | + } |
|
1668 | + // route |
|
1208 | 1669 | $data['latitude'] = $line['lat']; // lat |
1209 | 1670 | $data['longitude'] = $line['lon']; // long |
1210 | 1671 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1211 | 1672 | //$data['squawk'] = $line['squawk']; // squawk |
1212 | 1673 | //$data['emergency'] = ''; // emergency |
1213 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1214 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1215 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1674 | + if (isset($line['depicao'])) { |
|
1675 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1676 | + } |
|
1677 | + if (isset($line['deptime'])) { |
|
1678 | + $data['departure_airport_time'] = $line['deptime']; |
|
1679 | + } |
|
1680 | + if (isset($line['arricao'])) { |
|
1681 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1682 | + } |
|
1216 | 1683 | //$data['arrival_airport_time'] = $line['arrtime']; |
1217 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1218 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1219 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1220 | - else $data['info'] = ''; |
|
1684 | + if (isset($line['aircraft'])) { |
|
1685 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1686 | + } |
|
1687 | + if (isset($line['transponder'])) { |
|
1688 | + $data['squawk'] = $line['transponder']; |
|
1689 | + } |
|
1690 | + if (isset($line['atis'])) { |
|
1691 | + $data['info'] = $line['atis']; |
|
1692 | + } else { |
|
1693 | + $data['info'] = ''; |
|
1694 | + } |
|
1221 | 1695 | $data['format_source'] = 'pireps'; |
1222 | 1696 | $data['id_source'] = $id_source; |
1223 | 1697 | $data['datetime'] = date('Y-m-d H:i:s'); |
1224 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1225 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1698 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1699 | + $data['noarchive'] = true; |
|
1700 | + } |
|
1701 | + if (isset($value['name']) && $value['name'] != '') { |
|
1702 | + $data['source_name'] = $value['name']; |
|
1703 | + } |
|
1226 | 1704 | if ($line['icon'] === 'plane') { |
1227 | 1705 | $SI->add($data); |
1228 | 1706 | // print_r($data); |
@@ -1231,16 +1709,28 @@ discard block |
||
1231 | 1709 | $data['info'] = str_replace('&sect;','',$data['info']); |
1232 | 1710 | $typec = substr($data['ident'],-3); |
1233 | 1711 | $data['type'] = ''; |
1234 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
1235 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
1236 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
1237 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
1238 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
1239 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
1240 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1241 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1242 | - else $data['type'] = 'Observer'; |
|
1243 | - 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']); |
|
1712 | + if ($typec === 'APP') { |
|
1713 | + $data['type'] = 'Approach'; |
|
1714 | + } elseif ($typec === 'TWR') { |
|
1715 | + $data['type'] = 'Tower'; |
|
1716 | + } elseif ($typec === 'OBS') { |
|
1717 | + $data['type'] = 'Observer'; |
|
1718 | + } elseif ($typec === 'GND') { |
|
1719 | + $data['type'] = 'Ground'; |
|
1720 | + } elseif ($typec === 'DEL') { |
|
1721 | + $data['type'] = 'Delivery'; |
|
1722 | + } elseif ($typec === 'DEP') { |
|
1723 | + $data['type'] = 'Departure'; |
|
1724 | + } elseif ($typec === 'FSS') { |
|
1725 | + $data['type'] = 'Flight Service Station'; |
|
1726 | + } elseif ($typec === 'CTR') { |
|
1727 | + $data['type'] = 'Control Radar or Centre'; |
|
1728 | + } else { |
|
1729 | + $data['type'] = 'Observer'; |
|
1730 | + } |
|
1731 | + if (isset($ATC)) { |
|
1732 | + 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']); |
|
1733 | + } |
|
1244 | 1734 | } |
1245 | 1735 | unset($data); |
1246 | 1736 | } |
@@ -1255,7 +1745,9 @@ discard block |
||
1255 | 1745 | ) |
1256 | 1746 | ) { |
1257 | 1747 | //$buffer = $Common->getData($hosts[$id]); |
1258 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1748 | + if ($globalDebug) { |
|
1749 | + echo 'Get Data...'."\n"; |
|
1750 | + } |
|
1259 | 1751 | $buffer = $Common->getData($value['host']); |
1260 | 1752 | $all_data = json_decode($buffer,true); |
1261 | 1753 | if ($buffer != '' && is_array($all_data)) { |
@@ -1263,10 +1755,16 @@ discard block |
||
1263 | 1755 | foreach ($all_data as $line) { |
1264 | 1756 | $data = array(); |
1265 | 1757 | //$data['id'] = $line['id']; // id not usable |
1266 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1758 | + if (isset($line['pilotid'])) { |
|
1759 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1760 | + } |
|
1267 | 1761 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1268 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1269 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1762 | + if (isset($line['pilotname'])) { |
|
1763 | + $data['pilot_name'] = $line['pilotname']; |
|
1764 | + } |
|
1765 | + if (isset($line['pilotid'])) { |
|
1766 | + $data['pilot_id'] = $line['pilotid']; |
|
1767 | + } |
|
1270 | 1768 | $data['ident'] = $line['flightnum']; // ident |
1271 | 1769 | $data['altitude'] = $line['alt']; // altitude |
1272 | 1770 | $data['speed'] = $line['gs']; // speed |
@@ -1282,7 +1780,9 @@ discard block |
||
1282 | 1780 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1283 | 1781 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1284 | 1782 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1285 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1783 | + } else { |
|
1784 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1785 | + } |
|
1286 | 1786 | $data['departure_airport_icao'] = $line['depicao']; |
1287 | 1787 | $data['departure_airport_time'] = $line['deptime']; |
1288 | 1788 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1290,29 +1790,47 @@ discard block |
||
1290 | 1790 | if (isset($line['registration'])) { |
1291 | 1791 | $data['registration'] = $line['registration']; |
1292 | 1792 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
1293 | - } else $data['registration'] = $line['aircraft']; |
|
1294 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1295 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1793 | + } else { |
|
1794 | + $data['registration'] = $line['aircraft']; |
|
1795 | + } |
|
1796 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1797 | + $data['noarchive'] = true; |
|
1798 | + } |
|
1799 | + if (isset($line['route'])) { |
|
1800 | + $data['waypoints'] = $line['route']; |
|
1801 | + } |
|
1802 | + // route |
|
1296 | 1803 | if (isset($line['aircraftname'])) { |
1297 | 1804 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1298 | 1805 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1299 | 1806 | $aircraft_data = explode('-',$line['aircraftname']); |
1300 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1301 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1302 | - else { |
|
1807 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1808 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1809 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1810 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1811 | + } else { |
|
1303 | 1812 | $aircraft_data = explode(' ',$line['aircraftname']); |
1304 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1305 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1813 | + if (isset($aircraft_data[1])) { |
|
1814 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1815 | + } else { |
|
1816 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1817 | + } |
|
1306 | 1818 | } |
1307 | 1819 | } |
1308 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1820 | + if (isset($line['route'])) { |
|
1821 | + $data['waypoints'] = $line['route']; |
|
1822 | + } |
|
1309 | 1823 | $data['id_source'] = $id_source; |
1310 | 1824 | $data['format_source'] = 'phpvmacars'; |
1311 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1825 | + if (isset($value['name']) && $value['name'] != '') { |
|
1826 | + $data['source_name'] = $value['name']; |
|
1827 | + } |
|
1312 | 1828 | $SI->add($data); |
1313 | 1829 | unset($data); |
1314 | 1830 | } |
1315 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1831 | + if ($globalDebug) { |
|
1832 | + echo 'No more data...'."\n"; |
|
1833 | + } |
|
1316 | 1834 | unset($buffer); |
1317 | 1835 | unset($all_data); |
1318 | 1836 | } |
@@ -1325,7 +1843,9 @@ discard block |
||
1325 | 1843 | ) |
1326 | 1844 | ) { |
1327 | 1845 | //$buffer = $Common->getData($hosts[$id]); |
1328 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1846 | + if ($globalDebug) { |
|
1847 | + echo 'Get Data...'."\n"; |
|
1848 | + } |
|
1329 | 1849 | $buffer = $Common->getData($value['host']); |
1330 | 1850 | $all_data = json_decode($buffer,true); |
1331 | 1851 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1336,10 +1856,16 @@ discard block |
||
1336 | 1856 | //$data['id'] = $line['id']; // id not usable |
1337 | 1857 | $data['id'] = $line['id']; |
1338 | 1858 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1339 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1340 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1859 | + if (isset($line['user']['username'])) { |
|
1860 | + $data['pilot_name'] = $line['user']['username']; |
|
1861 | + } |
|
1862 | + if (isset($line['user_id'])) { |
|
1863 | + $data['pilot_id'] = $line['user_id']; |
|
1864 | + } |
|
1341 | 1865 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
1342 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1866 | + if (is_numeric($data['ident'])) { |
|
1867 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1868 | + } |
|
1343 | 1869 | $data['altitude'] = $line['altitude']; // altitude |
1344 | 1870 | $data['speed'] = $line['groundspeed']; // speed |
1345 | 1871 | $data['heading'] = $line['heading']; // heading |
@@ -1352,7 +1878,9 @@ discard block |
||
1352 | 1878 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
1353 | 1879 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1354 | 1880 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1355 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1881 | + } else { |
|
1882 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1883 | + } |
|
1356 | 1884 | |
1357 | 1885 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
1358 | 1886 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1360,17 +1888,26 @@ discard block |
||
1360 | 1888 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
1361 | 1889 | $data['registration'] = $line['bid']['aircraft']['registration']; |
1362 | 1890 | |
1363 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1364 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1891 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1892 | + $data['noarchive'] = true; |
|
1893 | + } |
|
1894 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
1895 | + $data['waypoints'] = $line['bid']['route']; |
|
1896 | + } |
|
1897 | + // route |
|
1365 | 1898 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
1366 | 1899 | |
1367 | 1900 | $data['id_source'] = $id_source; |
1368 | 1901 | $data['format_source'] = 'vaos'; |
1369 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1902 | + if (isset($value['name']) && $value['name'] != '') { |
|
1903 | + $data['source_name'] = $value['name']; |
|
1904 | + } |
|
1370 | 1905 | $SI->add($data); |
1371 | 1906 | unset($data); |
1372 | 1907 | } |
1373 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1908 | + if ($globalDebug) { |
|
1909 | + echo 'No more data...'."\n"; |
|
1910 | + } |
|
1374 | 1911 | unset($buffer); |
1375 | 1912 | unset($all_data); |
1376 | 1913 | } |
@@ -1383,7 +1920,9 @@ discard block |
||
1383 | 1920 | ) |
1384 | 1921 | ) { |
1385 | 1922 | //$buffer = $Common->getData($hosts[$id]); |
1386 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1923 | + if ($globalDebug) { |
|
1924 | + echo 'Get Data...'."\n"; |
|
1925 | + } |
|
1387 | 1926 | $buffer = $Common->getData($value['host']); |
1388 | 1927 | $all_data = json_decode($buffer,true); |
1389 | 1928 | if ($buffer != '' && is_array($all_data)) { |
@@ -1412,16 +1951,25 @@ discard block |
||
1412 | 1951 | $data['arrival_airport_icao'] = $line['arrival']; |
1413 | 1952 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1414 | 1953 | //$data['registration'] = $line['aircraft']; |
1415 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1954 | + if (isset($line['route'])) { |
|
1955 | + $data['waypoints'] = $line['route']; |
|
1956 | + } |
|
1957 | + // route |
|
1416 | 1958 | $data['aircraft_icao'] = $line['plane_type']; |
1417 | 1959 | $data['id_source'] = $id_source; |
1418 | 1960 | $data['format_source'] = 'vam'; |
1419 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1420 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1961 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1962 | + $data['noarchive'] = true; |
|
1963 | + } |
|
1964 | + if (isset($value['name']) && $value['name'] != '') { |
|
1965 | + $data['source_name'] = $value['name']; |
|
1966 | + } |
|
1421 | 1967 | $SI->add($data); |
1422 | 1968 | unset($data); |
1423 | 1969 | } |
1424 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1970 | + if ($globalDebug) { |
|
1971 | + echo 'No more data...'."\n"; |
|
1972 | + } |
|
1425 | 1973 | unset($buffer); |
1426 | 1974 | unset($all_data); |
1427 | 1975 | } |
@@ -1434,7 +1982,9 @@ discard block |
||
1434 | 1982 | ) |
1435 | 1983 | ) { |
1436 | 1984 | //$buffer = $Common->getData($hosts[$id]); |
1437 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1985 | + if ($globalDebug) { |
|
1986 | + echo 'Get Data...'."\n"; |
|
1987 | + } |
|
1438 | 1988 | $buffer = $Common->getData($value['host']); |
1439 | 1989 | $all_data = json_decode($buffer,true); |
1440 | 1990 | if ($buffer != '') { |
@@ -1452,12 +2002,16 @@ discard block |
||
1452 | 2002 | $data['id_source'] = $id_source; |
1453 | 2003 | $data['format_source'] = 'blitzortung'; |
1454 | 2004 | $SI->add($data); |
1455 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2005 | + if ($globalDebug) { |
|
2006 | + echo '☈ Lightning added'."\n"; |
|
2007 | + } |
|
1456 | 2008 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1457 | 2009 | unset($data); |
1458 | 2010 | } |
1459 | 2011 | } |
1460 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2012 | + if ($globalDebug) { |
|
2013 | + echo 'No more data...'."\n"; |
|
2014 | + } |
|
1461 | 2015 | unset($buffer); |
1462 | 2016 | } |
1463 | 2017 | $last_exec[$id]['last'] = time(); |
@@ -1469,7 +2023,9 @@ discard block |
||
1469 | 2023 | $write = NULL; |
1470 | 2024 | $e = NULL; |
1471 | 2025 | $n = socket_select($read, $write, $e, $timeout); |
1472 | - if ($e != NULL) var_dump($e); |
|
2026 | + if ($e != NULL) { |
|
2027 | + var_dump($e); |
|
2028 | + } |
|
1473 | 2029 | if ($n > 0) { |
1474 | 2030 | $reset = 0; |
1475 | 2031 | foreach ($read as $nb => $r) { |
@@ -1491,13 +2047,17 @@ discard block |
||
1491 | 2047 | if ($buffer !== FALSE) { |
1492 | 2048 | if ($format === 'vrstcp') { |
1493 | 2049 | $buffer = explode('},{',$buffer); |
1494 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
2050 | + } else { |
|
2051 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
2052 | + } |
|
1495 | 2053 | } |
1496 | 2054 | // SBS format is CSV format |
1497 | 2055 | if ($buffer !== FALSE && $buffer !== '') { |
1498 | 2056 | $tt[$format] = 0; |
1499 | 2057 | if ($format === 'acarssbs3') { |
1500 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2058 | + if ($globalDebug) { |
|
2059 | + echo 'ACARS : '.$buffer."\n"; |
|
2060 | + } |
|
1501 | 2061 | $ACARS->add(trim($buffer)); |
1502 | 2062 | $ACARS->deleteLiveAcarsData(); |
1503 | 2063 | } elseif ($format === 'raw') { |
@@ -1506,30 +2066,70 @@ discard block |
||
1506 | 2066 | if (is_array($data)) { |
1507 | 2067 | $data['datetime'] = date('Y-m-d H:i:s'); |
1508 | 2068 | $data['format_source'] = 'raw'; |
1509 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1510 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1511 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1512 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2069 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2070 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2071 | + } |
|
2072 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2073 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2074 | + } |
|
2075 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2076 | + $data['noarchive'] = true; |
|
2077 | + } |
|
2078 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2079 | + $SI->add($data); |
|
2080 | + } |
|
1513 | 2081 | } |
1514 | 2082 | } elseif ($format === 'ais') { |
1515 | 2083 | $ais_data = $AIS->parse_line(trim($buffer)); |
1516 | 2084 | $data = array(); |
1517 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1518 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1519 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1520 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1521 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1522 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1523 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1524 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1525 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1526 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1527 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1528 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1529 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1530 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1531 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1532 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2085 | + if (isset($ais_data['ident'])) { |
|
2086 | + $data['ident'] = $ais_data['ident']; |
|
2087 | + } |
|
2088 | + if (isset($ais_data['mmsi'])) { |
|
2089 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
2090 | + } |
|
2091 | + if (isset($ais_data['speed'])) { |
|
2092 | + $data['speed'] = $ais_data['speed']; |
|
2093 | + } |
|
2094 | + if (isset($ais_data['heading'])) { |
|
2095 | + $data['heading'] = $ais_data['heading']; |
|
2096 | + } |
|
2097 | + if (isset($ais_data['latitude'])) { |
|
2098 | + $data['latitude'] = $ais_data['latitude']; |
|
2099 | + } |
|
2100 | + if (isset($ais_data['longitude'])) { |
|
2101 | + $data['longitude'] = $ais_data['longitude']; |
|
2102 | + } |
|
2103 | + if (isset($ais_data['status'])) { |
|
2104 | + $data['status'] = $ais_data['status']; |
|
2105 | + } |
|
2106 | + if (isset($ais_data['statusid'])) { |
|
2107 | + $data['status_id'] = $ais_data['statusid']; |
|
2108 | + } |
|
2109 | + if (isset($ais_data['type'])) { |
|
2110 | + $data['type'] = $ais_data['type']; |
|
2111 | + } |
|
2112 | + if (isset($ais_data['imo'])) { |
|
2113 | + $data['imo'] = $ais_data['imo']; |
|
2114 | + } |
|
2115 | + if (isset($ais_data['callsign'])) { |
|
2116 | + $data['callsign'] = $ais_data['callsign']; |
|
2117 | + } |
|
2118 | + if (isset($ais_data['destination'])) { |
|
2119 | + $data['arrival_code'] = $ais_data['destination']; |
|
2120 | + } |
|
2121 | + if (isset($ais_data['eta_ts'])) { |
|
2122 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
2123 | + } |
|
2124 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2125 | + $data['noarchive'] = true; |
|
2126 | + } |
|
2127 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2128 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2129 | + } |
|
2130 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2131 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2132 | + } |
|
1533 | 2133 | |
1534 | 2134 | if (isset($ais_data['timestamp'])) { |
1535 | 2135 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1538,7 +2138,9 @@ discard block |
||
1538 | 2138 | } |
1539 | 2139 | $data['format_source'] = 'aisnmea'; |
1540 | 2140 | $data['id_source'] = $id_source; |
1541 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
2141 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
2142 | + $MI->add($data); |
|
2143 | + } |
|
1542 | 2144 | unset($data); |
1543 | 2145 | } elseif ($format === 'flightgearsp') { |
1544 | 2146 | //echo $buffer."\n"; |
@@ -1556,12 +2158,18 @@ discard block |
||
1556 | 2158 | $data['speed'] = round($line[5]*1.94384); |
1557 | 2159 | $data['datetime'] = date('Y-m-d H:i:s'); |
1558 | 2160 | $data['format_source'] = 'flightgearsp'; |
1559 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1560 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2161 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2162 | + $data['noarchive'] = true; |
|
2163 | + } |
|
2164 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2165 | + $SI->add($data); |
|
2166 | + } |
|
1561 | 2167 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1562 | 2168 | } |
1563 | 2169 | } elseif ($format === 'acars') { |
1564 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2170 | + if ($globalDebug) { |
|
2171 | + echo 'ACARS : '.$buffer."\n"; |
|
2172 | + } |
|
1565 | 2173 | $ACARS->add(trim($buffer)); |
1566 | 2174 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1567 | 2175 | $ACARS->deleteLiveAcarsData(); |
@@ -1582,8 +2190,12 @@ discard block |
||
1582 | 2190 | $aircraft_type = $line[10]; |
1583 | 2191 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1584 | 2192 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1585 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1586 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2193 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2194 | + $data['noarchive'] = true; |
|
2195 | + } |
|
2196 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2197 | + $SI->add($data); |
|
2198 | + } |
|
1587 | 2199 | } |
1588 | 2200 | } |
1589 | 2201 | } elseif ($format === 'beast') { |
@@ -1593,28 +2205,62 @@ discard block |
||
1593 | 2205 | foreach($buffer as $all_data) { |
1594 | 2206 | $line = json_decode('{'.$all_data.'}',true); |
1595 | 2207 | $data = array(); |
1596 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1597 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1598 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1599 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1600 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1601 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1602 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
2208 | + if (isset($line['Icao'])) { |
|
2209 | + $data['hex'] = $line['Icao']; |
|
2210 | + } |
|
2211 | + // hex |
|
2212 | + if (isset($line['Call'])) { |
|
2213 | + $data['ident'] = $line['Call']; |
|
2214 | + } |
|
2215 | + // ident |
|
2216 | + if (isset($line['Alt'])) { |
|
2217 | + $data['altitude'] = $line['Alt']; |
|
2218 | + } |
|
2219 | + // altitude |
|
2220 | + if (isset($line['Spd'])) { |
|
2221 | + $data['speed'] = $line['Spd']; |
|
2222 | + } |
|
2223 | + // speed |
|
2224 | + if (isset($line['Trak'])) { |
|
2225 | + $data['heading'] = $line['Trak']; |
|
2226 | + } |
|
2227 | + // heading |
|
2228 | + if (isset($line['Lat'])) { |
|
2229 | + $data['latitude'] = $line['Lat']; |
|
2230 | + } |
|
2231 | + // lat |
|
2232 | + if (isset($line['Long'])) { |
|
2233 | + $data['longitude'] = $line['Long']; |
|
2234 | + } |
|
2235 | + // long |
|
1603 | 2236 | //$data['verticalrate'] = $line['']; // verticale rate |
1604 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
2237 | + if (isset($line['Sqk'])) { |
|
2238 | + $data['squawk'] = $line['Sqk']; |
|
2239 | + } |
|
2240 | + // squawk |
|
1605 | 2241 | $data['emergency'] = ''; // emergency |
1606 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
2242 | + if (isset($line['Reg'])) { |
|
2243 | + $data['registration'] = $line['Reg']; |
|
2244 | + } |
|
1607 | 2245 | /* |
1608 | 2246 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1609 | 2247 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1610 | 2248 | */ |
1611 | 2249 | $data['datetime'] = date('Y-m-d H:i:s'); |
1612 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
2250 | + if (isset($line['Type'])) { |
|
2251 | + $data['aircraft_icao'] = $line['Type']; |
|
2252 | + } |
|
1613 | 2253 | $data['format_source'] = 'vrstcp'; |
1614 | 2254 | $data['id_source'] = $id_source; |
1615 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1616 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1617 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
2255 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2256 | + $data['noarchive'] = true; |
|
2257 | + } |
|
2258 | + if (isset($value['name']) && $value['name'] != '') { |
|
2259 | + $data['source_name'] = $value['name']; |
|
2260 | + } |
|
2261 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
2262 | + $SI->add($data); |
|
2263 | + } |
|
1618 | 2264 | unset($data); |
1619 | 2265 | } |
1620 | 2266 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1627,22 +2273,46 @@ discard block |
||
1627 | 2273 | $data['hex'] = $lined['hexid']; |
1628 | 2274 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1629 | 2275 | $data['datetime'] = date('Y-m-d H:i:s');; |
1630 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1631 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1632 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1633 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1634 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1635 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1636 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
2276 | + if (isset($lined['ident'])) { |
|
2277 | + $data['ident'] = $lined['ident']; |
|
2278 | + } |
|
2279 | + if (isset($lined['lat'])) { |
|
2280 | + $data['latitude'] = $lined['lat']; |
|
2281 | + } |
|
2282 | + if (isset($lined['lon'])) { |
|
2283 | + $data['longitude'] = $lined['lon']; |
|
2284 | + } |
|
2285 | + if (isset($lined['speed'])) { |
|
2286 | + $data['speed'] = $lined['speed']; |
|
2287 | + } |
|
2288 | + if (isset($lined['squawk'])) { |
|
2289 | + $data['squawk'] = $lined['squawk']; |
|
2290 | + } |
|
2291 | + if (isset($lined['alt'])) { |
|
2292 | + $data['altitude'] = $lined['alt']; |
|
2293 | + } |
|
2294 | + if (isset($lined['heading'])) { |
|
2295 | + $data['heading'] = $lined['heading']; |
|
2296 | + } |
|
1637 | 2297 | $data['id_source'] = $id_source; |
1638 | 2298 | $data['format_source'] = 'tsv'; |
1639 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1640 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1641 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1642 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2299 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2300 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2301 | + } |
|
2302 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2303 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2304 | + } |
|
2305 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2306 | + $data['noarchive'] = true; |
|
2307 | + } |
|
2308 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2309 | + $SI->add($data); |
|
2310 | + } |
|
1643 | 2311 | unset($lined); |
1644 | 2312 | unset($data); |
1645 | - } else $error = true; |
|
2313 | + } else { |
|
2314 | + $error = true; |
|
2315 | + } |
|
1646 | 2316 | } elseif ($format === 'aprs' && $use_aprs) { |
1647 | 2317 | if ($aprs_connect === 0) { |
1648 | 2318 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1668,63 +2338,121 @@ discard block |
||
1668 | 2338 | $aprs_last_tx = time(); |
1669 | 2339 | $data = array(); |
1670 | 2340 | //print_r($line); |
1671 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1672 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1673 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1674 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1675 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1676 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1677 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1678 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1679 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1680 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2341 | + if (isset($line['address'])) { |
|
2342 | + $data['hex'] = $line['address']; |
|
2343 | + } |
|
2344 | + if (isset($line['mmsi'])) { |
|
2345 | + $data['mmsi'] = $line['mmsi']; |
|
2346 | + } |
|
2347 | + if (isset($line['imo'])) { |
|
2348 | + $data['imo'] = $line['imo']; |
|
2349 | + } |
|
2350 | + if (isset($line['squawk'])) { |
|
2351 | + $data['squawk'] = $line['squawk']; |
|
2352 | + } |
|
2353 | + if (isset($line['arrival_code'])) { |
|
2354 | + $data['arrival_code'] = $line['arrival_code']; |
|
2355 | + } |
|
2356 | + if (isset($line['arrival_date'])) { |
|
2357 | + $data['arrival_date'] = $line['arrival_date']; |
|
2358 | + } |
|
2359 | + if (isset($line['typeid'])) { |
|
2360 | + $data['type_id'] = $line['typeid']; |
|
2361 | + } |
|
2362 | + if (isset($line['statusid'])) { |
|
2363 | + $data['status_id'] = $line['statusid']; |
|
2364 | + } |
|
2365 | + if (isset($line['timestamp'])) { |
|
2366 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2367 | + } else { |
|
2368 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2369 | + } |
|
1681 | 2370 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1682 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2371 | + if (isset($line['ident'])) { |
|
2372 | + $data['ident'] = $line['ident']; |
|
2373 | + } |
|
1683 | 2374 | $data['latitude'] = $line['latitude']; |
1684 | 2375 | $data['longitude'] = $line['longitude']; |
1685 | 2376 | //$data['verticalrate'] = $line[16]; |
1686 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2377 | + if (isset($line['speed'])) { |
|
2378 | + $data['speed'] = $line['speed']; |
|
2379 | + } |
|
1687 | 2380 | //else $data['speed'] = 0; |
1688 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1689 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1690 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2381 | + if (isset($line['altitude'])) { |
|
2382 | + $data['altitude'] = $line['altitude']; |
|
2383 | + } |
|
2384 | + if (isset($line['comment'])) { |
|
2385 | + $data['comment'] = $line['comment']; |
|
2386 | + } |
|
2387 | + if (isset($line['symbol'])) { |
|
2388 | + $data['type'] = $line['symbol']; |
|
2389 | + } |
|
1691 | 2390 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1692 | 2391 | |
1693 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2392 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2393 | + $data['heading'] = $line['heading']; |
|
2394 | + } |
|
1694 | 2395 | //else echo 'No heading...'."\n"; |
1695 | 2396 | //else $data['heading'] = 0; |
1696 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2397 | + if (isset($line['stealth'])) { |
|
2398 | + $data['aircraft_type'] = $line['stealth']; |
|
2399 | + } |
|
1697 | 2400 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1698 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1699 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1700 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1701 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2401 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2402 | + $data['noarchive'] = true; |
|
2403 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2404 | + $data['noarchive'] = false; |
|
2405 | + } |
|
2406 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2407 | + $data['noarchive'] = true; |
|
2408 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2409 | + $data['noarchive'] = false; |
|
2410 | + } |
|
1702 | 2411 | $data['id_source'] = $id_source; |
1703 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1704 | - else $data['format_source'] = 'aprs'; |
|
2412 | + if (isset($line['format_source'])) { |
|
2413 | + $data['format_source'] = $line['format_source']; |
|
2414 | + } else { |
|
2415 | + $data['format_source'] = 'aprs'; |
|
2416 | + } |
|
1705 | 2417 | $data['source_name'] = $line['source']; |
1706 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1707 | - else $data['source_type'] = 'flarm'; |
|
1708 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2418 | + if (isset($line['source_type'])) { |
|
2419 | + $data['source_type'] = $line['source_type']; |
|
2420 | + } else { |
|
2421 | + $data['source_type'] = 'flarm'; |
|
2422 | + } |
|
2423 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2424 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2425 | + } |
|
1709 | 2426 | $currentdate = date('Y-m-d H:i:s'); |
1710 | 2427 | $aprsdate = strtotime($data['datetime']); |
1711 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2428 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2429 | + $data['altitude_relative'] = 'AMSL'; |
|
2430 | + } |
|
1712 | 2431 | // Accept data if time <= system time + 20s |
1713 | 2432 | //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'])))) { |
1714 | 2433 | if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1715 | 2434 | $send = $SI->add($data); |
1716 | 2435 | } elseif ($data['source_type'] === 'ais') { |
1717 | 2436 | $data['type'] = ''; |
1718 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2437 | + if (isset($globalMarine) && $globalMarine) { |
|
2438 | + $send = $MI->add($data); |
|
2439 | + } |
|
1719 | 2440 | } elseif (isset($line['stealth'])) { |
1720 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1721 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2441 | + if ($line['stealth'] != 0) { |
|
2442 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
2443 | + } else { |
|
2444 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2445 | + } |
|
1722 | 2446 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1723 | 2447 | //$line['symbol'] === 'Balloon' || |
1724 | 2448 | $line['symbol'] === 'Glider' || |
1725 | 2449 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
1726 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1727 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2450 | + if ($line['symbol'] === 'Ballon') { |
|
2451 | + $data['aircraft_icao'] = 'BALL'; |
|
2452 | + } |
|
2453 | + if ($line['symbol'] === 'Glider') { |
|
2454 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2455 | + } |
|
1728 | 2456 | $send = $SI->add($data); |
1729 | 2457 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1730 | 2458 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1755,9 +2483,13 @@ discard block |
||
1755 | 2483 | //} 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') { |
1756 | 2484 | // } 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') { |
1757 | 2485 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1758 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2486 | + if (isset($globalTracker) && $globalTracker) { |
|
2487 | + $send = $TI->add($data); |
|
2488 | + } |
|
1759 | 2489 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1760 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2490 | + if (!isset($data['altitude'])) { |
|
2491 | + $data['altitude'] = 0; |
|
2492 | + } |
|
1761 | 2493 | $Source->deleteOldLocationByType('gs'); |
1762 | 2494 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
1763 | 2495 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1766,7 +2498,9 @@ discard block |
||
1766 | 2498 | } |
1767 | 2499 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
1768 | 2500 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1769 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2501 | + if ($globalDebug) { |
|
2502 | + echo '# Weather Station added'."\n"; |
|
2503 | + } |
|
1770 | 2504 | $Source->deleteOldLocationByType('wx'); |
1771 | 2505 | $weather_data = json_encode($line); |
1772 | 2506 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1776,7 +2510,9 @@ discard block |
||
1776 | 2510 | } |
1777 | 2511 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
1778 | 2512 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1779 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2513 | + if ($globalDebug) { |
|
2514 | + echo '☈ Lightning added'."\n"; |
|
2515 | + } |
|
1780 | 2516 | $Source->deleteOldLocationByType('lightning'); |
1781 | 2517 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
1782 | 2518 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1788,8 +2524,7 @@ discard block |
||
1788 | 2524 | print_r($line); |
1789 | 2525 | } |
1790 | 2526 | unset($data); |
1791 | - } |
|
1792 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2527 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1793 | 2528 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
1794 | 2529 | } |
1795 | 2530 | /* |
@@ -1798,7 +2533,9 @@ discard block |
||
1798 | 2533 | } |
1799 | 2534 | */ |
1800 | 2535 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1801 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2536 | + elseif ($line === true && $globalDebug) { |
|
2537 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2538 | + } |
|
1802 | 2539 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
1803 | 2540 | $Source->deleteOldLocationByType('lightning'); |
1804 | 2541 | $Source->deleteOldLocationByType('wx'); |
@@ -1834,27 +2571,47 @@ discard block |
||
1834 | 2571 | $data['ground'] = $line[21]; |
1835 | 2572 | $data['emergency'] = $line[19]; |
1836 | 2573 | $data['format_source'] = 'sbs'; |
1837 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1838 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
1839 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1840 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2574 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2575 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2576 | + } elseif ($line[0] == 'MLAT') { |
|
2577 | + $data['source_name'] = 'MLAT'; |
|
2578 | + } |
|
2579 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2580 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2581 | + } |
|
2582 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2583 | + $data['noarchive'] = true; |
|
2584 | + } |
|
1841 | 2585 | $data['id_source'] = $id_source; |
1842 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1843 | - else $error = true; |
|
2586 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2587 | + $send = $SI->add($data); |
|
2588 | + } else { |
|
2589 | + $error = true; |
|
2590 | + } |
|
1844 | 2591 | unset($data); |
1845 | - } else $error = true; |
|
2592 | + } else { |
|
2593 | + $error = true; |
|
2594 | + } |
|
1846 | 2595 | if ($error) { |
1847 | 2596 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
1848 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2597 | + if ($globalDebug) { |
|
2598 | + echo "Not a message. Ignoring... \n"; |
|
2599 | + } |
|
1849 | 2600 | } else { |
1850 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2601 | + if ($globalDebug) { |
|
2602 | + echo "Wrong line format. Ignoring... \n"; |
|
2603 | + } |
|
1851 | 2604 | if ($globalDebug) { |
1852 | 2605 | echo $buffer; |
1853 | 2606 | //print_r($line); |
1854 | 2607 | } |
1855 | 2608 | //socket_close($r); |
1856 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1857 | - if ($format === 'aprs') $aprs_connect = 0; |
|
2609 | + if ($globalDebug) { |
|
2610 | + echo "Reconnect after an error...\n"; |
|
2611 | + } |
|
2612 | + if ($format === 'aprs') { |
|
2613 | + $aprs_connect = 0; |
|
2614 | + } |
|
1858 | 2615 | $sourceer[$nb] = $globalSources[$nb]; |
1859 | 2616 | connect_all($sourceer); |
1860 | 2617 | $sourceer = array(); |
@@ -1862,10 +2619,14 @@ discard block |
||
1862 | 2619 | } |
1863 | 2620 | } |
1864 | 2621 | // Sleep for xxx microseconds |
1865 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2622 | + if (isset($globalSBSSleep)) { |
|
2623 | + usleep($globalSBSSleep); |
|
2624 | + } |
|
1866 | 2625 | } else { |
1867 | 2626 | if ($format === 'flightgearmp') { |
1868 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2627 | + if ($globalDebug) { |
|
2628 | + echo "Reconnect FlightGear MP..."; |
|
2629 | + } |
|
1869 | 2630 | //@socket_close($r); |
1870 | 2631 | sleep($globalMinFetch); |
1871 | 2632 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1874,10 +2635,15 @@ discard block |
||
1874 | 2635 | break; |
1875 | 2636 | |
1876 | 2637 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1877 | - if (isset($tt[$format])) $tt[$format]++; |
|
1878 | - else $tt[$format] = 0; |
|
2638 | + if (isset($tt[$format])) { |
|
2639 | + $tt[$format]++; |
|
2640 | + } else { |
|
2641 | + $tt[$format] = 0; |
|
2642 | + } |
|
1879 | 2643 | if ($tt[$format] > 30 || $buffer === FALSE) { |
1880 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2644 | + if ($globalDebug) { |
|
2645 | + echo "ERROR : Reconnect ".$format."..."; |
|
2646 | + } |
|
1881 | 2647 | //@socket_close($r); |
1882 | 2648 | sleep(2); |
1883 | 2649 | $aprs_connect = 0; |
@@ -1895,11 +2661,17 @@ discard block |
||
1895 | 2661 | } else { |
1896 | 2662 | $error = socket_strerror(socket_last_error()); |
1897 | 2663 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1898 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1899 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2664 | + if ($globalDebug) { |
|
2665 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2666 | + } |
|
2667 | + if (isset($globalDebug)) { |
|
2668 | + echo "Restarting...\n"; |
|
2669 | + } |
|
1900 | 2670 | // Restart the script if possible |
1901 | 2671 | if (is_array($sockets)) { |
1902 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2672 | + if ($globalDebug) { |
|
2673 | + echo "Shutdown all sockets..."; |
|
2674 | + } |
|
1903 | 2675 | |
1904 | 2676 | foreach ($sockets as $sock) { |
1905 | 2677 | @socket_shutdown($sock,2); |
@@ -1907,25 +2679,45 @@ discard block |
||
1907 | 2679 | } |
1908 | 2680 | |
1909 | 2681 | } |
1910 | - if ($globalDebug) echo "Waiting..."; |
|
2682 | + if ($globalDebug) { |
|
2683 | + echo "Waiting..."; |
|
2684 | + } |
|
1911 | 2685 | sleep(2); |
1912 | 2686 | $time = time(); |
1913 | 2687 | //connect_all($hosts); |
1914 | 2688 | $aprs_connect = 0; |
1915 | - if ($reset%5 === 0) sleep(20); |
|
1916 | - if ($reset%10 === 0) sleep(100); |
|
1917 | - if ($reset%20 === 0) sleep(200); |
|
1918 | - if ($reset > 100) exit('Too many attempts...'); |
|
1919 | - if ($globalDebug) echo "Restart all connections..."; |
|
2689 | + if ($reset%5 === 0) { |
|
2690 | + sleep(20); |
|
2691 | + } |
|
2692 | + if ($reset%10 === 0) { |
|
2693 | + sleep(100); |
|
2694 | + } |
|
2695 | + if ($reset%20 === 0) { |
|
2696 | + sleep(200); |
|
2697 | + } |
|
2698 | + if ($reset > 100) { |
|
2699 | + exit('Too many attempts...'); |
|
2700 | + } |
|
2701 | + if ($globalDebug) { |
|
2702 | + echo "Restart all connections..."; |
|
2703 | + } |
|
1920 | 2704 | connect_all($globalSources); |
1921 | 2705 | } |
1922 | 2706 | } |
1923 | 2707 | } |
1924 | 2708 | if ($globalDaemon === false) { |
1925 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1926 | - if (isset($SI)) $SI->checkAll(); |
|
1927 | - if (isset($TI)) $TI->checkAll(); |
|
1928 | - if (isset($MI)) $MI->checkAll(); |
|
2709 | + if ($globalDebug) { |
|
2710 | + echo 'Check all...'."\n"; |
|
2711 | + } |
|
2712 | + if (isset($SI)) { |
|
2713 | + $SI->checkAll(); |
|
2714 | + } |
|
2715 | + if (isset($TI)) { |
|
2716 | + $TI->checkAll(); |
|
2717 | + } |
|
2718 | + if (isset($MI)) { |
|
2719 | + $MI->checkAll(); |
|
2720 | + } |
|
1929 | 2721 | } |
1930 | 2722 | } |
1931 | 2723 | } |