@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | $Source = new Source(); |
6 | 6 | |
7 | 7 | if (isset($_GET['sourceid'])) { |
8 | - $sourceid = filter_input(INPUT_GET,'sourceid',FILTER_SANITIZE_NUMBER_INT); |
|
8 | + $sourceid = filter_input(INPUT_GET, 'sourceid', FILTER_SANITIZE_NUMBER_INT); |
|
9 | 9 | $source_data = $Source->getLocationInfoById($sourceid); |
10 | 10 | if (isset($source_data[0])) { |
11 | 11 | ?> |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | print '</div>'; |
35 | 35 | |
36 | 36 | if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>'; |
37 | -if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; |
|
38 | -print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>'; |
|
37 | +if ($spotter_item['country'] != '') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; |
|
38 | +print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'], 3).', '.round($spotter_item['longitude'], 3).'</div>'; |
|
39 | 39 | /* |
40 | 40 | if ($spotter_item['atc_range'] > 0) { |
41 | 41 | print '<div><span>'._("Range").'</span>'; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | */ |
46 | 46 | if ($spotter_item['type'] == 'wx') { |
47 | - $weather = json_decode($spotter_item['description'],true); |
|
47 | + $weather = json_decode($spotter_item['description'], true); |
|
48 | 48 | //print_r($weather); |
49 | 49 | if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>'; |
50 | 50 | if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'°hPa</div>'; |
@@ -46,20 +46,20 @@ discard block |
||
46 | 46 | die; |
47 | 47 | } |
48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
49 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
49 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
|
53 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver')); |
|
54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); |
55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
56 | 56 | if (isset($options['s'])) { |
57 | 57 | $globalSources = array(); |
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
59 | 59 | else $globalSources[] = array('host' => $options['s']); |
60 | 60 | } elseif (isset($options['source'])) { |
61 | 61 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
63 | 63 | else $globalSources[] = array('host' => $options['source']); |
64 | 64 | } |
65 | 65 | if (isset($options['aprsserverhost'])) { |
@@ -76,28 +76,28 @@ discard block |
||
76 | 76 | else $id_source = 1; |
77 | 77 | if (isset($globalServer) && $globalServer) { |
78 | 78 | if ($globalDebug) echo "Using Server Mode\n"; |
79 | - $SI=new SpotterServer(); |
|
79 | + $SI = new SpotterServer(); |
|
80 | 80 | /* |
81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 82 | $SI = new adsb2aprs(); |
83 | 83 | $SI->connect(); |
84 | 84 | */ |
85 | -} else $SI=new SpotterImport($Connection->db); |
|
85 | +} else $SI = new SpotterImport($Connection->db); |
|
86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
87 | 87 | if (isset($globalMarine) && $globalMarine) { |
88 | 88 | $AIS = new AIS(); |
89 | 89 | $MI = new MarineImport($Connection->db); |
90 | 90 | } |
91 | 91 | //$APRS=new APRS($Connection->db); |
92 | -$SBS=new SBS(); |
|
93 | -$ACARS=new ACARS($Connection->db); |
|
94 | -$Source=new Source($Connection->db); |
|
95 | -$Common=new Common(); |
|
92 | +$SBS = new SBS(); |
|
93 | +$ACARS = new ACARS($Connection->db); |
|
94 | +$Source = new Source($Connection->db); |
|
95 | +$Common = new Common(); |
|
96 | 96 | date_default_timezone_set('UTC'); |
97 | 97 | //$servertz = system('date +%Z'); |
98 | 98 | // signal handler - playing nice with sockets and dump1090 |
99 | 99 | if (function_exists('pcntl_fork')) { |
100 | - pcntl_signal(SIGINT, function() { |
|
100 | + pcntl_signal(SIGINT, function() { |
|
101 | 101 | global $sockets; |
102 | 102 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
103 | 103 | die("Bye!\n"); |
@@ -113,30 +113,30 @@ discard block |
||
113 | 113 | |
114 | 114 | function connect_all($hosts) { |
115 | 115 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
116 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
117 | 117 | $reset++; |
118 | 118 | if ($globalDebug) echo 'Connect to all...'."\n"; |
119 | 119 | foreach ($hosts as $id => $value) { |
120 | 120 | $host = $value['host']; |
121 | 121 | $globalSources[$id]['last_exec'] = 0; |
122 | 122 | // Here we check type of source(s) |
123 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
124 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
125 | 125 | //$formats[$id] = 'deltadbtxt'; |
126 | 126 | $globalSources[$id]['format'] = 'deltadbtxt'; |
127 | 127 | //$last_exec['deltadbtxt'] = 0; |
128 | 128 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
129 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
130 | 130 | //$formats[$id] = 'vatsimtxt'; |
131 | 131 | $globalSources[$id]['format'] = 'vatsimtxt'; |
132 | 132 | //$last_exec['vatsimtxt'] = 0; |
133 | 133 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
134 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
135 | 135 | //$formats[$id] = 'aircraftlistjson'; |
136 | 136 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
137 | 137 | //$last_exec['aircraftlistjson'] = 0; |
138 | 138 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
139 | - } else if (preg_match('/opensky/i',$host)) { |
|
139 | + } else if (preg_match('/opensky/i', $host)) { |
|
140 | 140 | //$formats[$id] = 'aircraftlistjson'; |
141 | 141 | $globalSources[$id]['format'] = 'opensky'; |
142 | 142 | //$last_exec['aircraftlistjson'] = 0; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | exit(0); |
154 | 154 | } |
155 | 155 | */ |
156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
156 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
157 | 157 | //$formats[$id] = 'planeupdatefaa'; |
158 | 158 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
159 | 159 | //$last_exec['planeupdatefaa'] = 0; |
@@ -162,29 +162,29 @@ discard block |
||
162 | 162 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
163 | 163 | exit(0); |
164 | 164 | } |
165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
165 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
166 | 166 | //$formats[$id] = 'phpvmacars'; |
167 | 167 | $globalSources[$id]['format'] = 'phpvmacars'; |
168 | 168 | //$last_exec['phpvmacars'] = 0; |
169 | 169 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
170 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
171 | 171 | //$formats[$id] = 'phpvmacars'; |
172 | 172 | $globalSources[$id]['format'] = 'vam'; |
173 | 173 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
174 | + } else if (preg_match('/whazzup/i', $host)) { |
|
175 | 175 | //$formats[$id] = 'whazzup'; |
176 | 176 | $globalSources[$id]['format'] = 'whazzup'; |
177 | 177 | //$last_exec['whazzup'] = 0; |
178 | 178 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
179 | - } else if (preg_match('/airwhere/i',$host)) { |
|
179 | + } else if (preg_match('/airwhere/i', $host)) { |
|
180 | 180 | $globalSources[$id]['format'] = 'airwhere'; |
181 | 181 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
182 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
182 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
183 | 183 | //$formats[$id] = 'pirepsjson'; |
184 | 184 | $globalSources[$id]['format'] = 'pirepsjson'; |
185 | 185 | //$last_exec['pirepsjson'] = 0; |
186 | 186 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
187 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
187 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
188 | 188 | //$formats[$id] = 'fr24json'; |
189 | 189 | $globalSources[$id]['format'] = 'fr24json'; |
190 | 190 | //$last_exec['fr24json'] = 0; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
194 | 194 | exit(0); |
195 | 195 | } |
196 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
196 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
197 | 197 | //$formats[$id] = 'fr24json'; |
198 | 198 | $globalSources[$id]['format'] = 'myshiptracking'; |
199 | 199 | //$last_exec['fr24json'] = 0; |
@@ -203,22 +203,22 @@ discard block |
||
203 | 203 | exit(0); |
204 | 204 | } |
205 | 205 | //} else if (preg_match('/10001/',$host)) { |
206 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
206 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
207 | 207 | //$formats[$id] = 'tsv'; |
208 | 208 | $globalSources[$id]['format'] = 'tsv'; |
209 | 209 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
210 | 210 | } |
211 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
211 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
212 | 212 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
213 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
213 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
214 | 214 | if ($idf !== false) { |
215 | 215 | $httpfeeds[$id] = $idf; |
216 | 216 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
217 | 217 | } |
218 | 218 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
219 | 219 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
220 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
221 | - $hostport = explode(':',$host); |
|
220 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
221 | + $hostport = explode(':', $host); |
|
222 | 222 | if (isset($hostport[1])) { |
223 | 223 | $port = $hostport[1]; |
224 | 224 | $hostn = $hostport[0]; |
@@ -228,19 +228,19 @@ discard block |
||
228 | 228 | } |
229 | 229 | $Common = new Common(); |
230 | 230 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
231 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
231 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
232 | 232 | } else { |
233 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
233 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
234 | 234 | } |
235 | 235 | if ($s) { |
236 | 236 | $sockets[$id] = $s; |
237 | 237 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
238 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
238 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
239 | 239 | //$formats[$id] = 'aprs'; |
240 | 240 | $globalSources[$id]['format'] = 'aprs'; |
241 | 241 | //$aprs_connect = 0; |
242 | 242 | //$use_aprs = true; |
243 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
243 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
244 | 244 | $globalSources[$id]['format'] = 'vrstcp'; |
245 | 245 | } elseif ($port == '10001') { |
246 | 246 | //$formats[$id] = 'tsv'; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
280 | 280 | else $timeout = 20; |
281 | 281 | $errno = ''; |
282 | -$errstr=''; |
|
282 | +$errstr = ''; |
|
283 | 283 | |
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | /* Initiate connections to all the hosts simultaneously */ |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | //connect_all($globalSources); |
288 | 288 | |
289 | 289 | if (isset($globalProxy) && $globalProxy) { |
290 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
290 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
291 | 291 | } else { |
292 | 292 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
293 | 293 | } |
@@ -317,16 +317,16 @@ discard block |
||
317 | 317 | |
318 | 318 | if ($use_aprs) { |
319 | 319 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
320 | - $APRS=new APRS(); |
|
320 | + $APRS = new APRS(); |
|
321 | 321 | $aprs_connect = 0; |
322 | 322 | $aprs_keep = 120; |
323 | 323 | $aprs_last_tx = time(); |
324 | 324 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
325 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
325 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
326 | 326 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
327 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
327 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
328 | 328 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
329 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
329 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
330 | 330 | if ($aprs_full) $aprs_filter = ''; |
331 | 331 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
332 | 332 | else $aprs_pass = '-1'; |
@@ -340,12 +340,12 @@ discard block |
||
340 | 340 | sleep(1); |
341 | 341 | if ($globalDebug) echo "SCAN MODE \n\n"; |
342 | 342 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
343 | -$endtime = time()+$globalCronEnd; |
|
343 | +$endtime = time() + $globalCronEnd; |
|
344 | 344 | $i = 1; |
345 | 345 | $tt = array(); |
346 | 346 | // Delete all ATC |
347 | 347 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
348 | - $ATC=new ATC($Connection->db); |
|
348 | + $ATC = new ATC($Connection->db); |
|
349 | 349 | } |
350 | 350 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
351 | 351 | $ATC->deleteAll(); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | |
354 | 354 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
355 | 355 | while ($i > 0) { |
356 | - if (!$globalDaemon) $i = $endtime-time(); |
|
356 | + if (!$globalDaemon) $i = $endtime - time(); |
|
357 | 357 | // Delete old ATC |
358 | 358 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
359 | 359 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | } |
368 | 368 | if ($max != $globalMinFetch) { |
369 | 369 | if ($globalDebug) echo 'Sleeping...'."\n"; |
370 | - sleep($globalMinFetch-$max+2); |
|
370 | + sleep($globalMinFetch - $max + 2); |
|
371 | 371 | } |
372 | 372 | } |
373 | 373 | |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | //$buffer = $Common->getData($hosts[$id]); |
381 | 381 | $buffer = $Common->getData($value['host']); |
382 | 382 | if ($buffer != '') $reset = 0; |
383 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
384 | - $buffer = explode('\n',$buffer); |
|
383 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
384 | + $buffer = explode('\n', $buffer); |
|
385 | 385 | foreach ($buffer as $line) { |
386 | 386 | if ($line != '' && count($line) > 7) { |
387 | 387 | $line = explode(',', $line); |
@@ -409,11 +409,11 @@ discard block |
||
409 | 409 | $last_exec[$id]['last'] = time(); |
410 | 410 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
411 | 411 | date_default_timezone_set('CET'); |
412 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
412 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
413 | 413 | date_default_timezone_set('UTC'); |
414 | 414 | if ($buffer != '') $reset = 0; |
415 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
416 | - $buffer = explode('\n',$buffer); |
|
415 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
416 | + $buffer = explode('\n', $buffer); |
|
417 | 417 | foreach ($buffer as $line) { |
418 | 418 | if ($line != '') { |
419 | 419 | //echo "'".$line."'\n"; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
432 | 432 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
433 | 433 | if (isset($ais_data['timestamp'])) { |
434 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
434 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
435 | 435 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
436 | 436 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
437 | 437 | $add = true; |
@@ -454,12 +454,12 @@ discard block |
||
454 | 454 | $w = $e = null; |
455 | 455 | |
456 | 456 | if (isset($arr[$id])) { |
457 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
457 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
458 | 458 | if ($nn > 0) { |
459 | 459 | foreach ($httpfeeds as $feed) { |
460 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
461 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
462 | - $buffer = explode('\n',$buffer); |
|
460 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
461 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
462 | + $buffer = explode('\n', $buffer); |
|
463 | 463 | foreach ($buffer as $line) { |
464 | 464 | if ($line != '') { |
465 | 465 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -477,9 +477,9 @@ discard block |
||
477 | 477 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
478 | 478 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
479 | 479 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
480 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
480 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
481 | 481 | if (isset($ais_data['timestamp'])) { |
482 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
482 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
483 | 483 | } else { |
484 | 484 | $data['datetime'] = date('Y-m-d H:i:s'); |
485 | 485 | } |
@@ -505,10 +505,10 @@ discard block |
||
505 | 505 | } |
506 | 506 | } |
507 | 507 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
508 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
508 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
509 | 509 | if ($buffer != '') { |
510 | 510 | //echo $buffer; |
511 | - $all_data = json_decode($buffer,true); |
|
511 | + $all_data = json_decode($buffer, true); |
|
512 | 512 | //print_r($all_data); |
513 | 513 | if (isset($all_data[0]['DATA'])) { |
514 | 514 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
524 | 524 | $data['imo'] = $line['IMO']; |
525 | 525 | //$data['arrival_code'] = $ais_data['destination']; |
526 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
526 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
527 | 527 | $data['format_source'] = 'myshiptracking'; |
528 | 528 | $data['id_source'] = $id_source; |
529 | 529 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | } |
536 | 536 | $last_exec[$id]['last'] = time(); |
537 | 537 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
538 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
538 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
539 | 539 | if ($buffer != '') { |
540 | - $all_data = json_decode($buffer,true); |
|
540 | + $all_data = json_decode($buffer, true); |
|
541 | 541 | if (isset($all_data[0]['mmsi'])) { |
542 | 542 | foreach ($all_data as $line) { |
543 | 543 | if ($line != '') { |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
567 | 567 | $buffer = $Common->getData($value['host']); |
568 | 568 | if ($buffer != '') { |
569 | - $all_data = json_decode($buffer,true); |
|
569 | + $all_data = json_decode($buffer, true); |
|
570 | 570 | if (isset($all_data['features'][0]['id'])) { |
571 | 571 | foreach ($all_data['features'] as $line) { |
572 | 572 | $data = array(); |
@@ -594,27 +594,27 @@ discard block |
||
594 | 594 | $last_exec[$id]['last'] = time(); |
595 | 595 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
596 | 596 | echo 'download...'; |
597 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
597 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
598 | 598 | echo 'done !'."\n"; |
599 | 599 | if ($buffer != '') $reset = 0; |
600 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
601 | - $buffer = explode('\n',$buffer); |
|
600 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
601 | + $buffer = explode('\n', $buffer); |
|
602 | 602 | foreach ($buffer as $line) { |
603 | 603 | if ($line != '') { |
604 | 604 | $data = array(); |
605 | - $data['mmsi'] = (int)substr($line,0,9); |
|
606 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
605 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
606 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
607 | 607 | //$data['status'] = substr($line,21,2); |
608 | 608 | //$data['type'] = substr($line,24,3); |
609 | - $data['latitude'] = substr($line,29,9); |
|
610 | - $data['longitude'] = substr($line,41,9); |
|
611 | - $data['speed'] = round(substr($line,51,5)); |
|
609 | + $data['latitude'] = substr($line, 29, 9); |
|
610 | + $data['longitude'] = substr($line, 41, 9); |
|
611 | + $data['speed'] = round(substr($line, 51, 5)); |
|
612 | 612 | //$data['course'] = substr($line,57,5); |
613 | - $data['heading'] = round(substr($line,63,3)); |
|
613 | + $data['heading'] = round(substr($line, 63, 3)); |
|
614 | 614 | //$data['draft'] = substr($line,67,4); |
615 | 615 | //$data['length'] = substr($line,72,3); |
616 | 616 | //$data['beam'] = substr($line,76,2); |
617 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
617 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
618 | 618 | //$data['callsign'] = trim(substr($line,100,7); |
619 | 619 | //$data['dest'] = substr($line,108,20); |
620 | 620 | //$data['etaDate'] = substr($line,129,5); |
@@ -633,8 +633,8 @@ discard block |
||
633 | 633 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
634 | 634 | //$buffer = $Common->getData($hosts[$id]); |
635 | 635 | $buffer = $Common->getData($value['host']); |
636 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
637 | - $buffer = explode('\n',$buffer); |
|
636 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
637 | + $buffer = explode('\n', $buffer); |
|
638 | 638 | $reset = 0; |
639 | 639 | foreach ($buffer as $line) { |
640 | 640 | if ($line != '') { |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
646 | 646 | $data['pilot_id'] = $line[1]; |
647 | 647 | $data['pilot_name'] = $line[2]; |
648 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
648 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
649 | 649 | $data['ident'] = $line[0]; // ident |
650 | 650 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
651 | 651 | $data['speed'] = $line[8]; // speed |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
662 | 662 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
663 | 663 | $data['departure_airport_icao'] = $line[11]; |
664 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
664 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
665 | 665 | $data['arrival_airport_icao'] = $line[13]; |
666 | 666 | $data['frequency'] = $line[4]; |
667 | 667 | $data['type'] = $line[18]; |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | $data['id_source'] = $id_source; |
671 | 671 | //$data['arrival_airport_time'] = ; |
672 | 672 | if ($line[9] != '') { |
673 | - $aircraft_data = explode('/',$line[9]); |
|
673 | + $aircraft_data = explode('/', $line[9]); |
|
674 | 674 | if (isset($aircraft_data[1])) { |
675 | 675 | $data['aircraft_icao'] = $aircraft_data[1]; |
676 | 676 | } |
@@ -685,9 +685,9 @@ discard block |
||
685 | 685 | if ($line[3] == 'PILOT') $SI->add($data); |
686 | 686 | elseif ($line[3] == 'ATC') { |
687 | 687 | //print_r($data); |
688 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
689 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
690 | - $typec = substr($data['ident'],-3); |
|
688 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
689 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
690 | + $typec = substr($data['ident'], -3); |
|
691 | 691 | if ($typec == 'APP') $data['type'] = 'Approach'; |
692 | 692 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
693 | 693 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -699,8 +699,8 @@ discard block |
||
699 | 699 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
700 | 700 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
701 | 701 | if (isset($ATC)) { |
702 | - 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']); |
|
703 | - 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']); |
|
702 | + 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']); |
|
703 | + 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']); |
|
704 | 704 | } |
705 | 705 | } |
706 | 706 | unset($data); |
@@ -711,24 +711,24 @@ discard block |
||
711 | 711 | //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
712 | 712 | $last_exec[$id]['last'] = time(); |
713 | 713 | } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
714 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
714 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
715 | 715 | if ($buffer != '') { |
716 | 716 | $all_data = simplexml_load_string($buffer); |
717 | - foreach($all_data->children() as $childdata) { |
|
717 | + foreach ($all_data->children() as $childdata) { |
|
718 | 718 | $data = array(); |
719 | 719 | $line = $childdata; |
720 | 720 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
721 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
722 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
723 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
724 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
725 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
726 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
727 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
721 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
722 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
723 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
724 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
725 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
726 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
727 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
728 | 728 | $data['altitude_relative'] = 'AMSL'; |
729 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
729 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
730 | 730 | $data['aircraft_icao'] = 'PARAGLIDER'; |
731 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
731 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
732 | 732 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
733 | 733 | $data['format_source'] = $value['format']; |
734 | 734 | $SI->add($data); |
@@ -736,31 +736,31 @@ discard block |
||
736 | 736 | } |
737 | 737 | } |
738 | 738 | $Source->deleteOldLocationByType('gs'); |
739 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
739 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
740 | 740 | if ($buffer != '') { |
741 | 741 | $all_data = simplexml_load_string($buffer); |
742 | - foreach($all_data->children() as $childdata) { |
|
742 | + foreach ($all_data->children() as $childdata) { |
|
743 | 743 | $data = array(); |
744 | 744 | $line = $childdata; |
745 | - $data['id'] = (int)$line['gsID']; |
|
746 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
747 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
748 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
745 | + $data['id'] = (int) $line['gsID']; |
|
746 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
747 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
748 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
749 | 749 | $data['altitude_relative'] = 'AMSL'; |
750 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
750 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
751 | 751 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
752 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
752 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
753 | 753 | } else { |
754 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
754 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
755 | 755 | } |
756 | 756 | unset($data); |
757 | 757 | } |
758 | 758 | } |
759 | 759 | $last_exec[$id]['last'] = time(); |
760 | 760 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
761 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
761 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
762 | 762 | if ($buffer != '') { |
763 | - $all_data = json_decode($buffer,true); |
|
763 | + $all_data = json_decode($buffer, true); |
|
764 | 764 | if (isset($all_data['acList'])) { |
765 | 765 | $reset = 0; |
766 | 766 | foreach ($all_data['acList'] as $line) { |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | $data['emergency'] = ''; // emergency |
778 | 778 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
779 | 779 | |
780 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
780 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
781 | 781 | else $data['datetime'] = date('Y-m-d H:i:s'); |
782 | 782 | |
783 | 783 | //$data['datetime'] = date('Y-m-d H:i:s'); |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | $data['verticalrate'] = $line['vrt']; // verticale rate |
804 | 804 | $data['squawk'] = $line['squawk']; // squawk |
805 | 805 | $data['emergency'] = ''; // emergency |
806 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
806 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
807 | 807 | else $data['datetime'] = date('Y-m-d H:i:s'); |
808 | 808 | $data['format_source'] = 'aircraftlistjson'; |
809 | 809 | $data['id_source'] = $id_source; |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
820 | 820 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
821 | 821 | $buffer = $Common->getData($value['host']); |
822 | - $all_data = json_decode($buffer,true); |
|
822 | + $all_data = json_decode($buffer, true); |
|
823 | 823 | if (isset($all_data['planes'])) { |
824 | 824 | $reset = 0; |
825 | 825 | foreach ($all_data['planes'] as $key => $line) { |
@@ -836,12 +836,12 @@ discard block |
||
836 | 836 | $data['emergency'] = ''; // emergency |
837 | 837 | $data['registration'] = $line[2]; |
838 | 838 | $data['aircraft_icao'] = $line[0]; |
839 | - $deparr = explode('-',$line[1]); |
|
839 | + $deparr = explode('-', $line[1]); |
|
840 | 840 | if (count($deparr) == 2) { |
841 | 841 | $data['departure_airport_icao'] = $deparr[0]; |
842 | 842 | $data['arrival_airport_icao'] = $deparr[1]; |
843 | 843 | } |
844 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
844 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
845 | 845 | $data['format_source'] = 'planeupdatefaa'; |
846 | 846 | $data['id_source'] = $id_source; |
847 | 847 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | $last_exec[$id]['last'] = time(); |
855 | 855 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
856 | 856 | $buffer = $Common->getData($value['host']); |
857 | - $all_data = json_decode($buffer,true); |
|
857 | + $all_data = json_decode($buffer, true); |
|
858 | 858 | if (isset($all_data['states'])) { |
859 | 859 | $reset = 0; |
860 | 860 | foreach ($all_data['states'] as $key => $line) { |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | //$data['emergency'] = ''; // emergency |
872 | 872 | //$data['registration'] = $line[2]; |
873 | 873 | //$data['aircraft_icao'] = $line[0]; |
874 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
874 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
875 | 875 | $data['format_source'] = 'opensky'; |
876 | 876 | $data['id_source'] = $id_source; |
877 | 877 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
886 | 886 | //$buffer = $Common->getData($hosts[$id]); |
887 | 887 | $buffer = $Common->getData($value['host']); |
888 | - $all_data = json_decode($buffer,true); |
|
888 | + $all_data = json_decode($buffer, true); |
|
889 | 889 | if (!empty($all_data)) $reset = 0; |
890 | 890 | foreach ($all_data as $key => $line) { |
891 | 891 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -918,11 +918,11 @@ discard block |
||
918 | 918 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
919 | 919 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
920 | 920 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
921 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
921 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
922 | 922 | //echo $buffer; |
923 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
924 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
925 | - $all_data = json_decode($buffer,true); |
|
923 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
924 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
925 | + $all_data = json_decode($buffer, true); |
|
926 | 926 | if (json_last_error() != JSON_ERROR_NONE) { |
927 | 927 | die(json_last_error_msg()); |
928 | 928 | } |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | //$data['departure_airport_iata'] = $line[11]; |
946 | 946 | //$data['arrival_airport_iata'] = $line[12]; |
947 | 947 | //$data['emergency'] = ''; // emergency |
948 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
948 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
949 | 949 | $data['format_source'] = 'radarvirtueljson'; |
950 | 950 | $data['id_source'] = $id_source; |
951 | 951 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -961,14 +961,14 @@ discard block |
||
961 | 961 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
962 | 962 | //$buffer = $Common->getData($hosts[$id]); |
963 | 963 | $buffer = $Common->getData($value['host'].'?'.time()); |
964 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
964 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
965 | 965 | |
966 | 966 | if (isset($all_data['pireps'])) { |
967 | 967 | $reset = 0; |
968 | 968 | foreach ($all_data['pireps'] as $line) { |
969 | 969 | $data = array(); |
970 | 970 | $data['id'] = $line['id']; |
971 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
971 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
972 | 972 | $data['ident'] = $line['callsign']; // ident |
973 | 973 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
974 | 974 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -998,9 +998,9 @@ discard block |
||
998 | 998 | $SI->add($data); |
999 | 999 | // print_r($data); |
1000 | 1000 | } elseif ($line['icon'] == 'ct') { |
1001 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1002 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1003 | - $typec = substr($data['ident'],-3); |
|
1001 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
1002 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1003 | + $typec = substr($data['ident'], -3); |
|
1004 | 1004 | $data['type'] = ''; |
1005 | 1005 | if ($typec == 'APP') $data['type'] = 'Approach'; |
1006 | 1006 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -1011,7 +1011,7 @@ discard block |
||
1011 | 1011 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
1012 | 1012 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1013 | 1013 | else $data['type'] = 'Observer'; |
1014 | - 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']); |
|
1014 | + 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']); |
|
1015 | 1015 | } |
1016 | 1016 | unset($data); |
1017 | 1017 | } |
@@ -1023,14 +1023,14 @@ discard block |
||
1023 | 1023 | //$buffer = $Common->getData($hosts[$id]); |
1024 | 1024 | if ($globalDebug) echo 'Get Data...'."\n"; |
1025 | 1025 | $buffer = $Common->getData($value['host']); |
1026 | - $all_data = json_decode($buffer,true); |
|
1026 | + $all_data = json_decode($buffer, true); |
|
1027 | 1027 | if ($buffer != '' && is_array($all_data)) { |
1028 | 1028 | $reset = 0; |
1029 | 1029 | foreach ($all_data as $line) { |
1030 | 1030 | $data = array(); |
1031 | 1031 | //$data['id'] = $line['id']; // id not usable |
1032 | 1032 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1033 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1033 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1034 | 1034 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1035 | 1035 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1036 | 1036 | $data['ident'] = $line['flightnum']; // ident |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | //$data['datetime'] = $line['lastupdate']; |
1046 | 1046 | //$data['last_update'] = $line['lastupdate']; |
1047 | 1047 | if (isset($value['timezone'])) { |
1048 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1048 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1049 | 1049 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1050 | 1050 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1051 | 1051 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1058,14 +1058,14 @@ discard block |
||
1058 | 1058 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1059 | 1059 | if (isset($line['aircraftname'])) { |
1060 | 1060 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1061 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1062 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1061 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1062 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1063 | 1063 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1064 | 1064 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1065 | 1065 | else { |
1066 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1067 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1068 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1066 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1067 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1068 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1069 | 1069 | } |
1070 | 1070 | } |
1071 | 1071 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1085,14 +1085,14 @@ discard block |
||
1085 | 1085 | //$buffer = $Common->getData($hosts[$id]); |
1086 | 1086 | if ($globalDebug) echo 'Get Data...'."\n"; |
1087 | 1087 | $buffer = $Common->getData($value['host']); |
1088 | - $all_data = json_decode($buffer,true); |
|
1088 | + $all_data = json_decode($buffer, true); |
|
1089 | 1089 | if ($buffer != '' && is_array($all_data)) { |
1090 | 1090 | $reset = 0; |
1091 | 1091 | foreach ($all_data as $line) { |
1092 | 1092 | $data = array(); |
1093 | 1093 | //$data['id'] = $line['id']; // id not usable |
1094 | 1094 | $data['id'] = trim($line['flight_id']); |
1095 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1095 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1096 | 1096 | $data['pilot_name'] = $line['pilot_name']; |
1097 | 1097 | $data['pilot_id'] = $line['pilot_id']; |
1098 | 1098 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1144,11 +1144,11 @@ discard block |
||
1144 | 1144 | //$value = $formats[$nb]; |
1145 | 1145 | $format = $globalSources[$nb]['format']; |
1146 | 1146 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1147 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1147 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1148 | 1148 | } elseif ($format == 'vrstcp') { |
1149 | 1149 | $buffer = @socket_read($r, 6000); |
1150 | 1150 | } else { |
1151 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1151 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1152 | 1152 | } |
1153 | 1153 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1154 | 1154 | //echo $buffer."\n"; |
@@ -1157,8 +1157,8 @@ discard block |
||
1157 | 1157 | $error = false; |
1158 | 1158 | //$SI::del(); |
1159 | 1159 | if ($format == 'vrstcp') { |
1160 | - $buffer = explode('},{',$buffer); |
|
1161 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1160 | + $buffer = explode('},{', $buffer); |
|
1161 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1162 | 1162 | // SBS format is CSV format |
1163 | 1163 | if ($buffer !== FALSE && $buffer != '') { |
1164 | 1164 | $tt[$format] = 0; |
@@ -1192,13 +1192,13 @@ discard block |
||
1192 | 1192 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1193 | 1193 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1194 | 1194 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1195 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1195 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1196 | 1196 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1197 | 1197 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1198 | 1198 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1199 | 1199 | |
1200 | 1200 | if (isset($ais_data['timestamp'])) { |
1201 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1201 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1202 | 1202 | } else { |
1203 | 1203 | $data['datetime'] = date('Y-m-d H:i:s'); |
1204 | 1204 | } |
@@ -1209,10 +1209,10 @@ discard block |
||
1209 | 1209 | } elseif ($format == 'flightgearsp') { |
1210 | 1210 | //echo $buffer."\n"; |
1211 | 1211 | if (strlen($buffer) > 5) { |
1212 | - $line = explode(',',$buffer); |
|
1212 | + $line = explode(',', $buffer); |
|
1213 | 1213 | $data = array(); |
1214 | 1214 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1215 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1215 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1216 | 1216 | $data['ident'] = $line[6]; |
1217 | 1217 | $data['aircraft_name'] = $line[7]; |
1218 | 1218 | $data['longitude'] = $line[1]; |
@@ -1229,16 +1229,16 @@ discard block |
||
1229 | 1229 | } elseif ($format == 'acars') { |
1230 | 1230 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1231 | 1231 | $ACARS->add(trim($buffer)); |
1232 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1232 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1233 | 1233 | $ACARS->deleteLiveAcarsData(); |
1234 | 1234 | } elseif ($format == 'flightgearmp') { |
1235 | - if (substr($buffer,0,1) != '#') { |
|
1235 | + if (substr($buffer, 0, 1) != '#') { |
|
1236 | 1236 | $data = array(); |
1237 | 1237 | //echo $buffer."\n"; |
1238 | - $line = explode(' ',$buffer); |
|
1238 | + $line = explode(' ', $buffer); |
|
1239 | 1239 | if (count($line) == 11) { |
1240 | - $userserver = explode('@',$line[0]); |
|
1241 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1240 | + $userserver = explode('@', $line[0]); |
|
1241 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1242 | 1242 | $data['ident'] = $userserver[0]; |
1243 | 1243 | $data['registration'] = $userserver[0]; |
1244 | 1244 | $data['latitude'] = $line[4]; |
@@ -1246,8 +1246,8 @@ discard block |
||
1246 | 1246 | $data['altitude'] = $line[6]; |
1247 | 1247 | $data['datetime'] = date('Y-m-d H:i:s'); |
1248 | 1248 | $aircraft_type = $line[10]; |
1249 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1250 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1249 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1250 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1251 | 1251 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1252 | 1252 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1253 | 1253 | } |
@@ -1256,8 +1256,8 @@ discard block |
||
1256 | 1256 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1257 | 1257 | die; |
1258 | 1258 | } elseif ($format == 'vrstcp') { |
1259 | - foreach($buffer as $all_data) { |
|
1260 | - $line = json_decode('{'.$all_data.'}',true); |
|
1259 | + foreach ($buffer as $all_data) { |
|
1260 | + $line = json_decode('{'.$all_data.'}', true); |
|
1261 | 1261 | $data = array(); |
1262 | 1262 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1263 | 1263 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1283,16 +1283,16 @@ discard block |
||
1283 | 1283 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1284 | 1284 | unset($data); |
1285 | 1285 | } |
1286 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1286 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1287 | 1287 | $line = explode("\t", $buffer); |
1288 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1288 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1289 | 1289 | $key = $line[$k]; |
1290 | - $lined[$key] = $line[$k+1]; |
|
1290 | + $lined[$key] = $line[$k + 1]; |
|
1291 | 1291 | } |
1292 | 1292 | if (count($lined) > 3) { |
1293 | 1293 | $data['hex'] = $lined['hexid']; |
1294 | 1294 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1295 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1295 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1296 | 1296 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1297 | 1297 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1298 | 1298 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1311,22 +1311,22 @@ discard block |
||
1311 | 1311 | } else $error = true; |
1312 | 1312 | } elseif ($format == 'aprs' && $use_aprs) { |
1313 | 1313 | if ($aprs_connect == 0) { |
1314 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1314 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1315 | 1315 | $aprs_connect = 1; |
1316 | 1316 | } |
1317 | 1317 | |
1318 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1318 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1319 | 1319 | $aprs_last_tx = time(); |
1320 | 1320 | $data_aprs = "# Keep alive"; |
1321 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1321 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1325 | 1325 | //echo 'APRS data : '.$buffer."\n"; |
1326 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1327 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1326 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1327 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1328 | 1328 | //echo $buffer."\n"; |
1329 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1329 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1330 | 1330 | $line = $APRS->parse($buffer); |
1331 | 1331 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1332 | 1332 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1341,7 +1341,7 @@ discard block |
||
1341 | 1341 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
1342 | 1342 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
1343 | 1343 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
1344 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1344 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1345 | 1345 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1346 | 1346 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1347 | 1347 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1420,20 +1420,20 @@ discard block |
||
1420 | 1420 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1421 | 1421 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1422 | 1422 | $Source->deleteOldLocationByType('gs'); |
1423 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1424 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1423 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
1424 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1425 | 1425 | } else { |
1426 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1426 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1427 | 1427 | } |
1428 | 1428 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1429 | 1429 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1430 | 1430 | //if ($globalDebug) echo '# Weather Station added'."\n"; |
1431 | 1431 | $Source->deleteOldLocationByType('wx'); |
1432 | 1432 | $weather_data = json_encode($line); |
1433 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
1434 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1433 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
1434 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1435 | 1435 | } else { |
1436 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1436 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1437 | 1437 | } |
1438 | 1438 | unset($data); |
1439 | 1439 | |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | } |
1444 | 1444 | } |
1445 | 1445 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1446 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1446 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1447 | 1447 | } |
1448 | 1448 | /* |
1449 | 1449 | 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')) { |
@@ -1530,7 +1530,7 @@ discard block |
||
1530 | 1530 | connect_all($sourceee); |
1531 | 1531 | $sourceee = array(); |
1532 | 1532 | //connect_all($globalSources); |
1533 | - $tt[$format]=0; |
|
1533 | + $tt[$format] = 0; |
|
1534 | 1534 | break; |
1535 | 1535 | } |
1536 | 1536 | } |
@@ -1539,14 +1539,14 @@ discard block |
||
1539 | 1539 | } else { |
1540 | 1540 | $error = socket_strerror(socket_last_error()); |
1541 | 1541 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1542 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1542 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1543 | 1543 | if (isset($globalDebug)) echo "Restarting...\n"; |
1544 | 1544 | // Restart the script if possible |
1545 | 1545 | if (is_array($sockets)) { |
1546 | 1546 | if ($globalDebug) echo "Shutdown all sockets..."; |
1547 | 1547 | |
1548 | 1548 | foreach ($sockets as $sock) { |
1549 | - @socket_shutdown($sock,2); |
|
1549 | + @socket_shutdown($sock, 2); |
|
1550 | 1550 | @socket_close($sock); |
1551 | 1551 | } |
1552 | 1552 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | if (!isset($globalDemo)) { |
13 | 13 | if (isset($_GET['coord'])) |
14 | 14 | { |
15 | - $coords = explode(',',$_GET['coord']); |
|
15 | + $coords = explode(',', $_GET['coord']); |
|
16 | 16 | // $spotter_array = Source::getAllLocationInfobyCoord($coords); |
17 | 17 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
18 | 18 | || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $output = '{"type": "FeatureCollection","features": ['; |
34 | 34 | if (!empty($spotter_array) && count($spotter_array) > 0) |
35 | 35 | { |
36 | - foreach($spotter_array as $spotter_item) |
|
36 | + foreach ($spotter_array as $spotter_item) |
|
37 | 37 | { |
38 | 38 | date_default_timezone_set('UTC'); |
39 | 39 | //waypoint plotting |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | $output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",'; |
53 | 53 | $output .= '"type": "'.$spotter_item['type'].'",'; |
54 | 54 | if ($spotter_item['type'] == 'wx') { |
55 | - $weather = json_decode($spotter_item['description'],true); |
|
56 | - if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",'; |
|
55 | + $weather = json_decode($spotter_item['description'], true); |
|
56 | + if (isset($weather['temp'])) $output .= '"temp": "'.$weather['temp'].'",'; |
|
57 | 57 | } |
58 | 58 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
59 | 59 | $output .= '},'; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $output .= '}'; |
66 | 66 | $output .= '},'; |
67 | 67 | } |
68 | - $output = substr($output, 0, -1); |
|
68 | + $output = substr($output, 0, -1); |
|
69 | 69 | } |
70 | 70 | $output .= ']}'; |
71 | 71 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | try { |
16 | 16 | $sth = $this->db->prepare($query); |
17 | 17 | $sth->execute($query_values); |
18 | - } catch(PDOException $e) { |
|
18 | + } catch (PDOException $e) { |
|
19 | 19 | return "error : ".$e->getMessage(); |
20 | 20 | } |
21 | 21 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | try { |
29 | 29 | $sth = $this->db->prepare($query); |
30 | 30 | $sth->execute($query_values); |
31 | - } catch(PDOException $e) { |
|
31 | + } catch (PDOException $e) { |
|
32 | 32 | return "error : ".$e->getMessage(); |
33 | 33 | } |
34 | 34 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | 35 | return $all; |
36 | 36 | } |
37 | 37 | |
38 | - public function getLocationInfobyNameType($name,$type) { |
|
38 | + public function getLocationInfobyNameType($name, $type) { |
|
39 | 39 | $query = "SELECT * FROM source_location WHERE name = :name AND type = :type"; |
40 | - $query_values = array(':name' => $name,':type' => $type); |
|
40 | + $query_values = array(':name' => $name, ':type' => $type); |
|
41 | 41 | try { |
42 | 42 | $sth = $this->db->prepare($query); |
43 | 43 | $sth->execute($query_values); |
44 | - } catch(PDOException $e) { |
|
44 | + } catch (PDOException $e) { |
|
45 | 45 | return "error : ".$e->getMessage(); |
46 | 46 | } |
47 | 47 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | try { |
55 | 55 | $sth = $this->db->prepare($query); |
56 | 56 | $sth->execute($query_values); |
57 | - } catch(PDOException $e) { |
|
57 | + } catch (PDOException $e) { |
|
58 | 58 | return "error : ".$e->getMessage(); |
59 | 59 | } |
60 | 60 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | try { |
68 | 68 | $sth = $this->db->prepare($query); |
69 | 69 | $sth->execute($query_values); |
70 | - } catch(PDOException $e) { |
|
70 | + } catch (PDOException $e) { |
|
71 | 71 | return "error : ".$e->getMessage(); |
72 | 72 | } |
73 | 73 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | try { |
81 | 81 | $sth = $this->db->prepare($query); |
82 | 82 | $sth->execute($query_values); |
83 | - } catch(PDOException $e) { |
|
83 | + } catch (PDOException $e) { |
|
84 | 84 | return "error : ".$e->getMessage(); |
85 | 85 | } |
86 | 86 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -93,56 +93,56 @@ discard block |
||
93 | 93 | try { |
94 | 94 | $sth = $this->db->prepare($query); |
95 | 95 | $sth->execute($query_values); |
96 | - } catch(PDOException $e) { |
|
96 | + } catch (PDOException $e) { |
|
97 | 97 | return "error : ".$e->getMessage(); |
98 | 98 | } |
99 | 99 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
100 | 100 | return $all; |
101 | 101 | } |
102 | 102 | |
103 | - public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
|
103 | + public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
104 | 104 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
105 | 105 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
106 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
106 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
107 | 107 | try { |
108 | 108 | $sth = $this->db->prepare($query); |
109 | 109 | $sth->execute($query_values); |
110 | - } catch(PDOException $e) { |
|
110 | + } catch (PDOException $e) { |
|
111 | 111 | echo "error : ".$e->getMessage(); |
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
|
115 | + public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
116 | 116 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
117 | 117 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
118 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
118 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
119 | 119 | try { |
120 | 120 | $sth = $this->db->prepare($query); |
121 | 121 | $sth->execute($query_values); |
122 | - } catch(PDOException $e) { |
|
122 | + } catch (PDOException $e) { |
|
123 | 123 | return "error : ".$e->getMessage(); |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | - public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') { |
|
127 | + public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') { |
|
128 | 128 | $query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source"; |
129 | - $query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description); |
|
129 | + $query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description); |
|
130 | 130 | try { |
131 | 131 | $sth = $this->db->prepare($query); |
132 | 132 | $sth->execute($query_values); |
133 | - } catch(PDOException $e) { |
|
133 | + } catch (PDOException $e) { |
|
134 | 134 | return "error : ".$e->getMessage(); |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
|
138 | + public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') { |
|
139 | 139 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
140 | 140 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
141 | - $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
141 | + $query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
142 | 142 | try { |
143 | 143 | $sth = $this->db->prepare($query); |
144 | 144 | $sth->execute($query_values); |
145 | - } catch(PDOException $e) { |
|
145 | + } catch (PDOException $e) { |
|
146 | 146 | echo "error : ".$e->getMessage(); |
147 | 147 | } |
148 | 148 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | try { |
154 | 154 | $sth = $this->db->prepare($query); |
155 | 155 | $sth->execute($query_values); |
156 | - } catch(PDOException $e) { |
|
156 | + } catch (PDOException $e) { |
|
157 | 157 | return "error : ".$e->getMessage(); |
158 | 158 | } |
159 | 159 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $this->db->prepare($query); |
166 | 166 | $sth->execute($query_values); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error : ".$e->getMessage(); |
169 | 169 | } |
170 | 170 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | try { |
175 | 175 | $sth = $this->db->prepare($query); |
176 | 176 | $sth->execute(); |
177 | - } catch(PDOException $e) { |
|
177 | + } catch (PDOException $e) { |
|
178 | 178 | return "error : ".$e->getMessage(); |
179 | 179 | } |
180 | 180 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | try { |
198 | 198 | $sth = $this->db->prepare($query); |
199 | 199 | $sth->execute(array(':type' => $type)); |
200 | - } catch(PDOException $e) { |
|
200 | + } catch (PDOException $e) { |
|
201 | 201 | return "error"; |
202 | 202 | } |
203 | 203 | return "success"; |
@@ -166,8 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | |
168 | 168 | private function urshift($n, $s) { |
169 | - return ($n >= 0) ? ($n >> $s) : |
|
170 | - (($n & 0x7fffffff) >> $s) | |
|
169 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
171 | 170 | (0x40000000 >> ($s - 1)); |
172 | 171 | } |
173 | 172 | |
@@ -179,7 +178,7 @@ discard block |
||
179 | 178 | //$split_input = str_split($input); |
180 | 179 | |
181 | 180 | /* Find the end of header checking for NULL bytes while doing it. */ |
182 | - $splitpos = strpos($input,':'); |
|
181 | + $splitpos = strpos($input, ':'); |
|
183 | 182 | |
184 | 183 | /* Check that end was found and body has at least one byte. */ |
185 | 184 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -189,15 +188,15 @@ discard block |
||
189 | 188 | |
190 | 189 | if ($debug) echo 'input : '.$input."\n"; |
191 | 190 | /* Save header and body. */ |
192 | - $body = substr($input,$splitpos+1,$input_len); |
|
191 | + $body = substr($input, $splitpos + 1, $input_len); |
|
193 | 192 | $body_len = strlen($body); |
194 | - $header = substr($input,0,$splitpos); |
|
193 | + $header = substr($input, 0, $splitpos); |
|
195 | 194 | //$header_len = strlen($header); |
196 | 195 | if ($debug) echo 'header : '.$header."\n"; |
197 | 196 | |
198 | 197 | /* Parse source, target and path. */ |
199 | 198 | //FLRDF0A52>APRS,qAS,LSTB |
200 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
199 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
201 | 200 | $ident = $matches[1]; |
202 | 201 | $all_elements = $matches[2]; |
203 | 202 | if ($ident == 'AIRCRAFT') { |
@@ -214,14 +213,14 @@ discard block |
||
214 | 213 | if ($debug) 'No ident'."\n"; |
215 | 214 | return false; |
216 | 215 | } |
217 | - $elements = explode(',',$all_elements); |
|
216 | + $elements = explode(',', $all_elements); |
|
218 | 217 | $source = end($elements); |
219 | 218 | $result['source'] = $source; |
220 | 219 | foreach ($elements as $element) { |
221 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
220 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
222 | 221 | //echo "ok"; |
223 | 222 | //if ($element == 'TCPIP*') return false; |
224 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
223 | + } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
225 | 224 | if ($debug) echo 'element : '.$element."\n"; |
226 | 225 | return false; |
227 | 226 | } |
@@ -234,14 +233,14 @@ discard block |
||
234 | 233 | */ |
235 | 234 | } |
236 | 235 | |
237 | - $type = substr($body,0,1); |
|
236 | + $type = substr($body, 0, 1); |
|
238 | 237 | if ($debug) echo 'type : '.$type."\n"; |
239 | 238 | if ($type == ';') { |
240 | 239 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
241 | - $result['address'] = trim(substr($body,1,9)); |
|
240 | + $result['address'] = trim(substr($body, 1, 9)); |
|
242 | 241 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
243 | - $result['mmsi'] = trim(substr($body,1,9)); |
|
244 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
242 | + $result['mmsi'] = trim(substr($body, 1, 9)); |
|
243 | + } else $result['ident'] = trim(substr($body, 1, 9)); |
|
245 | 244 | } elseif ($type == ',') { |
246 | 245 | // Invalid data or test data |
247 | 246 | return false; |
@@ -249,24 +248,24 @@ discard block |
||
249 | 248 | |
250 | 249 | // Check for Timestamp |
251 | 250 | $find = false; |
252 | - $body_parse = substr($body,1); |
|
251 | + $body_parse = substr($body, 1); |
|
253 | 252 | //echo 'Body : '.$body."\n"; |
254 | - if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
|
255 | - $body_parse = substr($body_parse,10); |
|
253 | + if (preg_match('/^;(.){9}\*/', $body, $matches)) { |
|
254 | + $body_parse = substr($body_parse, 10); |
|
256 | 255 | $find = true; |
257 | 256 | //echo $body_parse."\n"; |
258 | 257 | } |
259 | - if (preg_match('/^`(.*)\//',$body,$matches)) { |
|
260 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
258 | + if (preg_match('/^`(.*)\//', $body, $matches)) { |
|
259 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
261 | 260 | $find = true; |
262 | 261 | //echo $body_parse."\n"; |
263 | 262 | } |
264 | - if (preg_match("/^'(.*)\//",$body,$matches)) { |
|
265 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
263 | + if (preg_match("/^'(.*)\//", $body, $matches)) { |
|
264 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
266 | 265 | $find = true; |
267 | 266 | //echo $body_parse."\n"; |
268 | 267 | } |
269 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
268 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
270 | 269 | $find = true; |
271 | 270 | //print_r($matches); |
272 | 271 | $timestamp = $matches[0]; |
@@ -281,19 +280,19 @@ discard block |
||
281 | 280 | // This work or not ? |
282 | 281 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
283 | 282 | } |
284 | - $body_parse = substr($body_parse,7); |
|
283 | + $body_parse = substr($body_parse, 7); |
|
285 | 284 | $result['timestamp'] = $timestamp; |
286 | 285 | //echo date('Ymd H:i:s',$timestamp); |
287 | 286 | } |
288 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
|
287 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { |
|
289 | 288 | $find = true; |
290 | 289 | $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
291 | - $body_parse = substr($body_parse,8); |
|
290 | + $body_parse = substr($body_parse, 8); |
|
292 | 291 | $result['timestamp'] = $timestamp; |
293 | 292 | //echo date('Ymd H:i:s',$timestamp); |
294 | 293 | } |
295 | 294 | //if (strlen($body_parse) > 19) { |
296 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
295 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { |
|
297 | 296 | $find = true; |
298 | 297 | // 4658.70N/00707.78Ez |
299 | 298 | //print_r(str_split($body_parse)); |
@@ -320,11 +319,11 @@ discard block |
||
320 | 319 | */ |
321 | 320 | $latitude = $lat + floatval($lat_min)/60; |
322 | 321 | $longitude = $lon + floatval($lon_min)/60; |
323 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
324 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
322 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
323 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
325 | 324 | $result['latitude'] = $latitude; |
326 | 325 | $result['longitude'] = $longitude; |
327 | - $body_parse = substr($body_parse,18); |
|
326 | + $body_parse = substr($body_parse, 18); |
|
328 | 327 | $body_parse_len = strlen($body_parse); |
329 | 328 | } |
330 | 329 | $body_parse_len = strlen($body_parse); |
@@ -356,7 +355,7 @@ discard block |
||
356 | 355 | //echo $body_parse; |
357 | 356 | //if ($type != ';' && $type != '>') { |
358 | 357 | if ($type != '') { |
359 | - $body_parse = substr($body_parse,1); |
|
358 | + $body_parse = substr($body_parse, 1); |
|
360 | 359 | $body_parse_len = strlen($body_parse); |
361 | 360 | $result['symbol_code'] = $symbol_code; |
362 | 361 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
@@ -367,16 +366,16 @@ discard block |
||
367 | 366 | //$body_parse_len = strlen($body_parse); |
368 | 367 | if ($body_parse_len >= 7) { |
369 | 368 | |
370 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
371 | - $course = substr($body_parse,0,3); |
|
369 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
370 | + $course = substr($body_parse, 0, 3); |
|
372 | 371 | $tmp_s = intval($course); |
373 | 372 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
374 | - $speed = substr($body_parse,4,3); |
|
373 | + $speed = substr($body_parse, 4, 3); |
|
375 | 374 | if ($speed != '...') { |
376 | 375 | //$result['speed'] = round($speed*1.852); |
377 | 376 | $result['speed'] = intval($speed); |
378 | 377 | } |
379 | - $body_parse = substr($body_parse,7); |
|
378 | + $body_parse = substr($body_parse, 7); |
|
380 | 379 | } |
381 | 380 | // Check PHGR, PHG, RNG |
382 | 381 | } |
@@ -386,12 +385,12 @@ discard block |
||
386 | 385 | } |
387 | 386 | */ |
388 | 387 | if (strlen($body_parse) > 0) { |
389 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
388 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
390 | 389 | $altitude = intval($matches[1]); |
391 | 390 | //$result['altitude'] = round($altitude*0.3048); |
392 | 391 | $result['altitude'] = $altitude; |
393 | 392 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
394 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
393 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); |
|
395 | 394 | } |
396 | 395 | } |
397 | 396 | |
@@ -403,13 +402,13 @@ discard block |
||
403 | 402 | */ |
404 | 403 | // DAO |
405 | 404 | |
406 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
405 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
407 | 406 | |
408 | 407 | $dao = $matches[1]; |
409 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
408 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
410 | 409 | $dao_split = str_split($dao); |
411 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
412 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
410 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; |
|
411 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; |
|
413 | 412 | |
414 | 413 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
415 | 414 | else $result['latitude'] += $lat_off; |
@@ -417,50 +416,50 @@ discard block |
||
417 | 416 | else $result['longitude'] += $lon_off; |
418 | 417 | } |
419 | 418 | |
420 | - $body_parse = substr($body_parse,6); |
|
419 | + $body_parse = substr($body_parse, 6); |
|
421 | 420 | } |
422 | 421 | |
423 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
424 | - $result['ident'] = str_replace('_',' ',$matches[1]); |
|
422 | + if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
423 | + $result['ident'] = str_replace('_', ' ', $matches[1]); |
|
425 | 424 | } |
426 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
425 | + if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { |
|
427 | 426 | $result['squawk'] = $matches[1]; |
428 | 427 | } |
429 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
428 | + if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { |
|
430 | 429 | $result['aircraft_icao'] = $matches[1]; |
431 | 430 | } |
432 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
431 | + if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) { |
|
433 | 432 | $result['verticalrate'] = $matches[1]; |
434 | 433 | } |
435 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
434 | + if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { |
|
436 | 435 | $result['typeid'] = $matches[1]; |
437 | 436 | } |
438 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
437 | + if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) { |
|
439 | 438 | $result['statusid'] = $matches[1]; |
440 | 439 | } |
441 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
440 | + if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { |
|
442 | 441 | $result['imo'] = $matches[1]; |
443 | 442 | } |
444 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
443 | + if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { |
|
445 | 444 | $result['arrival_date'] = $matches[1]; |
446 | 445 | } |
447 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
448 | - $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
|
446 | + if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
447 | + $result['arrival_code'] = str_replace('_', ' ', $matches[1]); |
|
449 | 448 | } |
450 | 449 | // OGN comment |
451 | 450 | // echo "Before OGN : ".$body_parse."\n"; |
452 | 451 | //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
453 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
452 | + if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { |
|
454 | 453 | $id = $matches[1]; |
455 | 454 | //$mode = substr($id,0,2); |
456 | - $address = substr($id,2); |
|
455 | + $address = substr($id, 2); |
|
457 | 456 | //print_r($matches); |
458 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
457 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
459 | 458 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
460 | 459 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
461 | 460 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
462 | 461 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
463 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
462 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
464 | 463 | $result['aircrafttype_code'] = $aircraftType; |
465 | 464 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
466 | 465 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -477,7 +476,7 @@ discard block |
||
477 | 476 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
478 | 477 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
479 | 478 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
480 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
479 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
481 | 480 | $result['stealth'] = $stealth; |
482 | 481 | $result['address'] = $address; |
483 | 482 | } |
@@ -489,96 +488,96 @@ discard block |
||
489 | 488 | //$body_parse = substr($body_parse,1); |
490 | 489 | //$body_parse_len = strlen($body_parse); |
491 | 490 | //echo 'weather'."\n"; |
492 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
491 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
493 | 492 | $result['wind_dir'] = intval($matches[1]); |
494 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
495 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
496 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
497 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
498 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
493 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); |
|
494 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); |
|
495 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); |
|
496 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
497 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
499 | 498 | $result['wind_dir'] = intval($matches[1]); |
500 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
501 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
502 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
503 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
504 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
499 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
500 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
501 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
502 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
503 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
505 | 504 | $result['wind_dir'] = intval($matches[1]); |
506 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
507 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
508 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
509 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
505 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
506 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
507 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
508 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
510 | 509 | $result['wind_dir'] = intval($matches[1]); |
511 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
512 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
513 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
510 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
511 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
512 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
514 | 513 | } |
515 | 514 | //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
516 | 515 | //g012t088r000p000P000h38b10110 |
517 | 516 | //g011t086r000p000P000h29b10198 |
518 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
519 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
520 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
521 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
522 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
523 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
517 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
518 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
519 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
520 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
521 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
522 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
524 | 523 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
525 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
526 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
527 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
528 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
529 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
530 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
531 | - if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
532 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
524 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
525 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
526 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
527 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
528 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
529 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
530 | + if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1); |
|
531 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
533 | 532 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
534 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
535 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
536 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
537 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
538 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
539 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
540 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
541 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
533 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
534 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
535 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
536 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
537 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
538 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
539 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
540 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
542 | 541 | if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
543 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
544 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
545 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
546 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
547 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
548 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
549 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
542 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
543 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
544 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
545 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
546 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
547 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
548 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
550 | 549 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
551 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
552 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
553 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
554 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
555 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
556 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
557 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
550 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
551 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
552 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
553 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
554 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
555 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
556 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
558 | 557 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
559 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
560 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
561 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
562 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
563 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
564 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
565 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
558 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
559 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
560 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
561 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
562 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
563 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
564 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
566 | 565 | if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
567 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
568 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
569 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
570 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
571 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
566 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
567 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
568 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
569 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
570 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
572 | 571 | if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
573 | - if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); |
|
574 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
575 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
576 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
577 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
578 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
572 | + if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1); |
|
573 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
574 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
575 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
576 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
577 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
579 | 578 | if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
580 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
581 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
579 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
580 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
582 | 581 | } |
583 | 582 | $result['comment'] = trim($body_parse); |
584 | 583 | } |
@@ -586,42 +585,42 @@ discard block |
||
586 | 585 | |
587 | 586 | } |
588 | 587 | //} |
589 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
590 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
588 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
589 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
591 | 590 | if ($debug) print_r($result); |
592 | 591 | return $result; |
593 | 592 | } |
594 | 593 | |
595 | 594 | public function connect() { |
596 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
595 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
597 | 596 | $aprs_connect = 0; |
598 | 597 | $aprs_keep = 120; |
599 | 598 | $aprs_last_tx = time(); |
600 | 599 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
601 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
600 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
602 | 601 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
603 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
602 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
604 | 603 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
605 | 604 | else $aprs_pass = '-1'; |
606 | 605 | |
607 | - $aprs_filter = ''; |
|
606 | + $aprs_filter = ''; |
|
608 | 607 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
609 | 608 | $Common = new Common(); |
610 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); |
|
609 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); |
|
611 | 610 | if ($s !== false) { |
612 | 611 | echo 'Connected to APRS server! '."\n"; |
613 | 612 | $authstart = time(); |
614 | 613 | $this->socket = $s; |
615 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
|
616 | - socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); |
|
617 | - while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
|
614 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); |
|
615 | + socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1); |
|
616 | + while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { |
|
618 | 617 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
619 | 618 | echo 'APRS user verified !'."\n"; |
620 | 619 | $this->connected = true; |
621 | 620 | return true; |
622 | 621 | break; |
623 | 622 | } |
624 | - if (time()-$authstart > 5) { |
|
623 | + if (time() - $authstart > 5) { |
|
625 | 624 | echo 'APRS timeout'."\n"; |
626 | 625 | break; |
627 | 626 | } |
@@ -636,7 +635,7 @@ discard block |
||
636 | 635 | public function send($data) { |
637 | 636 | global $globalDebug; |
638 | 637 | if ($this->connected === false) $this->connect(); |
639 | - $send = socket_send( $this->socket , $data , strlen($data),0); |
|
638 | + $send = socket_send($this->socket, $data, strlen($data), 0); |
|
640 | 639 | if ($send === FALSE) { |
641 | 640 | if ($globalDebug) echo 'Reconnect...'; |
642 | 641 | socket_close($this->socket); |
@@ -646,14 +645,14 @@ discard block |
||
646 | 645 | } |
647 | 646 | |
648 | 647 | class APRSSpotter extends APRS { |
649 | - public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) { |
|
648 | + public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) { |
|
650 | 649 | $Common = new Common(); |
651 | 650 | if ($latitude != '' && $longitude != '') { |
652 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
653 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
654 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
655 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
656 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
651 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
652 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
653 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
654 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
655 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
657 | 656 | $w = $w1.$w2; |
658 | 657 | //$w = '00'; |
659 | 658 | $custom = ''; |
@@ -674,25 +673,25 @@ discard block |
||
674 | 673 | $custom .= 'AI='.$aircraft_icao; |
675 | 674 | } |
676 | 675 | if ($custom != '') $custom = ' '.$custom; |
677 | - $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
676 | + $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
678 | 677 | } |
679 | 678 | } |
680 | 679 | } |
681 | 680 | class APRSMarine extends APRS { |
682 | - public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) { |
|
681 | + public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) { |
|
683 | 682 | $Common = new Common(); |
684 | 683 | if ($latitude != '' && $longitude != '') { |
685 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
686 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
687 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
688 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
689 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
684 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
685 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
686 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
687 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
688 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
690 | 689 | $w = $w1.$w2; |
691 | 690 | //$w = '00'; |
692 | 691 | $custom = ''; |
693 | 692 | if ($ident != '') { |
694 | 693 | if ($custom != '') $custom .= '/'; |
695 | - $custom .= 'CS='.str_replace(' ','_',$ident); |
|
694 | + $custom .= 'CS='.str_replace(' ', '_', $ident); |
|
696 | 695 | } |
697 | 696 | if ($typeid != '') { |
698 | 697 | if ($custom != '') $custom .= '/'; |
@@ -712,11 +711,11 @@ discard block |
||
712 | 711 | } |
713 | 712 | if ($arrival_code != '') { |
714 | 713 | if ($custom != '') $custom .= '/'; |
715 | - $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
|
714 | + $custom .= 'AC='.str_replace(' ', '_', $arrival_code); |
|
716 | 715 | } |
717 | 716 | if ($custom != '') $custom = ' '.$custom; |
718 | 717 | $altitude = 0; |
719 | - $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
718 | + $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
720 | 719 | } |
721 | 720 | } |
722 | 721 | } |