battles/classes/User.php
2020-07-04 13:49:43 +03:00

74 lines
1.8 KiB
PHP

<?php
class User
{
public $id;
public $login;
public $email;
public $realname;
public $borndate;
public $info;
public $level;
public $align;
public $clan;
public $money;
public $strength;
public $dexterity;
public $intuition;
public $endurance;
public $intelligence;
public $wisdom;
public $ip;
public $session_id;
public $admin;
public $enter_game;
public $room;
public $block;
// Пока несуществующие, для совместимости.
public $married;
public $exp;
public $stats;
use Rooms;
public function __construct($user)
{
$user_query = db::c()->query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc();
foreach ($this as $key => $value) {
if (isset($user_query[$key])) {
$this->$key = $user_query[$key];
}
}
}
public function showPresents()
{
//$presents = db::c()->query('SELECT img, sender FROM `users_presents` WHERE expiration_date >= "?s" AND owner = ?i', date('Y-m-d'), $user->id);
$presents_query = db::c()->query();
if ($presents_query->getNumRows()) {
echo <<<PRESENT_BEFORE
<div>
<legend>Подарки</legend>
PRESENT_BEFORE;
while ($row = $presents_query->fetch_assoc()) {
echo <<<PRESENT
<img src = "{$row['img']}" title = "{$row['sender']}" alt = "{$row['sender']}" >
PRESENT;
}
echo <<<PRESENT_AFTER
</div>
PRESENT_AFTER;
}
}
public function showUserInfo() {
$dressed_items = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i' AND dressed_slot > 0, $this->id);
foreach ($dressed_items->fetch_assoc() as $item) {
}
}
}