@@ -14,13 +14,17 @@ discard block |
||
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
17 | +if (isset($globalTracker) && $globalTracker) { |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | +} |
|
18 | 20 | if (isset($globalMarine) && $globalMarine) { |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
21 | 23 | } |
22 | 24 | |
23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
24 | 28 | |
25 | 29 | // Check if schema is at latest version |
26 | 30 | $Connection = new Connection(); |
@@ -59,66 +63,107 @@ discard block |
||
59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 64 | if (isset($options['s'])) { |
61 | 65 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
64 | -} elseif (isset($options['source'])) { |
|
66 | + if (isset($options['format'])) { |
|
67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
68 | + } else { |
|
69 | + $globalSources[] = array('host' => $options['s']); |
|
70 | + } |
|
71 | + } elseif (isset($options['source'])) { |
|
65 | 72 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
68 | -} |
|
73 | + if (isset($options['format'])) { |
|
74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
75 | + } else { |
|
76 | + $globalSources[] = array('host' => $options['source']); |
|
77 | + } |
|
78 | + } |
|
69 | 79 | if (isset($options['aprsserverhost'])) { |
70 | 80 | $globalServerAPRS = TRUE; |
71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
72 | 82 | } |
73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
83 | +if (isset($options['aprsserverport'])) { |
|
84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
85 | +} |
|
86 | +if (isset($options['aprsserverssid'])) { |
|
87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
88 | +} |
|
89 | +if (isset($options['aprsserverpass'])) { |
|
90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
91 | +} |
|
92 | +if (isset($options['noaprsserver'])) { |
|
93 | + $globalServerAPRS = FALSE; |
|
94 | +} |
|
77 | 95 | if (isset($options['enable-aircraft'])) { |
78 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
96 | + if ($globalDebug) { |
|
97 | + echo 'Enable Aircraft mode'."\n"; |
|
98 | + } |
|
79 | 99 | $globalAircraft = TRUE; |
80 | 100 | } |
81 | 101 | if (isset($options['disable-aircraft'])) { |
82 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
102 | + if ($globalDebug) { |
|
103 | + echo 'Disable Aircraft mode'."\n"; |
|
104 | + } |
|
83 | 105 | $globalAircraft = FALSE; |
84 | 106 | } |
85 | 107 | if (isset($options['enable-tracker'])) { |
86 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
108 | + if ($globalDebug) { |
|
109 | + echo 'Enable Tracker mode'."\n"; |
|
110 | + } |
|
87 | 111 | $globalTracker = TRUE; |
88 | 112 | } |
89 | 113 | if (isset($options['disable-tracker'])) { |
90 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
114 | + if ($globalDebug) { |
|
115 | + echo 'Disable Tracker mode'."\n"; |
|
116 | + } |
|
91 | 117 | $globalTracker = FALSE; |
92 | 118 | } |
93 | 119 | if (isset($options['enable-marine'])) { |
94 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
120 | + if ($globalDebug) { |
|
121 | + echo 'Enable Marine mode'."\n"; |
|
122 | + } |
|
95 | 123 | $globalMarine = TRUE; |
96 | 124 | } |
97 | 125 | if (isset($options['disable-marine'])) { |
98 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
126 | + if ($globalDebug) { |
|
127 | + echo 'Disable Marine mode'."\n"; |
|
128 | + } |
|
99 | 129 | $globalMarine = FALSE; |
100 | 130 | } |
101 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
102 | -if (isset($options['server'])) $globalServer = TRUE; |
|
103 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
104 | -else $id_source = 1; |
|
131 | +if (isset($options['nodaemon'])) { |
|
132 | + $globalDaemon = FALSE; |
|
133 | +} |
|
134 | +if (isset($options['server'])) { |
|
135 | + $globalServer = TRUE; |
|
136 | +} |
|
137 | +if (isset($options['idsource'])) { |
|
138 | + $id_source = $options['idsource']; |
|
139 | +} else { |
|
140 | + $id_source = 1; |
|
141 | +} |
|
105 | 142 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
143 | + if ($globalDebug) { |
|
144 | + echo "Using Server Mode\n"; |
|
145 | + } |
|
107 | 146 | $SI=new SpotterServer(); |
108 | 147 | /* |
109 | 148 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 149 | $SI = new adsb2aprs(); |
111 | 150 | $SI->connect(); |
112 | 151 | */ |
113 | -} else $SI=new SpotterImport($Connection->db); |
|
152 | +} else { |
|
153 | + $SI=new SpotterImport($Connection->db); |
|
154 | +} |
|
114 | 155 | |
115 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
156 | +if (isset($globalTracker) && $globalTracker) { |
|
157 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
158 | +} |
|
116 | 159 | if (isset($globalMarine) && $globalMarine) { |
117 | 160 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
118 | 161 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
119 | 162 | } |
120 | 163 | |
121 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
164 | +if (isset($globalTracker) && $globalTracker) { |
|
165 | + $TI = new TrackerImport($Connection->db); |
|
166 | +} |
|
122 | 167 | if (isset($globalMarine) && $globalMarine) { |
123 | 168 | $AIS = new AIS(); |
124 | 169 | $MI = new MarineImport($Connection->db); |
@@ -143,7 +188,9 @@ discard block |
||
143 | 188 | } |
144 | 189 | |
145 | 190 | // let's try and connect |
146 | -if ($globalDebug) echo "Connecting...\n"; |
|
191 | +if ($globalDebug) { |
|
192 | + echo "Connecting...\n"; |
|
193 | +} |
|
147 | 194 | $use_aprs = false; |
148 | 195 | $aprs_full = false; |
149 | 196 | $reset = 0; |
@@ -152,7 +199,9 @@ discard block |
||
152 | 199 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
153 | 200 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
154 | 201 | $reset++; |
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
202 | + if ($globalDebug) { |
|
203 | + echo 'Connect to all...'."\n"; |
|
204 | + } |
|
156 | 205 | foreach ($hosts as $id => $value) { |
157 | 206 | $host = $value['host']; |
158 | 207 | $globalSources[$id]['last_exec'] = 0; |
@@ -162,27 +211,37 @@ discard block |
||
162 | 211 | //$formats[$id] = 'deltadbtxt'; |
163 | 212 | $globalSources[$id]['format'] = 'deltadbtxt'; |
164 | 213 | //$last_exec['deltadbtxt'] = 0; |
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
216 | + } |
|
166 | 217 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
167 | 218 | //$formats[$id] = 'vatsimtxt'; |
168 | 219 | $globalSources[$id]['format'] = 'vatsimtxt'; |
169 | 220 | //$last_exec['vatsimtxt'] = 0; |
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
221 | + if ($globalDebug) { |
|
222 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
223 | + } |
|
171 | 224 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
172 | 225 | //$formats[$id] = 'aircraftlistjson'; |
173 | 226 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
174 | 227 | //$last_exec['aircraftlistjson'] = 0; |
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
228 | + if ($globalDebug) { |
|
229 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
230 | + } |
|
176 | 231 | } else if (preg_match('/aircraft.json$/i',$host)) { |
177 | 232 | //$formats[$id] = 'aircraftjson'; |
178 | 233 | $globalSources[$id]['format'] = 'aircraftjson'; |
179 | 234 | //$last_exec['aircraftlistjson'] = 0; |
180 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
235 | + if ($globalDebug) { |
|
236 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
237 | + } |
|
181 | 238 | } else if (preg_match('/opensky/i',$host)) { |
182 | 239 | //$formats[$id] = 'aircraftlistjson'; |
183 | 240 | $globalSources[$id]['format'] = 'opensky'; |
184 | 241 | //$last_exec['aircraftlistjson'] = 0; |
185 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "Connect to opensky source (".$host.")...\n"; |
|
244 | + } |
|
186 | 245 | /* |
187 | 246 | // Disabled for now, site change source format |
188 | 247 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -199,7 +258,9 @@ discard block |
||
199 | 258 | //$formats[$id] = 'planeupdatefaa'; |
200 | 259 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
201 | 260 | //$last_exec['planeupdatefaa'] = 0; |
202 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
261 | + if ($globalDebug) { |
|
262 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
263 | + } |
|
203 | 264 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
204 | 265 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
205 | 266 | exit(0); |
@@ -208,37 +269,53 @@ discard block |
||
208 | 269 | //$formats[$id] = 'phpvmacars'; |
209 | 270 | $globalSources[$id]['format'] = 'phpvmacars'; |
210 | 271 | //$last_exec['phpvmacars'] = 0; |
211 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
272 | + if ($globalDebug) { |
|
273 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
274 | + } |
|
212 | 275 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
213 | 276 | //$formats[$id] = 'phpvmacars'; |
214 | 277 | $globalSources[$id]['format'] = 'vaos'; |
215 | 278 | //$last_exec['phpvmacars'] = 0; |
216 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
279 | + if ($globalDebug) { |
|
280 | + echo "Connect to vaos source (".$host.")...\n"; |
|
281 | + } |
|
217 | 282 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
218 | 283 | //$formats[$id] = 'phpvmacars'; |
219 | 284 | $globalSources[$id]['format'] = 'vam'; |
220 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
285 | + if ($globalDebug) { |
|
286 | + echo "Connect to Vam source (".$host.")...\n"; |
|
287 | + } |
|
221 | 288 | } else if (preg_match('/whazzup/i',$host)) { |
222 | 289 | //$formats[$id] = 'whazzup'; |
223 | 290 | $globalSources[$id]['format'] = 'whazzup'; |
224 | 291 | //$last_exec['whazzup'] = 0; |
225 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
292 | + if ($globalDebug) { |
|
293 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
294 | + } |
|
226 | 295 | } else if (preg_match('/blitzortung/i',$host)) { |
227 | 296 | $globalSources[$id]['format'] = 'blitzortung'; |
228 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
297 | + if ($globalDebug) { |
|
298 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
299 | + } |
|
229 | 300 | } else if (preg_match('/airwhere/i',$host)) { |
230 | 301 | $globalSources[$id]['format'] = 'airwhere'; |
231 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
302 | + if ($globalDebug) { |
|
303 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
304 | + } |
|
232 | 305 | } else if (preg_match('/recentpireps/i',$host)) { |
233 | 306 | //$formats[$id] = 'pirepsjson'; |
234 | 307 | $globalSources[$id]['format'] = 'pirepsjson'; |
235 | 308 | //$last_exec['pirepsjson'] = 0; |
236 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
309 | + if ($globalDebug) { |
|
310 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
311 | + } |
|
237 | 312 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
238 | 313 | //$formats[$id] = 'fr24json'; |
239 | 314 | $globalSources[$id]['format'] = 'fr24json'; |
240 | 315 | //$last_exec['fr24json'] = 0; |
241 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
316 | + if ($globalDebug) { |
|
317 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
318 | + } |
|
242 | 319 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
243 | 320 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
244 | 321 | exit(0); |
@@ -247,7 +324,9 @@ discard block |
||
247 | 324 | //$formats[$id] = 'fr24json'; |
248 | 325 | $globalSources[$id]['format'] = 'myshiptracking'; |
249 | 326 | //$last_exec['fr24json'] = 0; |
250 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
327 | + if ($globalDebug) { |
|
328 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
329 | + } |
|
251 | 330 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
252 | 331 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
253 | 332 | exit(0); |
@@ -256,16 +335,24 @@ discard block |
||
256 | 335 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
257 | 336 | //$formats[$id] = 'tsv'; |
258 | 337 | $globalSources[$id]['format'] = 'tsv'; |
259 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
338 | + if ($globalDebug) { |
|
339 | + echo "Connect to tsv source (".$host.")...\n"; |
|
340 | + } |
|
260 | 341 | } |
261 | 342 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
262 | 343 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
263 | 344 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
264 | 345 | if ($idf !== false) { |
265 | 346 | $httpfeeds[$id] = $idf; |
266 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
267 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
268 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
347 | + if ($globalDebug) { |
|
348 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
349 | + } |
|
350 | + } elseif ($globalDebug) { |
|
351 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
352 | + } |
|
353 | + } elseif ($globalDebug) { |
|
354 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
355 | + } |
|
269 | 356 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
270 | 357 | $hostport = explode(':',$host); |
271 | 358 | if (isset($hostport[1])) { |
@@ -305,19 +392,27 @@ discard block |
||
305 | 392 | //$formats[$id] = 'beast'; |
306 | 393 | $globalSources[$id]['format'] = 'beast'; |
307 | 394 | //} else $formats[$id] = 'sbs'; |
308 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
395 | + } else { |
|
396 | + $globalSources[$id]['format'] = 'sbs'; |
|
397 | + } |
|
309 | 398 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
310 | 399 | } |
311 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
400 | + if ($globalDebug) { |
|
401 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
402 | + } |
|
312 | 403 | } else { |
313 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
404 | + if ($globalDebug) { |
|
405 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
406 | + } |
|
314 | 407 | sleep(10); |
315 | 408 | $this->connect_all($hosts); |
316 | 409 | } |
317 | 410 | } |
318 | 411 | } |
319 | 412 | } |
320 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
413 | +if (!isset($globalMinFetch)) { |
|
414 | + $globalMinFetch = 15; |
|
415 | +} |
|
321 | 416 | |
322 | 417 | // Initialize all |
323 | 418 | $status = array(); |
@@ -326,13 +421,19 @@ discard block |
||
326 | 421 | $formats = array(); |
327 | 422 | $last_exec = array(); |
328 | 423 | $time = time(); |
329 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
330 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
331 | -else $timeout = 20; |
|
424 | +if (isset($globalSourcesTimeout)) { |
|
425 | + $timeout = $globalSourcesTimeOut; |
|
426 | +} else if (isset($globalSBS1TimeOut)) { |
|
427 | + $timeout = $globalSBS1TimeOut; |
|
428 | +} else { |
|
429 | + $timeout = 20; |
|
430 | +} |
|
332 | 431 | $errno = ''; |
333 | 432 | $errstr=''; |
334 | 433 | |
335 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
434 | +if (!isset($globalDaemon)) { |
|
435 | + $globalDaemon = TRUE; |
|
436 | +} |
|
336 | 437 | /* Initiate connections to all the hosts simultaneously */ |
337 | 438 | //connect_all($hosts); |
338 | 439 | //connect_all($globalSources); |
@@ -361,7 +462,9 @@ discard block |
||
361 | 462 | if (isset($source['format']) && $source['format'] == 'aprs') { |
362 | 463 | $aprs_connect = 0; |
363 | 464 | $use_aprs = true; |
364 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
465 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
466 | + $aprs_full = true; |
|
467 | + } |
|
365 | 468 | break; |
366 | 469 | } |
367 | 470 | } |
@@ -372,25 +475,46 @@ discard block |
||
372 | 475 | $aprs_connect = 0; |
373 | 476 | $aprs_keep = 120; |
374 | 477 | $aprs_last_tx = time(); |
375 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
376 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
377 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
378 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
379 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
380 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
381 | - if ($aprs_full) $aprs_filter = ''; |
|
382 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
383 | - else $aprs_pass = '-1'; |
|
478 | + if (isset($globalAPRSversion)) { |
|
479 | + $aprs_version = $globalAPRSversion; |
|
480 | + } else { |
|
481 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
482 | + } |
|
483 | + if (isset($globalAPRSssid)) { |
|
484 | + $aprs_ssid = $globalAPRSssid; |
|
485 | + } else { |
|
486 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
487 | + } |
|
488 | + if (isset($globalAPRSfilter)) { |
|
489 | + $aprs_filter = $globalAPRSfilter; |
|
490 | + } else { |
|
491 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
492 | + } |
|
493 | + if ($aprs_full) { |
|
494 | + $aprs_filter = ''; |
|
495 | + } |
|
496 | + if (isset($globalAPRSpass)) { |
|
497 | + $aprs_pass = $globalAPRSpass; |
|
498 | + } else { |
|
499 | + $aprs_pass = '-1'; |
|
500 | + } |
|
384 | 501 | |
385 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
386 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
387 | -} |
|
502 | + if ($aprs_filter != '') { |
|
503 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
504 | + } else { |
|
505 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
506 | + } |
|
507 | + } |
|
388 | 508 | |
389 | 509 | // connected - lets do some work |
390 | 510 | //if ($globalDebug) echo "Connected!\n"; |
391 | 511 | sleep(1); |
392 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
393 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
512 | +if ($globalDebug) { |
|
513 | + echo "SCAN MODE \n\n"; |
|
514 | +} |
|
515 | +if (!isset($globalCronEnd)) { |
|
516 | + $globalCronEnd = 60; |
|
517 | +} |
|
394 | 518 | $endtime = time()+$globalCronEnd; |
395 | 519 | $i = 1; |
396 | 520 | $tt = array(); |
@@ -404,22 +528,32 @@ discard block |
||
404 | 528 | |
405 | 529 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
406 | 530 | while ($i > 0) { |
407 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
531 | + if (function_exists('pcntl_fork')) { |
|
532 | + pcntl_signal_dispatch(); |
|
533 | + } |
|
408 | 534 | |
409 | - if (!$globalDaemon) $i = $endtime-time(); |
|
535 | + if (!$globalDaemon) { |
|
536 | + $i = $endtime-time(); |
|
537 | + } |
|
410 | 538 | // Delete old ATC |
411 | 539 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
412 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
540 | + if ($globalDebug) { |
|
541 | + echo 'Delete old ATC...'."\n"; |
|
542 | + } |
|
413 | 543 | $ATC->deleteOldATC(); |
414 | 544 | } |
415 | 545 | |
416 | 546 | if (count($last_exec) == count($globalSources)) { |
417 | 547 | $max = $globalMinFetch; |
418 | 548 | foreach ($last_exec as $last) { |
419 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
549 | + if ((time() - $last['last']) < $max) { |
|
550 | + $max = time() - $last['last']; |
|
551 | + } |
|
420 | 552 | } |
421 | 553 | if ($max < $globalMinFetch) { |
422 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
554 | + if ($globalDebug) { |
|
555 | + echo 'Sleeping...'."\n"; |
|
556 | + } |
|
423 | 557 | sleep($globalMinFetch-$max+2); |
424 | 558 | } |
425 | 559 | } |
@@ -429,7 +563,9 @@ discard block |
||
429 | 563 | foreach ($globalSources as $id => $value) { |
430 | 564 | date_default_timezone_set('UTC'); |
431 | 565 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
432 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
566 | + if (!isset($last_exec[$id]['last'])) { |
|
567 | + $last_exec[$id]['last'] = 0; |
|
568 | + } |
|
433 | 569 | if ($value['format'] === 'deltadbtxt' && |
434 | 570 | ( |
435 | 571 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -438,7 +574,9 @@ discard block |
||
438 | 574 | ) { |
439 | 575 | //$buffer = $Common->getData($hosts[$id]); |
440 | 576 | $buffer = $Common->getData($value['host']); |
441 | - if ($buffer != '') $reset = 0; |
|
577 | + if ($buffer != '') { |
|
578 | + $reset = 0; |
|
579 | + } |
|
442 | 580 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
443 | 581 | $buffer = explode('\n',$buffer); |
444 | 582 | foreach ($buffer as $line) { |
@@ -447,20 +585,41 @@ discard block |
||
447 | 585 | $data = array(); |
448 | 586 | $data['hex'] = $line[1]; // hex |
449 | 587 | $data['ident'] = $line[2]; // ident |
450 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
451 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
452 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
453 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
454 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
588 | + if (isset($line[3])) { |
|
589 | + $data['altitude'] = $line[3]; |
|
590 | + } |
|
591 | + // altitude |
|
592 | + if (isset($line[4])) { |
|
593 | + $data['speed'] = $line[4]; |
|
594 | + } |
|
595 | + // speed |
|
596 | + if (isset($line[5])) { |
|
597 | + $data['heading'] = $line[5]; |
|
598 | + } |
|
599 | + // heading |
|
600 | + if (isset($line[6])) { |
|
601 | + $data['latitude'] = $line[6]; |
|
602 | + } |
|
603 | + // lat |
|
604 | + if (isset($line[7])) { |
|
605 | + $data['longitude'] = $line[7]; |
|
606 | + } |
|
607 | + // long |
|
455 | 608 | $data['verticalrate'] = ''; // vertical rate |
456 | 609 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
457 | 610 | $data['emergency'] = ''; // emergency |
458 | 611 | $data['datetime'] = date('Y-m-d H:i:s'); |
459 | 612 | $data['format_source'] = 'deltadbtxt'; |
460 | 613 | $data['id_source'] = $id_source; |
461 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
462 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
463 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
614 | + if (isset($value['name']) && $value['name'] != '') { |
|
615 | + $data['source_name'] = $value['name']; |
|
616 | + } |
|
617 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
618 | + $data['noarchive'] = true; |
|
619 | + } |
|
620 | + if (isset($value['sourcestats'])) { |
|
621 | + $data['sourcestats'] = $value['sourcestats']; |
|
622 | + } |
|
464 | 623 | $SI->add($data); |
465 | 624 | unset($data); |
466 | 625 | } |
@@ -475,7 +634,9 @@ discard block |
||
475 | 634 | date_default_timezone_set('CET'); |
476 | 635 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
477 | 636 | date_default_timezone_set('UTC'); |
478 | - if ($buffer != '') $reset = 0; |
|
637 | + if ($buffer != '') { |
|
638 | + $reset = 0; |
|
639 | + } |
|
479 | 640 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
480 | 641 | $buffer = explode('\n',$buffer); |
481 | 642 | foreach ($buffer as $line) { |
@@ -484,18 +645,42 @@ discard block |
||
484 | 645 | $add = false; |
485 | 646 | $ais_data = $AIS->parse_line(trim($line)); |
486 | 647 | $data = array(); |
487 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
488 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
489 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
490 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
491 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
492 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
493 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
494 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
495 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
496 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
497 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
498 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
648 | + if (isset($ais_data['ident'])) { |
|
649 | + $data['ident'] = $ais_data['ident']; |
|
650 | + } |
|
651 | + if (isset($ais_data['mmsi'])) { |
|
652 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
653 | + } |
|
654 | + if (isset($ais_data['speed'])) { |
|
655 | + $data['speed'] = $ais_data['speed']; |
|
656 | + } |
|
657 | + if (isset($ais_data['heading'])) { |
|
658 | + $data['heading'] = $ais_data['heading']; |
|
659 | + } |
|
660 | + if (isset($ais_data['latitude'])) { |
|
661 | + $data['latitude'] = $ais_data['latitude']; |
|
662 | + } |
|
663 | + if (isset($ais_data['longitude'])) { |
|
664 | + $data['longitude'] = $ais_data['longitude']; |
|
665 | + } |
|
666 | + if (isset($ais_data['status'])) { |
|
667 | + $data['status'] = $ais_data['status']; |
|
668 | + } |
|
669 | + if (isset($ais_data['statusid'])) { |
|
670 | + $data['status_id'] = $ais_data['statusid']; |
|
671 | + } |
|
672 | + if (isset($ais_data['type'])) { |
|
673 | + $data['type'] = $ais_data['type']; |
|
674 | + } |
|
675 | + if (isset($ais_data['typeid'])) { |
|
676 | + $data['type_id'] = $ais_data['typeid']; |
|
677 | + } |
|
678 | + if (isset($ais_data['imo'])) { |
|
679 | + $data['imo'] = $ais_data['imo']; |
|
680 | + } |
|
681 | + if (isset($ais_data['callsign'])) { |
|
682 | + $data['callsign'] = $ais_data['callsign']; |
|
683 | + } |
|
499 | 684 | if (isset($ais_data['timestamp'])) { |
500 | 685 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
501 | 686 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -509,8 +694,12 @@ discard block |
||
509 | 694 | $data['format_source'] = 'aisnmeatxt'; |
510 | 695 | $data['id_source'] = $id_source; |
511 | 696 | //print_r($data); |
512 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
513 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
697 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
698 | + $data['noarchive'] = true; |
|
699 | + } |
|
700 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
701 | + $MI->add($data); |
|
702 | + } |
|
514 | 703 | unset($data); |
515 | 704 | } |
516 | 705 | } |
@@ -533,20 +722,48 @@ discard block |
||
533 | 722 | if ($line != '') { |
534 | 723 | $ais_data = $AIS->parse_line(trim($line)); |
535 | 724 | $data = array(); |
536 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
537 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
538 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
539 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
540 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
541 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
542 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
543 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
544 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
545 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
546 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
547 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
548 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
549 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
725 | + if (isset($ais_data['ident'])) { |
|
726 | + $data['ident'] = $ais_data['ident']; |
|
727 | + } |
|
728 | + if (isset($ais_data['mmsi'])) { |
|
729 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
730 | + } |
|
731 | + if (isset($ais_data['speed'])) { |
|
732 | + $data['speed'] = $ais_data['speed']; |
|
733 | + } |
|
734 | + if (isset($ais_data['heading'])) { |
|
735 | + $data['heading'] = $ais_data['heading']; |
|
736 | + } |
|
737 | + if (isset($ais_data['latitude'])) { |
|
738 | + $data['latitude'] = $ais_data['latitude']; |
|
739 | + } |
|
740 | + if (isset($ais_data['longitude'])) { |
|
741 | + $data['longitude'] = $ais_data['longitude']; |
|
742 | + } |
|
743 | + if (isset($ais_data['status'])) { |
|
744 | + $data['status'] = $ais_data['status']; |
|
745 | + } |
|
746 | + if (isset($ais_data['statusid'])) { |
|
747 | + $data['status_id'] = $ais_data['statusid']; |
|
748 | + } |
|
749 | + if (isset($ais_data['type'])) { |
|
750 | + $data['type'] = $ais_data['type']; |
|
751 | + } |
|
752 | + if (isset($ais_data['typeid'])) { |
|
753 | + $data['type_id'] = $ais_data['typeid']; |
|
754 | + } |
|
755 | + if (isset($ais_data['imo'])) { |
|
756 | + $data['imo'] = $ais_data['imo']; |
|
757 | + } |
|
758 | + if (isset($ais_data['callsign'])) { |
|
759 | + $data['callsign'] = $ais_data['callsign']; |
|
760 | + } |
|
761 | + if (isset($ais_data['destination'])) { |
|
762 | + $data['arrival_code'] = $ais_data['destination']; |
|
763 | + } |
|
764 | + if (isset($ais_data['eta_ts'])) { |
|
765 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
766 | + } |
|
550 | 767 | if (isset($ais_data['timestamp'])) { |
551 | 768 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
552 | 769 | } else { |
@@ -554,18 +771,27 @@ discard block |
||
554 | 771 | } |
555 | 772 | $data['format_source'] = 'aisnmeahttp'; |
556 | 773 | $data['id_source'] = $id_source; |
557 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
558 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
774 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
775 | + $data['noarchive'] = true; |
|
776 | + } |
|
777 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
778 | + $MI->add($data); |
|
779 | + } |
|
559 | 780 | unset($data); |
560 | 781 | } |
561 | 782 | } |
562 | 783 | } |
563 | 784 | } else { |
564 | 785 | $format = $value['format']; |
565 | - if (isset($tt[$format])) $tt[$format]++; |
|
566 | - else $tt[$format] = 0; |
|
786 | + if (isset($tt[$format])) { |
|
787 | + $tt[$format]++; |
|
788 | + } else { |
|
789 | + $tt[$format] = 0; |
|
790 | + } |
|
567 | 791 | if ($tt[$format] > 30) { |
568 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
792 | + if ($globalDebug) { |
|
793 | + echo 'Reconnect...'."\n"; |
|
794 | + } |
|
569 | 795 | sleep(2); |
570 | 796 | //$sourceeen[] = $value; |
571 | 797 | //connect_all($sourceeen); |
@@ -601,12 +827,18 @@ discard block |
||
601 | 827 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
602 | 828 | //$data['type_id'] = $line['TYPE']; |
603 | 829 | $data['imo'] = $line['IMO']; |
604 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
605 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
830 | + if ($line['DEST'] != '') { |
|
831 | + $data['arrival_code'] = $line['DEST']; |
|
832 | + } |
|
833 | + if ($line['ARV'] != '') { |
|
834 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
835 | + } |
|
606 | 836 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
607 | 837 | $data['format_source'] = 'myshiptracking'; |
608 | 838 | $data['id_source'] = $id_source; |
609 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
839 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
840 | + $data['noarchive'] = true; |
|
841 | + } |
|
610 | 842 | $MI->add($data); |
611 | 843 | unset($data); |
612 | 844 | } |
@@ -631,7 +863,9 @@ discard block |
||
631 | 863 | $data['callsign'] = $line['callsign']; |
632 | 864 | $data['mmsi'] = substr($line['mmsi'],-9); |
633 | 865 | $data['speed'] = $line['sog']; |
634 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
866 | + if ($line['heading'] != '511') { |
|
867 | + $data['heading'] = $line['heading']; |
|
868 | + } |
|
635 | 869 | $data['latitude'] = $line['latitude']; |
636 | 870 | $data['longitude'] = $line['longitude']; |
637 | 871 | $data['type_id'] = $line['shiptype']; |
@@ -639,7 +873,9 @@ discard block |
||
639 | 873 | $data['datetime'] = $line['time']; |
640 | 874 | $data['format_source'] = 'boatbeaconapp'; |
641 | 875 | $data['id_source'] = $id_source; |
642 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
876 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
877 | + $data['noarchive'] = true; |
|
878 | + } |
|
643 | 879 | $MI->add($data); |
644 | 880 | unset($data); |
645 | 881 | } |
@@ -661,22 +897,44 @@ discard block |
||
661 | 897 | foreach ($all_data['features'] as $line) { |
662 | 898 | print_r($line); |
663 | 899 | $data = array(); |
664 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
665 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
666 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
667 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
668 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
669 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
900 | + if (isset($line['properties']['name'])) { |
|
901 | + $data['ident'] = $line['properties']['name']; |
|
902 | + } |
|
903 | + if (isset($line['properties']['callsign'])) { |
|
904 | + $data['callsign'] = $line['properties']['callsign']; |
|
905 | + } |
|
906 | + if (isset($line['properties']['mmsi'])) { |
|
907 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
908 | + } |
|
909 | + if (isset($line['properties']['imo'])) { |
|
910 | + $data['imo'] = $line['properties']['imo']; |
|
911 | + } |
|
912 | + if (isset($line['properties']['speed'])) { |
|
913 | + $data['speed'] = $line['properties']['speed']; |
|
914 | + } |
|
915 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
916 | + $data['heading'] = $line['properties']['heading']; |
|
917 | + } |
|
670 | 918 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
671 | 919 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
672 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
673 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
674 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
920 | + if (isset($line['properties']['vesselType'])) { |
|
921 | + $data['type'] = $line['properties']['vesselType']; |
|
922 | + } |
|
923 | + if (isset($line['properties']['destination'])) { |
|
924 | + $data['arrival_code'] = $line['properties']['destination']; |
|
925 | + } |
|
926 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
927 | + $data['arrival_date'] = $line['properties']['eta']; |
|
928 | + } |
|
675 | 929 | $data['format_source'] = 'boatnerd'; |
676 | 930 | $data['id_source'] = $id_source; |
677 | 931 | $data['datetime'] = date('Y-m-d H:i:s'); |
678 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
679 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
932 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
933 | + $data['noarchive'] = true; |
|
934 | + } |
|
935 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
936 | + $MI->add($data); |
|
937 | + } |
|
680 | 938 | unset($data); |
681 | 939 | } |
682 | 940 | } |
@@ -693,7 +951,9 @@ discard block |
||
693 | 951 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
694 | 952 | echo 'done !'."\n"; |
695 | 953 | // FIXME: Need more work |
696 | - if ($buffer != '') $reset = 0; |
|
954 | + if ($buffer != '') { |
|
955 | + $reset = 0; |
|
956 | + } |
|
697 | 957 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
698 | 958 | $buffer = explode('\n',$buffer); |
699 | 959 | foreach ($buffer as $line) { |
@@ -719,7 +979,9 @@ discard block |
||
719 | 979 | //$data['etaTime'] = substr($line,135,5); |
720 | 980 | $data['format_source'] = 'shipplotter'; |
721 | 981 | $data['id_source'] = $id_source; |
722 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
982 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
983 | + $data['noarchive'] = true; |
|
984 | + } |
|
723 | 985 | //print_r($data); |
724 | 986 | echo 'Add...'."\n"; |
725 | 987 | $MI->add($data); |
@@ -753,16 +1015,28 @@ discard block |
||
753 | 1015 | $line = explode(':', $line); |
754 | 1016 | if (count($line) > 30 && $line[0] != 'callsign') { |
755 | 1017 | $data = array(); |
756 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
757 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1018 | + if (isset($line[37]) && $line[37] != '') { |
|
1019 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
1020 | + } else { |
|
1021 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1022 | + } |
|
758 | 1023 | $data['pilot_id'] = $line[1]; |
759 | 1024 | $data['pilot_name'] = $line[2]; |
760 | 1025 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
761 | 1026 | $data['ident'] = $line[0]; // ident |
762 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
1027 | + if ($line[7] != '' && $line[7] != 0) { |
|
1028 | + $data['altitude'] = $line[7]; |
|
1029 | + } |
|
1030 | + // altitude |
|
763 | 1031 | $data['speed'] = $line[8]; // speed |
764 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
765 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
1032 | + if (isset($line[45])) { |
|
1033 | + $data['heading'] = $line[45]; |
|
1034 | + } |
|
1035 | + // heading |
|
1036 | + elseif (isset($line[38])) { |
|
1037 | + $data['heading'] = $line[38]; |
|
1038 | + } |
|
1039 | + // heading |
|
766 | 1040 | $data['latitude'] = $line[5]; // lat |
767 | 1041 | $data['longitude'] = $line[6]; // long |
768 | 1042 | $data['verticalrate'] = ''; // vertical rate |
@@ -778,7 +1052,9 @@ discard block |
||
778 | 1052 | $data['frequency'] = $line[4]; |
779 | 1053 | $data['type'] = $line[18]; |
780 | 1054 | $data['range'] = $line[19]; |
781 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
1055 | + if (isset($line[35])) { |
|
1056 | + $data['info'] = $line[35]; |
|
1057 | + } |
|
782 | 1058 | $data['id_source'] = $id_source; |
783 | 1059 | //$data['arrival_airport_time'] = ; |
784 | 1060 | if ($line[9] != '') { |
@@ -792,27 +1068,47 @@ discard block |
||
792 | 1068 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
793 | 1069 | */ |
794 | 1070 | $data['format_source'] = $value['format']; |
795 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
796 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
797 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
798 | - elseif ($line[3] === 'ATC') { |
|
1071 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1072 | + $data['noarchive'] = true; |
|
1073 | + } |
|
1074 | + if (isset($value['name']) && $value['name'] != '') { |
|
1075 | + $data['source_name'] = $value['name']; |
|
1076 | + } |
|
1077 | + if ($line[3] === 'PILOT') { |
|
1078 | + $SI->add($data); |
|
1079 | + } elseif ($line[3] === 'ATC') { |
|
799 | 1080 | //print_r($data); |
800 | 1081 | $data['info'] = str_replace('^§','<br />',$data['info']); |
801 | 1082 | $data['info'] = str_replace('&sect;','',$data['info']); |
802 | 1083 | $typec = substr($data['ident'],-3); |
803 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
804 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
805 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
806 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
807 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
808 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
809 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
810 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
811 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
812 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
1084 | + if ($typec === 'APP') { |
|
1085 | + $data['type'] = 'Approach'; |
|
1086 | + } elseif ($typec === 'TWR') { |
|
1087 | + $data['type'] = 'Tower'; |
|
1088 | + } elseif ($typec === 'OBS') { |
|
1089 | + $data['type'] = 'Observer'; |
|
1090 | + } elseif ($typec === 'GND') { |
|
1091 | + $data['type'] = 'Ground'; |
|
1092 | + } elseif ($typec === 'DEL') { |
|
1093 | + $data['type'] = 'Delivery'; |
|
1094 | + } elseif ($typec === 'DEP') { |
|
1095 | + $data['type'] = 'Departure'; |
|
1096 | + } elseif ($typec === 'FSS') { |
|
1097 | + $data['type'] = 'Flight Service Station'; |
|
1098 | + } elseif ($typec === 'CTR') { |
|
1099 | + $data['type'] = 'Control Radar or Centre'; |
|
1100 | + } elseif ($data['type'] === '') { |
|
1101 | + $data['type'] = 'Observer'; |
|
1102 | + } |
|
1103 | + if (!isset($data['source_name'])) { |
|
1104 | + $data['source_name'] = ''; |
|
1105 | + } |
|
813 | 1106 | if (isset($ATC)) { |
814 | - 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']); |
|
815 | - 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']); |
|
1107 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1108 | + 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']); |
|
1109 | + } else { |
|
1110 | + 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']); |
|
1111 | + } |
|
816 | 1112 | } |
817 | 1113 | } |
818 | 1114 | unset($data); |
@@ -839,14 +1135,20 @@ discard block |
||
839 | 1135 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
840 | 1136 | $data['latitude'] = (float)$line['pktLatitude']; |
841 | 1137 | $data['longitude'] = (float)$line['pktLongitude']; |
842 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
843 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1138 | + if ((float)$line['pktTrack'] != 0) { |
|
1139 | + $data['heading'] = (float)$line['pktTrack']; |
|
1140 | + } |
|
1141 | + if ((int)$line['pktSpeed'] != 0) { |
|
1142 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1143 | + } |
|
844 | 1144 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
845 | 1145 | $data['altitude_relative'] = 'AMSL'; |
846 | 1146 | $data['pilot_id'] = (int)$line['pktPilotID']; |
847 | 1147 | $data['aircraft_icao'] = 'PARAGLIDER'; |
848 | 1148 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
849 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1149 | + if (isset($pilot_data[4])) { |
|
1150 | + $data['pilot_name'] = $pilot_data[4]; |
|
1151 | + } |
|
850 | 1152 | $data['format_source'] = $value['format']; |
851 | 1153 | $SI->add($data); |
852 | 1154 | unset($data); |
@@ -894,25 +1196,59 @@ discard block |
||
894 | 1196 | foreach ($all_data['acList'] as $line) { |
895 | 1197 | $data = array(); |
896 | 1198 | $data['hex'] = $line['Icao']; // hex |
897 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
898 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
899 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
900 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
901 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
902 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1199 | + if (isset($line['Call'])) { |
|
1200 | + $data['ident'] = $line['Call']; |
|
1201 | + } |
|
1202 | + // ident |
|
1203 | + if (isset($line['Alt'])) { |
|
1204 | + $data['altitude'] = $line['Alt']; |
|
1205 | + } |
|
1206 | + // altitude |
|
1207 | + if (isset($line['Spd'])) { |
|
1208 | + $data['speed'] = $line['Spd']; |
|
1209 | + } |
|
1210 | + // speed |
|
1211 | + if (isset($line['Trak'])) { |
|
1212 | + $data['heading'] = $line['Trak']; |
|
1213 | + } |
|
1214 | + // heading |
|
1215 | + if (isset($line['Lat'])) { |
|
1216 | + $data['latitude'] = $line['Lat']; |
|
1217 | + } |
|
1218 | + // lat |
|
1219 | + if (isset($line['Long'])) { |
|
1220 | + $data['longitude'] = $line['Long']; |
|
1221 | + } |
|
1222 | + // long |
|
903 | 1223 | //$data['verticalrate'] = $line['']; // verticale rate |
904 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1224 | + if (isset($line['Sqk'])) { |
|
1225 | + $data['squawk'] = $line['Sqk']; |
|
1226 | + } |
|
1227 | + // squawk |
|
905 | 1228 | $data['emergency'] = ''; // emergency |
906 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
907 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
908 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1229 | + if (isset($line['Reg'])) { |
|
1230 | + $data['registration'] = $line['Reg']; |
|
1231 | + } |
|
1232 | + if (isset($line['PosTime'])) { |
|
1233 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1234 | + } else { |
|
1235 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1236 | + } |
|
909 | 1237 | //$data['datetime'] = date('Y-m-d H:i:s'); |
910 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1238 | + if (isset($line['Type'])) { |
|
1239 | + $data['aircraft_icao'] = $line['Type']; |
|
1240 | + } |
|
911 | 1241 | $data['format_source'] = 'aircraftlistjson'; |
912 | 1242 | $data['id_source'] = $id_source; |
913 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
914 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
915 | - if (isset($data['latitude'])) $SI->add($data); |
|
1243 | + if (isset($value['name']) && $value['name'] != '') { |
|
1244 | + $data['source_name'] = $value['name']; |
|
1245 | + } |
|
1246 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1247 | + $data['noarchive'] = true; |
|
1248 | + } |
|
1249 | + if (isset($data['latitude'])) { |
|
1250 | + $SI->add($data); |
|
1251 | + } |
|
916 | 1252 | unset($data); |
917 | 1253 | } |
918 | 1254 | } elseif (is_array($all_data)) { |
@@ -929,17 +1265,26 @@ discard block |
||
929 | 1265 | $data['verticalrate'] = $line['vrt']; // verticale rate |
930 | 1266 | $data['squawk'] = $line['squawk']; // squawk |
931 | 1267 | $data['emergency'] = ''; // emergency |
932 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
933 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1268 | + if (isset($line['PosTime'])) { |
|
1269 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1270 | + } else { |
|
1271 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1272 | + } |
|
934 | 1273 | $data['format_source'] = 'aircraftlistjson'; |
935 | 1274 | $data['id_source'] = $id_source; |
936 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
937 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1275 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1276 | + $data['noarchive'] = true; |
|
1277 | + } |
|
1278 | + if (isset($value['name']) && $value['name'] != '') { |
|
1279 | + $data['source_name'] = $value['name']; |
|
1280 | + } |
|
938 | 1281 | $SI->add($data); |
939 | 1282 | unset($data); |
940 | 1283 | } |
941 | 1284 | } |
942 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1285 | + } elseif ($globalDebug) { |
|
1286 | + echo 'No data'."\n"; |
|
1287 | + } |
|
943 | 1288 | //$last_exec['aircraftlistjson'] = time(); |
944 | 1289 | $last_exec[$id]['last'] = time(); |
945 | 1290 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -975,8 +1320,12 @@ discard block |
||
975 | 1320 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
976 | 1321 | $data['format_source'] = 'planeupdatefaa'; |
977 | 1322 | $data['id_source'] = $id_source; |
978 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
979 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1323 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1324 | + $data['noarchive'] = true; |
|
1325 | + } |
|
1326 | + if (isset($value['name']) && $value['name'] != '') { |
|
1327 | + $data['source_name'] = $value['name']; |
|
1328 | + } |
|
980 | 1329 | $SI->add($data); |
981 | 1330 | unset($data); |
982 | 1331 | } |
@@ -1010,7 +1359,9 @@ discard block |
||
1010 | 1359 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
1011 | 1360 | $data['format_source'] = 'opensky'; |
1012 | 1361 | $data['id_source'] = $id_source; |
1013 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1362 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1363 | + $data['noarchive'] = true; |
|
1364 | + } |
|
1014 | 1365 | $SI->add($data); |
1015 | 1366 | unset($data); |
1016 | 1367 | } |
@@ -1030,15 +1381,42 @@ discard block |
||
1030 | 1381 | foreach ($all_data['aircraft'] as $key => $line) { |
1031 | 1382 | $data = array(); |
1032 | 1383 | // add support for ground vehicule with ~ in front of hex |
1033 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1034 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1035 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1036 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1037 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1038 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1039 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1040 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1041 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1384 | + if (isset($line['hex'])) { |
|
1385 | + $data['hex'] = $line['hex']; |
|
1386 | + } |
|
1387 | + // hex |
|
1388 | + if (isset($line['flight'])) { |
|
1389 | + $data['ident'] = trim($line['flight']); |
|
1390 | + } |
|
1391 | + // ident |
|
1392 | + if (isset($line['altitude'])) { |
|
1393 | + $data['altitude'] = $line['altitude']; |
|
1394 | + } |
|
1395 | + // altitude |
|
1396 | + if (isset($line['speed'])) { |
|
1397 | + $data['speed'] = $line['speed']; |
|
1398 | + } |
|
1399 | + // speed |
|
1400 | + if (isset($line['track'])) { |
|
1401 | + $data['heading'] = $line['track']; |
|
1402 | + } |
|
1403 | + // heading |
|
1404 | + if (isset($line['lat'])) { |
|
1405 | + $data['latitude'] = $line['lat']; |
|
1406 | + } |
|
1407 | + // lat |
|
1408 | + if (isset($line['lon'])) { |
|
1409 | + $data['longitude'] = $line['lon']; |
|
1410 | + } |
|
1411 | + // long |
|
1412 | + if (isset($line['vert_rate'])) { |
|
1413 | + $data['verticalrate'] = $line['vert_rate']; |
|
1414 | + } |
|
1415 | + // verticale rate |
|
1416 | + if (isset($line['squawk'])) { |
|
1417 | + $data['squawk'] = $line['squawk']; |
|
1418 | + } |
|
1419 | + // squawk |
|
1042 | 1420 | //$data['emergency'] = ''; // emergency |
1043 | 1421 | //$data['registration'] = $line[2]; |
1044 | 1422 | //$data['aircraft_icao'] = $line[0]; |
@@ -1046,10 +1424,17 @@ discard block |
||
1046 | 1424 | $data['format_source'] = 'aircraftjson'; |
1047 | 1425 | $data['id_source'] = $id_source; |
1048 | 1426 | if (isset($value['name']) && $value['name'] != '') { |
1049 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1050 | - else $data['source_name'] = $value['name']; |
|
1051 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1052 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1427 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1428 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
1429 | + } else { |
|
1430 | + $data['source_name'] = $value['name']; |
|
1431 | + } |
|
1432 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1433 | + $data['source_name'] = 'MLAT'; |
|
1434 | + } |
|
1435 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1436 | + $data['noarchive'] = true; |
|
1437 | + } |
|
1053 | 1438 | $SI->add($data); |
1054 | 1439 | unset($data); |
1055 | 1440 | } |
@@ -1066,7 +1451,9 @@ discard block |
||
1066 | 1451 | //$buffer = $Common->getData($hosts[$id]); |
1067 | 1452 | $buffer = $Common->getData($value['host']); |
1068 | 1453 | $all_data = json_decode($buffer,true); |
1069 | - if (!empty($all_data)) $reset = 0; |
|
1454 | + if (!empty($all_data)) { |
|
1455 | + $reset = 0; |
|
1456 | + } |
|
1070 | 1457 | foreach ($all_data as $key => $line) { |
1071 | 1458 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1072 | 1459 | $data = array(); |
@@ -1087,8 +1474,12 @@ discard block |
||
1087 | 1474 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
1088 | 1475 | $data['format_source'] = 'fr24json'; |
1089 | 1476 | $data['id_source'] = $id_source; |
1090 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1091 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1477 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1478 | + $data['noarchive'] = true; |
|
1479 | + } |
|
1480 | + if (isset($value['name']) && $value['name'] != '') { |
|
1481 | + $data['source_name'] = $value['name']; |
|
1482 | + } |
|
1092 | 1483 | $SI->add($data); |
1093 | 1484 | unset($data); |
1094 | 1485 | } |
@@ -1117,24 +1508,42 @@ discard block |
||
1117 | 1508 | if (isset($line['inf'])) { |
1118 | 1509 | $data = array(); |
1119 | 1510 | $data['hex'] = $line['inf']['ia']; |
1120 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1511 | + if (isset($line['inf']['cs'])) { |
|
1512 | + $data['ident'] = $line['inf']['cs']; |
|
1513 | + } |
|
1514 | + //$line[13] |
|
1121 | 1515 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1122 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1123 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1516 | + if (isset($line['inf']['gs'])) { |
|
1517 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1518 | + } |
|
1519 | + // speed |
|
1520 | + if (isset($line['inf']['tr'])) { |
|
1521 | + $data['heading'] = $line['inf']['tr']; |
|
1522 | + } |
|
1523 | + // heading |
|
1124 | 1524 | $data['latitude'] = $line['pt'][0]; // lat |
1125 | 1525 | $data['longitude'] = $line['pt'][1]; // long |
1126 | 1526 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1127 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1527 | + if (isset($line['inf']['sq'])) { |
|
1528 | + $data['squawk'] = $line['inf']['sq']; |
|
1529 | + } |
|
1530 | + // squawk |
|
1128 | 1531 | //$data['aircraft_icao'] = $line[8]; |
1129 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1532 | + if (isset($line['inf']['rc'])) { |
|
1533 | + $data['registration'] = $line['inf']['rc']; |
|
1534 | + } |
|
1130 | 1535 | //$data['departure_airport_iata'] = $line[11]; |
1131 | 1536 | //$data['arrival_airport_iata'] = $line[12]; |
1132 | 1537 | //$data['emergency'] = ''; // emergency |
1133 | 1538 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1134 | 1539 | $data['format_source'] = 'radarvirtueljson'; |
1135 | 1540 | $data['id_source'] = $id_source; |
1136 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1137 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1541 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1542 | + $data['noarchive'] = true; |
|
1543 | + } |
|
1544 | + if (isset($value['name']) && $value['name'] != '') { |
|
1545 | + $data['source_name'] = $value['name']; |
|
1546 | + } |
|
1138 | 1547 | $SI->add($data); |
1139 | 1548 | unset($data); |
1140 | 1549 | } |
@@ -1160,30 +1569,65 @@ discard block |
||
1160 | 1569 | $data['id'] = $line['id']; |
1161 | 1570 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1162 | 1571 | $data['ident'] = $line['callsign']; // ident |
1163 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1164 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1165 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1166 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1167 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1168 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1572 | + if (isset($line['pilotid'])) { |
|
1573 | + $data['pilot_id'] = $line['pilotid']; |
|
1574 | + } |
|
1575 | + // pilot id |
|
1576 | + if (isset($line['name'])) { |
|
1577 | + $data['pilot_name'] = $line['name']; |
|
1578 | + } |
|
1579 | + // pilot name |
|
1580 | + if (isset($line['alt'])) { |
|
1581 | + $data['altitude'] = $line['alt']; |
|
1582 | + } |
|
1583 | + // altitude |
|
1584 | + if (isset($line['gs'])) { |
|
1585 | + $data['speed'] = $line['gs']; |
|
1586 | + } |
|
1587 | + // speed |
|
1588 | + if (isset($line['heading'])) { |
|
1589 | + $data['heading'] = $line['heading']; |
|
1590 | + } |
|
1591 | + // heading |
|
1592 | + if (isset($line['route'])) { |
|
1593 | + $data['waypoints'] = $line['route']; |
|
1594 | + } |
|
1595 | + // route |
|
1169 | 1596 | $data['latitude'] = $line['lat']; // lat |
1170 | 1597 | $data['longitude'] = $line['lon']; // long |
1171 | 1598 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1172 | 1599 | //$data['squawk'] = $line['squawk']; // squawk |
1173 | 1600 | //$data['emergency'] = ''; // emergency |
1174 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1175 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1176 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1601 | + if (isset($line['depicao'])) { |
|
1602 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1603 | + } |
|
1604 | + if (isset($line['deptime'])) { |
|
1605 | + $data['departure_airport_time'] = $line['deptime']; |
|
1606 | + } |
|
1607 | + if (isset($line['arricao'])) { |
|
1608 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1609 | + } |
|
1177 | 1610 | //$data['arrival_airport_time'] = $line['arrtime']; |
1178 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1179 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1180 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1181 | - else $data['info'] = ''; |
|
1611 | + if (isset($line['aircraft'])) { |
|
1612 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1613 | + } |
|
1614 | + if (isset($line['transponder'])) { |
|
1615 | + $data['squawk'] = $line['transponder']; |
|
1616 | + } |
|
1617 | + if (isset($line['atis'])) { |
|
1618 | + $data['info'] = $line['atis']; |
|
1619 | + } else { |
|
1620 | + $data['info'] = ''; |
|
1621 | + } |
|
1182 | 1622 | $data['format_source'] = 'pireps'; |
1183 | 1623 | $data['id_source'] = $id_source; |
1184 | 1624 | $data['datetime'] = date('Y-m-d H:i:s'); |
1185 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1186 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1625 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1626 | + $data['noarchive'] = true; |
|
1627 | + } |
|
1628 | + if (isset($value['name']) && $value['name'] != '') { |
|
1629 | + $data['source_name'] = $value['name']; |
|
1630 | + } |
|
1187 | 1631 | if ($line['icon'] === 'plane') { |
1188 | 1632 | $SI->add($data); |
1189 | 1633 | // print_r($data); |
@@ -1192,16 +1636,28 @@ discard block |
||
1192 | 1636 | $data['info'] = str_replace('&sect;','',$data['info']); |
1193 | 1637 | $typec = substr($data['ident'],-3); |
1194 | 1638 | $data['type'] = ''; |
1195 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
1196 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
1197 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
1198 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
1199 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
1200 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
1201 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1202 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1203 | - else $data['type'] = 'Observer'; |
|
1204 | - 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']); |
|
1639 | + if ($typec === 'APP') { |
|
1640 | + $data['type'] = 'Approach'; |
|
1641 | + } elseif ($typec === 'TWR') { |
|
1642 | + $data['type'] = 'Tower'; |
|
1643 | + } elseif ($typec === 'OBS') { |
|
1644 | + $data['type'] = 'Observer'; |
|
1645 | + } elseif ($typec === 'GND') { |
|
1646 | + $data['type'] = 'Ground'; |
|
1647 | + } elseif ($typec === 'DEL') { |
|
1648 | + $data['type'] = 'Delivery'; |
|
1649 | + } elseif ($typec === 'DEP') { |
|
1650 | + $data['type'] = 'Departure'; |
|
1651 | + } elseif ($typec === 'FSS') { |
|
1652 | + $data['type'] = 'Flight Service Station'; |
|
1653 | + } elseif ($typec === 'CTR') { |
|
1654 | + $data['type'] = 'Control Radar or Centre'; |
|
1655 | + } else { |
|
1656 | + $data['type'] = 'Observer'; |
|
1657 | + } |
|
1658 | + if (isset($ATC)) { |
|
1659 | + 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']); |
|
1660 | + } |
|
1205 | 1661 | } |
1206 | 1662 | unset($data); |
1207 | 1663 | } |
@@ -1216,7 +1672,9 @@ discard block |
||
1216 | 1672 | ) |
1217 | 1673 | ) { |
1218 | 1674 | //$buffer = $Common->getData($hosts[$id]); |
1219 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1675 | + if ($globalDebug) { |
|
1676 | + echo 'Get Data...'."\n"; |
|
1677 | + } |
|
1220 | 1678 | $buffer = $Common->getData($value['host']); |
1221 | 1679 | $all_data = json_decode($buffer,true); |
1222 | 1680 | if ($buffer != '' && is_array($all_data)) { |
@@ -1224,10 +1682,16 @@ discard block |
||
1224 | 1682 | foreach ($all_data as $line) { |
1225 | 1683 | $data = array(); |
1226 | 1684 | //$data['id'] = $line['id']; // id not usable |
1227 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1685 | + if (isset($line['pilotid'])) { |
|
1686 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1687 | + } |
|
1228 | 1688 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1229 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1230 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1689 | + if (isset($line['pilotname'])) { |
|
1690 | + $data['pilot_name'] = $line['pilotname']; |
|
1691 | + } |
|
1692 | + if (isset($line['pilotid'])) { |
|
1693 | + $data['pilot_id'] = $line['pilotid']; |
|
1694 | + } |
|
1231 | 1695 | $data['ident'] = $line['flightnum']; // ident |
1232 | 1696 | $data['altitude'] = $line['alt']; // altitude |
1233 | 1697 | $data['speed'] = $line['gs']; // speed |
@@ -1243,7 +1707,9 @@ discard block |
||
1243 | 1707 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1244 | 1708 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1245 | 1709 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1246 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1710 | + } else { |
|
1711 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1712 | + } |
|
1247 | 1713 | $data['departure_airport_icao'] = $line['depicao']; |
1248 | 1714 | $data['departure_airport_time'] = $line['deptime']; |
1249 | 1715 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1251,29 +1717,47 @@ discard block |
||
1251 | 1717 | if (isset($line['registration'])) { |
1252 | 1718 | $data['registration'] = $line['registration']; |
1253 | 1719 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
1254 | - } else $data['registration'] = $line['aircraft']; |
|
1255 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1256 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1720 | + } else { |
|
1721 | + $data['registration'] = $line['aircraft']; |
|
1722 | + } |
|
1723 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1724 | + $data['noarchive'] = true; |
|
1725 | + } |
|
1726 | + if (isset($line['route'])) { |
|
1727 | + $data['waypoints'] = $line['route']; |
|
1728 | + } |
|
1729 | + // route |
|
1257 | 1730 | if (isset($line['aircraftname'])) { |
1258 | 1731 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1259 | 1732 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1260 | 1733 | $aircraft_data = explode('-',$line['aircraftname']); |
1261 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1262 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1263 | - else { |
|
1734 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1735 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1736 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1737 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1738 | + } else { |
|
1264 | 1739 | $aircraft_data = explode(' ',$line['aircraftname']); |
1265 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1266 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1740 | + if (isset($aircraft_data[1])) { |
|
1741 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1742 | + } else { |
|
1743 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1744 | + } |
|
1267 | 1745 | } |
1268 | 1746 | } |
1269 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1747 | + if (isset($line['route'])) { |
|
1748 | + $data['waypoints'] = $line['route']; |
|
1749 | + } |
|
1270 | 1750 | $data['id_source'] = $id_source; |
1271 | 1751 | $data['format_source'] = 'phpvmacars'; |
1272 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1752 | + if (isset($value['name']) && $value['name'] != '') { |
|
1753 | + $data['source_name'] = $value['name']; |
|
1754 | + } |
|
1273 | 1755 | $SI->add($data); |
1274 | 1756 | unset($data); |
1275 | 1757 | } |
1276 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1758 | + if ($globalDebug) { |
|
1759 | + echo 'No more data...'."\n"; |
|
1760 | + } |
|
1277 | 1761 | unset($buffer); |
1278 | 1762 | unset($all_data); |
1279 | 1763 | } |
@@ -1286,7 +1770,9 @@ discard block |
||
1286 | 1770 | ) |
1287 | 1771 | ) { |
1288 | 1772 | //$buffer = $Common->getData($hosts[$id]); |
1289 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1773 | + if ($globalDebug) { |
|
1774 | + echo 'Get Data...'."\n"; |
|
1775 | + } |
|
1290 | 1776 | $buffer = $Common->getData($value['host']); |
1291 | 1777 | $all_data = json_decode($buffer,true); |
1292 | 1778 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1297,10 +1783,16 @@ discard block |
||
1297 | 1783 | //$data['id'] = $line['id']; // id not usable |
1298 | 1784 | $data['id'] = $line['id']; |
1299 | 1785 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1300 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1301 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1786 | + if (isset($line['user']['username'])) { |
|
1787 | + $data['pilot_name'] = $line['user']['username']; |
|
1788 | + } |
|
1789 | + if (isset($line['user_id'])) { |
|
1790 | + $data['pilot_id'] = $line['user_id']; |
|
1791 | + } |
|
1302 | 1792 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
1303 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1793 | + if (is_numeric($data['ident'])) { |
|
1794 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1795 | + } |
|
1304 | 1796 | $data['altitude'] = $line['altitude']; // altitude |
1305 | 1797 | $data['speed'] = $line['groundspeed']; // speed |
1306 | 1798 | $data['heading'] = $line['heading']; // heading |
@@ -1313,7 +1805,9 @@ discard block |
||
1313 | 1805 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
1314 | 1806 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1315 | 1807 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1316 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1808 | + } else { |
|
1809 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1810 | + } |
|
1317 | 1811 | |
1318 | 1812 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
1319 | 1813 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1321,17 +1815,26 @@ discard block |
||
1321 | 1815 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
1322 | 1816 | $data['registration'] = $line['bid']['aircraft']['registration']; |
1323 | 1817 | |
1324 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1325 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1818 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1819 | + $data['noarchive'] = true; |
|
1820 | + } |
|
1821 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
1822 | + $data['waypoints'] = $line['bid']['route']; |
|
1823 | + } |
|
1824 | + // route |
|
1326 | 1825 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
1327 | 1826 | |
1328 | 1827 | $data['id_source'] = $id_source; |
1329 | 1828 | $data['format_source'] = 'vaos'; |
1330 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1829 | + if (isset($value['name']) && $value['name'] != '') { |
|
1830 | + $data['source_name'] = $value['name']; |
|
1831 | + } |
|
1331 | 1832 | $SI->add($data); |
1332 | 1833 | unset($data); |
1333 | 1834 | } |
1334 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1835 | + if ($globalDebug) { |
|
1836 | + echo 'No more data...'."\n"; |
|
1837 | + } |
|
1335 | 1838 | unset($buffer); |
1336 | 1839 | unset($all_data); |
1337 | 1840 | } |
@@ -1344,7 +1847,9 @@ discard block |
||
1344 | 1847 | ) |
1345 | 1848 | ) { |
1346 | 1849 | //$buffer = $Common->getData($hosts[$id]); |
1347 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1850 | + if ($globalDebug) { |
|
1851 | + echo 'Get Data...'."\n"; |
|
1852 | + } |
|
1348 | 1853 | $buffer = $Common->getData($value['host']); |
1349 | 1854 | $all_data = json_decode($buffer,true); |
1350 | 1855 | if ($buffer != '' && is_array($all_data)) { |
@@ -1373,16 +1878,25 @@ discard block |
||
1373 | 1878 | $data['arrival_airport_icao'] = $line['arrival']; |
1374 | 1879 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1375 | 1880 | //$data['registration'] = $line['aircraft']; |
1376 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1881 | + if (isset($line['route'])) { |
|
1882 | + $data['waypoints'] = $line['route']; |
|
1883 | + } |
|
1884 | + // route |
|
1377 | 1885 | $data['aircraft_icao'] = $line['plane_type']; |
1378 | 1886 | $data['id_source'] = $id_source; |
1379 | 1887 | $data['format_source'] = 'vam'; |
1380 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1381 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1888 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1889 | + $data['noarchive'] = true; |
|
1890 | + } |
|
1891 | + if (isset($value['name']) && $value['name'] != '') { |
|
1892 | + $data['source_name'] = $value['name']; |
|
1893 | + } |
|
1382 | 1894 | $SI->add($data); |
1383 | 1895 | unset($data); |
1384 | 1896 | } |
1385 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1897 | + if ($globalDebug) { |
|
1898 | + echo 'No more data...'."\n"; |
|
1899 | + } |
|
1386 | 1900 | unset($buffer); |
1387 | 1901 | unset($all_data); |
1388 | 1902 | } |
@@ -1395,7 +1909,9 @@ discard block |
||
1395 | 1909 | ) |
1396 | 1910 | ) { |
1397 | 1911 | //$buffer = $Common->getData($hosts[$id]); |
1398 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1912 | + if ($globalDebug) { |
|
1913 | + echo 'Get Data...'."\n"; |
|
1914 | + } |
|
1399 | 1915 | $buffer = $Common->getData($value['host']); |
1400 | 1916 | $all_data = json_decode($buffer,true); |
1401 | 1917 | if ($buffer != '') { |
@@ -1413,12 +1929,16 @@ discard block |
||
1413 | 1929 | $data['id_source'] = $id_source; |
1414 | 1930 | $data['format_source'] = 'blitzortung'; |
1415 | 1931 | $SI->add($data); |
1416 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1932 | + if ($globalDebug) { |
|
1933 | + echo '☈ Lightning added'."\n"; |
|
1934 | + } |
|
1417 | 1935 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1418 | 1936 | unset($data); |
1419 | 1937 | } |
1420 | 1938 | } |
1421 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1939 | + if ($globalDebug) { |
|
1940 | + echo 'No more data...'."\n"; |
|
1941 | + } |
|
1422 | 1942 | unset($buffer); |
1423 | 1943 | } |
1424 | 1944 | $last_exec[$id]['last'] = time(); |
@@ -1430,7 +1950,9 @@ discard block |
||
1430 | 1950 | $write = NULL; |
1431 | 1951 | $e = NULL; |
1432 | 1952 | $n = socket_select($read, $write, $e, $timeout); |
1433 | - if ($e != NULL) var_dump($e); |
|
1953 | + if ($e != NULL) { |
|
1954 | + var_dump($e); |
|
1955 | + } |
|
1434 | 1956 | if ($n > 0) { |
1435 | 1957 | $reset = 0; |
1436 | 1958 | foreach ($read as $nb => $r) { |
@@ -1452,13 +1974,17 @@ discard block |
||
1452 | 1974 | if ($buffer !== FALSE) { |
1453 | 1975 | if ($format === 'vrstcp') { |
1454 | 1976 | $buffer = explode('},{',$buffer); |
1455 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1977 | + } else { |
|
1978 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1979 | + } |
|
1456 | 1980 | } |
1457 | 1981 | // SBS format is CSV format |
1458 | 1982 | if ($buffer !== FALSE && $buffer !== '') { |
1459 | 1983 | $tt[$format] = 0; |
1460 | 1984 | if ($format === 'acarssbs3') { |
1461 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1985 | + if ($globalDebug) { |
|
1986 | + echo 'ACARS : '.$buffer."\n"; |
|
1987 | + } |
|
1462 | 1988 | $ACARS->add(trim($buffer)); |
1463 | 1989 | $ACARS->deleteLiveAcarsData(); |
1464 | 1990 | } elseif ($format === 'raw') { |
@@ -1467,30 +1993,70 @@ discard block |
||
1467 | 1993 | if (is_array($data)) { |
1468 | 1994 | $data['datetime'] = date('Y-m-d H:i:s'); |
1469 | 1995 | $data['format_source'] = 'raw'; |
1470 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1471 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1472 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1473 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1996 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1997 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1998 | + } |
|
1999 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2000 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2001 | + } |
|
2002 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2003 | + $data['noarchive'] = true; |
|
2004 | + } |
|
2005 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2006 | + $SI->add($data); |
|
2007 | + } |
|
1474 | 2008 | } |
1475 | 2009 | } elseif ($format === 'ais') { |
1476 | 2010 | $ais_data = $AIS->parse_line(trim($buffer)); |
1477 | 2011 | $data = array(); |
1478 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1479 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1480 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1481 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1482 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1483 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1484 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1485 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1486 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1487 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1488 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1489 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1490 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1491 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1492 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1493 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2012 | + if (isset($ais_data['ident'])) { |
|
2013 | + $data['ident'] = $ais_data['ident']; |
|
2014 | + } |
|
2015 | + if (isset($ais_data['mmsi'])) { |
|
2016 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
2017 | + } |
|
2018 | + if (isset($ais_data['speed'])) { |
|
2019 | + $data['speed'] = $ais_data['speed']; |
|
2020 | + } |
|
2021 | + if (isset($ais_data['heading'])) { |
|
2022 | + $data['heading'] = $ais_data['heading']; |
|
2023 | + } |
|
2024 | + if (isset($ais_data['latitude'])) { |
|
2025 | + $data['latitude'] = $ais_data['latitude']; |
|
2026 | + } |
|
2027 | + if (isset($ais_data['longitude'])) { |
|
2028 | + $data['longitude'] = $ais_data['longitude']; |
|
2029 | + } |
|
2030 | + if (isset($ais_data['status'])) { |
|
2031 | + $data['status'] = $ais_data['status']; |
|
2032 | + } |
|
2033 | + if (isset($ais_data['statusid'])) { |
|
2034 | + $data['status_id'] = $ais_data['statusid']; |
|
2035 | + } |
|
2036 | + if (isset($ais_data['type'])) { |
|
2037 | + $data['type'] = $ais_data['type']; |
|
2038 | + } |
|
2039 | + if (isset($ais_data['imo'])) { |
|
2040 | + $data['imo'] = $ais_data['imo']; |
|
2041 | + } |
|
2042 | + if (isset($ais_data['callsign'])) { |
|
2043 | + $data['callsign'] = $ais_data['callsign']; |
|
2044 | + } |
|
2045 | + if (isset($ais_data['destination'])) { |
|
2046 | + $data['arrival_code'] = $ais_data['destination']; |
|
2047 | + } |
|
2048 | + if (isset($ais_data['eta_ts'])) { |
|
2049 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
2050 | + } |
|
2051 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2052 | + $data['noarchive'] = true; |
|
2053 | + } |
|
2054 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2055 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2056 | + } |
|
2057 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2058 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2059 | + } |
|
1494 | 2060 | |
1495 | 2061 | if (isset($ais_data['timestamp'])) { |
1496 | 2062 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1499,7 +2065,9 @@ discard block |
||
1499 | 2065 | } |
1500 | 2066 | $data['format_source'] = 'aisnmea'; |
1501 | 2067 | $data['id_source'] = $id_source; |
1502 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
2068 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
2069 | + $MI->add($data); |
|
2070 | + } |
|
1503 | 2071 | unset($data); |
1504 | 2072 | } elseif ($format === 'flightgearsp') { |
1505 | 2073 | //echo $buffer."\n"; |
@@ -1517,12 +2085,18 @@ discard block |
||
1517 | 2085 | $data['speed'] = round($line[5]*1.94384); |
1518 | 2086 | $data['datetime'] = date('Y-m-d H:i:s'); |
1519 | 2087 | $data['format_source'] = 'flightgearsp'; |
1520 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1521 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2088 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2089 | + $data['noarchive'] = true; |
|
2090 | + } |
|
2091 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2092 | + $SI->add($data); |
|
2093 | + } |
|
1522 | 2094 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1523 | 2095 | } |
1524 | 2096 | } elseif ($format === 'acars') { |
1525 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2097 | + if ($globalDebug) { |
|
2098 | + echo 'ACARS : '.$buffer."\n"; |
|
2099 | + } |
|
1526 | 2100 | $ACARS->add(trim($buffer)); |
1527 | 2101 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1528 | 2102 | $ACARS->deleteLiveAcarsData(); |
@@ -1543,8 +2117,12 @@ discard block |
||
1543 | 2117 | $aircraft_type = $line[10]; |
1544 | 2118 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1545 | 2119 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1546 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1547 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2120 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2121 | + $data['noarchive'] = true; |
|
2122 | + } |
|
2123 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2124 | + $SI->add($data); |
|
2125 | + } |
|
1548 | 2126 | } |
1549 | 2127 | } |
1550 | 2128 | } elseif ($format === 'beast') { |
@@ -1554,28 +2132,62 @@ discard block |
||
1554 | 2132 | foreach($buffer as $all_data) { |
1555 | 2133 | $line = json_decode('{'.$all_data.'}',true); |
1556 | 2134 | $data = array(); |
1557 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1558 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1559 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1560 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1561 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1562 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1563 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
2135 | + if (isset($line['Icao'])) { |
|
2136 | + $data['hex'] = $line['Icao']; |
|
2137 | + } |
|
2138 | + // hex |
|
2139 | + if (isset($line['Call'])) { |
|
2140 | + $data['ident'] = $line['Call']; |
|
2141 | + } |
|
2142 | + // ident |
|
2143 | + if (isset($line['Alt'])) { |
|
2144 | + $data['altitude'] = $line['Alt']; |
|
2145 | + } |
|
2146 | + // altitude |
|
2147 | + if (isset($line['Spd'])) { |
|
2148 | + $data['speed'] = $line['Spd']; |
|
2149 | + } |
|
2150 | + // speed |
|
2151 | + if (isset($line['Trak'])) { |
|
2152 | + $data['heading'] = $line['Trak']; |
|
2153 | + } |
|
2154 | + // heading |
|
2155 | + if (isset($line['Lat'])) { |
|
2156 | + $data['latitude'] = $line['Lat']; |
|
2157 | + } |
|
2158 | + // lat |
|
2159 | + if (isset($line['Long'])) { |
|
2160 | + $data['longitude'] = $line['Long']; |
|
2161 | + } |
|
2162 | + // long |
|
1564 | 2163 | //$data['verticalrate'] = $line['']; // verticale rate |
1565 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
2164 | + if (isset($line['Sqk'])) { |
|
2165 | + $data['squawk'] = $line['Sqk']; |
|
2166 | + } |
|
2167 | + // squawk |
|
1566 | 2168 | $data['emergency'] = ''; // emergency |
1567 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
2169 | + if (isset($line['Reg'])) { |
|
2170 | + $data['registration'] = $line['Reg']; |
|
2171 | + } |
|
1568 | 2172 | /* |
1569 | 2173 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1570 | 2174 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1571 | 2175 | */ |
1572 | 2176 | $data['datetime'] = date('Y-m-d H:i:s'); |
1573 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
2177 | + if (isset($line['Type'])) { |
|
2178 | + $data['aircraft_icao'] = $line['Type']; |
|
2179 | + } |
|
1574 | 2180 | $data['format_source'] = 'vrstcp'; |
1575 | 2181 | $data['id_source'] = $id_source; |
1576 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1577 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1578 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
2182 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2183 | + $data['noarchive'] = true; |
|
2184 | + } |
|
2185 | + if (isset($value['name']) && $value['name'] != '') { |
|
2186 | + $data['source_name'] = $value['name']; |
|
2187 | + } |
|
2188 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
2189 | + $SI->add($data); |
|
2190 | + } |
|
1579 | 2191 | unset($data); |
1580 | 2192 | } |
1581 | 2193 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1588,22 +2200,46 @@ discard block |
||
1588 | 2200 | $data['hex'] = $lined['hexid']; |
1589 | 2201 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1590 | 2202 | $data['datetime'] = date('Y-m-d H:i:s');; |
1591 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1592 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1593 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1594 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1595 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1596 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1597 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
2203 | + if (isset($lined['ident'])) { |
|
2204 | + $data['ident'] = $lined['ident']; |
|
2205 | + } |
|
2206 | + if (isset($lined['lat'])) { |
|
2207 | + $data['latitude'] = $lined['lat']; |
|
2208 | + } |
|
2209 | + if (isset($lined['lon'])) { |
|
2210 | + $data['longitude'] = $lined['lon']; |
|
2211 | + } |
|
2212 | + if (isset($lined['speed'])) { |
|
2213 | + $data['speed'] = $lined['speed']; |
|
2214 | + } |
|
2215 | + if (isset($lined['squawk'])) { |
|
2216 | + $data['squawk'] = $lined['squawk']; |
|
2217 | + } |
|
2218 | + if (isset($lined['alt'])) { |
|
2219 | + $data['altitude'] = $lined['alt']; |
|
2220 | + } |
|
2221 | + if (isset($lined['heading'])) { |
|
2222 | + $data['heading'] = $lined['heading']; |
|
2223 | + } |
|
1598 | 2224 | $data['id_source'] = $id_source; |
1599 | 2225 | $data['format_source'] = 'tsv'; |
1600 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1601 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1602 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1603 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2226 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2227 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2228 | + } |
|
2229 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2230 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2231 | + } |
|
2232 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2233 | + $data['noarchive'] = true; |
|
2234 | + } |
|
2235 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2236 | + $SI->add($data); |
|
2237 | + } |
|
1604 | 2238 | unset($lined); |
1605 | 2239 | unset($data); |
1606 | - } else $error = true; |
|
2240 | + } else { |
|
2241 | + $error = true; |
|
2242 | + } |
|
1607 | 2243 | } elseif ($format === 'aprs' && $use_aprs) { |
1608 | 2244 | if ($aprs_connect === 0) { |
1609 | 2245 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1629,63 +2265,121 @@ discard block |
||
1629 | 2265 | $aprs_last_tx = time(); |
1630 | 2266 | $data = array(); |
1631 | 2267 | //print_r($line); |
1632 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1633 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1634 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1635 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1636 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1637 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1638 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1639 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1640 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1641 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2268 | + if (isset($line['address'])) { |
|
2269 | + $data['hex'] = $line['address']; |
|
2270 | + } |
|
2271 | + if (isset($line['mmsi'])) { |
|
2272 | + $data['mmsi'] = $line['mmsi']; |
|
2273 | + } |
|
2274 | + if (isset($line['imo'])) { |
|
2275 | + $data['imo'] = $line['imo']; |
|
2276 | + } |
|
2277 | + if (isset($line['squawk'])) { |
|
2278 | + $data['squawk'] = $line['squawk']; |
|
2279 | + } |
|
2280 | + if (isset($line['arrival_code'])) { |
|
2281 | + $data['arrival_code'] = $line['arrival_code']; |
|
2282 | + } |
|
2283 | + if (isset($line['arrival_date'])) { |
|
2284 | + $data['arrival_date'] = $line['arrival_date']; |
|
2285 | + } |
|
2286 | + if (isset($line['typeid'])) { |
|
2287 | + $data['type_id'] = $line['typeid']; |
|
2288 | + } |
|
2289 | + if (isset($line['statusid'])) { |
|
2290 | + $data['status_id'] = $line['statusid']; |
|
2291 | + } |
|
2292 | + if (isset($line['timestamp'])) { |
|
2293 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2294 | + } else { |
|
2295 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2296 | + } |
|
1642 | 2297 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1643 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2298 | + if (isset($line['ident'])) { |
|
2299 | + $data['ident'] = $line['ident']; |
|
2300 | + } |
|
1644 | 2301 | $data['latitude'] = $line['latitude']; |
1645 | 2302 | $data['longitude'] = $line['longitude']; |
1646 | 2303 | //$data['verticalrate'] = $line[16]; |
1647 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2304 | + if (isset($line['speed'])) { |
|
2305 | + $data['speed'] = $line['speed']; |
|
2306 | + } |
|
1648 | 2307 | //else $data['speed'] = 0; |
1649 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1650 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1651 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2308 | + if (isset($line['altitude'])) { |
|
2309 | + $data['altitude'] = $line['altitude']; |
|
2310 | + } |
|
2311 | + if (isset($line['comment'])) { |
|
2312 | + $data['comment'] = $line['comment']; |
|
2313 | + } |
|
2314 | + if (isset($line['symbol'])) { |
|
2315 | + $data['type'] = $line['symbol']; |
|
2316 | + } |
|
1652 | 2317 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1653 | 2318 | |
1654 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2319 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2320 | + $data['heading'] = $line['heading']; |
|
2321 | + } |
|
1655 | 2322 | //else echo 'No heading...'."\n"; |
1656 | 2323 | //else $data['heading'] = 0; |
1657 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2324 | + if (isset($line['stealth'])) { |
|
2325 | + $data['aircraft_type'] = $line['stealth']; |
|
2326 | + } |
|
1658 | 2327 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1659 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1660 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1661 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1662 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2328 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2329 | + $data['noarchive'] = true; |
|
2330 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2331 | + $data['noarchive'] = false; |
|
2332 | + } |
|
2333 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2334 | + $data['noarchive'] = true; |
|
2335 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2336 | + $data['noarchive'] = false; |
|
2337 | + } |
|
1663 | 2338 | $data['id_source'] = $id_source; |
1664 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1665 | - else $data['format_source'] = 'aprs'; |
|
2339 | + if (isset($line['format_source'])) { |
|
2340 | + $data['format_source'] = $line['format_source']; |
|
2341 | + } else { |
|
2342 | + $data['format_source'] = 'aprs'; |
|
2343 | + } |
|
1666 | 2344 | $data['source_name'] = $line['source']; |
1667 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1668 | - else $data['source_type'] = 'flarm'; |
|
1669 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2345 | + if (isset($line['source_type'])) { |
|
2346 | + $data['source_type'] = $line['source_type']; |
|
2347 | + } else { |
|
2348 | + $data['source_type'] = 'flarm'; |
|
2349 | + } |
|
2350 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2351 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2352 | + } |
|
1670 | 2353 | $currentdate = date('Y-m-d H:i:s'); |
1671 | 2354 | $aprsdate = strtotime($data['datetime']); |
1672 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2355 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2356 | + $data['altitude_relative'] = 'AMSL'; |
|
2357 | + } |
|
1673 | 2358 | // Accept data if time <= system time + 20s |
1674 | 2359 | //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'])))) { |
1675 | 2360 | if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1676 | 2361 | $send = $SI->add($data); |
1677 | 2362 | } elseif ($data['source_type'] === 'ais') { |
1678 | 2363 | $data['type'] = ''; |
1679 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2364 | + if (isset($globalMarine) && $globalMarine) { |
|
2365 | + $send = $MI->add($data); |
|
2366 | + } |
|
1680 | 2367 | } elseif (isset($line['stealth'])) { |
1681 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1682 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2368 | + if ($line['stealth'] != 0) { |
|
2369 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
2370 | + } else { |
|
2371 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2372 | + } |
|
1683 | 2373 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1684 | 2374 | //$line['symbol'] === 'Balloon' || |
1685 | 2375 | $line['symbol'] === 'Glider' || |
1686 | 2376 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
1687 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1688 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2377 | + if ($line['symbol'] === 'Ballon') { |
|
2378 | + $data['aircraft_icao'] = 'BALL'; |
|
2379 | + } |
|
2380 | + if ($line['symbol'] === 'Glider') { |
|
2381 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2382 | + } |
|
1689 | 2383 | $send = $SI->add($data); |
1690 | 2384 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1691 | 2385 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1716,9 +2410,13 @@ discard block |
||
1716 | 2410 | //} 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') { |
1717 | 2411 | // } 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') { |
1718 | 2412 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1719 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2413 | + if (isset($globalTracker) && $globalTracker) { |
|
2414 | + $send = $TI->add($data); |
|
2415 | + } |
|
1720 | 2416 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1721 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2417 | + if (!isset($data['altitude'])) { |
|
2418 | + $data['altitude'] = 0; |
|
2419 | + } |
|
1722 | 2420 | $Source->deleteOldLocationByType('gs'); |
1723 | 2421 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
1724 | 2422 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1727,7 +2425,9 @@ discard block |
||
1727 | 2425 | } |
1728 | 2426 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
1729 | 2427 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1730 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2428 | + if ($globalDebug) { |
|
2429 | + echo '# Weather Station added'."\n"; |
|
2430 | + } |
|
1731 | 2431 | $Source->deleteOldLocationByType('wx'); |
1732 | 2432 | $weather_data = json_encode($line); |
1733 | 2433 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1737,7 +2437,9 @@ discard block |
||
1737 | 2437 | } |
1738 | 2438 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
1739 | 2439 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1740 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2440 | + if ($globalDebug) { |
|
2441 | + echo '☈ Lightning added'."\n"; |
|
2442 | + } |
|
1741 | 2443 | $Source->deleteOldLocationByType('lightning'); |
1742 | 2444 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
1743 | 2445 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1749,8 +2451,7 @@ discard block |
||
1749 | 2451 | print_r($line); |
1750 | 2452 | } |
1751 | 2453 | unset($data); |
1752 | - } |
|
1753 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2454 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1754 | 2455 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
1755 | 2456 | } |
1756 | 2457 | /* |
@@ -1759,7 +2460,9 @@ discard block |
||
1759 | 2460 | } |
1760 | 2461 | */ |
1761 | 2462 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1762 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2463 | + elseif ($line === true && $globalDebug) { |
|
2464 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2465 | + } |
|
1763 | 2466 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
1764 | 2467 | $Source->deleteOldLocationByType('lightning'); |
1765 | 2468 | $Source->deleteOldLocationByType('wx'); |
@@ -1795,26 +2498,45 @@ discard block |
||
1795 | 2498 | $data['ground'] = $line[21]; |
1796 | 2499 | $data['emergency'] = $line[19]; |
1797 | 2500 | $data['format_source'] = 'sbs'; |
1798 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1799 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1800 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2501 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2502 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2503 | + } |
|
2504 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2505 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2506 | + } |
|
2507 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2508 | + $data['noarchive'] = true; |
|
2509 | + } |
|
1801 | 2510 | $data['id_source'] = $id_source; |
1802 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1803 | - else $error = true; |
|
2511 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2512 | + $send = $SI->add($data); |
|
2513 | + } else { |
|
2514 | + $error = true; |
|
2515 | + } |
|
1804 | 2516 | unset($data); |
1805 | - } else $error = true; |
|
2517 | + } else { |
|
2518 | + $error = true; |
|
2519 | + } |
|
1806 | 2520 | if ($error) { |
1807 | 2521 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
1808 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2522 | + if ($globalDebug) { |
|
2523 | + echo "Not a message. Ignoring... \n"; |
|
2524 | + } |
|
1809 | 2525 | } else { |
1810 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2526 | + if ($globalDebug) { |
|
2527 | + echo "Wrong line format. Ignoring... \n"; |
|
2528 | + } |
|
1811 | 2529 | if ($globalDebug) { |
1812 | 2530 | echo $buffer; |
1813 | 2531 | //print_r($line); |
1814 | 2532 | } |
1815 | 2533 | //socket_close($r); |
1816 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1817 | - if ($format === 'aprs') $aprs_connect = 0; |
|
2534 | + if ($globalDebug) { |
|
2535 | + echo "Reconnect after an error...\n"; |
|
2536 | + } |
|
2537 | + if ($format === 'aprs') { |
|
2538 | + $aprs_connect = 0; |
|
2539 | + } |
|
1818 | 2540 | $sourceer[$nb] = $globalSources[$nb]; |
1819 | 2541 | connect_all($sourceer); |
1820 | 2542 | $sourceer = array(); |
@@ -1822,10 +2544,14 @@ discard block |
||
1822 | 2544 | } |
1823 | 2545 | } |
1824 | 2546 | // Sleep for xxx microseconds |
1825 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2547 | + if (isset($globalSBSSleep)) { |
|
2548 | + usleep($globalSBSSleep); |
|
2549 | + } |
|
1826 | 2550 | } else { |
1827 | 2551 | if ($format === 'flightgearmp') { |
1828 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2552 | + if ($globalDebug) { |
|
2553 | + echo "Reconnect FlightGear MP..."; |
|
2554 | + } |
|
1829 | 2555 | //@socket_close($r); |
1830 | 2556 | sleep($globalMinFetch); |
1831 | 2557 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1834,10 +2560,15 @@ discard block |
||
1834 | 2560 | break; |
1835 | 2561 | |
1836 | 2562 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1837 | - if (isset($tt[$format])) $tt[$format]++; |
|
1838 | - else $tt[$format] = 0; |
|
2563 | + if (isset($tt[$format])) { |
|
2564 | + $tt[$format]++; |
|
2565 | + } else { |
|
2566 | + $tt[$format] = 0; |
|
2567 | + } |
|
1839 | 2568 | if ($tt[$format] > 30 || $buffer === FALSE) { |
1840 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2569 | + if ($globalDebug) { |
|
2570 | + echo "ERROR : Reconnect ".$format."..."; |
|
2571 | + } |
|
1841 | 2572 | //@socket_close($r); |
1842 | 2573 | sleep(2); |
1843 | 2574 | $aprs_connect = 0; |
@@ -1855,11 +2586,17 @@ discard block |
||
1855 | 2586 | } else { |
1856 | 2587 | $error = socket_strerror(socket_last_error()); |
1857 | 2588 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1858 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1859 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2589 | + if ($globalDebug) { |
|
2590 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2591 | + } |
|
2592 | + if (isset($globalDebug)) { |
|
2593 | + echo "Restarting...\n"; |
|
2594 | + } |
|
1860 | 2595 | // Restart the script if possible |
1861 | 2596 | if (is_array($sockets)) { |
1862 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2597 | + if ($globalDebug) { |
|
2598 | + echo "Shutdown all sockets..."; |
|
2599 | + } |
|
1863 | 2600 | |
1864 | 2601 | foreach ($sockets as $sock) { |
1865 | 2602 | @socket_shutdown($sock,2); |
@@ -1867,25 +2604,45 @@ discard block |
||
1867 | 2604 | } |
1868 | 2605 | |
1869 | 2606 | } |
1870 | - if ($globalDebug) echo "Waiting..."; |
|
2607 | + if ($globalDebug) { |
|
2608 | + echo "Waiting..."; |
|
2609 | + } |
|
1871 | 2610 | sleep(2); |
1872 | 2611 | $time = time(); |
1873 | 2612 | //connect_all($hosts); |
1874 | 2613 | $aprs_connect = 0; |
1875 | - if ($reset%5 === 0) sleep(20); |
|
1876 | - if ($reset%10 === 0) sleep(100); |
|
1877 | - if ($reset%20 === 0) sleep(200); |
|
1878 | - if ($reset > 100) exit('Too many attempts...'); |
|
1879 | - if ($globalDebug) echo "Restart all connections..."; |
|
2614 | + if ($reset%5 === 0) { |
|
2615 | + sleep(20); |
|
2616 | + } |
|
2617 | + if ($reset%10 === 0) { |
|
2618 | + sleep(100); |
|
2619 | + } |
|
2620 | + if ($reset%20 === 0) { |
|
2621 | + sleep(200); |
|
2622 | + } |
|
2623 | + if ($reset > 100) { |
|
2624 | + exit('Too many attempts...'); |
|
2625 | + } |
|
2626 | + if ($globalDebug) { |
|
2627 | + echo "Restart all connections..."; |
|
2628 | + } |
|
1880 | 2629 | connect_all($globalSources); |
1881 | 2630 | } |
1882 | 2631 | } |
1883 | 2632 | } |
1884 | 2633 | if ($globalDaemon === false) { |
1885 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1886 | - if (isset($SI)) $SI->checkAll(); |
|
1887 | - if (isset($TI)) $TI->checkAll(); |
|
1888 | - if (isset($MI)) $MI->checkAll(); |
|
2634 | + if ($globalDebug) { |
|
2635 | + echo 'Check all...'."\n"; |
|
2636 | + } |
|
2637 | + if (isset($SI)) { |
|
2638 | + $SI->checkAll(); |
|
2639 | + } |
|
2640 | + if (isset($TI)) { |
|
2641 | + $TI->checkAll(); |
|
2642 | + } |
|
2643 | + if (isset($MI)) { |
|
2644 | + $MI->checkAll(); |
|
2645 | + } |
|
1889 | 2646 | } |
1890 | 2647 | } |
1891 | 2648 | } |