file_put_contents
(
$fileforbid
,
$fileforbidarr
);
}
}
}
}
//防刷新
$str
="";
$file
="log/ipdate.dat";
if
(!
file_exists
("log")&&!
is_dir
("log"))
mkdir
("log",0777);
if
(!
file_exists
(
$file
))
file_put_contents
(
$file
,"");
$allowTime
= 120;
//防刷新时间
$allowNum
=10;
//防刷新次数
$uri
=
$_SERVER
['REQUEST_URI'];
$checkip
=md5(
$ip
);
$checkuri
=md5(
$uri
);
$yesno
=true;
$ipdate
=@file(
$file
);
foreach
(
$ipdate
as
$k
=>
$v
) {
$iptem
=
substr
(
$v
,0,32);
$uritem
=
substr
(
$v
,32,32);
$timetem
=
substr
(
$v
,64,10);
$numtem
=
substr
(
$v
,74);
if
(
$time
-
$timetem
<
$allowTime
) {
if
(
$iptem
!=
$checkip
)
$str
.=
$v
;
else
{
$yesno
=false;
if
(
$uritem
!=
$checkuri
)
$str
.=
$iptem
.
$checkuri
.
$time
."1\r\n";
elseif
(
$numtem
<
$allowNum
)
$str
.=
$iptem
.
$uritem
.
$timetem
.(
$numtem
+1)."\r\n";
else
{
if
(!
file_exists
(
$fileforbid
)) {
$addforbidarr
=
array
(
$ip
."\r\n",time()."\r\n",1);
file_put_contents
(
$fileforbid
,
$addforbidarr
);
}
file_put_contents
("log/forbided_ip.log",
$ip
."--".
date
("Y-m-d H:i:s",time())."--".
$uri
."\r\n",FILE_APPEND);