function populate_data($ICAO_arr) { global $Airports; for ($i = 0; $i < count($ICAO_arr); $i++) { $ICAO = $ICAO_arr[$i]; $metar_data = get_metar($ICAO); $taf_data = get_taf($ICAO); $Airports[] = array('ICAO' => $ICAO, 'METAR' => $metar_data, 'TAF' => $taf_data); } }
function metar_taf() { ?> <br/> <h4 style="font-weight:bold;">METAR/TAF GENERATOR</h4> <p>Insert up to 3 valid ICAO identifiers to get METAR and TAF Reports</p> <form action="<?php the_permalink(); ?> " id="avwx" method="POST"> ICAO CODES <input type="text" name="icao1" id="airport" maxlength="4" size="4" onkeyup="javascript:this.value=this.value.toUpperCase()"> <input type="text" name="icao2" id="airport" maxlength="4" size="4" onkeyup="javascript:this.value=this.value.toUpperCase()"> <input type="text" name="icao3" id="airport" maxlength="4" size="4" onkeyup="javascript:this.value=this.value.toUpperCase()"> <input type="submit" name="submit" id="submitted" value="GET REPORT"> </form> <br/> <?php if (isset($_POST['submit'])) { foreach ($_POST as $icao) { if ($icao == "GET REPORT") { break; } else { if ($icao != NULL) { echo get_metar($icao); echo "<br>"; echo "<br>"; echo get_taf($icao); echo "<br>"; echo "<br>"; } else { continue; } } } } }
} // end post validation // if (isset($remember_me)) { if ($show_display_name == "yes") { setcookie("remember_me", stripslashes($displayname), time() + 60 * 60 * 24 * 365 * 2); } elseif ($show_display_name == "no") { setcookie("remember_me", stripslashes($fullname), time() + 60 * 60 * 24 * 365 * 2); } } elseif (isset($reset_cookie)) { setcookie("remember_me", "", time() - 3600); } ob_end_flush(); } if ($display_weather == 'yes') { include 'phpweather.php'; $metar = get_metar($metar); $data = process_metar($metar); if ($weather_units == "f") { $mph = " mph"; $miles = " miles"; // weather info // if (!isset($data['temp_f'])) { $temp = ''; } else { $temp = $data['temp_f']; } if (!isset($data['windchill_f'])) { $windchill = ''; } else { $windchill = $data['windchill_f']; }
include "./helpers/get_metar.php"; $airport = strtoupper($_POST['airport']); /* Connect to Database */ $db = new mysqli($db_host, $db_username, $db_password, $db_database); $db->set_charset("utf8"); if ($db->connect_errno > 0) { die('Unable to connect to database [' . $db->connect_error . ']'); } // Execute SQL query $sql = "select * from runways where airport_ident='" . $airport . "'"; ?> <div class="content"> <div class="container-fluid"> <div class="col-md-12"> <div class="row"> <div class="col-md-10"> <div class="card"> <div class="header"> <h4 class="title">Información del Metar</h4> </div> <div class="content"> <div class="table-full-width"> <table class="table"> <tr><td><center> <?php get_metar($airport); ?> </center> </tr></td> </table></div> </div> </div> </div> <div class="col-md-10"> <div class="card"> <div class="header"> <h4 class="title">Mapa del Aeropuerto</h4> </div> <div class="content"> <div class="table-full-width"> <table class="table"> <tr><td><center> <?php include 'airport_map.php'; ?> </center> </tr></td> </table></div> </div> </div> </div> <div class="col-md-10"> <div class="card"> <div class="header"> <h4 class="title">Información de Pistas del Aeropuerto</h4> </div> <div class="content"> <div class="table-full-width"> <table class="table table-hover"> <?php
<?php $ICAO = strval($_GET['ICAO'] ? $_GET['ICAO'] : '0'); get_metar($ICAO); function get_metar($ICAO) { $fileName = "http://weather.noaa.gov/pub/data/observations/metar/stations/{$ICAO}.TXT"; $metar = ''; $fileData = @file($fileName) or die('METAR not available for ' . $ICAO); if ($fileData != false) { list($i, $date) = each($fileData); $utc = strtotime(trim($date)); $time = date("D, F jS Y g:i A", $utc); while (list($i, $line) = each($fileData)) { $metar .= ' ' . trim($line); } $metar = trim(str_replace(' ', ' ', $metar)); } echo "METAR for {$ICAO} (Issued: {$time} UTC):<br>{$metar}"; } function get_metar_all($ICAO) { $fileName = "http://weather.noaa.gov/pub/data/observations/metar/stations/{$ICAO}.TXT"; $metar = ''; $fileData = @file($fileName) or die('METAR not available for ' . $ICAO); if ($fileData != false) { list($i, $date) = each($fileData); $utc = strtotime(trim($date)); $time = date("D, F jS Y g:i A", $utc); while (list($i, $line) = each($fileData)) { $metar .= ' ' . trim($line);