Файл: foto/inc/user_show_foto.php
Строк: 133
<?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'] = $_GET['id_user'];
}
$ank = get_user($ank['id']);
if (!$ank) {
header("Location: /foto/?" . SID);
exit;
}
$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"));
if (isset($_GET['fav']) && $_GET['fav'] == 1) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmark_foto` WHERE `id_user` = '" . $user['id'] . "' AND `id_foto` = '" . $foto['id'] . "' LIMIT 1"), 0) == 0) {
mysql_query("INSERT INTO `bookmark_foto` (`id_foto`, `id_user`, `time`) VALUES ('$foto[id]', '$user[id]', '$time')");
msg('Фото добавлено в закладки');
header("Location: /foto/$ank[id]/$gallery[id]/$foto[id]/?page=" . intval($_GET['page']));
exit;
}
}
if (isset($_GET['fav']) && $_GET['fav'] == 0) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmark_foto` WHERE `id_user` = '" . $user['id'] . "' AND `id_foto` = '" . $foto['id'] . "' LIMIT 1"), 0) == 1) {
mysql_query("DELETE FROM `bookmark_foto` WHERE `id_user` = '$user[id]' AND `id_foto` = '$foto[id]' ");
$_SESSION['message'] = 'Фото удалено из закладок';
header("Location: /foto/$ank[id]/$gallery[id]/$foto[id]/?page=" . intval($_GET['page']));
exit;
}
}
$set['title'] = $ank['nick'] . ' - ' . $gallery['name'] . ' - ' . $foto['name']; // заголовок страницы
require_once '../sys/inc/thead.php';
if (user_access('foto_foto_edit') && $ank['level'] > $user['level'] || isset($user) && $ank['id'] == $user['id']) {
include 'inc/gallery_show_foto_act.php';
}
if (isset($user)) {
if (isset($_GET['rating']) && $_GET['rating'] == 'down') {
mysql_query("UPDATE `gallery_foto` SET `rating` = '" . ($foto['rating'] - 1) . "' WHERE `id` = '$foto[id]' LIMIT 1", $db);
mysql_query("DELETE FROM `gallery_rating` WHERE `id_user` = '$user[id]' AND `id_foto` = '$foto[id]' LIMIT 1");
header("Location: ?");
$foto = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery_foto` WHERE `id` = $foto[id] LIMIT 1"));
} elseif (isset($_GET['rating']) && $_GET['rating'] == 'up') {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_rating` WHERE `id_foto` = '$foto[id]' AND `id_user` = '$user[id]' LIMIT 1"), 0) != 0) {
} else {
mysql_query("UPDATE `gallery_foto` SET `rating` = '" . ($foto['rating'] + 1) . "' WHERE `id` = '$foto[id]' LIMIT 1", $db);
mysql_query("INSERT INTO `gallery_rating` (`id_user`, `id_foto`) values('$user[id]', '$foto[id]')", $db);
}
header("Location: ?");
}
}
err();
aut();
echo "<div class = 'blok' style='text-align: center;'>n";
if (IS_WEB) {
echo "<img class='show_foto' src='/foto/foto640/$foto[id].$foto[ras]' style = '-moz-box-shadow: 0 0 10px rgba(0,0,0,0.5);-webkit-box-shadow: 0 0 10px rgba(0,0,0,0.5);box-shadow: 0 0 10px rgba(0,0,0,0.5);border: 1px solid #CCDDED; padding: 2px; border-radius: 5px; max-width: 400px;' alt='$foto[name]' /><br />n";
} else {
echo "<img class='show_foto' src='/foto/foto640/$foto[id].$foto[ras]' style = '-moz-box-shadow: 0 0 10px rgba(0,0,0,0.5);-webkit-box-shadow: 0 0 10px rgba(0,0,0,0.5);box-shadow: 0 0 10px rgba(0,0,0,0.5);border: 1px solid #CCDDED; padding: 2px; border-radius: 5px; max-width: 200px;' alt='$foto[name]' /><br />n";
}
if ($foto['opis'] != null) {
echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($foto['opis'])))))))) . "<br />n";
}
echo "</div><div class = 'blok'>";
echo "<a href='/foto/foto0/$foto[id].$foto[ras]'>Открыть оригинал (" . size_file(filesize(H . 'sys/gallery/foto/' . $foto['id'] . '.jpg')) . ")";
echo "</a></div><div class = 'blok'>";
if (isset($user)) {
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_rating` WHERE `id_foto` = '$foto[id]'"), 0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_rating` WHERE `id_foto` = '$foto[id]' AND `id_user` = '$user[id]' LIMIT 1"), 0) == 0) {
if ($like == 0) {
echo "<img src = '/style/icons/like1.png' /><a href="?id=$foto[id]&rating=up"> Мне нравится</a> ($foto[rating]) ";
} else {
echo "<img src = '/style/icons/like1.png' /><a href="?id=$foto[id]&rating=up"> Мне нравится</a> ($foto[rating]) ";
}
} else {
if ($like == 0) {
echo "<img src = '/style/icons/like1.png' /><a href="?id=$foto[id]&rating=down"> Не нравится</a> ($foto[rating]) ";
} else {
echo "<img src = '/style/icons/like1.png' /><a href="?id=$foto[id]&rating=down"> Не нравится</a> ($foto[rating]) ";
}
}
echo "<br />";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmark_foto` WHERE `id_user` = '" . $user['id'] . "' AND `id_foto` = '" . $foto['id'] . "' LIMIT 1"), 0) == 0) {
echo "<img src='/style/icons/star1.png' /> <a href='?fav=1&page=$pageEnd'>Добавить в закладки</a>";
} else {
echo "<img src='/style/icons/star1.png' /> <a href='?fav=0&page=$pageEnd'>Удалить из закладок</a>";
}
echo " (" . mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmark_foto` WHERE `id_user` = '$user[id]' AND `id_foto` = '$foto[id]' LIMIT 1"), 0) . ")";
}
echo "</div>";
if (user_access('foto_foto_edit') && $ank['level'] > $user['level'] || isset($user) && $ank['id'] == $user['id']) {
include 'inc/gallery_show_foto_form.php';
}
echo "<a href='/foto/$ank[id]/$gallery[id]/komm/$foto[id]/'><div class = 'razd'>";
echo "<img src = '/style/icons/comment_white.png' /> Показать все комментарии (" . mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id_foto` = '$foto[id]'"), 0) . ")";
echo "</div></a>";
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");
header("Location: ?");
}
}
err();
$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 ($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 = 'blok'><tr><td class = 'icon14'>";
avatar($ank2['id'], '30');
echo " </td><td class = 'null'>n";
echo "<div class = 'right' id = 'hides'>" . vremja($post['time']) . "</div><b>";
user($ank2['id']);
echo "</b><br/>";
echo output_text($post['msg']);
echo "</td></tr></table>n";
}
if ($k_page > 1) {
str('?', $k_page, $page);
}
if (isset($user)) {
echo "<form method='post' class = 'blok' name='message' action='?$passgen'>n";
echo "<textarea aria-required = 'true' aria-invalid = 'false' required = 'required' name="msg" rows='1' style='width:70%'></textarea><br />n";
echo "<div class = 'button_blue'>";
echo "<button>Отправить</button>";
echo "</div></form>";
}
echo "<a href='/foto/$ank[id]/$gallery[id]/'><div class = 'razd'><img src = '/style/icons/left.png' /> К фотографиям</div></a>";
echo "<a href='/foto/$ank[id]/'><div class = 'razd'><img src = '/style/icons/left.png' /> К фотоальбомам</div></a>";
require_once '../sys/inc/tfoot.php';
exit;