PHP 防恶意刷新实现代码
程序员文章站
2023-10-17 19:06:35
复制代码 代码如下:
<?php
session_start();
$k=$_get['k'];
$t=$_get['t'];
$allowtime = 1800;//防刷新时间
$ip = get_client_ip();
$allowt = md5($ip.$k.$t);
if(!isset($_session[$allowt]))
{
$refresh = true;
$_session[$allowt] = time();
}elseif(time() - $_session[$allowt]>$allowtime){
$refresh = true;
$_session[$allowt] = time();
}else{
$refresh = false;
}
?>
复制代码 代码如下:
<?php
session_start();
$k=$_get['k'];
$t=$_get['t'];
$allowtime = 1800;//防刷新时间
$ip = get_client_ip();
$allowt = md5($ip.$k.$t);
if(!isset($_session[$allowt]))
{
$refresh = true;
$_session[$allowt] = time();
}elseif(time() - $_session[$allowt]>$allowtime){
$refresh = true;
$_session[$allowt] = time();
}else{
$refresh = false;
}
?>