<?
$tempdirmod="modules/surveys/";
require(TEMPDIR.$tempdirmod."coreclass.php");
$aepublic=new CSurveys();
$aepublic->PublicInitialize();
$aepublic->RequestVariables(1);
$IPblock=$REMOTE_ADDR;
$currenttime=time();
if ($aepublic->command=="surveys1") // vote in survey
{
$aepublic->DBQuery("DELETE FROM ".$aepublic->tablesurveys[0]." WHERE surveytime<'".$currenttime."'");
if ($_COOKIE["survey".$aepublic->surveyID]) $stop=1;
$aepublic->DBQuery("SELECT * FROM ".$aepublic->tablesurveys[0]." WHERE IP='".$IPblock."' AND surveytime>'".$currenttime."' AND surveyID='".$aepublic->surveyID."'");
if ($aepublic->rowsnumber) $stop=1;
if (!$stop)
{
if ($aepublic->vote==1) $aepublic->DBQuery("UPDATE ".$aepublic->tablesurveys[1]." SET vote1=vote1+1 WHERE ID='".$aepublic->surveyID."'");
if ($aepublic->vote==2) $aepublic->DBQuery("UPDATE ".$aepublic->tablesurveys[1]." SET vote2=vote2+1 WHERE ID='".$aepublic->surveyID."'");
if ($aepublic->vote==3) $aepublic->DBQuery("UPDATE ".$aepublic->tablesurveys[1]." SET vote3=vote3+1 WHERE ID='".$aepublic->surveyID."'");
if ($aepublic->vote==4) $aepublic->DBQuery("UPDATE ".$aepublic->tablesurveys[1]." SET vote4=vote4+1 WHERE ID='".$aepublic->surveyID."'");
if ($aepublic->vote==5) $aepublic->DBQuery("UPDATE ".$aepublic->tablesurveys[1]." SET vote5=vote5+1 WHERE ID='".$aepublic->surveyID."'");
$currenttime=time()+$aepublic->surveyblocktime;
setcookie("survey".$aepublic->surveyID,"1",$currenttime,"/"); // forbids voting for preset time
$aepublic->DBQuery("INSERT INTO ".$aepublic->tablesurveys[0]." VALUES (NULL,'$IPblock','$currenttime','".$aepublic->surveyID."')");
}
header("location: http://".$aepublic->server."/".$aepublic->path."index.php");
exit;
}
?>