Файл: foto/inc/komm.php
Строк: 76
<?php
if (!isset($user) && !isset($_GET['id_user'])) {
header("Location: /foto/?" . SID);
exit;
}
if (isset($user)) {
$ank['id'] = $user['id'];
}
if (isset($_GET['id_user'])) {
$ank['id'] = intval($_GET['id_user']);
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ank[id]' LIMIT 1"), 0) == 0) {
header("Location: /foto/?" . SID);
exit;
}
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));
$gallery['id'] = intval($_GET['id_gallery']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery` WHERE `id` = '$gallery[id]' AND `id_user` = '$ank[id]' LIMIT 1"), 0) == 0) {
header("Location: /foto/$ank[id]/?" . SID);
exit;
}
$gallery = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery` WHERE `id` = '$gallery[id]' AND `id_user` = '$ank[id]' LIMIT 1"));
$foto['id'] = intval($_GET['id_foto']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id` = '$foto[id]' LIMIT 1"), 0) == 0) {
header("Location: /foto/$ank[id]/$gallery[id]/?" . SID);
exit;
}
$foto = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery_foto` WHERE `id` = '$foto[id]' LIMIT 1"));
$set['title'] = $ank['nick'] . ' - ' . $gallery['name'] . ' - ' . $foto['name'] . ' - Комментари'; // заголовок страницы
require_once '../sys/inc/thead.php';
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 `gallery_komm` WHERE `id_foto` = '$foto[id]' AND `id_user` = '$user[id]' AND `msg` = '" . mysql_escape_string($msg) . "' LIMIT 1"), 0) != 0) {
$err = 'Ваше сообщение повторяет предыдущее';
} elseif (!isset($err)) {
if ($ank['id'] != $user['id']) {
mysql_query("INSERT INTO `tape` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$user[nick] оставил [url=/foto/$ank[id]/$gallery[id]/komm/$foto[id]/]комментарий к вашему фото[/url]', '$time')");
}
mysql_query("INSERT INTO `gallery_komm` (`id_foto`, `id_user`, `time`, `msg`) values('$foto[id]', '$user[id]', '$time', '" . mysql_real_escape_string($msg) . "')");
mysql_query("UPDATE `user` SET `money` = '" . ($user['money'] + 3) . "', `activity` = '" . ($user['activity'] + 2) . "' WHERE `id` = '$user[id]' LIMIT 1");
msg('Сообщение успешно добавлено');
}
}
err();
aut();
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id_foto` = '$foto[id]'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if (isset($user)) {
echo "<form method='post' class = 'foot' name='message' action='?$passgen'>n";
echo "Сообщение:<br />";
echo text::auto_bb('message', 'msg');
echo L . "<textarea name="msg"></textarea><br />n";
echo "<button class = 'btn'>";
echo "<img src = '/style/icons/tick.png' /> Отправить";
echo "</button></form>n";
}
if ($k_post == 0) {
echo "<table class = 'foot'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет комментариев";
echo "</td></tr></table>";
}
$q = mysql_query("SELECT * FROM `gallery_komm` WHERE `id_foto` = '$foto[id]' ORDER BY `id` ASC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q)) {
$ank2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_user]' LIMIT 1"));
echo "<table class = 'foot'><tr><td class = 'icon14'>";
avatar($ank2['id'], '48');
echo " </td><td class='null'>n";
user($ank2['id']);
echo "<br /><img src = '/style/icons/time.png' /> " . vremja($post['time']) . "<br />";
echo text::toOutput($post['msg']) . "<br />n";
echo "</td></tr></table>n";
}
if ($k_page > 1) {
str('?', $k_page, $page);
}
echo "<div class="foot">n";
echo "<img src = '/style/icons/left.png' /> <a href='/foto/$ank[id]/$gallery[id]/$foto[id]/'>К фотографии</a><br />n";
echo "<img src = '/style/icons/left.png' /> <a href='/foto/$ank[id]/$gallery[id]/'>К фотографиям</a><br />n";
echo "<img src = '/style/icons/left.png' /> <a href='/foto/$ank[id]/'>К фотоальбомам</a><br />n";
echo "</div>n";
require_once '../sys/inc/tfoot.php';
exit;