bouffeatulm/inc/User.class.php

51 lines
1.0 KiB
PHP
Raw Normal View History

2013-08-07 23:29:57 +02:00
<?php
require_once('config.php');
require_once('Storage.class.php');
2013-08-07 23:29:57 +02:00
class User extends Storage {
protected $id, $login, $password, $admin;
protected $TABLE_NAME = "Users";
2013-08-07 23:29:57 +02:00
protected $fields = array(
'id'=>'key',
'login'=>'string',
'password'=>'password',
2013-08-07 23:29:57 +02:00
'admin'=>'bool'
);
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;
}
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);
}
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;
}
}