View file news-ds/like/index.php

File size: 1.75Kb
<?
	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';

// Только для пользователей

	if (!isset($user))header("location: /index.php?");

	define ('id', isset( $_GET['id'] ) ? abs(intval($_GET['id'])) : 0);	
	define ('type', isset( $_GET['type'] ) ? abs(intval($_GET['type'])) : 0);	
	define ('s', isset( $_GET['s'] ) ? abs(intval($_GET['s'])) : 0);	
	
	$act = mysql_fetch_assoc(mysql_query("SELECT * FROM `news` WHERE `id` = '".id."' LIMIT 1"));	
	
// проверяем существует новость
	
	if (!empty($act)) {

	if (type == 0 || type == 1 ){
	
	$check = mysql_result(mysql_query("SELECT COUNT(*) FROM `like_object` WHERE `id_object` = '".id."' AND `type` = 'news' AND `id_user` = '$user[id]'"),0);
	if(empty($check)){
	mysql_query("INSERT INTO `like_object` (`id_user`, `id_object`, `type`, `like`) VALUES ('$user[id]', '".id."', 'news', '" .type. "')");
	include_once H.'sys/add/user.active.php';	
	}
	header("location: /news/".(s == 1 ? 'news/?id='.id.'':'')."".(s == 2 ? '/list/act.php?id='.$act['list'].'':'')."");
	exit;
	}else{$_SESSION['message'] = 'Ошибка'; header("location: /news/".(s == 1 ? 'news/?id='.id.'':'')."".(s == 2 ? '/list/act.php?id='.$act['list'].'':'')."");}	
	}else{$_SESSION['message'] = 'Ошибка запись не найдена'; header("location: /news/".(s == 1 ? 'news/?id='.id.'':'')."".(s == 2 ? '/list/act.php?id='.$act['list'].'':'')."");}	

?>