<?php
if (!defined('MODULE_FILE')) {
	Header("Location: ../../index.php");
	exit;
}
/*
©Serg_pnz,  2007
e-mail: print58@yandex.ru  
www.ponedelnikov.net
*/
$module_name = basename(dirname(__FILE__));
require_once("config/config_pogoda.php");

function readservis($link) {
$fd = fopen($link, "r");
$text="";
	if (!$fd) {
		return "Проблемка";
	} else {
		while (!feof ($fd)) {
			$text .= fgets($fd, 4096);
		}
	}
fclose ($fd);
return $text;
}

	$pagetitle = "$defis Погода";
	include("header.php");
	OpenTable();
	echo "<center><font class=\"title\"><b>Погода</b></font><br><font class='option'><b>в городе ".$city." на ближайшие дни</b></font></center>";
	CloseTable();

	OpenTable();
echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"javascripts/SwitchMenu.js\"></script>";
echo "<div id=\"cont\" onclick=\"SwitchMenu(&#039;news&#039;)\" style=\"cursor:pointer;\><span class=\"option\"><img src=\"images/arrow.gif\"><b>&nbsp;Заголовки новостей</b></span></div>";
echo "<div id=\"news\" style=\"display:none;\"><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"bgcolor4\">"
."<tr><th>Последние новости</th><th>Популярные новости</th>"
."</tr><tr class=\"bgcolor1\" valign=\"top\" width=\"50%\">";

// Last News
echo "<td valign=\"top\" width=\"50%\" align=\"left\">";
$result = $db->sql_query("SELECT sid, time, title FROM ".$prefix."_stories WHERE time <= NOW() AND status='1' ORDER BY time DESC LIMIT $limit");
while(list($sid, $time, $title) = $db->sql_fetchrow($result)) {
	formatTimestamp($time);
	$linkstrip = cutstr($title, $strip);
	echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"3\" border=\"0\"><tr><td><img src=\"images/blocks/News.gif\" title=\"$title\"></td><td align=\"left\" width=\"100%\">$datetime <a href=\"index.php?name=News&op=article&sid=$sid\" title=\"$title\">$linkstrip</a></td></tr></table>";
}

// Top News (по количеству просмотров)
echo "</td><td valign=\"top\" width=\"50%\" align=\"left\">";
$result = $db->sql_query("SELECT sid, time, title FROM ".$prefix."_stories WHERE time <= NOW() AND status='1' ORDER BY counter DESC LIMIT $limit");
while(list($sid, $time, $title) = $db->sql_fetchrow($result)) {
	formatTimestamp($time);
	$linkstrip = cutstr($title, $strip);
	echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"3\" border=\"0\"><tr><td><img src=\"images/blocks/News.gif\" title=\"$title\"></td><td align=\"left\" width=\"100%\">$datetime <a href=\"index.php?name=News&op=article&sid=$sid\" title=\"$title\">$linkstrip</a></td></tr></table>";
}

echo "</td></tr></table></div>";
	CloseTable();

	OpenTable();
$out = readservis("http://www.gismeteo.ua/towns/".$kod.".htm");
preg_match('/var frc=\'(.*)\'; var prhdr=/sUi',$out,$tabl);
echo preg_replace("#<tr><td colspan=8>(.*?)Печать</a></b></span></td></tr>#si","",$tabl[1]);

	OpenTable();
	echo "Прогноз погоды предоставлен сервисом <a href=\"http://www.gismeteo.ua\">Gismeteo</a>.";
	CloseTable();
	CloseTable();

	include("footer.php");

?>