View file fotov4/foto/inc/all_gallery.php

File size: 9.14Kb
<?
/* Бан пользователя */ 
if (isset($user) && 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;
}


$config = array(
	'q' => array(
		'type' => array(
			'Не найдено ни одного альбома!',
			'Не найдено ни одного альбома!'
			),
		'text' => (isset($_GET['q']) ? implode(' ', explode('+', text($_GET['q']))) : false)
	),
);


$act = isset($_GET['S']) ? my_esc($_GET['S']) : null;

switch ($act) {

default:

$set['title'] = 'Фотоальбомы'; // заголовок страницы

include_once H.'sys/inc/thead.php';
title();
aut();

if($_SERVER['REQUEST_METHOD'] == 'POST')
{
	if(!empty($_POST['q']) && !preg_match("#(^\ )#ui", $_POST['q']) && !preg_match("#(^\')#ui", $_POST['q']))
	{
		$_POST['q'] = implode('+', explode(' ', my_esc($_POST['q'])));
		header('Location: ?q='.$_POST['q'].'');
	}
	else
		header('Location: /foto/');
}

$sql = '';

if($config['q']['text']){
	$sql = " AND `name` like '%".$config['q']['text']."%'";
}


$set['p_str'] = '10';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery` WHERE `my` = '0'$sql"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];



?>
<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"> <span class="lc_br_text">Общие альбомы</span> 
</span>      
</div> 


<div style="margin: 10px 5px 5px;">  
<div> <div class="Tw1nGo-suggest_parent"> 
<form action="?"  method="POST">   
<div class="Tw1nGo-search suggest_parent">  <div class="Tw1nGo-relative"> 
<input class="Tw1nGo-search__input Tw1nGo-js-search__input " autocomplete="off" name="q" placeholder="Введите название альбома" value="<?= $config['q']['text'] ?>" maxlength="64" type="text">   
</div>  
<input class="Tw1nGo-search__btn Tw1nGo-js-search__submit Tw1nGo-search__btn_top" value="Найти" type="submit">   
<div class="Tw1nGo-suggest__list"></div> </div>     </form>  
</div> </div>   
</div>


<div class="tabs_block oh">    
<div class="tab_item left tab_active black"> Альбомы </div>   
<a href="/foto/?S=1" class="tab_item left"> Коллекции </a>   
<?
if ((user_access('foto_foto_edit')) || (isset($user) && $user['level'] >= 4)){
$k_complain = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto_complain` WHERE `read` = '1'"), 0);
?>
<a href="/foto/complaints.php" class="tab_item left"> Жалобы <?= ($k_complain > 0 ? '<span class="complain__cnt">'.$k_complain.'</span>' : '')?></a> 
<?
}
?>
</div>                
<?


if ($k_post == 0)
{
?>
<div class="wrapper"> <div class="block grey"> Список пуст. </div> </div>
<?
}
else{

?>
<div class="wrapper">
<?

$q = mysql_query("SELECT * FROM `gallery` WHERE `my` = '0'$sql 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('файл', 'файла', 'файлов');

$k_c = 0;
$k_c = $k_c + mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_user` = '".$post['id_user']."' AND `id_gallery` = '".$post['id']."'"), 0);

if (mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery` WHERE `id_user` = '".$post['id_user']."' AND `my` = '".$post['id']."'"), 0) > 0)
{
	$q2 = mysql_query("SELECT * FROM `gallery` WHERE `id_user` = '".$post['id_user']."' AND `my` = '".$post['id']."' ORDER BY `id` DESC");
        while ($post2 = mysql_fetch_assoc($q2))
        {
        	$k_c = $k_c + mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_gallery` = '".$post2['id']."'"), 0);
        }
}

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 = get_user($post['id_user']);

	if($config['q']['text'] !== false) {
		$post['name'] = preg_replace('/' . $config['q']['text'] . '/i', '<em class="Tw1nGo-found">$0</em>', $post['name']);
	}
	else{
		$post['name'] = text($post['name']);
	}

?>
<a class="link arrow oh" href="/foto/<?= $ank['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"> <?= $post['name']?> </b>
<div class="pd_t5"> <?= des2num($k_c, $files)?> </div>
</div>
</a> 
<?

}
?>
</div>
<?
}


if ($k_page>1)str('?'.($config['q']['text'] ?  'q='.$config['q']['text'].'&type=2&' : '').'',$k_page,$page); // Вывод страниц

?>
<a href="/" class="link darkblue return full_link">  <img src="/foto/style/ico/arr_back.png" alt="" class="ico_arrow-back">   Назад  </a>   
</div>
<?


break;

case '1':


$set['title'] = 'Колллекции'; // заголовок страницы

include_once H.'sys/inc/thead.php';
title();
aut();

if($_SERVER['REQUEST_METHOD'] == 'POST')
{
	if(!empty($_POST['q']) && !preg_match("#(^\ )#ui", $_POST['q']) && !preg_match("#(^\')#ui", $_POST['q']))
	{
		$_POST['q'] = implode('+', explode(' ', my_esc($_POST['q'])));
		header('Location: ?S=1&q='.$_POST['q'].'');
	}
	else
		header('Location: /foto/');
}

$sql = '';

if($config['q']['text']){
	$sql = " WHERE `name` like '%".$config['q']['text']."%'";
}


$set['p_str'] = '10';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_collect`$sql"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];

?>
<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"> <span class="lc_br_text">Общие коллекции</span> 
</span>      
</div> 


<div style="margin: 10px 5px 5px;">  
<div> <div class="Tw1nGo-suggest_parent"> 
<form action="?S=1"  method="POST">   
<div class="Tw1nGo-search suggest_parent">  <div class="Tw1nGo-relative"> 
<input class="Tw1nGo-search__input Tw1nGo-js-search__input " autocomplete="off" name="q" placeholder="Введите название коллекции" value="<?= $config['q']['text'] ?>" maxlength="64" type="text">   
</div>  
<input class="Tw1nGo-search__btn Tw1nGo-js-search__submit Tw1nGo-search__btn_top" value="Найти" type="submit">   
<div class="Tw1nGo-suggest__list"></div> </div>     </form>  
</div> </div>   
</div>


<div class="tabs_block oh">    
<a href="/foto/" class="tab_item left"> Альбомы </a>  
<div class="tab_item left tab_active black"> Коллекции </div>
<?
if ((user_access('foto_foto_edit')) || (isset($user) && $user['level'] >= 3)){
$k_complain = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto_complain` WHERE `read` = '1'"), 0);
?>
<a href="/foto/complaints.php" class="tab_item left"> Жалобы <?= ($k_complain > 0 ? '<span class="complain__cnt">'.$k_complain.'</span>' : '')?></a> 
<?
}
?>   
</div>                
<?


if ($k_post == 0)
{
?>
<div class="wrapper"> <div class="block grey"> Список пуст. </div> </div>
<?
}
else{

?>
<div class="wrapper">
<?

$q = mysql_query("SELECT * FROM `gallery_collect`$sql 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_collect_foto` WHERE `id_kat` = '$post[id]'"),0);
$files = array('файл', 'файла', 'файлов');


if($post['who'] == 2){
$ico_name = 'dir_friends';
}
elseif($post['who'] == 1){
$ico_name = 'dir_locked';
}
else{
$ico_name = 'dir_all';
}

// Хозяин
$ank = get_user($post['id_user']);

	if($config['q']['text'] !== false) {
		$post['name'] = preg_replace('/' . $config['q']['text'] . '/i', '<em class="Tw1nGo-found">$0</em>', $post['name']);
	}
	else{
		$post['name'] = text($post['name']);
	}

?>
<a class="link arrow oh" href="/foto/collections/<?= $ank['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"> <?= $post['name']?> </b>
<div class="pd_t5"> <?= des2num($count, $files)?> </div>
</div>
</a> 
<?

}
?>
</div>
<?
}

if ($k_page>1)str('?S=1&'.($config['q']['text'] ?  'q='.$config['q']['text'].'&type=2&' : '').'',$k_page,$page); // Вывод страниц

?>
<a href="/foto/" class="link darkblue return full_link">  <img src="/foto/style/ico/arr_back.png" alt="" class="ico_arrow-back">   Назад  </a>   
</div>
<?


break;
}

include_once H.'sys/inc/tfoot.php';

?>