Файл: system/classes/User.php
Строк: 17
<?php
class User
{
protected $user;
protected $get;
public function __construct ()
{
if (isset ($_COOKIE['token']))
{
$stmt = DB::run()->prepare('SELECT * FROM `users` WHERE `token` = :token LIMIT 1');
$stmt->execute([
':token' => $_COOKIE['token']
]);
$this->user = $stmt->fetch();
}
}
public function isAuth ()
{
return $this->user['id'];
}
public function get ($type)
{
$stmt = DB::run()->prepare('SELECT * FROM `users` WHERE `id` = :id LIMIT 1');
$stmt->execute([
':id' => $this->user['id']
]);
$this->get = $stmt->fetch();
return $this->get[$type];
}
}