Файл: modules/foto/inc/user_gallery.php
Строк: 246
<?php
/* DCMS Special
* Дата последнего редактирования 25.09.2016
* Модифицировал densnet
*/
if (!isset($user) && !isset($_GET['id_user'])) {
header("Location: " . DIR_FOTO . "?" . SID);
exit;
}
if (isset($user)) {
$ank['id'] = $user['id'];
}
if (isset($_GET['id_user'])) {
$ank['id'] = intval($_GET['id_user']);
}
$ank = get_user($ank['id']);
if (!$ank) {
header("Location: " . DIR_FOTO . "?" . SID);
exit;
}
$set['title'] = $ank['nick'] . ' - ' . lang('Фотоальбомы'); // заголовок страницы
require_once H . 'sys/inc/thead.php';
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery` WHERE `id_user` = '$ank[id]' AND `name` = 'Личные фото'"), 0) == 0) {
mysql_query("INSERT INTO `gallery` (`id_user`, `name`, `my`) values('$ank[id]', 'Личные фото', '1')");
}
err();
aut();
include 'inc/gallery.php';
#Навигация
echo "<div class='list-group-item-null list-group-item-grey'><small>";
if (isset($user)) {
echo "<span style='float: right;'>n";
#Кнопка меню действий
if (IS_WEB) {
echo "<a data-toggle='modal' data-target='#albom_add'><span data-toggle='tooltip' data-placement='left' title='" . lang('Создать альбом') . "'><i class='fa fa-plus fa-fw'></i></span></a>";
} else {
echo "<a href='" . DIR_FOTO . "$user[id]/?act=create'><span title='" . lang('Создать альбом') . "'><i class='fa fa-plus fa-fw'></i></span></a>";
}
echo "</span>n";
}
echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
echo "<a href='" . DIR_FOTO . "'>" . lang('Фотоальбомы') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
echo lang('Альбомы') . " $ank[nick]";
echo "</small></div><br />";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery` WHERE `id_user` = '$ank[id]' AND `my` = '0'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$where = NULL;
$q = mysql_query("SELECT * FROM `gallery`");
while ($post = mysql_fetch_assoc($q)) {
$ank2 = get_user($post['id_user']);
if ($post['access'] == 'all' || $post['access'] == 'friends' && ($ank2['level'] < $user['level'] || isset($user) && $ank2['id'] == $user['id']) || $post['access'] == 'pass' || $post['access'] == 'friends' && (mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE (`user` = '$user[id]' AND `friends` = '$ank2[id]') OR (`user` = '$ank2[id]' AND `friends` = '$user[id]')"), 0) != 0 || $ank2['level'] < $user['level'] || isset($user) && $ank2['id'] == $user['id']) || $post['access'] == 'auth' && isset($user)) {
$where = $where . " " . ($where == NULL ? "AND (" : "OR ") . "`id` = '$post[id]'";
}
}
if ($where != NULL) {
$where = $where . ")";
}
#Всплывающее меню
echo "<div class='modal fade' id='albom_add' tabindex='-1' role='dialog' aria-hidden='true'>n";
echo "<div class='modal-dialog'>n";
echo "<div class='modal-content'>n";
echo "<div class='modal-header'>n";
echo "<button type='button' class='close' data-dismiss='modal' aria-label='Close'>";
echo "<span aria-hidden='true'>×</span>";
echo "<span class='sr-only'>Close</span>";
echo "</button>";
echo "<h5 class='modal-title'>" . lang('Новый альбом') . "</h5>";
echo "</div>";
$new_gallery_access = 'all';
echo "<form class='list-group-item' name='new' style='margin-top: -1px;' action='" . DIR_FOTO . "$user[id]/?act=create&ok' method='post'>";
$doc->Input('name', 'Название альбома');
$doc->Textarea('opis', 'Описание альбома');
echo lang('Доступ') . ":<br />";
echo " <label class='custom-control custom-radio'><input class='custom-control-input' value='all' name='access' type='radio' " . ($new_gallery_access == 'all' ? " checked='checked'" : null) . "><span class='custom-control-indicator'></span><span class='custom-control-description'><i class='fa fa-unlock fa-fw'></i> " . lang('Всем') . "</span></label><br />
<label class='custom-control custom-radio'><input class='custom-control-input' value='only_me' name='access' type='radio' " . ($new_gallery_access == 'only_me' ? " checked='checked'" : null) . "><span class='custom-control-indicator'></span><span class='custom-control-description'><i class='fa fa-lock fa-fw'></i> " . lang('Только мне') . "</span></label><br />
<label class='custom-control custom-radio'><input class='custom-control-input' value='auth' name='access' type='radio' " . ($new_gallery_access == 'auth' ? " checked='checked'" : null) . "><span class='custom-control-indicator'></span><span class='custom-control-description'><i class='fa fa-user fa-fw'></i> " . lang('Только авторизованным') . "</span></label><br />
<label class='custom-control custom-radio'><input class='custom-control-input' value='friends' name='access' type='radio' " . ($new_gallery_access == 'friends' ? " checked='checked'" : null) . "><span class='custom-control-indicator'></span><span class='custom-control-description'><i class='fa fa-users fa-fw'></i> " . lang('Только друзьям') . "</span></label><br />
<label class='custom-control custom-radio'><input class='custom-control-input' value='pass' name='access' type='radio' " . ($new_gallery_access == 'pass' ? " checked='checked'" : null) . "><span class='custom-control-indicator'></span><span class='custom-control-description'><i class='fa fa-key fa-fw'></i> " . lang('Только по паролю') . "</span></label><br />
";
$doc->Input('password', 'Пароль альбома', "" . htmlspecialchars($user['anketa_password']) . "");
echo "<br />";
$doc->Button('btn btn-primary btn-sm', 'create', null, 'Создать');
echo "</form>";
echo "</div>n";
echo "</div>n";
echo "</div>n";
$z = mysql_query("SELECT * FROM `gallery` WHERE `id_user` = '$ank[id]' AND `my` = '1' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
while ($posts = mysql_fetch_assoc($z)) {
$fotos = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery_foto` WHERE `id_gallery` = '$posts[id]' ORDER BY RAND()"));
echo "<table class='list-group-item-null list-group-item-info'><tr><td class='icon14'>";
if ($fotos == null) {
echo "<div class='photos'>";
echo "<div class='photos_blok'><i class='fa fa-camera fa-fw'></i> <b>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$posts[id]'"), 0) . "</b></div>";
echo "<a href='" . DIR_FOTO . "$ank[id]/$posts[id]/'><img style='width:100px;height:100px;' src='" . DIR_FOTO . "foto128/0.png' alt='" . lang('Нет фото') . "' />";
echo "</a></div>";
} else {
echo "<div class='photos'>";
echo "<div class='photos_blok'><i class='fa fa-camera fa-fw'></i> <b>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$posts[id]'"), 0) . "</b></div>";
echo "<a href='" . DIR_FOTO . "$ank[id]/$posts[id]/'>";
echo "<img style='width:100px;height:100px;' src='" . DIR_FOTO . "foto150/$fotos[id].$fotos[ras]' title='" . mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$posts[id]'"), 0) . " " . lang('фото') . "' alt='" . lang('Фото') . "_$fotos[id]' />";
echo "</a></div>";
}
echo "</td><td class='null'>n";
echo "<a href='" . DIR_FOTO . "$ank[id]/$posts[id]/'><i class='fa fa-photo fa-fw'></i> " . toOutput($posts['name']) . "</a><br />";
echo "</td></tr></table>n";
}
if ($k_post == 0) {
$doc->NoResult();
}
$q = mysql_query("SELECT * FROM `gallery` WHERE `id_user` = '$ank[id]' AND `my` = '0' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q)) {
$foto = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery_foto` WHERE `id_gallery` = '$post[id]' ORDER BY RAND()"));
echo "<table class='list-group-item-null'><tr><td class='icon14'>";
if ($foto == null) {
echo "<div class='photos'>";
echo "<div class='photos_blok'><i class='fa fa-camera fa-fw'></i> <b>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$post[id]'"), 0) . "</b></div>";
echo "<a href='" . DIR_FOTO . "$ank[id]/$post[id]/'><img style='width:100px;height:100px;' src='" . DIR_FOTO . "foto128/0.png' alt='" . lang('Нет фото') . "' />";
echo "</a></div>";
} else {
echo "<div class='photos'>";
echo "<div class='photos_blok'><i class='fa fa-camera fa-fw'></i> <b>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$post[id]'"), 0) . "</b></div>";
echo "<a href='" . DIR_FOTO . "$ank[id]/$post[id]/'>";
echo "<img style='width:100px;height:100px;' src='" . DIR_FOTO . "foto150/$foto[id].$foto[ras]' title='" . mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$post[id]'"), 0) . " " . lang('фото') . "' alt='" . lang('Фото') . "_$foto[id]' />";
echo "</a></div>";
}
echo "</td><td class='null'>n";
echo "<span class='right'>";
if ($post['access'] == 'all') {
echo "<span class='hint--left' data-hint='" . lang('Доступен всем') . "' style='color: grey;'><i class='fa fa-globe fa-fw'></i></span>";
} elseif ($post['access'] == 'only_me') {
echo "<span class='hint--left' data-hint='" . lang('Доступен только автору') . "' style='color: grey;'><i class='fa fa-lock fa-fw'></i></span>";
} elseif ($post['access'] == 'friends') {
echo "<span class='hint--left' data-hint='" . lang('Доступен только друзьям автора') . "' style='color: grey;'><i class='fa fa-users fa-fw'></i></span>";
} elseif ($post['access'] == 'pass') {
echo "<span class='hint--left' data-hint='" . lang('Доступен только по паролю') . "' style='color: grey;'><i class='fa fa-key fa-fw'></i></span>";
} elseif ($post['access'] == 'auth') {
echo "<span class='hint--left' data-hint='" . lang('Доступен только авторизованным') . "' style='color: grey;'><i class='fa fa-user fa-fw'></i></span>";
}
echo "</span>";
echo "<a href='" . DIR_FOTO . "$ank[id]/$post[id]/'><i class='fa fa-photo fa-fw'></i> " . toOutput($post['name']) . "</a><br />";
if ($post['opis'] == null) {
echo "";
} else {
if ($post['opis'] == null) {
echo lang('Без описания') . "<br />";
} else {
echo toOutput($post['opis']) . "<br />n";
}
}
echo "<small style='color:grey;'>";
echo user($ank['id']);
echo " <span title='" . date::time($post['time_create']) . "'>" . date::timek($post['time_create']) . "</span>";
echo "</small>";
echo "</td></tr></table>n";
echo "<div class='hr'></div>";
}
if ($k_page > 1) {
str('?', $k_page, $page);
}
require_once H . 'sys/inc/tfoot.php';
exit;