89 lines
3.6 KiB
PHP
89 lines
3.6 KiB
PHP
<?php
|
||
/* @var User $u */
|
||
|
||
use Core\Config;
|
||
use Core\Db;
|
||
use Model\ActionModel;
|
||
use User\ItemsModel;
|
||
|
||
$bonus = [
|
||
1 => [
|
||
'name' => 'light',
|
||
'items' => [
|
||
[5048, 4, 0, 'usefromfile=1|nohaos=1|musor=2|noremont=1|tr_align=1|srok=86400|nosale=1|sudba=1'],
|
||
[391, 1, 0, 'useOnLogin=1|musor=1|noremont=1|tr_align=3|srok=86400|nosale=1|sudba=1'],
|
||
[4943, 1, 0, 'usefromfile=1|musor=1|noremont=1|tr_align=7|srok=86400|nosale=1|sudba=1'],
|
||
],
|
||
],
|
||
3 => [
|
||
'name' => 'dark',
|
||
'items' => [
|
||
[391, 1, 0, 'useOnLogin=1|musor=1|noremont=1|tr_align=3|srok=86400|nosale=1|sudba=1'],
|
||
],
|
||
],
|
||
7 => [
|
||
'name' => 'neytral',
|
||
'items' => [
|
||
[4943, 1, 0, 'usefromfile=1|musor=1|noremont=1|tr_align=7|srok=86400|nosale=1|sudba=1'],
|
||
],
|
||
],
|
||
];
|
||
|
||
//items >
|
||
// 0 → id,
|
||
// 1 → количество использований,
|
||
// 2 → [0 => 'на сегодня', 1 => ' всего'] (только отображение),
|
||
// 3 → data,
|
||
|
||
$vnr = [0 => 'на сегодня', 1 => ' всего'];
|
||
$itemsString = '';
|
||
$linkGET = 'take_item_' . $bonus[(int)$u->info['align']]['name'] . '_panel';
|
||
$actionName = $bonus[(int)$u->info['align']]['name'] . '_itm';
|
||
|
||
Db::sql('delete from actions where uid = ? and time < unix_timestamp(current_date) and vars like ?', [$u->info['id'], $actionName . '%']);
|
||
|
||
foreach ($bonus[(int)$u->info['align']]['items'] as $bonusItem) {
|
||
if ($bonusItem[1] === 0) {
|
||
continue;
|
||
}
|
||
$item = Db::getRow('select * from items_main where id = ?', [$bonusItem[0]]);
|
||
if (!$item['id']) {
|
||
continue;
|
||
}
|
||
|
||
$bonusItemStock = Db::getValue('select count(*) from actions where uid = ? and time >= unix_timestamp(current_date) and vars = ?', [$u->info['id'], $actionName . $item['id']]);
|
||
|
||
if ($bonusItem[1] - $bonusItemStock > 0 && intval($_GET[$linkGET]) === $item['id']) {
|
||
$nitm = ItemsModel::addItem($item['id'], $u->info['id'], $bonusItem[3]);
|
||
ActionModel::new($u->info, '', $actionName . $item['id']);
|
||
echo '<span style="color: red">Предмет «<b>' . $item['name'] . '</b>» перемещен к Вам в инвентарь!</span><br><br>';
|
||
}
|
||
|
||
//Вывод предметов
|
||
$s = '<img title="' . $item['name'] . ' (Осталось ' . $vnr[$bonusItem[2]] . ': ' . ($bonusItem[1] - $bonusItemStock) . ' шт.)" src="' . Config::img() . '/i/items/' . $item['img'] . '"> ';
|
||
if ($bonusItem[1] - $bonusItemStock > 0) {
|
||
$s = '<a href="main.php?ap=1&' . $linkGET . '=' . $item['id'] . '">' . $s . '</a>';
|
||
} else {
|
||
$s = '<span style="filter: alpha(opacity=20); -moz-opacity: 0.20; opacity: 0.20;">' . $s . '</span>';
|
||
}
|
||
$itemsString .= $s;
|
||
}
|
||
|
||
?>
|
||
<link href="<?= Config::img() ?>/css/main.css" rel="stylesheet" type="text/css">
|
||
<link rel="stylesheet" type="text/css" href="../css/club.css"/>
|
||
<link rel="stylesheet" type="text/css" href="/css/windows.css"/>
|
||
<script>
|
||
let elem = document.getElementById('se-pre-con');
|
||
elem.parentNode.removeChild(elem);
|
||
</script>
|
||
<h3>Проходи, <?= User::getLogin($u->info['id']) ?>, угощайся!</h3>
|
||
<div style="text-align: right;">
|
||
<input type="button" class="btn" value="Обновить" onclick="location='main.php?ap=1';">
|
||
<input type="button" class="btn" value="Вернуться" onclick="location='main.php';">
|
||
</div>
|
||
<div style="text-align: center;">
|
||
<div><strong>Абилки:</strong><br/><sup>(Чтобы забрать предмет просто нажмите на его изображение)</sup></div>
|
||
<div><?= $itemsString ?></div>
|
||
</div>
|