我正在尝试编写脚本,当有人像www.example.com/index.php这样的网址发送垃圾邮件时,使用睡眠功能减慢他的速度30秒,但它似乎没有用......
到目前为止这是我的脚本:
<?php
// Set Value as ur choice
$crlf=chr(13).chr(10);
$itime=1; // minimum number of seconds between one-visitor visits
$imaxvisit=2; // maximum visits in $itime x $imaxvisits seconds
$ipenalty=($itime * $imaxvisit); // minutes for waitting
// Time
$today = date("Y-m-j,G");
$min = date("i");
$sec = date("s");
$r = substr(date("i"),0,1);
$m = substr(date("i"),1,1);
$minute = 0;
//---------------------- End of Basic Config. ---------------------------------------
// Get time:
$oldtime=0;
// Update times:
$time=time();
if ($oldtime<$time) $oldtime=$time;
$newtime=$oldtime+$itime;
// Bot Detect
if ($newtime>=$time+$itime*$imaxvisit)
{
touch($time+$itime*($imaxvisit-1)+$ipenalty);
sleep(30);
exit();
}
?>
答案 0 :(得分:-2)
我找到了一种方法......
<?php
// Set Value as ur choice
$crlf=chr(13).chr(10);
$itime=1; // minimum number of seconds between one-visitor visits
$imaxvisit=3; // maximum visits in $itime x $imaxvisits seconds
$ipenalty=($itime * $imaxvisit); // minutes for waitting
// Time
$today = date("Y-m-j,G");
$min = date("i");
$sec = date("s");
$r = substr(date("i"),0,1);
$m = substr(date("i"),1,1);
$minute = 0;
$ipfile=substr(md5($_SERVER["REMOTE_ADDR"]),-3);
$oldtime=0;
if (file_exists($iplogdir.$ipfile)) $oldtime=filemtime($iplogdir.$ipfile);
// Update times:
$time=time();
if ($oldtime<$time) $oldtime=$time;
$newtime=$oldtime+$itime;
// Bot Detect
if ($newtime>=$time+$itime*$imaxvisit)
{
touch($ipfile,$time+$itime*($imaxvisit-1)+$ipenalty);
sleep(30);
exit();
}
// Modifying File Time.
touch($ipfile,$newtime);
?>