How can I add codes to a toplist script to prevent users from cheating by refreshing the page and getting hits for their site to be on top?
something like on surfwap
here is the code on the index.php page
if($sid>0)
{
$sites=mysql_fetch_array(mysql_query("SELECT * FROM sites where id='".$sid."' and banned='0';"));
$hin=$sites[6]+1;
mysql_query("UPDATE sites SET hin='".$hin."' WHERE id='".$sid."'");
}
CREATE TABLE `hits_table` (
`id` int(11) AUTO_INCREMENT NOT NULL PRIMARY KEY,
`referer` int(11) NOT NULL,
`user_ip` varchar(100) NOT NULL,
`user_agent` varchar(250) NOT NULL,
`datetime` datetime NOT NULL
)
referer = The website owner's ID supplying the hit
user_ip = The user who is directed's ip
user_agent = The user who is directed's browser
datetime = The datetime in which he/she directed to your site and a hit IS saved
WATCH CLOSELY now (i am about to pull a rabbit out of the hat ):
Before you save a click(hit) you MUST query to the database to check whether the user browsing has been saved as a hit. That can be achieved with an SQL stement like the one below:
SELECT * FROM hits_table WHERE referer='$referer' AND user_ip='$user_ip' AND datetime > '$datetime_in_30_minutes_back_or_less';
$datetime_in_30_minutes_back_or_less can be found by using the [datetime using the current datetime MINUS (-) 30 minutes or whatever time captcha you want to use]
dont allow a user to execute a DETELE statement (unless your not serious)
Try the suggestion and ask if your still stuck.
8)