Файл: modules/foto/inc/user_show_foto.php
Строк: 198
<?php
/* Мод "Фотоальбомы"
* Версия v0.0.1
* Дата последнего редактирования 08.01.2015
* Двиг DCMS Special
* Модифицировал densnet
* Файл user_show_foto.php
* Описание: выводит фото
*/
if (!isset($user) && !isset($_GET['id_user'])) {
header("Location: /modules/foto/?" . SID);
exit;
}
if (isset($user)) {
$ank['id'] = $user['id'];
}
if (isset($_GET['id_user'])) {
$ank['id'] = $_GET['id_user'];
}
$ank = user::get_user($ank['id']);
if (!$ank) {
header("Location: /modules/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: /modules/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: /modules/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: /modules/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: /modules/foto/$ank[id]/$gallery[id]/$foto[id]/?page=" . intval($_GET['page']));
exit;
}
}
$set['title'] = $ank['nick'] . ' - ' . $gallery['name'] . ' - ' . $foto['name']; // заголовок страницы
require_once H . '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: ?");
}
}
title();
aut();
err();
if (isset($_POST['password'])) {
$pass = $_POST['password'];
setcookie("passfoto[$gallery[id]]", $pass);
if (isset($_POST['password']) && $_POST['password'] == $gallery['password']) {
header("Location:?enter=ok");
}
}
if ($gallery['access'] == 'only_me') {
if ($ank['id'] == $user['id'] && isset($user) || isset($umodd)) {
} else {
echo "<div class = 'errs'>";
echo "Фото доступно только автору!";
echo "</div>";
require_once H . 'sys/inc/tfoot.php';
exit;
}
} elseif ($gallery['access'] == 'friends') {
if ($ank['id'] == $user['id'] && isset($user) || isset($umodd) || mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE (`user` = '$user[id]' AND `frend` = '$ank[id]') OR (`user` = '$ank[id]' AND `frend` = '$user[id]')"), 0) != 0) {
} else {
echo "<div class = 'errs'>";
echo "Фото доступно только друзьям автора!";
echo "</div>";
require_once H . 'sys/inc/tfoot.php';
exit;
}
} elseif ($gallery['access'] == 'pass') {
if (isset($_COOKIE['passfoto'][$gallery['id']]) && $_COOKIE['passfoto'][$gallery['id']] == $gallery['password'] || $ank['id'] == $user['id'] && isset($user) || isset($umodd)) {
} else {
if (isset($_POST['password']) && $_POST['password'] != $gallery['password']) {
$err[] = "Пароль неправильный";
}
err();
echo "<form class = 'razd' method = 'post'>n";
echo "Чтобы просмотреть фото, введите пароль:<br />n";
echo "<input type = 'text' name = 'password'/><br />n";
echo "<button class = 'button sign-ins'>Далее</button>";
echo "</form>";
require_once H . 'sys/inc/tfoot.php';
exit;
}
} elseif ($gallery['access'] == 'auth') {
if (isset($user)) {
} else {
echo "<div class = 'errs'>";
echo "Фото доступно только для авторизованных пользователей!";
echo "</div>";
require_once H . 'sys/inc/tfoot.php';
exit;
}
}
$user['ank_age'] = 0;
if ($user['ank_d_r'] != NULL && $user['ank_m_r'] != NULL && $user['ank_g_r'] != NULL) {
$user['ank_age'] = date("Y") - $user['ank_g_r'];
if (date("n") < $user['ank_m_r']) {
$user['ank_age'] = $user['ank_age'] - 1;
} elseif (date("n") == $user['ank_m_r'] && date("j") < $user['ank_d_r']) {
$user['ank_age'] = $user['ank_age'] - 1;
}
}
if (!isset($_SESSION['foto_adult']) && !isset($_GET['passed']) && $user['ank_age'] < 18 && $foto['adult'] == 1) {
if (!isset($user)) {
echo "<div class = 'razd'>";
echo "Фото с меткой <font color = 'red'>(+18)</font> доступны только для авторизованных пользователей. Пожалуйста, пройдите процесс <a href='/aut.php'>авторизации</a> или <a href='/reg.php'>регистрации</a>";
echo "</div>";
require_once H . 'sys/inc/tfoot.php';
exit;
}
echo "<div class = 'razd'>";
echo "Внимание! Это содержимое только для взрослых!<br/>После нажатия, Ваш выбор будет отправлен администрации<br/>";
echo "Нажимая ДА, Вы подтверждаете, что Вам 18 или более лет.<br/>Если Вам менее 18 лет - нажмите НЕТ.<br /><br />";
echo "<a class = 'count' href = '?passed'>Да</a> <a class = 'count' href = '/modules/foto/$ank[id]/'>Нет</a>";
echo "</div>";
require_once H . 'sys/inc/tfoot.php';
exit;
}
if (!isset($_SESSION['foto_adult']) && isset($_GET['passed']) && $foto['adult'] == 1) {
$_SESSION['foto_adult'] = 1;
}
echo "<div style = 'font-size: 18px;font-weight: bold;' class = 'razd'>" . img24('image.png') . " Фотография ";
echo "<span style = 'float:right;' id = 'hide'>";
echo "<a href = '" . DIR_FOTO . "foto0/$foto[id].$foto[ras]' title = 'Открыть в полном размере'>" . img16('poln.png') . "</a> ";
if ($ank['id'] == $user['id']) {
echo "<a href = '?act=avatar' title = 'Поставить на аватар'>" . img16('001.png') . "</a> ";
}
if (user::access('foto_foto_edit') && $ank['level'] > $user['level'] || isset($user) && $ank['id'] == $user['id']) {
echo "<a href = '?act=edit' title = 'Редактировать'>" . img16('set.png') . "</a> ";
echo "<a href = '?act=delete' title = 'Удалить'>" . img16('musor.png') . "</a>";
}
echo "</span></div>";
echo "<div class = 'razd' style = 'text-align: center;'>n";
if (IS_WEB) {
echo "<img class = 'show_foto' src='" . DIR_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: 450px; max-height: 450px; ' alt='$foto[name]' /><br />n";
} else {
echo "<img class = 'show_foto' src='" . DIR_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; max-height: 200px;' alt='$foto[name]' /><br />n";
}
if ($foto['opis'] != null) {
echo text::toOutput($foto['opis']) . "<br />n";
}
echo "</div><div class = 'razd'>";
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) {
echo "<a href = '?id=$foto[id]&rating=up' class = 'add' title = 'Мне нравится'>" . img16('r_up.png') . "</a>";
} else {
echo "<a href = '?id=$foto[id]&rating=down' class = 'addi' title = 'Не нравится'>" . img16('r_down.png') . "</a>";
}
echo "<a class = 'add'>$foto[rating]</a> ";
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 "<a href = '?fav=1&page=$pageEnd' class = 'add' title = 'Добавить в закладки'>" . img16('star_add.png') . "</a>";
} else {
echo "<a href = '?fav=0&page=$pageEnd' class = 'addi' title = 'Удалить из закладок'>" . img16('star_del.png') . "</a>";
}
echo "<a class = 'add'>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmark_foto` WHERE `id_foto` = '$foto[id]' LIMIT 1"), 0) . "</a>";
}
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='" . DIR_FOTO . "$ank[id]/$gallery[id]/komm/$foto[id]/'><div class = 'razd'>";
echo img16('komm.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 = text::antimat($msg);
if ($mat) {
$err[] = 'В тексте сообщения обнаружен мат: ' . $mat;
}
if (text::utf8_strlen($msg) > 10024) {
$err = 'Сообщение слишком длинное';
} elseif (text::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 `notification` (`id_user`, `id_kont`, `msg`, `time`) values('$user[id]', '$ank[id]', '$SexOst [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 "<div class = 'errs'>";
echo img16('error.png') . " Нет результатов";
echo "</div>";
}
$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 = 'razd'><tr><td class = 'icon14'>";
avatar($ank2['id'], '30');
echo " </td><td class = 'null'>n";
echo "<div style = 'float:right;' id = 'hides'>" . date::time($post['time']) . "</div><b>";
user($ank2['id']);
echo "</b><br/>";
echo text::toOutput($post['msg']);
echo "</td></tr></table>n";
}
if ($k_page > 1) {
str('?', $k_page, $page);
}
if (isset($user)) {
if ($foto['komm'] == 'all' || $foto['komm'] == 'only_me' && ($user['id'] == $ank['id'] || $user['level'] >= 3) || $foto['komm'] == 'friends' && ($ank['id'] == $user['id'] || $user['level'] >= 3 || mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE (`user` = '$user[id]' AND `frend` = '$ank[id]') OR (`user` = '$ank[id]' AND `frend` = '$user[id]')"), 0) != 0)) {
echo "<form method='post' class = 'razd' name='message' action='?$passgen'>n";
echo "<textarea aria-required = 'true' aria-invalid = 'false' required = 'required' name="msg" rows='2' style='width:70%'></textarea><br />n";
echo "<button class = 'button sign-ins'>Отправить</button>";
echo "</form>";
} else {
echo "<div class = 'errs'>";
echo "Автор ограничил круг лиц, которые могут оставлять комментарии.";
echo "</div>";
}
}
echo "<div class = 'razd'>";
echo "<a class = 'add' href = '" . DIR_FOTO . "$ank[id]/$gallery[id]/'>" . img16('left.png') . " К фотографиям</a><br /><br />";
echo "<a class = 'add' href = '" . DIR_FOTO . "$ank[id]/'>" . img16('left.png') . " К фотоальбомам</a>";
echo "</div>";
require_once H . 'sys/inc/tfoot.php';
exit;