@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | die; |
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
48 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::')); |
|
52 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::')); |
|
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
56 | 56 | $globalSources = array(); |
57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
57 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
58 | 58 | else $globalSources[] = array('host' => $options['s']); |
59 | 59 | } elseif (isset($options['source'])) { |
60 | 60 | $globalSources = array(); |
61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
61 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
62 | 62 | else $globalSources[] = array('host' => $options['source']); |
63 | 63 | } |
64 | 64 | if (isset($options['aprsserverhost'])) $globalServerAPRShost = $options['aprsserverhost']; |
@@ -71,27 +71,27 @@ discard block |
||
71 | 71 | else $id_source = 1; |
72 | 72 | if (isset($globalServer) && $globalServer) { |
73 | 73 | if ($globalDebug) echo "Using Server Mode\n"; |
74 | - $SI=new SpotterServer(); |
|
74 | + $SI = new SpotterServer(); |
|
75 | 75 | /* |
76 | 76 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
77 | 77 | $SI = new adsb2aprs(); |
78 | 78 | $SI->connect(); |
79 | 79 | */ |
80 | -} else $SI=new SpotterImport($Connection->db); |
|
80 | +} else $SI = new SpotterImport($Connection->db); |
|
81 | 81 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
82 | 82 | if (isset($globalMarine) && $globalMarine) { |
83 | 83 | $AIS = new AIS(); |
84 | 84 | $MI = new MarineImport($Connection->db); |
85 | 85 | } |
86 | 86 | //$APRS=new APRS($Connection->db); |
87 | -$SBS=new SBS(); |
|
88 | -$ACARS=new ACARS($Connection->db); |
|
89 | -$Common=new Common(); |
|
87 | +$SBS = new SBS(); |
|
88 | +$ACARS = new ACARS($Connection->db); |
|
89 | +$Common = new Common(); |
|
90 | 90 | date_default_timezone_set('UTC'); |
91 | 91 | //$servertz = system('date +%Z'); |
92 | 92 | // signal handler - playing nice with sockets and dump1090 |
93 | 93 | if (function_exists('pcntl_fork')) { |
94 | - pcntl_signal(SIGINT, function() { |
|
94 | + pcntl_signal(SIGINT, function() { |
|
95 | 95 | global $sockets; |
96 | 96 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
97 | 97 | die("Bye!\n"); |
@@ -107,35 +107,35 @@ discard block |
||
107 | 107 | |
108 | 108 | function connect_all($hosts) { |
109 | 109 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
110 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
110 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
111 | 111 | $reset++; |
112 | 112 | if ($globalDebug) echo 'Connect to all...'."\n"; |
113 | 113 | foreach ($hosts as $id => $value) { |
114 | 114 | $host = $value['host']; |
115 | 115 | $globalSources[$id]['last_exec'] = 0; |
116 | 116 | // Here we check type of source(s) |
117 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
118 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
117 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
118 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
119 | 119 | //$formats[$id] = 'deltadbtxt'; |
120 | 120 | $globalSources[$id]['format'] = 'deltadbtxt'; |
121 | 121 | //$last_exec['deltadbtxt'] = 0; |
122 | 122 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
123 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
123 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
124 | 124 | //$formats[$id] = 'vatsimtxt'; |
125 | 125 | $globalSources[$id]['format'] = 'vatsimtxt'; |
126 | 126 | //$last_exec['vatsimtxt'] = 0; |
127 | 127 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
128 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
128 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
129 | 129 | //$formats[$id] = 'aircraftlistjson'; |
130 | 130 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
131 | 131 | //$last_exec['aircraftlistjson'] = 0; |
132 | 132 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
133 | - } else if (preg_match('/opensky/i',$host)) { |
|
133 | + } else if (preg_match('/opensky/i', $host)) { |
|
134 | 134 | //$formats[$id] = 'aircraftlistjson'; |
135 | 135 | $globalSources[$id]['format'] = 'opensky'; |
136 | 136 | //$last_exec['aircraftlistjson'] = 0; |
137 | 137 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
138 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
138 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
139 | 139 | //$formats[$id] = 'radarvirtueljson'; |
140 | 140 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
141 | 141 | //$last_exec['radarvirtueljson'] = 0; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
145 | 145 | exit(0); |
146 | 146 | } |
147 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
147 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
148 | 148 | //$formats[$id] = 'planeupdatefaa'; |
149 | 149 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
150 | 150 | //$last_exec['planeupdatefaa'] = 0; |
@@ -153,26 +153,26 @@ discard block |
||
153 | 153 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
154 | 154 | exit(0); |
155 | 155 | } |
156 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
156 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
157 | 157 | //$formats[$id] = 'phpvmacars'; |
158 | 158 | $globalSources[$id]['format'] = 'phpvmacars'; |
159 | 159 | //$last_exec['phpvmacars'] = 0; |
160 | 160 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
161 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
161 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
162 | 162 | //$formats[$id] = 'phpvmacars'; |
163 | 163 | $globalSources[$id]['format'] = 'vam'; |
164 | 164 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
165 | - } else if (preg_match('/whazzup/i',$host)) { |
|
165 | + } else if (preg_match('/whazzup/i', $host)) { |
|
166 | 166 | //$formats[$id] = 'whazzup'; |
167 | 167 | $globalSources[$id]['format'] = 'whazzup'; |
168 | 168 | //$last_exec['whazzup'] = 0; |
169 | 169 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
170 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
170 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
171 | 171 | //$formats[$id] = 'pirepsjson'; |
172 | 172 | $globalSources[$id]['format'] = 'pirepsjson'; |
173 | 173 | //$last_exec['pirepsjson'] = 0; |
174 | 174 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
175 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
175 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
176 | 176 | //$formats[$id] = 'fr24json'; |
177 | 177 | $globalSources[$id]['format'] = 'fr24json'; |
178 | 178 | //$last_exec['fr24json'] = 0; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
182 | 182 | exit(0); |
183 | 183 | } |
184 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
184 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
185 | 185 | //$formats[$id] = 'fr24json'; |
186 | 186 | $globalSources[$id]['format'] = 'myshiptracking'; |
187 | 187 | //$last_exec['fr24json'] = 0; |
@@ -191,22 +191,22 @@ discard block |
||
191 | 191 | exit(0); |
192 | 192 | } |
193 | 193 | //} else if (preg_match('/10001/',$host)) { |
194 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
194 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
195 | 195 | //$formats[$id] = 'tsv'; |
196 | 196 | $globalSources[$id]['format'] = 'tsv'; |
197 | 197 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
198 | 198 | } |
199 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
199 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
200 | 200 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
201 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
201 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
202 | 202 | if ($idf !== false) { |
203 | 203 | $httpfeeds[$id] = $idf; |
204 | 204 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
205 | 205 | } |
206 | 206 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
207 | 207 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
208 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
209 | - $hostport = explode(':',$host); |
|
208 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
209 | + $hostport = explode(':', $host); |
|
210 | 210 | if (isset($hostport[1])) { |
211 | 211 | $port = $hostport[1]; |
212 | 212 | $hostn = $hostport[0]; |
@@ -216,19 +216,19 @@ discard block |
||
216 | 216 | } |
217 | 217 | $Common = new Common(); |
218 | 218 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
219 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
219 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
220 | 220 | } else { |
221 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
221 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
222 | 222 | } |
223 | 223 | if ($s) { |
224 | 224 | $sockets[$id] = $s; |
225 | 225 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
226 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
226 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
227 | 227 | //$formats[$id] = 'aprs'; |
228 | 228 | $globalSources[$id]['format'] = 'aprs'; |
229 | 229 | //$aprs_connect = 0; |
230 | 230 | //$use_aprs = true; |
231 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
231 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
232 | 232 | $globalSources[$id]['format'] = 'vrstcp'; |
233 | 233 | } elseif ($port == '10001') { |
234 | 234 | //$formats[$id] = 'tsv'; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
268 | 268 | else $timeout = 20; |
269 | 269 | $errno = ''; |
270 | -$errstr=''; |
|
270 | +$errstr = ''; |
|
271 | 271 | |
272 | 272 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
273 | 273 | /* Initiate connections to all the hosts simultaneously */ |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | //connect_all($globalSources); |
276 | 276 | |
277 | 277 | if (isset($globalProxy) && $globalProxy) { |
278 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
278 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
279 | 279 | } else { |
280 | 280 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
281 | 281 | } |
@@ -302,16 +302,16 @@ discard block |
||
302 | 302 | |
303 | 303 | if ($use_aprs) { |
304 | 304 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
305 | - $APRS=new APRS(); |
|
305 | + $APRS = new APRS(); |
|
306 | 306 | $aprs_connect = 0; |
307 | 307 | $aprs_keep = 120; |
308 | 308 | $aprs_last_tx = time(); |
309 | 309 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
310 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
310 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
311 | 311 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
312 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
312 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
313 | 313 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
314 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
314 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
315 | 315 | if ($aprs_full) $aprs_filter = ''; |
316 | 316 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
317 | 317 | else $aprs_pass = '-1'; |
@@ -325,12 +325,12 @@ discard block |
||
325 | 325 | sleep(1); |
326 | 326 | if ($globalDebug) echo "SCAN MODE \n\n"; |
327 | 327 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
328 | -$endtime = time()+$globalCronEnd; |
|
328 | +$endtime = time() + $globalCronEnd; |
|
329 | 329 | $i = 1; |
330 | 330 | $tt = array(); |
331 | 331 | // Delete all ATC |
332 | 332 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
333 | - $ATC=new ATC($Connection->db); |
|
333 | + $ATC = new ATC($Connection->db); |
|
334 | 334 | } |
335 | 335 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
336 | 336 | $ATC->deleteAll(); |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
340 | 340 | while ($i > 0) { |
341 | - if (!$globalDaemon) $i = $endtime-time(); |
|
341 | + if (!$globalDaemon) $i = $endtime - time(); |
|
342 | 342 | // Delete old ATC |
343 | 343 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
344 | 344 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | if ($max != $globalMinFetch) { |
355 | 355 | if ($globalDebug) echo 'Sleeping...'."\n"; |
356 | - sleep($globalMinFetch-$max+2); |
|
356 | + sleep($globalMinFetch - $max + 2); |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | //$buffer = $Common->getData($hosts[$id]); |
367 | 367 | $buffer = $Common->getData($value['host']); |
368 | 368 | if ($buffer != '') $reset = 0; |
369 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
370 | - $buffer = explode('\n',$buffer); |
|
369 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
370 | + $buffer = explode('\n', $buffer); |
|
371 | 371 | foreach ($buffer as $line) { |
372 | 372 | if ($line != '' && count($line) > 7) { |
373 | 373 | $line = explode(',', $line); |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | $last_exec[$id]['last'] = time(); |
395 | 395 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
396 | 396 | date_default_timezone_set('CET'); |
397 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
397 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
398 | 398 | date_default_timezone_set('UTC'); |
399 | 399 | if ($buffer != '') $reset = 0; |
400 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
401 | - $buffer = explode('\n',$buffer); |
|
400 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
401 | + $buffer = explode('\n', $buffer); |
|
402 | 402 | foreach ($buffer as $line) { |
403 | 403 | if ($line != '') { |
404 | 404 | echo "'".$line."'\n"; |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
417 | 417 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
418 | 418 | if (isset($ais_data['timestamp'])) { |
419 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
419 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
420 | 420 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
421 | 421 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
422 | 422 | $add = true; |
@@ -439,12 +439,12 @@ discard block |
||
439 | 439 | $w = $e = null; |
440 | 440 | |
441 | 441 | if (isset($arr[$id])) { |
442 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
442 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
443 | 443 | if ($nn > 0) { |
444 | 444 | foreach ($httpfeeds as $feed) { |
445 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
446 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
447 | - $buffer = explode('\n',$buffer); |
|
445 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
446 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
447 | + $buffer = explode('\n', $buffer); |
|
448 | 448 | foreach ($buffer as $line) { |
449 | 449 | if ($line != '') { |
450 | 450 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -460,9 +460,9 @@ discard block |
||
460 | 460 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
461 | 461 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
462 | 462 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
463 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
463 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
464 | 464 | if (isset($ais_data['timestamp'])) { |
465 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
465 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
466 | 466 | } else { |
467 | 467 | $data['datetime'] = date('Y-m-d H:i:s'); |
468 | 468 | } |
@@ -476,10 +476,10 @@ discard block |
||
476 | 476 | } |
477 | 477 | } |
478 | 478 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
479 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
479 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
480 | 480 | if ($buffer != '') { |
481 | 481 | //echo $buffer; |
482 | - $all_data = json_decode($buffer,true); |
|
482 | + $all_data = json_decode($buffer, true); |
|
483 | 483 | //print_r($all_data); |
484 | 484 | if (isset($all_data[0]['DATA'])) { |
485 | 485 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
495 | 495 | $data['imo'] = $line['IMO']; |
496 | 496 | //$data['arrival_code'] = $ais_data['destination']; |
497 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
497 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
498 | 498 | $data['format_source'] = 'myshiptracking'; |
499 | 499 | $data['id_source'] = $id_source; |
500 | 500 | $MI->add($data); |
@@ -506,9 +506,9 @@ discard block |
||
506 | 506 | } |
507 | 507 | $last_exec[$id]['last'] = time(); |
508 | 508 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
509 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
509 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
510 | 510 | if ($buffer != '') { |
511 | - $all_data = json_decode($buffer,true); |
|
511 | + $all_data = json_decode($buffer, true); |
|
512 | 512 | if (isset($all_data[0]['mmsi'])) { |
513 | 513 | foreach ($all_data as $line) { |
514 | 514 | if ($line != '') { |
@@ -535,27 +535,27 @@ discard block |
||
535 | 535 | $last_exec[$id]['last'] = time(); |
536 | 536 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
537 | 537 | echo 'download...'; |
538 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
538 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
539 | 539 | echo 'done !'."\n"; |
540 | 540 | if ($buffer != '') $reset = 0; |
541 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
542 | - $buffer = explode('\n',$buffer); |
|
541 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
542 | + $buffer = explode('\n', $buffer); |
|
543 | 543 | foreach ($buffer as $line) { |
544 | 544 | if ($line != '') { |
545 | 545 | $data = array(); |
546 | - $data['mmsi'] = (int)substr($line,0,9); |
|
547 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
546 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
547 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
548 | 548 | //$data['status'] = substr($line,21,2); |
549 | 549 | //$data['type'] = substr($line,24,3); |
550 | - $data['latitude'] = substr($line,29,9); |
|
551 | - $data['longitude'] = substr($line,41,9); |
|
552 | - $data['speed'] = round(substr($line,51,5)); |
|
550 | + $data['latitude'] = substr($line, 29, 9); |
|
551 | + $data['longitude'] = substr($line, 41, 9); |
|
552 | + $data['speed'] = round(substr($line, 51, 5)); |
|
553 | 553 | //$data['course'] = substr($line,57,5); |
554 | - $data['heading'] = round(substr($line,63,3)); |
|
554 | + $data['heading'] = round(substr($line, 63, 3)); |
|
555 | 555 | //$data['draft'] = substr($line,67,4); |
556 | 556 | //$data['length'] = substr($line,72,3); |
557 | 557 | //$data['beam'] = substr($line,76,2); |
558 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
558 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
559 | 559 | //$data['callsign'] = trim(substr($line,100,7); |
560 | 560 | //$data['dest'] = substr($line,108,20); |
561 | 561 | //$data['etaDate'] = substr($line,129,5); |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
574 | 574 | //$buffer = $Common->getData($hosts[$id]); |
575 | 575 | $buffer = $Common->getData($value['host']); |
576 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
577 | - $buffer = explode('\n',$buffer); |
|
576 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
577 | + $buffer = explode('\n', $buffer); |
|
578 | 578 | $reset = 0; |
579 | 579 | foreach ($buffer as $line) { |
580 | 580 | if ($line != '') { |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
586 | 586 | $data['pilot_id'] = $line[1]; |
587 | 587 | $data['pilot_name'] = $line[2]; |
588 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
588 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
589 | 589 | $data['ident'] = $line[0]; // ident |
590 | 590 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
591 | 591 | $data['speed'] = $line[8]; // speed |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
602 | 602 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
603 | 603 | $data['departure_airport_icao'] = $line[11]; |
604 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
604 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
605 | 605 | $data['arrival_airport_icao'] = $line[13]; |
606 | 606 | $data['frequency'] = $line[4]; |
607 | 607 | $data['type'] = $line[18]; |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | $data['id_source'] = $id_source; |
611 | 611 | //$data['arrival_airport_time'] = ; |
612 | 612 | if ($line[9] != '') { |
613 | - $aircraft_data = explode('/',$line[9]); |
|
613 | + $aircraft_data = explode('/', $line[9]); |
|
614 | 614 | if (isset($aircraft_data[1])) { |
615 | 615 | $data['aircraft_icao'] = $aircraft_data[1]; |
616 | 616 | } |
@@ -624,9 +624,9 @@ discard block |
||
624 | 624 | if ($line[3] == 'PILOT') $SI->add($data); |
625 | 625 | elseif ($line[3] == 'ATC') { |
626 | 626 | //print_r($data); |
627 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
628 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
629 | - $typec = substr($data['ident'],-3); |
|
627 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
628 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
629 | + $typec = substr($data['ident'], -3); |
|
630 | 630 | if ($typec == 'APP') $data['type'] = 'Approach'; |
631 | 631 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
632 | 632 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
638 | 638 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
639 | 639 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
640 | - if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
640 | + if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
641 | 641 | } |
642 | 642 | unset($data); |
643 | 643 | } |
@@ -648,9 +648,9 @@ discard block |
||
648 | 648 | $last_exec[$id]['last'] = time(); |
649 | 649 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
650 | 650 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
651 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
651 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
652 | 652 | if ($buffer != '') { |
653 | - $all_data = json_decode($buffer,true); |
|
653 | + $all_data = json_decode($buffer, true); |
|
654 | 654 | if (isset($all_data['acList'])) { |
655 | 655 | $reset = 0; |
656 | 656 | foreach ($all_data['acList'] as $line) { |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
707 | 707 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
708 | 708 | $buffer = $Common->getData($value['host']); |
709 | - $all_data = json_decode($buffer,true); |
|
709 | + $all_data = json_decode($buffer, true); |
|
710 | 710 | if (isset($all_data['planes'])) { |
711 | 711 | $reset = 0; |
712 | 712 | foreach ($all_data['planes'] as $key => $line) { |
@@ -723,12 +723,12 @@ discard block |
||
723 | 723 | $data['emergency'] = ''; // emergency |
724 | 724 | $data['registration'] = $line[2]; |
725 | 725 | $data['aircraft_icao'] = $line[0]; |
726 | - $deparr = explode('-',$line[1]); |
|
726 | + $deparr = explode('-', $line[1]); |
|
727 | 727 | if (count($deparr) == 2) { |
728 | 728 | $data['departure_airport_icao'] = $deparr[0]; |
729 | 729 | $data['arrival_airport_icao'] = $deparr[1]; |
730 | 730 | } |
731 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
731 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
732 | 732 | $data['format_source'] = 'planeupdatefaa'; |
733 | 733 | $data['id_source'] = $id_source; |
734 | 734 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | $last_exec[$id]['last'] = time(); |
741 | 741 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
742 | 742 | $buffer = $Common->getData($value['host']); |
743 | - $all_data = json_decode($buffer,true); |
|
743 | + $all_data = json_decode($buffer, true); |
|
744 | 744 | if (isset($all_data['states'])) { |
745 | 745 | $reset = 0; |
746 | 746 | foreach ($all_data['states'] as $key => $line) { |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | //$data['emergency'] = ''; // emergency |
758 | 758 | //$data['registration'] = $line[2]; |
759 | 759 | //$data['aircraft_icao'] = $line[0]; |
760 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
760 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
761 | 761 | $data['format_source'] = 'opensky'; |
762 | 762 | $data['id_source'] = $id_source; |
763 | 763 | $SI->add($data); |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
771 | 771 | //$buffer = $Common->getData($hosts[$id]); |
772 | 772 | $buffer = $Common->getData($value['host']); |
773 | - $all_data = json_decode($buffer,true); |
|
773 | + $all_data = json_decode($buffer, true); |
|
774 | 774 | if (!empty($all_data)) $reset = 0; |
775 | 775 | foreach ($all_data as $key => $line) { |
776 | 776 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -802,11 +802,11 @@ discard block |
||
802 | 802 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
803 | 803 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
804 | 804 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
805 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
805 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
806 | 806 | //echo $buffer; |
807 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
808 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
809 | - $all_data = json_decode($buffer,true); |
|
807 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
808 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
809 | + $all_data = json_decode($buffer, true); |
|
810 | 810 | if (json_last_error() != JSON_ERROR_NONE) { |
811 | 811 | die(json_last_error_msg()); |
812 | 812 | } |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | //$data['departure_airport_iata'] = $line[11]; |
830 | 830 | //$data['arrival_airport_iata'] = $line[12]; |
831 | 831 | //$data['emergency'] = ''; // emergency |
832 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
832 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
833 | 833 | $data['format_source'] = 'radarvirtueljson'; |
834 | 834 | $data['id_source'] = $id_source; |
835 | 835 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -844,14 +844,14 @@ discard block |
||
844 | 844 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
845 | 845 | //$buffer = $Common->getData($hosts[$id]); |
846 | 846 | $buffer = $Common->getData($value['host'].'?'.time()); |
847 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
847 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
848 | 848 | |
849 | 849 | if (isset($all_data['pireps'])) { |
850 | 850 | $reset = 0; |
851 | 851 | foreach ($all_data['pireps'] as $line) { |
852 | 852 | $data = array(); |
853 | 853 | $data['id'] = $line['id']; |
854 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
854 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
855 | 855 | $data['ident'] = $line['callsign']; // ident |
856 | 856 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
857 | 857 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -880,9 +880,9 @@ discard block |
||
880 | 880 | $SI->add($data); |
881 | 881 | // print_r($data); |
882 | 882 | } elseif ($line['icon'] == 'ct') { |
883 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
884 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
885 | - $typec = substr($data['ident'],-3); |
|
883 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
884 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
885 | + $typec = substr($data['ident'], -3); |
|
886 | 886 | $data['type'] = ''; |
887 | 887 | if ($typec == 'APP') $data['type'] = 'Approach'; |
888 | 888 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
894 | 894 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
895 | 895 | else $data['type'] = 'Observer'; |
896 | - 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']); |
|
896 | + 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']); |
|
897 | 897 | } |
898 | 898 | unset($data); |
899 | 899 | } |
@@ -905,14 +905,14 @@ discard block |
||
905 | 905 | //$buffer = $Common->getData($hosts[$id]); |
906 | 906 | if ($globalDebug) echo 'Get Data...'."\n"; |
907 | 907 | $buffer = $Common->getData($value['host']); |
908 | - $all_data = json_decode($buffer,true); |
|
908 | + $all_data = json_decode($buffer, true); |
|
909 | 909 | if ($buffer != '' && is_array($all_data)) { |
910 | 910 | $reset = 0; |
911 | 911 | foreach ($all_data as $line) { |
912 | 912 | $data = array(); |
913 | 913 | //$data['id'] = $line['id']; // id not usable |
914 | 914 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
915 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
915 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
916 | 916 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
917 | 917 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
918 | 918 | $data['ident'] = $line['flightnum']; // ident |
@@ -935,14 +935,14 @@ discard block |
||
935 | 935 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
936 | 936 | if (isset($line['aircraftname'])) { |
937 | 937 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
938 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
939 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
938 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
939 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
940 | 940 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
941 | 941 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
942 | 942 | else { |
943 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
944 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
945 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
943 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
944 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
945 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
946 | 946 | } |
947 | 947 | } |
948 | 948 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -962,14 +962,14 @@ discard block |
||
962 | 962 | //$buffer = $Common->getData($hosts[$id]); |
963 | 963 | if ($globalDebug) echo 'Get Data...'."\n"; |
964 | 964 | $buffer = $Common->getData($value['host']); |
965 | - $all_data = json_decode($buffer,true); |
|
965 | + $all_data = json_decode($buffer, true); |
|
966 | 966 | if ($buffer != '' && is_array($all_data)) { |
967 | 967 | $reset = 0; |
968 | 968 | foreach ($all_data as $line) { |
969 | 969 | $data = array(); |
970 | 970 | //$data['id'] = $line['id']; // id not usable |
971 | 971 | $data['id'] = trim($line['flight_id']); |
972 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
972 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
973 | 973 | $data['pilot_name'] = $line['pilot_name']; |
974 | 974 | $data['pilot_id'] = $line['pilot_id']; |
975 | 975 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1020,11 +1020,11 @@ discard block |
||
1020 | 1020 | //$value = $formats[$nb]; |
1021 | 1021 | $format = $globalSources[$nb]['format']; |
1022 | 1022 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1023 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1023 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1024 | 1024 | } elseif ($format == 'vrstcp') { |
1025 | 1025 | $buffer = @socket_read($r, 6000); |
1026 | 1026 | } else { |
1027 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1027 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1028 | 1028 | } |
1029 | 1029 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1030 | 1030 | //echo $buffer."\n"; |
@@ -1033,8 +1033,8 @@ discard block |
||
1033 | 1033 | $error = false; |
1034 | 1034 | //$SI::del(); |
1035 | 1035 | if ($format == 'vrstcp') { |
1036 | - $buffer = explode('},{',$buffer); |
|
1037 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1036 | + $buffer = explode('},{', $buffer); |
|
1037 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1038 | 1038 | // SBS format is CSV format |
1039 | 1039 | if ($buffer !== FALSE && $buffer != '') { |
1040 | 1040 | $tt[$format] = 0; |
@@ -1066,10 +1066,10 @@ discard block |
||
1066 | 1066 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1067 | 1067 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1068 | 1068 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1069 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1069 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1070 | 1070 | |
1071 | 1071 | if (isset($ais_data['timestamp'])) { |
1072 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1072 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1073 | 1073 | } else { |
1074 | 1074 | $data['datetime'] = date('Y-m-d H:i:s'); |
1075 | 1075 | } |
@@ -1080,10 +1080,10 @@ discard block |
||
1080 | 1080 | } elseif ($format == 'flightgearsp') { |
1081 | 1081 | //echo $buffer."\n"; |
1082 | 1082 | if (strlen($buffer) > 5) { |
1083 | - $line = explode(',',$buffer); |
|
1083 | + $line = explode(',', $buffer); |
|
1084 | 1084 | $data = array(); |
1085 | 1085 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1086 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1086 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1087 | 1087 | $data['ident'] = $line[6]; |
1088 | 1088 | $data['aircraft_name'] = $line[7]; |
1089 | 1089 | $data['longitude'] = $line[1]; |
@@ -1094,21 +1094,21 @@ discard block |
||
1094 | 1094 | $data['datetime'] = date('Y-m-d H:i:s'); |
1095 | 1095 | $data['format_source'] = 'flightgearsp'; |
1096 | 1096 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1097 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1097 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1098 | 1098 | } |
1099 | 1099 | } elseif ($format == 'acars') { |
1100 | 1100 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1101 | 1101 | $ACARS->add(trim($buffer)); |
1102 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1102 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1103 | 1103 | $ACARS->deleteLiveAcarsData(); |
1104 | 1104 | } elseif ($format == 'flightgearmp') { |
1105 | - if (substr($buffer,0,1) != '#') { |
|
1105 | + if (substr($buffer, 0, 1) != '#') { |
|
1106 | 1106 | $data = array(); |
1107 | 1107 | //echo $buffer."\n"; |
1108 | - $line = explode(' ',$buffer); |
|
1108 | + $line = explode(' ', $buffer); |
|
1109 | 1109 | if (count($line) == 11) { |
1110 | - $userserver = explode('@',$line[0]); |
|
1111 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1110 | + $userserver = explode('@', $line[0]); |
|
1111 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1112 | 1112 | $data['ident'] = $userserver[0]; |
1113 | 1113 | $data['registration'] = $userserver[0]; |
1114 | 1114 | $data['latitude'] = $line[4]; |
@@ -1116,8 +1116,8 @@ discard block |
||
1116 | 1116 | $data['altitude'] = $line[6]; |
1117 | 1117 | $data['datetime'] = date('Y-m-d H:i:s'); |
1118 | 1118 | $aircraft_type = $line[10]; |
1119 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1120 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1119 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1120 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1121 | 1121 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1122 | 1122 | } |
1123 | 1123 | } |
@@ -1125,8 +1125,8 @@ discard block |
||
1125 | 1125 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1126 | 1126 | die; |
1127 | 1127 | } elseif ($format == 'vrstcp') { |
1128 | - foreach($buffer as $all_data) { |
|
1129 | - $line = json_decode('{'.$all_data.'}',true); |
|
1128 | + foreach ($buffer as $all_data) { |
|
1129 | + $line = json_decode('{'.$all_data.'}', true); |
|
1130 | 1130 | $data = array(); |
1131 | 1131 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1132 | 1132 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1151,16 +1151,16 @@ discard block |
||
1151 | 1151 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1152 | 1152 | unset($data); |
1153 | 1153 | } |
1154 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1154 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1155 | 1155 | $line = explode("\t", $buffer); |
1156 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1156 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1157 | 1157 | $key = $line[$k]; |
1158 | - $lined[$key] = $line[$k+1]; |
|
1158 | + $lined[$key] = $line[$k + 1]; |
|
1159 | 1159 | } |
1160 | 1160 | if (count($lined) > 3) { |
1161 | 1161 | $data['hex'] = $lined['hexid']; |
1162 | 1162 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1163 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1163 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1164 | 1164 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1165 | 1165 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1166 | 1166 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1178,22 +1178,22 @@ discard block |
||
1178 | 1178 | } else $error = true; |
1179 | 1179 | } elseif ($format == 'aprs' && $use_aprs) { |
1180 | 1180 | if ($aprs_connect == 0) { |
1181 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1181 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1182 | 1182 | $aprs_connect = 1; |
1183 | 1183 | } |
1184 | 1184 | |
1185 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1185 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1186 | 1186 | $aprs_last_tx = time(); |
1187 | 1187 | $data_aprs = "# Keep alive"; |
1188 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1188 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1192 | 1192 | //echo 'APRS data : '.$buffer."\n"; |
1193 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1194 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1193 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1194 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1195 | 1195 | //echo $buffer."\n"; |
1196 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1196 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1197 | 1197 | $line = $APRS->parse($buffer); |
1198 | 1198 | //print_r($line); |
1199 | 1199 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | $data = array(); |
1203 | 1203 | //print_r($line); |
1204 | 1204 | if (isset($line['address'])) $data['hex'] = $line['address']; |
1205 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1205 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1206 | 1206 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1207 | 1207 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1208 | 1208 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | $currentdate = date('Y-m-d H:i:s'); |
1229 | 1229 | $aprsdate = strtotime($data['datetime']); |
1230 | 1230 | // Accept data if time <= system time + 20s |
1231 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1231 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1232 | 1232 | $send = $SI->add($data); |
1233 | 1233 | } elseif (isset($line['stealth'])) { |
1234 | 1234 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
@@ -1325,7 +1325,7 @@ discard block |
||
1325 | 1325 | connect_all($sourceee); |
1326 | 1326 | $sourceee = array(); |
1327 | 1327 | //connect_all($globalSources); |
1328 | - $tt[$format]=0; |
|
1328 | + $tt[$format] = 0; |
|
1329 | 1329 | break; |
1330 | 1330 | } |
1331 | 1331 | } |
@@ -1334,14 +1334,14 @@ discard block |
||
1334 | 1334 | } else { |
1335 | 1335 | $error = socket_strerror(socket_last_error()); |
1336 | 1336 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1337 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1337 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1338 | 1338 | if (isset($globalDebug)) echo "Restarting...\n"; |
1339 | 1339 | // Restart the script if possible |
1340 | 1340 | if (is_array($sockets)) { |
1341 | 1341 | if ($globalDebug) echo "Shutdown all sockets..."; |
1342 | 1342 | |
1343 | 1343 | foreach ($sockets as $sock) { |
1344 | - @socket_shutdown($sock,2); |
|
1344 | + @socket_shutdown($sock, 2); |
|
1345 | 1345 | @socket_close($sock); |
1346 | 1346 | } |
1347 | 1347 |