ACC SHELL

Path : /www/hosting/oltv.cz/www/utils/
File Upload :
Current File : /www/hosting/oltv.cz/www/utils/_.php

<?php
require('../include/config.php');

$apiKey = '25334d339fea06fffb3b026ca7b48896';
$cityId = 3069011;

$url = 'http://api.openweathermap.org/data/2.5/forecast?id='.$cityId.'&APPID='.$apiKey.'&units=metric';


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
$result = json_decode($result);
curl_close($ch);

function getIcon($icon) {
	switch ($icon) {
		case $icon == '01d' || $icon == '01n': $icon = 1; break;
		case $icon == '02d' || $icon == '02n': $icon = 2; break;
		case $icon == '03d' || $icon == '03n': $icon = 3; break;
		case $icon == '04d' || $icon == '04n': $icon = 3; break;
		case $icon == '09d' || $icon == '09n': $icon = 4; break;
		case $icon == '10d' || $icon == '10n': $icon = 5; break;
		case $icon == '11d' || $icon == '11n': $icon = 7; break;
		case $icon == '13d' || $icon == '13n': $icon = 14; break;
		case $icon == '50d' || $icon == '50n': $icon = 8; break;
	}

	return $icon;
}
$maxZitraTemp = 0;
foreach ($result->list as $data) {
	$epoch = $data->dt;
	$dt = new DateTime("@$epoch");

	$today = new Datetime();
	$today->modify('today 12:00');

	if ($dt->format('Y-m-d H:i:s') == $today->format('Y-m-d H:i:s')) {
		dibi::query("UPDATE [pocasi] SET teplota = %s, aktualni_kod = %i WHERE id = 1", round($data->main->temp), getIcon($data->weather[0]->icon));
	}

	$zitra = new Datetime();
	$zitra->modify('+1 day 12:00');

	if ($dt->format('Y-m-d') == $zitra->format('Y-m-d') && $data->main->temp > $maxZitraTemp) {
		$maxZitraTemp = $data->main->temp;
	}

	if ($dt->format('Y-m-d H:i:s') == $zitra->format('Y-m-d H:i:s')) {
		dibi::query("UPDATE [pocasi] SET teplota = %s, teplota_max = %s, aktualni_kod = %i WHERE id = 1", round($data->main->temp), round($maxZitraTemp), getIcon($data->weather[0]->icon));
	}
}

ACC SHELL 2018