@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | die; |
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
48 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::')); |
|
52 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::')); |
|
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
@@ -67,27 +67,27 @@ discard block |
||
67 | 67 | else $id_source = 1; |
68 | 68 | if (isset($globalServer) && $globalServer) { |
69 | 69 | if ($globalDebug) echo "Using Server Mode\n"; |
70 | - $SI=new SpotterServer(); |
|
70 | + $SI = new SpotterServer(); |
|
71 | 71 | /* |
72 | 72 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
73 | 73 | $SI = new adsb2aprs(); |
74 | 74 | $SI->connect(); |
75 | 75 | */ |
76 | -} else $SI=new SpotterImport($Connection->db); |
|
76 | +} else $SI = new SpotterImport($Connection->db); |
|
77 | 77 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
78 | 78 | if (isset($globalMarine) && $globalMarine) { |
79 | 79 | $AIS = new AIS(); |
80 | 80 | $MI = new MarineImport($Connection->db); |
81 | 81 | } |
82 | 82 | //$APRS=new APRS($Connection->db); |
83 | -$SBS=new SBS(); |
|
84 | -$ACARS=new ACARS($Connection->db); |
|
85 | -$Common=new Common(); |
|
83 | +$SBS = new SBS(); |
|
84 | +$ACARS = new ACARS($Connection->db); |
|
85 | +$Common = new Common(); |
|
86 | 86 | date_default_timezone_set('UTC'); |
87 | 87 | //$servertz = system('date +%Z'); |
88 | 88 | // signal handler - playing nice with sockets and dump1090 |
89 | 89 | if (function_exists('pcntl_fork')) { |
90 | - pcntl_signal(SIGINT, function() { |
|
90 | + pcntl_signal(SIGINT, function() { |
|
91 | 91 | global $sockets; |
92 | 92 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
93 | 93 | die("Bye!\n"); |
@@ -103,35 +103,35 @@ discard block |
||
103 | 103 | |
104 | 104 | function connect_all($hosts) { |
105 | 105 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
106 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
106 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
107 | 107 | $reset++; |
108 | 108 | if ($globalDebug) echo 'Connect to all...'."\n"; |
109 | 109 | foreach ($hosts as $id => $value) { |
110 | 110 | $host = $value['host']; |
111 | 111 | $globalSources[$id]['last_exec'] = 0; |
112 | 112 | // Here we check type of source(s) |
113 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
114 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
113 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
114 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
115 | 115 | //$formats[$id] = 'deltadbtxt'; |
116 | 116 | $globalSources[$id]['format'] = 'deltadbtxt'; |
117 | 117 | //$last_exec['deltadbtxt'] = 0; |
118 | 118 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
119 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
119 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
120 | 120 | //$formats[$id] = 'vatsimtxt'; |
121 | 121 | $globalSources[$id]['format'] = 'vatsimtxt'; |
122 | 122 | //$last_exec['vatsimtxt'] = 0; |
123 | 123 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
124 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
124 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
125 | 125 | //$formats[$id] = 'aircraftlistjson'; |
126 | 126 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
127 | 127 | //$last_exec['aircraftlistjson'] = 0; |
128 | 128 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
129 | - } else if (preg_match('/opensky/i',$host)) { |
|
129 | + } else if (preg_match('/opensky/i', $host)) { |
|
130 | 130 | //$formats[$id] = 'aircraftlistjson'; |
131 | 131 | $globalSources[$id]['format'] = 'opensky'; |
132 | 132 | //$last_exec['aircraftlistjson'] = 0; |
133 | 133 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
134 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
134 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
135 | 135 | //$formats[$id] = 'radarvirtueljson'; |
136 | 136 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
137 | 137 | //$last_exec['radarvirtueljson'] = 0; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
141 | 141 | exit(0); |
142 | 142 | } |
143 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
143 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
144 | 144 | //$formats[$id] = 'planeupdatefaa'; |
145 | 145 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
146 | 146 | //$last_exec['planeupdatefaa'] = 0; |
@@ -149,26 +149,26 @@ discard block |
||
149 | 149 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
150 | 150 | exit(0); |
151 | 151 | } |
152 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
152 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
153 | 153 | //$formats[$id] = 'phpvmacars'; |
154 | 154 | $globalSources[$id]['format'] = 'phpvmacars'; |
155 | 155 | //$last_exec['phpvmacars'] = 0; |
156 | 156 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
157 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
157 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
158 | 158 | //$formats[$id] = 'phpvmacars'; |
159 | 159 | $globalSources[$id]['format'] = 'vam'; |
160 | 160 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
161 | + } else if (preg_match('/whazzup/i', $host)) { |
|
162 | 162 | //$formats[$id] = 'whazzup'; |
163 | 163 | $globalSources[$id]['format'] = 'whazzup'; |
164 | 164 | //$last_exec['whazzup'] = 0; |
165 | 165 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
166 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
167 | 167 | //$formats[$id] = 'pirepsjson'; |
168 | 168 | $globalSources[$id]['format'] = 'pirepsjson'; |
169 | 169 | //$last_exec['pirepsjson'] = 0; |
170 | 170 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
172 | 172 | //$formats[$id] = 'fr24json'; |
173 | 173 | $globalSources[$id]['format'] = 'fr24json'; |
174 | 174 | //$last_exec['fr24json'] = 0; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
178 | 178 | exit(0); |
179 | 179 | } |
180 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
180 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
181 | 181 | //$formats[$id] = 'fr24json'; |
182 | 182 | $globalSources[$id]['format'] = 'myshiptracking'; |
183 | 183 | //$last_exec['fr24json'] = 0; |
@@ -187,22 +187,22 @@ discard block |
||
187 | 187 | exit(0); |
188 | 188 | } |
189 | 189 | //} else if (preg_match('/10001/',$host)) { |
190 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
190 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | 191 | //$formats[$id] = 'tsv'; |
192 | 192 | $globalSources[$id]['format'] = 'tsv'; |
193 | 193 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
194 | 194 | } |
195 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
195 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
196 | 196 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
197 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
197 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
198 | 198 | if ($idf !== false) { |
199 | 199 | $httpfeeds[$id] = $idf; |
200 | 200 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
201 | 201 | } |
202 | 202 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
203 | 203 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
204 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | - $hostport = explode(':',$host); |
|
204 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
205 | + $hostport = explode(':', $host); |
|
206 | 206 | if (isset($hostport[1])) { |
207 | 207 | $port = $hostport[1]; |
208 | 208 | $hostn = $hostport[0]; |
@@ -212,19 +212,19 @@ discard block |
||
212 | 212 | } |
213 | 213 | $Common = new Common(); |
214 | 214 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
215 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
215 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
216 | 216 | } else { |
217 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
217 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
218 | 218 | } |
219 | 219 | if ($s) { |
220 | 220 | $sockets[$id] = $s; |
221 | 221 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
222 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
222 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
223 | 223 | //$formats[$id] = 'aprs'; |
224 | 224 | $globalSources[$id]['format'] = 'aprs'; |
225 | 225 | //$aprs_connect = 0; |
226 | 226 | //$use_aprs = true; |
227 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
227 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
228 | 228 | $globalSources[$id]['format'] = 'vrstcp'; |
229 | 229 | } elseif ($port == '10001') { |
230 | 230 | //$formats[$id] = 'tsv'; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
264 | 264 | else $timeout = 20; |
265 | 265 | $errno = ''; |
266 | -$errstr=''; |
|
266 | +$errstr = ''; |
|
267 | 267 | |
268 | 268 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
269 | 269 | /* Initiate connections to all the hosts simultaneously */ |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | //connect_all($globalSources); |
272 | 272 | |
273 | 273 | if (isset($globalProxy) && $globalProxy) { |
274 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
274 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
275 | 275 | } else { |
276 | 276 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
277 | 277 | } |
@@ -298,16 +298,16 @@ discard block |
||
298 | 298 | |
299 | 299 | if ($use_aprs) { |
300 | 300 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
301 | - $APRS=new APRS(); |
|
301 | + $APRS = new APRS(); |
|
302 | 302 | $aprs_connect = 0; |
303 | 303 | $aprs_keep = 120; |
304 | 304 | $aprs_last_tx = time(); |
305 | 305 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
306 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
306 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
307 | 307 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
308 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
308 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
309 | 309 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
310 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
310 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
311 | 311 | if ($aprs_full) $aprs_filter = ''; |
312 | 312 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
313 | 313 | else $aprs_pass = '-1'; |
@@ -321,12 +321,12 @@ discard block |
||
321 | 321 | sleep(1); |
322 | 322 | if ($globalDebug) echo "SCAN MODE \n\n"; |
323 | 323 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
324 | -$endtime = time()+$globalCronEnd; |
|
324 | +$endtime = time() + $globalCronEnd; |
|
325 | 325 | $i = 1; |
326 | 326 | $tt = array(); |
327 | 327 | // Delete all ATC |
328 | 328 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
329 | - $ATC=new ATC($Connection->db); |
|
329 | + $ATC = new ATC($Connection->db); |
|
330 | 330 | } |
331 | 331 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
332 | 332 | $ATC->deleteAll(); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | |
335 | 335 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
336 | 336 | while ($i > 0) { |
337 | - if (!$globalDaemon) $i = $endtime-time(); |
|
337 | + if (!$globalDaemon) $i = $endtime - time(); |
|
338 | 338 | // Delete old ATC |
339 | 339 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
340 | 340 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | } |
350 | 350 | if ($max != $globalMinFetch) { |
351 | 351 | if ($globalDebug) echo 'Sleeping...'."\n"; |
352 | - sleep($globalMinFetch-$max+2); |
|
352 | + sleep($globalMinFetch - $max + 2); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | //$buffer = $Common->getData($hosts[$id]); |
363 | 363 | $buffer = $Common->getData($value['host']); |
364 | 364 | if ($buffer != '') $reset = 0; |
365 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
366 | - $buffer = explode('\n',$buffer); |
|
365 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
366 | + $buffer = explode('\n', $buffer); |
|
367 | 367 | foreach ($buffer as $line) { |
368 | 368 | if ($line != '' && count($line) > 7) { |
369 | 369 | $line = explode(',', $line); |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | $last_exec[$id]['last'] = time(); |
391 | 391 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
392 | 392 | date_default_timezone_set('CET'); |
393 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
393 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
394 | 394 | date_default_timezone_set('UTC'); |
395 | 395 | if ($buffer != '') $reset = 0; |
396 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
397 | - $buffer = explode('\n',$buffer); |
|
396 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
397 | + $buffer = explode('\n', $buffer); |
|
398 | 398 | foreach ($buffer as $line) { |
399 | 399 | if ($line != '') { |
400 | 400 | echo "'".$line."'\n"; |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
413 | 413 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
414 | 414 | if (isset($ais_data['timestamp'])) { |
415 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
415 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
416 | 416 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
417 | 417 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
418 | 418 | $add = true; |
@@ -435,12 +435,12 @@ discard block |
||
435 | 435 | $w = $e = null; |
436 | 436 | |
437 | 437 | if (isset($arr[$id])) { |
438 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
438 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
439 | 439 | if ($nn > 0) { |
440 | 440 | foreach ($httpfeeds as $feed) { |
441 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
442 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
443 | - $buffer = explode('\n',$buffer); |
|
441 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
442 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
443 | + $buffer = explode('\n', $buffer); |
|
444 | 444 | foreach ($buffer as $line) { |
445 | 445 | if ($line != '') { |
446 | 446 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -456,9 +456,9 @@ discard block |
||
456 | 456 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
457 | 457 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
458 | 458 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
459 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
459 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
460 | 460 | if (isset($ais_data['timestamp'])) { |
461 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
461 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
462 | 462 | } else { |
463 | 463 | $data['datetime'] = date('Y-m-d H:i:s'); |
464 | 464 | } |
@@ -472,10 +472,10 @@ discard block |
||
472 | 472 | } |
473 | 473 | } |
474 | 474 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
475 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
475 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
476 | 476 | if ($buffer != '') { |
477 | 477 | //echo $buffer; |
478 | - $all_data = json_decode($buffer,true); |
|
478 | + $all_data = json_decode($buffer, true); |
|
479 | 479 | //print_r($all_data); |
480 | 480 | if (isset($all_data[0]['DATA'])) { |
481 | 481 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
491 | 491 | $data['imo'] = $line['IMO']; |
492 | 492 | //$data['arrival_code'] = $ais_data['destination']; |
493 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
493 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
494 | 494 | $data['format_source'] = 'myshiptracking'; |
495 | 495 | $data['id_source'] = $id_source; |
496 | 496 | $MI->add($data); |
@@ -502,9 +502,9 @@ discard block |
||
502 | 502 | } |
503 | 503 | $last_exec[$id]['last'] = time(); |
504 | 504 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
505 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
505 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
506 | 506 | if ($buffer != '') { |
507 | - $all_data = json_decode($buffer,true); |
|
507 | + $all_data = json_decode($buffer, true); |
|
508 | 508 | if (isset($all_data[0]['mmsi'])) { |
509 | 509 | foreach ($all_data as $line) { |
510 | 510 | if ($line != '') { |
@@ -531,27 +531,27 @@ discard block |
||
531 | 531 | $last_exec[$id]['last'] = time(); |
532 | 532 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
533 | 533 | echo 'download...'; |
534 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
534 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
535 | 535 | echo 'done !'."\n"; |
536 | 536 | if ($buffer != '') $reset = 0; |
537 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
538 | - $buffer = explode('\n',$buffer); |
|
537 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
538 | + $buffer = explode('\n', $buffer); |
|
539 | 539 | foreach ($buffer as $line) { |
540 | 540 | if ($line != '') { |
541 | 541 | $data = array(); |
542 | - $data['mmsi'] = (int)substr($line,0,9); |
|
543 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
542 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
543 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
544 | 544 | //$data['status'] = substr($line,21,2); |
545 | 545 | //$data['type'] = substr($line,24,3); |
546 | - $data['latitude'] = substr($line,29,9); |
|
547 | - $data['longitude'] = substr($line,41,9); |
|
548 | - $data['speed'] = round(substr($line,51,5)); |
|
546 | + $data['latitude'] = substr($line, 29, 9); |
|
547 | + $data['longitude'] = substr($line, 41, 9); |
|
548 | + $data['speed'] = round(substr($line, 51, 5)); |
|
549 | 549 | //$data['course'] = substr($line,57,5); |
550 | - $data['heading'] = round(substr($line,63,3)); |
|
550 | + $data['heading'] = round(substr($line, 63, 3)); |
|
551 | 551 | //$data['draft'] = substr($line,67,4); |
552 | 552 | //$data['length'] = substr($line,72,3); |
553 | 553 | //$data['beam'] = substr($line,76,2); |
554 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
554 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
555 | 555 | //$data['callsign'] = trim(substr($line,100,7); |
556 | 556 | //$data['dest'] = substr($line,108,20); |
557 | 557 | //$data['etaDate'] = substr($line,129,5); |
@@ -569,8 +569,8 @@ discard block |
||
569 | 569 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
570 | 570 | //$buffer = $Common->getData($hosts[$id]); |
571 | 571 | $buffer = $Common->getData($value['host']); |
572 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
573 | - $buffer = explode('\n',$buffer); |
|
572 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
573 | + $buffer = explode('\n', $buffer); |
|
574 | 574 | $reset = 0; |
575 | 575 | foreach ($buffer as $line) { |
576 | 576 | if ($line != '') { |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
582 | 582 | $data['pilot_id'] = $line[1]; |
583 | 583 | $data['pilot_name'] = $line[2]; |
584 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
584 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
585 | 585 | $data['ident'] = $line[0]; // ident |
586 | 586 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
587 | 587 | $data['speed'] = $line[8]; // speed |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
598 | 598 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
599 | 599 | $data['departure_airport_icao'] = $line[11]; |
600 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
600 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
601 | 601 | $data['arrival_airport_icao'] = $line[13]; |
602 | 602 | $data['frequency'] = $line[4]; |
603 | 603 | $data['type'] = $line[18]; |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | $data['id_source'] = $id_source; |
607 | 607 | //$data['arrival_airport_time'] = ; |
608 | 608 | if ($line[9] != '') { |
609 | - $aircraft_data = explode('/',$line[9]); |
|
609 | + $aircraft_data = explode('/', $line[9]); |
|
610 | 610 | if (isset($aircraft_data[1])) { |
611 | 611 | $data['aircraft_icao'] = $aircraft_data[1]; |
612 | 612 | } |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | if ($line[3] == 'PILOT') $SI->add($data); |
621 | 621 | elseif ($line[3] == 'ATC') { |
622 | 622 | //print_r($data); |
623 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
624 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
625 | - $typec = substr($data['ident'],-3); |
|
623 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
624 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
625 | + $typec = substr($data['ident'], -3); |
|
626 | 626 | if ($typec == 'APP') $data['type'] = 'Approach'; |
627 | 627 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
628 | 628 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
634 | 634 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
635 | 635 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
636 | - 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']); |
|
636 | + 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']); |
|
637 | 637 | } |
638 | 638 | unset($data); |
639 | 639 | } |
@@ -644,9 +644,9 @@ discard block |
||
644 | 644 | $last_exec[$id]['last'] = time(); |
645 | 645 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
646 | 646 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
647 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
647 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
648 | 648 | if ($buffer != '') { |
649 | - $all_data = json_decode($buffer,true); |
|
649 | + $all_data = json_decode($buffer, true); |
|
650 | 650 | if (isset($all_data['acList'])) { |
651 | 651 | $reset = 0; |
652 | 652 | foreach ($all_data['acList'] as $line) { |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
703 | 703 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
704 | 704 | $buffer = $Common->getData($value['host']); |
705 | - $all_data = json_decode($buffer,true); |
|
705 | + $all_data = json_decode($buffer, true); |
|
706 | 706 | if (isset($all_data['planes'])) { |
707 | 707 | $reset = 0; |
708 | 708 | foreach ($all_data['planes'] as $key => $line) { |
@@ -719,12 +719,12 @@ discard block |
||
719 | 719 | $data['emergency'] = ''; // emergency |
720 | 720 | $data['registration'] = $line[2]; |
721 | 721 | $data['aircraft_icao'] = $line[0]; |
722 | - $deparr = explode('-',$line[1]); |
|
722 | + $deparr = explode('-', $line[1]); |
|
723 | 723 | if (count($deparr) == 2) { |
724 | 724 | $data['departure_airport_icao'] = $deparr[0]; |
725 | 725 | $data['arrival_airport_icao'] = $deparr[1]; |
726 | 726 | } |
727 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
727 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
728 | 728 | $data['format_source'] = 'planeupdatefaa'; |
729 | 729 | $data['id_source'] = $id_source; |
730 | 730 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | $last_exec[$id]['last'] = time(); |
737 | 737 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
738 | 738 | $buffer = $Common->getData($value['host']); |
739 | - $all_data = json_decode($buffer,true); |
|
739 | + $all_data = json_decode($buffer, true); |
|
740 | 740 | if (isset($all_data['states'])) { |
741 | 741 | $reset = 0; |
742 | 742 | foreach ($all_data['states'] as $key => $line) { |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | //$data['emergency'] = ''; // emergency |
754 | 754 | //$data['registration'] = $line[2]; |
755 | 755 | //$data['aircraft_icao'] = $line[0]; |
756 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
756 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
757 | 757 | $data['format_source'] = 'opensky'; |
758 | 758 | $data['id_source'] = $id_source; |
759 | 759 | $SI->add($data); |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
767 | 767 | //$buffer = $Common->getData($hosts[$id]); |
768 | 768 | $buffer = $Common->getData($value['host']); |
769 | - $all_data = json_decode($buffer,true); |
|
769 | + $all_data = json_decode($buffer, true); |
|
770 | 770 | if (!empty($all_data)) $reset = 0; |
771 | 771 | foreach ($all_data as $key => $line) { |
772 | 772 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -798,11 +798,11 @@ discard block |
||
798 | 798 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
799 | 799 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
800 | 800 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
801 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
801 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
802 | 802 | //echo $buffer; |
803 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
804 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
805 | - $all_data = json_decode($buffer,true); |
|
803 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
804 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
805 | + $all_data = json_decode($buffer, true); |
|
806 | 806 | if (json_last_error() != JSON_ERROR_NONE) { |
807 | 807 | die(json_last_error_msg()); |
808 | 808 | } |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | //$data['departure_airport_iata'] = $line[11]; |
826 | 826 | //$data['arrival_airport_iata'] = $line[12]; |
827 | 827 | //$data['emergency'] = ''; // emergency |
828 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
828 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
829 | 829 | $data['format_source'] = 'radarvirtueljson'; |
830 | 830 | $data['id_source'] = $id_source; |
831 | 831 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -840,14 +840,14 @@ discard block |
||
840 | 840 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
841 | 841 | //$buffer = $Common->getData($hosts[$id]); |
842 | 842 | $buffer = $Common->getData($value['host'].'?'.time()); |
843 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
843 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
844 | 844 | |
845 | 845 | if (isset($all_data['pireps'])) { |
846 | 846 | $reset = 0; |
847 | 847 | foreach ($all_data['pireps'] as $line) { |
848 | 848 | $data = array(); |
849 | 849 | $data['id'] = $line['id']; |
850 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
850 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
851 | 851 | $data['ident'] = $line['callsign']; // ident |
852 | 852 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
853 | 853 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -876,9 +876,9 @@ discard block |
||
876 | 876 | $SI->add($data); |
877 | 877 | // print_r($data); |
878 | 878 | } elseif ($line['icon'] == 'ct') { |
879 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
880 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
881 | - $typec = substr($data['ident'],-3); |
|
879 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
880 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
881 | + $typec = substr($data['ident'], -3); |
|
882 | 882 | $data['type'] = ''; |
883 | 883 | if ($typec == 'APP') $data['type'] = 'Approach'; |
884 | 884 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
890 | 890 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
891 | 891 | else $data['type'] = 'Observer'; |
892 | - 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']); |
|
892 | + 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']); |
|
893 | 893 | } |
894 | 894 | unset($data); |
895 | 895 | } |
@@ -901,14 +901,14 @@ discard block |
||
901 | 901 | //$buffer = $Common->getData($hosts[$id]); |
902 | 902 | if ($globalDebug) echo 'Get Data...'."\n"; |
903 | 903 | $buffer = $Common->getData($value['host']); |
904 | - $all_data = json_decode($buffer,true); |
|
904 | + $all_data = json_decode($buffer, true); |
|
905 | 905 | if ($buffer != '' && is_array($all_data)) { |
906 | 906 | $reset = 0; |
907 | 907 | foreach ($all_data as $line) { |
908 | 908 | $data = array(); |
909 | 909 | //$data['id'] = $line['id']; // id not usable |
910 | 910 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
911 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
911 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
912 | 912 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
913 | 913 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
914 | 914 | $data['ident'] = $line['flightnum']; // ident |
@@ -931,12 +931,12 @@ discard block |
||
931 | 931 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
932 | 932 | if (isset($line['aircraftname'])) { |
933 | 933 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
934 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
935 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
934 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
935 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
936 | 936 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
937 | 937 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
938 | 938 | else { |
939 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
939 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
940 | 940 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
941 | 941 | else $data['aircraft_icao'] = $line['aircraftname']; |
942 | 942 | } |
@@ -958,14 +958,14 @@ discard block |
||
958 | 958 | //$buffer = $Common->getData($hosts[$id]); |
959 | 959 | if ($globalDebug) echo 'Get Data...'."\n"; |
960 | 960 | $buffer = $Common->getData($value['host']); |
961 | - $all_data = json_decode($buffer,true); |
|
961 | + $all_data = json_decode($buffer, true); |
|
962 | 962 | if ($buffer != '' && is_array($all_data)) { |
963 | 963 | $reset = 0; |
964 | 964 | foreach ($all_data as $line) { |
965 | 965 | $data = array(); |
966 | 966 | //$data['id'] = $line['id']; // id not usable |
967 | 967 | $data['id'] = trim($line['flight_id']); |
968 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
968 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
969 | 969 | $data['pilot_name'] = $line['pilot_name']; |
970 | 970 | $data['pilot_id'] = $line['pilot_id']; |
971 | 971 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1016,9 +1016,9 @@ discard block |
||
1016 | 1016 | //$value = $formats[$nb]; |
1017 | 1017 | $format = $globalSources[$nb]['format']; |
1018 | 1018 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') { |
1019 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
1019 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
1020 | 1020 | } else { |
1021 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1021 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1022 | 1022 | } |
1023 | 1023 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1024 | 1024 | //echo $buffer."\n"; |
@@ -1027,8 +1027,8 @@ discard block |
||
1027 | 1027 | $error = false; |
1028 | 1028 | //$SI::del(); |
1029 | 1029 | if ($format == 'vrstcp') { |
1030 | - $buffer = explode('},{',$buffer); |
|
1031 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1030 | + $buffer = explode('},{', $buffer); |
|
1031 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1032 | 1032 | // SBS format is CSV format |
1033 | 1033 | if ($buffer !== FALSE && $buffer != '') { |
1034 | 1034 | $tt[$format] = 0; |
@@ -1060,10 +1060,10 @@ discard block |
||
1060 | 1060 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1061 | 1061 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1062 | 1062 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1063 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1063 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1064 | 1064 | |
1065 | 1065 | if (isset($ais_data['timestamp'])) { |
1066 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1066 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1067 | 1067 | } else { |
1068 | 1068 | $data['datetime'] = date('Y-m-d H:i:s'); |
1069 | 1069 | } |
@@ -1074,10 +1074,10 @@ discard block |
||
1074 | 1074 | } elseif ($format == 'flightgearsp') { |
1075 | 1075 | //echo $buffer."\n"; |
1076 | 1076 | if (strlen($buffer) > 5) { |
1077 | - $line = explode(',',$buffer); |
|
1077 | + $line = explode(',', $buffer); |
|
1078 | 1078 | $data = array(); |
1079 | 1079 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1080 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1080 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1081 | 1081 | $data['ident'] = $line[6]; |
1082 | 1082 | $data['aircraft_name'] = $line[7]; |
1083 | 1083 | $data['longitude'] = $line[1]; |
@@ -1088,21 +1088,21 @@ discard block |
||
1088 | 1088 | $data['datetime'] = date('Y-m-d H:i:s'); |
1089 | 1089 | $data['format_source'] = 'flightgearsp'; |
1090 | 1090 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1091 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1091 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1092 | 1092 | } |
1093 | 1093 | } elseif ($format == 'acars') { |
1094 | 1094 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1095 | 1095 | $ACARS->add(trim($buffer)); |
1096 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1096 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1097 | 1097 | $ACARS->deleteLiveAcarsData(); |
1098 | 1098 | } elseif ($format == 'flightgearmp') { |
1099 | - if (substr($buffer,0,1) != '#') { |
|
1099 | + if (substr($buffer, 0, 1) != '#') { |
|
1100 | 1100 | $data = array(); |
1101 | 1101 | //echo $buffer."\n"; |
1102 | - $line = explode(' ',$buffer); |
|
1102 | + $line = explode(' ', $buffer); |
|
1103 | 1103 | if (count($line) == 11) { |
1104 | - $userserver = explode('@',$line[0]); |
|
1105 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1104 | + $userserver = explode('@', $line[0]); |
|
1105 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1106 | 1106 | $data['ident'] = $userserver[0]; |
1107 | 1107 | $data['registration'] = $userserver[0]; |
1108 | 1108 | $data['latitude'] = $line[4]; |
@@ -1110,8 +1110,8 @@ discard block |
||
1110 | 1110 | $data['altitude'] = $line[6]; |
1111 | 1111 | $data['datetime'] = date('Y-m-d H:i:s'); |
1112 | 1112 | $aircraft_type = $line[10]; |
1113 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1114 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1113 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1114 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1115 | 1115 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1116 | 1116 | } |
1117 | 1117 | } |
@@ -1119,8 +1119,8 @@ discard block |
||
1119 | 1119 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1120 | 1120 | die; |
1121 | 1121 | } elseif ($format == 'vrstcp') { |
1122 | - foreach($buffer as $all_data) { |
|
1123 | - $line = json_decode('{'.$all_data.'}',true); |
|
1122 | + foreach ($buffer as $all_data) { |
|
1123 | + $line = json_decode('{'.$all_data.'}', true); |
|
1124 | 1124 | $data = array(); |
1125 | 1125 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1126 | 1126 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1145,16 +1145,16 @@ discard block |
||
1145 | 1145 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1146 | 1146 | unset($data); |
1147 | 1147 | } |
1148 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1148 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1149 | 1149 | $line = explode("\t", $buffer); |
1150 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1150 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1151 | 1151 | $key = $line[$k]; |
1152 | - $lined[$key] = $line[$k+1]; |
|
1152 | + $lined[$key] = $line[$k + 1]; |
|
1153 | 1153 | } |
1154 | 1154 | if (count($lined) > 3) { |
1155 | 1155 | $data['hex'] = $lined['hexid']; |
1156 | 1156 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1157 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1157 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1158 | 1158 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1159 | 1159 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1160 | 1160 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1172,22 +1172,22 @@ discard block |
||
1172 | 1172 | } else $error = true; |
1173 | 1173 | } elseif ($format == 'aprs' && $use_aprs) { |
1174 | 1174 | if ($aprs_connect == 0) { |
1175 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1175 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1176 | 1176 | $aprs_connect = 1; |
1177 | 1177 | } |
1178 | 1178 | |
1179 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1179 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1180 | 1180 | $aprs_last_tx = time(); |
1181 | 1181 | $data_aprs = "# Keep alive"; |
1182 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1182 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1186 | 1186 | //echo 'APRS data : '.$buffer."\n"; |
1187 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1188 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1187 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1188 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1189 | 1189 | //echo $buffer."\n"; |
1190 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1190 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1191 | 1191 | $line = $APRS->parse($buffer); |
1192 | 1192 | //print_r($line); |
1193 | 1193 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | $data = array(); |
1197 | 1197 | //print_r($line); |
1198 | 1198 | if (isset($line['address'])) $data['hex'] = $line['address']; |
1199 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1199 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1200 | 1200 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1201 | 1201 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1202 | 1202 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | $currentdate = date('Y-m-d H:i:s'); |
1223 | 1223 | $aprsdate = strtotime($data['datetime']); |
1224 | 1224 | // Accept data if time <= system time + 20s |
1225 | - 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'])))) { |
|
1225 | + 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'])))) { |
|
1226 | 1226 | $send = $SI->add($data); |
1227 | 1227 | } elseif (isset($line['stealth'])) { |
1228 | 1228 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
@@ -1319,7 +1319,7 @@ discard block |
||
1319 | 1319 | connect_all($sourceee); |
1320 | 1320 | $sourceee = array(); |
1321 | 1321 | //connect_all($globalSources); |
1322 | - $tt[$format]=0; |
|
1322 | + $tt[$format] = 0; |
|
1323 | 1323 | break; |
1324 | 1324 | } |
1325 | 1325 | } |
@@ -1328,14 +1328,14 @@ discard block |
||
1328 | 1328 | } else { |
1329 | 1329 | $error = socket_strerror(socket_last_error()); |
1330 | 1330 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1331 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1331 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1332 | 1332 | if (isset($globalDebug)) echo "Restarting...\n"; |
1333 | 1333 | // Restart the script if possible |
1334 | 1334 | if (is_array($sockets)) { |
1335 | 1335 | if ($globalDebug) echo "Shutdown all sockets..."; |
1336 | 1336 | |
1337 | 1337 | foreach ($sockets as $sock) { |
1338 | - @socket_shutdown($sock,2); |
|
1338 | + @socket_shutdown($sock, 2); |
|
1339 | 1339 | @socket_close($sock); |
1340 | 1340 | } |
1341 | 1341 |