Зачем-то инкапсуляция...
This commit is contained in:
+13
-10
@@ -13,6 +13,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
session_start();
|
||||
if ($_SESSION['uid'] != 2) {
|
||||
header("Location: index.php");
|
||||
@@ -20,7 +23,7 @@ if ($_SESSION['uid'] != 2) {
|
||||
}
|
||||
require_once 'config.php';
|
||||
|
||||
$user = new \Battles\User($_SESSION['uid']);
|
||||
$user = new User($_SESSION['uid']);
|
||||
$status = '';
|
||||
$dirname = "i/presents/";
|
||||
$images = glob($dirname . "*.png");
|
||||
@@ -44,28 +47,28 @@ if (!empty($_POST['sendAction'])) {
|
||||
$_POST['days'] = 1;
|
||||
}
|
||||
$cost = $_POST['days'] * 5;
|
||||
if ($user->money < $cost) {
|
||||
if ($user->getMoney() < $cost) {
|
||||
$status = "Не хватает кредитов на оплату подарка!";
|
||||
return;
|
||||
}
|
||||
|
||||
if ($_POST['sender'] == 1) {
|
||||
$sender = "Анонимный подарок";
|
||||
} elseif ($_POST['sender'] == 2 && $user->clan) {
|
||||
$sender = "Подарок от клана {$user->clan}";
|
||||
} elseif ($_POST['sender'] == 2 && $user->getClan()) {
|
||||
$sender = "Подарок от клана {$user->getClan()}";
|
||||
} else {
|
||||
$sender = "Подарок от {$user->login}";
|
||||
$sender = "Подарок от {$user->getLogin()}";
|
||||
}
|
||||
|
||||
$user->money -= $cost;
|
||||
Bank::setWalletMoney($user->money, $user->id);
|
||||
$user->setMoney($user->getMoney() - $cost);
|
||||
Bank::setWalletMoney($user->getMoney(), $user->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}!";
|
||||
db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $receiver['id'], $telegraphText);
|
||||
$status = "Подарок удачно доставлен к {$_POST['receiver']}! Вы потратили <b>{$cost}</b> кр.";
|
||||
}
|
||||
\Battles\Template::header('Дарильня');
|
||||
Template::header('Дарильня');
|
||||
?>
|
||||
<script src="js/main.js"></script>
|
||||
<style>
|
||||
@@ -102,10 +105,10 @@ if (!empty($_POST['sendAction'])) {
|
||||
rows=6 cols=80
|
||||
placeholder="Текст сопроводительной записки (в информации о персонаже не отображается). Заполнять не обязательно."></textarea><br>
|
||||
<br>Выберите, от чьего имени подарок:<br>
|
||||
<label><input type=radio name=sender value=0 checked> <?= $user->login ?></label><br>
|
||||
<label><input type=radio name=sender value=0 checked> <?= $user->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->clan ?></b></label><br>
|
||||
<label><input type=radio name=sender value=2> от имени клана <b><?= $user->getClan() ?></b></label><br>
|
||||
<?php endif; ?>
|
||||
<br>Долговечность подарка (5кр в день):<br>
|
||||
<input name="days" placeholder="Количество дней"><br>
|
||||
|
||||
Reference in New Issue
Block a user