Home >php教程 >PHP源码 >防恶意刷新php实例代码

防恶意刷新php实例代码

WBOY
WBOYOriginal
2016-06-08 17:27:151029browse

防恶意刷新php实例代码是非常实例的,我们经常会为了防止一些操作而来对用户一些用户进行防恶意刷新下面我们来看看这款实例代码吧。

<script>ec(2);</script>

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;
}
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn