Someone signed up on my site like 70 times at one go but the names were same just added on a letter or a number same ip address....can anyone give me the slightest idea on how to prevent such....i believe we call them spambots
Spambots
Collapse
X
-
Here is a function to check ip against the last 5 users to prevent same ip address registering over and over again.
PHP Code:function checkLastRegistrationsForIp($ip)
{
$lastUsers = mysql_query("SELECT ip FROM member DESC LIMIT 5;")); //Change sql to your table name/row
if(mysql_num_rows($lastUsers)>0)
{
while ($lastUser = mysql_fetch_array($lastUsers))
{
if($ip==$lastUser[0])
{
return true;
}
}
}
return false;
}
/////////////////////////Usage:
if(checkLastRegistrationsForIp($ip))
{
//dont allow registration
}
Last edited by something else; 03.03.17, 09:19.
-
A bot could be still registering 2 mins later so you might need to adjust timesPHP Code:$ip = $_SERVER['REMOTE_ADDR']; //Ip address maybe collected a different way than this, which could effect results.
$lastTime = mysql_fetch_array(mysql_query("SELECT MAX(registerTime) FROM members WHERE ip='".$ip."'")); //sql table name and rows "registerTime" and "ip" need changing
if(time()<$lastTime[0]+120) //120 = 60 secs * 2
{
//block register
}
Comment
-
Personally I would avoid them after cloudbleed, but I guess they can help to speed your site up.
This is a good quote about what they are about:Cloudflare is essentially nothing more than a content delivery network (CDN). The theory behind it is that they will cache copies of your website to their servers, which are spread across different locations. When a visitor visits your site the server that is closest to them is chosen and the connection has less distance to travel, hence speeding up the load times. It will also attempt to serve a cached copy of your site if it ever goes down for some reason.
Comment
Comment