<?php
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/adm_check.php';
include_once '../../sys/inc/user.php';
/* Бан пользователя */
if (dbresult(dbquery("SELECT COUNT(*) FROM `ban` WHERE `razdel` = 'notes' AND `id_user` = '$user[id]' AND (`time` > '$time' OR `view` = '0' OR `navsegda` = '1')"), 0) != 0) {
header('Location: /ban.php?' . SID);
exit;
}
$set['title'] = __('Новый блог');
include_once '../../sys/inc/thead.php';
title();
if (!isset($user)) {
header("location: index.php?");
}
if (isset($_POST['title']) && isset($_POST['msg'])) {
if (($user['rating'] < 2 || $user['group_access'] < 6)) {
if (!isset($_SESSION['captcha'])) {
$err[] = __('Ошибка проверочного числа');
}
if (!isset($_POST['chislo'])) {
$err[] = __('Введите проверочное число');
} elseif ($_POST['chislo'] == null) {
$err[] = __('Введите проверочное число');
} elseif ($_POST['chislo'] != $_SESSION['captcha']) {
$err[] = __('Проверьте правильность ввода проверочного числа');
}
}
if (!isset($err)) {
if (empty($_POST['title'])) {
$title = esc(stripslashes(htmlspecialchars(substr($_POST['msg'], 0, 24)))) . ' ...';
$title = my_esc($title);
} else {
$title = my_esc($_POST['title']);
}
$msg = my_esc($_POST['msg']);
$id_dir = intval($_POST['id_dir']);
if (isset($_POST['private'])) {
$privat = intval($_POST['private']);
} else {
$privat = 0;
}
if (isset($_POST['private_komm'])) {
$privat_komm = intval($_POST['private_komm']);
} else {
$privat_komm = 0;
}
$type = 0;
if (strlen2($title) > 100) {
$err = __('Название не может превышать больше 32 символов');
}
if (strlen2($msg) > 30000) {
$err = __('Содержание не может превышать больше 30000 символов');
}
if (strlen2($msg) < 2 && $type == 0) {
$err = __('Содержание слишком короткое');
}
if (!isset($err)) {
dbquery("INSERT INTO `notes` (`time`, `msg`, `name`, `id_user`, `private`, `private_komm`, `id_dir`, `type`) values('$time', '$msg', '$title', '{$user['id']}', '$privat', '$privat_komm', '$id_dir', '$type')");
$st = mysql_insert_id();
if ($privat != 2) {
dbquery("insert into `stena`(`id_stena`,`id_user`,`time`,`info`,`info_1`,`type`) values('" . $user['id'] . "','" . $user['id'] . "','" . $time . "','новый дневник','" . $st . "','note')");
}
/* Лента */
$q = dbquery("SELECT * FROM `frends` WHERE `user` = '" . $user['id'] . "' AND `i` = '1'");
while ($f = dbarray($q)) {
$a = get_user($f['frend']);
$lentaSet = dbarray(dbquery("SELECT * FROM `tape_set` WHERE `id_user` = '" . $a['id'] . "' LIMIT 1")); // Общая настройка ленты
if ($f['lenta_notes'] == 1 && $lentaSet['lenta_notes'] == 1) { // фильтр рассылки
dbquery("INSERT INTO `tape` (`id_user`,`avtor`, `type`, `time`, `id_file`) values('$a[id]', '$user[id]', 'notes', '$time', '$st')");
}
}
dbquery("OPTIMIZE TABLE `notes`");
$_SESSION['message'] = __('Блог успешно опубликован');
header("Location: list.php?id=$st");
$_SESSION['captcha'] = NULL;
exit;
}
}
}
if (isset($_GET['id_dir'])) {
$id_dir = intval($_GET['id_dir']);
} else {
$id_dir = 0;
}
err();
aut();
if (isset($_POST["msg"])) {
$msg = output_text($_POST["msg"]);
}
echo "<form method=\"post\" class='ui form segment' name=\"message\" action=\"add.php\">\n";
echo __('Название') . ":<br />\n<input name=\"title\" required value=\"\" type=\"text\" /><br />\n";
echo __('Сообщение') . ":<textarea name=\"msg\" required></textarea><br />\n";
echo __('Категория') . ":<br />\n<select name='id_dir'>\n";
$q = dbquery("SELECT * FROM `notes_dir` ORDER BY `id` DESC");
echo "<option value='0'" . ($id_dir == 0 ? " selected='selected'" : null) . "><b>" . __('Без категории') . "</b></option>\n";
while ($post = dbassoc($q)) {
echo "<option value='$post[id]'" . ($id_dir == $post['id'] ? " selected='selected'" : null) . ">" . text($post['name']) . "</option>\n";
}
echo "</select><br />\n";
?>
<div class='field'>
<label><?= __('Могут смотреть') ?>:</label>
<div class='ui radio checkbox'>
<input name='private' type='radio' value='0' selected='selected'/><label><?= __('Все') ?></label>
</div>
<br />
<div class='ui radio checkbox'>
<input name='private' type='radio' value='1' /><label><?= __('Друзья') ?> </label>
</div>
<br />
<div class='ui radio checkbox'>
<input name='private' type='radio' value='2' /><label><?= __('Только я') ?></label>
</div>
</div>
<div class='field'>
<label><?= __('Могут комментировать') ?>:</label>
<div class='ui radio checkbox'>
<input name='private_komm' type='radio' value='0' selected='selected'/>
<label><?= __('Все') ?> </label>
</div>
<br />
<div class='ui radio checkbox'>
<input name='private_komm' type='radio' value='1' />
<label><?= __('Друзья') ?> </label>
</div>
<br />
<div class='ui radio checkbox'>
<input name='private_komm' type='radio' value='2' />
<label><?= __('Только я') ?></label>
</div>
</div>
<?php
if ($user['rating'] < 6 || $user['group_access'] < 6) {
echo "<img src='/captcha.php?SESS=$sess' width='100' height='30' alt='Проверочное число' /><br />\n<input name='chislo' size='5' maxlength='5' value='' type='text' /><br/>\n";
}
echo "<br />";
echo "<button class='ui compact blue labeled icon button'><i class='mdi mdi-check icon'></i> " . __('Опубликовать') . "</button>\n";
echo "</form>\n";
echo "<div class='ui segment'>\n";
echo "<a href='index.php'><i class='mdi mdi-chevron-double-left'></i> " . __('Блоги') . "</a><br />\n";
echo "</div>\n";
include_once '../../sys/inc/tfoot.php';
?>