<?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:
Example #2
0
    } else {
        if ($settings_phavison_get_enabled && isset($_GET['call_to'])) {
            // Get the name of the function from the get data
            $function = $_GET['call_to'];
            if (isset($_GET['para'])) {
                $para = $_GET['para'];
            }
            run_function();
        } else {
            $error_code = "R-Err_1";
            $error_message = "No 'call_to' function was defined. Please specify a function and try again.";
        }
    }
}
function run_function()
{
    // We first need to bring in our dependant globals.
    global $function, $para, $call_data, $error_code, $error_message;
    // Here we check if the function exists then actually call the function.
    if (function_exists($function)) {
        $call_data = $function(json_decode(base64_decode($para), true));
    } else {
        $error_code = "R-Err_2";
        $error_message = "A call to the function '{$function}' was made. That function does not exist or is not within a php file under the home directory located at '" . $settings_php_dir . "'";
    }
}
// Calculate script running time (for debugging if needed).
$execution_time = (microtime(true) - $time_start) * 1000;
// Run the function and return the json object to jquery.phavison(.min).js
$return_data = populate_data($error_code, $error_message, $function, $para, $execution_time, $call_data, $settings_phavison_secure);
echo json_encode($return_data);