@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | die; |
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
53 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
|
57 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine')); |
|
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | 61 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
63 | 63 | else $globalSources[] = array('host' => $options['s']); |
64 | 64 | } elseif (isset($options['source'])) { |
65 | 65 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
67 | 67 | else $globalSources[] = array('host' => $options['source']); |
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | else $id_source = 1; |
105 | 105 | if (isset($globalServer) && $globalServer) { |
106 | 106 | if ($globalDebug) echo "Using Server Mode\n"; |
107 | - $SI=new SpotterServer(); |
|
107 | + $SI = new SpotterServer(); |
|
108 | 108 | /* |
109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 110 | $SI = new adsb2aprs(); |
111 | 111 | $SI->connect(); |
112 | 112 | */ |
113 | -} else $SI=new SpotterImport($Connection->db); |
|
113 | +} else $SI = new SpotterImport($Connection->db); |
|
114 | 114 | |
115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
116 | 116 | if (isset($globalMarine) && $globalMarine) { |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | $MI = new MarineImport($Connection->db); |
125 | 125 | } |
126 | 126 | //$APRS=new APRS($Connection->db); |
127 | -$SBS=new SBS(); |
|
127 | +$SBS = new SBS(); |
|
128 | 128 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
129 | - $ACARS=new ACARS($Connection->db,true); |
|
130 | - $Source=new Source($Connection->db); |
|
129 | + $ACARS = new ACARS($Connection->db, true); |
|
130 | + $Source = new Source($Connection->db); |
|
131 | 131 | } |
132 | -$Common=new Common(); |
|
132 | +$Common = new Common(); |
|
133 | 133 | date_default_timezone_set('UTC'); |
134 | 134 | //$servertz = system('date +%Z'); |
135 | 135 | // signal handler - playing nice with sockets and dump1090 |
136 | 136 | if (function_exists('pcntl_fork')) { |
137 | - pcntl_signal(SIGINT, function() { |
|
137 | + pcntl_signal(SIGINT, function() { |
|
138 | 138 | global $sockets; |
139 | 139 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
140 | 140 | die("Bye!\n"); |
@@ -150,30 +150,30 @@ discard block |
||
150 | 150 | |
151 | 151 | function connect_all($hosts) { |
152 | 152 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
153 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
154 | 154 | $reset++; |
155 | 155 | if ($globalDebug) echo 'Connect to all...'."\n"; |
156 | 156 | foreach ($hosts as $id => $value) { |
157 | 157 | $host = $value['host']; |
158 | 158 | $globalSources[$id]['last_exec'] = 0; |
159 | 159 | // Here we check type of source(s) |
160 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
160 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
161 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
162 | 162 | //$formats[$id] = 'deltadbtxt'; |
163 | 163 | $globalSources[$id]['format'] = 'deltadbtxt'; |
164 | 164 | //$last_exec['deltadbtxt'] = 0; |
165 | 165 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
166 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
167 | 167 | //$formats[$id] = 'vatsimtxt'; |
168 | 168 | $globalSources[$id]['format'] = 'vatsimtxt'; |
169 | 169 | //$last_exec['vatsimtxt'] = 0; |
170 | 170 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
171 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
172 | 172 | //$formats[$id] = 'aircraftlistjson'; |
173 | 173 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
174 | 174 | //$last_exec['aircraftlistjson'] = 0; |
175 | 175 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
176 | - } else if (preg_match('/opensky/i',$host)) { |
|
176 | + } else if (preg_match('/opensky/i', $host)) { |
|
177 | 177 | //$formats[$id] = 'aircraftlistjson'; |
178 | 178 | $globalSources[$id]['format'] = 'opensky'; |
179 | 179 | //$last_exec['aircraftlistjson'] = 0; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | exit(0); |
191 | 191 | } |
192 | 192 | */ |
193 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
193 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
194 | 194 | //$formats[$id] = 'planeupdatefaa'; |
195 | 195 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
196 | 196 | //$last_exec['planeupdatefaa'] = 0; |
@@ -199,37 +199,37 @@ discard block |
||
199 | 199 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
200 | 200 | exit(0); |
201 | 201 | } |
202 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
202 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
203 | 203 | //$formats[$id] = 'phpvmacars'; |
204 | 204 | $globalSources[$id]['format'] = 'phpvmacars'; |
205 | 205 | //$last_exec['phpvmacars'] = 0; |
206 | 206 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
207 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
207 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) { |
|
208 | 208 | //$formats[$id] = 'phpvmacars'; |
209 | 209 | $globalSources[$id]['format'] = 'vaos'; |
210 | 210 | //$last_exec['phpvmacars'] = 0; |
211 | 211 | if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
212 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
212 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
213 | 213 | //$formats[$id] = 'phpvmacars'; |
214 | 214 | $globalSources[$id]['format'] = 'vam'; |
215 | 215 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
216 | - } else if (preg_match('/whazzup/i',$host)) { |
|
216 | + } else if (preg_match('/whazzup/i', $host)) { |
|
217 | 217 | //$formats[$id] = 'whazzup'; |
218 | 218 | $globalSources[$id]['format'] = 'whazzup'; |
219 | 219 | //$last_exec['whazzup'] = 0; |
220 | 220 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
221 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
221 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
222 | 222 | $globalSources[$id]['format'] = 'blitzortung'; |
223 | 223 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
224 | - } else if (preg_match('/airwhere/i',$host)) { |
|
224 | + } else if (preg_match('/airwhere/i', $host)) { |
|
225 | 225 | $globalSources[$id]['format'] = 'airwhere'; |
226 | 226 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
227 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
227 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
228 | 228 | //$formats[$id] = 'pirepsjson'; |
229 | 229 | $globalSources[$id]['format'] = 'pirepsjson'; |
230 | 230 | //$last_exec['pirepsjson'] = 0; |
231 | 231 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
232 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
232 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
233 | 233 | //$formats[$id] = 'fr24json'; |
234 | 234 | $globalSources[$id]['format'] = 'fr24json'; |
235 | 235 | //$last_exec['fr24json'] = 0; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
239 | 239 | exit(0); |
240 | 240 | } |
241 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
241 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
242 | 242 | //$formats[$id] = 'fr24json'; |
243 | 243 | $globalSources[$id]['format'] = 'myshiptracking'; |
244 | 244 | //$last_exec['fr24json'] = 0; |
@@ -248,21 +248,21 @@ discard block |
||
248 | 248 | exit(0); |
249 | 249 | } |
250 | 250 | //} else if (preg_match('/10001/',$host)) { |
251 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
251 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
252 | 252 | //$formats[$id] = 'tsv'; |
253 | 253 | $globalSources[$id]['format'] = 'tsv'; |
254 | 254 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
255 | 255 | } |
256 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
256 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
257 | 257 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
258 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
258 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
259 | 259 | if ($idf !== false) { |
260 | 260 | $httpfeeds[$id] = $idf; |
261 | 261 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
262 | 262 | } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
263 | 263 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
264 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
265 | - $hostport = explode(':',$host); |
|
264 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
265 | + $hostport = explode(':', $host); |
|
266 | 266 | if (isset($hostport[1])) { |
267 | 267 | $port = $hostport[1]; |
268 | 268 | $hostn = $hostport[0]; |
@@ -272,19 +272,19 @@ discard block |
||
272 | 272 | } |
273 | 273 | $Common = new Common(); |
274 | 274 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
275 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
275 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
276 | 276 | } else { |
277 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
277 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
278 | 278 | } |
279 | 279 | if ($s) { |
280 | 280 | $sockets[$id] = $s; |
281 | 281 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
282 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
282 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
283 | 283 | //$formats[$id] = 'aprs'; |
284 | 284 | $globalSources[$id]['format'] = 'aprs'; |
285 | 285 | //$aprs_connect = 0; |
286 | 286 | //$use_aprs = true; |
287 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
287 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
288 | 288 | $globalSources[$id]['format'] = 'vrstcp'; |
289 | 289 | } elseif ($port == '10001') { |
290 | 290 | //$formats[$id] = 'tsv'; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
324 | 324 | else $timeout = 20; |
325 | 325 | $errno = ''; |
326 | -$errstr=''; |
|
326 | +$errstr = ''; |
|
327 | 327 | |
328 | 328 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
329 | 329 | /* Initiate connections to all the hosts simultaneously */ |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | //connect_all($globalSources); |
332 | 332 | |
333 | 333 | if (isset($globalProxy) && $globalProxy) { |
334 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
334 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
335 | 335 | } else { |
336 | 336 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
337 | 337 | } |
@@ -361,16 +361,16 @@ discard block |
||
361 | 361 | |
362 | 362 | if ($use_aprs) { |
363 | 363 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
364 | - $APRS=new APRS(); |
|
364 | + $APRS = new APRS(); |
|
365 | 365 | $aprs_connect = 0; |
366 | 366 | $aprs_keep = 120; |
367 | 367 | $aprs_last_tx = time(); |
368 | 368 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
369 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
369 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
370 | 370 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
371 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
371 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
372 | 372 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
373 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
373 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
374 | 374 | if ($aprs_full) $aprs_filter = ''; |
375 | 375 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
376 | 376 | else $aprs_pass = '-1'; |
@@ -384,12 +384,12 @@ discard block |
||
384 | 384 | sleep(1); |
385 | 385 | if ($globalDebug) echo "SCAN MODE \n\n"; |
386 | 386 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
387 | -$endtime = time()+$globalCronEnd; |
|
387 | +$endtime = time() + $globalCronEnd; |
|
388 | 388 | $i = 1; |
389 | 389 | $tt = array(); |
390 | 390 | // Delete all ATC |
391 | 391 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
392 | - $ATC=new ATC($Connection->db); |
|
392 | + $ATC = new ATC($Connection->db); |
|
393 | 393 | } |
394 | 394 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
395 | 395 | $ATC->deleteAll(); |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | |
398 | 398 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
399 | 399 | while ($i > 0) { |
400 | - if (!$globalDaemon) $i = $endtime-time(); |
|
400 | + if (!$globalDaemon) $i = $endtime - time(); |
|
401 | 401 | // Delete old ATC |
402 | 402 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
403 | 403 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | } |
412 | 412 | if ($max != $globalMinFetch) { |
413 | 413 | if ($globalDebug) echo 'Sleeping...'."\n"; |
414 | - sleep($globalMinFetch-$max+2); |
|
414 | + sleep($globalMinFetch - $max + 2); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | //$buffer = $Common->getData($hosts[$id]); |
431 | 431 | $buffer = $Common->getData($value['host']); |
432 | 432 | if ($buffer != '') $reset = 0; |
433 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | - $buffer = explode('\n',$buffer); |
|
433 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
434 | + $buffer = explode('\n', $buffer); |
|
435 | 435 | foreach ($buffer as $line) { |
436 | 436 | if ($line != '' && count($line) > 7) { |
437 | 437 | $line = explode(',', $line); |
@@ -464,11 +464,11 @@ discard block |
||
464 | 464 | ) |
465 | 465 | ) { |
466 | 466 | date_default_timezone_set('CET'); |
467 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
467 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
468 | 468 | date_default_timezone_set('UTC'); |
469 | 469 | if ($buffer != '') $reset = 0; |
470 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
471 | - $buffer = explode('\n',$buffer); |
|
470 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
471 | + $buffer = explode('\n', $buffer); |
|
472 | 472 | foreach ($buffer as $line) { |
473 | 473 | if ($line != '') { |
474 | 474 | //echo "'".$line."'\n"; |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
487 | 487 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
488 | 488 | if (isset($ais_data['timestamp'])) { |
489 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
489 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
490 | 490 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
491 | 491 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
492 | 492 | $add = true; |
@@ -509,15 +509,15 @@ discard block |
||
509 | 509 | $w = $e = null; |
510 | 510 | |
511 | 511 | if (isset($arr[$id])) { |
512 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
512 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
513 | 513 | if ($nn > 0) { |
514 | 514 | foreach ($httpfeeds as $feed) { |
515 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
515 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
516 | 516 | if ($buffer === FALSE) { |
517 | 517 | connect_all($globalSources); |
518 | 518 | } |
519 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
520 | - $buffer = explode('\n',$buffer); |
|
519 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
520 | + $buffer = explode('\n', $buffer); |
|
521 | 521 | foreach ($buffer as $line) { |
522 | 522 | if ($line != '') { |
523 | 523 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
536 | 536 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
537 | 537 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
538 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
538 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
539 | 539 | if (isset($ais_data['timestamp'])) { |
540 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
540 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
541 | 541 | } else { |
542 | 542 | $data['datetime'] = date('Y-m-d H:i:s'); |
543 | 543 | } |
@@ -569,10 +569,10 @@ discard block |
||
569 | 569 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
570 | 570 | ) |
571 | 571 | ) { |
572 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
572 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
573 | 573 | if ($buffer != '') { |
574 | 574 | //echo $buffer; |
575 | - $all_data = json_decode($buffer,true); |
|
575 | + $all_data = json_decode($buffer, true); |
|
576 | 576 | //print_r($all_data); |
577 | 577 | if (isset($all_data[0]['DATA'])) { |
578 | 578 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | $data['ident'] = $line['NAME']; |
582 | 582 | $data['mmsi'] = $line['MMSI']; |
583 | 583 | if (strlen($data['mmsi']) > 9) { |
584 | - $data['mmsi'] = substr($data['mmsi'],-9); |
|
584 | + $data['mmsi'] = substr($data['mmsi'], -9); |
|
585 | 585 | } |
586 | 586 | $data['speed'] = $line['SOG']; |
587 | 587 | $data['heading'] = $line['COG']; |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
591 | 591 | $data['imo'] = $line['IMO']; |
592 | 592 | //$data['arrival_code'] = $ais_data['destination']; |
593 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
593 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
594 | 594 | $data['format_source'] = 'myshiptracking'; |
595 | 595 | $data['id_source'] = $id_source; |
596 | 596 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -607,9 +607,9 @@ discard block |
||
607 | 607 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
608 | 608 | ) |
609 | 609 | ) { |
610 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
610 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
611 | 611 | if ($buffer != '') { |
612 | - $all_data = json_decode($buffer,true); |
|
612 | + $all_data = json_decode($buffer, true); |
|
613 | 613 | if (isset($all_data[0]['mmsi'])) { |
614 | 614 | foreach ($all_data as $line) { |
615 | 615 | if ($line != '') { |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | ) { |
644 | 644 | $buffer = $Common->getData($value['host']); |
645 | 645 | if ($buffer != '') { |
646 | - $all_data = json_decode($buffer,true); |
|
646 | + $all_data = json_decode($buffer, true); |
|
647 | 647 | if (isset($all_data['features'][0]['id'])) { |
648 | 648 | foreach ($all_data['features'] as $line) { |
649 | 649 | $data = array(); |
@@ -676,27 +676,27 @@ discard block |
||
676 | 676 | ) |
677 | 677 | ) { |
678 | 678 | echo 'download...'; |
679 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
679 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
680 | 680 | echo 'done !'."\n"; |
681 | 681 | if ($buffer != '') $reset = 0; |
682 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
683 | - $buffer = explode('\n',$buffer); |
|
682 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
683 | + $buffer = explode('\n', $buffer); |
|
684 | 684 | foreach ($buffer as $line) { |
685 | 685 | if ($line != '') { |
686 | 686 | $data = array(); |
687 | - $data['mmsi'] = (int)substr($line,0,9); |
|
688 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
687 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
688 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
689 | 689 | //$data['status'] = substr($line,21,2); |
690 | 690 | //$data['type'] = substr($line,24,3); |
691 | - $data['latitude'] = substr($line,29,9); |
|
692 | - $data['longitude'] = substr($line,41,9); |
|
693 | - $data['speed'] = round(substr($line,51,5)); |
|
691 | + $data['latitude'] = substr($line, 29, 9); |
|
692 | + $data['longitude'] = substr($line, 41, 9); |
|
693 | + $data['speed'] = round(substr($line, 51, 5)); |
|
694 | 694 | //$data['course'] = substr($line,57,5); |
695 | - $data['heading'] = round(substr($line,63,3)); |
|
695 | + $data['heading'] = round(substr($line, 63, 3)); |
|
696 | 696 | //$data['draft'] = substr($line,67,4); |
697 | 697 | //$data['length'] = substr($line,72,3); |
698 | 698 | //$data['beam'] = substr($line,76,2); |
699 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
699 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
700 | 700 | //$data['callsign'] = trim(substr($line,100,7); |
701 | 701 | //$data['dest'] = substr($line,108,20); |
702 | 702 | //$data['etaDate'] = substr($line,129,5); |
@@ -729,8 +729,8 @@ discard block |
||
729 | 729 | ) { |
730 | 730 | //$buffer = $Common->getData($hosts[$id]); |
731 | 731 | $buffer = $Common->getData($value['host']); |
732 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
733 | - $buffer = explode('\n',$buffer); |
|
732 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
733 | + $buffer = explode('\n', $buffer); |
|
734 | 734 | $reset = 0; |
735 | 735 | foreach ($buffer as $line) { |
736 | 736 | if ($line != '') { |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
742 | 742 | $data['pilot_id'] = $line[1]; |
743 | 743 | $data['pilot_name'] = $line[2]; |
744 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
744 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
745 | 745 | $data['ident'] = $line[0]; // ident |
746 | 746 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
747 | 747 | $data['speed'] = $line[8]; // speed |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
758 | 758 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
759 | 759 | $data['departure_airport_icao'] = $line[11]; |
760 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
760 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
761 | 761 | $data['arrival_airport_icao'] = $line[13]; |
762 | 762 | $data['frequency'] = $line[4]; |
763 | 763 | $data['type'] = $line[18]; |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | $data['id_source'] = $id_source; |
767 | 767 | //$data['arrival_airport_time'] = ; |
768 | 768 | if ($line[9] != '') { |
769 | - $aircraft_data = explode('/',$line[9]); |
|
769 | + $aircraft_data = explode('/', $line[9]); |
|
770 | 770 | if (isset($aircraft_data[1])) { |
771 | 771 | $data['aircraft_icao'] = $aircraft_data[1]; |
772 | 772 | } |
@@ -781,9 +781,9 @@ discard block |
||
781 | 781 | if ($line[3] == 'PILOT') $SI->add($data); |
782 | 782 | elseif ($line[3] == 'ATC') { |
783 | 783 | //print_r($data); |
784 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
785 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
786 | - $typec = substr($data['ident'],-3); |
|
784 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
785 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
786 | + $typec = substr($data['ident'], -3); |
|
787 | 787 | if ($typec == 'APP') $data['type'] = 'Approach'; |
788 | 788 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
789 | 789 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -795,8 +795,8 @@ discard block |
||
795 | 795 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
796 | 796 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
797 | 797 | if (isset($ATC)) { |
798 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
799 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
798 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
799 | + else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
800 | 800 | } |
801 | 801 | } |
802 | 802 | unset($data); |
@@ -812,24 +812,24 @@ discard block |
||
812 | 812 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
813 | 813 | ) |
814 | 814 | ) { |
815 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
815 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
816 | 816 | if ($buffer != '') { |
817 | 817 | $all_data = simplexml_load_string($buffer); |
818 | - foreach($all_data->children() as $childdata) { |
|
818 | + foreach ($all_data->children() as $childdata) { |
|
819 | 819 | $data = array(); |
820 | 820 | $line = $childdata; |
821 | 821 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
822 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
823 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
824 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
825 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
826 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
827 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
828 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
822 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
823 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
824 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
825 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
826 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
827 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
828 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
829 | 829 | $data['altitude_relative'] = 'AMSL'; |
830 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
830 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
831 | 831 | $data['aircraft_icao'] = 'PARAGLIDER'; |
832 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
832 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
833 | 833 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
834 | 834 | $data['format_source'] = $value['format']; |
835 | 835 | $SI->add($data); |
@@ -837,22 +837,22 @@ discard block |
||
837 | 837 | } |
838 | 838 | } |
839 | 839 | $Source->deleteOldLocationByType('gs'); |
840 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
840 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
841 | 841 | if ($buffer != '') { |
842 | 842 | $all_data = simplexml_load_string($buffer); |
843 | - foreach($all_data->children() as $childdata) { |
|
843 | + foreach ($all_data->children() as $childdata) { |
|
844 | 844 | $data = array(); |
845 | 845 | $line = $childdata; |
846 | - $data['id'] = (int)$line['gsID']; |
|
847 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
848 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
849 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
846 | + $data['id'] = (int) $line['gsID']; |
|
847 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
848 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
849 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
850 | 850 | $data['altitude_relative'] = 'AMSL'; |
851 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
851 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
852 | 852 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
853 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
853 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
854 | 854 | } else { |
855 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
855 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
856 | 856 | } |
857 | 857 | unset($data); |
858 | 858 | } |
@@ -870,9 +870,9 @@ discard block |
||
870 | 870 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
871 | 871 | ) |
872 | 872 | ) { |
873 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
873 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
874 | 874 | if ($buffer != '') { |
875 | - $all_data = json_decode($buffer,true); |
|
875 | + $all_data = json_decode($buffer, true); |
|
876 | 876 | if (isset($all_data['acList'])) { |
877 | 877 | $reset = 0; |
878 | 878 | foreach ($all_data['acList'] as $line) { |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
889 | 889 | $data['emergency'] = ''; // emergency |
890 | 890 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
891 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
891 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
892 | 892 | else $data['datetime'] = date('Y-m-d H:i:s'); |
893 | 893 | //$data['datetime'] = date('Y-m-d H:i:s'); |
894 | 894 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | $data['verticalrate'] = $line['vrt']; // verticale rate |
914 | 914 | $data['squawk'] = $line['squawk']; // squawk |
915 | 915 | $data['emergency'] = ''; // emergency |
916 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
916 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
917 | 917 | else $data['datetime'] = date('Y-m-d H:i:s'); |
918 | 918 | $data['format_source'] = 'aircraftlistjson'; |
919 | 919 | $data['id_source'] = $id_source; |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | ) |
935 | 935 | ) { |
936 | 936 | $buffer = $Common->getData($value['host']); |
937 | - $all_data = json_decode($buffer,true); |
|
937 | + $all_data = json_decode($buffer, true); |
|
938 | 938 | if (isset($all_data['planes'])) { |
939 | 939 | $reset = 0; |
940 | 940 | foreach ($all_data['planes'] as $key => $line) { |
@@ -951,12 +951,12 @@ discard block |
||
951 | 951 | $data['emergency'] = ''; // emergency |
952 | 952 | $data['registration'] = $line[2]; |
953 | 953 | $data['aircraft_icao'] = $line[0]; |
954 | - $deparr = explode('-',$line[1]); |
|
954 | + $deparr = explode('-', $line[1]); |
|
955 | 955 | if (count($deparr) == 2) { |
956 | 956 | $data['departure_airport_icao'] = $deparr[0]; |
957 | 957 | $data['arrival_airport_icao'] = $deparr[1]; |
958 | 958 | } |
959 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
959 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
960 | 960 | $data['format_source'] = 'planeupdatefaa'; |
961 | 961 | $data['id_source'] = $id_source; |
962 | 962 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | ) |
975 | 975 | ) { |
976 | 976 | $buffer = $Common->getData($value['host']); |
977 | - $all_data = json_decode($buffer,true); |
|
977 | + $all_data = json_decode($buffer, true); |
|
978 | 978 | if (isset($all_data['states'])) { |
979 | 979 | $reset = 0; |
980 | 980 | foreach ($all_data['states'] as $key => $line) { |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | //$data['emergency'] = ''; // emergency |
992 | 992 | //$data['registration'] = $line[2]; |
993 | 993 | //$data['aircraft_icao'] = $line[0]; |
994 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
994 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
995 | 995 | $data['format_source'] = 'opensky'; |
996 | 996 | $data['id_source'] = $id_source; |
997 | 997 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | ) { |
1011 | 1011 | //$buffer = $Common->getData($hosts[$id]); |
1012 | 1012 | $buffer = $Common->getData($value['host']); |
1013 | - $all_data = json_decode($buffer,true); |
|
1013 | + $all_data = json_decode($buffer, true); |
|
1014 | 1014 | if (!empty($all_data)) $reset = 0; |
1015 | 1015 | foreach ($all_data as $key => $line) { |
1016 | 1016 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1048,11 +1048,11 @@ discard block |
||
1048 | 1048 | ) |
1049 | 1049 | ) { |
1050 | 1050 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
1051 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1051 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
1052 | 1052 | //echo $buffer; |
1053 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1054 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1055 | - $all_data = json_decode($buffer,true); |
|
1053 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
1054 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
1055 | + $all_data = json_decode($buffer, true); |
|
1056 | 1056 | if (json_last_error() != JSON_ERROR_NONE) { |
1057 | 1057 | die(json_last_error_msg()); |
1058 | 1058 | } |
@@ -1075,7 +1075,7 @@ discard block |
||
1075 | 1075 | //$data['departure_airport_iata'] = $line[11]; |
1076 | 1076 | //$data['arrival_airport_iata'] = $line[12]; |
1077 | 1077 | //$data['emergency'] = ''; // emergency |
1078 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
1078 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
1079 | 1079 | $data['format_source'] = 'radarvirtueljson'; |
1080 | 1080 | $data['id_source'] = $id_source; |
1081 | 1081 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1096,14 +1096,14 @@ discard block |
||
1096 | 1096 | ) { |
1097 | 1097 | //$buffer = $Common->getData($hosts[$id]); |
1098 | 1098 | $buffer = $Common->getData($value['host'].'?'.time()); |
1099 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1099 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
1100 | 1100 | |
1101 | 1101 | if (isset($all_data['pireps'])) { |
1102 | 1102 | $reset = 0; |
1103 | 1103 | foreach ($all_data['pireps'] as $line) { |
1104 | 1104 | $data = array(); |
1105 | 1105 | $data['id'] = $line['id']; |
1106 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1106 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1107 | 1107 | $data['ident'] = $line['callsign']; // ident |
1108 | 1108 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
1109 | 1109 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1133,9 +1133,9 @@ discard block |
||
1133 | 1133 | $SI->add($data); |
1134 | 1134 | // print_r($data); |
1135 | 1135 | } elseif ($line['icon'] == 'ct') { |
1136 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1137 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1138 | - $typec = substr($data['ident'],-3); |
|
1136 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
1137 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1138 | + $typec = substr($data['ident'], -3); |
|
1139 | 1139 | $data['type'] = ''; |
1140 | 1140 | if ($typec == 'APP') $data['type'] = 'Approach'; |
1141 | 1141 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
1147 | 1147 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1148 | 1148 | else $data['type'] = 'Observer'; |
1149 | - 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']); |
|
1149 | + 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']); |
|
1150 | 1150 | } |
1151 | 1151 | unset($data); |
1152 | 1152 | } |
@@ -1163,14 +1163,14 @@ discard block |
||
1163 | 1163 | //$buffer = $Common->getData($hosts[$id]); |
1164 | 1164 | if ($globalDebug) echo 'Get Data...'."\n"; |
1165 | 1165 | $buffer = $Common->getData($value['host']); |
1166 | - $all_data = json_decode($buffer,true); |
|
1166 | + $all_data = json_decode($buffer, true); |
|
1167 | 1167 | if ($buffer != '' && is_array($all_data)) { |
1168 | 1168 | $reset = 0; |
1169 | 1169 | foreach ($all_data as $line) { |
1170 | 1170 | $data = array(); |
1171 | 1171 | //$data['id'] = $line['id']; // id not usable |
1172 | 1172 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1173 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1173 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1174 | 1174 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1175 | 1175 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1176 | 1176 | $data['ident'] = $line['flightnum']; // ident |
@@ -1185,7 +1185,7 @@ discard block |
||
1185 | 1185 | //$data['datetime'] = $line['lastupdate']; |
1186 | 1186 | //$data['last_update'] = $line['lastupdate']; |
1187 | 1187 | if (isset($value['timezone'])) { |
1188 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1188 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1189 | 1189 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1190 | 1190 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1191 | 1191 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1201,14 +1201,14 @@ discard block |
||
1201 | 1201 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1202 | 1202 | if (isset($line['aircraftname'])) { |
1203 | 1203 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1204 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1205 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1204 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1205 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1206 | 1206 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1207 | 1207 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1208 | 1208 | else { |
1209 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1210 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1211 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1209 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1210 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1211 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1212 | 1212 | } |
1213 | 1213 | } |
1214 | 1214 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1233,7 +1233,7 @@ discard block |
||
1233 | 1233 | //$buffer = $Common->getData($hosts[$id]); |
1234 | 1234 | if ($globalDebug) echo 'Get Data...'."\n"; |
1235 | 1235 | $buffer = $Common->getData($value['host']); |
1236 | - $all_data = json_decode($buffer,true); |
|
1236 | + $all_data = json_decode($buffer, true); |
|
1237 | 1237 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
1238 | 1238 | $reset = 0; |
1239 | 1239 | foreach ($all_data['ACARSData'] as $line) { |
@@ -1244,7 +1244,7 @@ discard block |
||
1244 | 1244 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1245 | 1245 | if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
1246 | 1246 | if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
1247 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1247 | + $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident |
|
1248 | 1248 | if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
1249 | 1249 | $data['altitude'] = $line['altitude']; // altitude |
1250 | 1250 | $data['speed'] = $line['groundspeed']; // speed |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | //$data['squawk'] = ''; // squawk |
1256 | 1256 | //$data['emergency'] = ''; // emergency |
1257 | 1257 | if (isset($value['timezone'])) { |
1258 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1258 | + $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); |
|
1259 | 1259 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1260 | 1260 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1261 | 1261 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1291,14 +1291,14 @@ discard block |
||
1291 | 1291 | //$buffer = $Common->getData($hosts[$id]); |
1292 | 1292 | if ($globalDebug) echo 'Get Data...'."\n"; |
1293 | 1293 | $buffer = $Common->getData($value['host']); |
1294 | - $all_data = json_decode($buffer,true); |
|
1294 | + $all_data = json_decode($buffer, true); |
|
1295 | 1295 | if ($buffer != '' && is_array($all_data)) { |
1296 | 1296 | $reset = 0; |
1297 | 1297 | foreach ($all_data as $line) { |
1298 | 1298 | $data = array(); |
1299 | 1299 | //$data['id'] = $line['id']; // id not usable |
1300 | 1300 | $data['id'] = trim($line['flight_id']); |
1301 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1301 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1302 | 1302 | $data['pilot_name'] = $line['pilot_name']; |
1303 | 1303 | $data['pilot_id'] = $line['pilot_id']; |
1304 | 1304 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1342,24 +1342,24 @@ discard block |
||
1342 | 1342 | //$buffer = $Common->getData($hosts[$id]); |
1343 | 1343 | if ($globalDebug) echo 'Get Data...'."\n"; |
1344 | 1344 | $buffer = $Common->getData($value['host']); |
1345 | - $all_data = json_decode($buffer,true); |
|
1345 | + $all_data = json_decode($buffer, true); |
|
1346 | 1346 | if ($buffer != '') { |
1347 | 1347 | $Source->deleteLocationBySource('blitzortung'); |
1348 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1349 | - $buffer = explode('\n',$buffer); |
|
1348 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1349 | + $buffer = explode('\n', $buffer); |
|
1350 | 1350 | foreach ($buffer as $buffer_line) { |
1351 | - $line = json_decode($buffer_line,true); |
|
1351 | + $line = json_decode($buffer_line, true); |
|
1352 | 1352 | if (isset($line['time'])) { |
1353 | 1353 | $data = array(); |
1354 | 1354 | $data['altitude'] = $line['alt']; // altitude |
1355 | 1355 | $data['latitude'] = $line['lat']; // lat |
1356 | 1356 | $data['longitude'] = $line['lon']; // long |
1357 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
1357 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1358 | 1358 | $data['id_source'] = $id_source; |
1359 | 1359 | $data['format_source'] = 'blitzortung'; |
1360 | 1360 | $SI->add($data); |
1361 | 1361 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1362 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
1362 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1363 | 1363 | unset($data); |
1364 | 1364 | } |
1365 | 1365 | } |
@@ -1384,11 +1384,11 @@ discard block |
||
1384 | 1384 | //$value = $formats[$nb]; |
1385 | 1385 | $format = $globalSources[$nb]['format']; |
1386 | 1386 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1387 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1387 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1388 | 1388 | } elseif ($format == 'vrstcp') { |
1389 | 1389 | $buffer = @socket_read($r, 6000); |
1390 | 1390 | } else { |
1391 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1391 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1392 | 1392 | } |
1393 | 1393 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1394 | 1394 | //echo $buffer."\n"; |
@@ -1398,8 +1398,8 @@ discard block |
||
1398 | 1398 | //$SI::del(); |
1399 | 1399 | if ($buffer !== FALSE) { |
1400 | 1400 | if ($format == 'vrstcp') { |
1401 | - $buffer = explode('},{',$buffer); |
|
1402 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1401 | + $buffer = explode('},{', $buffer); |
|
1402 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1403 | 1403 | } |
1404 | 1404 | // SBS format is CSV format |
1405 | 1405 | if ($buffer !== FALSE && $buffer !== '') { |
@@ -1434,13 +1434,13 @@ discard block |
||
1434 | 1434 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1435 | 1435 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1436 | 1436 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1437 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1437 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1438 | 1438 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1439 | 1439 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1440 | 1440 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1441 | 1441 | |
1442 | 1442 | if (isset($ais_data['timestamp'])) { |
1443 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1443 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1444 | 1444 | } else { |
1445 | 1445 | $data['datetime'] = date('Y-m-d H:i:s'); |
1446 | 1446 | } |
@@ -1451,10 +1451,10 @@ discard block |
||
1451 | 1451 | } elseif ($format == 'flightgearsp') { |
1452 | 1452 | //echo $buffer."\n"; |
1453 | 1453 | if (strlen($buffer) > 5) { |
1454 | - $line = explode(',',$buffer); |
|
1454 | + $line = explode(',', $buffer); |
|
1455 | 1455 | $data = array(); |
1456 | 1456 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1457 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1457 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1458 | 1458 | $data['ident'] = $line[6]; |
1459 | 1459 | $data['aircraft_name'] = $line[7]; |
1460 | 1460 | $data['longitude'] = $line[1]; |
@@ -1471,16 +1471,16 @@ discard block |
||
1471 | 1471 | } elseif ($format == 'acars') { |
1472 | 1472 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1473 | 1473 | $ACARS->add(trim($buffer)); |
1474 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1474 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1475 | 1475 | $ACARS->deleteLiveAcarsData(); |
1476 | 1476 | } elseif ($format == 'flightgearmp') { |
1477 | - if (substr($buffer,0,1) != '#') { |
|
1477 | + if (substr($buffer, 0, 1) != '#') { |
|
1478 | 1478 | $data = array(); |
1479 | 1479 | //echo $buffer."\n"; |
1480 | - $line = explode(' ',$buffer); |
|
1480 | + $line = explode(' ', $buffer); |
|
1481 | 1481 | if (count($line) == 11) { |
1482 | - $userserver = explode('@',$line[0]); |
|
1483 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1482 | + $userserver = explode('@', $line[0]); |
|
1483 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1484 | 1484 | $data['ident'] = $userserver[0]; |
1485 | 1485 | $data['registration'] = $userserver[0]; |
1486 | 1486 | $data['latitude'] = $line[4]; |
@@ -1488,8 +1488,8 @@ discard block |
||
1488 | 1488 | $data['altitude'] = $line[6]; |
1489 | 1489 | $data['datetime'] = date('Y-m-d H:i:s'); |
1490 | 1490 | $aircraft_type = $line[10]; |
1491 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1492 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1491 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1492 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1493 | 1493 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1494 | 1494 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1495 | 1495 | } |
@@ -1498,8 +1498,8 @@ discard block |
||
1498 | 1498 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1499 | 1499 | die; |
1500 | 1500 | } elseif ($format == 'vrstcp') { |
1501 | - foreach($buffer as $all_data) { |
|
1502 | - $line = json_decode('{'.$all_data.'}',true); |
|
1501 | + foreach ($buffer as $all_data) { |
|
1502 | + $line = json_decode('{'.$all_data.'}', true); |
|
1503 | 1503 | $data = array(); |
1504 | 1504 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1505 | 1505 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1525,16 +1525,16 @@ discard block |
||
1525 | 1525 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1526 | 1526 | unset($data); |
1527 | 1527 | } |
1528 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1528 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1529 | 1529 | $line = explode("\t", $buffer); |
1530 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1530 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1531 | 1531 | $key = $line[$k]; |
1532 | - $lined[$key] = $line[$k+1]; |
|
1532 | + $lined[$key] = $line[$k + 1]; |
|
1533 | 1533 | } |
1534 | 1534 | if (count($lined) > 3) { |
1535 | 1535 | $data['hex'] = $lined['hexid']; |
1536 | 1536 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1537 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1537 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1538 | 1538 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1539 | 1539 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1540 | 1540 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1553,23 +1553,23 @@ discard block |
||
1553 | 1553 | } else $error = true; |
1554 | 1554 | } elseif ($format == 'aprs' && $use_aprs) { |
1555 | 1555 | if ($aprs_connect == 0) { |
1556 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1556 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1557 | 1557 | $aprs_connect = 1; |
1558 | 1558 | } |
1559 | 1559 | |
1560 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1560 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1561 | 1561 | $aprs_last_tx = time(); |
1562 | 1562 | $data_aprs = "# Keep alive"; |
1563 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1563 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1564 | 1564 | } |
1565 | 1565 | |
1566 | 1566 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1567 | 1567 | //echo 'APRS data : '.$buffer."\n"; |
1568 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1569 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1568 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1569 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1570 | 1570 | //echo $buffer."\n"; |
1571 | 1571 | date_default_timezone_set('UTC'); |
1572 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1572 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1573 | 1573 | $line = $APRS->parse($buffer); |
1574 | 1574 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1575 | 1575 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1584,7 +1584,7 @@ discard block |
||
1584 | 1584 | if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
1585 | 1585 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
1586 | 1586 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
1587 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1587 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1588 | 1588 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1589 | 1589 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1590 | 1590 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1667,29 +1667,29 @@ discard block |
||
1667 | 1667 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1668 | 1668 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1669 | 1669 | $Source->deleteOldLocationByType('gs'); |
1670 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1671 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1670 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
1671 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1672 | 1672 | } else { |
1673 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1673 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1674 | 1674 | } |
1675 | 1675 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1676 | 1676 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1677 | 1677 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1678 | 1678 | $Source->deleteOldLocationByType('wx'); |
1679 | 1679 | $weather_data = json_encode($line); |
1680 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
1681 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1680 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
1681 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1682 | 1682 | } else { |
1683 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1683 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1684 | 1684 | } |
1685 | 1685 | } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
1686 | 1686 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1687 | 1687 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1688 | 1688 | $Source->deleteOldLocationByType('lightning'); |
1689 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
1690 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1689 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
1690 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1691 | 1691 | } else { |
1692 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1692 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1693 | 1693 | } |
1694 | 1694 | } elseif ($globalDebug) { |
1695 | 1695 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | unset($data); |
1699 | 1699 | } |
1700 | 1700 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1701 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1701 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1702 | 1702 | } |
1703 | 1703 | /* |
1704 | 1704 | 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')) { |
@@ -1707,7 +1707,7 @@ discard block |
||
1707 | 1707 | */ |
1708 | 1708 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1709 | 1709 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1710 | - if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1710 | + if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1711 | 1711 | $Source->deleteOldLocationByType('lightning'); |
1712 | 1712 | $Source->deleteOldLocationByType('wx'); |
1713 | 1713 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -1792,7 +1792,7 @@ discard block |
||
1792 | 1792 | connect_all($sourceee); |
1793 | 1793 | $sourceee = array(); |
1794 | 1794 | //connect_all($globalSources); |
1795 | - $tt[$format]=0; |
|
1795 | + $tt[$format] = 0; |
|
1796 | 1796 | break; |
1797 | 1797 | } |
1798 | 1798 | //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
@@ -1802,14 +1802,14 @@ discard block |
||
1802 | 1802 | } else { |
1803 | 1803 | $error = socket_strerror(socket_last_error()); |
1804 | 1804 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1805 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1805 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1806 | 1806 | if (isset($globalDebug)) echo "Restarting...\n"; |
1807 | 1807 | // Restart the script if possible |
1808 | 1808 | if (is_array($sockets)) { |
1809 | 1809 | if ($globalDebug) echo "Shutdown all sockets..."; |
1810 | 1810 | |
1811 | 1811 | foreach ($sockets as $sock) { |
1812 | - @socket_shutdown($sock,2); |
|
1812 | + @socket_shutdown($sock, 2); |
|
1813 | 1813 | @socket_close($sock); |
1814 | 1814 | } |
1815 | 1815 |