<?
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();
$set['title']="Написать в микроблог";
include_once '../sys/inc/thead.php';
title();
aut();
if(isset($_GET['ok']) && isset($_POST['text']) && $_POST['text']!=NULL)
{
$text=mysql_real_escape_string($_POST['text']);
$dostup=intval($_POST['dostup']);
if (strlen2($text)>1024)$err='Tекст микроблога превышает лимит в 1024 символов';
if (!isset($err))
{
$text=mysql_real_escape_string($_POST['text']);
if (isset($_POST['translit']) && $_POST['translit']==1)
{
$text=translit($text);
}
mysql_query("INSERT INTO `microblog` SET `uid` = '".$user['id']."', `time` ='".time()."', `text` ='$text'");
$mid=mysql_insert_id();
$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=$mid] микроблог [/url]";

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

msg('Mикроблог успешно сохранён');
echo "<img src='/img/microblog/back.png' alt='' /> <a href='microblog.php?id=$mid'>В микроблог</a><br />\n";
include_once '../sys/inc/tfoot.php';
exit();   
}
}
err();
echo "<div class='forma'><form method='post' action='?ok'>\n";
echo "- Текст микроблога: | <a href='/smiles/' title='Смайлы'>Смайлы</a><br />\n<input type=\"text\" name=\"text\" value=\"\" /><br />\n";
echo "<label><input type='checkbox' name='translit' value='1' /> Транслит</label><br />";
echo "<input value=\"Написать\" type=\"submit\" />\n";
echo "</div></form>\n";
echo"<div class='p_t'>\n";
echo "<img src='/img/microblog/back.png' alt='' /> <a href='all.php?id=$user[id]'>Назад</a><br />\n";
echo"</div>\n";
include_once '../sys/inc/tfoot.php';
?>