<?
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($_POST['status']) && isset($user) && $user['id'] == $ank['id'])
{
$msg=$_POST['status'];
if (isset($_POST['translit']) && $_POST['translit']==1)$msg=translit($msg);$mat=antimat($msg);
if ($mat)$err[]='В тексте сообщения обнаружен мат: '.$mat;

if (strlen2($msg)>512){$err='Сообщение слишком длинное';}
elseif (strlen2($msg)<2){$err='Короткое сообщение';}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `status` WHERE `id_user` = '$user[id]' AND `msg` = '".my_esc($msg)."' LIMIT 1"),0)!=0){$err='Ваше сообщение повторяет предыдущее';}
elseif(!isset($err)){
mysql_query("UPDATE `status` SET `pokaz` = '0' WHERE `id_user` = '$user[id]'");
mysql_query("INSERT INTO `status` (`id_user`, `time`, `msg`, `pokaz`) values('$user[id]', '$time', '".my_esc($msg)."', '1')");$status=mysql_fetch_assoc(mysql_query("SELECT * FROM `status` WHERE `id_user` = '$ank[id]' AND `pokaz` = '1' LIMIT 1"));

$_SESSION['message'] = 'Статус добавлен';
header("Location: ?id=$ank[id]");
exit;
} 
}

//-------------------------------------// 

// Статус пользователя
$status=mysql_fetch_assoc(mysql_query("SELECT * FROM `status` WHERE `id_user` = '$ank[id]' AND `pokaz` = '1' LIMIT 1"));

if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `status` WHERE `id` = '".intval($_GET['id'])."'"),0)==1) {
$post=mysql_fetch_assoc(mysql_query("SELECT * FROM `status` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1"));

$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));

if (isset($user) && ($user['level']>$ank['level']) || $post['id_user']==$user['id']) {
mysql_query("UPDATE FROM `status` WHERE `id` = '$post[id]'");
$_SESSION['message'] = 'Статус упешно измененён';
header("Location: index.php?id=$ank[id]"); 
exit;
}






/*-----------------------статус форма-----------------------*/
if (isset($user) && isset($_GET['status']))
{
	if ($user['id'] == $ank['id'])
	{
		echo '<div class="main">Статус [512 символов]</div>';
		echo '<form action="/info.php?id=' . $ank['id'] . '" method="post">';
		echo "$tPanel<textarea type=\"text\" style='' name=\"status\" value=\"\"/></textarea><br /> ";
		echo "<input class=\"submit\" style='' type=\"submit\" value=\"Изменить\" />";
		echo " <a href='/info.php?id=$ank[id]'>Отмена</a><br />";
		echo "</form>";
		include_once 'sys/inc/tfoot.php';
		exit;
	}
}
}
?>