Поправил инициализацию модулей
This commit is contained in:
parent
0b66a72484
commit
bef7165777
4 changed files with 40 additions and 32 deletions
|
|
@ -43,31 +43,38 @@ class User
|
|||
return null;
|
||||
}
|
||||
|
||||
public static function getUserByLogin($login)
|
||||
function getUserPassword($result) {
|
||||
return $result->get('password');
|
||||
}
|
||||
|
||||
public function getUserByLogin($login)
|
||||
{
|
||||
$stmt = $this->$db->prepareStatement("SELECT * FROM users WHERE login = ?");
|
||||
$stmt = $this->db->prepareStatement("SELECT * FROM users WHERE login = ?");
|
||||
$stmt->setString(1, $login);
|
||||
$result = $this->getUserByQuery($stmt);
|
||||
if ($result) {
|
||||
$time = time();
|
||||
$id = $this->id;
|
||||
$this->$db->executeQuery("UPDATE users SET lasttime = $time WHERE id_user = $id"); // Время входа
|
||||
$this->db->executeQuery("UPDATE users SET lasttime = $time WHERE id_user = $id"); // Время входа
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getUserById($id)
|
||||
public function getUserById($id)
|
||||
{
|
||||
$stmt = $this->$db->prepareStatement("SELECT * FROM users WHERE id_user = ?");
|
||||
$stmt = $this->db->prepareStatement("SELECT * FROM users WHERE id_user = ?");
|
||||
$stmt->setInt(1, $_SESSION ['access']);
|
||||
$result = $this->getUserByQuery($stmt);
|
||||
if ($result) {
|
||||
$lasttime = $result->getInt('lasttime');
|
||||
$time = time();
|
||||
if ($time - $lasttime > $this->LIFE_TIME) return null; // Вышло время сессии
|
||||
$id = $this->$id;
|
||||
if ($time - $lasttime > self::LIFE_TIME) return null; // Вышло время сессии
|
||||
$id = $this->id;
|
||||
$this->db->executeQuery("UPDATE users SET lasttime = $time WHERE id_user = $id"); // Время последнего обращения входа
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function setSID() {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue