@@ -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'])) { |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | else $id_source = 1; |
90 | 90 | if (isset($globalServer) && $globalServer) { |
91 | 91 | if ($globalDebug) echo "Using Server Mode\n"; |
92 | - $SI=new SpotterServer(); |
|
92 | + $SI = new SpotterServer(); |
|
93 | 93 | /* |
94 | 94 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
95 | 95 | $SI = new adsb2aprs(); |
96 | 96 | $SI->connect(); |
97 | 97 | */ |
98 | -} else $SI=new SpotterImport($Connection->db); |
|
98 | +} else $SI = new SpotterImport($Connection->db); |
|
99 | 99 | |
100 | 100 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
101 | 101 | if (isset($globalMarine) && $globalMarine) { |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | $MI = new MarineImport($Connection->db); |
110 | 110 | } |
111 | 111 | //$APRS=new APRS($Connection->db); |
112 | -$SBS=new SBS(); |
|
113 | -$ACARS=new ACARS($Connection->db,true); |
|
114 | -$Source=new Source($Connection->db); |
|
115 | -$Common=new Common(); |
|
112 | +$SBS = new SBS(); |
|
113 | +$ACARS = new ACARS($Connection->db, true); |
|
114 | +$Source = new Source($Connection->db); |
|
115 | +$Common = new Common(); |
|
116 | 116 | date_default_timezone_set('UTC'); |
117 | 117 | //$servertz = system('date +%Z'); |
118 | 118 | // signal handler - playing nice with sockets and dump1090 |
119 | 119 | if (function_exists('pcntl_fork')) { |
120 | - pcntl_signal(SIGINT, function() { |
|
120 | + pcntl_signal(SIGINT, function() { |
|
121 | 121 | global $sockets; |
122 | 122 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
123 | 123 | die("Bye!\n"); |
@@ -133,30 +133,30 @@ discard block |
||
133 | 133 | |
134 | 134 | function connect_all($hosts) { |
135 | 135 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
136 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
136 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
137 | 137 | $reset++; |
138 | 138 | if ($globalDebug) echo 'Connect to all...'."\n"; |
139 | 139 | foreach ($hosts as $id => $value) { |
140 | 140 | $host = $value['host']; |
141 | 141 | $globalSources[$id]['last_exec'] = 0; |
142 | 142 | // Here we check type of source(s) |
143 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
144 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
143 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
144 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
145 | 145 | //$formats[$id] = 'deltadbtxt'; |
146 | 146 | $globalSources[$id]['format'] = 'deltadbtxt'; |
147 | 147 | //$last_exec['deltadbtxt'] = 0; |
148 | 148 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
149 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
149 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
150 | 150 | //$formats[$id] = 'vatsimtxt'; |
151 | 151 | $globalSources[$id]['format'] = 'vatsimtxt'; |
152 | 152 | //$last_exec['vatsimtxt'] = 0; |
153 | 153 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
154 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
154 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
155 | 155 | //$formats[$id] = 'aircraftlistjson'; |
156 | 156 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
157 | 157 | //$last_exec['aircraftlistjson'] = 0; |
158 | 158 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
159 | - } else if (preg_match('/opensky/i',$host)) { |
|
159 | + } else if (preg_match('/opensky/i', $host)) { |
|
160 | 160 | //$formats[$id] = 'aircraftlistjson'; |
161 | 161 | $globalSources[$id]['format'] = 'opensky'; |
162 | 162 | //$last_exec['aircraftlistjson'] = 0; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | exit(0); |
174 | 174 | } |
175 | 175 | */ |
176 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
176 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
177 | 177 | //$formats[$id] = 'planeupdatefaa'; |
178 | 178 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
179 | 179 | //$last_exec['planeupdatefaa'] = 0; |
@@ -182,32 +182,32 @@ discard block |
||
182 | 182 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
183 | 183 | exit(0); |
184 | 184 | } |
185 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
185 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
186 | 186 | //$formats[$id] = 'phpvmacars'; |
187 | 187 | $globalSources[$id]['format'] = 'phpvmacars'; |
188 | 188 | //$last_exec['phpvmacars'] = 0; |
189 | 189 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
190 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
190 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
191 | 191 | //$formats[$id] = 'phpvmacars'; |
192 | 192 | $globalSources[$id]['format'] = 'vam'; |
193 | 193 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
194 | - } else if (preg_match('/whazzup/i',$host)) { |
|
194 | + } else if (preg_match('/whazzup/i', $host)) { |
|
195 | 195 | //$formats[$id] = 'whazzup'; |
196 | 196 | $globalSources[$id]['format'] = 'whazzup'; |
197 | 197 | //$last_exec['whazzup'] = 0; |
198 | 198 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
199 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
199 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
200 | 200 | $globalSources[$id]['format'] = 'blitzortung'; |
201 | 201 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
202 | - } else if (preg_match('/airwhere/i',$host)) { |
|
202 | + } else if (preg_match('/airwhere/i', $host)) { |
|
203 | 203 | $globalSources[$id]['format'] = 'airwhere'; |
204 | 204 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
205 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
205 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
206 | 206 | //$formats[$id] = 'pirepsjson'; |
207 | 207 | $globalSources[$id]['format'] = 'pirepsjson'; |
208 | 208 | //$last_exec['pirepsjson'] = 0; |
209 | 209 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
210 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
210 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
211 | 211 | //$formats[$id] = 'fr24json'; |
212 | 212 | $globalSources[$id]['format'] = 'fr24json'; |
213 | 213 | //$last_exec['fr24json'] = 0; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
217 | 217 | exit(0); |
218 | 218 | } |
219 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
219 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
220 | 220 | //$formats[$id] = 'fr24json'; |
221 | 221 | $globalSources[$id]['format'] = 'myshiptracking'; |
222 | 222 | //$last_exec['fr24json'] = 0; |
@@ -226,22 +226,22 @@ discard block |
||
226 | 226 | exit(0); |
227 | 227 | } |
228 | 228 | //} else if (preg_match('/10001/',$host)) { |
229 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
229 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
230 | 230 | //$formats[$id] = 'tsv'; |
231 | 231 | $globalSources[$id]['format'] = 'tsv'; |
232 | 232 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
233 | 233 | } |
234 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
234 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
235 | 235 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
236 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
236 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
237 | 237 | if ($idf !== false) { |
238 | 238 | $httpfeeds[$id] = $idf; |
239 | 239 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
240 | 240 | } |
241 | 241 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
242 | 242 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
243 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
244 | - $hostport = explode(':',$host); |
|
243 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
244 | + $hostport = explode(':', $host); |
|
245 | 245 | if (isset($hostport[1])) { |
246 | 246 | $port = $hostport[1]; |
247 | 247 | $hostn = $hostport[0]; |
@@ -251,19 +251,19 @@ discard block |
||
251 | 251 | } |
252 | 252 | $Common = new Common(); |
253 | 253 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
254 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
254 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
255 | 255 | } else { |
256 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
256 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
257 | 257 | } |
258 | 258 | if ($s) { |
259 | 259 | $sockets[$id] = $s; |
260 | 260 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
261 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
261 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
262 | 262 | //$formats[$id] = 'aprs'; |
263 | 263 | $globalSources[$id]['format'] = 'aprs'; |
264 | 264 | //$aprs_connect = 0; |
265 | 265 | //$use_aprs = true; |
266 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
266 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
267 | 267 | $globalSources[$id]['format'] = 'vrstcp'; |
268 | 268 | } elseif ($port == '10001') { |
269 | 269 | //$formats[$id] = 'tsv'; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
303 | 303 | else $timeout = 20; |
304 | 304 | $errno = ''; |
305 | -$errstr=''; |
|
305 | +$errstr = ''; |
|
306 | 306 | |
307 | 307 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
308 | 308 | /* Initiate connections to all the hosts simultaneously */ |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | //connect_all($globalSources); |
311 | 311 | |
312 | 312 | if (isset($globalProxy) && $globalProxy) { |
313 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
313 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
314 | 314 | } else { |
315 | 315 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
316 | 316 | } |
@@ -340,16 +340,16 @@ discard block |
||
340 | 340 | |
341 | 341 | if ($use_aprs) { |
342 | 342 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
343 | - $APRS=new APRS(); |
|
343 | + $APRS = new APRS(); |
|
344 | 344 | $aprs_connect = 0; |
345 | 345 | $aprs_keep = 120; |
346 | 346 | $aprs_last_tx = time(); |
347 | 347 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
348 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
348 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
349 | 349 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
350 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
350 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
351 | 351 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
352 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
352 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
353 | 353 | if ($aprs_full) $aprs_filter = ''; |
354 | 354 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
355 | 355 | else $aprs_pass = '-1'; |
@@ -363,12 +363,12 @@ discard block |
||
363 | 363 | sleep(1); |
364 | 364 | if ($globalDebug) echo "SCAN MODE \n\n"; |
365 | 365 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
366 | -$endtime = time()+$globalCronEnd; |
|
366 | +$endtime = time() + $globalCronEnd; |
|
367 | 367 | $i = 1; |
368 | 368 | $tt = array(); |
369 | 369 | // Delete all ATC |
370 | 370 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
371 | - $ATC=new ATC($Connection->db); |
|
371 | + $ATC = new ATC($Connection->db); |
|
372 | 372 | } |
373 | 373 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
374 | 374 | $ATC->deleteAll(); |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | |
377 | 377 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
378 | 378 | while ($i > 0) { |
379 | - if (!$globalDaemon) $i = $endtime-time(); |
|
379 | + if (!$globalDaemon) $i = $endtime - time(); |
|
380 | 380 | // Delete old ATC |
381 | 381 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
382 | 382 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | } |
391 | 391 | if ($max != $globalMinFetch) { |
392 | 392 | if ($globalDebug) echo 'Sleeping...'."\n"; |
393 | - sleep($globalMinFetch-$max+2); |
|
393 | + sleep($globalMinFetch - $max + 2); |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | //$buffer = $Common->getData($hosts[$id]); |
410 | 410 | $buffer = $Common->getData($value['host']); |
411 | 411 | if ($buffer != '') $reset = 0; |
412 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
413 | - $buffer = explode('\n',$buffer); |
|
412 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
413 | + $buffer = explode('\n', $buffer); |
|
414 | 414 | foreach ($buffer as $line) { |
415 | 415 | if ($line != '' && count($line) > 7) { |
416 | 416 | $line = explode(',', $line); |
@@ -443,11 +443,11 @@ discard block |
||
443 | 443 | ) |
444 | 444 | ) { |
445 | 445 | date_default_timezone_set('CET'); |
446 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
446 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
447 | 447 | date_default_timezone_set('UTC'); |
448 | 448 | if ($buffer != '') $reset = 0; |
449 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
450 | - $buffer = explode('\n',$buffer); |
|
449 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
450 | + $buffer = explode('\n', $buffer); |
|
451 | 451 | foreach ($buffer as $line) { |
452 | 452 | if ($line != '') { |
453 | 453 | //echo "'".$line."'\n"; |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
466 | 466 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
467 | 467 | if (isset($ais_data['timestamp'])) { |
468 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
468 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
469 | 469 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
470 | 470 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
471 | 471 | $add = true; |
@@ -488,12 +488,12 @@ discard block |
||
488 | 488 | $w = $e = null; |
489 | 489 | |
490 | 490 | if (isset($arr[$id])) { |
491 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
491 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
492 | 492 | if ($nn > 0) { |
493 | 493 | foreach ($httpfeeds as $feed) { |
494 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
495 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
496 | - $buffer = explode('\n',$buffer); |
|
494 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
495 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
496 | + $buffer = explode('\n', $buffer); |
|
497 | 497 | foreach ($buffer as $line) { |
498 | 498 | if ($line != '') { |
499 | 499 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -511,9 +511,9 @@ discard block |
||
511 | 511 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
512 | 512 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
513 | 513 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
514 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
514 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
515 | 515 | if (isset($ais_data['timestamp'])) { |
516 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
516 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
517 | 517 | } else { |
518 | 518 | $data['datetime'] = date('Y-m-d H:i:s'); |
519 | 519 | } |
@@ -544,10 +544,10 @@ discard block |
||
544 | 544 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
545 | 545 | ) |
546 | 546 | ) { |
547 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
547 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
548 | 548 | if ($buffer != '') { |
549 | 549 | //echo $buffer; |
550 | - $all_data = json_decode($buffer,true); |
|
550 | + $all_data = json_decode($buffer, true); |
|
551 | 551 | //print_r($all_data); |
552 | 552 | if (isset($all_data[0]['DATA'])) { |
553 | 553 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
563 | 563 | $data['imo'] = $line['IMO']; |
564 | 564 | //$data['arrival_code'] = $ais_data['destination']; |
565 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
565 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
566 | 566 | $data['format_source'] = 'myshiptracking'; |
567 | 567 | $data['id_source'] = $id_source; |
568 | 568 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -579,9 +579,9 @@ discard block |
||
579 | 579 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
580 | 580 | ) |
581 | 581 | ) { |
582 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
582 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
583 | 583 | if ($buffer != '') { |
584 | - $all_data = json_decode($buffer,true); |
|
584 | + $all_data = json_decode($buffer, true); |
|
585 | 585 | if (isset($all_data[0]['mmsi'])) { |
586 | 586 | foreach ($all_data as $line) { |
587 | 587 | if ($line != '') { |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | ) { |
616 | 616 | $buffer = $Common->getData($value['host']); |
617 | 617 | if ($buffer != '') { |
618 | - $all_data = json_decode($buffer,true); |
|
618 | + $all_data = json_decode($buffer, true); |
|
619 | 619 | if (isset($all_data['features'][0]['id'])) { |
620 | 620 | foreach ($all_data['features'] as $line) { |
621 | 621 | $data = array(); |
@@ -648,27 +648,27 @@ discard block |
||
648 | 648 | ) |
649 | 649 | ) { |
650 | 650 | echo 'download...'; |
651 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
651 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
652 | 652 | echo 'done !'."\n"; |
653 | 653 | if ($buffer != '') $reset = 0; |
654 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
655 | - $buffer = explode('\n',$buffer); |
|
654 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
655 | + $buffer = explode('\n', $buffer); |
|
656 | 656 | foreach ($buffer as $line) { |
657 | 657 | if ($line != '') { |
658 | 658 | $data = array(); |
659 | - $data['mmsi'] = (int)substr($line,0,9); |
|
660 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
659 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
660 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
661 | 661 | //$data['status'] = substr($line,21,2); |
662 | 662 | //$data['type'] = substr($line,24,3); |
663 | - $data['latitude'] = substr($line,29,9); |
|
664 | - $data['longitude'] = substr($line,41,9); |
|
665 | - $data['speed'] = round(substr($line,51,5)); |
|
663 | + $data['latitude'] = substr($line, 29, 9); |
|
664 | + $data['longitude'] = substr($line, 41, 9); |
|
665 | + $data['speed'] = round(substr($line, 51, 5)); |
|
666 | 666 | //$data['course'] = substr($line,57,5); |
667 | - $data['heading'] = round(substr($line,63,3)); |
|
667 | + $data['heading'] = round(substr($line, 63, 3)); |
|
668 | 668 | //$data['draft'] = substr($line,67,4); |
669 | 669 | //$data['length'] = substr($line,72,3); |
670 | 670 | //$data['beam'] = substr($line,76,2); |
671 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
671 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
672 | 672 | //$data['callsign'] = trim(substr($line,100,7); |
673 | 673 | //$data['dest'] = substr($line,108,20); |
674 | 674 | //$data['etaDate'] = substr($line,129,5); |
@@ -701,8 +701,8 @@ discard block |
||
701 | 701 | ) { |
702 | 702 | //$buffer = $Common->getData($hosts[$id]); |
703 | 703 | $buffer = $Common->getData($value['host']); |
704 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
705 | - $buffer = explode('\n',$buffer); |
|
704 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
705 | + $buffer = explode('\n', $buffer); |
|
706 | 706 | $reset = 0; |
707 | 707 | foreach ($buffer as $line) { |
708 | 708 | if ($line != '') { |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
714 | 714 | $data['pilot_id'] = $line[1]; |
715 | 715 | $data['pilot_name'] = $line[2]; |
716 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
716 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
717 | 717 | $data['ident'] = $line[0]; // ident |
718 | 718 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
719 | 719 | $data['speed'] = $line[8]; // speed |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
730 | 730 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
731 | 731 | $data['departure_airport_icao'] = $line[11]; |
732 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
732 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
733 | 733 | $data['arrival_airport_icao'] = $line[13]; |
734 | 734 | $data['frequency'] = $line[4]; |
735 | 735 | $data['type'] = $line[18]; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | $data['id_source'] = $id_source; |
739 | 739 | //$data['arrival_airport_time'] = ; |
740 | 740 | if ($line[9] != '') { |
741 | - $aircraft_data = explode('/',$line[9]); |
|
741 | + $aircraft_data = explode('/', $line[9]); |
|
742 | 742 | if (isset($aircraft_data[1])) { |
743 | 743 | $data['aircraft_icao'] = $aircraft_data[1]; |
744 | 744 | } |
@@ -753,9 +753,9 @@ discard block |
||
753 | 753 | if ($line[3] == 'PILOT') $SI->add($data); |
754 | 754 | elseif ($line[3] == 'ATC') { |
755 | 755 | //print_r($data); |
756 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
757 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
758 | - $typec = substr($data['ident'],-3); |
|
756 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
757 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
758 | + $typec = substr($data['ident'], -3); |
|
759 | 759 | if ($typec == 'APP') $data['type'] = 'Approach'; |
760 | 760 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
761 | 761 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -767,8 +767,8 @@ discard block |
||
767 | 767 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
768 | 768 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
769 | 769 | if (isset($ATC)) { |
770 | - 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']); |
|
771 | - 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']); |
|
770 | + 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']); |
|
771 | + 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']); |
|
772 | 772 | } |
773 | 773 | } |
774 | 774 | unset($data); |
@@ -784,24 +784,24 @@ discard block |
||
784 | 784 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
785 | 785 | ) |
786 | 786 | ) { |
787 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
787 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
788 | 788 | if ($buffer != '') { |
789 | 789 | $all_data = simplexml_load_string($buffer); |
790 | - foreach($all_data->children() as $childdata) { |
|
790 | + foreach ($all_data->children() as $childdata) { |
|
791 | 791 | $data = array(); |
792 | 792 | $line = $childdata; |
793 | 793 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
794 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
795 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
796 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
797 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
798 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
799 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
800 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
794 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
795 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
796 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
797 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
798 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
799 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
800 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
801 | 801 | $data['altitude_relative'] = 'AMSL'; |
802 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
802 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
803 | 803 | $data['aircraft_icao'] = 'PARAGLIDER'; |
804 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
804 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
805 | 805 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
806 | 806 | $data['format_source'] = $value['format']; |
807 | 807 | $SI->add($data); |
@@ -809,22 +809,22 @@ discard block |
||
809 | 809 | } |
810 | 810 | } |
811 | 811 | $Source->deleteOldLocationByType('gs'); |
812 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
812 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
813 | 813 | if ($buffer != '') { |
814 | 814 | $all_data = simplexml_load_string($buffer); |
815 | - foreach($all_data->children() as $childdata) { |
|
815 | + foreach ($all_data->children() as $childdata) { |
|
816 | 816 | $data = array(); |
817 | 817 | $line = $childdata; |
818 | - $data['id'] = (int)$line['gsID']; |
|
819 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
820 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
821 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
818 | + $data['id'] = (int) $line['gsID']; |
|
819 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
820 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
821 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
822 | 822 | $data['altitude_relative'] = 'AMSL'; |
823 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
823 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
824 | 824 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
825 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
825 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
826 | 826 | } else { |
827 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
827 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
828 | 828 | } |
829 | 829 | unset($data); |
830 | 830 | } |
@@ -842,9 +842,9 @@ discard block |
||
842 | 842 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
843 | 843 | ) |
844 | 844 | ) { |
845 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
845 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
846 | 846 | if ($buffer != '') { |
847 | - $all_data = json_decode($buffer,true); |
|
847 | + $all_data = json_decode($buffer, true); |
|
848 | 848 | if (isset($all_data['acList'])) { |
849 | 849 | $reset = 0; |
850 | 850 | foreach ($all_data['acList'] as $line) { |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
861 | 861 | $data['emergency'] = ''; // emergency |
862 | 862 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
863 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
863 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
864 | 864 | else $data['datetime'] = date('Y-m-d H:i:s'); |
865 | 865 | //$data['datetime'] = date('Y-m-d H:i:s'); |
866 | 866 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | $data['verticalrate'] = $line['vrt']; // verticale rate |
886 | 886 | $data['squawk'] = $line['squawk']; // squawk |
887 | 887 | $data['emergency'] = ''; // emergency |
888 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
888 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
889 | 889 | else $data['datetime'] = date('Y-m-d H:i:s'); |
890 | 890 | $data['format_source'] = 'aircraftlistjson'; |
891 | 891 | $data['id_source'] = $id_source; |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | ) |
907 | 907 | ) { |
908 | 908 | $buffer = $Common->getData($value['host']); |
909 | - $all_data = json_decode($buffer,true); |
|
909 | + $all_data = json_decode($buffer, true); |
|
910 | 910 | if (isset($all_data['planes'])) { |
911 | 911 | $reset = 0; |
912 | 912 | foreach ($all_data['planes'] as $key => $line) { |
@@ -923,12 +923,12 @@ discard block |
||
923 | 923 | $data['emergency'] = ''; // emergency |
924 | 924 | $data['registration'] = $line[2]; |
925 | 925 | $data['aircraft_icao'] = $line[0]; |
926 | - $deparr = explode('-',$line[1]); |
|
926 | + $deparr = explode('-', $line[1]); |
|
927 | 927 | if (count($deparr) == 2) { |
928 | 928 | $data['departure_airport_icao'] = $deparr[0]; |
929 | 929 | $data['arrival_airport_icao'] = $deparr[1]; |
930 | 930 | } |
931 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
931 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
932 | 932 | $data['format_source'] = 'planeupdatefaa'; |
933 | 933 | $data['id_source'] = $id_source; |
934 | 934 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | ) |
947 | 947 | ) { |
948 | 948 | $buffer = $Common->getData($value['host']); |
949 | - $all_data = json_decode($buffer,true); |
|
949 | + $all_data = json_decode($buffer, true); |
|
950 | 950 | if (isset($all_data['states'])) { |
951 | 951 | $reset = 0; |
952 | 952 | foreach ($all_data['states'] as $key => $line) { |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | //$data['emergency'] = ''; // emergency |
964 | 964 | //$data['registration'] = $line[2]; |
965 | 965 | //$data['aircraft_icao'] = $line[0]; |
966 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
966 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
967 | 967 | $data['format_source'] = 'opensky'; |
968 | 968 | $data['id_source'] = $id_source; |
969 | 969 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | ) { |
983 | 983 | //$buffer = $Common->getData($hosts[$id]); |
984 | 984 | $buffer = $Common->getData($value['host']); |
985 | - $all_data = json_decode($buffer,true); |
|
985 | + $all_data = json_decode($buffer, true); |
|
986 | 986 | if (!empty($all_data)) $reset = 0; |
987 | 987 | foreach ($all_data as $key => $line) { |
988 | 988 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1020,11 +1020,11 @@ discard block |
||
1020 | 1020 | ) |
1021 | 1021 | ) { |
1022 | 1022 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
1023 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1023 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
1024 | 1024 | //echo $buffer; |
1025 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1026 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1027 | - $all_data = json_decode($buffer,true); |
|
1025 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
1026 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
1027 | + $all_data = json_decode($buffer, true); |
|
1028 | 1028 | if (json_last_error() != JSON_ERROR_NONE) { |
1029 | 1029 | die(json_last_error_msg()); |
1030 | 1030 | } |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | //$data['departure_airport_iata'] = $line[11]; |
1048 | 1048 | //$data['arrival_airport_iata'] = $line[12]; |
1049 | 1049 | //$data['emergency'] = ''; // emergency |
1050 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
1050 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
1051 | 1051 | $data['format_source'] = 'radarvirtueljson'; |
1052 | 1052 | $data['id_source'] = $id_source; |
1053 | 1053 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1068,14 +1068,14 @@ discard block |
||
1068 | 1068 | ) { |
1069 | 1069 | //$buffer = $Common->getData($hosts[$id]); |
1070 | 1070 | $buffer = $Common->getData($value['host'].'?'.time()); |
1071 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1071 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
1072 | 1072 | |
1073 | 1073 | if (isset($all_data['pireps'])) { |
1074 | 1074 | $reset = 0; |
1075 | 1075 | foreach ($all_data['pireps'] as $line) { |
1076 | 1076 | $data = array(); |
1077 | 1077 | $data['id'] = $line['id']; |
1078 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1078 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1079 | 1079 | $data['ident'] = $line['callsign']; // ident |
1080 | 1080 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
1081 | 1081 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1105,9 +1105,9 @@ discard block |
||
1105 | 1105 | $SI->add($data); |
1106 | 1106 | // print_r($data); |
1107 | 1107 | } elseif ($line['icon'] == 'ct') { |
1108 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1109 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1110 | - $typec = substr($data['ident'],-3); |
|
1108 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
1109 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1110 | + $typec = substr($data['ident'], -3); |
|
1111 | 1111 | $data['type'] = ''; |
1112 | 1112 | if ($typec == 'APP') $data['type'] = 'Approach'; |
1113 | 1113 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
1119 | 1119 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1120 | 1120 | else $data['type'] = 'Observer'; |
1121 | - 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']); |
|
1121 | + 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']); |
|
1122 | 1122 | } |
1123 | 1123 | unset($data); |
1124 | 1124 | } |
@@ -1135,14 +1135,14 @@ discard block |
||
1135 | 1135 | //$buffer = $Common->getData($hosts[$id]); |
1136 | 1136 | if ($globalDebug) echo 'Get Data...'."\n"; |
1137 | 1137 | $buffer = $Common->getData($value['host']); |
1138 | - $all_data = json_decode($buffer,true); |
|
1138 | + $all_data = json_decode($buffer, true); |
|
1139 | 1139 | if ($buffer != '' && is_array($all_data)) { |
1140 | 1140 | $reset = 0; |
1141 | 1141 | foreach ($all_data as $line) { |
1142 | 1142 | $data = array(); |
1143 | 1143 | //$data['id'] = $line['id']; // id not usable |
1144 | 1144 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1145 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1145 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1146 | 1146 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1147 | 1147 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1148 | 1148 | $data['ident'] = $line['flightnum']; // ident |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | //$data['datetime'] = $line['lastupdate']; |
1158 | 1158 | //$data['last_update'] = $line['lastupdate']; |
1159 | 1159 | if (isset($value['timezone'])) { |
1160 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1160 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1161 | 1161 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1162 | 1162 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1163 | 1163 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1170,14 +1170,14 @@ discard block |
||
1170 | 1170 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1171 | 1171 | if (isset($line['aircraftname'])) { |
1172 | 1172 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1173 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1174 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1173 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1174 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1175 | 1175 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1176 | 1176 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1177 | 1177 | else { |
1178 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1179 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1180 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1178 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1179 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1180 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1202,14 +1202,14 @@ discard block |
||
1202 | 1202 | //$buffer = $Common->getData($hosts[$id]); |
1203 | 1203 | if ($globalDebug) echo 'Get Data...'."\n"; |
1204 | 1204 | $buffer = $Common->getData($value['host']); |
1205 | - $all_data = json_decode($buffer,true); |
|
1205 | + $all_data = json_decode($buffer, true); |
|
1206 | 1206 | if ($buffer != '' && is_array($all_data)) { |
1207 | 1207 | $reset = 0; |
1208 | 1208 | foreach ($all_data as $line) { |
1209 | 1209 | $data = array(); |
1210 | 1210 | //$data['id'] = $line['id']; // id not usable |
1211 | 1211 | $data['id'] = trim($line['flight_id']); |
1212 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1212 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1213 | 1213 | $data['pilot_name'] = $line['pilot_name']; |
1214 | 1214 | $data['pilot_id'] = $line['pilot_id']; |
1215 | 1215 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1253,24 +1253,24 @@ discard block |
||
1253 | 1253 | //$buffer = $Common->getData($hosts[$id]); |
1254 | 1254 | if ($globalDebug) echo 'Get Data...'."\n"; |
1255 | 1255 | $buffer = $Common->getData($value['host']); |
1256 | - $all_data = json_decode($buffer,true); |
|
1256 | + $all_data = json_decode($buffer, true); |
|
1257 | 1257 | if ($buffer != '') { |
1258 | 1258 | $Source->deleteLocationBySource('blitzortung'); |
1259 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1260 | - $buffer = explode('\n',$buffer); |
|
1259 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1260 | + $buffer = explode('\n', $buffer); |
|
1261 | 1261 | foreach ($buffer as $buffer_line) { |
1262 | - $line = json_decode($buffer_line,true); |
|
1262 | + $line = json_decode($buffer_line, true); |
|
1263 | 1263 | if (isset($line['time'])) { |
1264 | 1264 | $data = array(); |
1265 | 1265 | $data['altitude'] = $line['alt']; // altitude |
1266 | 1266 | $data['latitude'] = $line['lat']; // lat |
1267 | 1267 | $data['longitude'] = $line['lon']; // long |
1268 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
1268 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1269 | 1269 | $data['id_source'] = $id_source; |
1270 | 1270 | $data['format_source'] = 'blitzortung'; |
1271 | 1271 | $SI->add($data); |
1272 | 1272 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1273 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
1273 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1274 | 1274 | unset($data); |
1275 | 1275 | } |
1276 | 1276 | } |
@@ -1295,11 +1295,11 @@ discard block |
||
1295 | 1295 | //$value = $formats[$nb]; |
1296 | 1296 | $format = $globalSources[$nb]['format']; |
1297 | 1297 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1298 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1298 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1299 | 1299 | } elseif ($format == 'vrstcp') { |
1300 | 1300 | $buffer = @socket_read($r, 6000); |
1301 | 1301 | } else { |
1302 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1302 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1303 | 1303 | } |
1304 | 1304 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1305 | 1305 | //echo $buffer."\n"; |
@@ -1308,8 +1308,8 @@ discard block |
||
1308 | 1308 | $error = false; |
1309 | 1309 | //$SI::del(); |
1310 | 1310 | if ($format == 'vrstcp') { |
1311 | - $buffer = explode('},{',$buffer); |
|
1312 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1311 | + $buffer = explode('},{', $buffer); |
|
1312 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1313 | 1313 | // SBS format is CSV format |
1314 | 1314 | if ($buffer !== FALSE && $buffer != '') { |
1315 | 1315 | $tt[$format] = 0; |
@@ -1343,13 +1343,13 @@ discard block |
||
1343 | 1343 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1344 | 1344 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1345 | 1345 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1346 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1346 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1347 | 1347 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1348 | 1348 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1349 | 1349 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1350 | 1350 | |
1351 | 1351 | if (isset($ais_data['timestamp'])) { |
1352 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1352 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1353 | 1353 | } else { |
1354 | 1354 | $data['datetime'] = date('Y-m-d H:i:s'); |
1355 | 1355 | } |
@@ -1360,10 +1360,10 @@ discard block |
||
1360 | 1360 | } elseif ($format == 'flightgearsp') { |
1361 | 1361 | //echo $buffer."\n"; |
1362 | 1362 | if (strlen($buffer) > 5) { |
1363 | - $line = explode(',',$buffer); |
|
1363 | + $line = explode(',', $buffer); |
|
1364 | 1364 | $data = array(); |
1365 | 1365 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1366 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1366 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1367 | 1367 | $data['ident'] = $line[6]; |
1368 | 1368 | $data['aircraft_name'] = $line[7]; |
1369 | 1369 | $data['longitude'] = $line[1]; |
@@ -1380,16 +1380,16 @@ discard block |
||
1380 | 1380 | } elseif ($format == 'acars') { |
1381 | 1381 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1382 | 1382 | $ACARS->add(trim($buffer)); |
1383 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1383 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1384 | 1384 | $ACARS->deleteLiveAcarsData(); |
1385 | 1385 | } elseif ($format == 'flightgearmp') { |
1386 | - if (substr($buffer,0,1) != '#') { |
|
1386 | + if (substr($buffer, 0, 1) != '#') { |
|
1387 | 1387 | $data = array(); |
1388 | 1388 | //echo $buffer."\n"; |
1389 | - $line = explode(' ',$buffer); |
|
1389 | + $line = explode(' ', $buffer); |
|
1390 | 1390 | if (count($line) == 11) { |
1391 | - $userserver = explode('@',$line[0]); |
|
1392 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1391 | + $userserver = explode('@', $line[0]); |
|
1392 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1393 | 1393 | $data['ident'] = $userserver[0]; |
1394 | 1394 | $data['registration'] = $userserver[0]; |
1395 | 1395 | $data['latitude'] = $line[4]; |
@@ -1397,8 +1397,8 @@ discard block |
||
1397 | 1397 | $data['altitude'] = $line[6]; |
1398 | 1398 | $data['datetime'] = date('Y-m-d H:i:s'); |
1399 | 1399 | $aircraft_type = $line[10]; |
1400 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1401 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1400 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1401 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1402 | 1402 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1403 | 1403 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1404 | 1404 | } |
@@ -1407,8 +1407,8 @@ discard block |
||
1407 | 1407 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1408 | 1408 | die; |
1409 | 1409 | } elseif ($format == 'vrstcp') { |
1410 | - foreach($buffer as $all_data) { |
|
1411 | - $line = json_decode('{'.$all_data.'}',true); |
|
1410 | + foreach ($buffer as $all_data) { |
|
1411 | + $line = json_decode('{'.$all_data.'}', true); |
|
1412 | 1412 | $data = array(); |
1413 | 1413 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1414 | 1414 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1434,16 +1434,16 @@ discard block |
||
1434 | 1434 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1435 | 1435 | unset($data); |
1436 | 1436 | } |
1437 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1437 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1438 | 1438 | $line = explode("\t", $buffer); |
1439 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1439 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1440 | 1440 | $key = $line[$k]; |
1441 | - $lined[$key] = $line[$k+1]; |
|
1441 | + $lined[$key] = $line[$k + 1]; |
|
1442 | 1442 | } |
1443 | 1443 | if (count($lined) > 3) { |
1444 | 1444 | $data['hex'] = $lined['hexid']; |
1445 | 1445 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1446 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1446 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1447 | 1447 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1448 | 1448 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1449 | 1449 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1462,22 +1462,22 @@ discard block |
||
1462 | 1462 | } else $error = true; |
1463 | 1463 | } elseif ($format == 'aprs' && $use_aprs) { |
1464 | 1464 | if ($aprs_connect == 0) { |
1465 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1465 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1466 | 1466 | $aprs_connect = 1; |
1467 | 1467 | } |
1468 | 1468 | |
1469 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1469 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1470 | 1470 | $aprs_last_tx = time(); |
1471 | 1471 | $data_aprs = "# Keep alive"; |
1472 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1472 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1473 | 1473 | } |
1474 | 1474 | |
1475 | 1475 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1476 | 1476 | //echo 'APRS data : '.$buffer."\n"; |
1477 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1478 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1477 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1478 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1479 | 1479 | //echo $buffer."\n"; |
1480 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1480 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1481 | 1481 | $line = $APRS->parse($buffer); |
1482 | 1482 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1483 | 1483 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1492,7 +1492,7 @@ discard block |
||
1492 | 1492 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
1493 | 1493 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
1494 | 1494 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
1495 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1495 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1496 | 1496 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1497 | 1497 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1498 | 1498 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1574,29 +1574,29 @@ discard block |
||
1574 | 1574 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1575 | 1575 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1576 | 1576 | $Source->deleteOldLocationByType('gs'); |
1577 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1578 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1577 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
1578 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1579 | 1579 | } else { |
1580 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1580 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1581 | 1581 | } |
1582 | 1582 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1583 | 1583 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1584 | 1584 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1585 | 1585 | $Source->deleteOldLocationByType('wx'); |
1586 | 1586 | $weather_data = json_encode($line); |
1587 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
1588 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1587 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
1588 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1589 | 1589 | } else { |
1590 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1590 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1591 | 1591 | } |
1592 | 1592 | } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
1593 | 1593 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1594 | 1594 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1595 | 1595 | $Source->deleteOldLocationByType('lightning'); |
1596 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
1597 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1596 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
1597 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1598 | 1598 | } else { |
1599 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1599 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1600 | 1600 | } |
1601 | 1601 | } elseif ($globalDebug) { |
1602 | 1602 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1605,7 +1605,7 @@ discard block |
||
1605 | 1605 | unset($data); |
1606 | 1606 | } |
1607 | 1607 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1608 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1608 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1609 | 1609 | } |
1610 | 1610 | /* |
1611 | 1611 | 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')) { |
@@ -1614,7 +1614,7 @@ discard block |
||
1614 | 1614 | */ |
1615 | 1615 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1616 | 1616 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1617 | - if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1617 | + if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1618 | 1618 | $Source->deleteOldLocationByType('lightning'); |
1619 | 1619 | $Source->deleteOldLocationByType('wx'); |
1620 | 1620 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | connect_all($sourceee); |
1700 | 1700 | $sourceee = array(); |
1701 | 1701 | //connect_all($globalSources); |
1702 | - $tt[$format]=0; |
|
1702 | + $tt[$format] = 0; |
|
1703 | 1703 | break; |
1704 | 1704 | } |
1705 | 1705 | } |
@@ -1708,14 +1708,14 @@ discard block |
||
1708 | 1708 | } else { |
1709 | 1709 | $error = socket_strerror(socket_last_error()); |
1710 | 1710 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1711 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1711 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1712 | 1712 | if (isset($globalDebug)) echo "Restarting...\n"; |
1713 | 1713 | // Restart the script if possible |
1714 | 1714 | if (is_array($sockets)) { |
1715 | 1715 | if ($globalDebug) echo "Shutdown all sockets..."; |
1716 | 1716 | |
1717 | 1717 | foreach ($sockets as $sock) { |
1718 | - @socket_shutdown($sock,2); |
|
1718 | + @socket_shutdown($sock, 2); |
|
1719 | 1719 | @socket_close($sock); |
1720 | 1720 | } |
1721 | 1721 |