<?
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';
only_reg();

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

$blog=mysql_fetch_array(mysql_query("SELECT * FROM `us_wall` WHERE `id` = '$id' LIMIT 1"));

$whowrite = get_user($blog['id_user']);
$waladm = get_user($blog['id_user_adm']);

if (isset($user) && $check==0)
mysql_query("INSERT INTO `wall_love` SET `id_msg` = '$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] понравилась запись $whowrite[nick] на [url=http://xlofes.ru/wall/?id=$blog[id_user_adm]] стене [/url] пользователя $waladm[nick]";

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=http://xlofes.ru/wall/?id=$blog[id_user_adm]] стене [/url] $waladm[nick]";
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$blog[id_user]', '$msg2', '$time')");


}

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

?>