Файл: modules/diary/diary_form.php
Строк: 792
<?php
/* Мод "Дневники"
* Версия v0.0.1
* Дата последнего редактирования 27.11.2014
* Двиг DCMS Special
* Модифицировал densnet
* Файл diary_form.php
* Описание: Дневник
*/
if (isset($_GET['download'])) {
ob_clean();
ob_implicit_flush();
header('Content-Type: text/plain; charset=utf-8', true);
header('Content-Disposition: attachment; filename="' . retranslit($diary['id']) . '.txt";');
echo "Автор записи: $avtor[nick](" . $Date->time($diary['time']) . ")rn";
echo trim(text::br($diary['text'], "rn")) . "rn";
echo "rnИсточник: http://$_SERVER[SERVER_NAME]".DIR_DIARY."?id=$ank[id]&diary=$diary[id]rn";
exit;
}
if ($user['ank_d_r'] != NULL && $user['ank_m_r'] != NULL && $user['ank_g_r'] != NULL) {
$user['ank_age'] = date("Y") - $user['ank_g_r'];
if (date("n") < $user['ank_m_r']) {
$user['ank_age'] = $user['ank_age'] - 1;
} elseif (date("n") == $user['ank_m_r'] && date("j") < $user['ank_d_r']) {
$user['ank_age'] = $user['ank_age'] - 1;
}
} else {
$user['ank_age'] = 0;
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_enter` WHERE `id_user` = '$user[id]' AND `id_diary` = '$diary[id]' AND `type` = '18' LIMIT 1"), 0) == 0 && !isset($_GET['passed']) && $user['ank_age'] < 18 && $diary['+18'] == 1) {
echo "<div class = 'errs'>";
echo "Внимание! Это содержимое только для взрослых!<br />Нажимая Продолжить, Вы подтверждаете, что Вам 18 или более лет.<br /><br />";
echo "<a class = 'add' href = '?id=$ank[id]&diary=$diary[id]&passed'>" . img('ok.png') . " Продолжить</a>";
echo "<a class = 'add' href = '?'>" . img('cancel.png') . " Отмена</a></div>n";
} else {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_enter` WHERE `id_user` = '$user[id]' AND `id_diary` = '$diary[id]' AND `type` = '18' LIMIT 1"), 0) == 0 && isset($_GET['passed']) && $diary['+18'] == 1) {
mysql_query("INSERT INTO `diary_enter` (`id_user`, `id_diary`, `type`) values ('$user[id]', '$diary[id]', '18')");
}
if (isset($_GET['otvet_komm'])) {
if (!isset($user)) {
echo "<div class = 'errs'>Данная функция доступна только для авторизованных пользователей. Пожалуйста, пройдите <a href = '/aut.php'>авторизацию</a> или <a href = '/reg.php'>регистрацию</a></div>";
require_once H.'sys/inc/tfoot.php';
exit;
}
$komm = mysql_fetch_array(mysql_query("SELECT * FROM `diary_komm` WHERE `id` = '" . mysql_real_escape_string($_GET['otvet_komm']) . "' AND `id_diary` = '$diary[id]' LIMIT 1"));
$komm_avtor = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '" . mysql_real_escape_string($komm['id_user']) . "' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm` WHERE `id` = '$komm[id]' AND `id_diary` = '$diary[id]' LIMIT 1"), 0) == 0) {
echo "<div class = 'errs'>Комментарий не найден</div>";
} else {
if (isset($user) && $diary['no_komm'] == 0) {
if (isset($_POST['msg_otvet'])) {
$msg = $_POST['msg_otvet'];
if ($Text->utf8_strlen($msg) > 10024) {
echo "<div class = 'errs'>Сообщение слишком длинное</div>";
}
if ($Text->utf8_strlen($msg) < 2) {
echo "<div class = 'errs'>Комментарий не найден</div>";
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm` WHERE `id_diary` = '$diary[id]' AND `id_user` = '$user[id]' AND `msg` = '" . mysql_real_escape_string($msg) . "' LIMIT 1"), 0) != 0) {
echo "<div class = 'errs'>Ваше сообщение повторяет предыдущее</div>";
}
if (!isset($err)) {
mysql_query("INSERT INTO `diary_komm` (`id_diary`, `id_user`, `time`, `msg`, `id_otvet`, `id_otvet_msg`) values('$diary[id]', '$user[id]', '$time', '" . mysql_real_escape_string($msg) . "', '$komm_avtor[id]', '$komm[id]')");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm_wrote` WHERE `id_user` = '$user[id]' AND `id_diary` = '$diary[id]' LIMIT 1"), 0) == 0 && isset($user)) {
mysql_query("INSERT INTO `diary_komm_wrote` (`id_user`, `id_diary`) values ('$user[id]', '$diary[id]')");
}
if ($user['id'] != $avtor['id']) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$avtor[id]', '$SexOtv Вам в Вашем [url=/modules/diary/?id=$ank[id]&diary=$diary[id]]дневнике[/url]', '$time')");
}
$q = mysql_query("SELECT * FROM `diary_komm_wrote` WHERE `id_diary` = '$diary[id]'");
while ($f = mysql_fetch_array($q)) {
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[id_user]' LIMIT 1"));
if ($a['id'] != $user['id'] && $a['id'] != $avtor['id']) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$a[id]', '$SexOtv Вам в [url=/modules/diary/?id=$ank[id]&diary=$diary[id]]этом[/url] дневнике', '$time')");
}
}
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
}
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '".DIR_DIARY."'>Дневники</a> > <a href = '".DIR_DIARY."?id=$avtor[id]&diary=$diary[id]'>" . $Text->toOutput($diary['name']) . "</a> > <a href = '?'><b>Ответить</b></a></div>";
echo "<div style = 'font-size: 18px;font-weight: bold;' class = 'razdel'>" . img('other.png') . " Ответ</div>";
echo "<div class = 'razd'>$komm_avtor[nick] $SexNap:<br />" . htmlspecialchars($komm['msg']) . "</div>";
echo "<form method = 'post' class = 'razd' name = 'msg_otvet' action = '?id=$ank[id]&diary=$diary[id]&otvet_komm=$komm[id]' >";
echo "<b>Сообщение (10024 знаков)</b><br />";
echo text::auto_bb('msg_otvet', 'msg_otvet');
echo L . "<textarea aria-required = 'true' aria-invalid = 'false' required = 'required' name = 'msg_otvet'></textarea><br />";
echo "<button class = 'active'>";
echo "<span class = 'label'><span class = 'icon icon44' /> Ответить</span>";
echo "</button></form>";
} elseif ($diary['no_komm'] == '1' && ($user['id'] == $avtor['id'] || $user['level'] > 0)) {
if (isset($_POST['msg_otvet'])) {
$msg = $_POST['msg_otvet'];
if ($Text->utf8_strlen($msg) > 10024) {
$err[] = 'Сообщение слишком длинное';
}
if ($Text->utf8_strlen($msg) < 2) {
$err[] = 'Короткое сообщение';
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm` WHERE `id_diary` = '$diary[id]' AND `id_user` = '$user[id]' AND `msg` = '" . mysql_real_escape_string($msg) . "' LIMIT 1"), 0) != 0) {
$err[] = 'Ваше сообщение повторяет предыдущее';
}
if (!isset($err)) {
mysql_query("INSERT INTO `diary_komm` (`id_diary`, `id_user`, `time`, `msg`, `id_otvet`, `id_otvet_msg`) values('$diary[id]', '$user[id]', '$time', '" . mysql_real_escape_string($msg) . "', '$komm_avtor[id]', '$komm[id]')");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm_wrote` WHERE `id_user` = '$user[id]' AND `id_diary` = '$diary[id]' LIMIT 1"), 0) == 0 && isset($user)) {
mysql_query("INSERT INTO `diary_komm_wrote` (`id_user`, `id_diary`) values ('$user[id]', '$diary[id]')");
}
if ($user['id'] != $avtor['id']) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$avtor[id]', '$SexOtv Вам в Вашем [url=/modules/diary/?id=$ank[id]&diary=$diary[id]]дневнике[/url]', '$time')");
}
$q = mysql_query("SELECT * FROM `diary_komm_wrote` WHERE `id_diary` = '$diary[id]'");
while ($f = mysql_fetch_array($q)) {
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[id_user]' LIMIT 1"));
if ($a['id'] != $user['id'] && $a['id'] != $avtor['id']) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$f[id_user]', '$SexOtv Вам в [url=/modules/diary/?id=$ank[id]&diary=$diary[id]]этом[/url] дневнике', '$time')");
}
}
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
}
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '".DIR_DIARY."'>Дневники</a> > <a href = '".DIR_DIARY."?id=$avtor[id]&diary=$diary[id]'>" . $Text->toOutput($diary['name']) . "</a> > <a href = '?'><b>Ответить</b></a></div>";
echo "<div style = 'font-size: 18px;font-weight: bold;' class = 'razdel'>" . img('other.png') . " Ответ</div>";
echo "<div class = 'razd'>$komm_avtor[nick] $SexNap<br /> " . filter_var(htmlspecialchars($komm['msg'], FILTER_SANITIZE_SPECIAL_CHARS)) . "</div>";
echo "<form method = 'post' class = 'razd' name = 'msg_otvet' action = '?id=$ank[id]&diary=$diary[id]&otvet_komm=$komm[id]' >";
echo "<b>Сообщение (10024 знаков)</b><br />";
echo text::auto_bb('msg_otvet', 'msg_otvet');
echo L . "<textarea name = 'msg_otvet'></textarea><br />";
echo "<button class = 'active'>";
echo "<span class = 'label'><span class = 'icon icon44' /> Ответить</span>";
echo "</button></form>";
} else {
echo "<div class = 'errs'>Автор запретил оставлять комментарии</div>";
}
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]'>Вернуться</a></div>";
}
require_once H.'sys/inc/tfoot.php';
exit;
} elseif (isset($_GET['edit_komm'])) {
$komm = mysql_fetch_array(mysql_query("SELECT * FROM `diary_komm` WHERE `id` = '" . intval($_GET['edit_komm']) . "' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm` WHERE `id` = '$komm[id]' LIMIT 1"), 0) != 0) {
if ($user['id'] == $komm['id_user'] && $komm['time'] > time() - 600 && $diary['no_komm'] == 0 || $user['level'] >= 8) {
if (isset($_GET['ok'])) {
$msg_edit = mysql_real_escape_string($_POST['msg_edit']);
if ($Text->utf8_strlen($msg_edit) < 1) {
$err[] = 'Введите coбщение';
}
if ($Text->utf8_strlen($msg_edit) > 10024) {
$err[] = 'Сообщение слишком длинное';
}
if (!isset($err)) {
mysql_query("UPDATE `diary_komm` SET `msg` = '$msg_edit' WHERE `id` = '$komm[id]' LIMIT 1");
$qwe = mysql_error();
if ($qwe) {
mysql_query("INSERT INTO `diary_komm` (`id_diary`, `id_user`, `time`, `msg`) values('$diary[id]', '$user[id]', '$time', '" . mysql_real_escape_string($qwe) . "')");
}
header("Location: ?id=$ank[id]&diary=$diary[id]");
exit();
}
}
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '".DIR_DIARY."'>Дневники</a> > <a href = '".DIR_DIARY."?id=$avtor[id]&diary=$diary[id]'>" . $Text->toOutput($diary['name']) . "</a> > <a href = '?'><b>Редактирование комментария</b></a></div>";
echo "<div style = 'font-size: 18px;font-weight: bold;' class = 'razdel'>" . img('other.png') . " Редактирование</div>";
echo "<form method = 'post' class = 'razd' name = 'komm_set' action = '?id=$ank[id]&diary=$diary[id]&edit_komm&ok=$komm[id]'>";
echo "<b>Сообщение (10024 знаков)</b><br />";
echo text::auto_bb('komm_set', 'msg_edit');
echo L . "<textarea name = 'msg_edit'>$komm[msg]</textarea><br />";
echo "<button class = 'active'>";
echo "<span class = 'label'><span class = 'icon icon67' /> Сохранить</span>";
echo "</button></form>";
} else {
echo "<div class = 'errs'>У вас нет прав для данного действия!</div>";
}
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]'>Вернуться</a></div>";
} else {
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
} elseif (isset($_GET['cmpl_komm']) && isset($user)) {
$cmpl = intval($_GET['cmpl_komm']);
$cmpl = mysql_fetch_array(mysql_query("SELECT * FROM `diary_komm` WHERE `id` = $cmpl LIMIT 1"));
if (isset($_GET['ok'])) {
$msg_cmpl = $_POST['msg_cmpl'];
if ($Text->utf8_strlen($msg_cmpl) < 1) {
$err[] = 'Введите сообщение';
}
if ($Text->utf8_strlen($msg_cmpl) > 10024) {
$err[] = 'Сообщение слишком длинное';
}
$msg_cmpl = mysql_real_escape_string($msg_cmpl);
if (!isset($err)) {
mysql_query("INSERT INTO `diary_cmpl` (`type`, `id_subject`, `msg`, `time`, `ok`, `id_user`, `subject`) values ('$type', '$cmpl[id]', '$msg_cmpl', '$time', '0', '$user[id]', 'komm')");
header("location: ?id=$ank[id]&diary=$diary[id]");
}
}
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '".DIR_DIARY."'>Дневники</a> > <a href = '".DIR_DIARY."?id=$avtor[id]&diary=$diary[id]'>" . $Text->toOutput($diary['name']) . "</a> > <a href = '?'><b>Жалоба</b></a></div>";
echo "<div id = 'hide' class = 'razdel'>Новая жалоба <a style = 'float:right;color: grey;' href = '?id=$ank[id]&diary=$diary[id]'>" . img('cancel.png') . " <small>Закрыть</small></a></div>";
echo "<form method = 'post' name = 'cmpl_komm' class = 'razd' action = '?id=$ank[id]&diary=$diary[id]&cmpl_komm=$cmpl[id]&ok'>";
echo "<b>Жалоба на</b><br /><font color = 'red'>" . $Text->toOutput($cmpl['msg']) . "</font><br />";
echo "<b>Причина жалобы</b><br />";
echo "<input type = 'radio' name = 'reason' value = 'reklama' /> Это реклама!<br />";
echo "<input type = 'radio' name = 'reason' value = 'leks' /> Нецензурная лексика<br />";
echo "<input type = 'radio' name = 'reason' value = 'oskorb' /> Оскорбления<br />";
echo "<input type = 'radio' name = 'reason' value = 'prop' /> Пропаганда ненависти<br />";
echo "<input type = 'radio' name = 'reason' value = 'bessmsl' /> Бессмысленная тема<br />";
echo "<input type = 'radio' name = 'reason' value = 'other' /> Иное<br />";
echo "<b>Сообщение</b><br />";
echo text::auto_bb('cmpl_komm', 'msg_cmpl');
echo L . "<textarea name = 'msg_cmpl'></textarea><br />";
echo "<button class = 'active'>";
echo "<span class = 'label'><span class = 'icon icon44' /> Отправить</span>";
echo "</button></form>";
} elseif (isset($_GET['cmpl_diary']) && isset($user)) {
if (isset($_GET['ok'])) {
$type = $_POST['reason'];
$msg_cmpl = $_POST['msg_cmpl'];
if ($Text->utf8_strlen($msg_cmpl) < 1) {
$err[] = 'Введите сообщение';
}
if ($Text->utf8_strlen($msg_cmpl) > 10024) {
$err[] = 'Сообщение слишком длинное';
}
$msg_cmpl = mysql_real_escape_string($msg_cmpl);
if (!isset($err)) {
mysql_query("INSERT INTO `diary_cmpl` (`type`, `id_subject`, `msg`, `time`, `ok`, `id_user`, `subject`) values ('" . mysql_real_escape_string($type) . "', '$diary[id]', '$msg_cmpl', '$time', '0', '$user[id]', 'diary')");
header("location: ?id=$ank[id]&diary=$diary[id]");
}
}
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '".DIR_DIARY."'>Дневники</a> > <a href = '".DIR_DIARY."?id=$avtor[id]&diary=$diary[id]'>" . $Text->toOutput($diary['name']) . "</a> > <a href = '?'><b>Жалоба</b></a></div>";
echo "<div id = 'hide' class = 'razdel'>Новая жалоба <a style = 'float:right;color: grey;' href = '?id=$ank[id]&diary=$diary[id]'>" . img('cancel.png') . " <small>Закрыть</small></a></div>";
echo "<form method = 'post' name = 'cmpl_diary' class = 'razd' action = '?id=$ank[id]&diary=$diary[id]&cmpl_diary&ok'>";
echo "<b>Жалоба на</b><br /><font color = 'red'>" . $Text->toOutput($diary['text']) . "</font><br />";
echo "<b>Причина жалобы</b><br/>";
echo "<input type = 'radio' name = 'reason' value = 'reklama' /> Это реклама!<br/>";
echo "<input type = 'radio' name = 'reason' value = 'leks' /> Нецензурная лексика<br/>";
echo "<input type = 'radio' name = 'reason' value = 'oskorb' /> Оскорбления<br/>";
echo "<input type = 'radio' name = 'reason' value = 'prop' /> Пропаганда ненависти<br/>";
echo "<input type = 'radio' name = 'reason' value = 'bessmsl' /> Бессмысленная тема<br/>";
echo "<input type = 'radio' name = 'reason' value = 'other' /> Иное<br/>";
echo "<b>Сообщение</b><br />";
echo text::auto_bb('cmpl_diary', 'msg_cmpl');
echo L . "<textarea name = 'msg_cmpl'></textarea><br />";
echo "<button class = 'active'>";
echo "<span class = 'label'><span class = 'icon icon44' /> Отправить</span>";
echo "</button></form>";
} elseif (isset($_GET['poll'])) {
if ($diary['id_user'] == $user['id'] || $user['level'] >= 8) {
if ($diary['poll'] == '0') {
if (isset($_GET['ok'])) {
$poll_text = $_POST['poll_text'];
$result1 = $_POST['result1'];
if ($Text->utf8_strlen($result1) < 1) {
$err[] = '1 вариант обязателен для заполнения';
}
$result1 = mysql_real_escape_string($result1);
$result2 = $_POST['result2'];
if ($Text->utf8_strlen($result2) < 1) {
$err[] = '2 вариант обязателен для заполнения';
}
$result2 = mysql_real_escape_string($result2);
$result3 = $_POST['result3'];
$result3 = mysql_real_escape_string($result3);
$result4 = $_POST['result4'];
$result4 = mysql_real_escape_string($result4);
$result5 = $_POST['result5'];
$result5 = mysql_real_escape_string($result5);
$result6 = $_POST['result6'];
$result6 = mysql_real_escape_string($result6);
$result7 = $_POST['result7'];
$result7 = mysql_real_escape_string($result7);
$result8 = $_POST['result8'];
$result8 = mysql_real_escape_string($result8);
$result9 = $_POST['result9'];
$result9 = mysql_real_escape_string($result9);
$result10 = $_POST['result10'];
$result10 = mysql_real_escape_string($result10);
if ($Text->utf8_strlen($poll_text) < 1) {
$err[] = 'Введите текст';
}
if ($Text->utf8_strlen($pool_text) > 1024) {
$err[] = 'Текст слишком длинный';
}
$poll_text = mysql_real_escape_string($poll_text);
$poll_time = $time + $_POST['poll_time'];
$poll_timee = $_POST['poll_time'];
if (!isset($err)) {
mysql_query("UPDATE `diary` SET `poll` = '1', `poll_text` = '$poll_text', `poll_time` = '" . mysql_real_escape_string($poll_time) . "', `poll_timee` = '" . mysql_real_escape_string($poll_time) . "e' WHERE `id` = '$diary[id]'");
mysql_query("INSERT INTO `diary_poll` (`id_diary`, `var`, `num`) VALUES ('$diary[id]', '$result1', '1')");
mysql_query("INSERT INTO `diary_poll` (`id_diary`, `var`, `num`) VALUES ('$diary[id]', '$result2', '2')");
mysql_query("INSERT INTO `diary_poll` (`id_diary`, `var`, `num`) VALUES ('$diary[id]', '$result3', '3')");
mysql_query("INSERT INTO `diary_poll` (`id_diary`, `var`, `num`) VALUES ('$diary[id]', '$result4', '4')");
mysql_query("INSERT INTO `diary_poll` (`id_diary`, `var`, `num`) VALUES ('$diary[id]', '$result5', '5')");
mysql_query("INSERT INTO `diary_poll` (`id_diary`, `var`, `num`) VALUES ('$diary[id]', '$result6', '6')");
mysql_query("INSERT INTO `diary_poll` (`id_diary`, `var`, `num`) VALUES ('$diary[id]', '$result7', '7')");
mysql_query("INSERT INTO `diary_poll` (`id_diary`, `var`, `num`) VALUES ('$diary[id]', '$result8', '8')");
mysql_query("INSERT INTO `diary_poll` (`id_diary`, `var`, `num`) VALUES ('$diary[id]', '$result9', '9')");
mysql_query("INSERT INTO `diary_poll` (`id_diary`, `var`, `num`) VALUES ('$diary[id]', '$result10', '10')");
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
}
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '".DIR_DIARY."'>Дневники</a> > <a href = '".DIR_DIARY."?id=$avtor[id]&diary=$diary[id]'>" . $Text->toOutput($diary['name']) . "</a> > <a href = '?'><b>Создание опроса</b></a></div>";
echo "<div style = 'font-size: 18px;font-weight: bold;' class = 'razdel'>" . img('opros.png') . " Создание опроса</div>";
echo "<form class = 'razd' action = '?id=$ank[id]&diary=$diary[id]&poll=" . md5($diary['id']) . "&ok' method = 'post'>";
echo "<b>Опрос</b><br />";
echo "<textarea name = 'poll_text'></textarea><br />";
echo "<b>Варианты ответов</b><br />";
echo "<input type = 'text' name = 'result1' value = '' />*<br />n";
echo "<input type = 'text' name = 'result2' value = '' />*<br />n";
echo "<input type = 'text' name = 'result3' value = '' /><br />n";
echo "<input type = 'text' name = 'result4' value = '' /><br />n";
echo "<input type = 'text' name = 'result5' value = '' /><br />n";
echo "<input type = 'text' name = 'result6' value = '' /><br />n";
echo "<input type = 'text' name = 'result7' value = '' /><br />n";
echo "<input type = 'text' name = 'result8' value = '' /><br />n";
echo "<input type = 'text' name = 'result9' value = '' /><br />n";
echo "<input type = 'text' name = 'result10' value = '' /><br />n";
echo "Дата окончания через: <br />";
echo "<select name = 'poll_time'>n";
echo "<option value = '145152000' selected = 'selected'>Бессрочное</option>"
. "<option value = '86400'>1 День</option>"
. "<option value = '259200'>3 Дня</option>"
. "<option value = '604800'>1 Неделю</option>"
. "<option value = '2419200'>1 Месяц</option>"
. "<option value = '2419200'>3 Месяца</option>"
. "</select><br />";
echo "<button class = 'active' name = 'save'>";
echo "<span class = 'label'><span class = 'icon icon67' /> Сохранить</span>";
echo "</button></form>";
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]'>Вернуться</a></div>";
} elseif ($diary['poll'] == '1') {
if (isset($_POST['save'])) {
$result1 = $_POST['result1'];
if ($Text->utf8_strlen($result1) < 1) {
$err[] = '1 вариант обязателен для заполнения';
}
$result1 = mysql_real_escape_string($result1);
$result2 = $_POST['result2'];
if ($Text->utf8_strlen($result2) < 1) {
$err[] = '2 вариант обязателен для заполнения';
}
$result2 = mysql_real_escape_string($result2);
$result3 = $_POST['result3'];
$result3 = mysql_real_escape_string($result3);
$result4 = $_POST['result4'];
$result4 = mysql_real_escape_string($result4);
$result5 = $_POST['result5'];
$result5 = mysql_real_escape_string($result5);
$result6 = $_POST['result6'];
$result6 = mysql_real_escape_string($result6);
$result7 = $_POST['result7'];
$result7 = mysql_real_escape_string($result7);
$result8 = $_POST['result8'];
$result8 = mysql_real_escape_string($result8);
$result9 = $_POST['result9'];
$result9 = mysql_real_escape_string($result9);
$result10 = $_POST['result10'];
$result10 = mysql_real_escape_string($result10);
$poll_text = $_POST['poll_text'];
if ($Text->utf8_strlen($poll_text) < 1) {
$err[] = 'Введите текст';
}
if ($Text->utf8_strlen($poll_text) > 1024) {
$err[] = 'Текст слишком длинный';
}
$poll_text = mysql_real_escape_string($poll_text);
if (!isset($err)) {
mysql_query("UPDATE `diary` SET `poll_text` = '$poll_text' WHERE `id` = '$diary[id]' LIMIT 1");
mysql_query("UPDATE `diary_poll` SET `var` = '$result1' WHERE `id_diary` = '$diary[id]' and `num` = '1' LIMIT 1");
mysql_query("UPDATE `diary_poll` SET `var` = '$result2' WHERE `id_diary` = '$diary[id]' and `num` = '2' LIMIT 1");
mysql_query("UPDATE `diary_poll` SET `var` = '$result3' WHERE `id_diary` = '$diary[id]' and `num` = '3' LIMIT 1");
mysql_query("UPDATE `diary_poll` SET `var` = '$result4' WHERE `id_diary` = '$diary[id]' and `num` = '4' LIMIT 1");
mysql_query("UPDATE `diary_poll` SET `var` = '$result5' WHERE `id_diary` = '$diary[id]' and `num` = '5' LIMIT 1");
mysql_query("UPDATE `diary_poll` SET `var` = '$result6' WHERE `id_diary` = '$diary[id]' and `num` = '6' LIMIT 1");
mysql_query("UPDATE `diary_poll` SET `var` = '$result7' WHERE `id_diary` = '$diary[id]' and `num` = '7' LIMIT 1");
mysql_query("UPDATE `diary_poll` SET `var` = '$result8' WHERE `id_diary` = '$diary[id]' and `num` = '8' LIMIT 1");
mysql_query("UPDATE `diary_poll` SET `var` = '$result9' WHERE `id_diary` = '$diary[id]' and `num` = '9' LIMIT 1");
mysql_query("UPDATE `diary_poll` SET `var` = '$result10' WHERE `id_diary` = '$diary[id]' and `num` = '10' LIMIT 1");
if ($_POST['wipe'] == '1') {
mysql_query("DELETE FROM `diary_pollen` WHERE `id_diary` = '$diary[id]'");
}
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
} elseif (isset($_POST['delete'])) {
if ($diary['poll'] == '1') {
mysql_query("DELETE FROM `diary_poll` WHERE `id_diary` = '$diary[id]'");
mysql_query("DELETE FROM `diary_pollen` WHERE `id_diary` = '$diary[id]'");
mysql_query("UPDATE `diary` SET `poll` = '0' WHERE `id` = '$diary[id]'");
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
}
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '".DIR_DIARY."'>Дневники</a> > <a href = '".DIR_DIARY."?id=$avtor[id]&diary=$diary[id]'>" . $Text->toOutput($diary['name']) . "</a> > <a href = '?'><b>Редактирование опроса</b></a></div>";
echo "<div style = 'font-size: 18px;font-weight: bold;' class = 'razdel'>" . img('opros.png') . " Редактирование опроса</div>";
echo "<form class = 'razd' action='?id=$ank[id]&diary=$diary[id]&poll=" . md5($diary['id']) . "' method = 'post'>";
echo "<b>Опрос</b><br />";
echo "<textarea name = 'poll_text'>$diary[poll_text]</textarea><br />";
echo "<b>Варианты ответов</b><br />";
$result1 = mysql_fetch_array(mysql_query("SELECT * FROM `diary_poll` WHERE `id_diary` = '$diary[id]' AND `num` = '1' LIMIT 1"));
echo "<input type = 'text' name = 'result1' value = '$result1[var]' />*<br />n";
$result2 = mysql_fetch_array(mysql_query("SELECT * FROM `diary_poll` WHERE `id_diary` = '$diary[id]' AND `num` = '2' LIMIT 1"));
echo "<input type = 'text' name = 'result2' value = '$result2[var]' />*<br />n";
$result3 = mysql_fetch_array(mysql_query("SELECT * FROM `diary_poll` WHERE `id_diary` = '$diary[id]' and `num` = '3' LIMIT 1"));
echo "<input type = 'text' name = 'result3' value = '$result3[var]' /><br />n";
$result4 = mysql_fetch_array(mysql_query("SELECT * FROM `diary_poll` WHERE `id_diary` = '$diary[id]' and `num` = '4' LIMIT 1"));
echo "<input type = 'text' name = 'result4' value = '$result4[var]' /><br />n";
$result5 = mysql_fetch_array(mysql_query("SELECT * FROM `diary_poll` WHERE `id_diary` = '$diary[id]' and `num` = '5' LIMIT 1"));
echo "<input type = 'text' name = 'result5' value = '$result5[var]' /><br />n";
$result6 = mysql_fetch_array(mysql_query("SELECT * FROM `diary_poll` WHERE `id_diary` = '$diary[id]' and `num` = '6' LIMIT 1"));
echo "<input type = 'text' name = 'result6' value = '$result6[var]' /><br />n";
$result7 = mysql_fetch_array(mysql_query("SELECT * FROM `diary_poll` WHERE `id_diary` = '$diary[id]' and `num` = '7' LIMIT 1"));
echo "<input type = 'text' name = 'result7' value = '$result7[var]' /><br />n";
$result8 = mysql_fetch_array(mysql_query("SELECT * FROM `diary_poll` WHERE `id_diary` = '$diary[id]' and `num` = '8' LIMIT 1"));
echo "<input type = 'text' name = 'result8' value = '$result8[var]' /><br />n";
$result9 = mysql_fetch_array(mysql_query("SELECT * FROM `diary_poll` WHERE `id_diary` = '$diary[id]' and `num` = '9' LIMIT 1"));
echo "<input type = 'text' name = 'result9' value = '$result9[var]' /><br />n";
$result10 = mysql_fetch_array(mysql_query("SELECT * FROM `diary_poll` WHERE `id_diary` = '$diary[id]' and `num` = '10' LIMIT 1"));
echo "<input type = 'text' name = 'result10' value = '$result10[var]' /><br />n";
echo "<input id = 'wipe' type = 'checkbox' name = 'wipe' value = '1' />";
echo "<label for = 'wipe'>Сбросить результаты голосования: </label><br />";
echo "<button class = 'active' name = 'save'>";
echo "<span class = 'label'><span class = 'icon icon67' /> Сохранить</span>";
echo "</button>";
echo "<button class = 'active' name = 'delete'>";
echo "<span class = 'label'><span class = 'icon icon58' /> Удалить</span>";
echo "</button></form>";
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]'>Вернуться</a></div>";
}
} else {
echo "<div class = 'errs'>Это не ваш дневник!</div>";
}
} elseif (isset($_GET['golos']) && isset($user)) {
$golos = $_GET['golos'];
$golos = mysql_fetch_array(mysql_query("SELECT * FROM `diary_poll` WHERE `id` = '$golos' AND `id_diary` = '$diary[id]' LIMIT 1"));
if ($golos['var'] == NULL) {
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
$prov_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary` WHERE `id` = '" . intval($_GET['diary']) . "' AND `poll` = '1' AND `id_user` = '$ank[id]' ", $db), 0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_poll` WHERE `id` = '$golos[id]' AND `id_diary` = '$diary[id]' LIMIT 1"), 0) == 0) {
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
if ($time > $diary['poll_time']) {
echo "<div class = 'errs'>Опрос уже закрыт!</div>";
} elseif ($prov_p == 0) {
echo "<div class = 'errs'>К данному дневнику опрос не прикреплён!</div>";
} else {
if (isset($_POST['ok'])) {
$prov = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_pollen` WHERE `id_diary` = '" . intval($_GET['diary']) . "' AND `id_user` = '$user[id]' ", $db), 0);
if ($prov != 0) {
echo "<div class = 'errs'>Вы уже принимали участие в данном опросе!</div>";
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]'>Вернуться</a></div>";
} elseif (!isset($err)) {
mysql_query("INSERT INTO `diary_pollen` (id_user, id_var, id_diary, time) values('$user[id]', '$golos[id]', '$diary[id]', '$time')");
msg('Ваш голос успешно принят');
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]'>Вернуться</a></div>";
}
} else {
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '".DIR_DIARY."'>Дневники</a> > <a href = '".DIR_DIARY."?id=$avtor[id]&diary=$diary[id]'>" . $Text->toOutput($diary['name']) . "</a> > <a href = '?'><b>Голосование</b></a></div>";
echo "<div style = 'font-size: 18px;font-weight: bold;' class = 'razdel'>" . img('opros.png') . " Подтверждение голоса</div>";
echo "<form method = 'post' class = 'razd' action='?id=$ank[id]&diary=$diary[id]&golos=$golos[id]'>";
echo "Вы действительно хотите проголосовать за даный вариант?<br />";
echo "<button class = 'active' name = 'ok'>";
echo "<span class = 'label'><span class = 'icon icon44' /> Да</span>";
echo "</button></form>";
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]'>Вернуться</a></div>";
}
}
} elseif (isset($_GET['who_oprosen']) && $diary['poll'] == 1) {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_pollen` WHERE `id_diary` = '$diary[id]'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$q = mysql_query("SELECT * FROM `diary_pollen` WHERE `id_diary` = '$diary[id]' ORDER BY `id` ASC LIMIT $start, $set[p_str]");
if (mysql_num_rows($q) == 0) {
echo "<div class = 'errs'>";
echo img('error.png') . " Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
echo "<table class = 'razd'><tr><td class = 'icon14'>";
$ank2 = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
avatar($ank2['id'], '48');
echo "</td><td class = 'null'>";
user($ank2['id']);
echo "<br />" . img('clock.png') . " " . $Date->time($post['time']);
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("?id=$ank[id]&diary=$diary[id]&who_oprosen&", $k_page, $page);
}
if (isset($_GET['back']) && $user['level'] > 0) {
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&info=$diary[id_user]'>Вернуться</a></div>";
} else {
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]'>Вернуться</a></div>";
}
} elseif (isset($_GET['visits']) && $user['level'] >= 8) {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_visited` WHERE `id_diary` = '$diary[id]'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$q = mysql_query("SELECT * FROM `diary_visited` WHERE `id_diary` = '$diary[id]' ORDER BY `id` ASC LIMIT $start, $set[p_str]");
if (mysql_num_rows($q) == 0) {
echo "<div class = 'errs'>";
echo img('error.png') . " Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
$ank2 = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
echo "<table class = 'razd'><tr><td class = 'icon14'>";
avatar($ank2['id'], '48');
echo "</td><td class = 'null'>";
user($ank2['id']);
echo "<br />" . img('clock.png') . " " . $Date->time($post['time']);
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("?id=$ank[id]&diary=$diary[id]&visits&", $k_page, $page);
}
if (isset($_GET['back']) && $user['level'] > 0) {
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&info=$diary[id_user]'>Вернуться</a></div>";
} else {
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]'>Вернуться</a></div>";
}
} elseif (isset($_GET['user_bm'])) {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_bookmarks` WHERE `id_diary` = '$diary[id]'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$q = mysql_query("SELECT * FROM `diary_bookmarks` WHERE `id_diary` = '$diary[id]' ORDER BY `time` ASC LIMIT $start, $set[p_str]");
if (mysql_num_rows($q) == 0) {
echo "<div class = 'errs'>";
echo img('error.png') . " Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
$ank2 = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
echo "<table class = 'razd'><tr><td class = 'icon14'>";
avatar($ank2['id'], '48');
echo "</td><td class = 'null'>";
user($ank2['id']);
echo "<br />" . img('clock.png') . " " . $Date->time($post['time']);
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("?id=$ank[id]&diary=$diary[id]&user_bm&", $k_page, $page);
}
if (isset($_GET['back']) && $user['level'] > 0) {
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&info=$diary[id_user]'>Вернуться</a></div>";
} else {
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]'>Вернуться</a></div>";
}
} elseif (isset($_GET['cmpl']) && $user['level'] > 0) {
if (isset($_GET['msg'])) {
$msg_id = intval($_GET['msg']);
$msg = mysql_fetch_array(mysql_query("SELECT * FROM `diary_cmpl` WHERE `id` = '$msg_id' AND `subject` = 'diary' AND `id_subject` = '$diary[id]' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_cmpl` WHERE `id` = '$msg[id]' AND `subject` = 'diary' AND `id_subject` = '$diary[id]' LIMIT 1"), 0) == 0) {
echo "<div class = 'errs'>Сообщение не найдено!</div>";
} elseif ($Text->utf8_strlen($msg['msg']) < 0) {
echo "<div class = 'errs'>Сообщение не найдено!</div>";
} else {
echo "<div class = 'razd'>";
echo $Text->toOutput($msg['msg']);
echo "</div>";
}
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]&cmpl'>Вернуться</a></div>";
} else {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_cmpl` WHERE `subject` = 'diary' AND `id_subject` = '$diary[id]'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$cmpl_list = mysql_query("SELECT * FROM `diary_cmpl` WHERE `subject` = 'diary' AND `id_subject` = '$diary[id]' ORDER BY time LIMIT $start, $set[p_str]");
if (mysql_num_rows($cmpl_list) == 0) {
echo "<div class = 'errs'>";
echo img('error.png') . " Нет результатов";
echo "</div>";
}
if (isset($_GET['ok'])) {
mysql_query("UPDATE `diary_cmpl` SET `ok` = '1', `id_resh` = '$user[id]' WHERE `id` = '" . intval($_GET['ok']) . "' AND `ok` = '0' AND `subject` = 'diary' AND `id_subject` = '$diary[id]'");
header("Location: ?id=$ank[id]&diary=$diary[id]&cmpl");
}
while ($post = mysql_fetch_array($cmpl_list)) {
echo "<table class = 'razd'><tr><td class = 'null'>";
$avtor_cmpl = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_user]' LIMIT 1"));
$user_ok = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_resh]' LIMIT 1"));
echo user($avtor['id']);
echo "<br />Писать жалобы: ";
if ($avtor['do_cmpl_diary'] == 0) {
echo "<font color = 'green'>Разрешено</font>";
echo " [<a href='?cmpl&do_cmpl=$avtor[id]'>запретить</a>]<br />";
} else {
echo "<font color = 'red'>Запрещено</font>";
echo " [<a href='?cmpl&do_cmpl=$avtor[id]'>разрешить</a>]<br/>n";
}
echo "Время: " . $Date->time($post['time']) . "<br />";
echo "Причина жалобы:n";
if ($post['type'] == 'reklama') {
echo "Это реклама!n";
} elseif ($post['type'] == 'leks') {
echo "Нецензурная лексикаn";
} elseif ($post['type'] == 'oskorb') {
echo "Оскорблениen";
} elseif ($post['type'] == 'prop') {
echo "Пропаганда ненавистиn";
} elseif ($post['type'] == 'bessmsl') {
echo "Бессмысленная темаn";
} else {
echo "Иноеn";
}
if ($Text->utf8_strlen($post['msg']) > 0) {
echo " | <b><a class = 'add' href = '?id=$ank[id]&diary=$diary[id]&cmpl&msg=$post[id]'>" . img('sms.png') . " Сообщение</a></b><br />";
} else {
echo "<br />";
}
if ($post['ok'] == 1) {
echo "<font color = 'green'>Даную жалобу рассмотрел <a href = '/info.php?id=$user_ok[id]'>$user_ok[nick]</a></font><br />";
} else {
echo "<font color = 'red'>Жалоба не рассмотренна</font> <a href = '?id=$ank[id]&diary=$diary[id]&cmpl&ok=$post[id]' style = 'color:green'>[OK]</a>";
}
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("?id=$ank[id]&diary=$diary[id]&cmpl&", $k_page, $page);
}
if (isset($_GET['back'])) {
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&info=$diary[id_user]'>Вернуться</a></div>";
} else {
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]&diary=$diary[id]'>Вернуться</a></div>";
}
}
} else {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_visited` WHERE `id_user` = '$user[id]' AND `id_diary` = '$diary[id]' LIMIT 1"), 0) == 0 && isset($user)) {
mysql_query("INSERT INTO `diary_visited` (`id_user`, `id_diary`, `time`) values ('$user[id]', '$diary[id]', '$time')");
mysql_query("UPDATE `diary` SET `count_visits` = '$diary[count_visits]'+'1' WHERE `id` = '$diary[id]' LIMIT 1");
} else {
mysql_query("UPDATE `diary_visited` SET `time` = '$time' WHERE `id_diary` = '$diary[id]' AND `id_user` = '$user[id]' LIMIT 1");
}
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '".DIR_DIARY."'>Дневники</a> > <a href = '".DIR_DIARY."?id=$avtor[id]&diary=$diary[id]'>" . $Text->toOutput($diary['name']) . "</a></div>";
echo "<div style = 'font-size: 18px;font-weight: bold;' class = 'razdel'>" . img('books.png') . " Дневник " . $Text->toOutput($diary['name']) . "</div>";
echo "<table class = 'razd'><tr><td class = 'icon14'>";
avatar($avtor['id'], '48');
echo "</td><td class = 'null'>";
if ($user['level'] >= 0) {
echo user($avtor['id']);
}
echo "<br />" . img('clock.png') . " " . $Date->time($diary['time']);
echo "<br />" . img('set_mini.png') . " <small>";
if ($diary['type'] == 'only_me' && $diary['+18'] == '1') {
echo "Закрытая запись, +18";
} elseif ($diary['type'] == 'friends' && $diary['+18'] == '1') {
echo "Только для друзей, +18";
} elseif ($diary['type'] == 'pass' && $diary['+18'] == '1') {
echo "Расширенные настройки, +18";
} elseif ($diary['type'] == 'list' && $diary['+18'] == '1') {
echo "Расширенные настройки, +18";
} elseif ($diary['type'] == 'only_me') {
echo "Закрытая запись";
} elseif ($diary['type'] == 'friends') {
echo "Только для друзей";
} elseif ($diary['type'] == 'pass') {
echo "Расширенные настройки";
} elseif ($diary['type'] == 'list') {
echo "Расширенные настройки";
} elseif ($diary['+18'] == '1') {
echo "+18";
}
echo "</small><br />";
echo "</td></tr></table>";
echo "<div class = 'razd'>";
$df = mysql_query("SELECT * FROM `diary_files` WHERE `id_diary` = '$diary[id]' ORDER BY `id` DESC LIMIT 3");
while ($dfl = mysql_fetch_array($df)) {
if ($dfl['type'] == 'photo') {
$id_photo_local = mysql_fetch_array(mysql_query("SELECT * FROM `gallery_foto` WHERE `id` = '$dfl[id_photo_local]' LIMIT 1"));
$gallery = mysql_fetch_array(mysql_query("SELECT * FROM `gallery` WHERE `id` = '$id_photo_local[id_gallery]' LIMIT 1"));
$gallery_user = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$gallery[id_user]' LIMIT 1"));
echo "<a href = '/foto/$gallery_user[id]/$gallery[id]/$id_photo_local[id]/'><img src = '/foto/foto128/$id_photo_local[id].$id_photo_local[ras]' alt = 'Фото_$id_photo_local[id]' /><br/>";
echo " $id_photo_local[name].$id_photo_local[ras]</a>n";
} elseif ($dfl['type'] == 'file') {
$file = mysql_fetch_array(mysql_query("SELECT * FROM `user_files` WHERE `id` = '$dfl[id_file_local]' LIMIT 1"));
echo "<a href = '/user/files/file.php?id=$file[id]'>n";
if (is_file(H . "sys/files/screens/$file[id].png")) {
echo "<img class = 'show_foto' src = '/sys/files/screens/$file[id].png' alt = 'Скрин...' /><br/>n";
}
if (is_file(H . "style/img/files/$file[ras].png")) {
echo "<img src = '/style/img/files/$file[ras].png' />n";
} else {
echo "<img src = '/style/img/file.png' />n";
}
echo " $file[name].$file[ras]</a>";
}
echo "<br />";
}
echo $Text->toOutput($diary['text']) . "<br />";
if ($diary['poll'] == '1') {
echo "<div class = 'hr'></div>";
echo "<b>";
echo $Text->toOutput($diary['poll_text']) . "<br />";
echo '</b>';
$q2 = mysql_query("SELECT * FROM `diary_poll` WHERE `id_diary` = '$diary[id]' ORDER BY `num` ASC");
if (mysql_num_rows($q2) == 0) {
echo "<div class = 'errs'>Ошибка,не найдено ни одного варианта</div>";
}
while ($post2 = mysql_fetch_assoc($q2)) {
$zavse = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_pollen` WHERE `id_diary` = '$diary[id]' ", $db), 0);
$zaet = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_pollen` WHERE `id_diary` = '$diary[id]' AND `id_var` = '$post2[id]' ", $db), 0);
$prov = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_pollen` WHERE `id_diary` = '$diary[id]' AND `id_user` = '$user[id]'", $db), 0);
if ($post2['var'] != NULL) {
if ($zavse == 0) {
$p = 0;
} elseif ($zaet == 0) {
$p = 0;
} else {
$p = ($zaet / $zavse) * 100;
}
echo "<a href = '?id=$ank[id]&diary=$diary[id]&golos=$post2[id]'>" . $Text->toOutput($post2['var']) . "</a> - $zaet<span style='color:darkblue;font-size:small'> ($p%)</span>";
if (isset($_GET['grafik'])) {
echo "<br /><img src = '?img&k=$zaet&a=$zavse&p=$p' />";
}
echo "<br />";
}
}
echo "<br /><a href = '?id=$ank[id]&diary=$diary[id]&who_oprosen'><font color = 'grey'>Кто проголосовал?</font></a><br/>";
echo "<a href = '?id=$ank[id]&diary=$diary[id]&grafik'><font color = 'grey'>Показать опрос графично</font></a><br/>";
if ($diary['poll_timee'] != '145152000') {
if ($diary['poll_time'] > $time) {
echo "Опрос закончится " . $Date->time($diary['poll_time']) . "n";
} else {
echo "Опрос закончился " . $Date->time($diary['poll_time']) . "n";
}
}
}
echo "</div>";
if ($user['id'] == $diary['id_user'] || $user['level'] >= 8) {
echo "<div class = 'razdel' id = 'hide'><span class = 'tiptip'>";
echo "<a href = '?id=$ank[id]&edit=$diary[id]' class = 'button left' title = 'Редактировать'><span class = 'icon icon96' /></a>";
echo "<a href = '?id=$ank[id]&del=$diary[id]' class = 'button middle' title = 'Удалить'><span class = 'icon icon56' /></a>";
if ($diary['poll'] == 0) {
echo "<a href = '?id=$ank[id]&diary=$diary[id]&poll=" . md5($diary['id']) . "' class = 'button middle' title = 'Добавить опрос'><span class = 'icon icon178' /></a>";
} elseif ($diary['poll'] == '1') {
echo "<a href = '?id=$ank[id]&diary=$diary[id]&poll=" . md5($diary['id']) . "' class = 'button middle' title = 'Редактировать опрос'><span class = 'icon icon179' /></a>";
}
echo "<a href = '?id=$ank[id]&edit=$diary[id]&add&file' class = 'button middle' title = 'Добавить файл'><span class = 'icon icon87' /></a>";
echo "<a href = '?id=$ank[id]&edit=$diary[id]&add&photo' class = 'button right' title = 'Добавить фото'><span class = 'icon icon148' /></a>";
echo "</span></div>";
}
echo "<div class = 'razd'>";
if ($Text->utf8_strlen($diary['tags']) > 0) {
echo img('navig.png') . " Метки: ";
$tags = explode(',', $diary['tags']);
for ($i = 0; $i < count($tags); $i++) {
$diary_tag = mysql_fetch_array(mysql_query("SELECT * FROM `diary_tags` WHERE `id_user` = '$avtor[id]' AND `name` = '$tags[$i]' LIMIT 1"));
echo "<small><a href='?id=$ank[id]&tag=$diary_tag[id]&back_diary=$diary[id]'>" . $Text->toOutput($diary_tag['name']) . "</a> </small>";
}
echo "<br /><br />";
}
$count_bookmarks = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_bookmarks` WHERE `id_diary` = '$diary[id]' AND `private` = '0'"), 0);
$bm = mysql_fetch_array(mysql_query("SELECT * FROM `diary_bookmarks` WHERE `id_user` = '$user[id]' AND `id_diary` = '$diary[id]' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_bookmarks` WHERE `id_user` = '$user[id]' AND `id_diary` = '$diary[id]' LIMIT 1"), 0) != 0) {
echo "<a class = 'add' href = '?id=$user[id]&bookmarks&edit_bm=$bm[id]&back=diary'>" . img('bookmark.png') . " В закладках</a>";
} else {
echo "<a class = 'add' href = '?id=$user[id]&bookmarks&add=$diary[id]'>" . img('bookmark.png') . " В закладки</a>";
}
if ($count_bookmarks > 0) {
echo "<a class = 'add' href = '?id=$ank[id]&diary=$diary[id]&user_bm'>$count_bookmarks</a>";
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_bookmarks` WHERE `id_user` = '$user[id]' AND `id_diary` = '$diary[id]' LIMIT 1"), 0) != 0) {
echo "<span id = 'hide'><a class = 'add' href='?id=$user[id]&bookmarks&del_bm=$bm[id]&back=diary' title = 'Удалить'>" . img('del.png') . "</a></span>";
}
echo "<br /><br />";
$count_cmpl = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_cmpl` WHERE `id_subject` = '$diary[id]' AND `subject` = 'diary'"), 0);
echo "<a class = 'add' href = '?id=$ank[id]&diary=$diary[id]&cmpl_diary'>" . img('fire.png') . " Жалоба</a>";
if ($user['level'] >= 8) {
echo "<a class = 'add' href='?id=$ank[id]&diary=$diary[id]&cmpl'>$count_cmpl</a>n";
}
echo "</div><div class = 'razd'>";
$count_komm = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm` WHERE `id_diary` = '$diary[id]'"), 0);
if ($diary['count_visits'] > 0) {
if ($user['level'] >= 8) {
echo "<a class = 'add' href='?id=$ank[id]&diary=$diary[id]&visits'>" . img('chit.png') . " $diary[count_visits]</a> ";
} else {
echo "<a class = 'add'>" . img('chit.png') . " $diary[count_visits]</a> ";
}
}
echo "<a class = 'add'>" . img('comment_white.png') . " $count_komm</a> ";
echo "</div>";
$diary_next = mysql_query("SELECT * FROM `diary` WHERE `id` > '$diary[id]' AND `id_user` = '$ank[id]' ORDER BY `id` ASC LIMIT 1");
$diary_last = mysql_query("SELECT * FROM `diary` WHERE `id` < '$diary[id]' AND `id_user` = '$ank[id]' ORDER BY `id` DESC LIMIT 1");
echo "<div class = 'razd' style='font-weight: bold; font-size: small; text-align:center'>n";
while ($dl = mysql_fetch_array($diary_last)) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary` WHERE `id` < '$diary[id]' AND `id_user` = '$ank[id]' LIMIT 1"), 0) != 0)
echo "<a href = '?id=$ank[id]&diary=$dl[id]'>← Пред.</a>n";
}
while ($dn = mysql_fetch_array($diary_next)) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary` WHERE `id` > '$diary[id]' AND `id_user` = '$ank[id]' LIMIT 1"), 0) != 0)
echo " <a href='?id=$ank[id]&diary=$dn[id]'>След. →</a>n";
}
echo "</div>";
if (isset($_POST['msg']) && isset($user) && $diary['no_komm'] == 0) {
$msg = $_POST['msg'];
if ($Text->utf8_strlen($msg) > 10024) {
$err[] = 'Сообщение слишком длинное';
}
if ($Text->utf8_strlen($msg) < 2) {
$err[] = 'Короткое сообщение';
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm` WHERE `id_diary` = '$diary[id]' AND `id_user` = '$user[id]' AND `msg` = '" . mysql_real_escape_string($msg) . "' LIMIT 1"), 0) != 0) {
$err[] = 'Ваше сообщение повторяет предыдущее';
}
if (!isset($err)) {
mysql_query("INSERT INTO `diary_komm` (`id_diary`, `id_user`, `time`, `msg`) values('$diary[id]', '$user[id]', '$time', '" . mysql_real_escape_string($msg) . "')");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm_wrote` WHERE `id_user` = '$user[id]' AND `id_diary` = '$diary[id]' LIMIT 1"), 0) == 0 && isset($user)) {
mysql_query("INSERT INTO `diary_komm_wrote` (`id_user`, `id_diary`) values ('$user[id]', '$diary[id]')");
}
if ($ank['id'] != $user['id']) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$avtor[id]', '$SexOtv комментарий в Вашем [url=".DIR_DIARY."?id=$ank[id]&diary=$diary[id]]дневнике[/url]', '$time')");
}
$q = mysql_query("SELECT * FROM `diary_komm_wrote` WHERE `id_diary` = '$diary[id]'");
while ($f = mysql_fetch_array($q)) {
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[id_user]' LIMIT 1"));
if ($a['id'] != $user['id'] && $a['id'] != $avtor['id']) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$f[id_user]', '$SexOtv комментарий в [url=".DIR_DIARY."?id=$ank[id]&diary=$diary[id]]этом[/url] дневнике', '$time')");
}
}
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
} elseif (isset($_POST['msg']) && $diary['no_komm'] == '1' && ($user['id'] == $avtor['id'] || $user['level'] > 0)) {
$msg = $_POST['msg'];
if ($Text->utf8_strlen($msg) > 10024) {
$err[] = 'Сообщение слишком длинное';
}
if ($Text->utf8_strlen($msg) < 2) {
$err[] = 'Короткое сообщение';
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm` WHERE `id_diary` = '$diary[id]' AND `id_user` = '$user[id]' AND `msg` = '" . mysql_real_escape_string($msg) . "' LIMIT 1"), 0) != 0) {
$err[] = 'Ваше сообщение повторяет предыдущее';
}
if (!isset($err)) {
mysql_query("INSERT INTO `diary_komm` (`id_diary`, `id_user`, `time`, `msg`) values('$diary[id]', '$user[id]', '$time', '" . mysql_real_escape_string($msg) . "')");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm_wrote` WHERE `id_user` = '$user[id]' AND `id_diary` = '$diary[id]' LIMIT 1"), 0) == 0 && isset($user)) {
mysql_query("INSERT INTO `diary_komm_wrote` (`id_user`, `id_diary`) values ('$user[id]', '$diary[id]')");
}
$q = mysql_query("SELECT * FROM `diary_komm_wrote` WHERE `id_diary` = '$diary[id]'");
while ($f = mysql_fetch_array($q)) {
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[id_user]' LIMIT 1"));
if ($a['id'] != $user['id']) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$f[id_user]', '$SexNap комментарий в [url=".DIR_DIARY."?id=$ank[id]&diary=$diary[id]]этом[/url] дневнике', '$time')");
}
}
if ($ank['id'] != $user['id']) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$avtor[id]', '$SexNap комментарий в Вашем [url=".DIR_DIARY."?id=$ank[id]&diary=$diary[id]]дневнике[/url]', '$time')");
}
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
} elseif (isset($_GET['del_komm']) && ($user['level'] >= 8 || $user['id'] == $diary['id_user'])) {
$komm = $_GET['del_komm'];
$komm = mysql_fetch_array(mysql_query("SELECT * FROM `diary_komm` WHERE `id` = '$komm' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm` WHERE `id` = '$komm[id]' LIMIT 1"), 0) != 0) {
mysql_query("DELETE FROM `diary_komm` WHERE `id` = '$komm[id]'");
header("location: ?id=$ank[id]&diary=$diary[id]");
} else {
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm` WHERE `id_diary` = '$diary[id]' ORDER BY time"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$komm_list = mysql_query("SELECT * FROM `diary_komm` WHERE `id_diary` = '$diary[id]' ORDER BY time ASC LIMIT $start, $set[p_str]");
if (mysql_num_rows($komm_list) == 0) {
echo "<div class = 'errs'>";
echo img('error.png') . " Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_array($komm_list)) {
echo "<table class = 'razd'><tr><td class = 'icon14'>";
$ank2 = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
if ($post['id_otvet'] != NULL) {
$ank_otvet = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_otvet] LIMIT 1"));
}
avatar($ank2['id'], '48');
echo "</td><td class = 'null'>";
echo "<div style = 'float:right'>" . $Date->time($post['time']) . "";
if ($ank['id'] == $post['id_user']) {
echo " | Авторn";
}
echo "</div>";
echo user($ank2['id']);
echo "<br />";
if ($post['id_otvet'] != NULL) {
echo "Ответ для <a href = '/info.php?id=$ank_otvet[id]'>$ank_otvet[nick]</a>:<br/>";
}
echo "<br /><div style = 'float:right;' id = 'hide'>";
if (isset($user) && $diary['no_komm'] == 0) {
echo "<a class = 'add' href = '?id=$ank[id]&diary=$diary[id]&otvet_komm=$post[id]' title = 'Ответить'>" . img('pen.png') . "</a>";
} elseif ($diary['no_komm'] == '1' && ($user['id'] == $avtor['id'] || $user['level'] > 0)) {
echo "<a class = 'add' href='?id=$ank[id]&diary=$diary[id]&otvet_komm=$post[id]' title = 'Ответить'>" . img('pen.png') . "</a>";
}
if ($user['level'] >= 8 || $avtor['id'] == $user['id']) {
echo "<a class = 'add' href='?id=$ank[id]&diary=$diary[id]&del_komm=$post[id]' title = 'Удалить'>" . img('del.png') . "</a>";
}
echo "<a class = 'add' href='?id=$ank[id]&diary=$diary[id]&cmpl_komm=$post[id]' title = 'Жалоба'>" . img('zhal.png') . "</a>";
if (isset($user) && $user['id'] == $ank2['id'] && $post['time'] > time() - 600 && $diary['no_komm'] == 0 && $user['level'] == 0) {
echo "<a class = 'add' href='?id=$ank[id]&diary=$diary[id]&edit_komm=$post[id]' title = 'Редактировать'>" . img('set_mini.png') . " <small>" . ($post['time'] + 600 - time()) . " сек</small></a>";
} elseif ($user['level'] >= 8) {
echo "<a class = 'add' href='?id=$ank[id]&diary=$diary[id]&edit_komm=$post[id]' title = 'Редактировать'>" . img('set_mini.png') . "</a>";
}
echo "<a class = 'add' href='?dl&add=$ank2[id]' title = 'Добавить в список доступа'>" . img('dost.png') . "</a>";
echo "</div>";
echo $Text->toOutput($post['msg']);
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("?id=$ank[id]&diary=$diary[id]&", $k_page, $page);
}
if (isset($user) && $diary['no_komm'] == 0) {
echo "<form method='post' class = 'razd' name = 'msg' action='?id=$ank[id]&diary=$diary[id]'>n";
echo "<b>Сообщение</b><br />";
echo L . "<textarea name = 'msg'></textarea><br />";
echo "<button class = 'active'>";
echo "<span class = 'label'><span class = 'icon icon44' /> Отправить</span>";
echo "</button></form>";
} elseif ($diary['no_komm'] == '1' && ($user['id'] == $avtor['id'] || $user['level'] > 0)) {
echo "<form method = 'post' class = 'razd' name = 'msg' action='?id=$ank[id]&diary=$diary[id]'>n";
echo "<b>Сообщение</b><br />";
echo "<textarea name = 'msg'></textarea><br />n";
echo "<button class = 'active'>";
echo "<span class = 'label'><span class = 'icon icon44' /> Отправить</span>";
echo "</button></form>";
} else {
echo "<div class = 'errs'><b><center>Автор запретил добавлять комментарии</center></b></div>";
}
echo "<div class = 'razd'>" . img('left.png') . " <a href = '?id=$ank[id]'>Вернуться к дневникам $ank[nick]</a></div>";
}
}