看板 humorless
作者 humorless (休摩里斯)
標題 php session anti-flood protection
時間 2011年04月23日 Sat. PM 04:59:11


http://stackoverflow.com/questions/3199524/anti-flood-session-or-db-stocking-ips

Hi, right now I'm using an antiflood function in all my websites :

function flood($name,$time)
{
 $name = 'tmptmptmp'.$name;
 if(!isset($_SESSION[$name]))
 {
  $_SESSION[$name] = time();
  return true;   // (*)
 }
 else
 {
  if(time()-$time > $_SESSION[$name])
  {
   $_SESSION[$name] = time();
   return true;
  }
  else
  {
   return false;
  }
 }
}
I use it this way :

if(flood('post',60)) do something;
else 'you're posting too fast';



--
※ 作者: humorless 時間: 2011-04-23 16:59:11 來自: host-111-184-41-18.dynamic.kbtelecom.net
※ 編輯: humorless 時間: 2011-04-23 17:03:40 來自: host-111-184-41-18.dynamic.kbtelecom.net
※ 同主題文章:
php session anti-flood protection
04-23 16:59 humorless