Новый глобальный класс user и немного тестов
This commit is contained in:
parent
24c9a0978c
commit
62d497149d
39
classes/User.php
Normal file
39
classes/User.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class User
|
||||||
|
{
|
||||||
|
public $id;
|
||||||
|
public $login;
|
||||||
|
public $email;
|
||||||
|
private $pass;
|
||||||
|
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 function __construct($userid)
|
||||||
|
{
|
||||||
|
$user_query = db::c()->query('SELECT * FROM users WHERE id = ?i', $userid)->fetch_assoc();
|
||||||
|
foreach ($this as $key => $value) {
|
||||||
|
if (isset($user_query[$key])) {
|
||||||
|
$this->$key = $user_query[$key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
inf.php
11
inf.php
@ -4,13 +4,14 @@ require_once 'functions.php';
|
|||||||
|
|
||||||
$login = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
|
$login = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
|
||||||
$uid = isset($_SESSION['uid']) ? $_SESSION['uid'] : null;
|
$uid = isset($_SESSION['uid']) ? $_SESSION['uid'] : null;
|
||||||
$user = db::c()->query('SELECT `id`,`login`,`married`,`win`,borndate,`align`,`admin`,`realname`,`info`,`prof1`,`prof2`,`email`,`ip`,`exp`,`stats`,`money`,`room`,`doblest`
|
//$user = db::c()->query('SELECT `id`,`login`,`married`,`win`,borndate,`align`,`admin`,`realname`,`info`,`prof1`,`prof2`,`email`,`ip`,`exp`,`stats`,`money`,`room`,`doblest`
|
||||||
FROM `users`
|
// FROM `users`
|
||||||
WHERE `login` = "?s" OR `id` = "?s"', $login, $login)->fetch_assoc();
|
// WHERE `login` = "?s" OR `id` = "?s"', $login, $login)->fetch_assoc();
|
||||||
|
$user = new User($_SESSION['uid']);
|
||||||
$own = db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = "?s"', $uid)->fetch_assoc();
|
$own = db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = "?s"', $uid)->fetch_assoc();
|
||||||
$presents = db::c()->query('SELECT img, sender FROM `users_presents` WHERE expiration_date >= "?s" AND owner = ?i', date('Y-m-d'), $user['id']);
|
$presents = db::c()->query('SELECT img, sender FROM `users_presents` WHERE expiration_date >= "?s" AND owner = ?i', date('Y-m-d'), $user['id']);
|
||||||
|
|
||||||
if (empty($user['id'])): ?>
|
if (empty($user->id)): ?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="ru">
|
<html lang="ru">
|
||||||
<head>
|
<head>
|
||||||
@ -26,7 +27,7 @@ if (empty($user['id'])): ?>
|
|||||||
|
|
||||||
<html lang="ru">
|
<html lang="ru">
|
||||||
<head>
|
<head>
|
||||||
<title>Информация о <?= $user['login'] ?></title>
|
<title>Информация о <?= $user->login ?></title>
|
||||||
<meta charset=UTF-8"/>
|
<meta charset=UTF-8"/>
|
||||||
<link href="css/main.css" rel="stylesheet">
|
<link href="css/main.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
Loading…
Reference in New Issue
Block a user