<?php 

	$ip = $_SERVER['REMOTE_ADDR'];
	$anketaid = $_SESSION["anketa_id"];
	$mobile_anketa_string = "mobile_anketa_".$anketaid;
	
	$platnost = 3600;
	$rozdiel = 0;
	$now = time();
	
	$query2 = "DELETE from mobile_anketa_kontrola WHERE cas<".($now-$platnost);
	$dba->ExecuteQuery($query2);

	$query = "SELECT ip FROM mobile_anketa_kontrola WHERE anketa='".$anketaid."' AND ip='$ip' ";
	$num = $dba->GetNums($query);
	
	$hlasoval = ($num==0) ? false : true;
	
	if (!isset($_COOKIE["mobile_hlas_anketa"+$anketaid]) && !$hlasoval && !session_is_registered($mobile_anketa_string))
	{	
		$odpoved = $_GET["odpoved"];
		$dba->Increment('mobile_anketa', $odpoved, $anketaid, 1);
		session_register("hlasoval_v_ankete");
		$_SESSION["hlasoval_v_ankete"] = $anketaid;
		SetCookie("mobile_hlas_anketa"+$anketaid, 1, 0);
		session_register($mobile_anketa_string);
		$_SESSION[$mobile_anketa_string] = true;
		$query = "INSERT INTO mobile_anketa_kontrola (ip, cas, anketa) VALUES ('".$ip."','".$now."','".$anketaid."')";
		$dba->ExecuteQuery($query);
	}
	else 
	{
		session_register("mobile_voted");
	}
	header("location: ".$_SERVER['HTTP_REFERER']);

?>