View file fotov4/foto/collections/collections_edit.php

File size: 6.01Kb
<?

if (isset($user) && $user['id'] == $ank['id'])
{

if (isset($_GET['edit']) && $_GET['edit']=='rename'){
	
	if (isset($_POST['cfms']) && isset($_POST['name']))
	{
	
	$name = $_POST['name'];

	if (strlen2($name) < 3)$err = 'Название коллекции слишком короткое.';
	if (strlen2($name) > 32)$err = 'Название коллекции слишком длинное [max 32 симв.]';
	$name = my_esc($name);
		
		
	if (!isset($err))
	{
        if (!isset($_POST['who']) || $_POST['who'] == NULL || !is_numeric($_POST['who']) || $_POST['who'] < 0 || $_POST['who'] > 2)
        {
            $kat['who'] = 0;
        } else {
            $kat['who'] = abs(intval($_POST['who']));
        }
        	$kat['name'] = $name;
		mysql_query("UPDATE `gallery_collect` SET `name` = '".$kat['name']."', `who` = '".$kat['who']."' WHERE `id` = '".$kat['id']."' LIMIT 1");
		
		$_SESSION['message'] = 'Коллекция '.my_esc($_POST['name']).' успешно сохренена. ';
		header("Location: /foto/collections/".$ank['id']."/".$kat['id']."/");
		exit;
	}
	}
	
err();

?>

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

<form action="?edit=rename" method="post">
<div class="wrapper"> 
		
<div class="block pdb"  style="border-bottom:0;">   
		
<div>  
<label class="lbl">  Название коллекции:   (max 32)</label>    
<div class="input-txt_wrapper">  
<input class="input-txt" name="name" value="<?= text($kat['name'])?>" maxlength="32" type="text">  
</div>    
</div> 

		
</div> 
		
<div>
<div class="vlight_border_bottom stnd_padd pdb vlight_border_bottom"> <label class="lbl">Могут смотреть:</label> </div>

<div> 
<label for="am_na_0_3" class="t-block_item stnd_padd vlight_border_bottom"> 
<input name="who" id="am_na_0_3" value="0" class="m"<?=($kat['who'] == 0 ? ' checked="checked"' : null)?> type="radio"> 
<img class="m p16" src="/foto/style/ico/ac_all_darkblue.png" alt="Все"> <span class="m">&nbsp;Все</span> 
</label> 
</div>

<div> 
<label for="am_oo_0_3" class="t-block_item stnd_padd vlight_border_bottom"> 
<input name="who" id="am_oo_0_3" value="1" class="m"<?=($kat['who'] == 1 ? ' checked="checked"' : null)?> type="radio"> 
<img class="m p16" src="/foto/style/ico/ac_user_red.png" alt="Только я"> <span class="m">&nbsp;Только я</span> 
</label> 
</div>

<div> 
<label for="am_fo_0_3" class="t-block_item stnd_padd vlight_border_bottom"> 
<input name="who" id="am_fo_0_3" value="2" class="m"<?=($kat['who'] == 2 ? ' checked="checked"' : null)?> type="radio"> 
<img class="m p16" src="/foto/style/ico/ac_friends_green.png" alt="Мои друзья"> <span class="m">&nbsp;Мои друзья</span> 
</label> 
</div>
</div> 
		


	
		
<table class="table__wrap table__links"> <tbody><tr> 
<td class="table__cell" width="50%"> <!-- --><!-- --><!-- --><!-- -->
<button name="cfms" value="Сохранить" class="  link  blue full is_final    " id="cfms">
<img src="/foto/style/ico/ok_blue.png" alt="" class="m"> <span class="m">Сохранить</span><!-- --></button><!-- --><!-- --> 
</td> 
<td class="table__cell table__cell_last" width="50%">     
<a href="/foto/<?= $ank['id']?>/" class="link -full          "> <span>Отменить</span>  </a>  
</td> 
</tr> </tbody></table>
		
</div>
</form>

<div class="wrapper t_center">     
<a href="?act=delete" class="link -full  red      "> <span><!--     --><img src="/foto/style/ico/delete.png" style="padding: 0;" alt=""> <!--   --><span>Удалить коллекцию</span><!--    --></span>  </a>    
</div>
	
<a href="/foto/<?= $ank['id']?>/" class="link darkblue return full_link">  
<img src="/foto/style/ico/arr_back.png" alt="" class="ico_arrow-back">   Назад  
</a>

<?

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

// Удаление коллекции
if ((user_access('foto_alb_del') || isset($user) && $user['id'] == $ank['id']) && isset($_GET['act']) && $_GET['act'] == 'delete')
{

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

if (isset($_GET['act']) && $_GET['act'] == 'delete' && isset($_GET['ok']))
{
	$q = mysql_query("SELECT * FROM `gallery_collect_foto` WHERE `id_kat` = '".$kat['id']."'");
	
	while ($post = mysql_fetch_assoc($q))
	{
		//mysql_query("DELETE FROM `gallery_collect_komm` WHERE `id_foto` = '$post[id]' LIMIT 1");
		mysql_query("DELETE FROM `gallery_collect_foto` WHERE `id` = '".$post['id']."' LIMIT 1");
	}
	
	mysql_query("DELETE FROM `gallery_collect` WHERE `id` = '".$kat['id']."' LIMIT 1");
	$_SESSION['message'] = 'Коллекция успешно удалена.';
	header("Location: /foto/collections/".$ank['id']."/");
	exit;
}

?>
<div class="wrapper"> 
<div class="block bord-botm t_center grey">   
<div class="t_center "> Вы действительно хотите удалить коллекцию <!-- -->
<a href="/foto/collections/<?= $ank['id']?>/<?= $kat['id']?>/" class="arrow_link break-word"><!--  -->  
<img src="/foto/style/ico/<?= $ico_names?>_small.png" class="p16" style="padding: 0;margin: 0;" alt="">  <!--  --> <span><?= text($kat['name'])?></span></a>  и все файлы из неё? </div> 
</div>   
<table class="table__wrap table__links"> <tbody><tr>  
<td class="table__cell" width="50%">     
<a href="?act=delete&amp;ok" class="link -full    blue      "> <span><!--     --><img src="/foto/style/ico/ok_blue.png" alt="" class="m"> <!--   --><span class="m">Да</span><!--    --></span>  </a>    
</td>  
<td class="table__cell table__cell_last" width="50%">     
<a href="/foto/collections/<?= $ank['id']?>/<?= $kat['id']?>/" class="link -full          "> <span>Отмена</span>  </a>    
</td>  
</tr> </tbody></table>    
</div>
<a href="/foto/collections/<?= $ank['id']?>/<?= $kat['id']?>/?edit=rename" class="link darkblue return full_link">  
<img src="/foto/style/ico/arr_back.png" alt="" class="ico_arrow-back">   Назад  
</a>
<?
include_once H.'sys/inc/tfoot.php';
exit;	
}

?>