Файл: foto/func/photo.view.php
Строк: 155
<?php
if (isset($user)) {
mysql_query("UPDATE `discussions` SET `count` = '0' WHERE `id_user` = '$user_id' AND `type` = 'foto' AND `id_sim` = '$photo_id' LIMIT 1");
mysql_query("UPDATE `notification` SET `read` = '1' WHERE `type` = 'foto_komm' AND `id_user` = '$user_id' AND `id_object` = '$photo_id'");
}
if (isset($user) && isset($_GET['act'])) {
if ($user['id'] == $ank['id']) {
if ($_GET['act'] == 'avatar') {
mysql_query("UPDATE `gallery_foto` SET avatar = '0' WHERE id_user = '$user_id'");
mysql_query("UPDATE `gallery_foto` SET avatar = '1' WHERE id = '$photo_id' LIMIT 1");
$_SESSION['message'] = 'Аватар успешно установлен';
header('Location: ?');
exit;
}
}
}
if (isset($_POST['msg'])) {
if (!isset($user)) {
$err[] = 'Вы не авторизованы';
}
$msg = $_POST['msg'];
if (strlen2($msg) > 1024 ) {
$err[] = 'Сообщение слишком длинное';
}
elseif (strlen2($msg) < 2 ) {
$err[] = 'Короткое сообщение';
}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id_foto` = '$photo_id' AND `id_user` = '$user_id' AND `msg` = '" . my_esc($msg) . "' LIMIT 1"), 0) != 0) {
$err[] = 'Ваше сообщение повторяет предыдущее';
}
if(!isset($err)) {
if (isset($ank_reply['id'])) {
$notifiacation = mysql_fetch_assoc(mysql_query("SELECT * FROM `notification_set` WHERE `id_user` = '" . $ank_reply['id'] . "' LIMIT 1"));
if ($notifiacation['komm'] == 1 && $ank_reply['id'] != $user['id'])
mysql_query("INSERT INTO `notification` (`avtor`, `id_user`, `id_object`, `type`, `time`)
VALUES ('$user[id]', '$ank_reply[id]', '$photo_id', 'foto_komm', '$time')");
}
$ph->get_disc($user_id, $ank_id, $photo_id, $gallery_id);
mysql_query("INSERT INTO `gallery_komm` (`id_foto`, `id_user`, `time`, `msg`) values('$photo_id', '$user_id', '$time', '" . my_esc($msg) . "')");
$_SESSION['message'] = 'Сообщение успешно добавлено';
header('Location: ?page=' . $pageEnd);
exit;
}
}
$rating = mysql_fetch_assoc(mysql_query("
SELECT SUM(IF(`like` = 6, 1, 0)) AS 's', IF(id_user = '$user_id', `like`, 0) AS 'i'
FROM `gallery_rating`
WHERE `id_foto` = $photo_id
"));
if (isset($user) && $user['id'] != $ank['id'])
{
if (isset($_GET['rating']) && $_GET['rating'] > 0 && $_GET['rating'] < 7 && !$rating['i'])
{
$l = (int) $_GET['rating'];
$likes = array(1 => -3, 2 => -1, 3 => 0, 4 => 2, 5 => 3, 6 => 5);
$c = mysql_result(mysql_query("SELECT COUNT(*) FROM `user_set` WHERE `id_user` = '$user[id]' AND `ocenka` > '$time'"), 0);
if ($c == 0 && $l == 6) {
$_SESSION['message'] = 'Необходимо активировать услугу';
header("Location: /user/money/plus5.php");
exit;
}
mysql_query("INSERT INTO `gallery_rating` (`id_user`, `id_foto`, `like`, `time`, `avtor`)
values('$user[id]', '$photo[id]', '$l', '$time', $photo[id_user])");
mysql_query("UPDATE `gallery_foto` SET `rating` = `rating` + '$likes[$l]' WHERE `id` = '$photo[id]' LIMIT 1");
$_SESSION['message'] = 'Оценка успешно поставлена';
header("Location: ?");
exit;
}
}
$favorite = mysql_fetch_assoc(mysql_query("
SELECT COUNT(id) AS 'cnt', IF(id_user = '$user_id', 1, 0) AS 'i'
FROM mark_foto
WHERE id_foto = $photo_id
"));
if (isset($user) && isset($_GET['favorite'])) {
if (!$favorite['i']) {
mysql_query("INSERT INTO `mark_foto` (`id_foto`, `id_user`, `time`) VALUES ('$photo_id', '$user_id', '$time')");
$_SESSION['message'] = 'Фото добавлено в закладки';
} else {
mysql_query("DELETE FROM `mark_foto` WHERE `id_user` = '$user_id' AND `id_foto` = '$photo_id' LIMIT 1");
$_SESSION['message'] = 'Фото удалено из закладок';
}
header('Location: ?');
exit;
}
$set['title'] = 'Фотография - '. text($photo['name']);
include_once H.'sys/inc/thead.php';
title();
aut();
err();
?>
<div class="foot">
<img src="/style/icons/str2.gif">
<a href="/info.php?id=<?php echo $ank['id']; ?>"><?php echo $ank['nick']; ?></a> |
<a href="/foto/<?php echo $ank['id']; ?>/">Фотоальбомы</a> |
<a href="/foto/<?php echo $ank['id']; ?>/<?php echo $gallery_id; ?>/"><?php echo text($gallery['name']); ?></a> |
<b><?php echo text($photo['name']); ?></b>
</div>
<div class="nav2" style="position: relative;">
<img src="/foto/foto640/<?php echo $photo['id']; ?>.jpg" style="max-width: 70%; box-sizing: border-box;" />
<?php
if ($rating['s']) {
?>
<div style='display: inline; margin-left: -45px; vertical-align: top;'>
<img style='padding-top: 15px;' src='/style/icons/5_plus.png'/>
</div>
<?php
}
?>
</div>
<?php if (isset($user) && $ank['id'] != $user['id']) { ?>
<div class="nav2">
<?php
if (!$rating['i']) {
for($i = 6; $i >= 1; $i--)
{
?><a href="?rating=<?php echo $i; ?>"><img src="/style/icons/<?php echo $i; ?>.png" /></a><?php
}
} else {
?>
Ваша оценка <img src="/style/icons/<?php echo $rating['i']; ?>.png" />
<?
}
?>
</div>
<?php } ?>
<div class="nav1">
<img src="/style/icons/fav.gif" alt="*" />
<?php if (isset($user)) { ?>
<?php if (!$favorite['i']) { ?>
<a href="?favorite=1">Добавить в закладки</a><br />
<?php } else { ?>
<a href="?favorite=0">Удалить из закладок</a><br />
<?php } ?>
<?php } ?>
В закладках у (<?php echo $favorite['cnt']; ?>) чел.
</div>
<div class="c2" style="text-align: center;">
<?php
$cnt = mysql_fetch_assoc(mysql_query("
SELECT COUNT(ph.id) AS 'cnt',
SUM(IF(ph.id > '$photo_id', 1, 0)) AS 'left',
SUM(IF(ph.id < '$photo_id', 1, 0)) AS 'right',
(SELECT id FROM gallery_foto WHERE id > $photo_id AND id_gallery = $gallery_id ORDER BY id ASC LIMIT 1) AS 'id_left',
(SELECT id FROM gallery_foto WHERE id < $photo_id AND id_gallery = $gallery_id ORDER BY id DESC LIMIT 1) AS 'id_right'
FROM gallery_foto AS ph
WHERE ph.id_gallery = '$gallery_id'
"));
?>
<span class="page">
<?php echo ($cnt['left'] ? '<a href="/foto/'.$ank_id.'/'.$gallery_id.'/'.$cnt['id_left'].'/">« Пред.</a>' : '« Пред.'); ?>
</span>
(<?php echo ($cnt['left'] + 1); ?> из <?php echo ($cnt['cnt']); ?>)
<span class="page">
<?php echo ($cnt['right'] ? '<a href="/foto/'.$ank_id.'/'.$gallery_id.'/'.$cnt['id_right'].'/">След. »</a>' : 'След. »'); ?>
</span>
</div>
<div class="nav2">
<img src="/style/icons/d.gif" />
<a href="/foto/foto0/<?php echo $photo['id']; ?>.jpg" download>Скачать</a>
(<?php echo size_file(filesize(H.'sys/gallery/foto/'.$photo_id.'.jpg')); ?>)
</div>
<?php
if (isset($user) && ($ank['id'] == $user['id'] || user_access('foto_foto_edit'))) {
?>
<div class="nav1">
<?php if ($ank['id'] == $user['id']) { ?>
<a href="?act=avatar">
<img src="/style/icons/tick.png" /> Сделать главной
</a>
<br />
<a href="?func=photo.effects">
<img src="/style/icons/application_view_tile.png" /> Фоторедактор
</a>
<br />
<?php } ?>
<a href="?func=photo.edit">
<img src="/style/icons/cog.png" /> Параметры
</a>
<br />
<a href="?func=photo.delete">
<img src="/style/icons/photo_delete.png" /> Удалить
</a>
</div>
<?php
}
?>
<div class="foot">
Комментарии
</div>
<?
$k_post = mysql_result(mysql_query("SELECT COUNT(*)
FROM gallery_komm
WHERE id_foto = $photo_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) {
?>
<div class="mess comments_empty">Cписок комментариев пуст</div>
<?php
} else {
?>
<div id="comments" class="menus">
<div class="webmenu">
<a href="?page=<?php echo $page; ?>&sort=1" class="<?php echo ($user['sort'] == 1 ? 'activ' : ''); ?>">Внизу</a>
</div>
<div class="webmenu">
<a href="?page=<?php echo $page; ?>&sort=0" class="<?php echo ($user['sort'] == 0 ? 'activ' : ''); ?>">Вверху</a>
</div>
</div>
<?php
}
$q = mysql_query("SELECT *
FROM gallery_komm AS pk
WHERE pk.id_foto = $photo_id
ORDER BY pk.time DESC
LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q)) {
$anketa = user::get_user($post['id_user']);
?>
<div class="nav<?php echo ($num % 2 ? 1 : 2); ?>">
<?php echo $anketa['icon'] . $anketa['link'] . $anketa['medal'] . $anketa['online']; ?>
<?php if (isset($user) && $user['id'] != $post['id_user']) { ?>
<a href="?page=<?php echo $page; ?>&response=<?php echo $post['id_user']; ?>">[*]</a>
<?php } ?>
<?php echo '(' . vremja($post['time']) . ')'; ?><br />
<?php echo output_text($post['msg']); ?>
<?php if (isset($user) && ($ank['id'] == $user['id'] || user_access('foto_komm_del'))) { ?>
<div class="right">
<a href="?func=comments.delete&uid=<?php echo $post['id']; ?>&page=<?php echo $page; ?>">
<img src="/style/icons/delete.gif" alt="*" title="Удалить комментарий">
</a>
</div>
<?php } ?>
</div>
<?php
$num++;
}
if ($k_page > 1) {
str('?', $k_page, $page);
}
if (isset($user)) {
?>
<form method="post" name="message" action="?page=<?php echo $pageEnd; ?>&<?php echo REPLY; ?>">
<?php if (is_file(H.'style/themes/'.$set['set_them'].'/altername_post_form.php')) {
include_once H.'style/themes/'.$set['set_them'].'/altername_post_form.php';
} else {
echo $tPanel . '<textarea name="msg">' . $insert . '</textarea><br />';
}
?>
<input value="Отправить" type="submit" />
</form>
<?php
}
?>
<div class="foot">
<img src="/style/icons/str2.gif">
<a href="/info.php?id=<?php echo $ank['id']; ?>"><?php echo $ank['nick']; ?></a> |
<a href="/foto/<?php echo $ank['id']; ?>/">Фотоальбомы</a> |
<a href="/foto/<?php echo $ank['id']; ?>/<?php echo $gallery_id; ?>/"><?php echo text($gallery['name']); ?></a> |
<b><?php echo text($photo['name']); ?></b>
</div>