File size: 9.6Kb
<?
/*
* Modul: Новая смена аватара
* Autor: Tw1nGo
* URL: https://gix.su/user/Tw1nGo
*/
include_once $_SERVER['DOCUMENT_ROOT'] . '/sys/inc/home.php';
include_once H.'sys/inc/start.php';
include_once H.'sys/inc/compress.php';
include_once H.'sys/inc/sess.php';
include_once H.'sys/inc/settings.php';
include_once H.'sys/inc/db_connect.php';
include_once H.'sys/inc/ipua.php';
include_once H.'sys/inc/fnc.php';
include_once H.'sys/inc/user.php';
only_reg();
// Если вы в бане
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `razdel` = 'foto' AND `id_user` = '$user[id]' AND (`time` > '$time' OR `view` = '0' OR `navsegda` = '1')"), 0)!=0)
{
header('Location: /ban.php?'.SID);
exit;
}
$_SESSION['avatar_sort'] = 0;
if (isset($_GET['Lt']) && ($_GET['Lt'] == '0' || $_GET['Lt'] == '1'))
{
if ($_GET['Lt'] == '0')
{
$_SESSION['avatar_sort'] = 0;
}
else if ($_GET['Lt'] == '1')
{
$_SESSION['avatar_sort'] = 1;
}
}
if (isset($_GET['avatar'])) {
$id = (int) $_GET['avatar'];
$foto = mysql_fetch_array(mysql_query("SELECT * FROM `gallery_foto` WHERE `id` = '$id'"));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_user` = '$user[id]' AND `avatar` = '1' AND `id` = '$foto[id]'"),0) == 0) {
mysql_query("UPDATE `gallery_foto` SET `avatar` = '0' WHERE `id_user` = '$user[id]'");
mysql_query("UPDATE `gallery_foto` SET `avatar` = '1' WHERE `id` = '$foto[id]' LIMIT 1");
$_SESSION['message'] = 'Фотография успешно изменена.';
header('Location: /info.php?id='.$user['id'].'');
exit;
}
else{
$_SESSION['err'] = 'Эта фотография у Вас на аватаре.';
header('Location: ?');
exit;
}
}
$set['title'] = 'Смена аватара : ' . $user['nick'];
include_once H.'sys/inc/thead.php';
title();
aut();
?>
<link rel="stylesheet" href="/foto/style/style-foto.css" type="text/css" />
<div class="foto_head_bg">
<div class="lc_br wbg font0 relative oh" id="header_path">
<a href="/" style="font-size:0;"> <img src="/foto/style/ico/home.png" alt=""> </a>
<span class="lc_brw">
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <a href="/info.php?id=<?= $user['id']?>"><?= $user['nick']?></a>
</span>
<span class="lc_brw">
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <a href="/foto/<?= $user['id']?>/">Фото</a>
</span>
<span class="lc_brw">
<img src="/foto/style/ico/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text">Смена аватара</span>
</span>
</div>
<div class="header oh"> <b class="upcs m">Выбери фото для аватара</b> </div>
<?
if (isset($_GET['Dir_id'])) {
// Определяем ид папки
$Dir = (int) $_GET['Dir_id'];
$gallery = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery` WHERE `id` = '".$Dir."' AND `id_user` = '$user[id]' LIMIT 1"));
?>
<div class="wrapper-nobg t_center break-word">
<img src="/foto/style/ico/dir.png" alt="" class="p16 m">
<b class="upcs m"><!-- --><span><?= text($gallery['name'])?></span> </b>
</div>
<?
$set['p_str'] = 16;
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_user` = '$user[id]' AND `id_gallery` = '$Dir'"),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="wrapper"> <div class="block grey"> Список пуст. </div> </div>
<?
}
else
{
?>
<div id="sz_plain">
<div>
<div class="wrapper bb0">
<!-- -->
<?
$q = mysql_query("SELECT * FROM `gallery_foto` WHERE `id_user` = '$user[id]' AND `id_gallery` = '$Dir' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
$ank = get_user($post['id_user']);
$comm = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id_foto` = '$post[id]'"),0);
?>
<div class="block oh bord-botm">
<div class="left font0 padd_right p80">
<a class="tdn gview_link" href="?avatar=<?= $post['id']?>/">
<div class="inl_bl relative"> <img src="/foto/foto128/<?= $post['id']?>.<?= $post['ras']?>" alt="" class="preview s81_80"> </div>
</a>
</div>
<div class="oh">
<?
if ($post['metka'] == 1){
?>
<span class="grey right">
<img src="/foto/style/ico/adult.png" class="m" alt="">
</span>
<?
}
?>
<a href="?avatar=<?= $post['id']?>" class="arrow_link strong_link">
<img src="/foto/style/ico/pic.png" alt="" class="m p16">
<b class="m break-word darkblue break-word"><?= text($post['name'])?></b><b class="break-word lgrey3 m break-word">.<?= $post['ras']?></b>
</a>
<div class="oh">
<?
if ($post['opis'] != null){
?>
<div class="pad_t_a black break-word"> <?= output_text($post['opis'])?> </div>
<?
}
?>
<div class="oh grey pad_t_a">
<img src="/foto/style/ico/eye.png" class="m" alt=""> <span class="m"><?= $post['count']?></span>
<?
if($comm > 0){
?>
<span class="t-padd_left"> <img src="/foto/style/ico/com.png" class="m" alt=""> <span class="m"><?= $comm?></span> </span>
<?
}
?>
<span class="right m"> <?= size_file(filesize(H.'sys/gallery/foto/'.$post['id'].'.'.$post['ras'].''))?> </span>
</div> </div>
</div>
</div>
<?
}
?>
</div>
<?
if ($k_page > 1) {
str('?Dir='.$Dir.'&', $k_page, $page);
}
}
?>
<a href="?Lt=0" class="link darkblue return full_link"> <img src="/foto/style/ico/arr_back.png" alt="" class="ico_arrow-back"> Назад </a>
<?
}
elseif($_SESSION['avatar_sort'] == 1){
// ТОЛЬКО ФОТО
?>
<div class="tabs_block oh">
<a href="?Lt=0" class="tab_item left"> Папки </a>
<div class="tab_item left tab_active black"> Все файлы </div>
</div>
<?
// Количество фоток которых выводим на одну страницу
$set['p_str'] = '16';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_user` = '$user[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="wrapper"> <div class="block"> Список пуст. </div> </div>
<?
}
else{
?>
<div class="wrapper">
<div id="sz_gallery_loader" data-type="user" class="wbg oh tiles_block tiles_wrapper">
<?
$q = mysql_query("SELECT * FROM `gallery_foto` WHERE `id_user` = '$user[id]' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
$comm = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id_foto` = '$post[id]'"),0);
$gallery = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery` WHERE `id` = '$post[id_gallery]' LIMIT 1"));
?>
<div class=" tiled_item tiled_item-200" style="padding-top: 5px;">
<div class="tiled_inner t_center relative">
<span class="relative" style="display: inline-block;max-width: 100%; width: 100%;overflow: hidden;">
<div class="inl_bl22">
<a class="tdn" href="?avatar=<?= $post['id']?>">
<img src="/foto/foto640/<?= $post['id']?>.<?= $post['ras']?>" class="preview preview99 s201_200">
<?
if ($post['metka'] == 1){
?>
<img src="/foto/style/ico/adult.png" class="p16 f_18p" alt="">
<?
}
?>
</a>
</div>
</span>
<div class="tile_descr">
<div class="pl_photo_image_info oh">
<span class="tf grey">
<?
if($post['count'] > 0){
?>
<span class="inl_bl"> <img src="/foto/style/ico/eye.png" alt="" class="m"> <span class="m"><?= $post['count']?></span> </span>
<?
}
if($comm > 0){
?>
<span class="t-padd_left"> <img src="/foto/style/ico/com.png" class="m" alt=""> <span class="m"><?= $comm?></span> </span>
<?
}
?>
</span>
</div> </div>
</div>
</div>
<?
}
?>
</div>
</div>
<?
}
if ($k_page > 1) {
str('?Lt=1&', $k_page, $page);
}
?>
<a href="?Lt=0" class="link darkblue return full_link"> <img src="/foto/style/ico/arr_back.png" alt="" class="ico_arrow-back"> Назад </a>
<?
}
// ПЕРВАЯ СТРАНИЦА
else{
?>
<div class="tabs_block oh">
<div class="tab_item left tab_active black"> Папки </div>
<a href="?Lt=1" class="tab_item left"> Все файлы </a>
</div>
<?
$set['p_str'] = '10';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery` WHERE `id_user` = '$user[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="wrapper block"> Список пуст. </div></div>
<?
}
else{
?>
<div class="wrapper">
<?
$q = mysql_query("SELECT * FROM `gallery` WHERE `id_user` = '$user[id]' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
// Cчетчик фотографий
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '$post[id]'"),0);
$files = array('файл', 'файла', 'файлов');
if($post['pass'] != null){
$ico_name = 'dir_password';
}
else{
if($post['privat'] == 1){
$ico_name = 'dir_friends';
}
elseif($post['privat'] == 2){
$ico_name = 'dir_locked';
}
else{
$ico_name = 'dir_all';
}
}
// Хозяин
$ank_id = get_user($post['id_user']);
?>
<a class="link arrow oh" href="?Dir_id=<?= $post['id']?>">
<div class="left"> <img src="/foto/style/ico/<?= $ico_name?>.png" class="m p40" alt=""> </div>
<div class="oh pre_content_wrap grey">
<b class="darkblue break-word"> <?= text($post['name'])?> </b>
<div class="pd_t5"> <?= des2num($count, $files)?> </div>
</div>
</a>
<?
}
?>
</div>
<?
if ($k_page > 1) {
str('?', $k_page, $page);
}
}
?>
<a href="/info.php?id=<?= $user['id']?>" class="link darkblue return full_link"> <img src="/foto/style/ico/arr_back.png" alt="" class="ico_arrow-back"> Назад </a>
<?
}
?>
</div>
<?
include_once H.'sys/inc/tfoot.php';
?>