Файл: modules/foto/inc/user_gallery_show.php
Строк: 92
<?php
/* DCMS S (Special)
* Версия файла 0.0.1
* Дата последнего редактирования 12.11.2015
* Модифицировал densnet
*/
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']);
}
$ank = user::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: /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"));
$set['title'] = $ank['nick'] . ' - ' . $gallery['name'] . ' - Фотоальбом'; // заголовок страницы
require_once H . 'sys/inc/thead.php';
title();
aut();
err();
include 'inc/gallery_show_act.php';
if ($ank['level'] < $user['level'] || isset($user) && $ank['id'] == $user['id']) {
$umodd = 1;
}
if (isset($_POST['password'])) {
setcookie("passfoto[$gallery[id]]", $_POST['password']);
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)) {
$lock = "key";
} else {
echo "<div class = 'alert alert-danger'>";
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 `friends` WHERE (`user` = '$user[id]' AND `friends` = '$ank[id]') OR (`user` = '$ank[id]' AND `friends` = '$user[id]')"), 0) != 0) {
$lock = "key";
} else {
echo "<div class = 'alert alert-danger'>";
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)) {
$lock = "key";
} else {
if (isset($_POST['password']) && $_POST['password'] != $gallery['password']) {
$err[] = "Пароль неправильный";
}
err();
echo "<form class = 'comm' method='post'>";
echo "Чтобы просмотреть фотоальбом, введите пароль:<br />n";
echo "<input type='text' class='form-control' name='password'/><br />n";
echo "<button class = 'btn btn-success'>Далее</button>";
echo "</form>";
require_once H . 'sys/inc/tfoot.php';
exit;
}
} elseif ($gallery['access'] == 'auth') {
if (isset($user)) {
$lock = "key";
} else {
echo "<div class = 'alert alert-danger'>";
echo "Фотоальбом доступен только авторизованным пользователям!</div>";
require_once H . 'sys/inc/tfoot.php';
exit;
}
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$gallery[id]'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
echo "<div class='panel panel-default'>";
echo "<div class='panel-heading'>";
include 'inc/gallery_show_form.php';
echo "<div style = 'font-size: 18px;font-weight: bold;'>Фотографии <span class='badge'>$k_post</span></div>";
echo "</div>";
echo "<div class='panel-body'>";
if ($k_post == 0) {
echo "<div class = 'alert alert-danger'>";
echo "<span class='glyphicon glyphicon-warning-sign'></span> Нет результатов";
echo "</div>";
}
$q = mysql_query("SELECT * FROM `gallery_foto` WHERE `id_gallery` = '$gallery[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
echo "<table class = 'comm'><tr><td class = 'icon14'>";
while ($post = mysql_fetch_assoc($q)) {
echo "<a href = '" . DIR_FOTO . "$ank[id]/$gallery[id]/$post[id]/'><img class='media-object' src = '" . DIR_FOTO . "foto128/$post[id].$post[ras]' style = 'padding:1px; margin:2px; max-height: 60px; max-width:60px; border: 1px rgb(233, 234, 237) solid; vertical-align:top; background-position: center top;' alt='Фото_$post[id]' /></a>";
}
echo "</td></tr></table>n";
echo "</div></div>";
if ($k_page > 1) {
str('?', $k_page, $page);
}
echo "<div class = 'comm'><a href = '" . DIR_FOTO . "$ank[id]/'><span class='glyphicon glyphicon-arrow-left'></span> К фотоальбомам</a></div>";
require_once H . 'sys/inc/tfoot.php';
exit;