<?php
	require dirname(__FILE__).'/include/common.inc.php';
	require dirname(__FILE__).'/include/admin/content.class.php';
	$id=intval($id);
	if(!$id)exit('Bad request!');
	$c=new content();
	
	if($action=='up')
	{
		$db->query("UPDATE `".DB_PRE."content` SET `".DB_PRE."content`.`digups`=`".DB_PRE."content`.`digups`+1 WHERE `".DB_PRE."content`.`id`={$id}",true);
		$digups=$c->getfield($id,'digups');
		echo $digups;
	}
	elseif($action=='down')
	{
		$db->query("UPDATE `".DB_PRE."content` SET `".DB_PRE."content`.`digdowns`=`".DB_PRE."content`.`digdowns`+1 WHERE `".DB_PRE."content`.`id`={$id}",true);
		$digdowns=$c->getfield($id,'digdowns');
		echo $digdowns;
	}
	elseif($action=='cup')
	{
		$db->query("UPDATE `".DB_PRE."comment` SET `".DB_PRE."comment`.`support`=`".DB_PRE."comment`.`support`+1 WHERE `".DB_PRE."comment`.`id`={$id}",true);
		$r=$db->fetch_one("SELECT `".DB_PRE."comment`.`support` FROM `".DB_PRE."comment` WHERE `".DB_PRE."comment`.`id`={$id}");
		echo $r['support'];
	}
	elseif($action=='cdown')
	{
		$db->query("UPDATE `".DB_PRE."comment` SET `".DB_PRE."comment`.`against`=`".DB_PRE."comment`.`against`+1 WHERE `".DB_PRE."comment`.`id`={$id}",true);
		$r=$db->fetch_one("SELECT `".DB_PRE."comment`.`against` FROM `".DB_PRE."comment` WHERE `".DB_PRE."comment`.`id`={$id}");
		echo $r['against'];
	}
	exit();
?>