Файл: user/avatar_comm.php
Строк: 128
<?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 = 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']));
}
aut();
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='err'>Аватар не загружен!</div>";
echo "<div class='foot'><a href='/info.php?id=$ank[id]'>$ank[nick]</a></div>";
require_once '../sys/inc/tfoot.php';
exit;
}
echo "<div class = 'blok'><center>";
avatar($ank['id'], '200');
echo "</center></div>";
echo "<div class = 'blok'>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` = '$ank[id]' AND `id_user` = '$user[id]' LIMIT 1"), 0) == 0) {
if ($like == 0) {
echo "<a href='/user/avatar_like.php?id=$ank[id]&like'>Мне нравится</a> ";
} else {
echo "<a href='/user/avatar_like.php?id=$ank[id]&like'>Мне нравится</a> ";
echo "<img src = '/style/icons/like.png' /> <a href = '/user/avatar_like_all.php?id=$ank[id]'>$like</a>";
}
} else {
if ($like == 0) {
echo "<a href = '/user/avatar_like.php?id=$ank[id]&unlike'><font color = 'grey'>Мне нравится</font></a> ";
} else {
echo "<a href = '/user/avatar_like.php?id=$ank[id]&unlike'><font color = 'grey'>Мне нравится</font></a> ";
echo "<img src = '/style/icons/like.png' /> <a href = '/user/avatar_like_all.php?id=$ank[id]'>$like</a>";
}
}
echo "</div>n";
if (isset($_POST['msg']) && isset($user)) {
$msg = $_POST['msg'];
$mat = antimat($msg);
if ($mat) {
$err[] = 'В тексте сообщения обнаружен мат: ' . $mat;
}
if (utf8_strlen($msg) > 1024) {
$err[] = 'Сообщение слишком длинное';
} elseif (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'] + 1) . "', `activity` = '" . ($user['activity'] + 0.02) . "' WHERE `id` = '$user[id]' LIMIT 1");
if ($user['id'] != $ank['id']) {
mysql_query("INSERT INTO `tape` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$ank[id]', '" . ($user['sex'] ? 'оставил' : 'оставила') . " комментарий к вашему [url=/user/avatar_comm.php?id=$ank[id]]Аватару[/url]', '$time')");
}
msg('Сообщение успешно добавлено +1 монета +0.02 активности');
}
}
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 "<table class = 'blok'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет комментариев";
echo "</td></tr></table>";
}
$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 = get_user($post['id_user']);
echo "<table class = 'foot'><tr><td class = 'icon14'>";
avatar($ank12['id'], '48');
echo "</td><td class='null'>n";
user($ank12['id']);
echo "<br />";
echo "<img src = '/style/icons/time.png' /> " . vremja($post['time']) . "<br />";
if (($user['group_access'] >= 7 || $user['id'] == $ank['id']) && isset($user)){
echo "<div class = 'right' id = 'hide'>";
echo "<a href='avatar_comm_del.php?id=$post[id]' title = 'Удалить'><img src = '/style/icons/cross.png' /></a>";
echo "</div>";
}
echo output_text($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 = 'blok' 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 "<div class = 'button_blue'>";
echo "<button>Добавить</button>";
echo "</div></form>";
}
echo "<div class='foot'>";
echo "<img src = '/style/icons/left.png' /> <a href='/info.php?id=$ank[id]'>$ank[nick]</a>";
echo "</div>";
require_once '../sys/inc/tfoot.php';