@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
23 | 23 | } |
24 | 24 | |
25 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
26 | 28 | |
27 | 29 | if ($globalInstalled === FALSE) { |
28 | 30 | echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
@@ -68,66 +70,107 @@ discard block |
||
68 | 70 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
69 | 71 | if (isset($options['s'])) { |
70 | 72 | $globalSources = array(); |
71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
72 | - else $globalSources[] = array('host' => $options['s']); |
|
73 | -} elseif (isset($options['source'])) { |
|
73 | + if (isset($options['format'])) { |
|
74 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
75 | + } else { |
|
76 | + $globalSources[] = array('host' => $options['s']); |
|
77 | + } |
|
78 | + } elseif (isset($options['source'])) { |
|
74 | 79 | $globalSources = array(); |
75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
76 | - else $globalSources[] = array('host' => $options['source']); |
|
77 | -} |
|
80 | + if (isset($options['format'])) { |
|
81 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
82 | + } else { |
|
83 | + $globalSources[] = array('host' => $options['source']); |
|
84 | + } |
|
85 | + } |
|
78 | 86 | if (isset($options['aprsserverhost'])) { |
79 | 87 | $globalServerAPRS = TRUE; |
80 | 88 | $globalServerAPRShost = $options['aprsserverhost']; |
81 | 89 | } |
82 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
83 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
84 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
85 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
90 | +if (isset($options['aprsserverport'])) { |
|
91 | + $globalServerAPRSport = $options['aprsserverport']; |
|
92 | +} |
|
93 | +if (isset($options['aprsserverssid'])) { |
|
94 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
95 | +} |
|
96 | +if (isset($options['aprsserverpass'])) { |
|
97 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
98 | +} |
|
99 | +if (isset($options['noaprsserver'])) { |
|
100 | + $globalServerAPRS = FALSE; |
|
101 | +} |
|
86 | 102 | if (isset($options['enable-aircraft'])) { |
87 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
103 | + if ($globalDebug) { |
|
104 | + echo 'Enable Aircraft mode'."\n"; |
|
105 | + } |
|
88 | 106 | $globalAircraft = TRUE; |
89 | 107 | } |
90 | 108 | if (isset($options['disable-aircraft'])) { |
91 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
109 | + if ($globalDebug) { |
|
110 | + echo 'Disable Aircraft mode'."\n"; |
|
111 | + } |
|
92 | 112 | $globalAircraft = FALSE; |
93 | 113 | } |
94 | 114 | if (isset($options['enable-tracker'])) { |
95 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
115 | + if ($globalDebug) { |
|
116 | + echo 'Enable Tracker mode'."\n"; |
|
117 | + } |
|
96 | 118 | $globalTracker = TRUE; |
97 | 119 | } |
98 | 120 | if (isset($options['disable-tracker'])) { |
99 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
121 | + if ($globalDebug) { |
|
122 | + echo 'Disable Tracker mode'."\n"; |
|
123 | + } |
|
100 | 124 | $globalTracker = FALSE; |
101 | 125 | } |
102 | 126 | if (isset($options['enable-marine'])) { |
103 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
127 | + if ($globalDebug) { |
|
128 | + echo 'Enable Marine mode'."\n"; |
|
129 | + } |
|
104 | 130 | $globalMarine = TRUE; |
105 | 131 | } |
106 | 132 | if (isset($options['disable-marine'])) { |
107 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
133 | + if ($globalDebug) { |
|
134 | + echo 'Disable Marine mode'."\n"; |
|
135 | + } |
|
108 | 136 | $globalMarine = FALSE; |
109 | 137 | } |
110 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
111 | -if (isset($options['server'])) $globalServer = TRUE; |
|
112 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
113 | -else $id_source = 1; |
|
138 | +if (isset($options['nodaemon'])) { |
|
139 | + $globalDaemon = FALSE; |
|
140 | +} |
|
141 | +if (isset($options['server'])) { |
|
142 | + $globalServer = TRUE; |
|
143 | +} |
|
144 | +if (isset($options['idsource'])) { |
|
145 | + $id_source = $options['idsource']; |
|
146 | +} else { |
|
147 | + $id_source = 1; |
|
148 | +} |
|
114 | 149 | if (isset($globalServer) && $globalServer) { |
115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
150 | + if ($globalDebug) { |
|
151 | + echo "Using Server Mode\n"; |
|
152 | + } |
|
116 | 153 | $SI=new SpotterServer(); |
117 | 154 | /* |
118 | 155 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
119 | 156 | $SI = new adsb2aprs(); |
120 | 157 | $SI->connect(); |
121 | 158 | */ |
122 | -} else $SI=new SpotterImport($Connection->db); |
|
159 | +} else { |
|
160 | + $SI=new SpotterImport($Connection->db); |
|
161 | +} |
|
123 | 162 | |
124 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
163 | +if (isset($globalTracker) && $globalTracker) { |
|
164 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
165 | +} |
|
125 | 166 | if (isset($globalMarine) && $globalMarine) { |
126 | 167 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
127 | 168 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
128 | 169 | } |
129 | 170 | |
130 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
171 | +if (isset($globalTracker) && $globalTracker) { |
|
172 | + $TI = new TrackerImport($Connection->db); |
|
173 | +} |
|
131 | 174 | if (isset($globalMarine) && $globalMarine) { |
132 | 175 | $AIS = new AIS(); |
133 | 176 | $MI = new MarineImport($Connection->db); |
@@ -152,7 +195,9 @@ discard block |
||
152 | 195 | } |
153 | 196 | |
154 | 197 | // let's try and connect |
155 | -if ($globalDebug) echo "Connecting...\n"; |
|
198 | +if ($globalDebug) { |
|
199 | + echo "Connecting...\n"; |
|
200 | +} |
|
156 | 201 | $use_aprs = false; |
157 | 202 | $aprs_full = false; |
158 | 203 | $reset = 0; |
@@ -161,7 +206,9 @@ discard block |
||
161 | 206 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
162 | 207 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
163 | 208 | $reset++; |
164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
209 | + if ($globalDebug) { |
|
210 | + echo 'Connect to all...'."\n"; |
|
211 | + } |
|
165 | 212 | foreach ($hosts as $id => $value) { |
166 | 213 | $host = $value['host']; |
167 | 214 | $udp = false; |
@@ -172,32 +219,44 @@ discard block |
||
172 | 219 | //$formats[$id] = 'deltadbtxt'; |
173 | 220 | $globalSources[$id]['format'] = 'deltadbtxt'; |
174 | 221 | //$last_exec['deltadbtxt'] = 0; |
175 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
222 | + if ($globalDebug) { |
|
223 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
224 | + } |
|
176 | 225 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
177 | 226 | //$formats[$id] = 'vatsimtxt'; |
178 | 227 | $globalSources[$id]['format'] = 'vatsimtxt'; |
179 | 228 | //$last_exec['vatsimtxt'] = 0; |
180 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
229 | + if ($globalDebug) { |
|
230 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
231 | + } |
|
181 | 232 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
182 | 233 | //$formats[$id] = 'aircraftlistjson'; |
183 | 234 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
184 | 235 | //$last_exec['aircraftlistjson'] = 0; |
185 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
236 | + if ($globalDebug) { |
|
237 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
238 | + } |
|
186 | 239 | } else if (preg_match('/aircraft.json$/i',$host)) { |
187 | 240 | //$formats[$id] = 'aircraftjson'; |
188 | 241 | $globalSources[$id]['format'] = 'aircraftjson'; |
189 | 242 | //$last_exec['aircraftlistjson'] = 0; |
190 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
243 | + if ($globalDebug) { |
|
244 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
245 | + } |
|
191 | 246 | } else if (preg_match('/aircraft$/i',$host)) { |
192 | 247 | //$formats[$id] = 'planefinderclient'; |
193 | 248 | $globalSources[$id]['format'] = 'planefinderclient'; |
194 | 249 | //$last_exec['aircraftlistjson'] = 0; |
195 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
250 | + if ($globalDebug) { |
|
251 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
252 | + } |
|
196 | 253 | } else if (preg_match('/opensky/i',$host)) { |
197 | 254 | //$formats[$id] = 'aircraftlistjson'; |
198 | 255 | $globalSources[$id]['format'] = 'opensky'; |
199 | 256 | //$last_exec['aircraftlistjson'] = 0; |
200 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
257 | + if ($globalDebug) { |
|
258 | + echo "Connect to opensky source (".$host.")...\n"; |
|
259 | + } |
|
201 | 260 | /* |
202 | 261 | // Disabled for now, site change source format |
203 | 262 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -214,7 +273,9 @@ discard block |
||
214 | 273 | //$formats[$id] = 'planeupdatefaa'; |
215 | 274 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
216 | 275 | //$last_exec['planeupdatefaa'] = 0; |
217 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
276 | + if ($globalDebug) { |
|
277 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
278 | + } |
|
218 | 279 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
219 | 280 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
220 | 281 | exit(0); |
@@ -223,37 +284,53 @@ discard block |
||
223 | 284 | //$formats[$id] = 'phpvmacars'; |
224 | 285 | $globalSources[$id]['format'] = 'phpvmacars'; |
225 | 286 | //$last_exec['phpvmacars'] = 0; |
226 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
287 | + if ($globalDebug) { |
|
288 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
289 | + } |
|
227 | 290 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
228 | 291 | //$formats[$id] = 'phpvmacars'; |
229 | 292 | $globalSources[$id]['format'] = 'vaos'; |
230 | 293 | //$last_exec['phpvmacars'] = 0; |
231 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
294 | + if ($globalDebug) { |
|
295 | + echo "Connect to vaos source (".$host.")...\n"; |
|
296 | + } |
|
232 | 297 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
233 | 298 | //$formats[$id] = 'phpvmacars'; |
234 | 299 | $globalSources[$id]['format'] = 'vam'; |
235 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
300 | + if ($globalDebug) { |
|
301 | + echo "Connect to Vam source (".$host.")...\n"; |
|
302 | + } |
|
236 | 303 | } else if (preg_match('/whazzup/i',$host)) { |
237 | 304 | //$formats[$id] = 'whazzup'; |
238 | 305 | $globalSources[$id]['format'] = 'whazzup'; |
239 | 306 | //$last_exec['whazzup'] = 0; |
240 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
307 | + if ($globalDebug) { |
|
308 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
309 | + } |
|
241 | 310 | } else if (preg_match('/blitzortung/i',$host)) { |
242 | 311 | $globalSources[$id]['format'] = 'blitzortung'; |
243 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
312 | + if ($globalDebug) { |
|
313 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
314 | + } |
|
244 | 315 | } else if (preg_match('/airwhere/i',$host)) { |
245 | 316 | $globalSources[$id]['format'] = 'airwhere'; |
246 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
317 | + if ($globalDebug) { |
|
318 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
319 | + } |
|
247 | 320 | } else if (preg_match('/recentpireps/i',$host)) { |
248 | 321 | //$formats[$id] = 'pirepsjson'; |
249 | 322 | $globalSources[$id]['format'] = 'pirepsjson'; |
250 | 323 | //$last_exec['pirepsjson'] = 0; |
251 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
324 | + if ($globalDebug) { |
|
325 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
326 | + } |
|
252 | 327 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
253 | 328 | //$formats[$id] = 'fr24json'; |
254 | 329 | $globalSources[$id]['format'] = 'fr24json'; |
255 | 330 | //$last_exec['fr24json'] = 0; |
256 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
331 | + if ($globalDebug) { |
|
332 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
333 | + } |
|
257 | 334 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
258 | 335 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
259 | 336 | exit(0); |
@@ -262,7 +339,9 @@ discard block |
||
262 | 339 | //$formats[$id] = 'fr24json'; |
263 | 340 | $globalSources[$id]['format'] = 'myshiptracking'; |
264 | 341 | //$last_exec['fr24json'] = 0; |
265 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
342 | + if ($globalDebug) { |
|
343 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
344 | + } |
|
266 | 345 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
267 | 346 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
268 | 347 | exit(0); |
@@ -271,18 +350,28 @@ discard block |
||
271 | 350 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
272 | 351 | //$formats[$id] = 'tsv'; |
273 | 352 | $globalSources[$id]['format'] = 'tsv'; |
274 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
353 | + if ($globalDebug) { |
|
354 | + echo "Connect to tsv source (".$host.")...\n"; |
|
355 | + } |
|
275 | 356 | } |
276 | 357 | } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
277 | 358 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
278 | 359 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
279 | 360 | if ($idf !== false) { |
280 | 361 | $httpfeeds[$id] = $idf; |
281 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
282 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
283 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
284 | - elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
285 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
362 | + if ($globalDebug) { |
|
363 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
364 | + } |
|
365 | + } elseif ($globalDebug) { |
|
366 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
367 | + } |
|
368 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { |
|
369 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
370 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') { |
|
371 | + echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
372 | + } elseif ($globalDebug) { |
|
373 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
374 | + } |
|
286 | 375 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
287 | 376 | $hostport = explode(':',$host); |
288 | 377 | if (isset($hostport[1])) { |
@@ -323,20 +412,29 @@ discard block |
||
323 | 412 | //$formats[$id] = 'beast'; |
324 | 413 | $globalSources[$id]['format'] = 'beast'; |
325 | 414 | //} else $formats[$id] = 'sbs'; |
326 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
415 | + } else { |
|
416 | + $globalSources[$id]['format'] = 'sbs'; |
|
417 | + } |
|
327 | 418 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
328 | 419 | } |
329 | - if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
330 | - elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
420 | + if ($globalDebug && $udp) { |
|
421 | + echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
422 | + } elseif ($globalDebug) { |
|
423 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
424 | + } |
|
331 | 425 | } else { |
332 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
426 | + if ($globalDebug) { |
|
427 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
428 | + } |
|
333 | 429 | sleep(10); |
334 | 430 | connect_all($hosts); |
335 | 431 | } |
336 | 432 | } |
337 | 433 | } |
338 | 434 | } |
339 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
435 | +if (!isset($globalMinFetch)) { |
|
436 | + $globalMinFetch = 15; |
|
437 | +} |
|
340 | 438 | |
341 | 439 | // Initialize all |
342 | 440 | $status = array(); |
@@ -345,13 +443,19 @@ discard block |
||
345 | 443 | $formats = array(); |
346 | 444 | $last_exec = array(); |
347 | 445 | $time = time(); |
348 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
349 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
350 | -else $timeout = 20; |
|
446 | +if (isset($globalSourcesTimeout)) { |
|
447 | + $timeout = $globalSourcesTimeOut; |
|
448 | +} else if (isset($globalSBS1TimeOut)) { |
|
449 | + $timeout = $globalSBS1TimeOut; |
|
450 | +} else { |
|
451 | + $timeout = 20; |
|
452 | +} |
|
351 | 453 | $errno = ''; |
352 | 454 | $errstr=''; |
353 | 455 | |
354 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
456 | +if (!isset($globalDaemon)) { |
|
457 | + $globalDaemon = TRUE; |
|
458 | +} |
|
355 | 459 | /* Initiate connections to all the hosts simultaneously */ |
356 | 460 | //connect_all($hosts); |
357 | 461 | //connect_all($globalSources); |
@@ -380,7 +484,9 @@ discard block |
||
380 | 484 | if (isset($source['format']) && $source['format'] == 'aprs') { |
381 | 485 | $aprs_connect = 0; |
382 | 486 | $use_aprs = true; |
383 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
487 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
488 | + $aprs_full = true; |
|
489 | + } |
|
384 | 490 | break; |
385 | 491 | } |
386 | 492 | } |
@@ -391,25 +497,46 @@ discard block |
||
391 | 497 | $aprs_connect = 0; |
392 | 498 | $aprs_keep = 120; |
393 | 499 | $aprs_last_tx = time(); |
394 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
395 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
396 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
397 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
398 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
399 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
400 | - if ($aprs_full) $aprs_filter = ''; |
|
401 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
402 | - else $aprs_pass = '-1'; |
|
500 | + if (isset($globalAPRSversion)) { |
|
501 | + $aprs_version = $globalAPRSversion; |
|
502 | + } else { |
|
503 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
504 | + } |
|
505 | + if (isset($globalAPRSssid)) { |
|
506 | + $aprs_ssid = $globalAPRSssid; |
|
507 | + } else { |
|
508 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
509 | + } |
|
510 | + if (isset($globalAPRSfilter)) { |
|
511 | + $aprs_filter = $globalAPRSfilter; |
|
512 | + } else { |
|
513 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
514 | + } |
|
515 | + if ($aprs_full) { |
|
516 | + $aprs_filter = ''; |
|
517 | + } |
|
518 | + if (isset($globalAPRSpass)) { |
|
519 | + $aprs_pass = $globalAPRSpass; |
|
520 | + } else { |
|
521 | + $aprs_pass = '-1'; |
|
522 | + } |
|
403 | 523 | |
404 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
405 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
406 | -} |
|
524 | + if ($aprs_filter != '') { |
|
525 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
526 | + } else { |
|
527 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
528 | + } |
|
529 | + } |
|
407 | 530 | |
408 | 531 | // connected - lets do some work |
409 | 532 | //if ($globalDebug) echo "Connected!\n"; |
410 | 533 | sleep(1); |
411 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
412 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
534 | +if ($globalDebug) { |
|
535 | + echo "SCAN MODE \n\n"; |
|
536 | +} |
|
537 | +if (!isset($globalCronEnd)) { |
|
538 | + $globalCronEnd = 60; |
|
539 | +} |
|
413 | 540 | $endtime = time()+$globalCronEnd; |
414 | 541 | $i = 1; |
415 | 542 | $tt = array(); |
@@ -423,22 +550,32 @@ discard block |
||
423 | 550 | |
424 | 551 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
425 | 552 | while ($i > 0) { |
426 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
553 | + if (function_exists('pcntl_fork')) { |
|
554 | + pcntl_signal_dispatch(); |
|
555 | + } |
|
427 | 556 | |
428 | - if (!$globalDaemon) $i = $endtime-time(); |
|
557 | + if (!$globalDaemon) { |
|
558 | + $i = $endtime-time(); |
|
559 | + } |
|
429 | 560 | // Delete old ATC |
430 | 561 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
431 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
562 | + if ($globalDebug) { |
|
563 | + echo 'Delete old ATC...'."\n"; |
|
564 | + } |
|
432 | 565 | $ATC->deleteOldATC(); |
433 | 566 | } |
434 | 567 | |
435 | 568 | if (count($last_exec) == count($globalSources)) { |
436 | 569 | $max = $globalMinFetch; |
437 | 570 | foreach ($last_exec as $last) { |
438 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
571 | + if ((time() - $last['last']) < $max) { |
|
572 | + $max = time() - $last['last']; |
|
573 | + } |
|
439 | 574 | } |
440 | 575 | if ($max < $globalMinFetch) { |
441 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
576 | + if ($globalDebug) { |
|
577 | + echo 'Sleeping...'."\n"; |
|
578 | + } |
|
442 | 579 | sleep($globalMinFetch-$max+2); |
443 | 580 | } |
444 | 581 | } |
@@ -448,7 +585,9 @@ discard block |
||
448 | 585 | foreach ($globalSources as $id => $value) { |
449 | 586 | date_default_timezone_set('UTC'); |
450 | 587 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
451 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
588 | + if (!isset($last_exec[$id]['last'])) { |
|
589 | + $last_exec[$id]['last'] = 0; |
|
590 | + } |
|
452 | 591 | if ($value['format'] === 'deltadbtxt' && |
453 | 592 | ( |
454 | 593 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -457,7 +596,9 @@ discard block |
||
457 | 596 | ) { |
458 | 597 | //$buffer = $Common->getData($hosts[$id]); |
459 | 598 | $buffer = $Common->getData($value['host']); |
460 | - if ($buffer != '') $reset = 0; |
|
599 | + if ($buffer != '') { |
|
600 | + $reset = 0; |
|
601 | + } |
|
461 | 602 | $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
462 | 603 | $buffer = explode('\n', $buffer); |
463 | 604 | foreach ($buffer as $line) { |
@@ -466,20 +607,41 @@ discard block |
||
466 | 607 | $data = array(); |
467 | 608 | $data['hex'] = $line[1]; // hex |
468 | 609 | $data['ident'] = $line[2]; // ident |
469 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
470 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
471 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
472 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
473 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
610 | + if (isset($line[3])) { |
|
611 | + $data['altitude'] = $line[3]; |
|
612 | + } |
|
613 | + // altitude |
|
614 | + if (isset($line[4])) { |
|
615 | + $data['speed'] = $line[4]; |
|
616 | + } |
|
617 | + // speed |
|
618 | + if (isset($line[5])) { |
|
619 | + $data['heading'] = $line[5]; |
|
620 | + } |
|
621 | + // heading |
|
622 | + if (isset($line[6])) { |
|
623 | + $data['latitude'] = $line[6]; |
|
624 | + } |
|
625 | + // lat |
|
626 | + if (isset($line[7])) { |
|
627 | + $data['longitude'] = $line[7]; |
|
628 | + } |
|
629 | + // long |
|
474 | 630 | $data['verticalrate'] = ''; // vertical rate |
475 | 631 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
476 | 632 | $data['emergency'] = ''; // emergency |
477 | 633 | $data['datetime'] = date('Y-m-d H:i:s'); |
478 | 634 | $data['format_source'] = 'deltadbtxt'; |
479 | 635 | $data['id_source'] = $id_source; |
480 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
481 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
482 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
636 | + if (isset($value['name']) && $value['name'] != '') { |
|
637 | + $data['source_name'] = $value['name']; |
|
638 | + } |
|
639 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
640 | + $data['noarchive'] = true; |
|
641 | + } |
|
642 | + if (isset($value['sourcestats'])) { |
|
643 | + $data['sourcestats'] = $value['sourcestats']; |
|
644 | + } |
|
483 | 645 | $SI->add($data); |
484 | 646 | unset($data); |
485 | 647 | } |
@@ -514,11 +676,20 @@ discard block |
||
514 | 676 | $data['format_source'] = 'radarcapejson'; |
515 | 677 | $data['id_source'] = $id_source; |
516 | 678 | if (isset($value['name']) && $value['name'] != '') { |
517 | - if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
518 | - else $data['source_name'] = $value['name']; |
|
519 | - } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
520 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
521 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
679 | + if (isset($line['src']) && !$line['src'] == 'M') { |
|
680 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
681 | + } else { |
|
682 | + $data['source_name'] = $value['name']; |
|
683 | + } |
|
684 | + } elseif (isset($line['src']) && $line['src'] == 'M') { |
|
685 | + $data['source_name'] = 'MLAT'; |
|
686 | + } |
|
687 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
688 | + $data['noarchive'] = true; |
|
689 | + } |
|
690 | + if (isset($value['sourcestats'])) { |
|
691 | + $data['sourcestats'] = $value['sourcestats']; |
|
692 | + } |
|
522 | 693 | |
523 | 694 | $SI->add($data); |
524 | 695 | unset($data); |
@@ -534,7 +705,9 @@ discard block |
||
534 | 705 | date_default_timezone_set('CET'); |
535 | 706 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
536 | 707 | date_default_timezone_set('UTC'); |
537 | - if ($buffer != '') $reset = 0; |
|
708 | + if ($buffer != '') { |
|
709 | + $reset = 0; |
|
710 | + } |
|
538 | 711 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
539 | 712 | $buffer = explode('\n',$buffer); |
540 | 713 | foreach ($buffer as $line) { |
@@ -543,18 +716,42 @@ discard block |
||
543 | 716 | $add = false; |
544 | 717 | $ais_data = $AIS->parse_line(trim($line)); |
545 | 718 | $data = array(); |
546 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
547 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
548 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
549 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
550 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
551 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
552 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
553 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
554 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
555 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
556 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
557 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
719 | + if (isset($ais_data['ident'])) { |
|
720 | + $data['ident'] = $ais_data['ident']; |
|
721 | + } |
|
722 | + if (isset($ais_data['mmsi'])) { |
|
723 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
724 | + } |
|
725 | + if (isset($ais_data['speed'])) { |
|
726 | + $data['speed'] = $ais_data['speed']; |
|
727 | + } |
|
728 | + if (isset($ais_data['heading'])) { |
|
729 | + $data['heading'] = $ais_data['heading']; |
|
730 | + } |
|
731 | + if (isset($ais_data['latitude'])) { |
|
732 | + $data['latitude'] = $ais_data['latitude']; |
|
733 | + } |
|
734 | + if (isset($ais_data['longitude'])) { |
|
735 | + $data['longitude'] = $ais_data['longitude']; |
|
736 | + } |
|
737 | + if (isset($ais_data['status'])) { |
|
738 | + $data['status'] = $ais_data['status']; |
|
739 | + } |
|
740 | + if (isset($ais_data['statusid'])) { |
|
741 | + $data['status_id'] = $ais_data['statusid']; |
|
742 | + } |
|
743 | + if (isset($ais_data['type'])) { |
|
744 | + $data['type'] = $ais_data['type']; |
|
745 | + } |
|
746 | + if (isset($ais_data['typeid'])) { |
|
747 | + $data['type_id'] = $ais_data['typeid']; |
|
748 | + } |
|
749 | + if (isset($ais_data['imo'])) { |
|
750 | + $data['imo'] = $ais_data['imo']; |
|
751 | + } |
|
752 | + if (isset($ais_data['callsign'])) { |
|
753 | + $data['callsign'] = $ais_data['callsign']; |
|
754 | + } |
|
558 | 755 | if (isset($ais_data['timestamp'])) { |
559 | 756 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
560 | 757 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -568,8 +765,12 @@ discard block |
||
568 | 765 | $data['format_source'] = 'aisnmeatxt'; |
569 | 766 | $data['id_source'] = $id_source; |
570 | 767 | //print_r($data); |
571 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
572 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
768 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
769 | + $data['noarchive'] = true; |
|
770 | + } |
|
771 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
772 | + $MI->add($data); |
|
773 | + } |
|
573 | 774 | unset($data); |
574 | 775 | } |
575 | 776 | } |
@@ -592,20 +793,48 @@ discard block |
||
592 | 793 | if ($line != '') { |
593 | 794 | $ais_data = $AIS->parse_line(trim($line)); |
594 | 795 | $data = array(); |
595 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
596 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
597 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
598 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
599 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
600 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
601 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
602 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
603 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
604 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
605 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
606 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
607 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
608 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
796 | + if (isset($ais_data['ident'])) { |
|
797 | + $data['ident'] = $ais_data['ident']; |
|
798 | + } |
|
799 | + if (isset($ais_data['mmsi'])) { |
|
800 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
801 | + } |
|
802 | + if (isset($ais_data['speed'])) { |
|
803 | + $data['speed'] = $ais_data['speed']; |
|
804 | + } |
|
805 | + if (isset($ais_data['heading'])) { |
|
806 | + $data['heading'] = $ais_data['heading']; |
|
807 | + } |
|
808 | + if (isset($ais_data['latitude'])) { |
|
809 | + $data['latitude'] = $ais_data['latitude']; |
|
810 | + } |
|
811 | + if (isset($ais_data['longitude'])) { |
|
812 | + $data['longitude'] = $ais_data['longitude']; |
|
813 | + } |
|
814 | + if (isset($ais_data['status'])) { |
|
815 | + $data['status'] = $ais_data['status']; |
|
816 | + } |
|
817 | + if (isset($ais_data['statusid'])) { |
|
818 | + $data['status_id'] = $ais_data['statusid']; |
|
819 | + } |
|
820 | + if (isset($ais_data['type'])) { |
|
821 | + $data['type'] = $ais_data['type']; |
|
822 | + } |
|
823 | + if (isset($ais_data['typeid'])) { |
|
824 | + $data['type_id'] = $ais_data['typeid']; |
|
825 | + } |
|
826 | + if (isset($ais_data['imo'])) { |
|
827 | + $data['imo'] = $ais_data['imo']; |
|
828 | + } |
|
829 | + if (isset($ais_data['callsign'])) { |
|
830 | + $data['callsign'] = $ais_data['callsign']; |
|
831 | + } |
|
832 | + if (isset($ais_data['destination'])) { |
|
833 | + $data['arrival_code'] = $ais_data['destination']; |
|
834 | + } |
|
835 | + if (isset($ais_data['eta_ts'])) { |
|
836 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
837 | + } |
|
609 | 838 | if (isset($ais_data['timestamp'])) { |
610 | 839 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
611 | 840 | } else { |
@@ -613,18 +842,27 @@ discard block |
||
613 | 842 | } |
614 | 843 | $data['format_source'] = 'aisnmeahttp'; |
615 | 844 | $data['id_source'] = $id_source; |
616 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
617 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
845 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
846 | + $data['noarchive'] = true; |
|
847 | + } |
|
848 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
849 | + $MI->add($data); |
|
850 | + } |
|
618 | 851 | unset($data); |
619 | 852 | } |
620 | 853 | } |
621 | 854 | } |
622 | 855 | } else { |
623 | 856 | $format = $value['format']; |
624 | - if (isset($tt[$format])) $tt[$format]++; |
|
625 | - else $tt[$format] = 0; |
|
857 | + if (isset($tt[$format])) { |
|
858 | + $tt[$format]++; |
|
859 | + } else { |
|
860 | + $tt[$format] = 0; |
|
861 | + } |
|
626 | 862 | if ($tt[$format] > 30) { |
627 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
863 | + if ($globalDebug) { |
|
864 | + echo 'Reconnect...'."\n"; |
|
865 | + } |
|
628 | 866 | sleep(2); |
629 | 867 | //$sourceeen[] = $value; |
630 | 868 | //connect_all($sourceeen); |
@@ -660,12 +898,18 @@ discard block |
||
660 | 898 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
661 | 899 | //$data['type_id'] = $line['TYPE']; |
662 | 900 | $data['imo'] = $line['IMO']; |
663 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
664 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
901 | + if ($line['DEST'] != '') { |
|
902 | + $data['arrival_code'] = $line['DEST']; |
|
903 | + } |
|
904 | + if ($line['ARV'] != '') { |
|
905 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
906 | + } |
|
665 | 907 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
666 | 908 | $data['format_source'] = 'myshiptracking'; |
667 | 909 | $data['id_source'] = $id_source; |
668 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
910 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
911 | + $data['noarchive'] = true; |
|
912 | + } |
|
669 | 913 | $MI->add($data); |
670 | 914 | unset($data); |
671 | 915 | } |
@@ -690,7 +934,9 @@ discard block |
||
690 | 934 | $data['callsign'] = $line['callsign']; |
691 | 935 | $data['mmsi'] = substr($line['mmsi'],-9); |
692 | 936 | $data['speed'] = $line['sog']; |
693 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
937 | + if ($line['heading'] != '511') { |
|
938 | + $data['heading'] = $line['heading']; |
|
939 | + } |
|
694 | 940 | $data['latitude'] = $line['latitude']; |
695 | 941 | $data['longitude'] = $line['longitude']; |
696 | 942 | $data['type_id'] = $line['shiptype']; |
@@ -698,7 +944,9 @@ discard block |
||
698 | 944 | $data['datetime'] = $line['time']; |
699 | 945 | $data['format_source'] = 'boatbeaconapp'; |
700 | 946 | $data['id_source'] = $id_source; |
701 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
947 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
948 | + $data['noarchive'] = true; |
|
949 | + } |
|
702 | 950 | $MI->add($data); |
703 | 951 | unset($data); |
704 | 952 | } |
@@ -720,22 +968,44 @@ discard block |
||
720 | 968 | foreach ($all_data['features'] as $line) { |
721 | 969 | print_r($line); |
722 | 970 | $data = array(); |
723 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
724 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
725 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
726 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
727 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
728 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
971 | + if (isset($line['properties']['name'])) { |
|
972 | + $data['ident'] = $line['properties']['name']; |
|
973 | + } |
|
974 | + if (isset($line['properties']['callsign'])) { |
|
975 | + $data['callsign'] = $line['properties']['callsign']; |
|
976 | + } |
|
977 | + if (isset($line['properties']['mmsi'])) { |
|
978 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
979 | + } |
|
980 | + if (isset($line['properties']['imo'])) { |
|
981 | + $data['imo'] = $line['properties']['imo']; |
|
982 | + } |
|
983 | + if (isset($line['properties']['speed'])) { |
|
984 | + $data['speed'] = $line['properties']['speed']; |
|
985 | + } |
|
986 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
987 | + $data['heading'] = $line['properties']['heading']; |
|
988 | + } |
|
729 | 989 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
730 | 990 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
731 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
732 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
733 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
991 | + if (isset($line['properties']['vesselType'])) { |
|
992 | + $data['type'] = $line['properties']['vesselType']; |
|
993 | + } |
|
994 | + if (isset($line['properties']['destination'])) { |
|
995 | + $data['arrival_code'] = $line['properties']['destination']; |
|
996 | + } |
|
997 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
998 | + $data['arrival_date'] = $line['properties']['eta']; |
|
999 | + } |
|
734 | 1000 | $data['format_source'] = 'boatnerd'; |
735 | 1001 | $data['id_source'] = $id_source; |
736 | 1002 | $data['datetime'] = date('Y-m-d H:i:s'); |
737 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
738 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
1003 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1004 | + $data['noarchive'] = true; |
|
1005 | + } |
|
1006 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
1007 | + $MI->add($data); |
|
1008 | + } |
|
739 | 1009 | unset($data); |
740 | 1010 | } |
741 | 1011 | } |
@@ -748,11 +1018,17 @@ discard block |
||
748 | 1018 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
749 | 1019 | ) |
750 | 1020 | ) { |
751 | - if ($globalDebug) echo 'download...'; |
|
1021 | + if ($globalDebug) { |
|
1022 | + echo 'download...'; |
|
1023 | + } |
|
752 | 1024 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
753 | - if ($globalDebug) echo 'done !'."\n"; |
|
1025 | + if ($globalDebug) { |
|
1026 | + echo 'done !'."\n"; |
|
1027 | + } |
|
754 | 1028 | // FIXME: Need more work |
755 | - if ($buffer != '') $reset = 0; |
|
1029 | + if ($buffer != '') { |
|
1030 | + $reset = 0; |
|
1031 | + } |
|
756 | 1032 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
757 | 1033 | $buffer = explode('\n',$buffer); |
758 | 1034 | foreach ($buffer as $line) { |
@@ -778,7 +1054,9 @@ discard block |
||
778 | 1054 | //$data['etaTime'] = substr($line,135,5); |
779 | 1055 | $data['format_source'] = 'shipplotter'; |
780 | 1056 | $data['id_source'] = $id_source; |
781 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1057 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1058 | + $data['noarchive'] = true; |
|
1059 | + } |
|
782 | 1060 | //print_r($data); |
783 | 1061 | //echo 'Add...'."\n"; |
784 | 1062 | $MI->add($data); |
@@ -800,11 +1078,17 @@ discard block |
||
800 | 1078 | } |
801 | 1079 | } |
802 | 1080 | |
803 | - if ($globalDebug) echo '! Download... '; |
|
1081 | + if ($globalDebug) { |
|
1082 | + echo '! Download... '; |
|
1083 | + } |
|
804 | 1084 | for ($i =0; $i <= 1; $i++) { |
805 | - if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
1085 | + if ($globalDebug) { |
|
1086 | + echo 'Racetype: '.$i.' '; |
|
1087 | + } |
|
806 | 1088 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
807 | - if ($globalDebug) echo 'done'."\n"; |
|
1089 | + if ($globalDebug) { |
|
1090 | + echo 'done'."\n"; |
|
1091 | + } |
|
808 | 1092 | if ($buffer != '') { |
809 | 1093 | $all_data = json_decode($buffer,true); |
810 | 1094 | if (isset($all_data['missions'])) { |
@@ -815,7 +1099,9 @@ discard block |
||
815 | 1099 | if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { |
816 | 1100 | $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
817 | 1101 | sleep(30); |
818 | - } else $racebuffer = ''; |
|
1102 | + } else { |
|
1103 | + $racebuffer = ''; |
|
1104 | + } |
|
819 | 1105 | $bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
820 | 1106 | } else { |
821 | 1107 | $bufferm = ''; |
@@ -879,7 +1165,9 @@ discard block |
||
879 | 1165 | $data['captain_id'] = $sail['usrnr']; |
880 | 1166 | $data['captain_name'] = $sail['usrname']; |
881 | 1167 | $data['race_id'] = $sail['misnr']; |
882 | - if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank']; |
|
1168 | + if ($sail['rank'] != 'DNF') { |
|
1169 | + $data['race_rank'] = $sail['rank']; |
|
1170 | + } |
|
883 | 1171 | $data['race_time'] = $sail['racetime']; |
884 | 1172 | if ($mission_user != '') { |
885 | 1173 | $data['race_name'] = $mission_name.' ('.$mission_user.')'; |
@@ -889,7 +1177,9 @@ discard block |
||
889 | 1177 | //$data['callsign'] = trim(substr($line,100,7); |
890 | 1178 | $data['format_source'] = 'sailawayfull'; |
891 | 1179 | $data['id_source'] = $id_source; |
892 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1180 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1181 | + $data['noarchive'] = true; |
|
1182 | + } |
|
893 | 1183 | //print_r($data); |
894 | 1184 | //if ($data['race_id'] == '48') print_r($data); |
895 | 1185 | //echo 'Add...'."\n"; |
@@ -927,10 +1217,16 @@ discard block |
||
927 | 1217 | echo 'Sailaway API key MUST be defined'; |
928 | 1218 | exit(0); |
929 | 1219 | } |
930 | - if ($globalDebug) echo '! Download... '; |
|
1220 | + if ($globalDebug) { |
|
1221 | + echo '! Download... '; |
|
1222 | + } |
|
931 | 1223 | $sailawayoption = array('key' => $globalSailaway['key']); |
932 | - if (isset($globalSailaway['usrnr'])) $sailwayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
933 | - if (isset($globalSailaway['ubtnr'])) $sailwayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
1224 | + if (isset($globalSailaway['usrnr'])) { |
|
1225 | + $sailwayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
1226 | + } |
|
1227 | + if (isset($globalSailaway['ubtnr'])) { |
|
1228 | + $sailwayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
1229 | + } |
|
934 | 1230 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
935 | 1231 | if ($buffer != '') { |
936 | 1232 | $data = json_decode($buffer,true); |
@@ -940,7 +1236,9 @@ discard block |
||
940 | 1236 | $data = array(); |
941 | 1237 | $data['id'] = $sail['ubtnr']; |
942 | 1238 | $data['datetime'] = date('Y-m-d H:i:s'); |
943 | - if ($sail['online'] == '1') $data['last_update'] = date('Y-m-d H:i:s'); |
|
1239 | + if ($sail['online'] == '1') { |
|
1240 | + $data['last_update'] = date('Y-m-d H:i:s'); |
|
1241 | + } |
|
944 | 1242 | $data['latitude'] = $sail['ubtlat']; |
945 | 1243 | $data['longitude'] = $sail['ubtlon']; |
946 | 1244 | $data['type_id'] = 36; |
@@ -949,16 +1247,24 @@ discard block |
||
949 | 1247 | $data['captain_name'] = $sail['usrname']; |
950 | 1248 | $allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat'); |
951 | 1249 | $boattype = $sail['ubtbtpnr']; |
952 | - if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1]; |
|
1250 | + if (isset($allboats[$boattype-1])) { |
|
1251 | + $data['type'] = $allboats[$boattype-1]; |
|
1252 | + } |
|
953 | 1253 | $data['speed'] = round($sail['ubtspeed']*3.6,2); |
954 | 1254 | $data['format_source'] = 'sailaway'; |
955 | 1255 | $data['id_source'] = $id_source; |
956 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1256 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1257 | + $data['noarchive'] = true; |
|
1258 | + } |
|
957 | 1259 | $MI->add($data); |
958 | 1260 | unset($data); |
959 | 1261 | } |
960 | - } elseif ($globalDebug) echo 'Error in JSON parsing'; |
|
961 | - } elseif ($globalDebug) echo 'Empty result !'."\n"; |
|
1262 | + } elseif ($globalDebug) { |
|
1263 | + echo 'Error in JSON parsing'; |
|
1264 | + } |
|
1265 | + } elseif ($globalDebug) { |
|
1266 | + echo 'Empty result !'."\n"; |
|
1267 | + } |
|
962 | 1268 | $last_exec[$id]['last'] = time(); |
963 | 1269 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
964 | 1270 | } elseif ( |
@@ -986,16 +1292,28 @@ discard block |
||
986 | 1292 | $line = explode(':', $line); |
987 | 1293 | if (count($line) > 30 && $line[0] != 'callsign') { |
988 | 1294 | $data = array(); |
989 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
990 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1295 | + if (isset($line[37]) && $line[37] != '') { |
|
1296 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
1297 | + } else { |
|
1298 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1299 | + } |
|
991 | 1300 | $data['pilot_id'] = $line[1]; |
992 | 1301 | $data['pilot_name'] = $line[2]; |
993 | 1302 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
994 | 1303 | $data['ident'] = $line[0]; // ident |
995 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
1304 | + if ($line[7] != '' && $line[7] != 0) { |
|
1305 | + $data['altitude'] = $line[7]; |
|
1306 | + } |
|
1307 | + // altitude |
|
996 | 1308 | $data['speed'] = $line[8]; // speed |
997 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
998 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
1309 | + if (isset($line[45])) { |
|
1310 | + $data['heading'] = $line[45]; |
|
1311 | + } |
|
1312 | + // heading |
|
1313 | + elseif (isset($line[38])) { |
|
1314 | + $data['heading'] = $line[38]; |
|
1315 | + } |
|
1316 | + // heading |
|
999 | 1317 | $data['latitude'] = $line[5]; // lat |
1000 | 1318 | $data['longitude'] = $line[6]; // long |
1001 | 1319 | $data['verticalrate'] = ''; // vertical rate |
@@ -1011,7 +1329,9 @@ discard block |
||
1011 | 1329 | $data['frequency'] = $line[4]; |
1012 | 1330 | $data['type'] = $line[18]; |
1013 | 1331 | $data['range'] = $line[19]; |
1014 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
1332 | + if (isset($line[35])) { |
|
1333 | + $data['info'] = $line[35]; |
|
1334 | + } |
|
1015 | 1335 | $data['id_source'] = $id_source; |
1016 | 1336 | //$data['arrival_airport_time'] = ; |
1017 | 1337 | if ($line[9] != '') { |
@@ -1025,27 +1345,47 @@ discard block |
||
1025 | 1345 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
1026 | 1346 | */ |
1027 | 1347 | $data['format_source'] = $value['format']; |
1028 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1029 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1030 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
1031 | - elseif ($line[3] === 'ATC') { |
|
1348 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1349 | + $data['noarchive'] = true; |
|
1350 | + } |
|
1351 | + if (isset($value['name']) && $value['name'] != '') { |
|
1352 | + $data['source_name'] = $value['name']; |
|
1353 | + } |
|
1354 | + if ($line[3] === 'PILOT') { |
|
1355 | + $SI->add($data); |
|
1356 | + } elseif ($line[3] === 'ATC') { |
|
1032 | 1357 | //print_r($data); |
1033 | 1358 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1034 | 1359 | $data['info'] = str_replace('&sect;','',$data['info']); |
1035 | 1360 | $typec = substr($data['ident'],-3); |
1036 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
1037 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
1038 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
1039 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
1040 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
1041 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
1042 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1043 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1044 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
1045 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
1361 | + if ($typec === 'APP') { |
|
1362 | + $data['type'] = 'Approach'; |
|
1363 | + } elseif ($typec === 'TWR') { |
|
1364 | + $data['type'] = 'Tower'; |
|
1365 | + } elseif ($typec === 'OBS') { |
|
1366 | + $data['type'] = 'Observer'; |
|
1367 | + } elseif ($typec === 'GND') { |
|
1368 | + $data['type'] = 'Ground'; |
|
1369 | + } elseif ($typec === 'DEL') { |
|
1370 | + $data['type'] = 'Delivery'; |
|
1371 | + } elseif ($typec === 'DEP') { |
|
1372 | + $data['type'] = 'Departure'; |
|
1373 | + } elseif ($typec === 'FSS') { |
|
1374 | + $data['type'] = 'Flight Service Station'; |
|
1375 | + } elseif ($typec === 'CTR') { |
|
1376 | + $data['type'] = 'Control Radar or Centre'; |
|
1377 | + } elseif ($data['type'] === '') { |
|
1378 | + $data['type'] = 'Observer'; |
|
1379 | + } |
|
1380 | + if (!isset($data['source_name'])) { |
|
1381 | + $data['source_name'] = ''; |
|
1382 | + } |
|
1046 | 1383 | if (isset($ATC)) { |
1047 | - 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']); |
|
1048 | - 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']); |
|
1384 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1385 | + 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']); |
|
1386 | + } else { |
|
1387 | + 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']); |
|
1388 | + } |
|
1049 | 1389 | } |
1050 | 1390 | } |
1051 | 1391 | unset($data); |
@@ -1072,14 +1412,20 @@ discard block |
||
1072 | 1412 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
1073 | 1413 | $data['latitude'] = (float)$line['pktLatitude']; |
1074 | 1414 | $data['longitude'] = (float)$line['pktLongitude']; |
1075 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
1076 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1415 | + if ((float)$line['pktTrack'] != 0) { |
|
1416 | + $data['heading'] = (float)$line['pktTrack']; |
|
1417 | + } |
|
1418 | + if ((int)$line['pktSpeed'] != 0) { |
|
1419 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1420 | + } |
|
1077 | 1421 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
1078 | 1422 | $data['altitude_relative'] = 'AMSL'; |
1079 | 1423 | $data['pilot_id'] = (int)$line['pktPilotID']; |
1080 | 1424 | $data['aircraft_icao'] = 'PARAGLIDER'; |
1081 | 1425 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
1082 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1426 | + if (isset($pilot_data[4])) { |
|
1427 | + $data['pilot_name'] = $pilot_data[4]; |
|
1428 | + } |
|
1083 | 1429 | $data['format_source'] = $value['format']; |
1084 | 1430 | $SI->add($data); |
1085 | 1431 | unset($data); |
@@ -1127,25 +1473,59 @@ discard block |
||
1127 | 1473 | foreach ($all_data['acList'] as $line) { |
1128 | 1474 | $data = array(); |
1129 | 1475 | $data['hex'] = $line['Icao']; // hex |
1130 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1131 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1132 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1133 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1134 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1135 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1476 | + if (isset($line['Call'])) { |
|
1477 | + $data['ident'] = $line['Call']; |
|
1478 | + } |
|
1479 | + // ident |
|
1480 | + if (isset($line['Alt'])) { |
|
1481 | + $data['altitude'] = $line['Alt']; |
|
1482 | + } |
|
1483 | + // altitude |
|
1484 | + if (isset($line['Spd'])) { |
|
1485 | + $data['speed'] = $line['Spd']; |
|
1486 | + } |
|
1487 | + // speed |
|
1488 | + if (isset($line['Trak'])) { |
|
1489 | + $data['heading'] = $line['Trak']; |
|
1490 | + } |
|
1491 | + // heading |
|
1492 | + if (isset($line['Lat'])) { |
|
1493 | + $data['latitude'] = $line['Lat']; |
|
1494 | + } |
|
1495 | + // lat |
|
1496 | + if (isset($line['Long'])) { |
|
1497 | + $data['longitude'] = $line['Long']; |
|
1498 | + } |
|
1499 | + // long |
|
1136 | 1500 | //$data['verticalrate'] = $line['']; // verticale rate |
1137 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1501 | + if (isset($line['Sqk'])) { |
|
1502 | + $data['squawk'] = $line['Sqk']; |
|
1503 | + } |
|
1504 | + // squawk |
|
1138 | 1505 | $data['emergency'] = ''; // emergency |
1139 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1140 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1141 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1506 | + if (isset($line['Reg'])) { |
|
1507 | + $data['registration'] = $line['Reg']; |
|
1508 | + } |
|
1509 | + if (isset($line['PosTime'])) { |
|
1510 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1511 | + } else { |
|
1512 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1513 | + } |
|
1142 | 1514 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1143 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1515 | + if (isset($line['Type'])) { |
|
1516 | + $data['aircraft_icao'] = $line['Type']; |
|
1517 | + } |
|
1144 | 1518 | $data['format_source'] = 'aircraftlistjson'; |
1145 | 1519 | $data['id_source'] = $id_source; |
1146 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1147 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1148 | - if (isset($data['latitude'])) $SI->add($data); |
|
1520 | + if (isset($value['name']) && $value['name'] != '') { |
|
1521 | + $data['source_name'] = $value['name']; |
|
1522 | + } |
|
1523 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1524 | + $data['noarchive'] = true; |
|
1525 | + } |
|
1526 | + if (isset($data['latitude'])) { |
|
1527 | + $SI->add($data); |
|
1528 | + } |
|
1149 | 1529 | unset($data); |
1150 | 1530 | } |
1151 | 1531 | } elseif (is_array($all_data)) { |
@@ -1162,17 +1542,26 @@ discard block |
||
1162 | 1542 | $data['verticalrate'] = $line['vrt']; // verticale rate |
1163 | 1543 | $data['squawk'] = $line['squawk']; // squawk |
1164 | 1544 | $data['emergency'] = ''; // emergency |
1165 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1166 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1545 | + if (isset($line['PosTime'])) { |
|
1546 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1547 | + } else { |
|
1548 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1549 | + } |
|
1167 | 1550 | $data['format_source'] = 'aircraftlistjson'; |
1168 | 1551 | $data['id_source'] = $id_source; |
1169 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1170 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1552 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1553 | + $data['noarchive'] = true; |
|
1554 | + } |
|
1555 | + if (isset($value['name']) && $value['name'] != '') { |
|
1556 | + $data['source_name'] = $value['name']; |
|
1557 | + } |
|
1171 | 1558 | $SI->add($data); |
1172 | 1559 | unset($data); |
1173 | 1560 | } |
1174 | 1561 | } |
1175 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1562 | + } elseif ($globalDebug) { |
|
1563 | + echo 'No data'."\n"; |
|
1564 | + } |
|
1176 | 1565 | //$last_exec['aircraftlistjson'] = time(); |
1177 | 1566 | $last_exec[$id]['last'] = time(); |
1178 | 1567 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -1208,8 +1597,12 @@ discard block |
||
1208 | 1597 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
1209 | 1598 | $data['format_source'] = 'planeupdatefaa'; |
1210 | 1599 | $data['id_source'] = $id_source; |
1211 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1212 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1600 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1601 | + $data['noarchive'] = true; |
|
1602 | + } |
|
1603 | + if (isset($value['name']) && $value['name'] != '') { |
|
1604 | + $data['source_name'] = $value['name']; |
|
1605 | + } |
|
1213 | 1606 | $SI->add($data); |
1214 | 1607 | unset($data); |
1215 | 1608 | } |
@@ -1243,7 +1636,9 @@ discard block |
||
1243 | 1636 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
1244 | 1637 | $data['format_source'] = 'opensky'; |
1245 | 1638 | $data['id_source'] = $id_source; |
1246 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1639 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1640 | + $data['noarchive'] = true; |
|
1641 | + } |
|
1247 | 1642 | $SI->add($data); |
1248 | 1643 | unset($data); |
1249 | 1644 | } |
@@ -1263,15 +1658,42 @@ discard block |
||
1263 | 1658 | foreach ($all_data['aircraft'] as $key => $line) { |
1264 | 1659 | $data = array(); |
1265 | 1660 | // add support for ground vehicule with ~ in front of hex |
1266 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1267 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1268 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1269 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1270 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1271 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1272 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1273 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1274 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1661 | + if (isset($line['hex'])) { |
|
1662 | + $data['hex'] = $line['hex']; |
|
1663 | + } |
|
1664 | + // hex |
|
1665 | + if (isset($line['flight'])) { |
|
1666 | + $data['ident'] = trim($line['flight']); |
|
1667 | + } |
|
1668 | + // ident |
|
1669 | + if (isset($line['altitude'])) { |
|
1670 | + $data['altitude'] = $line['altitude']; |
|
1671 | + } |
|
1672 | + // altitude |
|
1673 | + if (isset($line['speed'])) { |
|
1674 | + $data['speed'] = $line['speed']; |
|
1675 | + } |
|
1676 | + // speed |
|
1677 | + if (isset($line['track'])) { |
|
1678 | + $data['heading'] = $line['track']; |
|
1679 | + } |
|
1680 | + // heading |
|
1681 | + if (isset($line['lat'])) { |
|
1682 | + $data['latitude'] = $line['lat']; |
|
1683 | + } |
|
1684 | + // lat |
|
1685 | + if (isset($line['lon'])) { |
|
1686 | + $data['longitude'] = $line['lon']; |
|
1687 | + } |
|
1688 | + // long |
|
1689 | + if (isset($line['vert_rate'])) { |
|
1690 | + $data['verticalrate'] = $line['vert_rate']; |
|
1691 | + } |
|
1692 | + // verticale rate |
|
1693 | + if (isset($line['squawk'])) { |
|
1694 | + $data['squawk'] = $line['squawk']; |
|
1695 | + } |
|
1696 | + // squawk |
|
1275 | 1697 | //$data['emergency'] = ''; // emergency |
1276 | 1698 | //$data['registration'] = $line[2]; |
1277 | 1699 | //$data['aircraft_icao'] = $line[0]; |
@@ -1279,10 +1701,17 @@ discard block |
||
1279 | 1701 | $data['format_source'] = 'aircraftjson'; |
1280 | 1702 | $data['id_source'] = $id_source; |
1281 | 1703 | if (isset($value['name']) && $value['name'] != '') { |
1282 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1283 | - else $data['source_name'] = $value['name']; |
|
1284 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1285 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1704 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1705 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
1706 | + } else { |
|
1707 | + $data['source_name'] = $value['name']; |
|
1708 | + } |
|
1709 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1710 | + $data['source_name'] = 'MLAT'; |
|
1711 | + } |
|
1712 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1713 | + $data['noarchive'] = true; |
|
1714 | + } |
|
1286 | 1715 | $SI->add($data); |
1287 | 1716 | unset($data); |
1288 | 1717 | } |
@@ -1302,22 +1731,54 @@ discard block |
||
1302 | 1731 | foreach ($all_data['aircraft'] as $key => $line) { |
1303 | 1732 | $data = array(); |
1304 | 1733 | $data['hex'] = $key; // hex |
1305 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1306 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1307 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1308 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1309 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1310 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1311 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1312 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1734 | + if (isset($line['callsign'])) { |
|
1735 | + $data['ident'] = trim($line['callsign']); |
|
1736 | + } |
|
1737 | + // ident |
|
1738 | + if (isset($line['altitude'])) { |
|
1739 | + $data['altitude'] = $line['altitude']; |
|
1740 | + } |
|
1741 | + // altitude |
|
1742 | + if (isset($line['speed'])) { |
|
1743 | + $data['speed'] = $line['speed']; |
|
1744 | + } |
|
1745 | + // speed |
|
1746 | + if (isset($line['heading'])) { |
|
1747 | + $data['heading'] = $line['heading']; |
|
1748 | + } |
|
1749 | + // heading |
|
1750 | + if (isset($line['lat'])) { |
|
1751 | + $data['latitude'] = $line['lat']; |
|
1752 | + } |
|
1753 | + // lat |
|
1754 | + if (isset($line['lon'])) { |
|
1755 | + $data['longitude'] = $line['lon']; |
|
1756 | + } |
|
1757 | + // long |
|
1758 | + if (isset($line['vert_rate'])) { |
|
1759 | + $data['verticalrate'] = $line['vert_rate']; |
|
1760 | + } |
|
1761 | + // verticale rate |
|
1762 | + if (isset($line['squawk'])) { |
|
1763 | + $data['squawk'] = $line['squawk']; |
|
1764 | + } |
|
1765 | + // squawk |
|
1313 | 1766 | //$data['emergency'] = ''; // emergency |
1314 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1315 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1767 | + if (isset($line['reg'])) { |
|
1768 | + $data['registration'] = $line['reg']; |
|
1769 | + } |
|
1770 | + if (isset($line['type'])) { |
|
1771 | + $data['aircraft_icao'] = $line['type']; |
|
1772 | + } |
|
1316 | 1773 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
1317 | 1774 | $data['format_source'] = 'planefinderclient'; |
1318 | 1775 | $data['id_source'] = $id_source; |
1319 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1320 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1776 | + if (isset($value['name']) && $value['name'] != '') { |
|
1777 | + $data['source_name'] = $value['name']; |
|
1778 | + } |
|
1779 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1780 | + $data['noarchive'] = true; |
|
1781 | + } |
|
1321 | 1782 | $SI->add($data); |
1322 | 1783 | unset($data); |
1323 | 1784 | } |
@@ -1333,7 +1794,9 @@ discard block |
||
1333 | 1794 | //$buffer = $Common->getData($hosts[$id]); |
1334 | 1795 | $buffer = $Common->getData($value['host']); |
1335 | 1796 | $all_data = json_decode($buffer,true); |
1336 | - if (!empty($all_data)) $reset = 0; |
|
1797 | + if (!empty($all_data)) { |
|
1798 | + $reset = 0; |
|
1799 | + } |
|
1337 | 1800 | foreach ($all_data as $key => $line) { |
1338 | 1801 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1339 | 1802 | $data = array(); |
@@ -1354,8 +1817,12 @@ discard block |
||
1354 | 1817 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
1355 | 1818 | $data['format_source'] = 'fr24json'; |
1356 | 1819 | $data['id_source'] = $id_source; |
1357 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1358 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1820 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1821 | + $data['noarchive'] = true; |
|
1822 | + } |
|
1823 | + if (isset($value['name']) && $value['name'] != '') { |
|
1824 | + $data['source_name'] = $value['name']; |
|
1825 | + } |
|
1359 | 1826 | $SI->add($data); |
1360 | 1827 | unset($data); |
1361 | 1828 | } |
@@ -1384,24 +1851,42 @@ discard block |
||
1384 | 1851 | if (isset($line['inf'])) { |
1385 | 1852 | $data = array(); |
1386 | 1853 | $data['hex'] = $line['inf']['ia']; |
1387 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1854 | + if (isset($line['inf']['cs'])) { |
|
1855 | + $data['ident'] = $line['inf']['cs']; |
|
1856 | + } |
|
1857 | + //$line[13] |
|
1388 | 1858 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1389 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1390 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1859 | + if (isset($line['inf']['gs'])) { |
|
1860 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1861 | + } |
|
1862 | + // speed |
|
1863 | + if (isset($line['inf']['tr'])) { |
|
1864 | + $data['heading'] = $line['inf']['tr']; |
|
1865 | + } |
|
1866 | + // heading |
|
1391 | 1867 | $data['latitude'] = $line['pt'][0]; // lat |
1392 | 1868 | $data['longitude'] = $line['pt'][1]; // long |
1393 | 1869 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1394 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1870 | + if (isset($line['inf']['sq'])) { |
|
1871 | + $data['squawk'] = $line['inf']['sq']; |
|
1872 | + } |
|
1873 | + // squawk |
|
1395 | 1874 | //$data['aircraft_icao'] = $line[8]; |
1396 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1875 | + if (isset($line['inf']['rc'])) { |
|
1876 | + $data['registration'] = $line['inf']['rc']; |
|
1877 | + } |
|
1397 | 1878 | //$data['departure_airport_iata'] = $line[11]; |
1398 | 1879 | //$data['arrival_airport_iata'] = $line[12]; |
1399 | 1880 | //$data['emergency'] = ''; // emergency |
1400 | 1881 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1401 | 1882 | $data['format_source'] = 'radarvirtueljson'; |
1402 | 1883 | $data['id_source'] = $id_source; |
1403 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1404 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1884 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1885 | + $data['noarchive'] = true; |
|
1886 | + } |
|
1887 | + if (isset($value['name']) && $value['name'] != '') { |
|
1888 | + $data['source_name'] = $value['name']; |
|
1889 | + } |
|
1405 | 1890 | $SI->add($data); |
1406 | 1891 | unset($data); |
1407 | 1892 | } |
@@ -1427,30 +1912,65 @@ discard block |
||
1427 | 1912 | $data['id'] = $line['id']; |
1428 | 1913 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1429 | 1914 | $data['ident'] = $line['callsign']; // ident |
1430 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1431 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1432 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1433 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1434 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1435 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1915 | + if (isset($line['pilotid'])) { |
|
1916 | + $data['pilot_id'] = $line['pilotid']; |
|
1917 | + } |
|
1918 | + // pilot id |
|
1919 | + if (isset($line['name'])) { |
|
1920 | + $data['pilot_name'] = $line['name']; |
|
1921 | + } |
|
1922 | + // pilot name |
|
1923 | + if (isset($line['alt'])) { |
|
1924 | + $data['altitude'] = $line['alt']; |
|
1925 | + } |
|
1926 | + // altitude |
|
1927 | + if (isset($line['gs'])) { |
|
1928 | + $data['speed'] = $line['gs']; |
|
1929 | + } |
|
1930 | + // speed |
|
1931 | + if (isset($line['heading'])) { |
|
1932 | + $data['heading'] = $line['heading']; |
|
1933 | + } |
|
1934 | + // heading |
|
1935 | + if (isset($line['route'])) { |
|
1936 | + $data['waypoints'] = $line['route']; |
|
1937 | + } |
|
1938 | + // route |
|
1436 | 1939 | $data['latitude'] = $line['lat']; // lat |
1437 | 1940 | $data['longitude'] = $line['lon']; // long |
1438 | 1941 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1439 | 1942 | //$data['squawk'] = $line['squawk']; // squawk |
1440 | 1943 | //$data['emergency'] = ''; // emergency |
1441 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1442 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1443 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1944 | + if (isset($line['depicao'])) { |
|
1945 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1946 | + } |
|
1947 | + if (isset($line['deptime'])) { |
|
1948 | + $data['departure_airport_time'] = $line['deptime']; |
|
1949 | + } |
|
1950 | + if (isset($line['arricao'])) { |
|
1951 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1952 | + } |
|
1444 | 1953 | //$data['arrival_airport_time'] = $line['arrtime']; |
1445 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1446 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1447 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1448 | - else $data['info'] = ''; |
|
1954 | + if (isset($line['aircraft'])) { |
|
1955 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1956 | + } |
|
1957 | + if (isset($line['transponder'])) { |
|
1958 | + $data['squawk'] = $line['transponder']; |
|
1959 | + } |
|
1960 | + if (isset($line['atis'])) { |
|
1961 | + $data['info'] = $line['atis']; |
|
1962 | + } else { |
|
1963 | + $data['info'] = ''; |
|
1964 | + } |
|
1449 | 1965 | $data['format_source'] = 'pireps'; |
1450 | 1966 | $data['id_source'] = $id_source; |
1451 | 1967 | $data['datetime'] = date('Y-m-d H:i:s'); |
1452 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1453 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1968 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1969 | + $data['noarchive'] = true; |
|
1970 | + } |
|
1971 | + if (isset($value['name']) && $value['name'] != '') { |
|
1972 | + $data['source_name'] = $value['name']; |
|
1973 | + } |
|
1454 | 1974 | if ($line['icon'] === 'plane') { |
1455 | 1975 | $SI->add($data); |
1456 | 1976 | // print_r($data); |
@@ -1459,16 +1979,28 @@ discard block |
||
1459 | 1979 | $data['info'] = str_replace('&sect;','',$data['info']); |
1460 | 1980 | $typec = substr($data['ident'],-3); |
1461 | 1981 | $data['type'] = ''; |
1462 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
1463 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
1464 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
1465 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
1466 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
1467 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
1468 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1469 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1470 | - else $data['type'] = 'Observer'; |
|
1471 | - 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']); |
|
1982 | + if ($typec === 'APP') { |
|
1983 | + $data['type'] = 'Approach'; |
|
1984 | + } elseif ($typec === 'TWR') { |
|
1985 | + $data['type'] = 'Tower'; |
|
1986 | + } elseif ($typec === 'OBS') { |
|
1987 | + $data['type'] = 'Observer'; |
|
1988 | + } elseif ($typec === 'GND') { |
|
1989 | + $data['type'] = 'Ground'; |
|
1990 | + } elseif ($typec === 'DEL') { |
|
1991 | + $data['type'] = 'Delivery'; |
|
1992 | + } elseif ($typec === 'DEP') { |
|
1993 | + $data['type'] = 'Departure'; |
|
1994 | + } elseif ($typec === 'FSS') { |
|
1995 | + $data['type'] = 'Flight Service Station'; |
|
1996 | + } elseif ($typec === 'CTR') { |
|
1997 | + $data['type'] = 'Control Radar or Centre'; |
|
1998 | + } else { |
|
1999 | + $data['type'] = 'Observer'; |
|
2000 | + } |
|
2001 | + if (isset($ATC)) { |
|
2002 | + 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']); |
|
2003 | + } |
|
1472 | 2004 | } |
1473 | 2005 | unset($data); |
1474 | 2006 | } |
@@ -1483,7 +2015,9 @@ discard block |
||
1483 | 2015 | ) |
1484 | 2016 | ) { |
1485 | 2017 | //$buffer = $Common->getData($hosts[$id]); |
1486 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
2018 | + if ($globalDebug) { |
|
2019 | + echo 'Get Data...'."\n"; |
|
2020 | + } |
|
1487 | 2021 | $buffer = $Common->getData($value['host']); |
1488 | 2022 | $all_data = json_decode($buffer,true); |
1489 | 2023 | if ($buffer != '' && is_array($all_data)) { |
@@ -1491,10 +2025,16 @@ discard block |
||
1491 | 2025 | foreach ($all_data as $line) { |
1492 | 2026 | $data = array(); |
1493 | 2027 | //$data['id'] = $line['id']; // id not usable |
1494 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
2028 | + if (isset($line['pilotid'])) { |
|
2029 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
2030 | + } |
|
1495 | 2031 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1496 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1497 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
2032 | + if (isset($line['pilotname'])) { |
|
2033 | + $data['pilot_name'] = $line['pilotname']; |
|
2034 | + } |
|
2035 | + if (isset($line['pilotid'])) { |
|
2036 | + $data['pilot_id'] = $line['pilotid']; |
|
2037 | + } |
|
1498 | 2038 | $data['ident'] = $line['flightnum']; // ident |
1499 | 2039 | $data['altitude'] = $line['alt']; // altitude |
1500 | 2040 | $data['speed'] = $line['gs']; // speed |
@@ -1510,7 +2050,9 @@ discard block |
||
1510 | 2050 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1511 | 2051 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1512 | 2052 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1513 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2053 | + } else { |
|
2054 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2055 | + } |
|
1514 | 2056 | $data['departure_airport_icao'] = $line['depicao']; |
1515 | 2057 | $data['departure_airport_time'] = $line['deptime']; |
1516 | 2058 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1518,29 +2060,47 @@ discard block |
||
1518 | 2060 | if (isset($line['registration'])) { |
1519 | 2061 | $data['registration'] = $line['registration']; |
1520 | 2062 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
1521 | - } else $data['registration'] = $line['aircraft']; |
|
1522 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1523 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
2063 | + } else { |
|
2064 | + $data['registration'] = $line['aircraft']; |
|
2065 | + } |
|
2066 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
2067 | + $data['noarchive'] = true; |
|
2068 | + } |
|
2069 | + if (isset($line['route'])) { |
|
2070 | + $data['waypoints'] = $line['route']; |
|
2071 | + } |
|
2072 | + // route |
|
1524 | 2073 | if (isset($line['aircraftname'])) { |
1525 | 2074 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1526 | 2075 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1527 | 2076 | $aircraft_data = explode('-',$line['aircraftname']); |
1528 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1529 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1530 | - else { |
|
2077 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
2078 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
2079 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
2080 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
2081 | + } else { |
|
1531 | 2082 | $aircraft_data = explode(' ',$line['aircraftname']); |
1532 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1533 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
2083 | + if (isset($aircraft_data[1])) { |
|
2084 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
2085 | + } else { |
|
2086 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
2087 | + } |
|
1534 | 2088 | } |
1535 | 2089 | } |
1536 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
2090 | + if (isset($line['route'])) { |
|
2091 | + $data['waypoints'] = $line['route']; |
|
2092 | + } |
|
1537 | 2093 | $data['id_source'] = $id_source; |
1538 | 2094 | $data['format_source'] = 'phpvmacars'; |
1539 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
2095 | + if (isset($value['name']) && $value['name'] != '') { |
|
2096 | + $data['source_name'] = $value['name']; |
|
2097 | + } |
|
1540 | 2098 | $SI->add($data); |
1541 | 2099 | unset($data); |
1542 | 2100 | } |
1543 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2101 | + if ($globalDebug) { |
|
2102 | + echo 'No more data...'."\n"; |
|
2103 | + } |
|
1544 | 2104 | unset($buffer); |
1545 | 2105 | unset($all_data); |
1546 | 2106 | } |
@@ -1553,7 +2113,9 @@ discard block |
||
1553 | 2113 | ) |
1554 | 2114 | ) { |
1555 | 2115 | //$buffer = $Common->getData($hosts[$id]); |
1556 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
2116 | + if ($globalDebug) { |
|
2117 | + echo 'Get Data...'."\n"; |
|
2118 | + } |
|
1557 | 2119 | $buffer = $Common->getData($value['host']); |
1558 | 2120 | $all_data = json_decode($buffer,true); |
1559 | 2121 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1564,10 +2126,16 @@ discard block |
||
1564 | 2126 | //$data['id'] = $line['id']; // id not usable |
1565 | 2127 | $data['id'] = $line['id']; |
1566 | 2128 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1567 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1568 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
2129 | + if (isset($line['user']['username'])) { |
|
2130 | + $data['pilot_name'] = $line['user']['username']; |
|
2131 | + } |
|
2132 | + if (isset($line['user_id'])) { |
|
2133 | + $data['pilot_id'] = $line['user_id']; |
|
2134 | + } |
|
1569 | 2135 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
1570 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
2136 | + if (is_numeric($data['ident'])) { |
|
2137 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
2138 | + } |
|
1571 | 2139 | $data['altitude'] = $line['altitude']; // altitude |
1572 | 2140 | $data['speed'] = $line['groundspeed']; // speed |
1573 | 2141 | $data['heading'] = $line['heading']; // heading |
@@ -1580,7 +2148,9 @@ discard block |
||
1580 | 2148 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
1581 | 2149 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1582 | 2150 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1583 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2151 | + } else { |
|
2152 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2153 | + } |
|
1584 | 2154 | |
1585 | 2155 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
1586 | 2156 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1588,17 +2158,26 @@ discard block |
||
1588 | 2158 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
1589 | 2159 | $data['registration'] = $line['bid']['aircraft']['registration']; |
1590 | 2160 | |
1591 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1592 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
2161 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
2162 | + $data['noarchive'] = true; |
|
2163 | + } |
|
2164 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
2165 | + $data['waypoints'] = $line['bid']['route']; |
|
2166 | + } |
|
2167 | + // route |
|
1593 | 2168 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
1594 | 2169 | |
1595 | 2170 | $data['id_source'] = $id_source; |
1596 | 2171 | $data['format_source'] = 'vaos'; |
1597 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
2172 | + if (isset($value['name']) && $value['name'] != '') { |
|
2173 | + $data['source_name'] = $value['name']; |
|
2174 | + } |
|
1598 | 2175 | $SI->add($data); |
1599 | 2176 | unset($data); |
1600 | 2177 | } |
1601 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2178 | + if ($globalDebug) { |
|
2179 | + echo 'No more data...'."\n"; |
|
2180 | + } |
|
1602 | 2181 | unset($buffer); |
1603 | 2182 | unset($all_data); |
1604 | 2183 | } |
@@ -1611,7 +2190,9 @@ discard block |
||
1611 | 2190 | ) |
1612 | 2191 | ) { |
1613 | 2192 | //$buffer = $Common->getData($hosts[$id]); |
1614 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
2193 | + if ($globalDebug) { |
|
2194 | + echo 'Get Data...'."\n"; |
|
2195 | + } |
|
1615 | 2196 | $buffer = $Common->getData($value['host']); |
1616 | 2197 | $all_data = json_decode($buffer,true); |
1617 | 2198 | if ($buffer != '' && is_array($all_data)) { |
@@ -1640,16 +2221,25 @@ discard block |
||
1640 | 2221 | $data['arrival_airport_icao'] = $line['arrival']; |
1641 | 2222 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1642 | 2223 | //$data['registration'] = $line['aircraft']; |
1643 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
2224 | + if (isset($line['route'])) { |
|
2225 | + $data['waypoints'] = $line['route']; |
|
2226 | + } |
|
2227 | + // route |
|
1644 | 2228 | $data['aircraft_icao'] = $line['plane_type']; |
1645 | 2229 | $data['id_source'] = $id_source; |
1646 | 2230 | $data['format_source'] = 'vam'; |
1647 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1648 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
2231 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
2232 | + $data['noarchive'] = true; |
|
2233 | + } |
|
2234 | + if (isset($value['name']) && $value['name'] != '') { |
|
2235 | + $data['source_name'] = $value['name']; |
|
2236 | + } |
|
1649 | 2237 | $SI->add($data); |
1650 | 2238 | unset($data); |
1651 | 2239 | } |
1652 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2240 | + if ($globalDebug) { |
|
2241 | + echo 'No more data...'."\n"; |
|
2242 | + } |
|
1653 | 2243 | unset($buffer); |
1654 | 2244 | unset($all_data); |
1655 | 2245 | } |
@@ -1662,7 +2252,9 @@ discard block |
||
1662 | 2252 | ) |
1663 | 2253 | ) { |
1664 | 2254 | //$buffer = $Common->getData($hosts[$id]); |
1665 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
2255 | + if ($globalDebug) { |
|
2256 | + echo 'Get Data...'."\n"; |
|
2257 | + } |
|
1666 | 2258 | $buffer = $Common->getData($value['host']); |
1667 | 2259 | $all_data = json_decode($buffer,true); |
1668 | 2260 | if ($buffer != '') { |
@@ -1680,12 +2272,16 @@ discard block |
||
1680 | 2272 | $data['id_source'] = $id_source; |
1681 | 2273 | $data['format_source'] = 'blitzortung'; |
1682 | 2274 | $SI->add($data); |
1683 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2275 | + if ($globalDebug) { |
|
2276 | + echo '☈ Lightning added'."\n"; |
|
2277 | + } |
|
1684 | 2278 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1685 | 2279 | unset($data); |
1686 | 2280 | } |
1687 | 2281 | } |
1688 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2282 | + if ($globalDebug) { |
|
2283 | + echo 'No more data...'."\n"; |
|
2284 | + } |
|
1689 | 2285 | unset($buffer); |
1690 | 2286 | } |
1691 | 2287 | $last_exec[$id]['last'] = time(); |
@@ -1714,10 +2310,15 @@ discard block |
||
1714 | 2310 | } |
1715 | 2311 | } else { |
1716 | 2312 | $format = $value['format']; |
1717 | - if (isset($tt[$format])) $tt[$format]++; |
|
1718 | - else $tt[$format] = 0; |
|
2313 | + if (isset($tt[$format])) { |
|
2314 | + $tt[$format]++; |
|
2315 | + } else { |
|
2316 | + $tt[$format] = 0; |
|
2317 | + } |
|
1719 | 2318 | if ($tt[$format] > 30) { |
1720 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
2319 | + if ($globalDebug) { |
|
2320 | + echo 'Reconnect...'."\n"; |
|
2321 | + } |
|
1721 | 2322 | sleep(2); |
1722 | 2323 | //$sourceeen[] = $value; |
1723 | 2324 | //connect_all($sourceeen); |
@@ -1734,7 +2335,9 @@ discard block |
||
1734 | 2335 | $write = NULL; |
1735 | 2336 | $e = NULL; |
1736 | 2337 | $n = socket_select($read, $write, $e, $timeout); |
1737 | - if ($e != NULL) var_dump($e); |
|
2338 | + if ($e != NULL) { |
|
2339 | + var_dump($e); |
|
2340 | + } |
|
1738 | 2341 | if ($n > 0) { |
1739 | 2342 | $reset = 0; |
1740 | 2343 | foreach ($read as $nb => $r) { |
@@ -1756,13 +2359,17 @@ discard block |
||
1756 | 2359 | if ($buffer !== FALSE) { |
1757 | 2360 | if ($format === 'vrstcp') { |
1758 | 2361 | $buffer = explode('},{',$buffer); |
1759 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
2362 | + } else { |
|
2363 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
2364 | + } |
|
1760 | 2365 | } |
1761 | 2366 | // SBS format is CSV format |
1762 | 2367 | if ($buffer !== FALSE && $buffer !== '') { |
1763 | 2368 | $tt[$format] = 0; |
1764 | 2369 | if ($format === 'acarssbs3') { |
1765 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2370 | + if ($globalDebug) { |
|
2371 | + echo 'ACARS : '.$buffer."\n"; |
|
2372 | + } |
|
1766 | 2373 | $ACARS->add(trim($buffer)); |
1767 | 2374 | $ACARS->deleteLiveAcarsData(); |
1768 | 2375 | } elseif ($format === 'raw') { |
@@ -1772,9 +2379,15 @@ discard block |
||
1772 | 2379 | //if (!empty($data)) print_r($data); |
1773 | 2380 | $data['datetime'] = date('Y-m-d H:i:s'); |
1774 | 2381 | $data['format_source'] = 'raw'; |
1775 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1776 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1777 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2382 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2383 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2384 | + } |
|
2385 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2386 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2387 | + } |
|
2388 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2389 | + $data['noarchive'] = true; |
|
2390 | + } |
|
1778 | 2391 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1779 | 2392 | $SI->add($data); |
1780 | 2393 | unset($data); |
@@ -1782,22 +2395,54 @@ discard block |
||
1782 | 2395 | } elseif ($format === 'ais') { |
1783 | 2396 | $ais_data = $AIS->parse_line(trim($buffer)); |
1784 | 2397 | $data = array(); |
1785 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1786 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1787 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1788 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1789 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1790 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1791 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1792 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1793 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1794 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1795 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1796 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1797 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1798 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1799 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1800 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2398 | + if (isset($ais_data['ident'])) { |
|
2399 | + $data['ident'] = $ais_data['ident']; |
|
2400 | + } |
|
2401 | + if (isset($ais_data['mmsi'])) { |
|
2402 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
2403 | + } |
|
2404 | + if (isset($ais_data['speed'])) { |
|
2405 | + $data['speed'] = $ais_data['speed']; |
|
2406 | + } |
|
2407 | + if (isset($ais_data['heading'])) { |
|
2408 | + $data['heading'] = $ais_data['heading']; |
|
2409 | + } |
|
2410 | + if (isset($ais_data['latitude'])) { |
|
2411 | + $data['latitude'] = $ais_data['latitude']; |
|
2412 | + } |
|
2413 | + if (isset($ais_data['longitude'])) { |
|
2414 | + $data['longitude'] = $ais_data['longitude']; |
|
2415 | + } |
|
2416 | + if (isset($ais_data['status'])) { |
|
2417 | + $data['status'] = $ais_data['status']; |
|
2418 | + } |
|
2419 | + if (isset($ais_data['statusid'])) { |
|
2420 | + $data['status_id'] = $ais_data['statusid']; |
|
2421 | + } |
|
2422 | + if (isset($ais_data['type'])) { |
|
2423 | + $data['type'] = $ais_data['type']; |
|
2424 | + } |
|
2425 | + if (isset($ais_data['imo'])) { |
|
2426 | + $data['imo'] = $ais_data['imo']; |
|
2427 | + } |
|
2428 | + if (isset($ais_data['callsign'])) { |
|
2429 | + $data['callsign'] = $ais_data['callsign']; |
|
2430 | + } |
|
2431 | + if (isset($ais_data['destination'])) { |
|
2432 | + $data['arrival_code'] = $ais_data['destination']; |
|
2433 | + } |
|
2434 | + if (isset($ais_data['eta_ts'])) { |
|
2435 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
2436 | + } |
|
2437 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2438 | + $data['noarchive'] = true; |
|
2439 | + } |
|
2440 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2441 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2442 | + } |
|
2443 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2444 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2445 | + } |
|
1801 | 2446 | |
1802 | 2447 | if (isset($ais_data['timestamp'])) { |
1803 | 2448 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1806,7 +2451,9 @@ discard block |
||
1806 | 2451 | } |
1807 | 2452 | $data['format_source'] = 'aisnmea'; |
1808 | 2453 | $data['id_source'] = $id_source; |
1809 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
2454 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
2455 | + $MI->add($data); |
|
2456 | + } |
|
1810 | 2457 | unset($data); |
1811 | 2458 | } elseif ($format === 'flightgearsp') { |
1812 | 2459 | //echo $buffer."\n"; |
@@ -1824,17 +2471,25 @@ discard block |
||
1824 | 2471 | $data['speed'] = round($line[5]*1.94384); |
1825 | 2472 | $data['datetime'] = date('Y-m-d H:i:s'); |
1826 | 2473 | $data['format_source'] = 'flightgearsp'; |
1827 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1828 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2474 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2475 | + $data['noarchive'] = true; |
|
2476 | + } |
|
2477 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2478 | + $SI->add($data); |
|
2479 | + } |
|
1829 | 2480 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1830 | 2481 | } |
1831 | 2482 | } elseif ($format === 'acars') { |
1832 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2483 | + if ($globalDebug) { |
|
2484 | + echo 'ACARS : '.$buffer."\n"; |
|
2485 | + } |
|
1833 | 2486 | $ACARS->add(trim($buffer)); |
1834 | 2487 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1835 | 2488 | $ACARS->deleteLiveAcarsData(); |
1836 | 2489 | } elseif ($format === 'acarsjsonudp') { |
1837 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2490 | + if ($globalDebug) { |
|
2491 | + echo 'ACARS : '.$buffer."\n"; |
|
2492 | + } |
|
1838 | 2493 | $line = json_decode(trim($buffer), true); |
1839 | 2494 | if (!empty($line)) { |
1840 | 2495 | $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
@@ -1859,8 +2514,12 @@ discard block |
||
1859 | 2514 | $aircraft_type = $line[10]; |
1860 | 2515 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1861 | 2516 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1862 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1863 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2517 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2518 | + $data['noarchive'] = true; |
|
2519 | + } |
|
2520 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2521 | + $SI->add($data); |
|
2522 | + } |
|
1864 | 2523 | } |
1865 | 2524 | } |
1866 | 2525 | } elseif ($format === 'beast') { |
@@ -1870,28 +2529,62 @@ discard block |
||
1870 | 2529 | foreach($buffer as $all_data) { |
1871 | 2530 | $line = json_decode('{'.$all_data.'}',true); |
1872 | 2531 | $data = array(); |
1873 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1874 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1875 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1876 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1877 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1878 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1879 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
2532 | + if (isset($line['Icao'])) { |
|
2533 | + $data['hex'] = $line['Icao']; |
|
2534 | + } |
|
2535 | + // hex |
|
2536 | + if (isset($line['Call'])) { |
|
2537 | + $data['ident'] = $line['Call']; |
|
2538 | + } |
|
2539 | + // ident |
|
2540 | + if (isset($line['Alt'])) { |
|
2541 | + $data['altitude'] = $line['Alt']; |
|
2542 | + } |
|
2543 | + // altitude |
|
2544 | + if (isset($line['Spd'])) { |
|
2545 | + $data['speed'] = $line['Spd']; |
|
2546 | + } |
|
2547 | + // speed |
|
2548 | + if (isset($line['Trak'])) { |
|
2549 | + $data['heading'] = $line['Trak']; |
|
2550 | + } |
|
2551 | + // heading |
|
2552 | + if (isset($line['Lat'])) { |
|
2553 | + $data['latitude'] = $line['Lat']; |
|
2554 | + } |
|
2555 | + // lat |
|
2556 | + if (isset($line['Long'])) { |
|
2557 | + $data['longitude'] = $line['Long']; |
|
2558 | + } |
|
2559 | + // long |
|
1880 | 2560 | //$data['verticalrate'] = $line['']; // verticale rate |
1881 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
2561 | + if (isset($line['Sqk'])) { |
|
2562 | + $data['squawk'] = $line['Sqk']; |
|
2563 | + } |
|
2564 | + // squawk |
|
1882 | 2565 | $data['emergency'] = ''; // emergency |
1883 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
2566 | + if (isset($line['Reg'])) { |
|
2567 | + $data['registration'] = $line['Reg']; |
|
2568 | + } |
|
1884 | 2569 | /* |
1885 | 2570 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1886 | 2571 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1887 | 2572 | */ |
1888 | 2573 | $data['datetime'] = date('Y-m-d H:i:s'); |
1889 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
2574 | + if (isset($line['Type'])) { |
|
2575 | + $data['aircraft_icao'] = $line['Type']; |
|
2576 | + } |
|
1890 | 2577 | $data['format_source'] = 'vrstcp'; |
1891 | 2578 | $data['id_source'] = $id_source; |
1892 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1893 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1894 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
2579 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2580 | + $data['noarchive'] = true; |
|
2581 | + } |
|
2582 | + if (isset($value['name']) && $value['name'] != '') { |
|
2583 | + $data['source_name'] = $value['name']; |
|
2584 | + } |
|
2585 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
2586 | + $SI->add($data); |
|
2587 | + } |
|
1895 | 2588 | unset($data); |
1896 | 2589 | } |
1897 | 2590 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1904,22 +2597,46 @@ discard block |
||
1904 | 2597 | $data['hex'] = $lined['hexid']; |
1905 | 2598 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1906 | 2599 | $data['datetime'] = date('Y-m-d H:i:s');; |
1907 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1908 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1909 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1910 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1911 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1912 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1913 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
2600 | + if (isset($lined['ident'])) { |
|
2601 | + $data['ident'] = $lined['ident']; |
|
2602 | + } |
|
2603 | + if (isset($lined['lat'])) { |
|
2604 | + $data['latitude'] = $lined['lat']; |
|
2605 | + } |
|
2606 | + if (isset($lined['lon'])) { |
|
2607 | + $data['longitude'] = $lined['lon']; |
|
2608 | + } |
|
2609 | + if (isset($lined['speed'])) { |
|
2610 | + $data['speed'] = $lined['speed']; |
|
2611 | + } |
|
2612 | + if (isset($lined['squawk'])) { |
|
2613 | + $data['squawk'] = $lined['squawk']; |
|
2614 | + } |
|
2615 | + if (isset($lined['alt'])) { |
|
2616 | + $data['altitude'] = $lined['alt']; |
|
2617 | + } |
|
2618 | + if (isset($lined['heading'])) { |
|
2619 | + $data['heading'] = $lined['heading']; |
|
2620 | + } |
|
1914 | 2621 | $data['id_source'] = $id_source; |
1915 | 2622 | $data['format_source'] = 'tsv'; |
1916 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1917 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1918 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1919 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2623 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2624 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2625 | + } |
|
2626 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2627 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2628 | + } |
|
2629 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2630 | + $data['noarchive'] = true; |
|
2631 | + } |
|
2632 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2633 | + $SI->add($data); |
|
2634 | + } |
|
1920 | 2635 | unset($lined); |
1921 | 2636 | unset($data); |
1922 | - } else $error = true; |
|
2637 | + } else { |
|
2638 | + $error = true; |
|
2639 | + } |
|
1923 | 2640 | } elseif ($format === 'aprs' && $use_aprs) { |
1924 | 2641 | if ($aprs_connect === 0) { |
1925 | 2642 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1945,47 +2662,96 @@ discard block |
||
1945 | 2662 | $aprs_last_tx = time(); |
1946 | 2663 | $data = array(); |
1947 | 2664 | //print_r($line); |
1948 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1949 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1950 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1951 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1952 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1953 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1954 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1955 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1956 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1957 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2665 | + if (isset($line['address'])) { |
|
2666 | + $data['hex'] = $line['address']; |
|
2667 | + } |
|
2668 | + if (isset($line['mmsi'])) { |
|
2669 | + $data['mmsi'] = $line['mmsi']; |
|
2670 | + } |
|
2671 | + if (isset($line['imo'])) { |
|
2672 | + $data['imo'] = $line['imo']; |
|
2673 | + } |
|
2674 | + if (isset($line['squawk'])) { |
|
2675 | + $data['squawk'] = $line['squawk']; |
|
2676 | + } |
|
2677 | + if (isset($line['arrival_code'])) { |
|
2678 | + $data['arrival_code'] = $line['arrival_code']; |
|
2679 | + } |
|
2680 | + if (isset($line['arrival_date'])) { |
|
2681 | + $data['arrival_date'] = $line['arrival_date']; |
|
2682 | + } |
|
2683 | + if (isset($line['typeid'])) { |
|
2684 | + $data['type_id'] = $line['typeid']; |
|
2685 | + } |
|
2686 | + if (isset($line['statusid'])) { |
|
2687 | + $data['status_id'] = $line['statusid']; |
|
2688 | + } |
|
2689 | + if (isset($line['timestamp'])) { |
|
2690 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2691 | + } else { |
|
2692 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2693 | + } |
|
1958 | 2694 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1959 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2695 | + if (isset($line['ident'])) { |
|
2696 | + $data['ident'] = $line['ident']; |
|
2697 | + } |
|
1960 | 2698 | $data['latitude'] = $line['latitude']; |
1961 | 2699 | $data['longitude'] = $line['longitude']; |
1962 | 2700 | //$data['verticalrate'] = $line[16]; |
1963 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2701 | + if (isset($line['speed'])) { |
|
2702 | + $data['speed'] = $line['speed']; |
|
2703 | + } |
|
1964 | 2704 | //else $data['speed'] = 0; |
1965 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1966 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1967 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2705 | + if (isset($line['altitude'])) { |
|
2706 | + $data['altitude'] = $line['altitude']; |
|
2707 | + } |
|
2708 | + if (isset($line['comment'])) { |
|
2709 | + $data['comment'] = $line['comment']; |
|
2710 | + } |
|
2711 | + if (isset($line['symbol'])) { |
|
2712 | + $data['type'] = $line['symbol']; |
|
2713 | + } |
|
1968 | 2714 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1969 | 2715 | |
1970 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2716 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2717 | + $data['heading'] = $line['heading']; |
|
2718 | + } |
|
1971 | 2719 | //else echo 'No heading...'."\n"; |
1972 | 2720 | //else $data['heading'] = 0; |
1973 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2721 | + if (isset($line['stealth'])) { |
|
2722 | + $data['aircraft_type'] = $line['stealth']; |
|
2723 | + } |
|
1974 | 2724 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1975 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1976 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1977 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1978 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2725 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2726 | + $data['noarchive'] = true; |
|
2727 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2728 | + $data['noarchive'] = false; |
|
2729 | + } |
|
2730 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2731 | + $data['noarchive'] = true; |
|
2732 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2733 | + $data['noarchive'] = false; |
|
2734 | + } |
|
1979 | 2735 | $data['id_source'] = $id_source; |
1980 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1981 | - else $data['format_source'] = 'aprs'; |
|
2736 | + if (isset($line['format_source'])) { |
|
2737 | + $data['format_source'] = $line['format_source']; |
|
2738 | + } else { |
|
2739 | + $data['format_source'] = 'aprs'; |
|
2740 | + } |
|
1982 | 2741 | $data['source_name'] = $line['source']; |
1983 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1984 | - else $data['source_type'] = 'flarm'; |
|
1985 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2742 | + if (isset($line['source_type'])) { |
|
2743 | + $data['source_type'] = $line['source_type']; |
|
2744 | + } else { |
|
2745 | + $data['source_type'] = 'flarm'; |
|
2746 | + } |
|
2747 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2748 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2749 | + } |
|
1986 | 2750 | $currentdate = date('Y-m-d H:i:s'); |
1987 | 2751 | $aprsdate = strtotime($data['datetime']); |
1988 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2752 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2753 | + $data['altitude_relative'] = 'AMSL'; |
|
2754 | + } |
|
1989 | 2755 | // Accept data if time <= system time + 20s |
1990 | 2756 | //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'])))) { |
1991 | 2757 | if ( |
@@ -1997,7 +2763,9 @@ discard block |
||
1997 | 2763 | $send = $SI->add($data); |
1998 | 2764 | } elseif ($data['source_type'] === 'ais') { |
1999 | 2765 | $data['type'] = ''; |
2000 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2766 | + if (isset($globalMarine) && $globalMarine) { |
|
2767 | + $send = $MI->add($data); |
|
2768 | + } |
|
2001 | 2769 | } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
2002 | 2770 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
2003 | 2771 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
@@ -2005,8 +2773,12 @@ discard block |
||
2005 | 2773 | $line['symbol'] === 'Glider' || |
2006 | 2774 | $line['symbol'] === 'No. Plane' || |
2007 | 2775 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
2008 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
2009 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2776 | + if ($line['symbol'] === 'Ballon') { |
|
2777 | + $data['aircraft_icao'] = 'BALL'; |
|
2778 | + } |
|
2779 | + if ($line['symbol'] === 'Glider') { |
|
2780 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2781 | + } |
|
2010 | 2782 | $send = $SI->add($data); |
2011 | 2783 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
2012 | 2784 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -2037,9 +2809,13 @@ discard block |
||
2037 | 2809 | //} 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') { |
2038 | 2810 | // } 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') { |
2039 | 2811 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
2040 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2812 | + if (isset($globalTracker) && $globalTracker) { |
|
2813 | + $send = $TI->add($data); |
|
2814 | + } |
|
2041 | 2815 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
2042 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2816 | + if (!isset($data['altitude'])) { |
|
2817 | + $data['altitude'] = 0; |
|
2818 | + } |
|
2043 | 2819 | $Source->deleteOldLocationByType('gs'); |
2044 | 2820 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
2045 | 2821 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -2048,7 +2824,9 @@ discard block |
||
2048 | 2824 | } |
2049 | 2825 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
2050 | 2826 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
2051 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2827 | + if ($globalDebug) { |
|
2828 | + echo '# Weather Station added'."\n"; |
|
2829 | + } |
|
2052 | 2830 | $Source->deleteOldLocationByType('wx'); |
2053 | 2831 | $weather_data = json_encode($line); |
2054 | 2832 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -2058,7 +2836,9 @@ discard block |
||
2058 | 2836 | } |
2059 | 2837 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
2060 | 2838 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
2061 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2839 | + if ($globalDebug) { |
|
2840 | + echo '☈ Lightning added'."\n"; |
|
2841 | + } |
|
2062 | 2842 | $Source->deleteOldLocationByType('lightning'); |
2063 | 2843 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
2064 | 2844 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -2070,8 +2850,7 @@ discard block |
||
2070 | 2850 | print_r($line); |
2071 | 2851 | } |
2072 | 2852 | unset($data); |
2073 | - } |
|
2074 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2853 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2075 | 2854 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
2076 | 2855 | } |
2077 | 2856 | /* |
@@ -2080,7 +2859,9 @@ discard block |
||
2080 | 2859 | } |
2081 | 2860 | */ |
2082 | 2861 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
2083 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2862 | + elseif ($line === true && $globalDebug) { |
|
2863 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2864 | + } |
|
2084 | 2865 | if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
2085 | 2866 | $Source->deleteOldLocationByType('lightning'); |
2086 | 2867 | $Source->deleteOldLocationByType('wx'); |
@@ -2117,27 +2898,47 @@ discard block |
||
2117 | 2898 | $data['ground'] = $line[21]; |
2118 | 2899 | $data['emergency'] = $line[19]; |
2119 | 2900 | $data['format_source'] = 'sbs'; |
2120 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
2121 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
2122 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2123 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2901 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2902 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2903 | + } elseif ($line[0] == 'MLAT') { |
|
2904 | + $data['source_name'] = 'MLAT'; |
|
2905 | + } |
|
2906 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2907 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2908 | + } |
|
2909 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2910 | + $data['noarchive'] = true; |
|
2911 | + } |
|
2124 | 2912 | $data['id_source'] = $id_source; |
2125 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
2126 | - else $error = true; |
|
2913 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2914 | + $send = $SI->add($data); |
|
2915 | + } else { |
|
2916 | + $error = true; |
|
2917 | + } |
|
2127 | 2918 | unset($data); |
2128 | - } else $error = true; |
|
2919 | + } else { |
|
2920 | + $error = true; |
|
2921 | + } |
|
2129 | 2922 | if ($error) { |
2130 | 2923 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
2131 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2924 | + if ($globalDebug) { |
|
2925 | + echo "Not a message. Ignoring... \n"; |
|
2926 | + } |
|
2132 | 2927 | } else { |
2133 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2928 | + if ($globalDebug) { |
|
2929 | + echo "Wrong line format. Ignoring... \n"; |
|
2930 | + } |
|
2134 | 2931 | if ($globalDebug) { |
2135 | 2932 | echo $buffer; |
2136 | 2933 | //print_r($line); |
2137 | 2934 | } |
2138 | 2935 | //socket_close($r); |
2139 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
2140 | - if ($format === 'aprs') $aprs_connect = 0; |
|
2936 | + if ($globalDebug) { |
|
2937 | + echo "Reconnect after an error...\n"; |
|
2938 | + } |
|
2939 | + if ($format === 'aprs') { |
|
2940 | + $aprs_connect = 0; |
|
2941 | + } |
|
2141 | 2942 | $sourceer[$nb] = $globalSources[$nb]; |
2142 | 2943 | connect_all($sourceer); |
2143 | 2944 | $sourceer = array(); |
@@ -2145,10 +2946,14 @@ discard block |
||
2145 | 2946 | } |
2146 | 2947 | } |
2147 | 2948 | // Sleep for xxx microseconds |
2148 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2949 | + if (isset($globalSBSSleep)) { |
|
2950 | + usleep($globalSBSSleep); |
|
2951 | + } |
|
2149 | 2952 | } else { |
2150 | 2953 | if ($format === 'flightgearmp') { |
2151 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2954 | + if ($globalDebug) { |
|
2955 | + echo "Reconnect FlightGear MP..."; |
|
2956 | + } |
|
2152 | 2957 | //@socket_close($r); |
2153 | 2958 | sleep($globalMinFetch); |
2154 | 2959 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2157,10 +2962,15 @@ discard block |
||
2157 | 2962 | break; |
2158 | 2963 | |
2159 | 2964 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
2160 | - if (isset($tt[$format])) $tt[$format]++; |
|
2161 | - else $tt[$format] = 0; |
|
2965 | + if (isset($tt[$format])) { |
|
2966 | + $tt[$format]++; |
|
2967 | + } else { |
|
2968 | + $tt[$format] = 0; |
|
2969 | + } |
|
2162 | 2970 | if ($tt[$format] > 30 || $buffer === FALSE) { |
2163 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2971 | + if ($globalDebug) { |
|
2972 | + echo "ERROR : Reconnect ".$format."..."; |
|
2973 | + } |
|
2164 | 2974 | //@socket_close($r); |
2165 | 2975 | sleep(2); |
2166 | 2976 | $aprs_connect = 0; |
@@ -2178,11 +2988,17 @@ discard block |
||
2178 | 2988 | } else { |
2179 | 2989 | $error = socket_strerror(socket_last_error()); |
2180 | 2990 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
2181 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2182 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2991 | + if ($globalDebug) { |
|
2992 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2993 | + } |
|
2994 | + if (isset($globalDebug)) { |
|
2995 | + echo "Restarting...\n"; |
|
2996 | + } |
|
2183 | 2997 | // Restart the script if possible |
2184 | 2998 | if (is_array($sockets)) { |
2185 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2999 | + if ($globalDebug) { |
|
3000 | + echo "Shutdown all sockets..."; |
|
3001 | + } |
|
2186 | 3002 | |
2187 | 3003 | foreach ($sockets as $sock) { |
2188 | 3004 | @socket_shutdown($sock,2); |
@@ -2190,25 +3006,45 @@ discard block |
||
2190 | 3006 | } |
2191 | 3007 | |
2192 | 3008 | } |
2193 | - if ($globalDebug) echo "Waiting..."; |
|
3009 | + if ($globalDebug) { |
|
3010 | + echo "Waiting..."; |
|
3011 | + } |
|
2194 | 3012 | sleep(2); |
2195 | 3013 | $time = time(); |
2196 | 3014 | //connect_all($hosts); |
2197 | 3015 | $aprs_connect = 0; |
2198 | - if ($reset%5 === 0) sleep(20); |
|
2199 | - if ($reset%10 === 0) sleep(100); |
|
2200 | - if ($reset%20 === 0) sleep(200); |
|
2201 | - if ($reset > 100) exit('Too many attempts...'); |
|
2202 | - if ($globalDebug) echo "Restart all connections..."; |
|
3016 | + if ($reset%5 === 0) { |
|
3017 | + sleep(20); |
|
3018 | + } |
|
3019 | + if ($reset%10 === 0) { |
|
3020 | + sleep(100); |
|
3021 | + } |
|
3022 | + if ($reset%20 === 0) { |
|
3023 | + sleep(200); |
|
3024 | + } |
|
3025 | + if ($reset > 100) { |
|
3026 | + exit('Too many attempts...'); |
|
3027 | + } |
|
3028 | + if ($globalDebug) { |
|
3029 | + echo "Restart all connections..."; |
|
3030 | + } |
|
2203 | 3031 | connect_all($globalSources); |
2204 | 3032 | } |
2205 | 3033 | } |
2206 | 3034 | } |
2207 | 3035 | if ($globalDaemon === false) { |
2208 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
2209 | - if (isset($SI)) $SI->checkAll(); |
|
2210 | - if (isset($TI)) $TI->checkAll(); |
|
2211 | - if (isset($MI)) $MI->checkAll(); |
|
3036 | + if ($globalDebug) { |
|
3037 | + echo 'Check all...'."\n"; |
|
3038 | + } |
|
3039 | + if (isset($SI)) { |
|
3040 | + $SI->checkAll(); |
|
3041 | + } |
|
3042 | + if (isset($TI)) { |
|
3043 | + $TI->checkAll(); |
|
3044 | + } |
|
3045 | + if (isset($MI)) { |
|
3046 | + $MI->checkAll(); |
|
3047 | + } |
|
2212 | 3048 | } |
2213 | 3049 | } |
2214 | 3050 | } |