Final: Делаем подарки.

This commit is contained in:
Igor Barkov [iwork] 2019-01-28 18:29:22 +02:00
parent 849ffbeb0c
commit bf585364cd
2 changed files with 10 additions and 14 deletions

10
inf.php
View File

@ -10,7 +10,7 @@ $user = db::c()->query('SELECT `id`,`login`,`married`,`win`,borndate,`align`,`ad
$own = db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = "?s"', $uid)->fetch_assoc();
$presents = db::c()->query('SELECT `img`,`present` FROM `inventory` WHERE type = 200 AND `present`<>"?s" AND `owner` = ?i', '', $user['id']);
$presents_new = db::c()->query('SELECT `img`, `sender` FROM `users_presents` WHERE owner = ?i',$user['id']);
$presents_new = db::c()->query('SELECT img, sender FROM `users_presents` WHERE owner = ?i',$user['id']);
if (empty($user['id'])): ?>
<html>
@ -69,11 +69,9 @@ if (!empty($user['realname'])) echo "Имя: " . $user['realname'] . "<br>";
<div>
<legend>Подарки+</legend>
<?php
while ($row = $presents_new->fetch_assoc())
if (empty($row['sender'])) $sender = 'Анонимный подарок';
else $sender = 'Подарок от ' . $row['sender'];
echo "<img src={$row['img']} class='tooltip' title='Подарок от {$sender}'>";
?>
while ($row = $presents_new->fetch_assoc()): ?>
<img src="<?= $row['img'] ?>" title="<?= $row['sender'] ?>" alt="<?= $row['sender'] ?>">
<?php endwhile;?>
</div>
<?php endif; ?>
<?php if (!empty($user['prof1']) OR !empty($user['prof2'])): ?>

View File

@ -47,17 +47,15 @@ if (!empty($_POST['sendAction'])) {
return;
}
if ($_POST['sender'] == 1) $from = null;
elseif ($_POST['sender'] == 2 && $user['ClanName']) $from = ' клана ' . $user['ClanName'];
else $from = $user['login'];
if ($_POST['sender'] == 1) $sender = "Анонимный подарок";
elseif ($_POST['sender'] == 2 && $user['ClanName']) $sender = "Подарок от клана {$user['ClanName']}";
else $sender = "Подарок от {$user['login']}";
db::c()->query('UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i', $cost, $_SESSION['uid']);
db::c()->query('INSERT INTO users_presents (owner, img, text, sender, expiration_date) VALUES (?i,"?s","?s","?s",DATE_ADD(NOW(),INTERVAL ?i DAY))', $receiver['id'], $_POST['present'], $_POST['text'], $_POST['sender'], $_POST['days']);
#FIXME Я так не хочу подключать functions!
// $deloText = "{$user['login']} купил подарок за {$cost} кр. и подарил его персонажу {$_POST['receiver']}";
// addToDelo($deloText);
db::c()->query('INSERT INTO users_presents (owner, img, text, sender, expiration_date) VALUES (?i,"?s","?s","?s",DATE_ADD(NOW(),INTERVAL ?i DAY))', $receiver['id'], $_POST['present'], $_POST['text'], $sender, $_POST['days']);
$telegraphText = "Вам пришёл подарок от {$from}!";
db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $receiver['id'], $telegraphText)->fetch_assoc();
db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $receiver['id'], $telegraphText);
$status = "Подарок удачно доставлен к {$_POST['receiver']}! Вы потратили <b>{$cost}</b> кр.";
}
?>