<?
class CSurveys extends CEngine
{
function CSurveys()
{
$this->CEngine();
}
function GetSurveyID()
{
return $this->surveyID=$this->access["ID"];
}
function GetSurveyVariables()
{
$this->answer[0]=$this->access["ans1"];
$this->answer[1]=$this->access["ans2"];
$this->answer[2]=$this->access["ans3"];
$this->answer[3]=$this->access["ans4"];
$this->answer[4]=$this->access["ans5"];
$this->vote[0]=$this->access["vote1"];
$this->vote[1]=$this->access["vote2"];
$this->vote[2]=$this->access["vote3"];
$this->vote[3]=$this->access["vote4"];
$this->vote[4]=$this->access["vote5"];
$this->status=$this->access["status"];
$this->totalvotes=$this->vote[0]+$this->vote[1]+$this->vote[2]+$this->vote[3]+$this->vote[4];
if ($this->totalvotes) $this->percentagepervote=100/$this->totalvotes;
}
function GetSurveyTitle()
{
$title=stripslashes($this->access["title"]);
echo $title;
}
function GetSurveyChoices($before="",$between="",$after="")
{
for ($i=0;$i<=4;$i++)
{
$votepercentage[$i]=number_format($this->vote[$i]*$this->percentagepervote,2,".",".");
if ($_COOKIE["survey".$this->surveyID])
{
if ($this->answer[$i]) echo $before,$this->answer[$i],$between,'<img src="admin/',$i+1,'.gif" height="10" width="',$votepercentage[$i],'" alt="',$votepercentage[$i],'% (',$this->vote[$i],')">',$after;
}
else
{
if ($this->answer[$i]) echo $before,$this->answer[$i],$between,'<input type="radio" name="vote" value="',$i+1,'">',$after;
}
}
}
function GetSurveyTotal()
{
echo $this->totalvotes;
}
// Gets running survey or $surveyID
function GetSurvey($surveyID="running",$surveynumber=3)
{
if ($surveyID=="running") $this->DBQuery("SELECT * FROM ".$this->tablesurveys[1]." WHERE status=1");
if ($this->surveyID) $this->DBQuery("SELECT * FROM ".$this->tablesurveys[1]." WHERE ID='".$this->surveyID."'");
if ($surveyID AND $surveyID<>"running") $this->DBQuery("SELECT * FROM ".$this->tablesurveys[1]." WHERE ID='".$surveyID."'");
if (!$surveyID AND $surveynumber) $this->DBQuery("SELECT * FROM ".$this->tablesurveys[1]." ORDER BY status DESC LIMIT ".$surveynumber);
}
}
?>