<?

if (!isset($user)) {
header("Location: index.php?".SID);
exit;
	}

if (isset($_GET[ok])) {

$name=esc(stripcslashes(htmlspecialchars($_POST['name'])));
if (isset($_POST['translit1']) && $_POST['translit1']==1)$name=translit($name);
if (strlen2($name)<3)$err='Статус должен быть длиннее';
if (strlen2($name)>512)$err='Перебор 512';
$name=mysql_real_escape_string($name);

if (!isset($err)) {

mysql_query("UPDATE `user` SET `balls` = '".($user['balls']+1)."' WHERE `id` = '$user[id]' LIMIT 1");

mysql_query("INSERT INTO `dnev` (`id_user`, `name`, `msg`, `read`, `write`, `time`) values('$user[id]', '$name', '$msg', '$_POST[read]', '$_POST[write]', '$time')");
$dnev[id]=mysql_insert_id();

if ($_POST[read]!=2) {
$q = mysql_query("SELECT * FROM `fanat` WHERE `user` = '$user[id]' AND `i` = '1'");
while ($f = mysql_fetch_array($q))
{
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[frend]' LIMIT 1"));

$msg_lenta="Добавил новый статус [url=/dnev/dnev.php?id=$dnev[id]&page=end] $name [/url]";

mysql_query("INSERT INTO `lenta` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$a[id]', '$msg_lenta', '$time')"); 
	}
	}
header("Location: index.php".SID);
exit;

	}
	}

err();
if ($ank[id]==$user[id]) {

echo "<form method='post' enctype='multipart/form-data'  action='?ok'>";
echo "<input name='name' type='text' maxlength='512' value='$_POST[name]' />\n";
echo "<input value='+' type='submit' />\n";
echo "</form>\n";
}

?>