Рефакторинг, очистка, работа над ошибками, связанными с базой, отказ от глобальной переменной $user во многих файлах.
Singleton в некоторых местах вместо решения #42. Новые шаги для решения #16 и #52. Closes #42. Closes #32. Closes #31.
This commit is contained in:
+10
-10
@@ -13,6 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
@@ -23,7 +24,6 @@ if ($_SESSION['uid'] != 2) {
|
||||
}
|
||||
require_once 'config.php';
|
||||
|
||||
$user = new User($_SESSION['uid']);
|
||||
$status = '';
|
||||
$dirname = "i/presents/";
|
||||
$images = glob($dirname . "*.png");
|
||||
@@ -47,21 +47,21 @@ if (!empty($_POST['sendAction'])) {
|
||||
$_POST['days'] = 1;
|
||||
}
|
||||
$cost = $_POST['days'] * 5;
|
||||
if ($user->getMoney() < $cost) {
|
||||
if (User::getInstance()->getMoney() < $cost) {
|
||||
$status = "Не хватает кредитов на оплату подарка!";
|
||||
return;
|
||||
}
|
||||
|
||||
if ($_POST['sender'] == 1) {
|
||||
$sender = "Анонимный подарок";
|
||||
} elseif ($_POST['sender'] == 2 && $user->getClan()) {
|
||||
$sender = "Подарок от клана {$user->getClan()}";
|
||||
} elseif ($_POST['sender'] == 2 && User::getInstance()->getClan()) {
|
||||
$sender = "Подарок от клана " . User::getInstance()->getClan();
|
||||
} else {
|
||||
$sender = "Подарок от {$user->getLogin()}";
|
||||
$sender = "Подарок от " . User::getInstance()->getLogin();
|
||||
}
|
||||
|
||||
$user->setMoney($user->getMoney() - $cost);
|
||||
Bank::setWalletMoney($user->getMoney(), $user->getId());
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - $cost);
|
||||
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
|
||||
db::c()->query('INSERT INTO users_presents (owner, img, text, sender, expiration_date) VALUES (?i,"?s","?s","?s",DATE_ADD(CURDATE(),INTERVAL ?i DAY))', $receiver['id'], $_POST['present'], $_POST['text'], $sender, $_POST['days']);
|
||||
|
||||
$telegraphText = "Вам пришёл подарок от {$sender}!";
|
||||
@@ -105,10 +105,10 @@ Template::header('Дарильня');
|
||||
rows=6 cols=80
|
||||
placeholder="Текст сопроводительной записки (в информации о персонаже не отображается). Заполнять не обязательно."></textarea><br>
|
||||
<br>Выберите, от чьего имени подарок:<br>
|
||||
<label><input type=radio name=sender value=0 checked> <?= $user->getLogin() ?></label><br>
|
||||
<label><input type=radio name=sender value=0 checked> <?= User::getInstance()->getLogin() ?></label><br>
|
||||
<label><input type=radio name=sender value=1> анонимно</label><br>
|
||||
<?php if (!empty($user['ClanName'])): ?>
|
||||
<label><input type=radio name=sender value=2> от имени клана <b><?= $user->getClan() ?></b></label><br>
|
||||
<?php if (!empty(User::getInstance()->getClan())): ?>
|
||||
<label><input type=radio name=sender value=2> от имени клана <b><?= User::getInstance()->getClan() ?></b></label><br>
|
||||
<?php endif; ?>
|
||||
<br>Долговечность подарка (5кр в день):<br>
|
||||
<input name="days" placeholder="Количество дней"><br>
|
||||
|
||||
Reference in New Issue
Block a user