Recommend a good php script:
class Login_Ban
011 {
012
013
014
015
016 /**
017 * The number of attempts
018 *
019 * @var int
020 */
021
022 var $Limit_attempts = '3';
023
024 /**
025 * The time of ban (Minutes)
026 *
027 * @var int
028 */
029
030 var $Ban_time = '15';
031
032 /**
033 * Constructor.
034 * @param Limit attemps to ban
035 * @param time of ban (Minutes)
036 */
037
038 function Login_Ban($Limit_attempts = '3', $Ban_time = '15')
039 {
040 $this->Limit_attempts = $Limit_attempts;
041 $this->Ban_time = $Ban_time;
042 }
043
044 /**
045 * Add the cookies
046 * @param the name if cookie
047 * @param the value
048 */
049 function SetCookies($CookiesName, $Value)
050 {
051 setcookie($CookiesName, $Value,time() + 60 * 60 * 24 * 30, NULL ,NULL, NULL, TRUE);
052 }
053
054 /**
055 * Add new attemp.
056 */
057
058 function Set_Attemp()
059 {
060 if(! isset($_COOKIE['login_attemp']))
061 {
062 $this->SetCookies('login_attemp', '1');
063 $this->SetCookies('attemp_date', time());
064 } elseif(isset($_COOKIE['login_attemp']))
065 {
066 $this->SetCookies('login_attemp', $_COOKIE['login_attemp'] + 1);
067 $this->SetCookies('attemp_date', time());
068 }
069 }
070
071
072 /**
073 * To verify that it has been banned
074 *
075 */
076
077 function Banned()
078 {
079 if(! isset($_COOKIE['login_attemp']))
080 {
081 return false;
082 } elseif(isset($_COOKIE['login_attemp']))
083 {
084 if(($_COOKIE['login_attemp'] == $this->Limit_attemps || $_COOKIE['login_attemp'] > $this->Limit_attemps))
085 {
086 if($this->Ban_time * 60 + time() == $_COOKIE['attemp_date'] || $this->Ban_time * 60 + time() * 60 > $_COOKIE['attemp_date'])
087 {
088 return true;
089 } else
090 {
091 return false;
092 }
093 } else
094 {
095 return false;
096 }
097 }
098 }
099
100 /**
101 * Delete the attemper cookies.
102 */
103
104 function mkempty()
105 {
106 $this->SetCookies('login_attemp', '');
107 $this->SetCookies('attemp_date', '');
108 }
109
110
111 }
112
113
114
115
116 ?>