@@ -59,8 +59,11 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 61 | 61 | $sth->closeCursor(); |
| 62 | - if ($row['nb'] > 0) return false; |
|
| 63 | - else return true; |
|
| 62 | + if ($row['nb'] > 0) { |
|
| 63 | + return false; |
|
| 64 | + } else { |
|
| 65 | + return true; |
|
| 66 | + } |
|
| 64 | 67 | } |
| 65 | 68 | |
| 66 | 69 | public static function insert_last_update() { |
@@ -82,9 +85,14 @@ discard block |
||
| 82 | 85 | //$pieces = explode(' ',$data); |
| 83 | 86 | $pieces = preg_split('/\s/',$data); |
| 84 | 87 | $pos = 0; |
| 85 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 86 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
| 87 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 88 | + if ($pieces[0] == 'METAR') { |
|
| 89 | + $pos++; |
|
| 90 | + } elseif ($pieces[0] == 'SPECI') { |
|
| 91 | + $pos++; |
|
| 92 | + } |
|
| 93 | + if (strlen($pieces[$pos]) != 4) { |
|
| 94 | + $pos++; |
|
| 95 | + } |
|
| 88 | 96 | $result = array(); |
| 89 | 97 | $result['location'] = $pieces[$pos]; |
| 90 | 98 | $pos++; |
@@ -93,16 +101,26 @@ discard block |
||
| 93 | 101 | $c = count($pieces); |
| 94 | 102 | for($pos++; $pos < $c; $pos++) { |
| 95 | 103 | $piece = $pieces[$pos]; |
| 96 | - if ($piece == 'RMK') break; |
|
| 97 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
| 98 | - if ($piece == 'COR') $result['correction'] = true; |
|
| 104 | + if ($piece == 'RMK') { |
|
| 105 | + break; |
|
| 106 | + } |
|
| 107 | + if ($piece == 'AUTO') { |
|
| 108 | + $result['auto'] = true; |
|
| 109 | + } |
|
| 110 | + if ($piece == 'COR') { |
|
| 111 | + $result['correction'] = true; |
|
| 112 | + } |
|
| 99 | 113 | // Wind Speed |
| 100 | 114 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 101 | 115 | $result['wind']['direction'] = (float)$matches[1]; |
| 102 | 116 | $result['wind']['unit'] = $matches[4]; |
| 103 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 104 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 105 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 117 | + if ($result['wind']['unit'] == 'KT') { |
|
| 118 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 119 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
| 120 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 121 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
| 122 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 123 | + } |
|
| 106 | 124 | $result['wind']['gust'] = (float)$matches[3]; |
| 107 | 125 | $result['wind']['unit'] = $matches[4]; |
| 108 | 126 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -185,14 +203,23 @@ discard block |
||
| 185 | 203 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
| 186 | 204 | $type = $matches[1]; |
| 187 | 205 | $cloud = array(); |
| 188 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
| 189 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 190 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
| 191 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
| 192 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
| 193 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
| 194 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 195 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
| 206 | + if ($type == 'SKC') { |
|
| 207 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
| 208 | + } elseif ($type == 'CLR') { |
|
| 209 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 210 | + } elseif ($type == 'NSC') { |
|
| 211 | + $cloud['type'] = 'No significant cloud'; |
|
| 212 | + } elseif ($type == 'FEW') { |
|
| 213 | + $cloud['type'] = 'Few'; |
|
| 214 | + } elseif ($type == 'SCT') { |
|
| 215 | + $cloud['type'] = 'Scattered'; |
|
| 216 | + } elseif ($type == 'BKN') { |
|
| 217 | + $cloud['type'] = 'Broken'; |
|
| 218 | + } elseif ($type == 'OVC') { |
|
| 219 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 220 | + } elseif ($type == 'VV') { |
|
| 221 | + $cloud['type'] = 'Vertical visibility'; |
|
| 222 | + } |
|
| 196 | 223 | $cloud['type_code'] = $type; |
| 197 | 224 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
| 198 | 225 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -218,8 +245,11 @@ discard block |
||
| 218 | 245 | $result['RVR']['friction'] = $matches[5]; |
| 219 | 246 | } |
| 220 | 247 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 221 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 222 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 248 | + if (isset($matches[5])) { |
|
| 249 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 250 | + } else { |
|
| 251 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 252 | + } |
|
| 223 | 253 | if (isset($matches[3])) { |
| 224 | 254 | $range = Array( |
| 225 | 255 | 'from' => (float)$matches[2], |
@@ -252,8 +282,11 @@ discard block |
||
| 252 | 282 | if (isset($matches[3])) { |
| 253 | 283 | $text[] = $this->texts[$matches[3]]; |
| 254 | 284 | } |
| 255 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
| 256 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 285 | + if (!isset($result['weather'])) { |
|
| 286 | + $result['weather'] = implode(' ', $text); |
|
| 287 | + } else { |
|
| 288 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 289 | + } |
|
| 257 | 290 | } |
| 258 | 291 | } |
| 259 | 292 | return $result; |
@@ -264,8 +297,11 @@ discard block |
||
| 264 | 297 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
| 265 | 298 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
| 266 | 299 | } else { |
| 267 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 268 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 300 | + if ($globalDBdriver == 'mysql') { |
|
| 301 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 302 | + } else { |
|
| 303 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 304 | + } |
|
| 269 | 305 | } |
| 270 | 306 | $query_values = array(':icao' => $icao); |
| 271 | 307 | try { |
@@ -321,7 +357,9 @@ discard block |
||
| 321 | 357 | |
| 322 | 358 | public function addMETARCycle() { |
| 323 | 359 | global $globalDebug, $globalIVAO, $globalTransaction; |
| 324 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
| 360 | + if (isset($globalDebug) && $globalDebug) { |
|
| 361 | + echo "Downloading METAR cycle..."; |
|
| 362 | + } |
|
| 325 | 363 | date_default_timezone_set("UTC"); |
| 326 | 364 | $Common = new Common(); |
| 327 | 365 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -332,31 +370,47 @@ discard block |
||
| 332 | 370 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
| 333 | 371 | } |
| 334 | 372 | if ($handle) { |
| 335 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
| 373 | + if (isset($globalDebug) && $globalDebug) { |
|
| 374 | + echo "Done - Updating DB..."; |
|
| 375 | + } |
|
| 336 | 376 | $date = ''; |
| 337 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 377 | + if ($globalTransaction) { |
|
| 378 | + $this->db->beginTransaction(); |
|
| 379 | + } |
|
| 338 | 380 | while(($line = fgets($handle,4096)) !== false) { |
| 339 | 381 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
| 340 | 382 | $date = $line; |
| 341 | 383 | } elseif ($line != '') { |
| 342 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 384 | + if ($date == '') { |
|
| 385 | + $date = date('Y/m/d H:m'); |
|
| 386 | + } |
|
| 343 | 387 | $pos = 0; |
| 344 | 388 | $pieces = preg_split('/\s/',$line); |
| 345 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 346 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 389 | + if ($pieces[0] == 'METAR') { |
|
| 390 | + $pos++; |
|
| 391 | + } |
|
| 392 | + if (strlen($pieces[$pos]) != 4) { |
|
| 393 | + $pos++; |
|
| 394 | + } |
|
| 347 | 395 | $location = $pieces[$pos]; |
| 348 | 396 | echo $this->addMETAR($location,$line,$date); |
| 349 | 397 | } |
| 350 | 398 | } |
| 351 | 399 | fclose($handle); |
| 352 | - if ($globalTransaction) $this->db->commit(); |
|
| 400 | + if ($globalTransaction) { |
|
| 401 | + $this->db->commit(); |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + if (isset($globalDebug) && $globalDebug) { |
|
| 405 | + echo "Done\n"; |
|
| 353 | 406 | } |
| 354 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
| 355 | 407 | } |
| 356 | 408 | |
| 357 | 409 | public function downloadMETAR($icao) { |
| 358 | 410 | global $globalMETARurl; |
| 359 | - if ($globalMETARurl == '') return array(); |
|
| 411 | + if ($globalMETARurl == '') { |
|
| 412 | + return array(); |
|
| 413 | + } |
|
| 360 | 414 | date_default_timezone_set("UTC"); |
| 361 | 415 | $Common = new Common(); |
| 362 | 416 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -367,16 +421,24 @@ discard block |
||
| 367 | 421 | $date = $line; |
| 368 | 422 | } |
| 369 | 423 | if ($line != '') { |
| 370 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 424 | + if ($date == '') { |
|
| 425 | + $date = date('Y/m/d H:m'); |
|
| 426 | + } |
|
| 371 | 427 | $pos = 0; |
| 372 | 428 | $pieces = preg_split('/\s/',$line); |
| 373 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 374 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 429 | + if ($pieces[0] == 'METAR') { |
|
| 430 | + $pos++; |
|
| 431 | + } |
|
| 432 | + if (strlen($pieces[$pos]) != 4) { |
|
| 433 | + $pos++; |
|
| 434 | + } |
|
| 375 | 435 | $location = $pieces[$pos]; |
| 376 | 436 | if (strlen($location == 4)) { |
| 377 | 437 | $this->addMETAR($location,$line,$date); |
| 378 | 438 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 379 | - } else return array(); |
|
| 439 | + } else { |
|
| 440 | + return array(); |
|
| 441 | + } |
|
| 380 | 442 | } |
| 381 | 443 | } |
| 382 | 444 | return array(); |
@@ -48,7 +48,9 @@ discard block |
||
| 48 | 48 | $all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']); |
| 49 | 49 | if (isset($globalTimezone)) { |
| 50 | 50 | date_default_timezone_set($globalTimezone); |
| 51 | - } else date_default_timezone_set('UTC'); |
|
| 51 | + } else { |
|
| 52 | + date_default_timezone_set('UTC'); |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | if (is_array($all_data) && count($all_data) > 1) { |
| 54 | 56 | print '<br/>'; |
@@ -327,9 +329,13 @@ discard block |
||
| 327 | 329 | print '<div>'; |
| 328 | 330 | if (isset($spotter_item['pilot_id']) && $spotter_item['pilot_id'] != "") |
| 329 | 331 | { |
| 330 | - if ($spotter_item['format_source'] == 'whazzup') print '<a href="https://www.ivao.aero/Member.aspx?ID='.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>'; |
|
| 331 | - elseif ($spotter_item['format_source'] == 'vatsimtxt') print '<a href="http://www.vataware.com/pilot/'.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>'; |
|
| 332 | - else print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
| 332 | + if ($spotter_item['format_source'] == 'whazzup') { |
|
| 333 | + print '<a href="https://www.ivao.aero/Member.aspx?ID='.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>'; |
|
| 334 | + } elseif ($spotter_item['format_source'] == 'vatsimtxt') { |
|
| 335 | + print '<a href="http://www.vataware.com/pilot/'.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>'; |
|
| 336 | + } else { |
|
| 337 | + print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
| 338 | + } |
|
| 333 | 339 | } else { |
| 334 | 340 | if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != "") |
| 335 | 341 | { |
@@ -118,8 +118,12 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']); |
| 120 | 120 | $ident = $spotter_array[0]['ident']; |
| 121 | - if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
|
| 122 | - if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
|
| 121 | + if (isset($spotter_array[0]['latitude'])) { |
|
| 122 | + $latitude = $spotter_array[0]['latitude']; |
|
| 123 | + } |
|
| 124 | + if (isset($spotter_array[0]['longitude'])) { |
|
| 125 | + $longitude = $spotter_array[0]['longitude']; |
|
| 126 | + } |
|
| 123 | 127 | require_once('header.php'); |
| 124 | 128 | if (isset($globalArchive) && $globalArchive && $type == 'aircraft') { |
| 125 | 129 | // Requirement for altitude graph |
@@ -127,7 +131,9 @@ discard block |
||
| 127 | 131 | $all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']); |
| 128 | 132 | if (isset($globalTimezone)) { |
| 129 | 133 | date_default_timezone_set($globalTimezone); |
| 130 | - } else date_default_timezone_set('UTC'); |
|
| 134 | + } else { |
|
| 135 | + date_default_timezone_set('UTC'); |
|
| 136 | + } |
|
| 131 | 137 | if (is_array($all_data) && count($all_data) > 1) { |
| 132 | 138 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
| 133 | 139 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -204,14 +210,22 @@ discard block |
||
| 204 | 210 | if (isset($spotter_array[0]['airline_icao'])) { |
| 205 | 211 | print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>'; |
| 206 | 212 | } |
| 207 | - if ($type == 'aircraft') print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>'; |
|
| 213 | + if ($type == 'aircraft') { |
|
| 214 | + print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>'; |
|
| 215 | + } |
|
| 208 | 216 | print '</div>'; |
| 209 | 217 | |
| 210 | - if ($type == 'aircraft') include('ident-sub-menu.php'); |
|
| 218 | + if ($type == 'aircraft') { |
|
| 219 | + include('ident-sub-menu.php'); |
|
| 220 | + } |
|
| 211 | 221 | print '<div class="table column">'; |
| 212 | - if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
| 213 | - elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
| 214 | - elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
| 222 | + if ($type == 'aircraft') { |
|
| 223 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
| 224 | + } elseif ($type == 'marine') { |
|
| 225 | + print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
| 226 | + } elseif ($type == 'tracker') { |
|
| 227 | + print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
| 228 | + } |
|
| 215 | 229 | |
| 216 | 230 | include('table-output.php'); |
| 217 | 231 | print '<div class="pagination">'; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | $limit_start = 0; |
| 16 | 16 | $limit_end = 25; |
| 17 | 17 | $absolute_difference = 25; |
| 18 | - } else { |
|
| 18 | + } else { |
|
| 19 | 19 | $limit_explode = explode(",", $_GET['limit']); |
| 20 | 20 | $limit_start = $limit_explode[0]; |
| 21 | 21 | $limit_end = $limit_explode[1]; |
@@ -47,7 +47,9 @@ discard block |
||
| 47 | 47 | $METAR = new METAR(); |
| 48 | 48 | $metar_info = $METAR->getMETAR($airport_icao); |
| 49 | 49 | //print_r($metar_info); |
| 50 | - if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
| 50 | + if (isset($metar_info[0]['metar'])) { |
|
| 51 | + $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
| 52 | + } |
|
| 51 | 53 | //print_r($metar_parse); |
| 52 | 54 | } |
| 53 | 55 | |
@@ -61,7 +63,9 @@ discard block |
||
| 61 | 63 | print '<option></option>'; |
| 62 | 64 | $Stats = new Stats(); |
| 63 | 65 | $airport_names = $Stats->getAllAirportNames(); |
| 64 | - if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
|
| 66 | + if (empty($airport_names)) { |
|
| 67 | + $airport_names = $Spotter->getAllAirportNames(); |
|
| 68 | + } |
|
| 65 | 69 | ksort($airport_names); |
| 66 | 70 | foreach($airport_names as $airport_name) |
| 67 | 71 | { |
@@ -102,7 +106,9 @@ discard block |
||
| 102 | 106 | // Use spotter also |
| 103 | 107 | if (isset($globalTimezone)) { |
| 104 | 108 | date_default_timezone_set($globalTimezone); |
| 105 | - } else date_default_timezone_set('UTC'); |
|
| 109 | + } else { |
|
| 110 | + date_default_timezone_set('UTC'); |
|
| 111 | + } |
|
| 106 | 112 | if (count($all_data) > 0) { |
| 107 | 113 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
| 108 | 114 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -4,10 +4,15 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | setcookie("MapFormat",'2d'); |
| 6 | 6 | |
| 7 | -if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = ''; |
|
| 7 | +if (!isset($globalOpenWeatherMapKey)) { |
|
| 8 | + $globalOpenWeatherMapKey = ''; |
|
| 9 | +} |
|
| 8 | 10 | // Compressed GeoJson is used if true |
| 9 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 10 | -else $compress = $globalJsonCompress; |
|
| 11 | +if (!isset($globalJsonCompress)) { |
|
| 12 | + $compress = true; |
|
| 13 | +} else { |
|
| 14 | + $compress = $globalJsonCompress; |
|
| 15 | +} |
|
| 11 | 16 | if (isset($_GET['archive'])) { |
| 12 | 17 | $archive = true; |
| 13 | 18 | //$archiveupdatetime = 50; |
@@ -18,8 +23,11 @@ discard block |
||
| 18 | 23 | //$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10)); |
| 19 | 24 | //$lastupd = 20; |
| 20 | 25 | $lastupd = $_GET['archivespeed']*$archiveupdatetime; |
| 21 | - if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate']; |
|
| 22 | - else $enddate = time(); |
|
| 26 | + if (isset($_GET['enddate']) && $_GET['enddate'] != '') { |
|
| 27 | + $enddate = $_GET['enddate']; |
|
| 28 | + } else { |
|
| 29 | + $enddate = time(); |
|
| 30 | + } |
|
| 23 | 31 | setcookie("archive_begin",$begindate); |
| 24 | 32 | setcookie("archive_end",$enddate); |
| 25 | 33 | setcookie("archive_update",$lastupd); |
@@ -106,7 +114,17 @@ discard block |
||
| 106 | 114 | } |
| 107 | 115 | |
| 108 | 116 | //create the map |
| 109 | - map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom); |
|
| 117 | + map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) { |
|
| 118 | + print $latitude; |
|
| 119 | +} else { |
|
| 120 | + print $globalCenterLatitude; |
|
| 121 | +} |
|
| 122 | +?>,<?php if (isset($longitude)) { |
|
| 123 | + print $longitude; |
|
| 124 | +} else { |
|
| 125 | + print $globalCenterLongitude; |
|
| 126 | +} |
|
| 127 | +?>], zoom); |
|
| 110 | 128 | <?php |
| 111 | 129 | } else { |
| 112 | 130 | ?> |
@@ -119,9 +137,19 @@ discard block |
||
| 119 | 137 | || navigator.userAgent.match(/BlackBerry/i) |
| 120 | 138 | || navigator.userAgent.match(/Windows Phone/i)) |
| 121 | 139 | { |
| 122 | - var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>; |
|
| 140 | + var zoom = <?php if (isset($globalLiveZoom)) { |
|
| 141 | + print $globalLiveZoom-1; |
|
| 142 | +} else { |
|
| 143 | + print '8'; |
|
| 144 | +} |
|
| 145 | +?>; |
|
| 123 | 146 | } else { |
| 124 | - var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>; |
|
| 147 | + var zoom = <?php if (isset($globalLiveZoom)) { |
|
| 148 | + print $globalLiveZoom; |
|
| 149 | +} else { |
|
| 150 | + print '9'; |
|
| 151 | +} |
|
| 152 | +?>; |
|
| 125 | 153 | } |
| 126 | 154 | |
| 127 | 155 | //create the map |
@@ -146,16 +174,27 @@ discard block |
||
| 146 | 174 | bounds = L.latLngBounds(southWest,northEast); |
| 147 | 175 | //a few title layers |
| 148 | 176 | <?php |
| 149 | - if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType']; |
|
| 150 | - else $MapType = $globalMapProvider; |
|
| 177 | + if (isset($_COOKIE['MapType'])) { |
|
| 178 | + $MapType = $_COOKIE['MapType']; |
|
| 179 | + } else { |
|
| 180 | + $MapType = $globalMapProvider; |
|
| 181 | + } |
|
| 151 | 182 | |
| 152 | 183 | if ($MapType == 'Mapbox') { |
| 153 | - if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId; |
|
| 154 | - else $MapBoxId = $_COOKIE['MapTypeId']; |
|
| 155 | -?> |
|
| 184 | + if ($_COOKIE['MapTypeId'] == 'default') { |
|
| 185 | + $MapBoxId = $globalMapboxId; |
|
| 186 | + } else { |
|
| 187 | + $MapBoxId = $_COOKIE['MapTypeId']; |
|
| 188 | + } |
|
| 189 | + ?> |
|
| 156 | 190 | L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', { |
| 157 | 191 | maxZoom: 18, |
| 158 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
| 192 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
| 193 | + print 'false'; |
|
| 194 | +} else { |
|
| 195 | + print 'true'; |
|
| 196 | +} |
|
| 197 | +?>, |
|
| 159 | 198 | attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + |
| 160 | 199 | '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + |
| 161 | 200 | 'Imagery © <a href="http://mapbox.com">Mapbox</a>', |
@@ -167,7 +206,12 @@ discard block |
||
| 167 | 206 | ?> |
| 168 | 207 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
| 169 | 208 | maxZoom: 18, |
| 170 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
| 209 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
| 210 | + print 'false'; |
|
| 211 | +} else { |
|
| 212 | + print 'true'; |
|
| 213 | +} |
|
| 214 | +?>, |
|
| 171 | 215 | attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + |
| 172 | 216 | '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>' |
| 173 | 217 | }).addTo(map); |
@@ -213,20 +257,26 @@ discard block |
||
| 213 | 257 | map.addLayer(yandexLayer); |
| 214 | 258 | <?php |
| 215 | 259 | } elseif ($MapType == 'Bing-Aerial') { |
| 216 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 217 | -?> |
|
| 260 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
| 261 | + setcookie('MapType','OpenStreetMap'); |
|
| 262 | + } |
|
| 263 | + ?> |
|
| 218 | 264 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'}); |
| 219 | 265 | map.addLayer(bingLayer); |
| 220 | 266 | <?php |
| 221 | 267 | } elseif ($MapType == 'Bing-Hybrid') { |
| 222 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 223 | -?> |
|
| 268 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
| 269 | + setcookie('MapType','OpenStreetMap'); |
|
| 270 | + } |
|
| 271 | + ?> |
|
| 224 | 272 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'}); |
| 225 | 273 | map.addLayer(bingLayer); |
| 226 | 274 | <?php |
| 227 | 275 | } elseif ($MapType == 'Bing-Road') { |
| 228 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
| 229 | -?> |
|
| 276 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
| 277 | + setcookie('MapType','OpenStreetMap'); |
|
| 278 | + } |
|
| 279 | + ?> |
|
| 230 | 280 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'}); |
| 231 | 281 | map.addLayer(bingLayer); |
| 232 | 282 | <?php |
@@ -249,9 +299,24 @@ discard block |
||
| 249 | 299 | $customid = $MapType; |
| 250 | 300 | ?> |
| 251 | 301 | L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', { |
| 252 | - maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>, |
|
| 253 | - minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>, |
|
| 254 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
| 302 | + maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) { |
|
| 303 | + print $globalMapCustomLayer[$customid]['maxZoom']; |
|
| 304 | +} else { |
|
| 305 | + print '18'; |
|
| 306 | +} |
|
| 307 | +?>, |
|
| 308 | + minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) { |
|
| 309 | + print $globalMapCustomLayer[$customid]['minZoom']; |
|
| 310 | +} else { |
|
| 311 | + print '0'; |
|
| 312 | +} |
|
| 313 | +?>, |
|
| 314 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
| 315 | + print 'false'; |
|
| 316 | +} else { |
|
| 317 | + print 'true'; |
|
| 318 | +} |
|
| 319 | +?>, |
|
| 255 | 320 | attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>' |
| 256 | 321 | }).addTo(map); |
| 257 | 322 | |
@@ -285,7 +350,12 @@ discard block |
||
| 285 | 350 | } |
| 286 | 351 | } elseif ($globalBounding == 'circle') { |
| 287 | 352 | ?> |
| 288 | - var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{ |
|
| 353 | + var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) { |
|
| 354 | + print $globalBoundingCircleSize; |
|
| 355 | +} else { |
|
| 356 | + print '70000'; |
|
| 357 | +} |
|
| 358 | +?>,{ |
|
| 289 | 359 | color: '#92C7D1', |
| 290 | 360 | fillColor: '#92C7D1', |
| 291 | 361 | fillOpacity: 0.3, |
@@ -382,7 +452,12 @@ discard block |
||
| 382 | 452 | //} |
| 383 | 453 | }); |
| 384 | 454 | update_locationsLayer(); |
| 385 | -setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
| 455 | +setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) { |
|
| 456 | + print $globalMapRefresh*1000*2; |
|
| 457 | +} else { |
|
| 458 | + print '60000'; |
|
| 459 | +} |
|
| 460 | +?>); |
|
| 386 | 461 | |
| 387 | 462 | <?php |
| 388 | 463 | // Add support for custom json via $globalMapJson |
@@ -184,17 +184,23 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | /* Check that end was found and body has at least one byte. */ |
| 186 | 186 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
| 187 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
| 187 | + if ($globalDebug) { |
|
| 188 | + echo '!!! APRS invalid : '.$input."\n"; |
|
| 189 | + } |
|
| 188 | 190 | return false; |
| 189 | 191 | } |
| 190 | 192 | |
| 191 | - if ($debug) echo 'input : '.$input."\n"; |
|
| 193 | + if ($debug) { |
|
| 194 | + echo 'input : '.$input."\n"; |
|
| 195 | + } |
|
| 192 | 196 | /* Save header and body. */ |
| 193 | 197 | $body = substr($input,$splitpos+1,$input_len); |
| 194 | 198 | $body_len = strlen($body); |
| 195 | 199 | $header = substr($input,0,$splitpos); |
| 196 | 200 | //$header_len = strlen($header); |
| 197 | - if ($debug) echo 'header : '.$header."\n"; |
|
| 201 | + if ($debug) { |
|
| 202 | + echo 'header : '.$header."\n"; |
|
| 203 | + } |
|
| 198 | 204 | |
| 199 | 205 | /* Parse source, target and path. */ |
| 200 | 206 | //FLRDF0A52>APRS,qAS,LSTB |
@@ -208,11 +214,15 @@ discard block |
||
| 208 | 214 | $result['format_source'] = 'famaprs'; |
| 209 | 215 | $result['source_type'] = 'ais'; |
| 210 | 216 | } else { |
| 211 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
| 217 | + if ($debug) { |
|
| 218 | + echo 'ident : '.$ident."\n"; |
|
| 219 | + } |
|
| 212 | 220 | $result['ident'] = $ident; |
| 213 | 221 | } |
| 214 | 222 | } else { |
| 215 | - if ($debug) 'No ident'."\n"; |
|
| 223 | + if ($debug) { |
|
| 224 | + 'No ident'."\n"; |
|
| 225 | + } |
|
| 216 | 226 | return false; |
| 217 | 227 | } |
| 218 | 228 | $elements = explode(',',$all_elements); |
@@ -223,7 +233,9 @@ discard block |
||
| 223 | 233 | //echo "ok"; |
| 224 | 234 | //if ($element == 'TCPIP*') return false; |
| 225 | 235 | } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
| 226 | - if ($debug) echo 'element : '.$element."\n"; |
|
| 236 | + if ($debug) { |
|
| 237 | + echo 'element : '.$element."\n"; |
|
| 238 | + } |
|
| 227 | 239 | return false; |
| 228 | 240 | } |
| 229 | 241 | /* |
@@ -236,13 +248,17 @@ discard block |
||
| 236 | 248 | } |
| 237 | 249 | |
| 238 | 250 | $type = substr($body,0,1); |
| 239 | - if ($debug) echo 'type : '.$type."\n"; |
|
| 251 | + if ($debug) { |
|
| 252 | + echo 'type : '.$type."\n"; |
|
| 253 | + } |
|
| 240 | 254 | if ($type == ';') { |
| 241 | 255 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
| 242 | 256 | $result['address'] = trim(substr($body,1,9)); |
| 243 | 257 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
| 244 | 258 | $result['mmsi'] = trim(substr($body,1,9)); |
| 245 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
| 259 | + } else { |
|
| 260 | + $result['ident'] = trim(substr($body,1,9)); |
|
| 261 | + } |
|
| 246 | 262 | } elseif ($type == ',') { |
| 247 | 263 | // Invalid data or test data |
| 248 | 264 | return false; |
@@ -311,7 +327,9 @@ discard block |
||
| 311 | 327 | //$symbol_table = $matches[4]; |
| 312 | 328 | $lat = intval($lat_deg); |
| 313 | 329 | $lon = intval($lon_deg); |
| 314 | - if ($lat > 89 || $lon > 179) return false; |
|
| 330 | + if ($lat > 89 || $lon > 179) { |
|
| 331 | + return false; |
|
| 332 | + } |
|
| 315 | 333 | |
| 316 | 334 | /* |
| 317 | 335 | $tmp_5b = str_replace('.','',$lat_min); |
@@ -321,8 +339,12 @@ discard block |
||
| 321 | 339 | */ |
| 322 | 340 | $latitude = $lat + floatval($lat_min)/60; |
| 323 | 341 | $longitude = $lon + floatval($lon_min)/60; |
| 324 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
| 325 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
| 342 | + if ($sind == 'S') { |
|
| 343 | + $latitude = 0-$latitude; |
|
| 344 | + } |
|
| 345 | + if ($wind == 'W') { |
|
| 346 | + $longitude = 0-$longitude; |
|
| 347 | + } |
|
| 326 | 348 | $result['latitude'] = $latitude; |
| 327 | 349 | $result['longitude'] = $longitude; |
| 328 | 350 | $body_parse = substr($body_parse,18); |
@@ -350,8 +372,11 @@ discard block |
||
| 350 | 372 | //echo 'find'."\n"; |
| 351 | 373 | $body_split = str_split($body_parse); |
| 352 | 374 | $symbol_code = $body_split[0]; |
| 353 | - if (!isset($symbolll) || $symbolll == '/') $symbol_code = '/'.$symbol_code; |
|
| 354 | - else $symbol_code = '\\'.$symbol_code; |
|
| 375 | + if (!isset($symbolll) || $symbolll == '/') { |
|
| 376 | + $symbol_code = '/'.$symbol_code; |
|
| 377 | + } else { |
|
| 378 | + $symbol_code = '\\'.$symbol_code; |
|
| 379 | + } |
|
| 355 | 380 | //' |
| 356 | 381 | //} |
| 357 | 382 | //echo $body_parse; |
@@ -360,7 +385,9 @@ discard block |
||
| 360 | 385 | $body_parse = substr($body_parse,1); |
| 361 | 386 | $body_parse_len = strlen($body_parse); |
| 362 | 387 | $result['symbol_code'] = $symbol_code; |
| 363 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 388 | + if (isset($this->symbols[$symbol_code])) { |
|
| 389 | + $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 390 | + } |
|
| 364 | 391 | if ($symbol_code != '_') { |
| 365 | 392 | } |
| 366 | 393 | //$body_parse = substr($body_parse,1); |
@@ -371,7 +398,9 @@ discard block |
||
| 371 | 398 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
| 372 | 399 | $course = substr($body_parse,0,3); |
| 373 | 400 | $tmp_s = intval($course); |
| 374 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
| 401 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
| 402 | + $result['heading'] = intval($course); |
|
| 403 | + } |
|
| 375 | 404 | $speed = substr($body_parse,4,3); |
| 376 | 405 | if ($speed != '...') { |
| 377 | 406 | //$result['speed'] = round($speed*1.852); |
@@ -412,10 +441,16 @@ discard block |
||
| 412 | 441 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
| 413 | 442 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
| 414 | 443 | |
| 415 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
| 416 | - else $result['latitude'] += $lat_off; |
|
| 417 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
| 418 | - else $result['longitude'] += $lon_off; |
|
| 444 | + if ($result['latitude'] < 0) { |
|
| 445 | + $result['latitude'] -= $lat_off; |
|
| 446 | + } else { |
|
| 447 | + $result['latitude'] += $lat_off; |
|
| 448 | + } |
|
| 449 | + if ($result['longitude'] < 0) { |
|
| 450 | + $result['longitude'] -= $lon_off; |
|
| 451 | + } else { |
|
| 452 | + $result['longitude'] += $lon_off; |
|
| 453 | + } |
|
| 419 | 454 | } |
| 420 | 455 | |
| 421 | 456 | $body_parse = substr($body_parse,6); |
@@ -457,27 +492,48 @@ discard block |
||
| 457 | 492 | $address = substr($id,2); |
| 458 | 493 | //print_r($matches); |
| 459 | 494 | $addressType = (intval(substr($id,0,2),16))&3; |
| 460 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
| 461 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
| 462 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
| 463 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
| 495 | + if ($addressType == 0) { |
|
| 496 | + $result['addresstype'] = "RANDOM"; |
|
| 497 | + } elseif ($addressType == 1) { |
|
| 498 | + $result['addresstype'] = "ICAO"; |
|
| 499 | + } elseif ($addressType == 2) { |
|
| 500 | + $result['addresstype'] = "FLARM"; |
|
| 501 | + } elseif ($addressType == 3) { |
|
| 502 | + $result['addresstype'] = "OGN"; |
|
| 503 | + } |
|
| 464 | 504 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
| 465 | 505 | $result['aircrafttype_code'] = $aircraftType; |
| 466 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
| 467 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
| 468 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
| 469 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 470 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
| 471 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
| 472 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 473 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 474 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 475 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 476 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
| 477 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
| 478 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
| 479 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
| 480 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 506 | + if ($aircraftType == 0) { |
|
| 507 | + $result['aircrafttype'] = "UNKNOWN"; |
|
| 508 | + } elseif ($aircraftType == 1) { |
|
| 509 | + $result['aircrafttype'] = "GLIDER"; |
|
| 510 | + } elseif ($aircraftType == 2) { |
|
| 511 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
| 512 | + } elseif ($aircraftType == 3) { |
|
| 513 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 514 | + } elseif ($aircraftType == 4) { |
|
| 515 | + $result['aircrafttype'] = "PARACHUTE"; |
|
| 516 | + } elseif ($aircraftType == 5) { |
|
| 517 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
| 518 | + } elseif ($aircraftType == 6) { |
|
| 519 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 520 | + } elseif ($aircraftType == 7) { |
|
| 521 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 522 | + } elseif ($aircraftType == 8) { |
|
| 523 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 524 | + } elseif ($aircraftType == 9) { |
|
| 525 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 526 | + } elseif ($aircraftType == 10) { |
|
| 527 | + $result['aircrafttype'] = "UFO"; |
|
| 528 | + } elseif ($aircraftType == 11) { |
|
| 529 | + $result['aircrafttype'] = "BALLOON"; |
|
| 530 | + } elseif ($aircraftType == 12) { |
|
| 531 | + $result['aircrafttype'] = "AIRSHIP"; |
|
| 532 | + } elseif ($aircraftType == 13) { |
|
| 533 | + $result['aircrafttype'] = "UAV"; |
|
| 534 | + } elseif ($aircraftType == 15) { |
|
| 535 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 536 | + } |
|
| 481 | 537 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
| 482 | 538 | $result['stealth'] = $stealth; |
| 483 | 539 | $result['address'] = $address; |
@@ -517,79 +573,183 @@ discard block |
||
| 517 | 573 | //g012t088r000p000P000h38b10110 |
| 518 | 574 | //g011t086r000p000P000h29b10198 |
| 519 | 575 | 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)) { |
| 520 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 521 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 522 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 523 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 524 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 525 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 526 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 576 | + if ($matches[1] != '...') { |
|
| 577 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 578 | + } |
|
| 579 | + if ($matches[2] != '...') { |
|
| 580 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 581 | + } |
|
| 582 | + if ($matches[3] != '...') { |
|
| 583 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 584 | + } |
|
| 585 | + if ($matches[4] != '...') { |
|
| 586 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 587 | + } |
|
| 588 | + if ($matches[5] != '...') { |
|
| 589 | + $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 590 | + } |
|
| 591 | + if ($matches[6] != '...') { |
|
| 592 | + $result['humidity'] = intval($matches[6]); |
|
| 593 | + } |
|
| 594 | + if ($matches[7] != '...') { |
|
| 595 | + $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 596 | + } |
|
| 527 | 597 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 528 | 598 | } 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)) { |
| 529 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 530 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 531 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 532 | - if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
| 533 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 534 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 535 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 599 | + if ($matches[1] != '...') { |
|
| 600 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 601 | + } |
|
| 602 | + if ($matches[2] != '...') { |
|
| 603 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 604 | + } |
|
| 605 | + if ($matches[3] != '...') { |
|
| 606 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 607 | + } |
|
| 608 | + if ($matches[5] != '...') { |
|
| 609 | + $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
| 610 | + } |
|
| 611 | + if ($matches[4] != '...') { |
|
| 612 | + $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 613 | + } |
|
| 614 | + if ($matches[6] != '...') { |
|
| 615 | + $result['humidity'] = intval($matches[6]); |
|
| 616 | + } |
|
| 617 | + if ($matches[7] != '...') { |
|
| 618 | + $result['pressure'] = round((intval($matches[7])/10),1); |
|
| 619 | + } |
|
| 536 | 620 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 537 | 621 | } 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)) { |
| 538 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 539 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 540 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 541 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 542 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 543 | - if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
|
| 544 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 622 | + if ($matches[1] != '...') { |
|
| 623 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 624 | + } |
|
| 625 | + if ($matches[2] != '...') { |
|
| 626 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 627 | + } |
|
| 628 | + if ($matches[3] != '...') { |
|
| 629 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 630 | + } |
|
| 631 | + if ($matches[4] != '...') { |
|
| 632 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 633 | + } |
|
| 634 | + if ($matches[5] != '...') { |
|
| 635 | + $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
| 636 | + } |
|
| 637 | + if ($matches[7] != '...') { |
|
| 638 | + $result['humidity'] = intval($matches[7]); |
|
| 639 | + } |
|
| 640 | + if ($matches[6] != '...') { |
|
| 641 | + $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 642 | + } |
|
| 545 | 643 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 546 | 644 | } 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)) { |
| 547 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 548 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 549 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 550 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 551 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 552 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 645 | + if ($matches[1] != '...') { |
|
| 646 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 647 | + } |
|
| 648 | + if ($matches[2] != '...') { |
|
| 649 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 650 | + } |
|
| 651 | + if ($matches[3] != '...') { |
|
| 652 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 653 | + } |
|
| 654 | + if ($matches[4] != '...') { |
|
| 655 | + $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
| 656 | + } |
|
| 657 | + if ($matches[6] != '...') { |
|
| 658 | + $result['humidity'] = intval($matches[6]); |
|
| 659 | + } |
|
| 660 | + if ($matches[5] != '...') { |
|
| 661 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 662 | + } |
|
| 553 | 663 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 554 | 664 | } 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)) { |
| 555 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 556 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 557 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 558 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 559 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
|
| 560 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 665 | + if ($matches[1] != '...') { |
|
| 666 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 667 | + } |
|
| 668 | + if ($matches[2] != '...') { |
|
| 669 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 670 | + } |
|
| 671 | + if ($matches[3] != '...') { |
|
| 672 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 673 | + } |
|
| 674 | + if ($matches[4] != '...') { |
|
| 675 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 676 | + } |
|
| 677 | + if ($matches[6] != '...') { |
|
| 678 | + $result['humidity'] = intval($matches[6]); |
|
| 679 | + } |
|
| 680 | + if ($matches[5] != '...') { |
|
| 681 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 682 | + } |
|
| 561 | 683 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 562 | 684 | } 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)) { |
| 563 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 564 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 565 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 566 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 567 | - if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
|
| 568 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 685 | + if ($matches[1] != '...') { |
|
| 686 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 687 | + } |
|
| 688 | + if ($matches[2] != '...') { |
|
| 689 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 690 | + } |
|
| 691 | + if ($matches[3] != '...') { |
|
| 692 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 693 | + } |
|
| 694 | + if ($matches[4] != '...') { |
|
| 695 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
| 696 | + } |
|
| 697 | + if ($matches[5] != '...') { |
|
| 698 | + $result['humidity'] = intval($matches[5]); |
|
| 699 | + } |
|
| 700 | + if ($matches[6] != '...') { |
|
| 701 | + $result['pressure'] = round((intval($matches[6])/10),1); |
|
| 702 | + } |
|
| 569 | 703 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 570 | 704 | } 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)) { |
| 571 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 572 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 573 | - if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
|
| 574 | - if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); |
|
| 705 | + if ($matches[1] != '...') { |
|
| 706 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 707 | + } |
|
| 708 | + if ($matches[2] != '...') { |
|
| 709 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 710 | + } |
|
| 711 | + if ($matches[2] != '...') { |
|
| 712 | + $result['humidity'] = intval($matches[3]); |
|
| 713 | + } |
|
| 714 | + if ($matches[4] != '...') { |
|
| 715 | + $result['pressure'] = round((intval($matches[4])/10),1); |
|
| 716 | + } |
|
| 575 | 717 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 576 | 718 | } 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)) { |
| 577 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 578 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 579 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 580 | - if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
|
| 581 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 719 | + if ($matches[1] != '...') { |
|
| 720 | + $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
| 721 | + } |
|
| 722 | + if ($matches[2] != '...') { |
|
| 723 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
| 724 | + } |
|
| 725 | + if ($matches[3] != '...') { |
|
| 726 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
| 727 | + } |
|
| 728 | + if ($matches[4] != '...') { |
|
| 729 | + $result['humidity'] = intval($matches[4]); |
|
| 730 | + } |
|
| 731 | + if ($matches[5] != '...') { |
|
| 732 | + $result['pressure'] = round((intval($matches[5])/10),1); |
|
| 733 | + } |
|
| 582 | 734 | $body_parse = substr($body_parse,strlen($matches[0])); |
| 583 | 735 | } |
| 584 | 736 | $result['comment'] = trim($body_parse); |
| 585 | 737 | } |
| 586 | - } else $result['comment'] = trim($body_parse); |
|
| 738 | + } else { |
|
| 739 | + $result['comment'] = trim($body_parse); |
|
| 740 | + } |
|
| 587 | 741 | |
| 588 | 742 | } |
| 589 | 743 | //} |
| 590 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
| 591 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
| 592 | - if ($debug) print_r($result); |
|
| 744 | + if (isset($result['latitude'])) { |
|
| 745 | + $result['latitude'] = round($result['latitude'],4); |
|
| 746 | + } |
|
| 747 | + if (isset($result['longitude'])) { |
|
| 748 | + $result['longitude'] = round($result['longitude'],4); |
|
| 749 | + } |
|
| 750 | + if ($debug) { |
|
| 751 | + print_r($result); |
|
| 752 | + } |
|
| 593 | 753 | return $result; |
| 594 | 754 | } |
| 595 | 755 | |
@@ -598,12 +758,21 @@ discard block |
||
| 598 | 758 | $aprs_connect = 0; |
| 599 | 759 | $aprs_keep = 120; |
| 600 | 760 | $aprs_last_tx = time(); |
| 601 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 602 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 603 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
|
| 604 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 605 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
|
| 606 | - else $aprs_pass = '-1'; |
|
| 761 | + if (isset($globalAPRSversion)) { |
|
| 762 | + $aprs_version = $globalAPRSversion; |
|
| 763 | + } else { |
|
| 764 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 765 | + } |
|
| 766 | + if (isset($globalServerAPRSssid)) { |
|
| 767 | + $aprs_ssid = $globalServerAPRSssid; |
|
| 768 | + } else { |
|
| 769 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 770 | + } |
|
| 771 | + if (isset($globalServerAPRSpass)) { |
|
| 772 | + $aprs_pass = $globalServerAPRSpass; |
|
| 773 | + } else { |
|
| 774 | + $aprs_pass = '-1'; |
|
| 775 | + } |
|
| 607 | 776 | |
| 608 | 777 | $aprs_filter = ''; |
| 609 | 778 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
@@ -636,10 +805,14 @@ discard block |
||
| 636 | 805 | |
| 637 | 806 | public function send($data) { |
| 638 | 807 | global $globalDebug; |
| 639 | - if ($this->connected === false) $this->connect(); |
|
| 808 | + if ($this->connected === false) { |
|
| 809 | + $this->connect(); |
|
| 810 | + } |
|
| 640 | 811 | $send = socket_send( $this->socket , $data , strlen($data),0); |
| 641 | 812 | if ($send === FALSE) { |
| 642 | - if ($globalDebug) echo 'Reconnect...'; |
|
| 813 | + if ($globalDebug) { |
|
| 814 | + echo 'Reconnect...'; |
|
| 815 | + } |
|
| 643 | 816 | socket_close($this->socket); |
| 644 | 817 | $this->connect(); |
| 645 | 818 | } |
@@ -661,22 +834,32 @@ discard block |
||
| 661 | 834 | //$w = '00'; |
| 662 | 835 | $custom = ''; |
| 663 | 836 | if ($ident != '') { |
| 664 | - if ($custom != '') $custom .= '/'; |
|
| 837 | + if ($custom != '') { |
|
| 838 | + $custom .= '/'; |
|
| 839 | + } |
|
| 665 | 840 | $custom .= 'CS='.$ident; |
| 666 | 841 | } |
| 667 | 842 | if ($squawk != '') { |
| 668 | - if ($custom != '') $custom .= '/'; |
|
| 843 | + if ($custom != '') { |
|
| 844 | + $custom .= '/'; |
|
| 845 | + } |
|
| 669 | 846 | $custom .= 'SQ='.$squawk; |
| 670 | 847 | } |
| 671 | 848 | if ($verticalrate != '') { |
| 672 | - if ($custom != '') $custom .= '/'; |
|
| 849 | + if ($custom != '') { |
|
| 850 | + $custom .= '/'; |
|
| 851 | + } |
|
| 673 | 852 | $custom .= 'VR='.$verticalrate; |
| 674 | 853 | } |
| 675 | 854 | if ($aircraft_icao != '' && $aircraft_icao != 'NA') { |
| 676 | - if ($custom != '') $custom .= '/'; |
|
| 855 | + if ($custom != '') { |
|
| 856 | + $custom .= '/'; |
|
| 857 | + } |
|
| 677 | 858 | $custom .= 'AI='.$aircraft_icao; |
| 678 | 859 | } |
| 679 | - if ($custom != '') $custom = ' '.$custom; |
|
| 860 | + if ($custom != '') { |
|
| 861 | + $custom = ' '.$custom; |
|
| 862 | + } |
|
| 680 | 863 | /* |
| 681 | 864 | // Use AMSL altitude |
| 682 | 865 | $GeoidClass = new GeoidHeight(); |
@@ -700,30 +883,44 @@ discard block |
||
| 700 | 883 | //$w = '00'; |
| 701 | 884 | $custom = ''; |
| 702 | 885 | if ($ident != '') { |
| 703 | - if ($custom != '') $custom .= '/'; |
|
| 886 | + if ($custom != '') { |
|
| 887 | + $custom .= '/'; |
|
| 888 | + } |
|
| 704 | 889 | $custom .= 'CS='.str_replace(' ','_',$ident); |
| 705 | 890 | } |
| 706 | 891 | if ($typeid != '') { |
| 707 | - if ($custom != '') $custom .= '/'; |
|
| 892 | + if ($custom != '') { |
|
| 893 | + $custom .= '/'; |
|
| 894 | + } |
|
| 708 | 895 | $custom .= 'TI='.$typeid; |
| 709 | 896 | } |
| 710 | 897 | if ($statusid != '') { |
| 711 | - if ($custom != '') $custom .= '/'; |
|
| 898 | + if ($custom != '') { |
|
| 899 | + $custom .= '/'; |
|
| 900 | + } |
|
| 712 | 901 | $custom .= 'SI='.$statusid; |
| 713 | 902 | } |
| 714 | 903 | if ($imo != '') { |
| 715 | - if ($custom != '') $custom .= '/'; |
|
| 904 | + if ($custom != '') { |
|
| 905 | + $custom .= '/'; |
|
| 906 | + } |
|
| 716 | 907 | $custom .= 'IMO='.$imo; |
| 717 | 908 | } |
| 718 | 909 | if ($arrival_date != '') { |
| 719 | - if ($custom != '') $custom .= '/'; |
|
| 910 | + if ($custom != '') { |
|
| 911 | + $custom .= '/'; |
|
| 912 | + } |
|
| 720 | 913 | $custom .= 'AD='.strtotime($arrival_date); |
| 721 | 914 | } |
| 722 | 915 | if ($arrival_code != '') { |
| 723 | - if ($custom != '') $custom .= '/'; |
|
| 916 | + if ($custom != '') { |
|
| 917 | + $custom .= '/'; |
|
| 918 | + } |
|
| 724 | 919 | $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
| 725 | 920 | } |
| 726 | - if ($custom != '') $custom = ' '.$custom; |
|
| 921 | + if ($custom != '') { |
|
| 922 | + $custom = ' '.$custom; |
|
| 923 | + } |
|
| 727 | 924 | $altitude = 0; |
| 728 | 925 | $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"); |
| 729 | 926 | } |
@@ -28,16 +28,25 @@ discard block |
||
| 28 | 28 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
| 29 | 29 | //$airline_icao = substr($ident, 0, 3); |
| 30 | 30 | return $ident; |
| 31 | - } else return $ident; |
|
| 32 | - } else return $ident; |
|
| 31 | + } else { |
|
| 32 | + return $ident; |
|
| 33 | + } |
|
| 34 | + } else { |
|
| 35 | + return $ident; |
|
| 36 | + } |
|
| 33 | 37 | if ($airline_icao == 'AF') { |
| 34 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 35 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 38 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 39 | + $icao = $ident; |
|
| 40 | + } else { |
|
| 41 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 42 | + } |
|
| 36 | 43 | } else { |
| 37 | 44 | $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
| 38 | 45 | if (isset($identicao[0])) { |
| 39 | 46 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
| 40 | - } else $icao = $ident; |
|
| 47 | + } else { |
|
| 48 | + $icao = $ident; |
|
| 49 | + } |
|
| 41 | 50 | } |
| 42 | 51 | return $icao; |
| 43 | 52 | } |
@@ -55,7 +64,9 @@ discard block |
||
| 55 | 64 | $sth->closeCursor(); |
| 56 | 65 | if (count($row) > 0) { |
| 57 | 66 | return $row['operator_correct']; |
| 58 | - } else return $ident; |
|
| 67 | + } else { |
|
| 68 | + return $ident; |
|
| 69 | + } |
|
| 59 | 70 | } |
| 60 | 71 | |
| 61 | 72 | public function addOperator($ident,$correct_ident,$source) { |
@@ -84,7 +95,9 @@ discard block |
||
| 84 | 95 | global $globalTranslationSources, $globalTranslationFetch; |
| 85 | 96 | //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder'); |
| 86 | 97 | $globalTranslationSources = array(); |
| 87 | - if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE; |
|
| 98 | + if (!isset($globalTranslationFetch)) { |
|
| 99 | + $globalTranslationFetch = TRUE; |
|
| 100 | + } |
|
| 88 | 101 | //echo "Check Translation for ".$ident."..."; |
| 89 | 102 | $correct = $this->getOperator($ident); |
| 90 | 103 | if ($correct != '' && $correct != $ident) { |
@@ -36,79 +36,126 @@ |
||
| 36 | 36 | $data['hex'] = trim($line['hex']); |
| 37 | 37 | if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 38 | 38 | $data['datetime'] = $line['datetime']; |
| 39 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 39 | + } else { |
|
| 40 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 41 | + } |
|
| 40 | 42 | if (!isset($line['aircraft_icao'])) { |
| 41 | 43 | $Spotter = new Spotter(); |
| 42 | 44 | $aircraft_icao = $Spotter->getAllAircraftType($data['hex']); |
| 43 | 45 | $Spotter->db = null; |
| 44 | 46 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
| 45 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 46 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 47 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 48 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 47 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
| 48 | + $aircraft_icao = 'GLID'; |
|
| 49 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
| 50 | + $aircraft_icao = 'UHEL'; |
|
| 51 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
| 52 | + $aircraft_icao = 'TOWPLANE'; |
|
| 53 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
| 54 | + $aircraft_icao = 'POWAIRC'; |
|
| 55 | + } |
|
| 49 | 56 | } |
| 50 | 57 | $data['aircraft_icao'] = $aircraft_icao; |
| 51 | - } else $data['aircraft_icao'] = $line['aircraft_icao']; |
|
| 58 | + } else { |
|
| 59 | + $data['aircraft_icao'] = $line['aircraft_icao']; |
|
| 60 | + } |
|
| 52 | 61 | //if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n"; |
| 53 | 62 | } |
| 54 | 63 | if (isset($line['registration']) && $line['registration'] != '') { |
| 55 | 64 | $data['registration'] = $line['registration']; |
| 56 | - } else $data['registration'] = null; |
|
| 65 | + } else { |
|
| 66 | + $data['registration'] = null; |
|
| 67 | + } |
|
| 57 | 68 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 58 | 69 | $data['waypoints'] = $line['waypoints']; |
| 59 | - } else $data['waypoints'] = null; |
|
| 70 | + } else { |
|
| 71 | + $data['waypoints'] = null; |
|
| 72 | + } |
|
| 60 | 73 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
| 61 | 74 | $data['ident'] = trim($line['ident']); |
| 62 | - } else $data['ident'] = null; |
|
| 75 | + } else { |
|
| 76 | + $data['ident'] = null; |
|
| 77 | + } |
|
| 63 | 78 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') { |
| 64 | 79 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 65 | 80 | $data['latitude'] = $line['latitude']; |
| 66 | - } else $data['latitude'] = null; |
|
| 81 | + } else { |
|
| 82 | + $data['latitude'] = null; |
|
| 83 | + } |
|
| 67 | 84 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 68 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 85 | + if ($line['longitude'] > 180) { |
|
| 86 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 87 | + } |
|
| 69 | 88 | $data['longitude'] = $line['longitude']; |
| 70 | - } else $data['longitude'] = null; |
|
| 89 | + } else { |
|
| 90 | + $data['longitude'] = null; |
|
| 91 | + } |
|
| 71 | 92 | } else { |
| 72 | 93 | $data['latitude'] = null; |
| 73 | 94 | $data['longitude'] = null; |
| 74 | 95 | } |
| 75 | 96 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 76 | 97 | $data['verticalrate'] = $line['verticalrate']; |
| 77 | - } else $data['verticalrate'] = null; |
|
| 98 | + } else { |
|
| 99 | + $data['verticalrate'] = null; |
|
| 100 | + } |
|
| 78 | 101 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 79 | 102 | $data['emergency'] = $line['emergency']; |
| 80 | - } else $data['emergency'] = null; |
|
| 103 | + } else { |
|
| 104 | + $data['emergency'] = null; |
|
| 105 | + } |
|
| 81 | 106 | if (isset($line['ground']) && $line['ground'] != '') { |
| 82 | 107 | $data['ground'] = $line['ground']; |
| 83 | - } else $data['ground'] = null; |
|
| 108 | + } else { |
|
| 109 | + $data['ground'] = null; |
|
| 110 | + } |
|
| 84 | 111 | if (isset($line['speed']) && $line['speed'] != '') { |
| 85 | 112 | $data['speed'] = round($line['speed']); |
| 86 | - } else $data['speed'] = null; |
|
| 113 | + } else { |
|
| 114 | + $data['speed'] = null; |
|
| 115 | + } |
|
| 87 | 116 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 88 | 117 | $data['squawk'] = $line['squawk']; |
| 89 | - } else $data['squawk'] = null; |
|
| 118 | + } else { |
|
| 119 | + $data['squawk'] = null; |
|
| 120 | + } |
|
| 90 | 121 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 91 | 122 | $data['altitude'] = round($line['altitude']); |
| 92 | - } else $data['altitude'] = null; |
|
| 123 | + } else { |
|
| 124 | + $data['altitude'] = null; |
|
| 125 | + } |
|
| 93 | 126 | if (isset($line['heading']) && $line['heading'] != '') { |
| 94 | 127 | $data['heading'] = round($line['heading']); |
| 95 | - } else $data['heading'] = null; |
|
| 128 | + } else { |
|
| 129 | + $data['heading'] = null; |
|
| 130 | + } |
|
| 96 | 131 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 97 | 132 | $data['source_name'] = $line['source_name']; |
| 98 | - } else $data['source_name'] = null; |
|
| 133 | + } else { |
|
| 134 | + $data['source_name'] = null; |
|
| 135 | + } |
|
| 99 | 136 | if (isset($line['over_country']) && $line['over_country'] != '') { |
| 100 | 137 | $data['over_country'] = $line['over_country']; |
| 101 | - } else $data['over_country'] = null; |
|
| 138 | + } else { |
|
| 139 | + $data['over_country'] = null; |
|
| 140 | + } |
|
| 102 | 141 | if (isset($line['noarchive']) && $line['noarchive']) { |
| 103 | 142 | $data['noarchive'] = true; |
| 104 | - } else $data['noarchive'] = false; |
|
| 143 | + } else { |
|
| 144 | + $data['noarchive'] = false; |
|
| 145 | + } |
|
| 105 | 146 | $data['format_source'] = $line['format_source']; |
| 106 | - if (isset($line['id_source'])) $id_source = $line['id_source']; |
|
| 147 | + if (isset($line['id_source'])) { |
|
| 148 | + $id_source = $line['id_source']; |
|
| 149 | + } |
|
| 107 | 150 | if (isset($data['hex'])) { |
| 108 | 151 | echo '.'; |
| 109 | 152 | $id_user = $globalServerUserID; |
| 110 | - if ($id_user == NULL) $id_user = 1; |
|
| 111 | - if (!isset($id_source)) $id_source = 1; |
|
| 153 | + if ($id_user == NULL) { |
|
| 154 | + $id_user = 1; |
|
| 155 | + } |
|
| 156 | + if (!isset($id_source)) { |
|
| 157 | + $id_source = 1; |
|
| 158 | + } |
|
| 112 | 159 | $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)'; |
| 113 | 160 | $query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']); |
| 114 | 161 | try { |
@@ -15,8 +15,12 @@ discard block |
||
| 15 | 15 | } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
| 16 | 16 | $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
| 17 | 17 | $sql_date = $end_date; |
| 18 | - } else $sql_date = ''; |
|
| 19 | -} else $sql_date = ''; |
|
| 18 | + } else { |
|
| 19 | + $sql_date = ''; |
|
| 20 | + } |
|
| 21 | + } else { |
|
| 22 | + $sql_date = ''; |
|
| 23 | +} |
|
| 20 | 24 | |
| 21 | 25 | if (isset($_GET['highest_altitude'])) { |
| 22 | 26 | //for altitude manipulation |
@@ -30,8 +34,12 @@ discard block |
||
| 30 | 34 | } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
| 31 | 35 | $start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000"; |
| 32 | 36 | $sql_altitude = $start_altitude; |
| 33 | - } else $sql_altitude = ''; |
|
| 34 | -} else $sql_altitude = ''; |
|
| 37 | + } else { |
|
| 38 | + $sql_altitude = ''; |
|
| 39 | + } |
|
| 40 | + } else { |
|
| 41 | + $sql_altitude = ''; |
|
| 42 | +} |
|
| 35 | 43 | |
| 36 | 44 | //calculuation for the pagination |
| 37 | 45 | if(!isset($_GET['limit'])) |
@@ -48,7 +56,7 @@ discard block |
||
| 48 | 56 | $limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
| 49 | 57 | $absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
| 50 | 58 | } |
| 51 | -} else { |
|
| 59 | +} else { |
|
| 52 | 60 | $limit_explode = explode(",", $_GET['limit']); |
| 53 | 61 | $limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT); |
| 54 | 62 | $limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT); |
@@ -66,8 +74,11 @@ discard block |
||
| 66 | 74 | |
| 67 | 75 | header('Content-Type: application/json'); |
| 68 | 76 | |
| 69 | -if (isset($_GET['sort'])) $sort = $_GET['sort']; |
|
| 70 | -else $sort = ''; |
|
| 77 | +if (isset($_GET['sort'])) { |
|
| 78 | + $sort = $_GET['sort']; |
|
| 79 | +} else { |
|
| 80 | + $sort = ''; |
|
| 81 | +} |
|
| 71 | 82 | $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING); |
| 72 | 83 | $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING); |
| 73 | 84 | $aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING); |