|
@ -16,15 +16,19 @@ class User |
|
|
|
|
|
|
|
|
static function login($login, $password) |
|
|
static function login($login, $password) |
|
|
{ |
|
|
{ |
|
|
if (empty($login)) { |
|
|
|
|
|
|
|
|
if (empty($login) || empty($password)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (! self::$user = self::getByLogin($login) ) { |
|
|
|
|
|
|
|
|
if(!preg_match("/^[a-z0-9_-]{3,20}$/i", $login)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (self::$user->password != md5($password)) { |
|
|
|
|
|
|
|
|
if (!self::$user = self::getByLogin(strtolower($login)) ) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (self::$user->pass != $password) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -54,7 +58,7 @@ class User |
|
|
static function setSession() |
|
|
static function setSession() |
|
|
{ |
|
|
{ |
|
|
Env::setCookie('login', self::$user->login, TIME_NOW + LOGIN_COOKIE_TTL); |
|
|
Env::setCookie('login', self::$user->login, TIME_NOW + LOGIN_COOKIE_TTL); |
|
|
Env::setCookie('login_hash', self::getHash(), TIME_NOW + LOGIN_COOKIE_TTL); |
|
|
|
|
|
|
|
|
Env::setCookie('login_hash', self::getHash(), TIME_NOW + LOGIN_COOKIE_TTL); |
|
|
|
|
|
|
|
|
session_start(); |
|
|
session_start(); |
|
|
|
|
|
|
|
@ -76,7 +80,7 @@ class User |
|
|
|
|
|
|
|
|
static function getHash() |
|
|
static function getHash() |
|
|
{ |
|
|
{ |
|
|
return md5(self::$user->id.'hckrz'.self::$user->login.'mst'.self::$user->password.'dai'); |
|
|
|
|
|
|
|
|
return md5(self::$user->id.'hckrz'.self::$user->login.'mst'.self::$user->pass.'dai'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static function getInfo() |
|
|
static function getInfo() |
|
@ -91,7 +95,7 @@ class User |
|
|
|
|
|
|
|
|
static function getByLogin($login) |
|
|
static function getByLogin($login) |
|
|
{ |
|
|
{ |
|
|
return Load::model('UserData')->getByLogin($login); |
|
|
|
|
|
|
|
|
return Load::model('UserData')->getByLogin($login); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
?>
|
|
|
?>
|