@@ -4,8 +4,8 @@ |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['airport'])) { |
7 | - header('Location: '.$globalURL.'/airport'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/airport'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING); |
11 | 11 | $Spotter = new Spotter(); |
@@ -5,8 +5,8 @@ |
||
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | |
7 | 7 | if (!isset($_GET['aircraft_type'])) { |
8 | - header('Location: '.$globalURL.'/aircraft'); |
|
9 | - die(); |
|
8 | + header('Location: '.$globalURL.'/aircraft'); |
|
9 | + die(); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | $aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING); |
@@ -4,8 +4,8 @@ |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['aircraft_manufacturer'])) { |
7 | - header('Location: '.$globalURL.'/manufacturer'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/manufacturer'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $Spotter = new Spotter(); |
11 | 11 | $manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))); |
@@ -48,7 +48,7 @@ |
||
48 | 48 | $metar_info = $METAR->getMETAR($airport_icao); |
49 | 49 | //print_r($metar_info); |
50 | 50 | if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']); |
51 | - //print_r($metar_parse); |
|
51 | + //print_r($metar_parse); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | $title = sprintf(_("Detailed View for %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']); |
@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['country'])) { |
6 | - header('Location: '.$globalURL.'/country'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/country'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | </tr> |
318 | 318 | <!-- |
319 | 319 | <?php |
320 | - require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
321 | - $Connection = new Connection(); |
|
320 | + require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
321 | + $Connection = new Connection(); |
|
322 | 322 | ?> |
323 | 323 | --> |
324 | 324 | <?php |
325 | - if ($Connection->db != NULL) { |
|
325 | + if ($Connection->db != NULL) { |
|
326 | 326 | if ($Connection->tableExists('source_location')) { |
327 | - require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
328 | - $Source = new Source(); |
|
329 | - //$alllocations = $Source->getAllLocationInfo(); |
|
330 | - $alllocations = $Source->getLocationInfobyType(''); |
|
331 | - foreach ($alllocations as $location) { |
|
327 | + require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
328 | + $Source = new Source(); |
|
329 | + //$alllocations = $Source->getAllLocationInfo(); |
|
330 | + $alllocations = $Source->getLocationInfobyType(''); |
|
331 | + foreach ($alllocations as $location) { |
|
332 | 332 | ?> |
333 | 333 | <tr> |
334 | 334 | <input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" /> |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | </tr> |
343 | 343 | |
344 | 344 | <?php |
345 | - } |
|
345 | + } |
|
346 | + } |
|
346 | 347 | } |
347 | - } |
|
348 | 348 | ?> |
349 | 349 | |
350 | 350 | <tr> |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | ?> |
453 | 453 | <tr> |
454 | 454 | <?php |
455 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
455 | + if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
456 | 456 | ?> |
457 | 457 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
458 | 458 | <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
459 | 459 | <?php |
460 | - } else { |
|
460 | + } else { |
|
461 | 461 | $hostport = explode(':',$source['host']); |
462 | 462 | if (isset($hostport[1])) { |
463 | 463 | $host = $hostport[0]; |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | <td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td> |
471 | 471 | <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php print $port; ?>" /></td> |
472 | 472 | <?php |
473 | - } |
|
473 | + } |
|
474 | 474 | ?> |
475 | 475 | <td> |
476 | 476 | <select name="format[]" id="format"> |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | <br /> |
881 | 881 | <p> |
882 | 882 | <?php |
883 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
883 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
884 | 884 | ?> |
885 | 885 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
886 | 886 | <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
@@ -890,11 +890,11 @@ discard block |
||
890 | 890 | <b>The directory cache is not writable, aircraft icon will not be cached</b> |
891 | 891 | <?php |
892 | 892 | } |
893 | - } else { |
|
893 | + } else { |
|
894 | 894 | ?> |
895 | 895 | <b>PHP GD is not installed, you can't change color of aircraft icon on map</b> |
896 | 896 | <?php |
897 | - } |
|
897 | + } |
|
898 | 898 | ?> |
899 | 899 | </p> |
900 | 900 | <br /> |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | </p> |
919 | 919 | <?php |
920 | 920 | require('../footer.php'); |
921 | - exit; |
|
921 | + exit; |
|
922 | 922 | } |
923 | 923 | // ' |
924 | 924 | $settings = array(); |
@@ -1009,8 +1009,8 @@ discard block |
||
1009 | 1009 | |
1010 | 1010 | $sources = array(); |
1011 | 1011 | foreach ($source_name as $keys => $name) { |
1012 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1013 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1012 | + if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1013 | + else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1014 | 1014 | } |
1015 | 1015 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
1016 | 1016 | |
@@ -1392,14 +1392,14 @@ discard block |
||
1392 | 1392 | |
1393 | 1393 | // Set some defaults values... |
1394 | 1394 | if (!isset($globalAircraftImageSources)) { |
1395 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1396 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1395 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1396 | + $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1397 | 1397 | } |
1398 | 1398 | |
1399 | 1399 | if (!isset($globalSchedulesSources)) { |
1400 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1401 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1402 | - } |
|
1400 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1401 | + $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1402 | + } |
|
1403 | 1403 | |
1404 | 1404 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1405 | 1405 | |
@@ -1446,21 +1446,21 @@ discard block |
||
1446 | 1446 | $popi = false; |
1447 | 1447 | $popw = false; |
1448 | 1448 | foreach ($_SESSION['done'] as $done) { |
1449 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1450 | - if ($done == 'Create database') $pop = true; |
|
1451 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1452 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1453 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1449 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1450 | + if ($done == 'Create database') $pop = true; |
|
1451 | + if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1452 | + if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1453 | + if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1454 | 1454 | } |
1455 | 1455 | if ($pop) { |
1456 | - sleep(5); |
|
1457 | - print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1456 | + sleep(5); |
|
1457 | + print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1458 | 1458 | } else if ($popi) { |
1459 | - sleep(5); |
|
1460 | - print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1459 | + sleep(5); |
|
1460 | + print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1461 | 1461 | } else if ($popw) { |
1462 | - sleep(5); |
|
1463 | - print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1462 | + sleep(5); |
|
1463 | + print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1464 | 1464 | } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
1465 | 1465 | print '</div></ul>'; |
1466 | 1466 | print '<div id="error"></div>'; |
@@ -1523,7 +1523,7 @@ discard block |
||
1523 | 1523 | unset($_COOKIE['install']); |
1524 | 1524 | print '<div class="info column"><ul>'; |
1525 | 1525 | foreach ($_SESSION['done'] as $done) { |
1526 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1526 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1527 | 1527 | } |
1528 | 1528 | print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>'; |
1529 | 1529 | print '</ul></div>'; |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | $coords = explode(',',$_GET['coord']); |
16 | 16 | // $spotter_array = Source::getAllLocationInfobyCoord($coords); |
17 | 17 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
18 | - || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
18 | + || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
19 | 19 | $spotter_array = $Source->getAllLocationInfo(); |
20 | 20 | } else { |
21 | 21 | $spotter_array = $Source->getLocationInfoByType(''); |
22 | 22 | } |
23 | 23 | } else { |
24 | 24 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
25 | - || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
25 | + || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
26 | 26 | $spotter_array = $Source->getAllLocationInfo(); |
27 | 27 | } else { |
28 | 28 | $spotter_array = $Source->getLocationInfoByType(''); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | date_default_timezone_set('UTC'); |
39 | 39 | //waypoint plotting |
40 | 40 | $output .= '{"type": "Feature",'; |
41 | - $output .= '"properties": {'; |
|
41 | + $output .= '"properties": {'; |
|
42 | 42 | $output .= '"id": "'.$spotter_item['id'].'",'; |
43 | 43 | $output .= '"location_id": "'.$spotter_item['location_id'].'",'; |
44 | 44 | $output .= '"name": "'.$spotter_item['name'].'",'; |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",'; |
57 | 57 | } |
58 | 58 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
59 | - $output .= '},'; |
|
60 | - $output .= '"geometry": {'; |
|
59 | + $output .= '},'; |
|
60 | + $output .= '"geometry": {'; |
|
61 | 61 | $output .= '"type": "Point",'; |
62 | 62 | $output .= '"coordinates": ['; |
63 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
63 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
64 | 64 | $output .= ']'; |
65 | - $output .= '}'; |
|
65 | + $output .= '}'; |
|
66 | 66 | $output .= '},'; |
67 | 67 | } |
68 | 68 | $output = substr($output, 0, -1); |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); |
4 | 4 | class aprs { |
5 | - private $socket; |
|
6 | - private $connected = false; |
|
5 | + private $socket; |
|
6 | + private $connected = false; |
|
7 | 7 | |
8 | - protected $symbols = array('/!' => 'Police', |
|
8 | + protected $symbols = array('/!' => 'Police', |
|
9 | 9 | '/#' => 'DIGI', |
10 | 10 | '/$' => 'Phone', |
11 | 11 | '/%' => 'DX Cluster', |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | '\~' => 'TNC Stream SW'); |
166 | 166 | |
167 | 167 | |
168 | - private function urshift($n, $s) { |
|
168 | + private function urshift($n, $s) { |
|
169 | 169 | return ($n >= 0) ? ($n >> $s) : |
170 | - (($n & 0x7fffffff) >> $s) | |
|
170 | + (($n & 0x7fffffff) >> $s) | |
|
171 | 171 | (0x40000000 >> ($s - 1)); |
172 | - } |
|
172 | + } |
|
173 | 173 | |
174 | - public function parse($input) { |
|
174 | + public function parse($input) { |
|
175 | 175 | global $globalDebug; |
176 | 176 | $debug = false; |
177 | 177 | $result = array(); |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | |
184 | 184 | /* Check that end was found and body has at least one byte. */ |
185 | 185 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
186 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
187 | - return false; |
|
186 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
187 | + return false; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | if ($debug) echo 'input : '.$input."\n"; |
@@ -198,34 +198,34 @@ discard block |
||
198 | 198 | /* Parse source, target and path. */ |
199 | 199 | //FLRDF0A52>APRS,qAS,LSTB |
200 | 200 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
201 | - $ident = $matches[1]; |
|
202 | - $all_elements = $matches[2]; |
|
203 | - if ($ident == 'AIRCRAFT') { |
|
201 | + $ident = $matches[1]; |
|
202 | + $all_elements = $matches[2]; |
|
203 | + if ($ident == 'AIRCRAFT') { |
|
204 | 204 | $result['format_source'] = 'famaprs'; |
205 | 205 | $result['source_type'] = 'modes'; |
206 | - } elseif ($ident == 'MARINE') { |
|
206 | + } elseif ($ident == 'MARINE') { |
|
207 | 207 | $result['format_source'] = 'famaprs'; |
208 | 208 | $result['source_type'] = 'ais'; |
209 | - } else { |
|
209 | + } else { |
|
210 | 210 | if ($debug) echo 'ident : '.$ident."\n"; |
211 | 211 | $result['ident'] = $ident; |
212 | - } |
|
212 | + } |
|
213 | 213 | } else { |
214 | - if ($debug) 'No ident'."\n"; |
|
215 | - return false; |
|
214 | + if ($debug) 'No ident'."\n"; |
|
215 | + return false; |
|
216 | 216 | } |
217 | 217 | $elements = explode(',',$all_elements); |
218 | 218 | $source = end($elements); |
219 | 219 | $result['source'] = $source; |
220 | 220 | foreach ($elements as $element) { |
221 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
222 | - //echo "ok"; |
|
223 | - //if ($element == 'TCPIP*') return false; |
|
224 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
221 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
222 | + //echo "ok"; |
|
223 | + //if ($element == 'TCPIP*') return false; |
|
224 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
225 | 225 | if ($debug) echo 'element : '.$element."\n"; |
226 | 226 | return false; |
227 | - } |
|
228 | - /* |
|
227 | + } |
|
228 | + /* |
|
229 | 229 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
230 | 230 | //echo "ok"; |
231 | 231 | } else { |
@@ -252,48 +252,48 @@ discard block |
||
252 | 252 | $body_parse = substr($body,1); |
253 | 253 | //echo 'Body : '.$body."\n"; |
254 | 254 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
255 | - $body_parse = substr($body_parse,10); |
|
256 | - $find = true; |
|
257 | - //echo $body_parse."\n"; |
|
255 | + $body_parse = substr($body_parse,10); |
|
256 | + $find = true; |
|
257 | + //echo $body_parse."\n"; |
|
258 | 258 | } |
259 | 259 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
260 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
261 | - $find = true; |
|
262 | - //echo $body_parse."\n"; |
|
260 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
261 | + $find = true; |
|
262 | + //echo $body_parse."\n"; |
|
263 | 263 | } |
264 | 264 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
265 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
266 | - $find = true; |
|
267 | - //echo $body_parse."\n"; |
|
265 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
266 | + $find = true; |
|
267 | + //echo $body_parse."\n"; |
|
268 | 268 | } |
269 | 269 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
270 | - $find = true; |
|
271 | - //print_r($matches); |
|
272 | - $timestamp = $matches[0]; |
|
273 | - if ($matches[4] == 'h') { |
|
270 | + $find = true; |
|
271 | + //print_r($matches); |
|
272 | + $timestamp = $matches[0]; |
|
273 | + if ($matches[4] == 'h') { |
|
274 | 274 | $timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]); |
275 | 275 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
276 | 276 | /* |
277 | 277 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
278 | 278 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
279 | 279 | */ |
280 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
280 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
281 | 281 | // This work or not ? |
282 | 282 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
283 | - } |
|
284 | - $body_parse = substr($body_parse,7); |
|
285 | - $result['timestamp'] = $timestamp; |
|
286 | - //echo date('Ymd H:i:s',$timestamp); |
|
283 | + } |
|
284 | + $body_parse = substr($body_parse,7); |
|
285 | + $result['timestamp'] = $timestamp; |
|
286 | + //echo date('Ymd H:i:s',$timestamp); |
|
287 | 287 | } |
288 | 288 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
289 | - $find = true; |
|
290 | - $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
291 | - $body_parse = substr($body_parse,8); |
|
292 | - $result['timestamp'] = $timestamp; |
|
293 | - //echo date('Ymd H:i:s',$timestamp); |
|
289 | + $find = true; |
|
290 | + $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
291 | + $body_parse = substr($body_parse,8); |
|
292 | + $result['timestamp'] = $timestamp; |
|
293 | + //echo date('Ymd H:i:s',$timestamp); |
|
294 | 294 | } |
295 | 295 | //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)) { |
|
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)) { |
|
297 | 297 | $find = true; |
298 | 298 | // 4658.70N/00707.78Ez |
299 | 299 | //print_r(str_split($body_parse)); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $lon = intval($lon_deg); |
313 | 313 | if ($lat > 89 || $lon > 179) return false; |
314 | 314 | |
315 | - /* |
|
315 | + /* |
|
316 | 316 | $tmp_5b = str_replace('.','',$lat_min); |
317 | 317 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
318 | 318 | print_r($matches); |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | $result['longitude'] = $longitude; |
327 | 327 | $body_parse = substr($body_parse,18); |
328 | 328 | $body_parse_len = strlen($body_parse); |
329 | - } |
|
330 | - $body_parse_len = strlen($body_parse); |
|
331 | - if ($body_parse_len > 0) { |
|
329 | + } |
|
330 | + $body_parse_len = strlen($body_parse); |
|
331 | + if ($body_parse_len > 0) { |
|
332 | 332 | /* |
333 | 333 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
334 | 334 | $body_split = str_split($body); |
@@ -362,95 +362,95 @@ discard block |
||
362 | 362 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
363 | 363 | if ($symbol_code != '_') { |
364 | 364 | } |
365 | - //$body_parse = substr($body_parse,1); |
|
366 | - //$body_parse = trim($body_parse); |
|
367 | - //$body_parse_len = strlen($body_parse); |
|
368 | - if ($body_parse_len >= 7) { |
|
365 | + //$body_parse = substr($body_parse,1); |
|
366 | + //$body_parse = trim($body_parse); |
|
367 | + //$body_parse_len = strlen($body_parse); |
|
368 | + if ($body_parse_len >= 7) { |
|
369 | 369 | |
370 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
371 | - $course = substr($body_parse,0,3); |
|
372 | - $tmp_s = intval($course); |
|
373 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
374 | - $speed = substr($body_parse,4,3); |
|
375 | - if ($speed != '...') { |
|
376 | - //$result['speed'] = round($speed*1.852); |
|
377 | - $result['speed'] = intval($speed); |
|
378 | - } |
|
379 | - $body_parse = substr($body_parse,7); |
|
380 | - } |
|
381 | - // Check PHGR, PHG, RNG |
|
382 | - } |
|
383 | - /* |
|
370 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
371 | + $course = substr($body_parse,0,3); |
|
372 | + $tmp_s = intval($course); |
|
373 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
374 | + $speed = substr($body_parse,4,3); |
|
375 | + if ($speed != '...') { |
|
376 | + //$result['speed'] = round($speed*1.852); |
|
377 | + $result['speed'] = intval($speed); |
|
378 | + } |
|
379 | + $body_parse = substr($body_parse,7); |
|
380 | + } |
|
381 | + // Check PHGR, PHG, RNG |
|
382 | + } |
|
383 | + /* |
|
384 | 384 | else if ($body_parse_len > 0) { |
385 | 385 | $rest = $body_parse; |
386 | 386 | } |
387 | 387 | */ |
388 | - if (strlen($body_parse) > 0) { |
|
389 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
390 | - $altitude = intval($matches[1]); |
|
391 | - //$result['altitude'] = round($altitude*0.3048); |
|
392 | - $result['altitude'] = $altitude; |
|
393 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
394 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
395 | - } |
|
396 | - } |
|
388 | + if (strlen($body_parse) > 0) { |
|
389 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
390 | + $altitude = intval($matches[1]); |
|
391 | + //$result['altitude'] = round($altitude*0.3048); |
|
392 | + $result['altitude'] = $altitude; |
|
393 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
394 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
395 | + } |
|
396 | + } |
|
397 | 397 | |
398 | - // Telemetry |
|
399 | - /* |
|
398 | + // Telemetry |
|
399 | + /* |
|
400 | 400 | if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
401 | 401 | // Nothing yet... |
402 | 402 | } |
403 | 403 | */ |
404 | - // DAO |
|
404 | + // DAO |
|
405 | 405 | |
406 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
406 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
407 | 407 | |
408 | - $dao = $matches[1]; |
|
409 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
408 | + $dao = $matches[1]; |
|
409 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
410 | 410 | $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; |
|
411 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
412 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
413 | 413 | |
414 | 414 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
415 | 415 | else $result['latitude'] += $lat_off; |
416 | 416 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
417 | 417 | else $result['longitude'] += $lon_off; |
418 | - } |
|
418 | + } |
|
419 | 419 | |
420 | - $body_parse = substr($body_parse,6); |
|
421 | - } |
|
420 | + $body_parse = substr($body_parse,6); |
|
421 | + } |
|
422 | 422 | |
423 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
423 | + if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
424 | 424 | $result['ident'] = str_replace('_',' ',$matches[1]); |
425 | - } |
|
426 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
425 | + } |
|
426 | + if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
427 | 427 | $result['squawk'] = $matches[1]; |
428 | - } |
|
429 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
428 | + } |
|
429 | + if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
430 | 430 | $result['aircraft_icao'] = $matches[1]; |
431 | - } |
|
432 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
431 | + } |
|
432 | + if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
433 | 433 | $result['verticalrate'] = $matches[1]; |
434 | - } |
|
435 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
434 | + } |
|
435 | + if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
436 | 436 | $result['typeid'] = $matches[1]; |
437 | - } |
|
438 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
437 | + } |
|
438 | + if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
439 | 439 | $result['statusid'] = $matches[1]; |
440 | - } |
|
441 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
440 | + } |
|
441 | + if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
442 | 442 | $result['imo'] = $matches[1]; |
443 | - } |
|
444 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
443 | + } |
|
444 | + if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
445 | 445 | $result['arrival_date'] = $matches[1]; |
446 | - } |
|
447 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
446 | + } |
|
447 | + if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
448 | 448 | $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
449 | - } |
|
450 | - // OGN comment |
|
449 | + } |
|
450 | + // OGN comment |
|
451 | 451 | // echo "Before OGN : ".$body_parse."\n"; |
452 | - //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}) ([+-])([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)) { |
|
454 | 454 | $id = $matches[1]; |
455 | 455 | //$mode = substr($id,0,2); |
456 | 456 | $address = substr($id,2); |
@@ -480,42 +480,42 @@ discard block |
||
480 | 480 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
481 | 481 | $result['stealth'] = $stealth; |
482 | 482 | $result['address'] = $address; |
483 | - } |
|
483 | + } |
|
484 | 484 | |
485 | - //Comment |
|
486 | - $result['comment'] = trim($body_parse); |
|
485 | + //Comment |
|
486 | + $result['comment'] = trim($body_parse); |
|
487 | 487 | //} else { |
488 | - // parse weather |
|
489 | - //$body_parse = substr($body_parse,1); |
|
490 | - //$body_parse_len = strlen($body_parse); |
|
491 | - //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)) { |
|
493 | - $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)) { |
|
488 | + // parse weather |
|
489 | + //$body_parse = substr($body_parse,1); |
|
490 | + //$body_parse_len = strlen($body_parse); |
|
491 | + //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)) { |
|
493 | + $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)) { |
|
499 | 499 | $result['wind_dir'] = intval($matches[1]); |
500 | 500 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
501 | 501 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
502 | 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)) { |
|
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)) { |
|
505 | 505 | $result['wind_dir'] = intval($matches[1]); |
506 | 506 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
507 | 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)) { |
|
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)) { |
|
510 | 510 | $result['wind_dir'] = intval($matches[1]); |
511 | 511 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
512 | 512 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
513 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
514 | - } |
|
515 | - //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
516 | - //g012t088r000p000P000h38b10110 |
|
517 | - //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)) { |
|
513 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
514 | + } |
|
515 | + //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
516 | + //g012t088r000p000P000h38b10110 |
|
517 | + //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 | 519 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
520 | 520 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
521 | 521 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
@@ -523,8 +523,8 @@ discard block |
||
523 | 523 | if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
524 | 524 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
525 | 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)) { |
|
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 | 528 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
529 | 529 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
530 | 530 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
@@ -532,8 +532,8 @@ discard block |
||
532 | 532 | if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
533 | 533 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
534 | 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)) { |
|
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 | 537 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
538 | 538 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
539 | 539 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
@@ -541,58 +541,58 @@ discard block |
||
541 | 541 | if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
542 | 542 | if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
543 | 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)) { |
|
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 | 546 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
547 | 547 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
548 | 548 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
549 | 549 | if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
550 | 550 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
551 | 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)) { |
|
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 | 554 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
555 | 555 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
556 | 556 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
557 | 557 | if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
558 | 558 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
559 | 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)) { |
|
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 | 562 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
563 | 563 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
564 | 564 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
565 | 565 | if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
566 | 566 | if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
567 | 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)) { |
|
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 | 570 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
571 | 571 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
572 | 572 | if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
573 | 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)) { |
|
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 | 576 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
577 | 577 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
578 | 578 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
579 | 579 | if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
580 | 580 | if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
581 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
582 | - } |
|
583 | - $result['comment'] = trim($body_parse); |
|
581 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
582 | + } |
|
583 | + $result['comment'] = trim($body_parse); |
|
584 | 584 | } |
585 | 585 | } else $result['comment'] = trim($body_parse); |
586 | 586 | |
587 | - } |
|
587 | + } |
|
588 | 588 | //} |
589 | 589 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
590 | 590 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
591 | 591 | if ($debug) print_r($result); |
592 | 592 | return $result; |
593 | - } |
|
593 | + } |
|
594 | 594 | |
595 | - public function connect() { |
|
595 | + public function connect() { |
|
596 | 596 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
597 | 597 | $aprs_connect = 0; |
598 | 598 | $aprs_keep = 120; |
@@ -616,24 +616,24 @@ discard block |
||
616 | 616 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); |
617 | 617 | while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
618 | 618 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
619 | - echo 'APRS user verified !'."\n"; |
|
620 | - $this->connected = true; |
|
621 | - return true; |
|
622 | - break; |
|
619 | + echo 'APRS user verified !'."\n"; |
|
620 | + $this->connected = true; |
|
621 | + return true; |
|
622 | + break; |
|
623 | 623 | } |
624 | 624 | if (time()-$authstart > 5) { |
625 | - echo 'APRS timeout'."\n"; |
|
626 | - break; |
|
625 | + echo 'APRS timeout'."\n"; |
|
626 | + break; |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | } |
630 | - } |
|
630 | + } |
|
631 | 631 | |
632 | - public function disconnect() { |
|
632 | + public function disconnect() { |
|
633 | 633 | socket_close($this->socket); |
634 | - } |
|
634 | + } |
|
635 | 635 | |
636 | - public function send($data) { |
|
636 | + public function send($data) { |
|
637 | 637 | global $globalDebug; |
638 | 638 | if ($this->connected === false) $this->connect(); |
639 | 639 | $send = socket_send( $this->socket , $data , strlen($data),0); |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | socket_close($this->socket); |
643 | 643 | $this->connect(); |
644 | 644 | } |
645 | - } |
|
645 | + } |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | class APRSSpotter extends APRS { |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets all the spotter information based on the latest data entry |
|
90 | - * |
|
91 | - * @return Array the spotter information |
|
92 | - * |
|
93 | - */ |
|
89 | + * Gets all the spotter information based on the latest data entry |
|
90 | + * |
|
91 | + * @return Array the spotter information |
|
92 | + * |
|
93 | + */ |
|
94 | 94 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
95 | 95 | { |
96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Gets Minimal Live Spotter data |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
135 | + * Gets Minimal Live Spotter data |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | 140 | public function getMinLiveTrackerData($filter = array()) |
141 | 141 | { |
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | - * Gets Minimal Live Spotter data since xx seconds |
|
174 | - * |
|
175 | - * @return Array the spotter information |
|
176 | - * |
|
177 | - */ |
|
173 | + * Gets Minimal Live Spotter data since xx seconds |
|
174 | + * |
|
175 | + * @return Array the spotter information |
|
176 | + * |
|
177 | + */ |
|
178 | 178 | public function getMinLastLiveTrackerData($filter = array()) |
179 | 179 | { |
180 | 180 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | - * Gets number of latest data entry |
|
234 | - * |
|
235 | - * @return String number of entry |
|
236 | - * |
|
237 | - */ |
|
233 | + * Gets number of latest data entry |
|
234 | + * |
|
235 | + * @return String number of entry |
|
236 | + * |
|
237 | + */ |
|
238 | 238 | public function getLiveTrackerCount($filter = array()) |
239 | 239 | { |
240 | 240 | global $globalDBdriver, $globalLiveInterval; |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
262 | - * Gets all the spotter information based on the latest data entry and coord |
|
263 | - * |
|
264 | - * @return Array the spotter information |
|
265 | - * |
|
266 | - */ |
|
262 | + * Gets all the spotter information based on the latest data entry and coord |
|
263 | + * |
|
264 | + * @return Array the spotter information |
|
265 | + * |
|
266 | + */ |
|
267 | 267 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
268 | 268 | { |
269 | 269 | global $globalDBdriver, $globalLiveInterval; |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
290 | - * Gets all the spotter information based on the latest data entry and coord |
|
291 | - * |
|
292 | - * @return Array the spotter information |
|
293 | - * |
|
294 | - */ |
|
290 | + * Gets all the spotter information based on the latest data entry and coord |
|
291 | + * |
|
292 | + * @return Array the spotter information |
|
293 | + * |
|
294 | + */ |
|
295 | 295 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
296 | 296 | { |
297 | 297 | global $globalDBdriver, $globalLiveInterval; |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
321 | - * Gets all the spotter information based on a user's latitude and longitude |
|
322 | - * |
|
323 | - * @return Array the spotter information |
|
324 | - * |
|
325 | - */ |
|
321 | + * Gets all the spotter information based on a user's latitude and longitude |
|
322 | + * |
|
323 | + * @return Array the spotter information |
|
324 | + * |
|
325 | + */ |
|
326 | 326 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
327 | 327 | { |
328 | 328 | $Tracker = new Tracker($this->db); |
@@ -335,142 +335,142 @@ discard block |
||
335 | 335 | if ($lng != '') |
336 | 336 | { |
337 | 337 | if (!is_numeric($lng)) |
338 | - { |
|
339 | - return false; |
|
340 | - } |
|
341 | - } |
|
342 | - |
|
343 | - if ($radius != '') |
|
344 | - { |
|
345 | - if (!is_numeric($radius)) |
|
346 | - { |
|
347 | - return false; |
|
348 | - } |
|
349 | - } |
|
338 | + { |
|
339 | + return false; |
|
340 | + } |
|
341 | + } |
|
342 | + |
|
343 | + if ($radius != '') |
|
344 | + { |
|
345 | + if (!is_numeric($radius)) |
|
346 | + { |
|
347 | + return false; |
|
348 | + } |
|
349 | + } |
|
350 | 350 | $additional_query = ''; |
351 | 351 | if ($interval != '') |
352 | - { |
|
353 | - if (!is_string($interval)) |
|
354 | - { |
|
355 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
356 | - return false; |
|
357 | - } else { |
|
358 | - if ($interval == '1m') |
|
359 | - { |
|
360 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
361 | - } else if ($interval == '15m'){ |
|
362 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
363 | - } |
|
364 | - } |
|
365 | - } else { |
|
366 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
367 | - } |
|
368 | - |
|
369 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
352 | + { |
|
353 | + if (!is_string($interval)) |
|
354 | + { |
|
355 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
356 | + return false; |
|
357 | + } else { |
|
358 | + if ($interval == '1m') |
|
359 | + { |
|
360 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
361 | + } else if ($interval == '15m'){ |
|
362 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
363 | + } |
|
364 | + } |
|
365 | + } else { |
|
366 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
367 | + } |
|
368 | + |
|
369 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
370 | 370 | WHERE tracker_live.latitude <> '' |
371 | 371 | AND tracker_live.longitude <> '' |
372 | 372 | ".$additional_query." |
373 | 373 | HAVING distance < :radius |
374 | 374 | ORDER BY distance"; |
375 | 375 | |
376 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
376 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
377 | 377 | |
378 | - return $spotter_array; |
|
379 | - } |
|
378 | + return $spotter_array; |
|
379 | + } |
|
380 | 380 | |
381 | 381 | |
382 | - /** |
|
383 | - * Gets all the spotter information based on a particular callsign |
|
384 | - * |
|
385 | - * @return Array the spotter information |
|
386 | - * |
|
387 | - */ |
|
382 | + /** |
|
383 | + * Gets all the spotter information based on a particular callsign |
|
384 | + * |
|
385 | + * @return Array the spotter information |
|
386 | + * |
|
387 | + */ |
|
388 | 388 | public function getLastLiveTrackerDataByIdent($ident) |
389 | 389 | { |
390 | 390 | $Tracker = new Tracker($this->db); |
391 | 391 | date_default_timezone_set('UTC'); |
392 | 392 | |
393 | 393 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
394 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
394 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
395 | 395 | |
396 | 396 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
397 | 397 | |
398 | 398 | return $spotter_array; |
399 | 399 | } |
400 | 400 | |
401 | - /** |
|
402 | - * Gets all the spotter information based on a particular callsign |
|
403 | - * |
|
404 | - * @return Array the spotter information |
|
405 | - * |
|
406 | - */ |
|
401 | + /** |
|
402 | + * Gets all the spotter information based on a particular callsign |
|
403 | + * |
|
404 | + * @return Array the spotter information |
|
405 | + * |
|
406 | + */ |
|
407 | 407 | public function getDateLiveTrackerDataByIdent($ident,$date) |
408 | 408 | { |
409 | 409 | $Tracker = new Tracker($this->db); |
410 | 410 | date_default_timezone_set('UTC'); |
411 | 411 | |
412 | 412 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
413 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
413 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
414 | 414 | |
415 | - $date = date('c',$date); |
|
415 | + $date = date('c',$date); |
|
416 | 416 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
417 | 417 | |
418 | 418 | return $spotter_array; |
419 | 419 | } |
420 | 420 | |
421 | - /** |
|
422 | - * Gets last spotter information based on a particular callsign |
|
423 | - * |
|
424 | - * @return Array the spotter information |
|
425 | - * |
|
426 | - */ |
|
421 | + /** |
|
422 | + * Gets last spotter information based on a particular callsign |
|
423 | + * |
|
424 | + * @return Array the spotter information |
|
425 | + * |
|
426 | + */ |
|
427 | 427 | public function getLastLiveTrackerDataById($id) |
428 | 428 | { |
429 | 429 | $Tracker = new Tracker($this->db); |
430 | 430 | date_default_timezone_set('UTC'); |
431 | 431 | |
432 | 432 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
433 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
433 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
434 | 434 | |
435 | 435 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
436 | 436 | |
437 | 437 | return $spotter_array; |
438 | 438 | } |
439 | 439 | |
440 | - /** |
|
441 | - * Gets last spotter information based on a particular callsign |
|
442 | - * |
|
443 | - * @return Array the spotter information |
|
444 | - * |
|
445 | - */ |
|
440 | + /** |
|
441 | + * Gets last spotter information based on a particular callsign |
|
442 | + * |
|
443 | + * @return Array the spotter information |
|
444 | + * |
|
445 | + */ |
|
446 | 446 | public function getDateLiveTrackerDataById($id,$date) |
447 | 447 | { |
448 | 448 | $Tracker = new Tracker($this->db); |
449 | 449 | date_default_timezone_set('UTC'); |
450 | 450 | |
451 | 451 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
452 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
453 | - $date = date('c',$date); |
|
452 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
453 | + $date = date('c',$date); |
|
454 | 454 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
455 | 455 | |
456 | 456 | return $spotter_array; |
457 | 457 | } |
458 | 458 | |
459 | - /** |
|
460 | - * Gets altitude information based on a particular callsign |
|
461 | - * |
|
462 | - * @return Array the spotter information |
|
463 | - * |
|
464 | - */ |
|
459 | + /** |
|
460 | + * Gets altitude information based on a particular callsign |
|
461 | + * |
|
462 | + * @return Array the spotter information |
|
463 | + * |
|
464 | + */ |
|
465 | 465 | public function getAltitudeLiveTrackerDataByIdent($ident) |
466 | 466 | { |
467 | 467 | |
468 | 468 | date_default_timezone_set('UTC'); |
469 | 469 | |
470 | 470 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
471 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
471 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
472 | 472 | |
473 | - try { |
|
473 | + try { |
|
474 | 474 | |
475 | 475 | $sth = $this->db->prepare($query); |
476 | 476 | $sth->execute(array(':ident' => $ident)); |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | return $spotter_array; |
484 | 484 | } |
485 | 485 | |
486 | - /** |
|
487 | - * Gets all the spotter information based on a particular id |
|
488 | - * |
|
489 | - * @return Array the spotter information |
|
490 | - * |
|
491 | - */ |
|
486 | + /** |
|
487 | + * Gets all the spotter information based on a particular id |
|
488 | + * |
|
489 | + * @return Array the spotter information |
|
490 | + * |
|
491 | + */ |
|
492 | 492 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
493 | 493 | { |
494 | 494 | global $globalDBdriver, $globalLiveInterval; |
@@ -516,18 +516,18 @@ discard block |
||
516 | 516 | return $spotter_array; |
517 | 517 | } |
518 | 518 | |
519 | - /** |
|
520 | - * Gets all the spotter information based on a particular ident |
|
521 | - * |
|
522 | - * @return Array the spotter information |
|
523 | - * |
|
524 | - */ |
|
519 | + /** |
|
520 | + * Gets all the spotter information based on a particular ident |
|
521 | + * |
|
522 | + * @return Array the spotter information |
|
523 | + * |
|
524 | + */ |
|
525 | 525 | public function getAllLiveTrackerDataByIdent($ident) |
526 | 526 | { |
527 | 527 | date_default_timezone_set('UTC'); |
528 | 528 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
529 | 529 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
530 | - try { |
|
530 | + try { |
|
531 | 531 | |
532 | 532 | $sth = $this->db->prepare($query); |
533 | 533 | $sth->execute(array(':ident' => $ident)); |
@@ -541,23 +541,23 @@ discard block |
||
541 | 541 | |
542 | 542 | |
543 | 543 | /** |
544 | - * Deletes all info in the table |
|
545 | - * |
|
546 | - * @return String success or false |
|
547 | - * |
|
548 | - */ |
|
544 | + * Deletes all info in the table |
|
545 | + * |
|
546 | + * @return String success or false |
|
547 | + * |
|
548 | + */ |
|
549 | 549 | public function deleteLiveTrackerData() |
550 | 550 | { |
551 | 551 | global $globalDBdriver; |
552 | 552 | if ($globalDBdriver == 'mysql') { |
553 | 553 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
554 | 554 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
555 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
555 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
556 | 556 | } else { |
557 | 557 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
558 | 558 | } |
559 | 559 | |
560 | - try { |
|
560 | + try { |
|
561 | 561 | |
562 | 562 | $sth = $this->db->prepare($query); |
563 | 563 | $sth->execute(); |
@@ -569,18 +569,18 @@ discard block |
||
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
572 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
573 | - * |
|
574 | - * @return String success or false |
|
575 | - * |
|
576 | - */ |
|
572 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
573 | + * |
|
574 | + * @return String success or false |
|
575 | + * |
|
576 | + */ |
|
577 | 577 | public function deleteLiveTrackerDataNotUpdated() |
578 | 578 | { |
579 | 579 | global $globalDBdriver, $globalDebug; |
580 | 580 | if ($globalDBdriver == 'mysql') { |
581 | 581 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
582 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
583 | - try { |
|
582 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
583 | + try { |
|
584 | 584 | |
585 | 585 | $sth = $this->db->prepare($query); |
586 | 586 | $sth->execute(); |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | return "error"; |
589 | 589 | } |
590 | 590 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
591 | - $i = 0; |
|
592 | - $j =0; |
|
591 | + $i = 0; |
|
592 | + $j =0; |
|
593 | 593 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
594 | 594 | foreach($all as $row) |
595 | 595 | { |
@@ -597,20 +597,20 @@ discard block |
||
597 | 597 | $j++; |
598 | 598 | if ($j == 30) { |
599 | 599 | if ($globalDebug) echo "."; |
600 | - try { |
|
600 | + try { |
|
601 | 601 | |
602 | 602 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
603 | 603 | $sth->execute(); |
604 | 604 | } catch(PDOException $e) { |
605 | 605 | return "error"; |
606 | 606 | } |
607 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
608 | - $j = 0; |
|
607 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
608 | + $j = 0; |
|
609 | 609 | } |
610 | 610 | $query_delete .= "'".$row['famtrackid']."',"; |
611 | 611 | } |
612 | 612 | if ($i > 0) { |
613 | - try { |
|
613 | + try { |
|
614 | 614 | |
615 | 615 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
616 | 616 | $sth->execute(); |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | return "success"; |
622 | 622 | } elseif ($globalDBdriver == 'pgsql') { |
623 | 623 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
624 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
625 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
626 | - try { |
|
624 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
625 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
626 | + try { |
|
627 | 627 | |
628 | 628 | $sth = $this->db->prepare($query); |
629 | 629 | $sth->execute(); |
@@ -667,17 +667,17 @@ discard block |
||
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
670 | - * Deletes all info in the table for an ident |
|
671 | - * |
|
672 | - * @return String success or false |
|
673 | - * |
|
674 | - */ |
|
670 | + * Deletes all info in the table for an ident |
|
671 | + * |
|
672 | + * @return String success or false |
|
673 | + * |
|
674 | + */ |
|
675 | 675 | public function deleteLiveTrackerDataByIdent($ident) |
676 | 676 | { |
677 | 677 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
678 | 678 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
679 | 679 | |
680 | - try { |
|
680 | + try { |
|
681 | 681 | |
682 | 682 | $sth = $this->db->prepare($query); |
683 | 683 | $sth->execute(array(':ident' => $ident)); |
@@ -689,17 +689,17 @@ discard block |
||
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
692 | - * Deletes all info in the table for an id |
|
693 | - * |
|
694 | - * @return String success or false |
|
695 | - * |
|
696 | - */ |
|
692 | + * Deletes all info in the table for an id |
|
693 | + * |
|
694 | + * @return String success or false |
|
695 | + * |
|
696 | + */ |
|
697 | 697 | public function deleteLiveTrackerDataById($id) |
698 | 698 | { |
699 | 699 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
700 | 700 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
701 | 701 | |
702 | - try { |
|
702 | + try { |
|
703 | 703 | |
704 | 704 | $sth = $this->db->prepare($query); |
705 | 705 | $sth->execute(array(':id' => $id)); |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | |
713 | 713 | |
714 | 714 | /** |
715 | - * Gets the aircraft ident within the last hour |
|
716 | - * |
|
717 | - * @return String the ident |
|
718 | - * |
|
719 | - */ |
|
715 | + * Gets the aircraft ident within the last hour |
|
716 | + * |
|
717 | + * @return String the ident |
|
718 | + * |
|
719 | + */ |
|
720 | 720 | public function getIdentFromLastHour($ident) |
721 | 721 | { |
722 | 722 | global $globalDBdriver, $globalTimezone; |
@@ -742,14 +742,14 @@ discard block |
||
742 | 742 | $ident_result = $row['ident']; |
743 | 743 | } |
744 | 744 | return $ident_result; |
745 | - } |
|
745 | + } |
|
746 | 746 | |
747 | 747 | /** |
748 | - * Check recent aircraft |
|
749 | - * |
|
750 | - * @return String the ident |
|
751 | - * |
|
752 | - */ |
|
748 | + * Check recent aircraft |
|
749 | + * |
|
750 | + * @return String the ident |
|
751 | + * |
|
752 | + */ |
|
753 | 753 | public function checkIdentRecent($ident) |
754 | 754 | { |
755 | 755 | global $globalDBdriver, $globalTimezone; |
@@ -775,14 +775,14 @@ discard block |
||
775 | 775 | $ident_result = $row['famtrackid']; |
776 | 776 | } |
777 | 777 | return $ident_result; |
778 | - } |
|
778 | + } |
|
779 | 779 | |
780 | 780 | /** |
781 | - * Check recent aircraft by id |
|
782 | - * |
|
783 | - * @return String the ident |
|
784 | - * |
|
785 | - */ |
|
781 | + * Check recent aircraft by id |
|
782 | + * |
|
783 | + * @return String the ident |
|
784 | + * |
|
785 | + */ |
|
786 | 786 | public function checkIdRecent($id) |
787 | 787 | { |
788 | 788 | global $globalDBdriver, $globalTimezone; |
@@ -808,19 +808,19 @@ discard block |
||
808 | 808 | $ident_result = $row['famtrackid']; |
809 | 809 | } |
810 | 810 | return $ident_result; |
811 | - } |
|
811 | + } |
|
812 | 812 | |
813 | 813 | /** |
814 | - * Adds a new spotter data |
|
815 | - * |
|
816 | - * @param String $famtrackid the ID from flightaware |
|
817 | - * @param String $ident the flight ident |
|
818 | - * @param String $aircraft_icao the aircraft type |
|
819 | - * @param String $departure_airport_icao the departure airport |
|
820 | - * @param String $arrival_airport_icao the arrival airport |
|
821 | - * @return String success or false |
|
822 | - * |
|
823 | - */ |
|
814 | + * Adds a new spotter data |
|
815 | + * |
|
816 | + * @param String $famtrackid the ID from flightaware |
|
817 | + * @param String $ident the flight ident |
|
818 | + * @param String $aircraft_icao the aircraft type |
|
819 | + * @param String $departure_airport_icao the departure airport |
|
820 | + * @param String $arrival_airport_icao the arrival airport |
|
821 | + * @return String success or false |
|
822 | + * |
|
823 | + */ |
|
824 | 824 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
825 | 825 | { |
826 | 826 | global $globalURL, $globalArchive, $globalDebug; |
@@ -893,8 +893,8 @@ discard block |
||
893 | 893 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
894 | 894 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
895 | 895 | |
896 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
897 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
896 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
897 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
898 | 898 | |
899 | 899 | $query = ''; |
900 | 900 | if ($globalArchive) { |
@@ -909,18 +909,18 @@ discard block |
||
909 | 909 | |
910 | 910 | $sth = $this->db->prepare($query); |
911 | 911 | $sth->execute($query_values); |
912 | - } catch(PDOException $e) { |
|
913 | - return "error : ".$e->getMessage(); |
|
914 | - } |
|
915 | - /* |
|
912 | + } catch(PDOException $e) { |
|
913 | + return "error : ".$e->getMessage(); |
|
914 | + } |
|
915 | + /* |
|
916 | 916 | echo 'putinarchive : '.$putinarchive."\n"; |
917 | 917 | echo 'noarchive : '.$noarchive."\n"; |
918 | 918 | */ |
919 | 919 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
920 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
921 | - $TrackerArchive = new TrackerArchive($this->db); |
|
922 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
923 | - if ($globalDebug) echo $result.')'; |
|
920 | + if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
921 | + $TrackerArchive = new TrackerArchive($this->db); |
|
922 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
923 | + if ($globalDebug) echo $result.')'; |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | return "success"; |