Файл: user/wall/comments.php
Строк: 192
<?php
/* DCMS Special
* Дата последнего редактирования 11.12.2015
* Модифицировал densnet
*/
foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
require_once "../../sys/inc/{$inc}.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 H . 'sys/inc/thead.php';
aut();
err();
$wall = mysql_fetch_array(mysql_query("SELECT * FROM `wall` WHERE `id` = '" . intval($_GET['id']) . "';"));
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 = "$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']) {
$not = "$SexOcen Вашу [url=/user/wall/comments.php?id=$wall[id]]запись[/url].";
} elseif ($user['id'] != $ank['id'] && $userlike['id'] != $ank['id']) {
$not = "$SexOcen Вашу [url=/user/wall/comments.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 ('$user[id]', '$userlike[id]', '$not', '$time')");
}
}
}
}
}
#Список тех, кому понравилась новость
if (isset($_GET['like_all'])) {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `wall_like` WHERE `id_komm` = '" . 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'];
$k_sisa = $k_post - 1;
$q = mysql_query("SELECT * FROM `wall_like` WHERE `id_komm` = '" . intval($_GET['id']) . "' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
$stena = intval($_GET['id']);
#Навигация
echo "<ol class='breadcrumb'>";
echo "<li><a href='/'><i class='fa fa-home fa-fw'></i></a></li>";
echo "<li><a href='/info.php?id=$ank[id]'>$ank[nick]</a></li>";
echo "<li><a href='/info.php?id=$ank[id]&act=wall'>Стена</a></li>";
echo "<li><a href='/user/wall/comments.php?id=$stena'>" . cutStr($wall['msg'], 30) . "</a></li>";
echo "<li class='active'>Им это нравится</li>";
echo "</ol>";
if ($k_post == 0) {
echo "<div class='list-group-item'>";
echo "<i class='fa fa-info-circle fa-fw'></i> Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
$ank = get_user($post['id_user']);
echo "<div class='list-group-item'>";
if ($ank['id'] == 0) {
avatar(0, '30', 'border-radius: 2px;');
echo "<i class='fa fa-user fa-fw'></i> Пользователь удален";
} else {
avatar($ank['id'], '30', 'border-radius: 2px;');
user($ank['id']);
}
echo "</div>";
}
if ($k_page > 1) {
echo "<div class='list-group-item'>";
echo $k_sisa;
echo "</div>";
}
require_once H . 'sys/inc/tfoot.php';
}
$user_id = $ank['id'];
#Навигация
echo "<ol class='breadcrumb'>";
echo "<li><a href='/'><i class='fa fa-home fa-fw'></i></a></li>";
echo "<li><a href='/info.php?id=$ank[id]'>$ank[nick]</a></li>";
echo "<li><a href='/info.php?id=$ank[id]&act=wall'>Стена</a></li>";
echo "<li class='active'>" . cutStr($wall['msg'], 40) . "</li>";
echo "</ol>";
echo "<div class='list-group-item'>";
if (($user['level'] >= 4) || ($user['id'] == $wall['id_user'])) {
echo "<span style = 'float:right' id = 'hide'>";
echo "<a href='edit.php?id=$wall[id]' data-toggle='tooltip' data-placement='left' title='Редактировать'><span class='fa fa-cog fa-fw'></span></a> ";
echo "<a href='edit.php?id=$wall[id]&del' data-toggle='tooltip' data-placement='left' title='Удалить'><span class='fa fa-trash-o fa-fw'></span></a>";
echo "</span>";
}
echo user($ank['id']);
echo " <span title='" . date::times($wall['time']) . "' style='color:grey;'>" . date::timek($wall['time']) . "</span>";
echo "</div><div class='list-group-item'>";
echo "" . toOutput($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='/files/delete/$file[id]/' title = 'Удалить файл'><img src = '/files/$file[id]/$file[name].$file[ras]' max-width = '100' height = '100' style = 'margin: 1px;'/></a>";
} else {
echo "<img src='/files/$file[id]/$file[name].$file[ras]' max-width = '100' height = '100' style = 'margin: 1px;'/>";
}
}
}
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;
}
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'] + 2) . "' 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')");
}
$komm = mysql_query("SELECT * FROM `wall_comments` WHERE `id_wall` = '$wall[id]' ORDER BY `id`");
while ($posts = mysql_fetch_assoc($komm)) {
$userkomm = get_user($posts['id_user']);
if ($user['id'] != $userkomm['id']) {
if ($user['id'] == $ank['id']) {
$not = "$SexKomm Вашу [url=/user/wall/comments.php?id=$wall[id]]запись[/url]. ";
} elseif ($user['id'] != $ank['id'] && $userkomm['id'] != $ank['id']) {
$not = "$SexKomm Вашу [url=/user/wall/comments.php?id=$wall[id]]запись[/url]. ";
}
if ($userkomm['id'] != $user['id'] && $userkomm['id'] != $ank['id']) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) VALUES ('$user[id]', '$userkomm[id]', '$not', '$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]");
echo "<div class='list-group-item'>";
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `wall_like` WHERE `id_komm` = '" . intval($_GET['id']) . "'"), 0);
if ($like == 0) {
$l = null;
} else {
$l = 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) {
echo "<a href='comments.php?id=" . intval($_GET['id']) . "&like'><i class='fa fa-heart-o fa-fw'></i> Нравится $l</a> ";
} else {
echo "<a href='comments.php?id=" . intval($_GET['id']) . "&unlike'><i class='fa fa-heart fa-fw'></i> Нравится $l</a> ";
}
$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 = $like - 1;
#Выводит тех, кому понравилась новость
if ($user['id'] == $kum) {
if ($like == 1) {
$vam = "Вам это нравится";
} elseif ($like >= 2) {
$vam = "Вам и еще <a href='?id=" . intval($_GET['id']) . "&like_all'>" . sklon_text($kem, array('пользователю', 'пользователям', 'пользователям')) . "</a> это нравится";
}
} else {
$vam = "<a href='?id=" . intval($_GET['id']) . "&like_all'>" . sklon_text($like, array('пользователю', 'пользователям', 'пользователям')) . "</a> это нравится";
}
if ($like == 1) {
echo "<div class='hr'></div>";
echo "<font color='#B2B2B2'><i class='fa fa-heart fa-fw'></i> $vam</font>";
} elseif ($like >= 2) {
echo "<div class='hr'></div>";
echo "<font color='#B2B2B2'><i class='fa fa-heart fa-fw'></i> $vam</font>";
}
echo "</div>";
while ($post = mysql_fetch_assoc($q)) {
$ank = get_user($post['id_user']);
echo "<ul class='media-list media-list-conversation list-group-item'>";
echo "<li class='media'>";
echo "<a class='media-left' href='/info.php?id=$ank[id]'>";
avatars($ank['id'], '40');
echo "</a>";
echo "<div class='media-body'><div class='media-body-text'>";
echo toOutput($post['msg']);
echo "</div><div class='media-footer'>";
echo "<small class='text-muted'>";
if (isset($user) && ($user['level'] >= 4) || isset($user) && ($user['id'] == $wall['id_user'])) {
echo "<span style='float:right;' id='hides'>";
echo "<a href='?id=" . intval($_GET['id']) . "&del=$post[id]' data-toggle='tooltip' data-placement='left' title='Удалить комментарий'><span class='fa fa-trash-o'></span></a>";
echo "</span>";
}
echo user($ank['id']) . " <span data-toggle='tooltip' data-placement='right' title='" . date::time($post['time']) . "' style='color:grey;'>" . date::times($post['time']) . "</span> ";
echo "</small>";
echo "</div></div>";
echo "</li>";
echo "</ul>";
}
if ($k_page > 1) {
echo "<div class='list-group-item'>";
str("?id=" . intval($_GET['id']) . '&', $k_page, $page);
echo "</div>";
}
if ($wall['privat_komm'] == 1) {
echo "<div class='list-group-item'>";
echo "Автор $SexZapr комментировать";
echo "</div>";
} else {
if (isset($user)) {
echo "<form method='post' name='message' class='list-group-item' action='?id=" . intval($_GET['id']) . "&page=$page'>";
echo "<textarea name='msg' rows='2' class='form-control' placeholder='Что Вы об этом думаете?'></textarea><br />n";
echo "<button class='btn btn-success'>Добавить</button>";
echo "</form>";
}
}
require_once H . 'sys/inc/tfoot.php';