<?
require_once '../core/system.php';
echo admin();
$header = 'Создание Новости';
require_once H.'core/head.php';
if($user[prava] >= 5 ){
switch($act) {
case 'post':
if(isset($_POST['title']) && isset($_POST['title'])) {
$title = check($_POST['title']);
$msg = check($_POST['title']);
$time = time();
//$id_user = $user[id];
if(mb_strlen($title) < 1 or mb_strlen($name) > 255) $err =  'Длина названия должна быть в пределах 3 - 256 символов';
if(!isset($err)) {
mysql_query("INSERT INTO `news` SET `title` = '$title', `time` = '$time', `id_user` = '$user[id]'");
$now_news = mysql_fetch_assoc(mysql_query("SELECT * FROM `news` WHERE `time` = '$time'"));
mysql_query("INSERT INTO `time` SET `id_user` = '$user[id]', `msg` = '$msg', `time` = '$time', `id_news` = '$now_news[id]', `news_content` = '1'");
mysql_query("update `user` set `news_read` = '1'");
header('Location: /news/');
$_SESSION['message'] = 'Новость добавлена';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = $err;
// Вывод ошибки 
exit();
} 
}else{
header('Location: ?');
$_SESSION['err'] = 'Введите данные';
exit();
}
break;
default;
echo '<form class="player" method="post" action="?act=post">';
echo 'Описание: <br /><input class="text large" type="text" name="title" /><br />';
echo '<span class="btn"><span class="end"><input class="label" type="submit" value="Создать"></span></span>';
echo "</form>";
echo "<div class='mini-line'></div>";
echo "<div class='player menuList'>";
echo "<li><a href='$admin_tools_link'><img src='/images/icon/arrow.png'>$admin_tools_title_name</a></li>";
echo "</div>";
}
}
require_once H.'core/foot.php';
?>