public function searchSend() { $weather = new \Models\Weather(); if (isset($_POST["day"]) && isset($_POST["month"]) && isset($_POST["year"]) && isset($_POST["type"])) { $day = htmlspecialchars(filter_input(INPUT_POST, 'day', FILTER_SANITIZE_NUMBER_INT)); $month = htmlspecialchars(filter_input(INPUT_POST, 'month', FILTER_SANITIZE_NUMBER_INT)); $year = htmlspecialchars(filter_input(INPUT_POST, 'year', FILTER_SANITIZE_NUMBER_INT)); $type = htmlspecialchars(filter_input(INPUT_POST, 'type', FILTER_SANITIZE_STRING)); $date = $year . "-" . $month . "-" . $day; $data["response"] = $weather->getAllByTypeAndDate($type, $date); echo json_encode($data["response"]); } else { if (isset($_POST["month"]) && isset($_POST["year"]) && isset($_POST["type"])) { $month = htmlspecialchars(filter_input(INPUT_POST, 'month', FILTER_SANITIZE_NUMBER_INT)); $year = htmlspecialchars(filter_input(INPUT_POST, 'year', FILTER_SANITIZE_NUMBER_INT)); $type = htmlspecialchars(filter_input(INPUT_POST, 'type', FILTER_SANITIZE_STRING)); $data["response"] = $weather->getAllByTypeAndMonth($type, $month, $year, "text"); echo json_encode($data["response"]); } else { if (isset($_POST["year"]) && isset($_POST["type"])) { $year = htmlspecialchars(filter_input(INPUT_POST, 'year', FILTER_SANITIZE_NUMBER_INT)); $type = htmlspecialchars(filter_input(INPUT_POST, 'type', FILTER_SANITIZE_STRING)); $data["response"] = $weather->getAllByTypeAndYear($type, $year, "text"); echo json_encode($data["response"]); } } } }
public function arduinoFetcher() { if (isset($_GET)) { if (isset($_GET['type']) && isset($_GET['value']) && isset($_GET['key'])) { $weather = new \Models\Weather(); $postData = array('id' => "", 'type' => $_GET['type'], 'value' => $_GET['value']); $weather->sendData($postData); } } }
public function getLightning() { $weather = new \Models\Weather(); $data["response"] = $weather->getLastLightning(); echo json_encode($data["response"]); }
public function index() { $cache = new \Helpers\SimpleCache(); $sunriseSunset = json_decode($cache->get_data('sunrise-sunset', 'http://api.sunrise-sunset.org/json?lat=48.0833&lng=7.3667&date=today&formatted=1'), TRUE); $data["forecast_api"] = json_decode($cache->get_data('forecast', 'http://www.prevision-meteo.ch/services/json/colmar'), TRUE); //$saint=json_decode($cache->get_data('fete', 'http://fetedujour.fr/api/v2/'.FETE_API_KEY.'/json-normal'), TRUE); $data["title"] = "Accueil"; $data['javascript'] = array('AjaxControllers/Index/index'); $weather = new \Models\Weather(); $data["saintDuJour"] = $saint["name"]; $data["last_temp"] = $weather->getLastDataByType("temperature"); $data["last_dewPoint"] = $weather->getLastDataByType("dewPoint"); $data["max_temp"] = $weather->getExtremumByTypeAndDate("max", "temperature", date('Y-m-d')); $data["min_temp"] = $weather->getExtremumByTypeAndDate("min", "temperature", date('Y-m-d')); $data["last_windSpeed"] = $weather->getLastDataByType("windSpeed"); $data["last_windDir"] = $weather->getLastDataByType("windDir"); $data["max_windSpeed"] = $weather->getExtremumByTypeAndDate("max", "windSpeed", date('Y-m-d')); $data["min_windSpeed"] = $weather->getExtremumByTypeAndDate("min", "windSpeed", date('Y-m-d')); $data["last_rainFall"] = $weather->getLastDataByType("rainFall"); $data["sumWeek_rainFall"] = $weather->getExtremumByDateRow("sum", "rainFall", "1", "week"); $data["sumMonth_rainFall"] = $weather->getExtremumByDateRow("sum", "rainFall", "1", "month"); $data["last_humidity"] = $weather->getLastDataByType("humidity"); $data["last_pressure"] = $weather->getLastDataByType("pressure"); $data["last_uvIndex"] = $weather->getLastDataByType("uvIndex"); $data["vigilance"] = simplexml_load_file("http://vigilance.meteofrance.com/data/NXFR33_LFPW_.xml"); $data["sunrise_hour"] = strtotime($sunriseSunset["results"]["sunrise"]) + 3600; $data["sunrise_hour"] = date('G\\hi\\ms\\s', $data["sunrise_hour"]); $data["sunset_hour"] = strtotime($sunriseSunset["results"]["sunset"]) + 3600; $data["sunset_hour"] = date('G\\hi\\ms\\s', $data["sunset_hour"]); $data["day_length"] = gmdate("G\\hi\\ms\\s", strtotime($sunriseSunset["results"]["day_length"])); View::renderTemplate('header', $data); View::render('pages/index', $data); View::renderTemplate('footer', $data); }