<?php 

$city = $tools->keyGlobals('city', 0);
$full = $tools->keyGlobals('full', 0);
$city = mysql_fetch_assoc(mysql_query("SELECT * FROM city WHERE city_id = " . (int) $city));

if (!$city) {
    if (isset($user)) {
        $city_search = $user['ank_city'];
        $city = mysql_fetch_assoc(mysql_query("SELECT * FROM city WHERE name = '$city_search'"));
    }
    
    if (!$city) {
        $city = mysql_fetch_assoc(mysql_query("SELECT * FROM city WHERE name = 'Москва'"));
    }
}

// Класс Yandex API
require 'classes/class.Yandex.php';

$set['title'] = __('Погода').'/'.$city['name'];
require H.'sys/inc/thead.php';
title();
aut();
?>
  <div class='foot'> <a href='/'><img src='img/in.png' alt='*' class='icon'/> Назад </a> / 
  <a href="?city=<?= $city['city_id']?>"><?= $city['name']?></a> / 
  <b class="active"><?= __('Погода')?></b>
</div>

<div class="gmenu">
  <center>
    <b><?= __('Погода в городе г.')?><?= $city['name']?></b> <a href="/user/settings/?func=location&amp;r=weather"><img src="img/gear.png" alt="*" class="icon"/> <?= __('Изменить')?></a>
  </center>
</div>
  <div class='gmenu'>
    <a href="?func=<?= $func?>&amp;city=<?= $city['city_id']?>">КРАТКО</a> | 
    <a href="?func=<?= $func?>&amp;city=<?= $city['city_id']?>&amp;full=1">ПОДРОБНО</a>
</div>
<?
$weather = new Yandex();

if ($city['yandex_id'] == 0) {
    $city = mysql_fetch_assoc(mysql_query("SELECT * FROM city 
                                           WHERE region_id = '$city[region_id]' AND yandex_id != '0' 
                                           LIMIT 1"));
}

$weather->city = $city['yandex_id'];
$weather->count = 10;

$data = $weather->get_weather_day();

foreach($data['day'] AS $key => $day) {
  ?>
  <div class="gmenu">
    <div class="nav1">
       <b><?= $day['day_of_week']?>, <?= $day['day']?>.<?= $day['month']?></b>
    </div>
    

        <div class="nav2">
        <? 
        $i = 1; 
        
        if ($key != 0 && count($day['weather']) > 2 && $full == 0) {
          unset($day['weather'][0], $day['weather'][2]);
        }
        
        foreach($day['weather'] AS $post) { ?> 
          <div class="col-xs-6 col-md-6 center" style="padding-top: 4px; padding-bottom: 4px;">
            <?= ($post['time_of_day'] ? $post['time_of_day'] : __('сейчас'))?><br />
            <img src="http://yandex.st/weather/1.1.78/i/icons/48x48/<?= $post['image']?>.png"  style="max-width: 32px; width: 32px;"/> 
            <b><?= $post['temperature']?>&ordm;C</b><br /> 
            
            <? if ($full == 1) { ?>
              <?= $post['comment']?>
            <? } ?>
          </div>
        <? 
        $i++;
        }   
        ?>
        </div>
  </div>
  <?       
}

?>
<div class="foot">
  <a href="?city=<?= $city['city_id']?>"><img src='img/in.png' alt='*' class='icon'/> <?= __('Назад')?></a>
</div>
<?