Forum Moderators: phranque
<?php
// initialize vars
$lastipsarray=array();
$counter=0;
// open list of last ips
$lastipsfhd=fopen("path/to/lastips.txt","r");
// read them in
while(!feof($lastipsfhd))
{
$last100ips[]=str_replace("\n","",fgets($lastipsfhd));
}
$userip=getenv("REMOTE_ADDR");
if(array_search($userip,$last100ips))
{
$userisallowed=-1;
fclose($lastipsfhd);
print "quitting for heavy usage, please come back in a few seconds...";
exit;
}
else
{
fclose($lastipsfhd);
// write out IPs
$userisallowed=1;
}
// HERE YOUR CODE FOR ALLOWED USERS!
?>
that code needs some completion, but if you write out the IPs there and keep a backlog of around 100 ips, that should help?
Regards,
P!