@@ -13,13 +13,17 @@ discard block |
||
13 | 13 | require_once(dirname(__FILE__).'/../require/class.SBS.php'); |
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
16 | +if (isset($globalTracker) && $globalTracker) { |
|
17 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
18 | +} |
|
17 | 19 | if (isset($globalMarine) && $globalMarine) { |
18 | 20 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
20 | 22 | } |
21 | 23 | |
22 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
24 | +if (!isset($globalDebug)) { |
|
25 | + $globalDebug = FALSE; |
|
26 | +} |
|
23 | 27 | |
24 | 28 | // Check if schema is at latest version |
25 | 29 | $Connection = new Connection(); |
@@ -59,20 +63,33 @@ discard block |
||
59 | 63 | $globalSources = array(); |
60 | 64 | $globalSources[] = array('host' => $options['source']); |
61 | 65 | } |
62 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
63 | -if (isset($options['server'])) $globalServer = TRUE; |
|
64 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
65 | -else $id_source = 1; |
|
66 | +if (isset($options['nodaemon'])) { |
|
67 | + $globalDaemon = FALSE; |
|
68 | +} |
|
69 | +if (isset($options['server'])) { |
|
70 | + $globalServer = TRUE; |
|
71 | +} |
|
72 | +if (isset($options['idsource'])) { |
|
73 | + $id_source = $options['idsource']; |
|
74 | +} else { |
|
75 | + $id_source = 1; |
|
76 | +} |
|
66 | 77 | if (isset($globalServer) && $globalServer) { |
67 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
78 | + if ($globalDebug) { |
|
79 | + echo "Using Server Mode\n"; |
|
80 | + } |
|
68 | 81 | $SI=new SpotterServer(); |
69 | 82 | /* |
70 | 83 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
71 | 84 | $SI = new adsb2aprs(); |
72 | 85 | $SI->connect(); |
73 | 86 | */ |
74 | -} else $SI=new SpotterImport($Connection->db); |
|
75 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
87 | +} else { |
|
88 | + $SI=new SpotterImport($Connection->db); |
|
89 | +} |
|
90 | +if (isset($globalTracker) && $globalTracker) { |
|
91 | + $TI = new TrackerImport($Connection->db); |
|
92 | +} |
|
76 | 93 | if (isset($globalMarine) && $globalMarine) { |
77 | 94 | $AIS = new AIS(); |
78 | 95 | $MI = new MarineImport($Connection->db); |
@@ -94,7 +111,9 @@ discard block |
||
94 | 111 | } |
95 | 112 | |
96 | 113 | // let's try and connect |
97 | -if ($globalDebug) echo "Connecting...\n"; |
|
114 | +if ($globalDebug) { |
|
115 | + echo "Connecting...\n"; |
|
116 | +} |
|
98 | 117 | $use_aprs = false; |
99 | 118 | $aprs_full = false; |
100 | 119 | $reset = 0; |
@@ -103,7 +122,9 @@ discard block |
||
103 | 122 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
104 | 123 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
105 | 124 | $reset++; |
106 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
125 | + if ($globalDebug) { |
|
126 | + echo 'Connect to all...'."\n"; |
|
127 | + } |
|
107 | 128 | foreach ($hosts as $id => $value) { |
108 | 129 | $host = $value['host']; |
109 | 130 | $globalSources[$id]['last_exec'] = 0; |
@@ -113,27 +134,37 @@ discard block |
||
113 | 134 | //$formats[$id] = 'deltadbtxt'; |
114 | 135 | $globalSources[$id]['format'] = 'deltadbtxt'; |
115 | 136 | //$last_exec['deltadbtxt'] = 0; |
116 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
137 | + if ($globalDebug) { |
|
138 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
139 | + } |
|
117 | 140 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
118 | 141 | //$formats[$id] = 'vatsimtxt'; |
119 | 142 | $globalSources[$id]['format'] = 'vatsimtxt'; |
120 | 143 | //$last_exec['vatsimtxt'] = 0; |
121 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
144 | + if ($globalDebug) { |
|
145 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
146 | + } |
|
122 | 147 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
123 | 148 | //$formats[$id] = 'aircraftlistjson'; |
124 | 149 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
125 | 150 | //$last_exec['aircraftlistjson'] = 0; |
126 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
151 | + if ($globalDebug) { |
|
152 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
153 | + } |
|
127 | 154 | } else if (preg_match('/opensky/i',$host)) { |
128 | 155 | //$formats[$id] = 'aircraftlistjson'; |
129 | 156 | $globalSources[$id]['format'] = 'opensky'; |
130 | 157 | //$last_exec['aircraftlistjson'] = 0; |
131 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
158 | + if ($globalDebug) { |
|
159 | + echo "Connect to opensky source (".$host.")...\n"; |
|
160 | + } |
|
132 | 161 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
133 | 162 | //$formats[$id] = 'radarvirtueljson'; |
134 | 163 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
135 | 164 | //$last_exec['radarvirtueljson'] = 0; |
136 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
165 | + if ($globalDebug) { |
|
166 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
167 | + } |
|
137 | 168 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
138 | 169 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
139 | 170 | exit(0); |
@@ -142,7 +173,9 @@ discard block |
||
142 | 173 | //$formats[$id] = 'planeupdatefaa'; |
143 | 174 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
144 | 175 | //$last_exec['planeupdatefaa'] = 0; |
145 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
176 | + if ($globalDebug) { |
|
177 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
178 | + } |
|
146 | 179 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
147 | 180 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
148 | 181 | exit(0); |
@@ -151,26 +184,36 @@ discard block |
||
151 | 184 | //$formats[$id] = 'phpvmacars'; |
152 | 185 | $globalSources[$id]['format'] = 'phpvmacars'; |
153 | 186 | //$last_exec['phpvmacars'] = 0; |
154 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
187 | + if ($globalDebug) { |
|
188 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
189 | + } |
|
155 | 190 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
156 | 191 | //$formats[$id] = 'phpvmacars'; |
157 | 192 | $globalSources[$id]['format'] = 'vam'; |
158 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "Connect to Vam source (".$host.")...\n"; |
|
195 | + } |
|
159 | 196 | } else if (preg_match('/whazzup/i',$host)) { |
160 | 197 | //$formats[$id] = 'whazzup'; |
161 | 198 | $globalSources[$id]['format'] = 'whazzup'; |
162 | 199 | //$last_exec['whazzup'] = 0; |
163 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
200 | + if ($globalDebug) { |
|
201 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
202 | + } |
|
164 | 203 | } else if (preg_match('/recentpireps/i',$host)) { |
165 | 204 | //$formats[$id] = 'pirepsjson'; |
166 | 205 | $globalSources[$id]['format'] = 'pirepsjson'; |
167 | 206 | //$last_exec['pirepsjson'] = 0; |
168 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
207 | + if ($globalDebug) { |
|
208 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
209 | + } |
|
169 | 210 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
170 | 211 | //$formats[$id] = 'fr24json'; |
171 | 212 | $globalSources[$id]['format'] = 'fr24json'; |
172 | 213 | //$last_exec['fr24json'] = 0; |
173 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
216 | + } |
|
174 | 217 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
175 | 218 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
176 | 219 | exit(0); |
@@ -179,7 +222,9 @@ discard block |
||
179 | 222 | //$formats[$id] = 'fr24json'; |
180 | 223 | $globalSources[$id]['format'] = 'myshiptracking'; |
181 | 224 | //$last_exec['fr24json'] = 0; |
182 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
225 | + if ($globalDebug) { |
|
226 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
227 | + } |
|
183 | 228 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
184 | 229 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
185 | 230 | exit(0); |
@@ -188,17 +233,24 @@ discard block |
||
188 | 233 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
189 | 234 | //$formats[$id] = 'tsv'; |
190 | 235 | $globalSources[$id]['format'] = 'tsv'; |
191 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
236 | + if ($globalDebug) { |
|
237 | + echo "Connect to tsv source (".$host.")...\n"; |
|
238 | + } |
|
192 | 239 | } |
193 | 240 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
194 | 241 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
195 | 242 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
196 | 243 | if ($idf !== false) { |
197 | 244 | $httpfeeds[$id] = $idf; |
198 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
245 | + if ($globalDebug) { |
|
246 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
247 | + } |
|
248 | + } elseif ($globalDebug) { |
|
249 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
199 | 250 | } |
200 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
201 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
251 | + } elseif ($globalDebug) { |
|
252 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
253 | + } |
|
202 | 254 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
203 | 255 | $hostport = explode(':',$host); |
204 | 256 | if (isset($hostport[1])) { |
@@ -236,17 +288,25 @@ discard block |
||
236 | 288 | //$formats[$id] = 'beast'; |
237 | 289 | $globalSources[$id]['format'] = 'beast'; |
238 | 290 | //} else $formats[$id] = 'sbs'; |
239 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
291 | + } else { |
|
292 | + $globalSources[$id]['format'] = 'sbs'; |
|
293 | + } |
|
240 | 294 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
241 | 295 | } |
242 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
296 | + if ($globalDebug) { |
|
297 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
298 | + } |
|
243 | 299 | } else { |
244 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
300 | + if ($globalDebug) { |
|
301 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
302 | + } |
|
245 | 303 | } |
246 | 304 | } |
247 | 305 | } |
248 | 306 | } |
249 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
307 | +if (!isset($globalMinFetch)) { |
|
308 | + $globalMinFetch = 15; |
|
309 | +} |
|
250 | 310 | |
251 | 311 | // Initialize all |
252 | 312 | $status = array(); |
@@ -255,13 +315,19 @@ discard block |
||
255 | 315 | $formats = array(); |
256 | 316 | $last_exec = array(); |
257 | 317 | $time = time(); |
258 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
259 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
260 | -else $timeout = 20; |
|
318 | +if (isset($globalSourcesTimeout)) { |
|
319 | + $timeout = $globalSourcesTimeOut; |
|
320 | +} else if (isset($globalSBS1TimeOut)) { |
|
321 | + $timeout = $globalSBS1TimeOut; |
|
322 | +} else { |
|
323 | + $timeout = 20; |
|
324 | +} |
|
261 | 325 | $errno = ''; |
262 | 326 | $errstr=''; |
263 | 327 | |
264 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
328 | +if (!isset($globalDaemon)) { |
|
329 | + $globalDaemon = TRUE; |
|
330 | +} |
|
265 | 331 | /* Initiate connections to all the hosts simultaneously */ |
266 | 332 | //connect_all($hosts); |
267 | 333 | //connect_all($globalSources); |
@@ -287,7 +353,9 @@ discard block |
||
287 | 353 | if (isset($source['format']) && $source['format'] == 'aprs') { |
288 | 354 | $aprs_connect = 0; |
289 | 355 | $use_aprs = true; |
290 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
356 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
357 | + $aprs_full = true; |
|
358 | + } |
|
291 | 359 | break; |
292 | 360 | } |
293 | 361 | } |
@@ -298,26 +366,49 @@ discard block |
||
298 | 366 | $aprs_connect = 0; |
299 | 367 | $aprs_keep = 120; |
300 | 368 | $aprs_last_tx = time(); |
301 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
302 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
303 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
304 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
305 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
306 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
307 | - if ($aprs_full) $aprs_filter = ''; |
|
308 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
309 | - else $aprs_pass = '-1'; |
|
369 | + if (isset($globalAPRSversion)) { |
|
370 | + $aprs_version = $globalAPRSversion; |
|
371 | + } else { |
|
372 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
373 | + } |
|
374 | + if (isset($globalAPRSssid)) { |
|
375 | + $aprs_ssid = $globalAPRSssid; |
|
376 | + } else { |
|
377 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
378 | + } |
|
379 | + if (isset($globalAPRSfilter)) { |
|
380 | + $aprs_filter = $globalAPRSfilter; |
|
381 | + } else { |
|
382 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
383 | + } |
|
384 | + if ($aprs_full) { |
|
385 | + $aprs_filter = ''; |
|
386 | + } |
|
387 | + if (isset($globalAPRSpass)) { |
|
388 | + $aprs_pass = $globalAPRSpass; |
|
389 | + } else { |
|
390 | + $aprs_pass = '-1'; |
|
391 | + } |
|
310 | 392 | |
311 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
312 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
393 | + if ($aprs_filter != '') { |
|
394 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
395 | + } else { |
|
396 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
397 | + } |
|
313 | 398 | echo $aprs_login."\n"; |
314 | 399 | } |
315 | 400 | |
316 | 401 | // connected - lets do some work |
317 | -if ($globalDebug) echo "Connected!\n"; |
|
402 | +if ($globalDebug) { |
|
403 | + echo "Connected!\n"; |
|
404 | +} |
|
318 | 405 | sleep(1); |
319 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
320 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
406 | +if ($globalDebug) { |
|
407 | + echo "SCAN MODE \n\n"; |
|
408 | +} |
|
409 | +if (!isset($globalCronEnd)) { |
|
410 | + $globalCronEnd = 60; |
|
411 | +} |
|
321 | 412 | $endtime = time()+$globalCronEnd; |
322 | 413 | $i = 1; |
323 | 414 | $tt = array(); |
@@ -331,10 +422,14 @@ discard block |
||
331 | 422 | |
332 | 423 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
333 | 424 | while ($i > 0) { |
334 | - if (!$globalDaemon) $i = $endtime-time(); |
|
425 | + if (!$globalDaemon) { |
|
426 | + $i = $endtime-time(); |
|
427 | + } |
|
335 | 428 | // Delete old ATC |
336 | 429 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
337 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
430 | + if ($globalDebug) { |
|
431 | + echo 'Delete old ATC...'."\n"; |
|
432 | + } |
|
338 | 433 | $ATC->deleteOldATC(); |
339 | 434 | } |
340 | 435 | |
@@ -342,10 +437,14 @@ discard block |
||
342 | 437 | if (count($last_exec) == count($globalSources)) { |
343 | 438 | $max = $globalMinFetch; |
344 | 439 | foreach ($last_exec as $last) { |
345 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
440 | + if ((time() - $last['last']) < $max) { |
|
441 | + $max = time() - $last['last']; |
|
442 | + } |
|
346 | 443 | } |
347 | 444 | if ($max != $globalMinFetch) { |
348 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
445 | + if ($globalDebug) { |
|
446 | + echo 'Sleeping...'."\n"; |
|
447 | + } |
|
349 | 448 | sleep($globalMinFetch-$max+2); |
350 | 449 | } |
351 | 450 | } |
@@ -354,11 +453,15 @@ discard block |
||
354 | 453 | //foreach ($formats as $id => $value) { |
355 | 454 | foreach ($globalSources as $id => $value) { |
356 | 455 | date_default_timezone_set('UTC'); |
357 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
456 | + if (!isset($last_exec[$id]['last'])) { |
|
457 | + $last_exec[$id]['last'] = 0; |
|
458 | + } |
|
358 | 459 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
359 | 460 | //$buffer = $Common->getData($hosts[$id]); |
360 | 461 | $buffer = $Common->getData($value['host']); |
361 | - if ($buffer != '') $reset = 0; |
|
462 | + if ($buffer != '') { |
|
463 | + $reset = 0; |
|
464 | + } |
|
362 | 465 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
363 | 466 | $buffer = explode('\n',$buffer); |
364 | 467 | foreach ($buffer as $line) { |
@@ -367,19 +470,38 @@ discard block |
||
367 | 470 | $data = array(); |
368 | 471 | $data['hex'] = $line[1]; // hex |
369 | 472 | $data['ident'] = $line[2]; // ident |
370 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
371 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
372 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
373 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
374 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
473 | + if (isset($line[3])) { |
|
474 | + $data['altitude'] = $line[3]; |
|
475 | + } |
|
476 | + // altitude |
|
477 | + if (isset($line[4])) { |
|
478 | + $data['speed'] = $line[4]; |
|
479 | + } |
|
480 | + // speed |
|
481 | + if (isset($line[5])) { |
|
482 | + $data['heading'] = $line[5]; |
|
483 | + } |
|
484 | + // heading |
|
485 | + if (isset($line[6])) { |
|
486 | + $data['latitude'] = $line[6]; |
|
487 | + } |
|
488 | + // lat |
|
489 | + if (isset($line[7])) { |
|
490 | + $data['longitude'] = $line[7]; |
|
491 | + } |
|
492 | + // long |
|
375 | 493 | $data['verticalrate'] = ''; // vertical rate |
376 | 494 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
377 | 495 | $data['emergency'] = ''; // emergency |
378 | 496 | $data['datetime'] = date('Y-m-d H:i:s'); |
379 | 497 | $data['format_source'] = 'deltadbtxt'; |
380 | 498 | $data['id_source'] = $id_source; |
381 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
382 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
499 | + if (isset($value['name']) && $value['name'] != '') { |
|
500 | + $data['source_name'] = $value['name']; |
|
501 | + } |
|
502 | + if (isset($value['sourcestats'])) { |
|
503 | + $data['sourcestats'] = $value['sourcestats']; |
|
504 | + } |
|
383 | 505 | $SI->add($data); |
384 | 506 | unset($data); |
385 | 507 | } |
@@ -389,7 +511,9 @@ discard block |
||
389 | 511 | date_default_timezone_set('CET'); |
390 | 512 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
391 | 513 | date_default_timezone_set('UTC'); |
392 | - if ($buffer != '') $reset = 0; |
|
514 | + if ($buffer != '') { |
|
515 | + $reset = 0; |
|
516 | + } |
|
393 | 517 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
394 | 518 | $buffer = explode('\n',$buffer); |
395 | 519 | foreach ($buffer as $line) { |
@@ -398,16 +522,36 @@ discard block |
||
398 | 522 | $add = false; |
399 | 523 | $ais_data = $AIS->parse_line(trim($line)); |
400 | 524 | $data = array(); |
401 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
402 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
403 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
404 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
405 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
406 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
407 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
408 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
409 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
410 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
525 | + if (isset($ais_data['ident'])) { |
|
526 | + $data['ident'] = $ais_data['ident']; |
|
527 | + } |
|
528 | + if (isset($ais_data['mmsi'])) { |
|
529 | + $data['mmsi'] = $ais_data['mmsi']; |
|
530 | + } |
|
531 | + if (isset($ais_data['speed'])) { |
|
532 | + $data['speed'] = $ais_data['speed']; |
|
533 | + } |
|
534 | + if (isset($ais_data['heading'])) { |
|
535 | + $data['heading'] = $ais_data['heading']; |
|
536 | + } |
|
537 | + if (isset($ais_data['latitude'])) { |
|
538 | + $data['latitude'] = $ais_data['latitude']; |
|
539 | + } |
|
540 | + if (isset($ais_data['longitude'])) { |
|
541 | + $data['longitude'] = $ais_data['longitude']; |
|
542 | + } |
|
543 | + if (isset($ais_data['status'])) { |
|
544 | + $data['status'] = $ais_data['status']; |
|
545 | + } |
|
546 | + if (isset($ais_data['type'])) { |
|
547 | + $data['type'] = $ais_data['type']; |
|
548 | + } |
|
549 | + if (isset($ais_data['imo'])) { |
|
550 | + $data['imo'] = $ais_data['imo']; |
|
551 | + } |
|
552 | + if (isset($ais_data['callsign'])) { |
|
553 | + $data['callsign'] = $ais_data['callsign']; |
|
554 | + } |
|
411 | 555 | if (isset($ais_data['timestamp'])) { |
412 | 556 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
413 | 557 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -422,7 +566,9 @@ discard block |
||
422 | 566 | $data['id_source'] = $id_source; |
423 | 567 | print_r($data); |
424 | 568 | echo 'Add...'."\n"; |
425 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
569 | + if ($add && $ais_data['mmsi_type'] == 'Ship') { |
|
570 | + $MI->add($data); |
|
571 | + } |
|
426 | 572 | unset($data); |
427 | 573 | } |
428 | 574 | } |
@@ -442,18 +588,42 @@ discard block |
||
442 | 588 | if ($line != '') { |
443 | 589 | $ais_data = $AIS->parse_line(trim($line)); |
444 | 590 | $data = array(); |
445 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
446 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
447 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
448 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
449 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
450 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
451 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
452 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
453 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
454 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
455 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
456 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
591 | + if (isset($ais_data['ident'])) { |
|
592 | + $data['ident'] = $ais_data['ident']; |
|
593 | + } |
|
594 | + if (isset($ais_data['mmsi'])) { |
|
595 | + $data['mmsi'] = $ais_data['mmsi']; |
|
596 | + } |
|
597 | + if (isset($ais_data['speed'])) { |
|
598 | + $data['speed'] = $ais_data['speed']; |
|
599 | + } |
|
600 | + if (isset($ais_data['heading'])) { |
|
601 | + $data['heading'] = $ais_data['heading']; |
|
602 | + } |
|
603 | + if (isset($ais_data['latitude'])) { |
|
604 | + $data['latitude'] = $ais_data['latitude']; |
|
605 | + } |
|
606 | + if (isset($ais_data['longitude'])) { |
|
607 | + $data['longitude'] = $ais_data['longitude']; |
|
608 | + } |
|
609 | + if (isset($ais_data['status'])) { |
|
610 | + $data['status'] = $ais_data['status']; |
|
611 | + } |
|
612 | + if (isset($ais_data['type'])) { |
|
613 | + $data['type'] = $ais_data['type']; |
|
614 | + } |
|
615 | + if (isset($ais_data['imo'])) { |
|
616 | + $data['imo'] = $ais_data['imo']; |
|
617 | + } |
|
618 | + if (isset($ais_data['callsign'])) { |
|
619 | + $data['callsign'] = $ais_data['callsign']; |
|
620 | + } |
|
621 | + if (isset($ais_data['destination'])) { |
|
622 | + $data['arrival_code'] = $ais_data['destination']; |
|
623 | + } |
|
624 | + if (isset($ais_data['eta_ts'])) { |
|
625 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
626 | + } |
|
457 | 627 | if (isset($ais_data['timestamp'])) { |
458 | 628 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
459 | 629 | } else { |
@@ -461,7 +631,9 @@ discard block |
||
461 | 631 | } |
462 | 632 | $data['format_source'] = 'aisnmeahttp'; |
463 | 633 | $data['id_source'] = $id_source; |
464 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
634 | + if ($ais_data['mmsi_type'] == 'Ship') { |
|
635 | + $MI->add($data); |
|
636 | + } |
|
465 | 637 | unset($data); |
466 | 638 | } |
467 | 639 | } |
@@ -510,7 +682,9 @@ discard block |
||
510 | 682 | $data['callsign'] = $line['callsign']; |
511 | 683 | $data['mmsi'] = $line['mmsi']; |
512 | 684 | $data['speed'] = $line['sog']; |
513 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
685 | + if ($line['heading'] != '511') { |
|
686 | + $data['heading'] = $line['heading']; |
|
687 | + } |
|
514 | 688 | $data['latitude'] = $line['latitude']; |
515 | 689 | $data['longitude'] = $line['longitude']; |
516 | 690 | $data['type_id'] = $line['shiptype']; |
@@ -530,7 +704,9 @@ discard block |
||
530 | 704 | echo 'download...'; |
531 | 705 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
532 | 706 | echo 'done !'."\n"; |
533 | - if ($buffer != '') $reset = 0; |
|
707 | + if ($buffer != '') { |
|
708 | + $reset = 0; |
|
709 | + } |
|
534 | 710 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
535 | 711 | $buffer = explode('\n',$buffer); |
536 | 712 | foreach ($buffer as $line) { |
@@ -574,16 +750,28 @@ discard block |
||
574 | 750 | $line = explode(':', $line); |
575 | 751 | if (count($line) > 30 && $line[0] != 'callsign') { |
576 | 752 | $data = array(); |
577 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
578 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
753 | + if (isset($line[37]) && $line[37] != '') { |
|
754 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
755 | + } else { |
|
756 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
757 | + } |
|
579 | 758 | $data['pilot_id'] = $line[1]; |
580 | 759 | $data['pilot_name'] = $line[2]; |
581 | 760 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
582 | 761 | $data['ident'] = $line[0]; // ident |
583 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
762 | + if ($line[7] != '' && $line[7] != 0) { |
|
763 | + $data['altitude'] = $line[7]; |
|
764 | + } |
|
765 | + // altitude |
|
584 | 766 | $data['speed'] = $line[8]; // speed |
585 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
586 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
767 | + if (isset($line[45])) { |
|
768 | + $data['heading'] = $line[45]; |
|
769 | + } |
|
770 | + // heading |
|
771 | + elseif (isset($line[38])) { |
|
772 | + $data['heading'] = $line[38]; |
|
773 | + } |
|
774 | + // heading |
|
587 | 775 | $data['latitude'] = $line[5]; // lat |
588 | 776 | $data['longitude'] = $line[6]; // long |
589 | 777 | $data['verticalrate'] = ''; // vertical rate |
@@ -599,7 +787,9 @@ discard block |
||
599 | 787 | $data['frequency'] = $line[4]; |
600 | 788 | $data['type'] = $line[18]; |
601 | 789 | $data['range'] = $line[19]; |
602 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
790 | + if (isset($line[35])) { |
|
791 | + $data['info'] = $line[35]; |
|
792 | + } |
|
603 | 793 | $data['id_source'] = $id_source; |
604 | 794 | //$data['arrival_airport_time'] = ; |
605 | 795 | if ($line[9] != '') { |
@@ -613,24 +803,41 @@ discard block |
||
613 | 803 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
614 | 804 | */ |
615 | 805 | $data['format_source'] = $value['format']; |
616 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
617 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
618 | - elseif ($line[3] == 'ATC') { |
|
806 | + if (isset($value['name']) && $value['name'] != '') { |
|
807 | + $data['source_name'] = $value['name']; |
|
808 | + } |
|
809 | + if ($line[3] == 'PILOT') { |
|
810 | + $SI->add($data); |
|
811 | + } elseif ($line[3] == 'ATC') { |
|
619 | 812 | //print_r($data); |
620 | 813 | $data['info'] = str_replace('^§','<br />',$data['info']); |
621 | 814 | $data['info'] = str_replace('&sect;','',$data['info']); |
622 | 815 | $typec = substr($data['ident'],-3); |
623 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
624 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
625 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
626 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
627 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
628 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
629 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
630 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
631 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
632 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
633 | - if (isset($ATC)) 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']); |
|
816 | + if ($typec == 'APP') { |
|
817 | + $data['type'] = 'Approach'; |
|
818 | + } elseif ($typec == 'TWR') { |
|
819 | + $data['type'] = 'Tower'; |
|
820 | + } elseif ($typec == 'OBS') { |
|
821 | + $data['type'] = 'Observer'; |
|
822 | + } elseif ($typec == 'GND') { |
|
823 | + $data['type'] = 'Ground'; |
|
824 | + } elseif ($typec == 'DEL') { |
|
825 | + $data['type'] = 'Delivery'; |
|
826 | + } elseif ($typec == 'DEP') { |
|
827 | + $data['type'] = 'Departure'; |
|
828 | + } elseif ($typec == 'FSS') { |
|
829 | + $data['type'] = 'Flight Service Station'; |
|
830 | + } elseif ($typec == 'CTR') { |
|
831 | + $data['type'] = 'Control Radar or Centre'; |
|
832 | + } elseif ($data['type'] == '') { |
|
833 | + $data['type'] = 'Observer'; |
|
834 | + } |
|
835 | + if (!isset($data['source_name'])) { |
|
836 | + $data['source_name'] = ''; |
|
837 | + } |
|
838 | + if (isset($ATC)) { |
|
839 | + 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']); |
|
840 | + } |
|
634 | 841 | } |
635 | 842 | unset($data); |
636 | 843 | } |
@@ -649,26 +856,55 @@ discard block |
||
649 | 856 | foreach ($all_data['acList'] as $line) { |
650 | 857 | $data = array(); |
651 | 858 | $data['hex'] = $line['Icao']; // hex |
652 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
653 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
654 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
655 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
656 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
657 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
859 | + if (isset($line['Call'])) { |
|
860 | + $data['ident'] = $line['Call']; |
|
861 | + } |
|
862 | + // ident |
|
863 | + if (isset($line['Alt'])) { |
|
864 | + $data['altitude'] = $line['Alt']; |
|
865 | + } |
|
866 | + // altitude |
|
867 | + if (isset($line['Spd'])) { |
|
868 | + $data['speed'] = $line['Spd']; |
|
869 | + } |
|
870 | + // speed |
|
871 | + if (isset($line['Trak'])) { |
|
872 | + $data['heading'] = $line['Trak']; |
|
873 | + } |
|
874 | + // heading |
|
875 | + if (isset($line['Lat'])) { |
|
876 | + $data['latitude'] = $line['Lat']; |
|
877 | + } |
|
878 | + // lat |
|
879 | + if (isset($line['Long'])) { |
|
880 | + $data['longitude'] = $line['Long']; |
|
881 | + } |
|
882 | + // long |
|
658 | 883 | //$data['verticalrate'] = $line['']; // verticale rate |
659 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
884 | + if (isset($line['Sqk'])) { |
|
885 | + $data['squawk'] = $line['Sqk']; |
|
886 | + } |
|
887 | + // squawk |
|
660 | 888 | $data['emergency'] = ''; // emergency |
661 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
889 | + if (isset($line['Reg'])) { |
|
890 | + $data['registration'] = $line['Reg']; |
|
891 | + } |
|
662 | 892 | /* |
663 | 893 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
664 | 894 | else $data['datetime'] = date('Y-m-d H:i:s'); |
665 | 895 | */ |
666 | 896 | $data['datetime'] = date('Y-m-d H:i:s'); |
667 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
897 | + if (isset($line['Type'])) { |
|
898 | + $data['aircraft_icao'] = $line['Type']; |
|
899 | + } |
|
668 | 900 | $data['format_source'] = 'aircraftlistjson'; |
669 | 901 | $data['id_source'] = $id_source; |
670 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
671 | - if (isset($data['datetime'])) $SI->add($data); |
|
902 | + if (isset($value['name']) && $value['name'] != '') { |
|
903 | + $data['source_name'] = $value['name']; |
|
904 | + } |
|
905 | + if (isset($data['datetime'])) { |
|
906 | + $SI->add($data); |
|
907 | + } |
|
672 | 908 | unset($data); |
673 | 909 | } |
674 | 910 | } elseif (is_array($all_data)) { |
@@ -688,7 +924,9 @@ discard block |
||
688 | 924 | $data['datetime'] = date('Y-m-d H:i:s'); |
689 | 925 | $data['format_source'] = 'aircraftlistjson'; |
690 | 926 | $data['id_source'] = $id_source; |
691 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
927 | + if (isset($value['name']) && $value['name'] != '') { |
|
928 | + $data['source_name'] = $value['name']; |
|
929 | + } |
|
692 | 930 | $SI->add($data); |
693 | 931 | unset($data); |
694 | 932 | } |
@@ -724,7 +962,9 @@ discard block |
||
724 | 962 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
725 | 963 | $data['format_source'] = 'planeupdatefaa'; |
726 | 964 | $data['id_source'] = $id_source; |
727 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
965 | + if (isset($value['name']) && $value['name'] != '') { |
|
966 | + $data['source_name'] = $value['name']; |
|
967 | + } |
|
728 | 968 | $SI->add($data); |
729 | 969 | unset($data); |
730 | 970 | } |
@@ -764,7 +1004,9 @@ discard block |
||
764 | 1004 | //$buffer = $Common->getData($hosts[$id]); |
765 | 1005 | $buffer = $Common->getData($value['host']); |
766 | 1006 | $all_data = json_decode($buffer,true); |
767 | - if (!empty($all_data)) $reset = 0; |
|
1007 | + if (!empty($all_data)) { |
|
1008 | + $reset = 0; |
|
1009 | + } |
|
768 | 1010 | foreach ($all_data as $key => $line) { |
769 | 1011 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
770 | 1012 | $data = array(); |
@@ -785,7 +1027,9 @@ discard block |
||
785 | 1027 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
786 | 1028 | $data['format_source'] = 'fr24json'; |
787 | 1029 | $data['id_source'] = $id_source; |
788 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1030 | + if (isset($value['name']) && $value['name'] != '') { |
|
1031 | + $data['source_name'] = $value['name']; |
|
1032 | + } |
|
789 | 1033 | $SI->add($data); |
790 | 1034 | unset($data); |
791 | 1035 | } |
@@ -809,23 +1053,39 @@ discard block |
||
809 | 1053 | if (isset($line['inf'])) { |
810 | 1054 | $data = array(); |
811 | 1055 | $data['hex'] = $line['inf']['ia']; |
812 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1056 | + if (isset($line['inf']['cs'])) { |
|
1057 | + $data['ident'] = $line['inf']['cs']; |
|
1058 | + } |
|
1059 | + //$line[13] |
|
813 | 1060 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
814 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
815 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1061 | + if (isset($line['inf']['gs'])) { |
|
1062 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1063 | + } |
|
1064 | + // speed |
|
1065 | + if (isset($line['inf']['tr'])) { |
|
1066 | + $data['heading'] = $line['inf']['tr']; |
|
1067 | + } |
|
1068 | + // heading |
|
816 | 1069 | $data['latitude'] = $line['pt'][0]; // lat |
817 | 1070 | $data['longitude'] = $line['pt'][1]; // long |
818 | 1071 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
819 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1072 | + if (isset($line['inf']['sq'])) { |
|
1073 | + $data['squawk'] = $line['inf']['sq']; |
|
1074 | + } |
|
1075 | + // squawk |
|
820 | 1076 | //$data['aircraft_icao'] = $line[8]; |
821 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1077 | + if (isset($line['inf']['rc'])) { |
|
1078 | + $data['registration'] = $line['inf']['rc']; |
|
1079 | + } |
|
822 | 1080 | //$data['departure_airport_iata'] = $line[11]; |
823 | 1081 | //$data['arrival_airport_iata'] = $line[12]; |
824 | 1082 | //$data['emergency'] = ''; // emergency |
825 | 1083 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
826 | 1084 | $data['format_source'] = 'radarvirtueljson'; |
827 | 1085 | $data['id_source'] = $id_source; |
828 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1086 | + if (isset($value['name']) && $value['name'] != '') { |
|
1087 | + $data['source_name'] = $value['name']; |
|
1088 | + } |
|
829 | 1089 | $SI->add($data); |
830 | 1090 | unset($data); |
831 | 1091 | } |
@@ -846,29 +1106,62 @@ discard block |
||
846 | 1106 | $data['id'] = $line['id']; |
847 | 1107 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
848 | 1108 | $data['ident'] = $line['callsign']; // ident |
849 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
850 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
851 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
852 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
853 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
854 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1109 | + if (isset($line['pilotid'])) { |
|
1110 | + $data['pilot_id'] = $line['pilotid']; |
|
1111 | + } |
|
1112 | + // pilot id |
|
1113 | + if (isset($line['name'])) { |
|
1114 | + $data['pilot_name'] = $line['name']; |
|
1115 | + } |
|
1116 | + // pilot name |
|
1117 | + if (isset($line['alt'])) { |
|
1118 | + $data['altitude'] = $line['alt']; |
|
1119 | + } |
|
1120 | + // altitude |
|
1121 | + if (isset($line['gs'])) { |
|
1122 | + $data['speed'] = $line['gs']; |
|
1123 | + } |
|
1124 | + // speed |
|
1125 | + if (isset($line['heading'])) { |
|
1126 | + $data['heading'] = $line['heading']; |
|
1127 | + } |
|
1128 | + // heading |
|
1129 | + if (isset($line['route'])) { |
|
1130 | + $data['waypoints'] = $line['route']; |
|
1131 | + } |
|
1132 | + // route |
|
855 | 1133 | $data['latitude'] = $line['lat']; // lat |
856 | 1134 | $data['longitude'] = $line['lon']; // long |
857 | 1135 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
858 | 1136 | //$data['squawk'] = $line['squawk']; // squawk |
859 | 1137 | //$data['emergency'] = ''; // emergency |
860 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
861 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
862 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1138 | + if (isset($line['depicao'])) { |
|
1139 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1140 | + } |
|
1141 | + if (isset($line['deptime'])) { |
|
1142 | + $data['departure_airport_time'] = $line['deptime']; |
|
1143 | + } |
|
1144 | + if (isset($line['arricao'])) { |
|
1145 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1146 | + } |
|
863 | 1147 | //$data['arrival_airport_time'] = $line['arrtime']; |
864 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
865 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
866 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
867 | - else $data['info'] = ''; |
|
1148 | + if (isset($line['aircraft'])) { |
|
1149 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1150 | + } |
|
1151 | + if (isset($line['transponder'])) { |
|
1152 | + $data['squawk'] = $line['transponder']; |
|
1153 | + } |
|
1154 | + if (isset($line['atis'])) { |
|
1155 | + $data['info'] = $line['atis']; |
|
1156 | + } else { |
|
1157 | + $data['info'] = ''; |
|
1158 | + } |
|
868 | 1159 | $data['format_source'] = 'pireps'; |
869 | 1160 | $data['id_source'] = $id_source; |
870 | 1161 | $data['datetime'] = date('Y-m-d H:i:s'); |
871 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1162 | + if (isset($value['name']) && $value['name'] != '') { |
|
1163 | + $data['source_name'] = $value['name']; |
|
1164 | + } |
|
872 | 1165 | if ($line['icon'] == 'plane') { |
873 | 1166 | $SI->add($data); |
874 | 1167 | // print_r($data); |
@@ -877,16 +1170,28 @@ discard block |
||
877 | 1170 | $data['info'] = str_replace('&sect;','',$data['info']); |
878 | 1171 | $typec = substr($data['ident'],-3); |
879 | 1172 | $data['type'] = ''; |
880 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
881 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
882 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
883 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
884 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
885 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
886 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
887 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
888 | - else $data['type'] = 'Observer'; |
|
889 | - 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']); |
|
1173 | + if ($typec == 'APP') { |
|
1174 | + $data['type'] = 'Approach'; |
|
1175 | + } elseif ($typec == 'TWR') { |
|
1176 | + $data['type'] = 'Tower'; |
|
1177 | + } elseif ($typec == 'OBS') { |
|
1178 | + $data['type'] = 'Observer'; |
|
1179 | + } elseif ($typec == 'GND') { |
|
1180 | + $data['type'] = 'Ground'; |
|
1181 | + } elseif ($typec == 'DEL') { |
|
1182 | + $data['type'] = 'Delivery'; |
|
1183 | + } elseif ($typec == 'DEP') { |
|
1184 | + $data['type'] = 'Departure'; |
|
1185 | + } elseif ($typec == 'FSS') { |
|
1186 | + $data['type'] = 'Flight Service Station'; |
|
1187 | + } elseif ($typec == 'CTR') { |
|
1188 | + $data['type'] = 'Control Radar or Centre'; |
|
1189 | + } else { |
|
1190 | + $data['type'] = 'Observer'; |
|
1191 | + } |
|
1192 | + if (isset($ATC)) { |
|
1193 | + 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']); |
|
1194 | + } |
|
890 | 1195 | } |
891 | 1196 | unset($data); |
892 | 1197 | } |
@@ -896,7 +1201,9 @@ discard block |
||
896 | 1201 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
897 | 1202 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
898 | 1203 | //$buffer = $Common->getData($hosts[$id]); |
899 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1204 | + if ($globalDebug) { |
|
1205 | + echo 'Get Data...'."\n"; |
|
1206 | + } |
|
900 | 1207 | $buffer = $Common->getData($value['host']); |
901 | 1208 | $all_data = json_decode($buffer,true); |
902 | 1209 | if ($buffer != '' && is_array($all_data)) { |
@@ -904,10 +1211,16 @@ discard block |
||
904 | 1211 | foreach ($all_data as $line) { |
905 | 1212 | $data = array(); |
906 | 1213 | //$data['id'] = $line['id']; // id not usable |
907 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1214 | + if (isset($line['pilotid'])) { |
|
1215 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1216 | + } |
|
908 | 1217 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
909 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
910 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1218 | + if (isset($line['pilotname'])) { |
|
1219 | + $data['pilot_name'] = $line['pilotname']; |
|
1220 | + } |
|
1221 | + if (isset($line['pilotid'])) { |
|
1222 | + $data['pilot_id'] = $line['pilotid']; |
|
1223 | + } |
|
911 | 1224 | $data['ident'] = $line['flightnum']; // ident |
912 | 1225 | $data['altitude'] = $line['alt']; // altitude |
913 | 1226 | $data['speed'] = $line['gs']; // speed |
@@ -925,27 +1238,41 @@ discard block |
||
925 | 1238 | $data['arrival_airport_icao'] = $line['arricao']; |
926 | 1239 | $data['arrival_airport_time'] = $line['arrtime']; |
927 | 1240 | $data['registration'] = $line['aircraft']; |
928 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1241 | + if (isset($line['route'])) { |
|
1242 | + $data['waypoints'] = $line['route']; |
|
1243 | + } |
|
1244 | + // route |
|
929 | 1245 | if (isset($line['aircraftname'])) { |
930 | 1246 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
931 | 1247 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
932 | 1248 | $aircraft_data = explode('-',$line['aircraftname']); |
933 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
934 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
935 | - else { |
|
1249 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) { |
|
1250 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1251 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) { |
|
1252 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1253 | + } else { |
|
936 | 1254 | $aircraft_data = explode(' ',$line['aircraftname']); |
937 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
938 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
1255 | + if (isset($aircraft_data[1])) { |
|
1256 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1257 | + } else { |
|
1258 | + $data['aircraft_icao'] = $line['aircraftname']; |
|
1259 | + } |
|
939 | 1260 | } |
940 | 1261 | } |
941 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1262 | + if (isset($line['route'])) { |
|
1263 | + $data['waypoints'] = $line['route']; |
|
1264 | + } |
|
942 | 1265 | $data['id_source'] = $id_source; |
943 | 1266 | $data['format_source'] = 'phpvmacars'; |
944 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1267 | + if (isset($value['name']) && $value['name'] != '') { |
|
1268 | + $data['source_name'] = $value['name']; |
|
1269 | + } |
|
945 | 1270 | $SI->add($data); |
946 | 1271 | unset($data); |
947 | 1272 | } |
948 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1273 | + if ($globalDebug) { |
|
1274 | + echo 'No more data...'."\n"; |
|
1275 | + } |
|
949 | 1276 | unset($buffer); |
950 | 1277 | unset($all_data); |
951 | 1278 | } |
@@ -953,7 +1280,9 @@ discard block |
||
953 | 1280 | $last_exec[$id]['last'] = time(); |
954 | 1281 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
955 | 1282 | //$buffer = $Common->getData($hosts[$id]); |
956 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1283 | + if ($globalDebug) { |
|
1284 | + echo 'Get Data...'."\n"; |
|
1285 | + } |
|
957 | 1286 | $buffer = $Common->getData($value['host']); |
958 | 1287 | $all_data = json_decode($buffer,true); |
959 | 1288 | if ($buffer != '' && is_array($all_data)) { |
@@ -982,15 +1311,22 @@ discard block |
||
982 | 1311 | $data['arrival_airport_icao'] = $line['arrival']; |
983 | 1312 | //$data['arrival_airport_time'] = $line['arrival_time']; |
984 | 1313 | //$data['registration'] = $line['aircraft']; |
985 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1314 | + if (isset($line['route'])) { |
|
1315 | + $data['waypoints'] = $line['route']; |
|
1316 | + } |
|
1317 | + // route |
|
986 | 1318 | $data['aircraft_icao'] = $line['plane_type']; |
987 | 1319 | $data['id_source'] = $id_source; |
988 | 1320 | $data['format_source'] = 'vam'; |
989 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1321 | + if (isset($value['name']) && $value['name'] != '') { |
|
1322 | + $data['source_name'] = $value['name']; |
|
1323 | + } |
|
990 | 1324 | $SI->add($data); |
991 | 1325 | unset($data); |
992 | 1326 | } |
993 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1327 | + if ($globalDebug) { |
|
1328 | + echo 'No more data...'."\n"; |
|
1329 | + } |
|
994 | 1330 | unset($buffer); |
995 | 1331 | unset($all_data); |
996 | 1332 | } |
@@ -998,7 +1334,9 @@ discard block |
||
998 | 1334 | $last_exec[$id]['last'] = time(); |
999 | 1335 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1000 | 1336 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais') { |
1001 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1337 | + if (function_exists('pcntl_fork')) { |
|
1338 | + pcntl_signal_dispatch(); |
|
1339 | + } |
|
1002 | 1340 | //$last_exec[$id]['last'] = time(); |
1003 | 1341 | |
1004 | 1342 | //$read = array( $sockets[$id] ); |
@@ -1006,7 +1344,9 @@ discard block |
||
1006 | 1344 | $write = NULL; |
1007 | 1345 | $e = NULL; |
1008 | 1346 | $n = socket_select($read, $write, $e, $timeout); |
1009 | - if ($e != NULL) var_dump($e); |
|
1347 | + if ($e != NULL) { |
|
1348 | + var_dump($e); |
|
1349 | + } |
|
1010 | 1350 | if ($n > 0) { |
1011 | 1351 | $reset = 0; |
1012 | 1352 | foreach ($read as $nb => $r) { |
@@ -1028,7 +1368,9 @@ discard block |
||
1028 | 1368 | if ($buffer != '') { |
1029 | 1369 | $tt[$format] = 0; |
1030 | 1370 | if ($format == 'acarssbs3') { |
1031 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1371 | + if ($globalDebug) { |
|
1372 | + echo 'ACARS : '.$buffer."\n"; |
|
1373 | + } |
|
1032 | 1374 | $ACARS->add(trim($buffer)); |
1033 | 1375 | $ACARS->deleteLiveAcarsData(); |
1034 | 1376 | } elseif ($format == 'raw') { |
@@ -1037,25 +1379,55 @@ discard block |
||
1037 | 1379 | if (is_array($data)) { |
1038 | 1380 | $data['datetime'] = date('Y-m-d H:i:s'); |
1039 | 1381 | $data['format_source'] = 'raw'; |
1040 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1041 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1042 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1382 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1383 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1384 | + } |
|
1385 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1386 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1387 | + } |
|
1388 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1389 | + $SI->add($data); |
|
1390 | + } |
|
1043 | 1391 | } |
1044 | 1392 | } elseif ($format == 'ais') { |
1045 | 1393 | $ais_data = $AIS->parse_line(trim($buffer)); |
1046 | 1394 | $data = array(); |
1047 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1048 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1049 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1050 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1051 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1052 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1053 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1054 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1055 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1056 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1057 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1058 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1395 | + if (isset($ais_data['ident'])) { |
|
1396 | + $data['ident'] = $ais_data['ident']; |
|
1397 | + } |
|
1398 | + if (isset($ais_data['mmsi'])) { |
|
1399 | + $data['mmsi'] = $ais_data['mmsi']; |
|
1400 | + } |
|
1401 | + if (isset($ais_data['speed'])) { |
|
1402 | + $data['speed'] = $ais_data['speed']; |
|
1403 | + } |
|
1404 | + if (isset($ais_data['heading'])) { |
|
1405 | + $data['heading'] = $ais_data['heading']; |
|
1406 | + } |
|
1407 | + if (isset($ais_data['latitude'])) { |
|
1408 | + $data['latitude'] = $ais_data['latitude']; |
|
1409 | + } |
|
1410 | + if (isset($ais_data['longitude'])) { |
|
1411 | + $data['longitude'] = $ais_data['longitude']; |
|
1412 | + } |
|
1413 | + if (isset($ais_data['status'])) { |
|
1414 | + $data['status'] = $ais_data['status']; |
|
1415 | + } |
|
1416 | + if (isset($ais_data['type'])) { |
|
1417 | + $data['type'] = $ais_data['type']; |
|
1418 | + } |
|
1419 | + if (isset($ais_data['imo'])) { |
|
1420 | + $data['imo'] = $ais_data['imo']; |
|
1421 | + } |
|
1422 | + if (isset($ais_data['callsign'])) { |
|
1423 | + $data['callsign'] = $ais_data['callsign']; |
|
1424 | + } |
|
1425 | + if (isset($ais_data['destination'])) { |
|
1426 | + $data['arrival_code'] = $ais_data['destination']; |
|
1427 | + } |
|
1428 | + if (isset($ais_data['eta_ts'])) { |
|
1429 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1430 | + } |
|
1059 | 1431 | |
1060 | 1432 | if (isset($ais_data['timestamp'])) { |
1061 | 1433 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1064,7 +1436,9 @@ discard block |
||
1064 | 1436 | } |
1065 | 1437 | $data['format_source'] = 'aisnmea'; |
1066 | 1438 | $data['id_source'] = $id_source; |
1067 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1439 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
1440 | + $MI->add($data); |
|
1441 | + } |
|
1068 | 1442 | unset($data); |
1069 | 1443 | } elseif ($format == 'flightgearsp') { |
1070 | 1444 | //echo $buffer."\n"; |
@@ -1082,11 +1456,15 @@ discard block |
||
1082 | 1456 | $data['speed'] = round($line[5]*1.94384); |
1083 | 1457 | $data['datetime'] = date('Y-m-d H:i:s'); |
1084 | 1458 | $data['format_source'] = 'flightgearsp'; |
1085 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1459 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1460 | + $SI->add($data); |
|
1461 | + } |
|
1086 | 1462 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1087 | 1463 | } |
1088 | 1464 | } elseif ($format == 'acars') { |
1089 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1465 | + if ($globalDebug) { |
|
1466 | + echo 'ACARS : '.$buffer."\n"; |
|
1467 | + } |
|
1090 | 1468 | $ACARS->add(trim($buffer)); |
1091 | 1469 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1092 | 1470 | $ACARS->deleteLiveAcarsData(); |
@@ -1107,7 +1485,9 @@ discard block |
||
1107 | 1485 | $aircraft_type = $line[10]; |
1108 | 1486 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1109 | 1487 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1110 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1488 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1489 | + $SI->add($data); |
|
1490 | + } |
|
1111 | 1491 | } |
1112 | 1492 | } |
1113 | 1493 | } elseif ($format == 'beast') { |
@@ -1123,21 +1503,43 @@ discard block |
||
1123 | 1503 | $data['hex'] = $lined['hexid']; |
1124 | 1504 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1125 | 1505 | $data['datetime'] = date('Y-m-d H:i:s');; |
1126 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1127 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1128 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1129 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1130 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1131 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1132 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1506 | + if (isset($lined['ident'])) { |
|
1507 | + $data['ident'] = $lined['ident']; |
|
1508 | + } |
|
1509 | + if (isset($lined['lat'])) { |
|
1510 | + $data['latitude'] = $lined['lat']; |
|
1511 | + } |
|
1512 | + if (isset($lined['lon'])) { |
|
1513 | + $data['longitude'] = $lined['lon']; |
|
1514 | + } |
|
1515 | + if (isset($lined['speed'])) { |
|
1516 | + $data['speed'] = $lined['speed']; |
|
1517 | + } |
|
1518 | + if (isset($lined['squawk'])) { |
|
1519 | + $data['squawk'] = $lined['squawk']; |
|
1520 | + } |
|
1521 | + if (isset($lined['alt'])) { |
|
1522 | + $data['altitude'] = $lined['alt']; |
|
1523 | + } |
|
1524 | + if (isset($lined['heading'])) { |
|
1525 | + $data['heading'] = $lined['heading']; |
|
1526 | + } |
|
1133 | 1527 | $data['id_source'] = $id_source; |
1134 | 1528 | $data['format_source'] = 'tsv'; |
1135 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1136 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1137 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1529 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1530 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1531 | + } |
|
1532 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1533 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1534 | + } |
|
1535 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1536 | + $SI->add($data); |
|
1537 | + } |
|
1138 | 1538 | unset($lined); |
1139 | 1539 | unset($data); |
1140 | - } else $error = true; |
|
1540 | + } else { |
|
1541 | + $error = true; |
|
1542 | + } |
|
1141 | 1543 | } elseif ($format == 'aprs' && $use_aprs) { |
1142 | 1544 | if ($aprs_connect == 0) { |
1143 | 1545 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1163,49 +1565,82 @@ discard block |
||
1163 | 1565 | $aprs_last_tx = time(); |
1164 | 1566 | $data = array(); |
1165 | 1567 | //print_r($line); |
1166 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1167 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1168 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1568 | + if (isset($line['address'])) { |
|
1569 | + $data['hex'] = $line['address']; |
|
1570 | + } |
|
1571 | + if (isset($line['timestamp'])) { |
|
1572 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1573 | + } else { |
|
1574 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1575 | + } |
|
1169 | 1576 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1170 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1577 | + if (isset($line['ident'])) { |
|
1578 | + $data['ident'] = $line['ident']; |
|
1579 | + } |
|
1171 | 1580 | $data['latitude'] = $line['latitude']; |
1172 | 1581 | $data['longitude'] = $line['longitude']; |
1173 | 1582 | //$data['verticalrate'] = $line[16]; |
1174 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1175 | - else $data['speed'] = 0; |
|
1176 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1177 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1178 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1179 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1583 | + if (isset($line['speed'])) { |
|
1584 | + $data['speed'] = $line['speed']; |
|
1585 | + } else { |
|
1586 | + $data['speed'] = 0; |
|
1587 | + } |
|
1588 | + if (isset($line['altitude'])) { |
|
1589 | + $data['altitude'] = $line['altitude']; |
|
1590 | + } |
|
1591 | + if (isset($line['comment'])) { |
|
1592 | + $data['comment'] = $line['comment']; |
|
1593 | + } |
|
1594 | + if (isset($line['symbol'])) { |
|
1595 | + $data['type'] = $line['symbol']; |
|
1596 | + } |
|
1597 | + if (isset($line['heading'])) { |
|
1598 | + $data['heading'] = $line['heading']; |
|
1599 | + } |
|
1180 | 1600 | //else $data['heading'] = 0; |
1181 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1182 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1601 | + if (isset($line['stealth'])) { |
|
1602 | + $data['aircraft_type'] = $line['stealth']; |
|
1603 | + } |
|
1604 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
1605 | + $data['noarchive'] = true; |
|
1606 | + } |
|
1183 | 1607 | $data['id_source'] = $id_source; |
1184 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1185 | - else $data['format_source'] = 'aprs'; |
|
1608 | + if (isset($line['format_source'])) { |
|
1609 | + $data['format_source'] = $line['format_source']; |
|
1610 | + } else { |
|
1611 | + $data['format_source'] = 'aprs'; |
|
1612 | + } |
|
1186 | 1613 | $data['source_name'] = $line['source']; |
1187 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1188 | - else $data['source_type'] = 'flarm'; |
|
1189 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1614 | + if (isset($line['source_type'])) { |
|
1615 | + $data['source_type'] = $line['source_type']; |
|
1616 | + } else { |
|
1617 | + $data['source_type'] = 'flarm'; |
|
1618 | + } |
|
1619 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1620 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1621 | + } |
|
1190 | 1622 | $currentdate = date('Y-m-d H:i:s'); |
1191 | 1623 | $aprsdate = strtotime($data['datetime']); |
1192 | 1624 | // Accept data if time <= system time + 20s |
1193 | 1625 | 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'])))) { |
1194 | 1626 | $send = $SI->add($data); |
1195 | 1627 | } elseif (isset($line['stealth'])) { |
1196 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1197 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1628 | + if ($line['stealth'] != 0) { |
|
1629 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1630 | + } else { |
|
1631 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1632 | + } |
|
1198 | 1633 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
1199 | 1634 | } 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') { |
1200 | 1635 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1201 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
1636 | + if (isset($globalTracker) && $globalTracker) { |
|
1637 | + $send = $TI->add($data); |
|
1638 | + } |
|
1202 | 1639 | } |
1203 | 1640 | unset($data); |
1204 | - } |
|
1205 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1641 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1206 | 1642 | echo '!! Weather Station not yet supported'."\n"; |
1207 | - } |
|
1208 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
1643 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
1209 | 1644 | echo '!! Car & Trucks not yet supported'."\n"; |
1210 | 1645 | } |
1211 | 1646 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
@@ -1238,25 +1673,42 @@ discard block |
||
1238 | 1673 | $data['ground'] = $line[21]; |
1239 | 1674 | $data['emergency'] = $line[19]; |
1240 | 1675 | $data['format_source'] = 'sbs'; |
1241 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1242 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1676 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1677 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1678 | + } |
|
1679 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1680 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1681 | + } |
|
1243 | 1682 | $data['id_source'] = $id_source; |
1244 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1245 | - else $error = true; |
|
1683 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1684 | + $send = $SI->add($data); |
|
1685 | + } else { |
|
1686 | + $error = true; |
|
1687 | + } |
|
1246 | 1688 | unset($data); |
1247 | - } else $error = true; |
|
1689 | + } else { |
|
1690 | + $error = true; |
|
1691 | + } |
|
1248 | 1692 | if ($error) { |
1249 | 1693 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1250 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
1694 | + if ($globalDebug) { |
|
1695 | + echo "Not a message. Ignoring... \n"; |
|
1696 | + } |
|
1251 | 1697 | } else { |
1252 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
1698 | + if ($globalDebug) { |
|
1699 | + echo "Wrong line format. Ignoring... \n"; |
|
1700 | + } |
|
1253 | 1701 | if ($globalDebug) { |
1254 | 1702 | echo $buffer; |
1255 | 1703 | print_r($line); |
1256 | 1704 | } |
1257 | 1705 | //socket_close($r); |
1258 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1259 | - if ($format == 'aprs') $aprs_connect = 0; |
|
1706 | + if ($globalDebug) { |
|
1707 | + echo "Reconnect after an error...\n"; |
|
1708 | + } |
|
1709 | + if ($format == 'aprs') { |
|
1710 | + $aprs_connect = 0; |
|
1711 | + } |
|
1260 | 1712 | $sourceer[$nb] = $globalSources[$nb]; |
1261 | 1713 | connect_all($sourceer); |
1262 | 1714 | $sourceer = array(); |
@@ -1264,10 +1716,14 @@ discard block |
||
1264 | 1716 | } |
1265 | 1717 | } |
1266 | 1718 | // Sleep for xxx microseconds |
1267 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
1719 | + if (isset($globalSBSSleep)) { |
|
1720 | + usleep($globalSBSSleep); |
|
1721 | + } |
|
1268 | 1722 | } else { |
1269 | 1723 | if ($format == 'flightgearmp') { |
1270 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1724 | + if ($globalDebug) { |
|
1725 | + echo "Reconnect FlightGear MP..."; |
|
1726 | + } |
|
1271 | 1727 | //@socket_close($r); |
1272 | 1728 | sleep($globalMinFetch); |
1273 | 1729 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1276,10 +1732,15 @@ discard block |
||
1276 | 1732 | break; |
1277 | 1733 | |
1278 | 1734 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1279 | - if (isset($tt[$format])) $tt[$format]++; |
|
1280 | - else $tt[$format] = 0; |
|
1735 | + if (isset($tt[$format])) { |
|
1736 | + $tt[$format]++; |
|
1737 | + } else { |
|
1738 | + $tt[$format] = 0; |
|
1739 | + } |
|
1281 | 1740 | if ($tt[$format] > 30) { |
1282 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
1741 | + if ($globalDebug) { |
|
1742 | + echo "ERROR : Reconnect ".$format."..."; |
|
1743 | + } |
|
1283 | 1744 | //@socket_close($r); |
1284 | 1745 | sleep(2); |
1285 | 1746 | $aprs_connect = 0; |
@@ -1296,11 +1757,17 @@ discard block |
||
1296 | 1757 | } else { |
1297 | 1758 | $error = socket_strerror(socket_last_error()); |
1298 | 1759 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1299 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1300 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
1760 | + if ($globalDebug) { |
|
1761 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1762 | + } |
|
1763 | + if (isset($globalDebug)) { |
|
1764 | + echo "Restarting...\n"; |
|
1765 | + } |
|
1301 | 1766 | // Restart the script if possible |
1302 | 1767 | if (is_array($sockets)) { |
1303 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1768 | + if ($globalDebug) { |
|
1769 | + echo "Shutdown all sockets..."; |
|
1770 | + } |
|
1304 | 1771 | |
1305 | 1772 | foreach ($sockets as $sock) { |
1306 | 1773 | @socket_shutdown($sock,2); |
@@ -1308,18 +1775,24 @@ discard block |
||
1308 | 1775 | } |
1309 | 1776 | |
1310 | 1777 | } |
1311 | - if ($globalDebug) echo "Restart all connections..."; |
|
1778 | + if ($globalDebug) { |
|
1779 | + echo "Restart all connections..."; |
|
1780 | + } |
|
1312 | 1781 | sleep(2); |
1313 | 1782 | $time = time(); |
1314 | 1783 | //connect_all($hosts); |
1315 | 1784 | $aprs_connect = 0; |
1316 | - if ($reset > 40) exit('Too many attempts...'); |
|
1785 | + if ($reset > 40) { |
|
1786 | + exit('Too many attempts...'); |
|
1787 | + } |
|
1317 | 1788 | connect_all($globalSources); |
1318 | 1789 | } |
1319 | 1790 | } |
1320 | 1791 | } |
1321 | 1792 | if ($globalDaemon === false) { |
1322 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1793 | + if ($globalDebug) { |
|
1794 | + echo 'Check all...'."\n"; |
|
1795 | + } |
|
1323 | 1796 | $SI->checkAll(); |
1324 | 1797 | } |
1325 | 1798 | } |