<?
include '../config.php';
include '../func.php';
head();
aut();
ban();
////////////////////////////////////////
mysql_query("UPDATE `profile` SET `online` = 'blog' WHERE `id` = '".$id_session."'");

if ( $_GET['status'] == 'msg_empty' ) echo link1 . 'Не введена запись' . div;
if ( $_GET['status'] == 'topic_empty' ) echo link1 . 'Не введена тема' . div;
if ( $_GET['status'] == 'add_yes' ) echo link1 . 'Запись успешно добавлена' . div;
if ( $_GET['status'] == 'add_error' ) echo link1 . 'Возникла ошибка' . div;

echo head . "<b>Блоги</b>" . div . katalog;   

echo '<form action="add.php?mod=add" method="post" name="form">';

echo '<b>Тема:</b><br/>';
echo "<input name=\"topic\" maxlength=\"50\" title=\"infa\" emptyok=\"false\"/><br/ >";

echo 'Текст:<br/>';
echo '<textarea id="tarea" name="text" cols="30" rows="5" style="width: 99%;"></textarea><br/>';
echo '<input name="submit" type="submit" class="button" value="Написать" /></form><br/ >';
echo "<b><a href=\"../info.php?act=bb\">BB-Коды</a></b> <a href=\"../smiles.php?\">Смайлы</a><br/ >" ;
echo div;

if ( $_GET['mod'] == 'add' ) {

$topic = html($_POST['topic']);
$msg = html($_POST['text']);

if ( empty($topic) ) header("Location: add.php?blog=".$id."&status=topic_empty");
if ( empty($msg) ) header("Location: add.php?blog=".$id."&status=msg_empty");

$result = mysql_query("Insert into blogs set user ='".$id_session."', msg = '".$msg."', top = '".$topic."', date = '".time()."'");
$msg1 = '<b>'.user($id_session).'</b> написал <b><a href="blog/">блог</a></b>';
mysql_query("INSERT INTO `jurnal` SET  `msg` = '".$msg1."', `user` = '".$id_session."', `date` = '".time()."'");

if ( $result != NULL ) header("Location: add.php?blog=".$id."&status=add_yes");
else header("Location: add.php?blog=".$id."&status=add_error");
}





/////////////////////////////////////////

pod_navig();
foot();
?>