<?

/////// by Kyber 2011
/////// ICQ 626-000-895
/////// Поддержка: http://klybok.net
////// Запрещено продавать!!!



/////////////////////////////кода мода/////////////запросы
if(isset($_GET['like'])){
$rat=mysql_fetch_assoc(mysql_query("SELECT * FROM `news` WHERE `id` = '".intval($_GET['like'])."' AND `id` = '".$news['id']."' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `news_p_rating` WHERE `id_user` = '".$user['id']."' AND `id_post` = '".$rat['id']."'"), 0)==0 && $rat['id_user']!=$user['id']){
mysql_query("UPDATE `news` SET `rating` = '".($rat['rating']+1)."' WHERE `id` = '".$rat['id']."' LIMIT 1",$db);
mysql_query("INSERT INTO `news_p_rating` (`id_user`, `id_post`, `rating`) values('".$user['id']."', '".$rat['id']."','1')",$db);}
}
mysql_query("alter table `news` add `rating` int(11) default '0';");
mysql_query("CREATE TABLE IF NOT EXISTS `news_p_rating` (
  `id` int(11) NOT NULL auto_increment,
  `id_user` int(11) NOT NULL,
  `id_post` int(11) NOT NULL,
  `rating` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;");
/////////////////////////////кода мода/////////////

$q=mysql_query("SELECT * FROM `news` WHERE `main_time` > '".time()."' ORDER BY `id` DESC LIMIT 1");
if (mysql_num_rows($q)==1 && !$set['web'])
{
$news = mysql_fetch_assoc($q);
echo "<div class='news'>\n";
echo "<div class='p_t'>\n";
echo "<a href='/news/'>$news[title]</a>\n";
echo "(".vremja($news['time']).")\n";
echo "</div>\n";
echo "<div class='p_m'>\n";
//echo output_text($news['msg'])."<br />\n";
if ($news['link']!=NULL)echo "<a href='".htmlentities($news['link'], ENT_QUOTES, 'UTF-8')."'>Подробности</a><br />\n";
/////////////////////////////кода мода/////////////вывод
if(isset($user))echo " <font color=#FF4500>❤</font> <a href='/news/?like=$news[id]'><font color=#FF4500><b>Нравится</b> </font></a> <a href='/news/komy.php?id=".$news['id']."'><font color=#00ff00> + ".$news['rating']."</font></a> | ";
/////////////////////////////кода мода/////////////
echo "<a href='/news/komm.php?id=$news[id]'>Комментарии</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '$news[id]'"),0).")<br />\n";
echo "</div>\n";
echo "</div>\n";


}
?>