Файл: modules/foto/inc/user_gallery.php
Строк: 195
<?php
/* DCMS Special
* Дата последнего редактирования 19.12.2015
* Модифицировал densnet
*/
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'] = intval($_GET['id_user']);
}
$ank = get_user($ank['id']);
if (!$ank) {
header("Location: /modules/foto/?" . SID);
exit;
}
$set['title'] = $ank['nick'] . ' - Фотоальбомы'; // заголовок страницы
require_once H . 'sys/inc/thead.php';
aut();
err();
include 'inc/gallery.php';
#Навигация
echo "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='" . DIR_FOTO . "'>Фотоальбомы</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'>Альбомы $ank[nick]</a></li>";
echo "</ul>";
echo "</nav>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery` WHERE `id_user` = '$ank[id]'"), 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='card-header' style='color: grey;'><div class='bd-example'><span style='float: right;'>n";
#Кнопка меню действий
if (isset($user) && $user['id'] == $ank['id']) {
if (IS_WEB) {
echo "<a data-toggle='modal' data-target='#albom_add' href='" . DIR_FOTO . "$user[id]/?act=create'><span data-toggle='tooltip' data-placement='left' title='Создать альбом'><i class='material-icons'>add_to_photos</i></span></a>";
} else {
echo "<a href='" . DIR_FOTO . "$user[id]/?act=create'><span title='Создать альбом'><i class='material-icons'>add_to_photos</i></span></a>";
}
}
echo "</span></div>n";
echo "Фотоальбомы - $k_post</div>n";
#Всплывающее меню
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'>Новый альбом</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'>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='name' name='name' length='32' type='text' value='' class='validate'>";
echo "<label for='name'>Название альбома</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<textarea name='opis' id='opis' length='256' class='materialize-textarea'></textarea>";
echo "<label for='opis'>Описание альбома</label>";
echo "</div>";
echo "</div>";
echo "Доступ:<br />";
echo "<input class='with-gap' name='access' type='radio' " . ($new_gallery_access == 'all' ? " checked='checked'" : null) . " id='all' value='all' /><label for='all'><i class='material-icons'>public</i> Всем</label><br />";
echo "<input class='with-gap' name='access' type='radio' " . ($new_gallery_access == 'only_me' ? " checked='checked'" : null) . " id='only_me' value='only_me' /><label for='only_me'><i class='material-icons'>lock</i> Только мне</label><br />";
echo "<input class='with-gap' name='access' type='radio' " . ($new_gallery_access == 'auth' ? " checked='checked'" : null) . " id='auth' value='auth' /><label for='auth'><i class='material-icons'>person</i> Только авторизованным</label><br />";
echo "<input class='with-gap' name='access' type='radio' " . ($new_gallery_access == 'friends' ? " checked='checked'" : null) . " id='friends' value='friends' /><label for='friends'><i class='material-icons'>group</i> Только друзьям</label><br />";
echo "<input class='with-gap' name='access' type='radio' " . ($new_gallery_access == 'pass' ? " checked='checked'" : null) . " id='pass' value='pass' /><label for='pass'><i class='material-icons'>vpn_key</i> Только по паролю</label><br />";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='password' name='password' length='16' type='text' value='" . htmlspecialchars($user['anketa_password']) . "' class='validate'>";
echo "<label for='password'>Пароль альбома</label>";
echo "</div>";
echo "</div>";
echo "<button name='create' class='waves-effect waves-light btn'>Создать</button> ";
echo "</form>";
echo "</div>n";
echo "</div>n";
echo "</div>n";
if ($k_post == 0) {
echo "<div class='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<i class='material-icons'>feedback</i> Нет результатов";
echo "</div>";
}
$q = mysql_query("SELECT * FROM `gallery` WHERE `id_user` = '$ank[id]' 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 "<div class='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<table><tr><td class='icon14'>";
if ($foto == null) {
echo "<div class='photos'>";
echo "<div class='photos_blok'><i class='material-icons'>photo_camera</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='Нет фото' />";
echo "</a></div>";
} else {
echo "<div class='photos'>";
echo "<div class='photos_blok'><i class='material-icons'>photo_camera</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 . "foto128/$foto[id].$foto[ras]' title='" . mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$post[id]'"), 0) . " фото' alt='Фото_$foto[id]' />";
echo "</a></div>";
}
echo "</td><td class='null'>n";
echo "<span style='float:right;' id='hides'>";
echo "<span title='" . date::time($post['time_create']) . "' style='color:grey;'>" . date::timek($post['time_create']) . "</span>";
echo "</span>";
echo "<a href='" . DIR_FOTO . "$ank[id]/$post[id]/'><i class='material-icons'>photo_album</i> " . toOutput($post['name']) . "</a><br />";
if ($post['opis'] == null) {
echo "";
} else {
if ($post['opis'] == null) {
echo 'Без описания<br />';
} else {
echo toOutput($post['opis']) . "<br />n";
}
}
if ($post['access'] == 'all') {
echo "<i class='material-icons'>public</i> Доступен всем";
} elseif ($post['access'] == 'only_me') {
echo "<i class='material-icons'>lock</i> Доступен только автору";
} elseif ($post['access'] == 'friends') {
echo "<i class='material-icons'>group</i> Доступен только друзьям автора";
} elseif ($post['access'] == 'pass') {
echo "<i class='material-icons'>vpn_key</i> Доступен только по паролю";
} elseif ($post['access'] == 'auth') {
echo "<i class='material-icons'>person</i> Доступен только авторизованным";
}
echo "<br />";
echo user($ank['id']);
echo "</td></tr></table></div>n";
}
if ($k_page > 1) {
echo "<div class='list-group-item'>";
str('?', $k_page, $page);
echo "</div>";
}
require_once H . 'sys/inc/tfoot.php';
exit;