<?
if(!defined('interval')) define('interval', 5);//定义常量:时间间隔为5秒
if(!defined('now_time')) define('now_time', time());//定义常量:当前时间
$refresh_time = isset($_COOKIE['refresh_time']) ? intval($_COOKIE['refresh_time']) : 0;
if ($refresh_time == 0)
{
setcookie('refresh_time', now_time - interval);//第一次访问
}
elseif ($refresh_time > (now_time - interval))
{
$temp = $refresh_time + interval - now_time;
echo "防刷新机制,请过" . ($refresh_time + interval - now_time)."秒钟后重试。";
exit();
}
else
{
setcookie('refresh_time', now_time);//此时正常输出
}
?>
if(!defined('interval')) define('interval', 5);//定义常量:时间间隔为5秒
if(!defined('now_time')) define('now_time', time());//定义常量:当前时间
$refresh_time = isset($_COOKIE['refresh_time']) ? intval($_COOKIE['refresh_time']) : 0;
if ($refresh_time == 0)
{
setcookie('refresh_time', now_time - interval);//第一次访问
}
elseif ($refresh_time > (now_time - interval))
{
$temp = $refresh_time + interval - now_time;
echo "防刷新机制,请过" . ($refresh_time + interval - now_time)."秒钟后重试。";
exit();
}
else
{
setcookie('refresh_time', now_time);//此时正常输出
}
?>