|
|
@ -1,14 +1,14 @@ |
|
|
|
<?php |
|
|
|
/** |
|
|
|
* Класс для работы с пользователями |
|
|
|
* |
|
|
|
* @copyright |
|
|
|
* @link |
|
|
|
* @package Majestic |
|
|
|
* @subpackage Decorator |
|
|
|
* @since |
|
|
|
* @version SVN: $Id$ |
|
|
|
* @filesource $URL$ |
|
|
|
/** |
|
|
|
* Класс для работы с пользователями |
|
|
|
* |
|
|
|
* @copyright |
|
|
|
* @link |
|
|
|
* @package Majestic |
|
|
|
* @subpackage Decorator |
|
|
|
* @since |
|
|
|
* @version SVN: $Id$ |
|
|
|
* @filesource $URL$ |
|
|
|
*/ |
|
|
|
class User |
|
|
|
{ |
|
|
@ -16,15 +16,19 @@ class User |
|
|
|
|
|
|
|
static function login($login, $password) |
|
|
|
{ |
|
|
|
if (empty($login)) { |
|
|
|
if (empty($login) || empty($password)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if(!preg_match("/^[a-z0-9_-]{3,20}$/i", $login)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (! self::$user = self::getByLogin($login) ) { |
|
|
|
if (!self::$user = self::getByLogin(strtolower($login)) ) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (self::$user->password != md5($password)) { |
|
|
|
if (self::$user->pass != $password) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
@ -54,7 +58,7 @@ class User |
|
|
|
static function setSession() |
|
|
|
{ |
|
|
|
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(); |
|
|
|
|
|
|
@ -76,9 +80,9 @@ class User |
|
|
|
|
|
|
|
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() |
|
|
|
{ |
|
|
|
return Env::Session('user', self::$user); |
|
|
@ -91,7 +95,7 @@ class User |
|
|
|
|
|
|
|
static function getByLogin($login) |
|
|
|
{ |
|
|
|
return Load::model('UserData')->getByLogin($login); |
|
|
|
return Load::model('UserData')->getByLogin($login); |
|
|
|
} |
|
|
|
} |
|
|
|
?>
|