Файл: user/wall/comments.php
Строк: 186
<?php
/*
* Стена
* DCMS Special
* Модифицировал densnet
* Файл comments.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/img/like.png[/img] $SexOcen Вашу [url=/user/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 = 'razd'><div class = 'right' id = 'hides'>" . vremja($wall['time']) . "</div>";
echo user($ank['id']);
echo "</div><div class = 'razd'>";
echo "" . output_text($wall['msg']) . " <br />";
$q_f = mysql_query("SELECT * FROM `wall_files` WHERE `id_wall` = '" . intval($_GET['id']) . "'");
while ($file = mysql_fetch_assoc($q_f)) {
if (preg_match('#jpg|jpeg|gif|png#i', $file['ras'])) {
if (isset($user) && $user['level'] > 1) {
echo "<a href = '/wall/delete/$file[id]/' title = 'Удалить файл'><img src = '/wall/files/$file[id]/$file[name].$file[ras]' max-width = '100' height = '100' style = 'margin: 1px;'/></a>";
} else {
echo "<img src = '/wall/files/$file[id]/$file[name].$file[ras]' max-width = '100' height = '100' style = 'margin: 1px;'/>";
}
}
}
if (($user['level'] >= 4) || ($user['id'] == $wall['id_user'])) {
echo "<div class = 'clear_fix'>";
echo "<div class = 'dropdown'>";
echo "<a href = '#' class = 'button'><span class = 'icon icon96' /><span class = 'label'>Администрирование</span><span class = 'toggle'></span></a>";
echo "<div class = 'dropdown-slider'>";
echo "<a href = 'edit.php?id=$wall[id]' class = 'ddm'><span class = 'icon icon98' /><span class = 'label'>Редактировать</span></a>";
echo "<a href = 'edit.php?id=$wall[id]&del' class = 'ddm'><span class = 'icon icon58' /><span class = 'label'>Удалить</span></a>";
echo "</div></div></div>";
}
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 = "$SexOst комментарий в Вашей [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 = 'razd'>";
$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/img/like.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/img/like.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 = '/user/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 = '/user/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 = 'razd'><tr><td class = 'icon48'>";
avatar($ank['id'], '30');
echo "</td><td class = 'null'>";
echo "<div class = 'right'><font color = 'grey'>" . vremja($post['time']) . "</font></div>";
user($ank['id']);
echo "<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/img/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 = 'errs'>";
echo "Автор $SexZapr комментировать";
echo "</div>";
} else {
if (isset($user)) {
echo "<form method = 'post' name = 'message' class = 'razd' action = '?id=" . intval($_GET['id']) . "&page=$page'>";
echo L . "<textarea aria-required = 'true' aria-invalid = 'false' required = 'required' name = 'msg' rows = '2' style = 'width:70%'></textarea><br />n";
echo "<button class = 'action'>";
echo "<span class = 'label'><span class = 'icon icon44' /> Добавить</span>";
echo "</button></form>";
}
}
require_once '../../sys/inc/tfoot.php';