Hi . I am trying to set up a voting system. I have been using php sessions to do a 5 minute block on a vote per file. I have noticed that running this on other servers there seems to be a problem working correctly with that. So I saw this little script code and thought I would go this way..
$past = time()-900;
$sql = "DELETE FROM ".$prefix."_whoiswhere WHERE time < $past";
$db->sql_query($sql);
$sql = "SELECT time FROM ".$prefix."_whoiswhere WHERE username='$uname'";
$result = $db->sql_query($sql);
$ctime = time();
if ($row = $db->sql_fetchrow($result)) {
$sql = "UPDATE ".$prefix."_whoiswhere SET username='$uname', time='$ctime', host_addr='$ip', guest='$guest' , module='$name', url='$url' WHERE username='$uname'";
$db->sql_query($sql);
} else {
$sql = "INSERT INTO ".$prefix."_whoiswhere (username, time, host_addr, guest,module,url) VALUES ('$uname', '$ctime', '$ip', '$guest','$name','$url')";
$db->sql_query($sql);
}
My problem is I want to customise it for what I want to do. I want it so that it will store a username and file they voted on. And the time of course. The code abouve I know will remove after some time. I am not sure what
$past = time()-900;
this line excetly figures. eg. the -900 .. Is that subtracting what? Milliseconds/seconds/ect. Would this be an eficiant way to do this kind of figureing for running on different servers?
Also will this kind of thing work even if days have past before it is called again?
Thanks in advanced