2013-08-07 23:29:57 +02:00
|
|
|
<?php
|
|
|
|
require_once('config.php');
|
2013-08-08 22:55:12 +02:00
|
|
|
require_once('Storage.class.php');
|
2013-08-07 23:29:57 +02:00
|
|
|
|
|
|
|
class User extends Storage {
|
2013-08-08 22:55:12 +02:00
|
|
|
protected $id, $login, $password, $admin;
|
|
|
|
protected $TABLE_NAME = "Users";
|
2013-08-07 23:29:57 +02:00
|
|
|
protected $fields = array(
|
|
|
|
'id'=>'key',
|
2013-08-08 22:55:12 +02:00
|
|
|
'login'=>'string',
|
|
|
|
'password'=>'password',
|
2013-08-07 23:29:57 +02:00
|
|
|
'admin'=>'bool'
|
|
|
|
);
|
|
|
|
|
2013-08-08 22:55:12 +02:00
|
|
|
public function __construct() {
|
2013-08-07 23:29:57 +02:00
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLogin() {
|
|
|
|
return $this->login;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getId() {
|
|
|
|
return $this->id;
|
|
|
|
}
|
2013-08-08 22:55:12 +02:00
|
|
|
|
|
|
|
public function getAdmin() {
|
|
|
|
return $this->admin;
|
|
|
|
}
|
2013-08-07 23:29:57 +02:00
|
|
|
|
|
|
|
public function setLogin($login) {
|
|
|
|
$this->login = $login;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPassword($password) {
|
|
|
|
$this->password = User::encrypt($password);
|
|
|
|
}
|
|
|
|
|
2013-08-08 22:55:12 +02:00
|
|
|
public function setAdmin($admin) {
|
|
|
|
$this->admin = $admin;
|
|
|
|
}
|
|
|
|
|
2013-08-07 23:29:57 +02:00
|
|
|
public function encrypt($text) {
|
|
|
|
return crypt($text, SALT);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function check_password($password) {
|
|
|
|
return User::encrypt($password) == $this->password;
|
|
|
|
}
|
|
|
|
}
|