Часть логов теперь пишется в SQLITE, а не в текстовые файлы (#33). Проинициализирован класс Nick в свитках.

This commit is contained in:
Igor Barkov (iwork)
2021-08-26 17:44:14 +03:00
parent 6fa217b93b
commit 5e264f837a
65 changed files with 438 additions and 233 deletions
+24 -22
View File
@@ -100,11 +100,6 @@ class User
$this->pass = $pass;
}
public function savePass()
{
self::$db->execute('UPDATE users SET pass = ? WHERE id = ?', [$this->pass, $this->id]);
}
public function getRealname(): string
{
return $this->realname;
@@ -151,13 +146,8 @@ class User
*/
public function setClan(?string $short_name)
{
if (is_null($short_name)) {
$this->clan = null;
self::$db->execute('update users set clan = null where id = ?', $this->id);
} else {
$this->clan = $short_name;
self::$db->execute('update users set clan = ? where id = ?', [$short_name, $this->id]);
}
$this->clan = is_null($short_name) ? null : $short_name;
$this->saveUser();
}
public function getMoney(): int
@@ -217,11 +207,6 @@ class User
}
}
public function saveShadow()
{
self::$db->execute('UPDATE users SET shadow = ? WHERE id = ?', [$this->shadow, $this->id]);
}
public function getExperience(): int
{
return $this->experience;
@@ -242,11 +227,6 @@ class User
return $this->zayavka;
}
public function saveAnketa()
{
self::$db->execute('UPDATE users SET realname = ?, info = ? WHERE id = ?', [$this->realname, $this->info, $this->id]);
}
public function setOnline()
{
self::$db->execute('update online set real_time = ? where user_id = ?', [time(), $this->getId()]);
@@ -285,4 +265,26 @@ class User
return true;
}
/** Сохраняет в базу актуальные логин, пароль, email, имя, дату рождения, текст инфы, склонность, клан, образ, права админа.
*
*/
public function saveUser()
{
$query = 'update users set login = ?, pass = ?, email = ?, realname = ?, borndate = ?, info = ?, align = ?, clan = ?, shadow = ?, admin = ? where id = ?';
$vals = [
$this->login, //set
$this->pass,
$this->email,
$this->realname,
$this->borndate,
$this->info,
$this->align,
$this->clan,
$this->shadow,
$this->admin,
$this->id //where
];
DBPDO::$db->execute($query, $vals);
}
}