Пример #1
0
<?php

/* This is Web Service for Aviation Weather Reports
    the Service Returns all Israel Available METAR and TAF Reports as JSON Object

    @Author - Gil Vitzinger
    @DateCreated - 17/06/2013

    */
header('Content-type: application/json');
$ICAO_arr = array("LLBG", "LLSD", "LLES", "LLIB", "LLHA", "LLOV", "LLBS", "LLET", "LLHZ", "LLJR", "LLMG", "LLKS", "LLIB", "LLSD", "LLEY", "LLFK", "LLMZ", "LLMR", "LLHB", "LLHS", "LLRM", "LLRD", "LLNV", "LLEK");
$timeFormat = "d-m-Y H:i:s";
$Airports = array();
//Get TAF data for all airports available
$taf_data_arr = getTAFdata();
populate_data($ICAO_arr, $Airports);
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 get_metar retrives metar broadcast for a specific airport according to given ICAO designation
   * @param $ICAO - ICAO designation for the Airport
   * @ return - returns Array Object:
       Array:
Пример #2
0
<?php

$ICAO = strval($_GET['ICAO'] ? $_GET['ICAO'] : '0');
$taf_data = getTAFdata();
echo get_taf($ICAO);
function get_taf($ICAO)
{
    global $taf_data;
    return $taf_data[$ICAO];
}
function getTAFdata()
{
    $query_str = 'http://www.ogimet.com/ultimos_tafs.php?lang=en&estado=Isra&fmt=txt&iord=yes&Send=Send';
    $raw_data = file_get_contents($query_str);
    $taf_data = TAF_split($raw_data);
    return $taf_data;
}
function TAF_split($data)
{
    $temp = explode("##########################################################", $data);
    $timeOfQuery = $temp[1];
    $temp = explode('###################################', $temp[2]);
    $timeOfData = $temp[1];
    $raw_data = $temp[2];
    $temp = explode("TAF", $raw_data);
    $i = 1;
    while ($i < sizeof($temp)) {
        $tmp = explode('=', $temp[$i]);
        $key_str = trim(substr($tmp[0], 1, 5));
        $tmp[0] = str_replace("BECMG", "<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . PHP_EOL . "BECMG", $tmp[0]);
        $tmp[0] = str_replace("TEMPO", "<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . PHP_EOL . "TEMPO", $tmp[0]);