Файл: user/wall/comments.php
Строк: 160
<?php
require_once '../../sys/inc/start.php';
require_once '../../sys/inc/compress.php';
require_once '../../sys/inc/sess.php';
require_once '../../sys/inc/settings.php';
require_once '../../sys/inc/db_connect.php';
require_once '../../sys/inc/ipua.php';
require_once '../../sys/inc/fnc.php';
require_once '../../sys/inc/user.php';
$id = intval($_GET['id']);
$wall = mysql_fetch_array(mysql_query("SELECT * FROM `wall` WHERE `id` = '" . intval($_GET['id']) . "';"));
$ank = get_user($wall['id_user']);
$set['title'] = ' Запись - ' . $ank['nick'] . '';
require_once '../../sys/inc/thead.php';
err();
aut();
if (isset($_GET['unlike']) && isset($user)) {
mysql_query("DELETE FROM `wall_like` WHERE `id_user` = '$user[id]' AND `id_komm` = '" . intval($_GET['id']) . "' LIMIT 1");
}
if (isset($_GET['like']) && isset($user)) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `wall_like` WHERE `id_komm` = '" . intval($_GET['id']) . "' AND `id_user` = '$user[id]' LIMIT 1"), 0) != 0) {
} else {
mysql_query("INSERT INTO `wall_like` (`id_user`, `id_komm`) values('$user[id]', '" . intval($_GET['id']) . "')");
if (isset($user) && $user['id'] != $ank['id']) {
$mess = "[img]http://$_SERVER[HTTP_HOST]/style/icons/like.png[/img] " . ($user['sex'] ? 'оценил' : 'оценила') . " Вашу [url=/wall/comments.php?id=$wall[id]]запись[/url].";
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$ank[id]', '$mess', '$time')");
}
$like = mysql_query("SELECT * FROM `wall_like` WHERE `id_komm` = '$wall[id]' ORDER BY `id`");
while ($postlike = mysql_fetch_assoc($like)) {
$userlike = get_user($postlike['id_user']);
if ($user[id] != $userlike[id]) {
if ($user[id] == $ank[id]) {
$pemberitahuan = ' ' . $user['nick'] . ' написал(а) мнение о [url=/list.php?id=' . $wall['id'] . ']новости[/url].';
} elseif ($user[id] != $ank[id] && $userlike[id] != $ank[id]) {
$pemberitahuan = ' ' . $user['nick'] . ' Также как и на ' . $ank['nick'] . ' [url=/list.php?id=' . $wall['id'] . ']новость[/url].';
}
if ($userlike[id] != $user[id] && $userlike[id] != $ank[id]) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) VALUES ('0', '$userlike[id]', '$pemberitahuan', '$time')");
}
}
}
}
}
$user_id = $ank['id'];
echo "<div class = 'blok'><div class = 'right' id = 'hides'>" . vremja($wall['time']) . "</div>";
echo user($ank['id']);
echo "</div><div class = 'blok'>";
echo "" . output_text($wall['msg']) . " <br />";
include H . '/user/wall/filei.php';
if (($user['level'] >= 4) || ($user['id'] == $wall['id_user'])) {
echo "<br /><a href='edit.php?id=$wall[id]'><small>Редактировать</small></a> | ";
echo "<a href='edit.php?id=$wall[id]&del'><small>Удалить</small></a>";
}
echo "</div>";
if (!isset($_GET['id']) && !is_numeric($_GET['id'])) {
header("Location: index.php?" . SID);
exit;
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `wall` WHERE `id` = '" . intval($_GET['id']) . "' LIMIT 1", $db), 0) == 0) {
header("Location: index.php?" . SID);
exit;
}
$wall = mysql_fetch_array(mysql_query("SELECT * FROM `wall` WHERE `id` = '" . intval($_GET['id']) . "';"));
if (isset($_POST['msg']) && isset($user)) {
$msg = $_POST['msg'];
if (utf8_strlen($msg) > 10024) {
$err = 'Слишком длинное сообщение';
} elseif (utf8_strlen($msg) < 2) {
$err = 'Короткое сообщение';
} elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `wall_comments` WHERE `id_wall` = '" . intval($_GET['id']) . "' AND `id_user` = '$user[id]' AND `msg` = '" . mysql_real_escape_string($msg) . "' LIMIT 1"), 0) != 0) {
$err = 'Ваше сообщение повторяет предыдущее';
} else {
mysql_query("INSERT INTO `wall_comments` (`id_user`, `time`, `msg`, `id_wall`) values('$user[id]', '$time', '" . mysql_real_escape_string($msg) . "', '" . intval($_GET['id']) . "')");
mysql_query("UPDATE `user` SET `money` = '" . ($user['money'] + 5) . "', `activity` = '" . ($user['activity'] + 1) . "' WHERE `id` = '$user[id]' LIMIT 1");
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `wall_count` WHERE `id_wall` = '" . intval($_GET['id']) . "' AND `id_user` = '$user[id]' LIMIT 1"), 0) == 0) {
mysql_query("INSERT INTO `wall_count` (`id_user`, `id_wall`) values('$user[id]', '" . intval($_GET['id']) . "')");
}
mysql_query("INSERT INTO `wall` (`user_id`, `who`, `time`) values('$user_id', '" . $user['id'] . "', '" . time() . "')");
if (isset($user) && $user['id'] != $ank['id']) {
$mess = "" . ($user['sex'] ? 'оставил' : 'оставила') . " комментарий в Вашей [url=/user/wall/comments.php?id=$wall[id]&page=end]записи[/url]. ";
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$ank[id]', '$mess', '$time')");
}
}
} elseif (isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `wall_comments` WHERE `id` = '" . intval($_GET['del']) . "' && `id_wall` = '" . intval($_GET['id']) . "'"), 0)) {
if (isset($user) && ($user['level'] >= 4) || isset($user) && ($user['id'] = $wall['id_user'])) {
mysql_query("DELETE FROM `wall_comments` WHERE `id` = '" . intval($_GET['del']) . "' LIMIT 1");
header("Location: comments.php?id=" . intval($_GET['id']) . "" . SID);
exit;
}
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `wall_comments` WHERE `id_wall` = '" . intval($_GET['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 `wall_comments` WHERE `id_wall` = '" . intval($_GET['id']) . "' ORDER BY `time` ASC LIMIT $start, $set[p_str]");
$kim = @mysql_result(mysql_query("SELECT COUNT(*) FROM `wall_like` WHERE `id_komm` = '" . intval($_GET['id']) . "'"), 0);
$kum = @mysql_result(mysql_query("SELECT `id_user` FROM `wall_like` WHERE `id_komm` = '" . intval($_GET['id']) . "'"), 0);
$kom = @mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id`='$kum' LIMIT 1"), 0);
$kem = $kim - 1;
echo "<div class = 'blok'>";
$wall_like = mysql_result(mysql_query("SELECT COUNT(*) FROM `wall_like` WHERE `id_komm` = '" . intval($_GET['id']) . "'"), 0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `wall_like` WHERE `id_komm` = '" . intval($_GET['id']) . "' AND `id_user` = '$user[id]' LIMIT 1"), 0) == 0) {
if ($wall_like == 0) {
echo "<a href = 'like.php?id=" . intval($_GET['id']) . "&likes'><small>Мне нравится</small></a> ";
} else {
echo "<a href = 'like.php?id=" . intval($_GET['id']) . "&likes'><small>Мне нравится</small></a> ";
echo "<a href = 'like_all.php?id=" . intval($_GET['id']) . "'><img src = '/style/icons/like1.png' /><small><font color = 'grey'>$wall_like</font></small></a>";
}
} else {
if ($wall_like == 0) {
echo "<a href = 'like.php?id=" . intval($_GET['id']) . "&unlikes'><small><font color = 'grey'>Мне нравится</font></small></a> ";
} else {
echo "<a href = 'like.php?id=" . intval($_GET['id']) . "&unlikes'><small><font color = 'grey'>Мне нравится</font></small></a> ";
echo "<a href = 'like_all.php?id=" . intval($_GET['id']) . "'><img src = '/style/icons/like1.png' /><small><font color = 'grey'>$wall_like</font></small></a>";
}
}
if ($kom == $user['nick']) {
$kom = "Вам";
} else {
$kom = @mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id` = '$kum' LIMIT 1"), 0);
}
if ($kim == 1) {
echo "<div>";
echo "<small><font color = 'grey'>Понравилось <a href='/info.php?id=$kum'>$kom</a></font></small>";
echo "</div>";
} elseif ($kim == 2) {
echo "<div>";
echo "<small><font color = 'grey'>Понравилось <a href = '/info.php?id=$kum'>$kom</a> и <a href = '/wall/like_all.php?id=$wall[id]'> ещё $kem пользователю.</a></font></small>";
echo "</div>";
} elseif ($kim >= 3) {
echo "<div>";
echo "<small><font color = 'grey'>Понравилось <a href = '/info.php?id=$kum'>$kom</a> и <a href = '/wall/like_all.php?id=$wall[id]'> ещё $kem пользователям.</a></font></small>";
echo "</div>";
}
echo "</div>";
while ($post = mysql_fetch_assoc($q)) {
$ank = get_user($post['id_user']);
echo "<table class = 'blok'><tr><td class = 'icon14'>";
avatar($ank['id'], '30');
echo "</td><td class = 'null'>";
echo "<div class = 'right'><font color='grey'>" . vremja($post['time']) . "</font></div><b>";
user($ank['id']);
echo "</b><br />";
if (isset($user) && ($user['level'] >= 4) || isset($user) && ($user['id'] == $wall['id_user'])) {
echo "<div class = 'right' id='hide'>n";
echo "<a href = '?id=" . intval($_GET['id']) . "&del=$post[id]' title = 'Удалить комментарий'><img src='/style/icons/cross.png' /></a>";
echo "</div>";
}
echo output_text($post['msg']);
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("?id=" . intval($_GET['id']) . '&', $k_page, $page);
}
if ($wall['privat_komm'] == 1) {
echo "<div class = 'err'>";
echo "Автор " . ($ank['sex'] ? 'запретил' : 'запретила') . " комментировать";
echo "</div>";
} else {
if (isset($user)) {
echo "<form method="post" name='message' class = 'blok' action="?id=" . intval($_GET['id']) . "&page=$page">n";
echo "Ваш комментарий <a href = '/pages/smiles/'><img src = '/style/icons/smile.png' /></a><br />";
echo "<textarea aria-required = 'true' aria-invalid = 'false' required = 'required' name="msg" rows='1' style='width:70%'></textarea><br />n";
echo "<div class = 'button_blue'>";
echo "<button>Отправить</button>";
echo "</div></form>";
}
}
require_once '../../sys/inc/tfoot.php';