Файл: user/avatar_comm.php
Строк: 139
<?php
/* Мод "Аватар"
* Версия v0.0.1
* Дата последнего редактирования 22.11.2014
* Двиг DCMS Special
* Модифицировал densnet
* Файл avatar_comm.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';
if (isset($user)) {
$ank['id'] = $user['id'];
}
if (isset($_GET['id'])) {
$ank['id'] = intval($_GET['id']);
}
if ($ank['id'] == 0) {
exit;
}
$ank = user::get_user($ank['id']);
if (!$ank) {
header("Location: /index.php?" . SID);
exit;
}
$ank['rating'] = intval(@mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$ank[id]'"), 0));
$set['title'] = $ank['nick'] . ' - Комментарии к аватару ';
require_once '../sys/inc/thead.php';
if ((!isset($_SESSION['refer']) || $_SESSION['refer'] == NULL) && isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != NULL &&
!preg_match('#info.php#', $_SERVER['HTTP_REFERER'])) {
$_SESSION['refer'] = str_replace('&', '&', preg_replace('#^http://[^/]*/#', '/', $_SERVER['HTTP_REFERER']));
}
if (isset($_GET['like']) && isset($user)) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_like` WHERE `id_komm` = '" . intval($_GET['id']) . "' AND `id_user` = '$user[id]' LIMIT 1"), 0) != 0) {
} else {
mysql_query("INSERT INTO `avatar_like` (`id_user`, `id_komm`) values('$user[id]', '" . intval($_GET['id']) . "')");
}
if (isset($user) && $user['id'] != $ank['id']) {
$msg = "[img]http://$_SERVER[HTTP_HOST]/style/img/like.png[/img] $SexOcen Ваш [url=/user/avatar_comm.php?id=$ank[id]]аватар[/url].";
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$ank[id]', '$msg', '$time')");
}
}
if (isset($_GET['unlike']) && isset($user)) {
mysql_query("DELETE FROM `avatar_like` WHERE `id_user` = '$user[id]' AND `id_komm` = '" . intval($_GET['id']) . "' LIMIT 1");
header("Location: avatar_comm.php?id=$ank[id]" . SID);
}
title();
aut();
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '/info.php?id=$ank[id]'>$ank[nick]</a> > <a href = '?'><b>Комментарии к аватару</b></a></div>";
if (!is_file(H . "/sys/avatar/$ank[id].gif") && !is_file(H . "/sys/avatar/$ank[id].jpg") && !is_file(H . "/sys/avatar/$ank[id].png")) {
echo "<div class = 'errs'>Аватар не загружен!</div>";
echo "<div class = 'razd'><a href='/info.php?id=$ank[id]'>" . img('left.png') . " $ank[nick]</a></div>";
require_once '../sys/inc/tfoot.php';
exit;
}
echo "<div class = 'razd'><center>";
avatar($ank['id'], '200');
echo "</center></div>";
echo "<div class = 'razd'>n";
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_like` WHERE `id_komm` = '$ank[id]'"), 0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_like` WHERE `id_komm` = '" . intval($_GET['id']) . "' AND `id_user` = '$user[id]' LIMIT 1"), 0) == 0) {
echo "<a href = 'avatar_comm.php?id=$ank[id]&like' class = 'add'>Нравится</a> ";
} else {
echo "<a href = 'avatar_comm.php?id=$ank[id]&unlike' class = 'addi'>Не нравится</a> ";
}
echo "<a class = 'add' href = 'avatar_like_all.php?id=$ank[id]'>" . img('like.png') . " $like</a>";
echo "</div>n";
if (isset($_POST['msg']) && isset($user)) {
$msg = $_POST['msg'];
$mat = antimat($msg);
if ($mat) {
$err[] = 'В тексте сообщения обнаружен мат: ' . $mat;
}
if (text::utf8_strlen($msg) > 1024) {
$err[] = 'Сообщение слишком длинное';
} elseif (text::utf8_strlen($msg) < 2) {
$err[] = 'Короткое сообщение';
} elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_comments` WHERE `id_user` = '$user[id]' AND `avatar_id`='$ank[id]' AND `msg` = '" . mysql_real_escape_string($msg) . "' LIMIT 1"), 0) != 0) {
$err = 'Ваше сообщение повторяет предыдущее';
} elseif (!isset($err)) {
mysql_query("INSERT INTO `avatar_comments` (id_user, time, msg, avatar_id) values('$user[id]', '$time', '" . mysql_real_escape_string($msg) . "', '$ank[id]')");
mysql_query("UPDATE `user` SET `money` = '" . ($user['money'] + 3) . "', `activity` = '" . ($user['activity'] + 3) . "' WHERE `id` = '$user[id]' LIMIT 1");
if ($user['id'] != $ank['id']) {
mysql_query("INSERT INTO `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$ank[id]', '$SexOst комментарий к Вашему [url=/user/avatar_comm.php?id=$ank[id]]Аватару[/url]', '$time')");
}
msg('Сообщение успешно добавлено');
}
}
err();
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_comments` WHERE `avatar_id`='$ank[id]'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo img('error.png') . " Нет результатов";
echo "</div>";
}
$q = mysql_query("SELECT * FROM `avatar_comments` WHERE `avatar_id`='$ank[id]' ORDER BY id DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q)) {
$ank12 = user::get_user($post['id_user']);
echo "<table class = 'razd'><tr><td class = 'icon14'>";
avatar($ank12['id'], '48');
echo "</td><td class = 'null'>";
echo "<div style = 'float:right;'>" . date::time($post['time']) . "</div>";
user($ank12['id']);
echo "<br />";
if (($user['group_access'] >= 7 || $user['id'] == $ank['id']) && isset($user)) {
echo "<div style = 'float:right;' id = 'hide'>";
echo "<a href = 'avatar_comm_del.php?id=$post[id]' class = 'add' title = 'Удалить'>" . img('del.png') . "</a>";
echo "</div>";
}
echo text::toOutput($post['msg']);
echo "</td></tr></table>n";
}
if ($k_page > 1) {
str('?id=' . $ank['id'] . '&', $k_page, $page);
}
if (isset($user)) {
echo "<form method = "post" class = 'razd' name='message' action="?id=$ank[id]&$passgen">n";
echo "Сообщение: <br />";
echo "<textarea aria-required = 'true' aria-invalid = 'false' required = 'required' name="msg"></textarea><br />n";
echo "<button class = 'action'>";
echo "<span class = 'label'><span class = 'icon icon44' /> Добавить</span>";
echo "</button></form>";
}
echo "<div class = 'razd'>" . img('left.png') . " <a href='/info.php?id=$ank[id]'>$ank[nick]</a></div>";
require_once '../sys/inc/tfoot.php';