[php]代码库
<?php
session_start();
$nowtime = time() ;
if (session_is_registered('lasttime'))
{
$lasttime = $_SESSION['lasttime'];
$times = $_SESSION['times'] + 1;
$_SESSION['times'] = $times;
}else{
$lasttime = $nowtime;
$times = 1;
$_SESSION['times'] = $times;
$_SESSION['lasttime'] = $lasttime;
}
if (($nowtime - $lasttime)<3){
if ($times>=5){
header(sprintf("Location: %s",'http://127.0.0.1'));
exit;
}
}else{
$times = 0;
$_SESSION['lasttime'] = $nowtime;
$_SESSION['times'] = $times;
}
?>
//该片段来自于http://yuncode.net