Файл: diary/diary_form.php
Строк: 805
<?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](" . vremja($diary['time']) . ")rn";
echo trim(br($diary['text'], "rn")) . "rn";
echo "rnИсточник: http://$_SERVER[SERVER_NAME]/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='foot'>Внимание! Это содержимое только для взрослых!<br/>Нажимая ДА, Вы подтверждаете, что Вам 18 или более лет.<br/>Если Вам менее 18 лет - нажмите НЕТ.<br/><br/><a href='?id=$ank[id]&diary=$diary[id]&passed'>Да</a> <a href='?'>Нет</a><br/></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 "Данная функция доступна только для авторизованных пользователей. Пожалуйста, пройдите <a href='/aut.php'>авторизацию</a> или <a href='/reg.php'>регистрацию</a>";
require_once '../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='err'>Комментарий не найден</div>";
} else {
if (isset($user) && $diary['no_komm'] == 0) {
if (isset($_POST['msg_otvet'])) {
$msg = $_POST['msg_otvet'];
if (utf8_strlen($msg) > 10024) {
echo "<div class='err'>Сообщение слишком длинное</div>";
}
if (utf8_strlen($msg) < 2) {
echo "<div class='err'>Комментарий не найден</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='err'>Ваше сообщение повторяет предыдущее</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']) {
if ($user['sex'] == 1) {
$sex = 'оставил';
} else {
$sex = 'оставила';
}
mysql_query("INSERT INTO `tape` (`id_user`, `id_kont`, `msg`, `time`) values('" . $user['id'] . "', '$avtor[id]', '[url=/info.php?id=$user[id]]$user[nick][/url] $sex комментарий в вашем [url=/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']) {
if ($user['sex'] == 1) {
$sex = 'оставил';
} else {
$sex = 'оставила';
}
mysql_query("INSERT INTO `tape` (`id_user`, `id_kont`, `msg`, `time`) values('" . $user['id'] . "', '$a[id]', '[url=/info.php?id=$user[id]]$user[nick][/url] $sex комментарий в [url=/diary/?id=$ank[id]&diary=$diary[id]]этом[/url] дневнике', '$time')");
}
}
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
}
echo "<div class='foot'>$komm_avtor[nick] написал:<br/>";
echo "" . htmlspecialchars($komm['msg']) . "</div>n";
echo "<form method='post' class = 'foot' name='msg_otvet' action='?id=$ank[id]&diary=$diary[id]&otvet_komm=$komm[id]' >n";
echo "Сообщение (1024 знаков)<br />";
echo text::auto_bb('msg_otvet', 'msg_otvet');
echo L . "<textarea name='msg_otvet'></textarea><br />n";
echo "<button class = 'btn'>";
echo "<img src = '/style/icons/tick.png' /> Отправить";
echo "</button></form>n";
} elseif ($diary['no_komm'] == '1' && ($user['id'] == $avtor['id'] || $user['level'] > 0)) {
if (isset($_POST['msg_otvet'])) {
$msg = $_POST['msg_otvet'];
if (utf8_strlen($msg) > 1024) {
$err[] = 'Сообщение слишком длинное';
}
if (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']) {
if ($user['sex'] == 1) {
$sex = 'оставил';
} else {
$sex = 'оставила';
}
mysql_query("INSERT INTO `tape` (`id_user`, `id_kont`, `msg`, `time`) values('" . $user['id'] . "', '$avtor[id]', '[url=/info.php?$user[id]]$user[nick][/url] $sex комментарий в вашем [url=/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']) {
if ($user['sex'] == 1) {
$sex = 'оставил';
} else {
$sex = 'оставила';
}
mysql_query("INSERT INTO `tape` (`id_user`, `id_kont`, `msg`, `time`) values('" . $user['id'] . "', '$f[id_user]', '[url=/profile/?id=$user[id]]$user[nick][/url] $sex комментарий в [url=/diary/?id=$ank[id]&diary=$diary[id]]этом[/url] дневнике', '$time')");
}
}
header("Location: ?id=$ank[id]&diary=$diary[id]");
}
}
echo "<div class='foot'>$komm_avtor[nick] написал:<br/> " . filter_var(htmlspecialchars($komm['msg'], FILTER_SANITIZE_SPECIAL_CHARS)) . "</div>n";
echo "<form method='post' class = 'foot' name='msg_otvet' action='?id=$ank[id]&diary=$diary[id]&otvet_komm=$komm[id]' >n";
echo "Сообщение (1024 знаков)<br />";
echo text::auto_bb('msg_otvet', 'msg_otvet');
echo L . "<textarea name='msg_otvet'></textarea><br />n";
echo "<button class = 'btn'>";
echo "<img src = '/style/icons/tick.png' /> Отправить";
echo "</button></form>n";
} else {
echo "<div class='err'>Автор запретил добавлять комментарии</div>";
}
echo "<a href='?id=$ank[id]&diary=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>n";
}
require_once '../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 (utf8_strlen($msg_edit) < 1) {
$err[] = 'Введите coбщение';
}
if (utf8_strlen($msg_edit) > 1024) {
$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 "<form method='post' class = 'foot' name = 'komm_set' action='?id=$ank[id]&diary=$diary[id]&edit_komm&ok=$komm[id]'>n";
echo "Сообщение (1024 знаков)<br/>";
echo text::auto_bb('komm_set', 'msg_edit');
echo L . "<textarea name='msg_edit'>$komm[msg]</textarea><br />n";
echo "<button class = 'btn'>";
echo "<img src = '/style/icons/save.png' /> Сохранить изменения";
echo "</button></form>n";
} else {
echo "<div class = 'err'>У вас нет прав для данного действия!</div>";
}
echo "<a href='?id=$ank[id]&diary=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>n";
} 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 (utf8_strlen($msg_cmpl) < 1) {
$err[] = 'Введите сообщение';
}
if (utf8_strlen($msg_cmpl) > 1024) {
$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 "<form method='post' name = 'cmpl_komm' class = 'foot' action='?id=$ank[id]&diary=$diary[id]&cmpl_komm=$cmpl[id]&ok'>";
echo "Жалоба на:<br/><font color = 'red'>" . text::toOutput($cmpl['msg']) . "</font><br />";
echo "Причина жалобы:<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 "Сообщение:<br/>";
echo text::auto_bb('cmpl_komm', 'msg_cmpl');
echo L . "<textarea name='msg_cmpl'></textarea><br/>n";
echo "<div class = 'right' id = 'hide'>";
echo "<a href = '?id=$ank[id]&diary=$diary[id]' title = 'Отмена'><img src = '/style/icons/cross.png' /></a>";
echo "</div>";
echo "<button class = 'btn'>";
echo "<img src = '/style/icons/tick.png' /> Отправить";
echo "</button></form>";
} elseif (isset($_GET['cmpl_diary']) && isset($user)) {
if (isset($_GET['ok'])) {
$type = $_POST['reason'];
$msg_cmpl = $_POST['msg_cmpl'];
if (utf8_strlen($msg_cmpl) < 1) {
$err[] = 'Введите сообщение';
}
if (utf8_strlen($msg_cmpl) > 1024) {
$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 "<form method='post' name = 'cmpl_diary' class = 'foot' action='?id=$ank[id]&diary=$diary[id]&cmpl_diary&ok'>";
echo "Жалоба на:<br/><font color = 'red'>" . text::toOutput($diary['text']) . "</font><br/>";
echo "Причина жалобы:<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 "Сообщение:<br/>";
echo text::auto_bb('cmpl_diary', 'msg_cmpl');
echo L . "<textarea name='msg_cmpl'></textarea><br/>n";
echo "<div class = 'right' id = 'hide'>";
echo "<a href = '?id=$ank[id]&diary=$diary[id]' title = 'Отмена'><img src = '/style/icons/cross.png' /></a>";
echo "</div><button class = 'btn'>";
echo "<img src = '/style/icons/tick.png' /> Отправить";
echo "</button></form>n";
} 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 (utf8_strlen($result1) < 1) {
$err[] = '1 вариант обязателен для заполнения';
}
$result1 = mysql_real_escape_string($result1);
$result2 = $_POST['result2'];
if (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 (utf8_strlen($poll_text) < 1) {
$err[] = 'Введите текст';
}
if (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='menu_razd'>Создание нового опроса:</div>n";
echo "<form class = 'foot' action='?id=$ank[id]&diary=$diary[id]&poll=" . md5($diary['id']) . "&ok' method='post'>n";
echo L . "<textarea name='poll_text'></textarea><br />";
echo "Варианты ответов:<br />n";
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 = 'btn' name='save'>";
echo "<img src = '/style/icons/save.png' /> Сохранить изменения";
echo "</button></form>n";
echo "<a href='?id=$ank[id]&diary=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>n";
} elseif ($diary['poll'] == '1') {
if (isset($_POST['save'])) {
$result1 = $_POST['result1'];
if (utf8_strlen($result1) < 1) {
$err[] = '1 вариант обязателен для заполнения';
}
$result1 = mysql_real_escape_string($result1);
$result2 = $_POST['result2'];
if (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 (utf8_strlen($poll_text) < 1) {
$err[] = 'Введите текст';
}
if (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 "<form class = 'foot' action='?id=$ank[id]&diary=$diary[id]&poll=" . md5($diary['id']) . "' method='post'>n";
echo "<textarea name='poll_text'>$diary[poll_text]</textarea><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 "<label for='wipe'>Сбросить результаты голосования: </label>n";
echo "<input id='wipe' type='checkbox' name='wipe' value='1' /><br />";
echo "<button class = 'btn' name='save'>";
echo "<img src = '/style/icons/save.png' /> Сохранить";
echo "</button>";
echo "<button class = 'btn' name='delete'>";
echo "<img src = '/style/icons/cross.png' /> Удалить";
echo "</button></form>n";
echo "<a href='?id=$ank[id]&diary=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>n";
}
} else {
echo "Это не ваш дневник!";
}
} 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 = 'err'>Опрос уже закрыт!</div>n";
} elseif ($prov_p == 0) {
echo "<div class = 'err'>К данному дневнику опрос не прикреплён!</div>n";
} 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 = 'err'>Вы уже принимали участие в данном опросе!</div>n";
} 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('Ваш голос успешно принят');
}
} else {
echo "<form method='post' class = 'foot' action='?id=$ank[id]&diary=$diary[id]&golos=$golos[id]'>n";
echo "Вы действительно хотите проголосовать за даный вариант?<br />n";
echo "<button class = 'btn' name='ok'>";
echo "<img src = '/style/icons/tick.png' /> Да";
echo "</button> <a href='?id=$ank[id]&diary=$diary[id]'>Нет</a></form>n";
}
}
} 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 "<table class = 'foot'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет результатов";
echo "</td></tr></table>";
}
while ($post = mysql_fetch_assoc($q)) {
echo "<table class = 'foot'><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 "<img src = '/style/icons/time.png' /> " . vremja($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 "<a href='?id=$diary[id_user]&info=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>";
} else {
echo "<a href='?id=$diary[id_user]&diary=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>";
}
} 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 "<table class = 'foot'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет результатов";
echo "</td></tr></table>";
}
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 = 'foot'><tr><td class = 'icon14'>";
avatar($ank2['id'], '48');
echo "</td><td class = 'null'>";
user($ank2['id']);
echo "<br /><img src = '/style/icons/time.png' /> " . vremja($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'])) {
echo "<a href='?id=$diary[id_user]&info=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>";
} else {
echo "<a href='?id=$ank[id]&diary=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>";
}
} 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 "<table class = 'foot'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет результатов";
echo "</td></tr></table>";
}
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 = 'foot'><tr><td class = 'icon14'>";
avatar($ank2['id'], '48');
echo "</td><td class = 'null'>";
echo user($ank2['id']);
echo "<br /><img src = '/style/icons/time.png' /> " . vremja($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 "<a href='?id=$diary[id_user]&info=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>";
} else {
echo "<a href='?id=$diary[id_user]&diary=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>";
}
} 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 = 'err'>Сообщение не найдено!</div>";
} elseif (strlen2($msg['msg']) < 0) {
echo "<div class = 'err'>Сообщение не найдено!</div>";
} else {
echo "<div class = 'foot'>";
echo text::toOutput($msg['msg']);
echo "</div>";
}
echo "<a href='?id=$ank[id]&diary=$diary[id]&cmpl'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>n";
} 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 "<table class = 'foot'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет результатов";
echo "</td></tr></table>";
}
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 = 'foot'><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/>n";
} else {
echo "<font color = 'red'>Запрещено</font>";
echo " [<a href='?cmpl&do_cmpl=$avtor[id]'>разрешить</a>]<br/>n";
}
echo "Время: " . vremja($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 (utf8_strlen($post['msg']) > 0) {
echo " | <b><a href='?id=$ank[id]&diary=$diary[id]&cmpl&msg=$post[id]'>Сообщение</a></b><br/>n";
} else {
echo "<br/>n";
}
if ($post['ok'] == 1) {
echo "<font color='green'>Даную жалобу рассмотрел <a href='/info.php?id=$user_ok[id]'>$user_ok[nick]</a></font><br/>n";
} else {
echo "<font color='red'>Жалоба не рассмотренна</font> <a href='?id=$ank[id]&diary=$diary[id]&cmpl&ok=$post[id]' style='color:green'>[OK]</a>n";
}
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("?id=$ank[id]&diary=$diary[id]&cmpl&", $k_page, $page);
}
if (isset($_GET['back'])) {
echo "<a href='?id=$diary[id_user]&info=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>n";
} else {
echo "<a href='?id=$diary[id_user]&diary=$diary[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>n";
}
}
} 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='foot'>n";
if ($user['level'] >= 0) {
echo " " . user($avtor['id']) . " n";
}
echo "<div class='right'> " . vremja($diary['time']) . "</div>";
echo "<br />";
if (utf8_strlen($diary['name']) > 0) {
echo "<b>" . text::toOutput($diary['name']) . "</b>";
}
echo "<font color='red'>n";
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 "</font><br />";
$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/icons/files/$file[ras].png")) {
echo "<img src='/style/icons/files/$file[ras].png' />n";
} else {
echo "<img src='/style/icons/file.png' />n";
}
echo " $file[name].$file[ras]</a>";
}
echo "<br />";
}
echo "" . text::toOutput($diary['text']) . "<br />";
if ($diary['poll'] == '1') {
echo "<b>";
echo text::toOutput($diary['poll_text']) . "<br />n";
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 "Ошибка,не найдено ни одного варианта n";
}
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 "<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 "Опрос закончится " . vremja($diary['poll_time']) . "n";
} else {
echo "Опрос закончился " . vremja($diary['poll_time']) . "n";
}
}
}
echo "</div>";
if ($user['id'] == $diary['id_user'] || $user['level'] >= 8) {
echo "<div class='panel'>";
echo "<a href='?id=$ank[id]&edit=$diary[id]' title = 'Редактировать'><img src = '/style/icons/set.png' /></a> ";
echo "<a href='?id=$ank[id]&del=$diary[id]' title = 'Удалить'><img src = '/style/icons/cross.png' /></a> ";
if ($diary['poll'] == 0) {
echo "<a href='?id=$ank[id]&diary=$diary[id]&poll=" . md5($diary['id']) . "' title = 'Добавить опрос'><img src = '/style/icons/opros.png' /></a>n";
} elseif ($diary['poll'] == '1') {
echo "<a href='?id=$ank[id]&diary=$diary[id]&poll=" . md5($diary['id']) . "' title = 'Редактировать опрос'><img src = '/style/icons/opros_set.png' /></a>n";
}
echo "<a href='?id=$ank[id]&edit=$diary[id]&add&file' title = 'Добавить файл'><img src = '/style/icons/upload.png' /></a> ";
echo "<a href='?id=$ank[id]&edit=$diary[id]&add&photo' title = 'Добавить фото'><img src = '/style/icons/photo.png' /></a> ";
echo "</div>";
}
if (utf8_strlen($diary['tags']) > 0) {
echo "<div class='foot'>";
echo "<img src='/style/icons/bookmark-small.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 "<span style='font-size: small'><a href='?id=$ank[id]&tag=$diary_tag[id]&back_diary=$diary[id]'>" . text::toOutput($diary_tag['name']) . "</a> </span>n";
}
echo "</div>";
}
echo "<div class='foot'>";
$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 "<img src='/style/icons/star0.png' /> <a href='?id=$user[id]&bookmarks&edit_bm=$bm[id]&back=diary'>В закладках</a>n";
} else {
echo "<img src='/style/icons/star1.png' /> <a href='?id=$user[id]&bookmarks&add=$diary[id]'>В закладки</a>n";
}
if ($count_bookmarks > 0) {
echo "<a href='?id=$ank[id]&diary=$diary[id]&user_bm'>($count_bookmarks)</a>n";
}
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 href='?id=$user[id]&bookmarks&del_bm=$bm[id]&back=diary' title='удалить'><img src='/style/icons/cross.png' /></a></span>";
}
echo "<br />";
$count_cmpl = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_cmpl` WHERE `id_subject` = '$diary[id]' AND `subject` = 'diary'"), 0);
echo "<img src='/style/icons/zhaloba.png' /> <a href='?id=$ank[id]&diary=$diary[id]&cmpl_diary'>Жалоба</a>n";
if ($user['level'] >= 8) {
echo " <a href='?id=$ank[id]&diary=$diary[id]&cmpl'>($count_cmpl)</a>n";
}
echo "</div><div class='menu'>";
$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 "<img src='/style/icons/eye1.png' /> <a href='?id=$ank[id]&diary=$diary[id]&visits'>$diary[count_visits]</a> ";
} else {
echo "<img src='/style/icons/eye1.png' /> $diary[count_visits] ";
}
}
echo "<img src='/style/icons/comment_white.png' /> $count_komm";
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='foot' 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>n";
if (isset($_POST['msg']) && isset($user) && $diary['no_komm'] == 0) {
$msg = $_POST['msg'];
if (utf8_strlen($msg) > 1024) {
$err[] = 'Сообщение слишком длинное';
}
if (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']) {
if ($user['sex'] == 1) {
$sex = 'оставил';
} else {
$sex = 'оставила';
}
mysql_query("INSERT INTO `tape` (`id_user`, `id_kont`, `msg`, `time`) values('" . $user['id'] . "', '$avtor[id]', '[url=/info.php?id=$user[id]]$user[nick][/url] $sex комментарий в вашем [url=/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']) {
if ($user['sex'] == 1) {
$sex = 'оставил';
} else {
$sex = 'оставила';
}
mysql_query("INSERT INTO `tape` (`id_user`, `id_kont`, `msg`, `time`) values('" . $user['id'] . "', '$f[id_user]', '[url=/info.php?id=$user[id]]$user[nick][/url] $sex комментарий в [url=/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 (utf8_strlen($msg) > 1024) {
$err[] = 'Сообщение слишком длинное';
}
if (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']) {
if ($user['sex'] == 1) {
$sex = 'оставил';
} else {
$sex = 'оставила';
}
mysql_query("INSERT INTO `tape` (`id_user`, `id_kont`, `msg`, `time`) values('" . $user['id'] . "', '$f[id_user]', '[url=/info.php?id=$user[id]]$user[nick][/url] $sex комментарий в [url=/diary/?id=$ank[id]&diary=$diary[id]]этом[/url] дневнике', '$time')");
}
}
if ($ank['id'] != $user['id']) {
if ($user['sex'] == 1) {
$sex = 'оставил';
} else {
$sex = 'оставила';
}
mysql_query("INSERT INTO `tape` (`id_user`, `id_kont`, `msg`, `time`) values('" . $user['id'] . "', '$avtor[id]', '[url=/info.php?id=$user[id]]$user[nick][/url] $sex комментарий в вашем [url=/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 "<table class = 'foot'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет комментариев";
echo "</td></tr></table>";
}
while ($post = mysql_fetch_array($komm_list)) {
echo "<table class = 'foot'><tr><td class = 'null'>";
$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"));
}
echo "<div class='right'>" . vremja($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 text::toOutput($post['msg']);
echo "<div class='right' id = 'hide'>";
if (isset($user) && $diary['no_komm'] == 0) {
echo "<a href='?id=$ank[id]&diary=$diary[id]&otvet_komm=$post[id]' title = 'Ответить'><img src = '/style/icons/pencil.png' /></a> n";
} elseif ($diary['no_komm'] == '1' && ($user['id'] == $avtor['id'] || $user['level'] > 0)) {
echo "<a href='?id=$ank[id]&diary=$diary[id]&otvet_komm=$post[id]' title = 'Ответить'><img src = '/style/icons/pencil.png' /></a> n";
}
if ($user['level'] >= 8 || $avtor['id'] == $user['id']) {
echo "<a href='?id=$ank[id]&diary=$diary[id]&del_komm=$post[id]' title = 'Удалить'><img src = '/style/icons/cross.png' /></a>n";
}
echo " <a href='?id=$ank[id]&diary=$diary[id]&cmpl_komm=$post[id]' title = 'Жалоба'><img src = '/style/icons/zhaloba.png' /></a> n";
if (isset($user) && $user['id'] == $ank2['id'] && $post['time'] > time() - 600 && $diary['no_komm'] == 0 && $user['level'] == 0) {
echo "<a href='?id=$ank[id]&diary=$diary[id]&edit_komm=$post[id]' title = 'Редактировать'><img src = '/style/icons/set.png' />(" . ($post['time'] + 600 - time()) . " сек)</a>n";
} elseif ($user['level'] >= 8) {
echo "<a href='?id=$ank[id]&diary=$diary[id]&edit_komm=$post[id]' title = 'Редактировать'><img src = '/style/icons/set.png' /></a>n";
}
echo "<a href='?dl&add=$ank2[id]' title='удалить'><img src = '/style/icons/ok.png' /></a>n";
echo "</div>";
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 = 'foot' name='msg' action='?id=$ank[id]&diary=$diary[id]'>n";
echo "Сообщение:<br />";
echo L . "<textarea name='msg'></textarea><br />n";
echo "<button class = 'btn'>";
echo "<img src = '/style/icons/tick.png' /> Отправить";
echo "</button></form>n";
} elseif ($diary['no_komm'] == '1' && ($user['id'] == $avtor['id'] || $user['level'] > 0)) {
echo "<form method='post' class = 'foot' name='msg' action='?id=$ank[id]&diary=$diary[id]'>n";
echo "Сообщение:<br />";
echo "<textarea name='msg'></textarea><br />n";
echo "<button class = 'btn'>";
echo "<img src = '/style/icons/tick.png' /> Отправить";
echo "</button></form>n";
} else {
echo "<div class='busi'><b><center>Автор запретил добавлять комментарии</center></b></div>";
}
echo "<a href='?id=$ank[id]'><div class='foot'><img src='/style/icons/left.png' /> Назад</div></a>";
}
}