Зачатки MVC
This commit is contained in:
parent
25a6f17d7e
commit
c6316820a0
56
classes/ItemTypes.php
Normal file
56
classes/ItemTypes.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lopiu
|
||||
* Date: 04.07.2020
|
||||
* Time: 12:33
|
||||
*/
|
||||
|
||||
trait ItemTypes
|
||||
{
|
||||
public function getItemName($item_type_id) {
|
||||
switch ($item_type_id) {
|
||||
case 1:
|
||||
$this->typename = 'Серьги';
|
||||
break;
|
||||
case 2:
|
||||
$this->typename = 'Ожерелье';
|
||||
break;
|
||||
case 3:
|
||||
$this->typename = 'Оружие';
|
||||
break;
|
||||
case 4:
|
||||
$this->typename = 'Броня';
|
||||
break;
|
||||
case 5:
|
||||
$this->typename = 'Кольцо';
|
||||
break;
|
||||
|
||||
case 8:
|
||||
$this->typename = 'Шлем';
|
||||
break;
|
||||
case 9:
|
||||
$this->typename = 'Перчатки';
|
||||
break;
|
||||
case 10:
|
||||
$this->typename = 'Щит';
|
||||
break;
|
||||
case 11:
|
||||
$this->typename = 'Обувь';
|
||||
break;
|
||||
case 12:
|
||||
$this->typename = 'Магический свиток';
|
||||
break;
|
||||
case 22:
|
||||
$this->typename = 'Рубашка';
|
||||
break;
|
||||
case 50:
|
||||
$this->typename = 'Волшебное зелье';
|
||||
break;
|
||||
case 200:
|
||||
$this->typename = 'Сувенир';
|
||||
break;
|
||||
default:
|
||||
$this->typename = 'Хлам';
|
||||
}
|
||||
}
|
||||
}
|
59
classes/Rooms.php
Normal file
59
classes/Rooms.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lopiu
|
||||
* Date: 04.07.2020
|
||||
* Time: 11:10
|
||||
*/
|
||||
|
||||
|
||||
|
||||
trait Rooms
|
||||
{
|
||||
/**
|
||||
* Возвращает имя комнаты по её ID.
|
||||
* @param $room_id - ID комнаты.
|
||||
* @return string
|
||||
*/
|
||||
public function getRoomName($room_id)
|
||||
{
|
||||
switch ($room_id) {
|
||||
default:
|
||||
$this->roomname = "Неизвестная локация";
|
||||
break;
|
||||
case 1:
|
||||
$this->roomname = "Дом поединков";
|
||||
break;
|
||||
case 20:
|
||||
$this->roomname = "Центральная площадь";
|
||||
break;
|
||||
case 21:
|
||||
$this->roomname = "Страшилкина улица";
|
||||
break;
|
||||
case 22:
|
||||
$this->roomname = "Магазин";
|
||||
break;
|
||||
case 23:
|
||||
$this->roomname = "Ремонтная мастерская";
|
||||
break;
|
||||
case 24:
|
||||
$this->roomname = "Памятник Архангелу";
|
||||
break;
|
||||
case 25:
|
||||
$this->roomname = "Комиссионный магазин";
|
||||
break;
|
||||
case 26:
|
||||
$this->roomname = "Большая парковая улица";
|
||||
break;
|
||||
case 27:
|
||||
$this->roomname = "Почта";
|
||||
break;
|
||||
case 28:
|
||||
$this->roomname = "Регистратура кланов";
|
||||
break;
|
||||
case 29:
|
||||
$this->roomname = "Банк";
|
||||
break;
|
||||
}
|
||||
return $this->roomname;
|
||||
}
|
||||
}
|
@ -31,6 +31,8 @@ class User
|
||||
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();
|
||||
@ -62,4 +64,11 @@ 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) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
9
inf.php
9
inf.php
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
include_once 'functions.php';
|
||||
|
||||
include_once 'models/PresentsModel.php';
|
||||
//$login = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
|
||||
$login = urldecode($_SERVER['QUERY_STRING']) ?? '';
|
||||
$uid = $_SESSION['uid'] ?? null;
|
||||
@ -22,6 +22,9 @@ function private_access($uid)
|
||||
return false;
|
||||
}
|
||||
|
||||
$presentsModel = new PresentsModel();
|
||||
$presentsList = $presentsModel->getAllPresents($user->id);
|
||||
|
||||
if (empty($user->id)): ?>
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
@ -49,7 +52,7 @@ if (empty($user->id)): ?>
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<td style="width: 250px; vertical-align: top;">
|
||||
<?php /*echo showinf_pers($user['id']);*/
|
||||
<?php echo showinf_pers($user['id']);
|
||||
if (!empty($user->married)): ?>
|
||||
<a href="inf.php?<?= $user->married ?>" target=_blank>
|
||||
<img alt="В браке с <?= $user->married ?>" src="i/married.gif"
|
||||
@ -79,7 +82,7 @@ if (!empty($user->realname)) {
|
||||
?>
|
||||
<p style="font-family: Consolas,monospace;"><?= nl2br($user->info) ?></p>
|
||||
<hr>
|
||||
<?php $user->showPresents(); ?>
|
||||
<?php include_once 'views/presents-list.php'; ?>
|
||||
<?php
|
||||
# Секретный раздел
|
||||
# Если я любой паладин, и смотрю не админа, или я сам админ.
|
||||
|
13
models/PresentsModel.php
Normal file
13
models/PresentsModel.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lopiu
|
||||
* Date: 04.07.2020
|
||||
* Time: 13:17
|
||||
*/
|
||||
|
||||
class PresentsModel
|
||||
{
|
||||
public function getAllPresents($user_id) {
|
||||
return db::c()->query('SELECT sender_id, image FROM `users_presents` WHERE owner_id = ?i', $user_id);
|
||||
}
|
||||
}
|
3
views/presents-list.php
Normal file
3
views/presents-list.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php foreach ($presentsList as $row): ?>
|
||||
<img src="<?= $row['img'] ?>" title="<?= $row['sender'] ?>" alt="<?= $row['sender'] ?>">
|
||||
<?php endforeach; ?>
|
Loading…
Reference in New Issue
Block a user