View file gift/gift.php

File size: 6.15Kb
<?

	include_once '../../sys/inc/start.php';
	include_once '../../sys/inc/compress.php';
	include_once '../../sys/inc/sess.php';
	include_once '../../sys/inc/home.php';
	include_once '../../sys/inc/settings.php';
	include_once '../../sys/inc/db_connect.php';
	include_once '../../sys/inc/ipua.php';
	include_once '../../sys/inc/fnc.php';
	include_once '../../sys/inc/user.php';
	only_reg();

	define ('id', isset( $_GET['id'] ) ? abs(intval($_GET['id'])) : 0);	
	define ('delete', isset( $_GET['delete'] ) ? htmlspecialchars($_GET['id']) : null);	

	# создатель || главный админ | админ	

	$admin = ($user['group_access'] == 15 || $user['group_access'] == 9 || $user['group_access'] == 8 ? 0:1);

	$act = mysql_fetch_assoc(mysql_query("SELECT * FROM `gifts_user` WHERE `id` = '".id."' LIMIT 1"));	
	
	if (empty($act)){ $_SESSION['message'] = 'Подарок не существует.';header("Location: /".SID); exit; } 

	$ank = get_user($act['id_user']); // 
	$data = get_user($act['id_ank']); // 

	$set['title']="Подробности : Подарок : $ank[nick]";
	include_once '../../sys/inc/thead.php';
	title();
	aut();
	
	$array = array('Публичный','Личный','Анонимный');
	
	# удаление подарка $_GET
	
	if (isset($_GET['delete']) && $_GET['delete'] == 'ok'):
	if($act['id_user'] == $user['id'] || $admin == 0):
	mysql_query("DELETE FROM `gifts_user` WHERE `id` = '".$act['id']."'");		
	$_SESSION['message'] = 'Подарок удален!';
	header("Location: /user/gift/index.php?id=".$ank['id']."");
	exit;		

	else:
	$_SESSION['message'] = 'Отказано в доступе';
	header("Location: /user/gift/gift.php?id=".$act['id']."");	
	exit;	
	endif;		

	endif;	

	// публичный
	
	if ($act['type'] == 0){
	$coment = ''.($act['coment'] == null ? '':'<div class="oh pad_t_a"> <b class="grey">Сообщение:</b> '.htmlspecialchars($act['coment']).'').'';
	$avtor  = '<div class="pad_t_a"><b class="grey">Подарил:</b> '. user::avatar($data['id'],  2).''. user::nick($data['id'], 1, 1, 1).'  <br>';	
			
	}	
	
	// личный
	
	if ($act['type'] == 1){
	$coment = '
	'.($act['id_user'] == $user['id'] || $admin == 0 ? '
	'.($act['coment'] == null ? '':'<div class="oh pad_t_a"> <b class="grey">Сообщение:</b> '.htmlspecialchars($act['coment']).'').'
	':'').'';
	$avtor  = '
	'.($act['id_user'] == $user['id'] || $admin == 0 ? '
	<div class="pad_t_a"><b class="grey">Подарил:</b> '. user::avatar($data['id'],  2).''. user::nick($data['id'], 1, 1, 1).'  <br>
	':'
	<div class="pad_t_a"><b class="grey">Подарил:</b> Неизвестный  <br>
	').'';		
	}
	
	// Анонимный
	
	if ($act['type'] == 2){
	$coment = ''.($act['id_user'] == $user['id'] || $admin == 0 ? ''.($act['coment'] == null ? '':'<div class="oh pad_t_a"> <b class="grey">Сообщение:</b> '.htmlspecialchars($act['coment']).'').'':'').'';
	$avtor  = ''.($admin == 0 ? '
	<div class="pad_t_a"><b class="grey">Подарил:</b> '. user::avatar($data['id'],  2).''. user::nick($data['id'], 1, 1, 1).'  <br>
	':'
	<div class="pad_t_a"><b class="grey">Подарил:</b> Неизвестный  <br>
	').'';	
	
	}
	
	echo '
	<link rel="stylesheet" href="style.css" type="text/css" />
	<div class="main_bg">
	
	<div class="lc_br wbg font0 relative oh" id="header_path">  
	<a href="/" style="font-size:0;"> <img src="ico/home.png" alt=""> </a>     
	<span class="lc_brw"> <img src="ico/sep.png" alt="" class="lc_br_sep"> 
	<a href="/info.php?id='.$ank['id'].'">'.$ank['nick'].'</a> </span>     
	<span class="lc_brw"> <img src="ico/sep.png" alt="" class="lc_br_sep"> 
	<a href="/user/gift/index.php?id='.$ank['id'].'">Подарки</a> </span>     
	<span class="lc_brw"> 
	<img src="ico/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text">
	Подробности</span>
	</span>	
	</div>
	'.(delete != null && $act['id_user'] == $user['id'] || delete != null && $admin == 0  ? '
	<div class="wrapper"><div class="busi" style ="text-align: center;">
	Вы действительно хотите удалить подарок?</br>
	<a href = "/user/gift/gift.php?id='.$act['id'].'&delete=ok">Да</a> | <a href = "/user/gift/gift.php?id='.$act['id'].'">Нет</a>  
	</div></div>
	':'').'



	<div class="wrapper "> 
	<div class="block oh "> 
	<img src="/sys/gift/' . $act['id_gift'] . '.png" alt=""> </br>
	'.$avtor.'
	</div>
	<div class="pad_t_a"><b class="grey">Дата:</b> ' . vremja($act['time']) . '<br> 
	</div>
	<div class="pad_t_a"> <b class="grey">Тип подарка:</b> '.$array[$act['type']].'
	</div>
	'.$coment.'
	</div>

	</div></div>
	'.($act['id_user'] == $user['id'] || $admin == 0 ? '
	<div class="wrapper">  
	<div class="wbg grey">  
	<div class="last"> 
	<div class="list f-c_fll">         
	'.($act['id_user'] == $user['id'] && $act['type'] < 2 ? '
	<a href="/user/gift/categories.php?category=1&id='.$data['id'].'" class="link -full     blue c-blue  link_arrow    "> <span>
	<img src="ico/gifts_blue.png" alt="" class="m"> 
	<span class="m blue c-blue">Ответить</span>
	</span>  
	</a>   
	':'').'
	<div class="last">      
	<a href="/user/gift/gift.php?id='.$act['id'].'&delete" class="link -full     red c-red  link_arrow    "> <span>
	<img src="ico/delete.png" alt="" class="m"> 
	<span class="m red c-red">Удалить подарок</span>
	</span>  </a>    </div>    </div>    </div> </div> </div>
	':'').'

	<div id="header_path"> </div>
	<div class="lc_br wbg font0 relative oh" id="header_path">  
	<a href="/" style="font-size:0;"> <img src="ico/home.png" alt=""> </a>     
	<span class="lc_brw"> <img src="ico/sep.png" alt="" class="lc_br_sep"> 
	<a href="/info.php?id='.$ank['id'].'">'.$ank['nick'].'</a> </span>     
	<span class="lc_brw"> <img src="ico/sep.png" alt="" class="lc_br_sep"> 
	<a href="/user/gift/index.php?id='.$ank['id'].'">Подарки</a> </span>     
	<span class="lc_brw"> 
	<img src="ico/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text">
	Подробности</span>
	</span>	
	</div>
	';



	include_once '../../sys/inc/tfoot.php';
?>