<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';

if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog` WHERE `id` = '".intval($_GET['id'])."'"),0)==1)
{
$id=intval($_GET['id']);
$check=mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_klass` WHERE `id_blog` = '$id' AND `uid` = '$user[id]'"),0);

$blog=mysql_fetch_array(mysql_query("SELECT * FROM `microblog` WHERE `id` = '$id' LIMIT 1"));
if (isset($user) && $check==0)
mysql_query("INSERT INTO `microblog_klass` SET `id_blog` = '$id', `uid` = '$user[id]', `time` = '".time()."'");

$q = mysql_query("SELECT * FROM `frends` WHERE `user` = '$user[id]'");
while ($f = mysql_fetch_array($q))
{
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[frend]' LIMIT 1"));

$msg_lenta="Ваш друг [b]$user[nick][/b] считает классным [url=/microblog/microblog.php?id=$id] микроблог [/url]";

mysql_query("INSERT INTO `lenta` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$a[id]', '$msg_lenta', '$time')"); 
}

$msg2="[b]$user[nick][/b] считает ваш [url=/microblog/microblog.php?id=$id] микроблог [/url] классным .супер.";
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$blog[uid]', '$msg2', '$time')");


}

if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']!=NULL)
header("Location: ".$_SERVER['HTTP_REFERER']);
else
header("Location: microblog.php?id=$id");

?>