battles/ashop.php

368 lines
25 KiB
PHP
Raw Normal View History

2018-01-28 16:40:49 +00:00
<?php
session_start();
if ($_SESSION['uid'] == null) header("Location: index.php");
include "config.php";
include "functions.php";
2018-06-22 14:52:29 +00:00
if ($user['room'] != 50) {
header("Location: main.php");
die();
}
$itemWeight = db::c()->query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $user['id'])->fetch_assoc();
if ($user['battle'] != 0) {
header('location: fbattle.php');
die();
}
2018-01-28 16:40:49 +00:00
2018-06-22 16:46:48 +00:00
$bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id`=?i', $_SESSION['uid'])->fetch_assoc();
2018-01-28 16:40:49 +00:00
2018-06-22 19:33:11 +00:00
//$set = isset($_POST['set']) ? $_POST['set'] : '';
//$var = $value ?: "Другое значение";
if (isset($_GET['set']) OR isset($_POST['set'])){
$set = empty($_GET['set']) ?: $_GET['set'];
$set = empty($_POST['set']) ?: $_POST['set'];
$count = isset($_POST['count']) && is_numeric($_POST['count']) ? $_POST['count'] : 0;
if ($count < 1) {
$count = 0;
2018-06-22 14:52:29 +00:00
$count_ok = 0;
} else $count_ok = 1;
2018-01-28 16:40:49 +00:00
2018-06-22 16:46:48 +00:00
$dress = db::c()->query('SELECT * FROM `ashop` WHERE `id`=?i', $set)->fetch_assoc();
2018-06-22 14:52:29 +00:00
if ($count_ok == 0) {
err('Неправильно введено количество.');
2018-06-22 14:52:29 +00:00
} elseif (($dress['massa'] * $_POST['count'] + $itemWeight['m']) > (get_meshok())) {
err('Недостаточно места в рюкзаке.');
2018-06-22 14:52:29 +00:00
} elseif ($count_ok == 1 && ($bank['ekr'] >= ($dress['ecost'] * $_POST['count'])) && ($dress['count'] >= $_POST['count'])) {
for ($k = 1; $k <= $_POST['count']; $k++) {
2018-06-22 16:46:48 +00:00
if (isset($dress['goden'])) $goden = $dress['goden'] * 24 * 60 * 60 + time(); // Ну вот нахуя?
db::c()->query('
INSERT INTO `inventory`
(
`prototype`,`owner`,`name`,`type`,`massa`,`cost`,`img`,`maxdur`,`isrep`,`gsila`,`glovk`,`ginta`,`gintel`,
`ghp`,`gnoj`,`gtopor`,`gdubina`,`gmech`,`gfire`,`gwater`,`gair`,`gearth`,`glight`,`ggray`,`gdark`,
`needident`,`nsila`,`nlovk`,`ninta`,`nintel`,`nmudra`,`nvinos`,`nnoj`,`ntopor`,`ndubina`,`nmech`,
`nfire`,`nwater`,`nair`,`nearth`,`nlight`,`ngray`,`ndark`,`mfkrit`,`mfakrit`,`mfuvorot`,`mfauvorot`,
`bron1`,`bron2`,`bron3`,`bron4`,`maxu`,`minu`,`magic`,`nlevel`,`nalign`,`dategoden`,`goden`,`otdel`,
`artefact`, `koll`
)
VALUES (?i,?i,"?s",?i,?i,"?s","?s",?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i)
', $dress['id'], $_SESSION['uid'], $dress['name'], $dress['type'], $dress['massa'], $dress['cost'], $dress['img'], $dress['maxdur'], $dress['isrep'],
$dress['gsila'], $dress['glovk'], $dress['ginta'], $dress['gintel'], $dress['ghp'], $dress['gnoj'], $dress['gtopor'], $dress['gdubina'], $dress['gmech'],
$dress['gfire'], $dress['gwater'], $dress['gair'], $dress['gearth'], $dress['glight'], $dress['ggray'], $dress['gdark'], $dress['needident'],
$dress['nsila'], $dress['nlovk'], $dress['ninta'], $dress['nintel'], $dress['nmudra'], $dress['nvinos'], $dress['nnoj'], $dress['ntopor'], $dress['ndubina'], $dress['nmech'],
$dress['nfire'], $dress['nwater'], $dress['nair'], $dress['nearth'], $dress['nlight'], $dress['ngray'], $dress['ndark'], $dress['mfkrit'], $dress['mfakrit'],
$dress['mfuvorot'], $dress['mfauvorot'], $dress['bron1'], $dress['bron3'], $dress['bron2'], $dress['bron4'], $dress['maxu'], $dress['minu'], $dress['magic'],
$dress['nlevel'], $dress['nalign'], $goden, $dress['goden'], $dress['razdel'], $dress['artefact'], $dress['koll']);
db::c()->query('UPDATE `ashop` SET `count` = `count`- ?i WHERE `id` = ?i', $_POST['count'], $set);
$invdb = db::c()->query('SELECT `id` FROM `inventory` WHERE `name` = "?s" ORDER by `id` DESC LIMIT ?i', $dress['name'], $_POST['count']);
if ($_POST['count'] == 1) {
$dressinv = $invdb->fetch_assoc();
2018-06-22 14:52:29 +00:00
$dressid = "cap" . $dressinv['id'];
$dresscount = " ";
} else {
$dressid = "";
2018-06-22 16:46:48 +00:00
while ($dressinv = $invdb->fetch_assoc()) {
2018-06-22 14:52:29 +00:00
$dressid .= "cap" . $dressinv['id'] . ",";
}
$dresscount = "(x" . $_POST['count'] . ") ";
}
$allcost = $_POST['count'] * $dress['ecost'];
2018-06-22 16:46:48 +00:00
$deloText = $user['login'] . " купил товар: " . $dress['name'] . $dresscount . "id:(" . $dressid . ") [0/" . $dress['maxdur'] . "] за " . $allcost . " екр.";
db::c()->query('INSERT INTO `delo` (`author` ,`pers`, `text`, `type`, `date`) VALUES (?i, ?i, "?s", ?i, "?s")', 0, $user['id'], $deloText, 1, time());
err('Вы купили ' .$_POST['count']. ' шт. "' .$dress['name']. '.');
2018-06-22 16:46:48 +00:00
db::c()->query('UPDATE `bank` set `ekr` = `ekr` - ?i WHERE `id` = ?i', $allcost, $_SESSION['uid']);
2018-06-22 14:52:29 +00:00
$bank['ekr'] -= $allcost;
2018-01-28 16:40:49 +00:00
}
2018-06-22 14:52:29 +00:00
} else {
err('Недостаточно денег или нет вещей в наличии.');
2018-01-28 16:40:49 +00:00
}
}
?>
<!DOCTYPE html>
2018-06-22 14:52:29 +00:00
<html>
<head>
<meta charset="utf-8">
<link href="css/main.css" rel="stylesheet"/>
2018-06-22 14:52:29 +00:00
<script language="JavaScript">
function AddCount(name, txt) {
document.all("hint3").innerHTML = '<form method=post style="margin:0; padding:0;"><table border=0 width=100% cellspacing=1 cellpadding=0 bgcolor="#CCC3AA"><tr><td align=center><B>Купить неск. штук</td><td width=20 align=right valign=top style="cursor: hand" onclick="closehint3();"><b>x</td></tr><tr><td colspan=2>' +
2018-06-22 14:52:29 +00:00
'<table border=0 width=100% cellspacing=0 cellpadding=0 bgcolor="#FFF6DD"><tr><input type="hidden" name="set" value="' + name + '"><td colspan=2 align=center><b><i>' + txt + '</td></tr><tr><td width=80% align=right>' +
'Количество (шт.) <input type="text" name="count" size=4 ></td><td width=20%>&nbsp;<input type="submit" value=" »» ">' +
'</td></tr></table></td></tr></table></form>';
document.all("hint3").style.visibility = "visible";
document.all("hint3").style.left = 100;
document.all("hint3").style.top = 100;
document.all("count").focus();
}
2018-01-28 16:40:49 +00:00
2018-06-22 14:52:29 +00:00
// Закрывает окно
function closehint3() {
document.all("hint3").style.visibility = "hidden";
}
</script>
2018-01-28 16:40:49 +00:00
</head>
<body>
<h1>Магазин Берёзка</h1>
2018-01-28 16:40:49 +00:00
<table border=0 width=100% cellspacing="0" cellpadding="0">
<tr>
<td align=right>
<form action="city.php" method=GET>
2018-06-22 14:52:29 +00:00
<input type="button" value="Подсказка" style="background-color:#A9AFC0"
onClick="window.open('help/shop.html', 'help', 'height=300,width=500,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes')">
<INPUT TYPE="button" onClick="location.href='city.php?cp=1';" value="Вернуться" title="Вернуться">
</form>
</td>
</tr>
2018-01-28 16:40:49 +00:00
</table>
<table border=0 width=100% cellspacing="0" cellpadding="4">
2018-06-22 14:52:29 +00:00
<tr>
<form method=POST>
2018-06-22 14:52:29 +00:00
<input type="hidden" name="sid" value="">
<input type="hidden" name="id" value="1">
<td valign=top align=left>
<!--Магазин-->
2018-06-22 19:33:11 +00:00
<table border=0 width=100% cellspacing="0" cellpadding="0" <?php if (!$_REQUEST['present']) { echo 'bgcolor="#A5A5A5"';} ?>>
2018-06-22 14:52:29 +00:00
<tr>
<td align=center><b>
2018-06-22 19:33:11 +00:00
<?php
2018-06-22 14:52:29 +00:00
if ($_REQUEST['compare'] && !$_REQUEST['common'] && !$_REQUEST['present']) {
echo "Составление подарочного букета";
} elseif ($_REQUEST['present']) {
//echo "Составление подарочного букета";
} else {
switch ($_GET['otdel']) {
case null:
echo "Оружие: кастеты,ножи";
$_GET['otdel'] = 1;
break;
case 1:
echo "Оружие: кастеты,ножи";
break;
case 11:
echo "Оружие: топоры";
break;
case 12:
echo "Оружие: дубины,булавы";
break;
case 13:
echo "Оружие: мечи";
break;
case 14:
echo "Оружие: луки и арбалеты";
break;
case 2:
echo "Одежда: сапоги";
break;
case 21:
echo "Одежда: перчатки";
break;
case 22:
echo "&Одежда: легкая броня";
break;
case 23:
echo "Одежда: тяжелая броня";
break;
case 24:
echo "Одежда: шлемы";
break;
case 3:
echo "Щиты";
break;
case 4:
echo "Ювелирные товары: серьги";
break;
case 41:
echo "Ювелирные товары: ожерелья";
break;
case 42:
echo "Ювелирные товары: кольца";
break;
case 5:
echo "Заклинания: нейтральные";
break;
case 51:
echo "Заклинания: боевые и защитные";
break;
case 6:
echo "Амуниция";
break;
case 7:
echo "Букеты";
break;
}
}
?>
</b></td>
</tr>
<tr>
<td><!--Рюкзак-->
<table border=0 width=100% cellspacing="1" cellpadding="2" bgcolor="#A5A5A5">
2018-06-22 19:33:11 +00:00
<?php
2018-06-22 14:52:29 +00:00
if ($_REQUEST['present']) {
if ($_POST['to_login'] && $_POST['flower']) {
2018-06-22 16:46:48 +00:00
$to = db::c()->query('SELECT `id`,`login`,`room` FROM `users` WHERE `login` = ?i', $_POST['to_login'])->fetch_assoc();
2018-06-22 14:52:29 +00:00
if ($_POST['to_login'] == $user['login']) {
err('Очень щедро - дарить что-то самому себе! ;)');
2018-06-22 14:52:29 +00:00
} elseif ($to['room'] > 500 && $to['room'] < 561) {
err('Персонаж в данный момент участвует в турнире в Башне Смерти. Попробуйте позже.');
2018-06-22 14:52:29 +00:00
} else {
if ($_POST['from'] == 1) {
$from = 'Аноним';
} elseif ($_POST['from'] == 2 && $user['klan']) {
$from = ' клана ' . $user['klan'];
} else {
$from = $user['login'];
}
2018-06-22 16:46:48 +00:00
2018-06-22 19:33:11 +00:00
db::c()->query('UPDATE `inventory` SET `owner` = ?i, `present` = "?s", `letter` = "?s" WHERE `present` = "?s" AND `id` = "?s" AND `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $to['id'], $from, $_POST['podarok2'], null, $_POST['flower'], $_SESSION['uid']);
2018-06-22 16:46:48 +00:00
$res = db::c()->query('SELECT `id`,`name`,`duration`,`maxdur` FROM `inventory` WHERE `id` = ?i', $_POST['flower'])->fetch_assoc();
$deloTextSender = "Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\"";
$deloTextReceiver = "Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\"";
db::c()->query('INSERT INTO `delo`(`author`,`pers`,`text`,`type`,`date`) VALUES (0,?i,"?s",1,?i)', $_SESSION['uid'], $deloTextSender, time());
db::c()->query('INSERT INTO `delo`(`author`,`pers`,`text`,`type`,`date`) VALUES (0,?i,"?s",1,?i)', $to['id'], $deloTextReceiver, time());
$telegraphText = "Вам пришёл подарок \"" . $res['name'] . "\" от " . $from . "!";
db::c()->query('INSERT INTO `telegraph` (owner, text) VALUES (?i,"?s")', $to['id'], $telegraphText)->fetch_assoc();
err('Подарок удачно доставлен к ' . $_POST['to_login']);
2018-06-22 14:52:29 +00:00
}
}
?>
<!-- Подарить подарок -->
2018-06-22 14:52:29 +00:00
<table cellspacing=0 cellpadding=0 width=100% bgcolor=#e0e0e2>
<td>
<form method="post">
2018-06-22 14:52:29 +00:00
<input type=hidden name=present value=1>
Вы можете сделать подарок дорогому человеку. Ваш подарок будет
отображаться в информации о персонаже.
<ol>
<li>Укажите логин персонажа, которому хотите сделать подарок<br>
<input type=text name=to_login value="" placeholder="Логин">
<li><input type=text name=podarok2 value="" maxlength=60 size=50 placeholder="Цель подарка.">
<li><textarea name=txt rows=6 cols=80 placeholder="Текст сопроводительной записки (в информации о персонаже не отображается)"></textarea>
2018-06-22 14:52:29 +00:00
<li>Выберите, от чьего имени подарок:<br>
<label><input type=radio name=from value=0 checked> <?= nick::id($user['id'])->full() ?></label><br>
<label><input type=radio name=from value=1> анонимно</label><br>
<label><input type=radio name=from value=2> от имени клана</label><br>
2018-06-22 14:52:29 +00:00
<li>Нажмите кнопку <b>Подарить</b> под предметом, который хотите
преподнести в подарок:<br>
</ol>
<input type="hidden" name="flower" id="flower" value="">
<table border=0 width=100% cellspacing="1" cellpadding="2" bgcolor="#A5A5A5">
2018-06-22 14:52:29 +00:00
<?
//print_r($_POST);
2018-06-22 16:46:48 +00:00
$data = db::c()->query('SELECT `id`,`img` FROM `inventory` WHERE `owner`= ?i
AND `dressed` = 0
AND (
`name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR
`name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S"
)
AND `setsale` = 0 AND `present` = "?s"
ORDER by `id` DESC', $_SESSION['uid'], '%Букет%','%Сувенир%','%Подарок%','%Валентинка%','%Открытка%','Ель%','%Медаль%','%Статуэтка%',null);
while ($row = $data->fetch_assoc()) {
2018-06-22 14:52:29 +00:00
if (!in_array($row['id'], array_keys($_SESSION['flowers']))) {
$row['count'] = 1;
if ($i == 0) {
$i = 1;
$color = '#C7C7C7';
} else {
$i = 0;
$color = '#D5D5D5';
}
echo "<tr bgcolor={$color}><td align=center style='width:150px'><img src=\"i/sh/{$row['img']}\" border=0>";
?>
<br><input type=submit
onClick="document.all['flower'].value="<?= $row['id']; ?>"" value="Подарить">
</form>
</td>
<?
echo "<td valign=top>";
showitem($row);
echo "</td></tr>";
}
}
?>
</table>
2018-06-22 14:52:29 +00:00
<?
} else {
2018-06-22 19:34:55 +00:00
$data = db::c()->query('SELECT `id`,`img`,`name` FROM `ashop` WHERE `count` > 0 AND `razdel` = "?s" AND `ecost` > 0 ORDER by `ecost` ASC', $_GET['otdel']);
2018-06-22 16:46:48 +00:00
while ($row = $data->fetch_assoc()) {
2018-06-22 14:52:29 +00:00
if ($i == 0) {
$i = 1;
$color = '#C7C7C7';
} else {
$i = 0;
$color = '#D5D5D5';
}
echo "<tr bgcolor=" . $color . "><td align=center style='width:150px'><img src=\"i/sh/{$row['img']}\" border=0>";
?>
<br/>
<a href="ashop.php?otdel=<?= $_GET['otdel'] ?>&set=<?= $row['id'] ?>&sid=">купить</A>
<img src="i/up.gif" width=11 height=11 border=0 alt="Купить несколько штук"
style="cursor:hand"
onClick="AddCount("<?= $row['id'] ?>", "<?= $row['name'] ?>")"></td>
<?
echo "<td valign=top>";
showitem($row);
echo "</td></tr>";
}
}
?>
</table>
</td>
</tr>
</table>
</td>
<td valign=top width=280>
<b>Масса всех ваших вещей: <?=$itemWeight['m']?>/<?=get_meshok()?>
<br>У вас в наличии: <span style="color: #339900;"><?=$bank['ekr']?></span> екр.</b>
2018-06-22 14:52:29 +00:00
<!--<hr /><a href=upgrade_items.php><font color=blue>Улучшение Артефактов</font></a>-->
<hr>
<div style="margin-left:15px; margin-top: 10px;">
<form method="post">
</div>
</form>
<div style="background-color: #d2d0d0;padding: 1px; text-align: center; font-weight: bold;">
Отделы магазина
2018-06-22 14:52:29 +00:00
</div>
<b>Оружие:</b><br>
<!--<a href="ashop.php?otdel=1&sid=&0.162486541405194">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;кастеты,ножи</a><br>-->
<a href="ashop.php?otdel=11&sid=&0.337606814894404">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;топоры</a><br>
<a href="ashop.php?otdel=12&sid=&0.286790872806733">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;дубины,булавы</a><br>
<a href="ashop.php?otdel=13&sid=&0.0943516060419363">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;мечи</a><br>
<b>Одежда:</b><br>
<a href="ashop.php?otdel=24&sid=&0.567932791291376">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;шлемы</a><br>
<a href="ashop.php?otdel=23&sid=&0.99133839275569">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;тяжелая броня</a><br>
<a href="ashop.php?otdel=22&sid=&0.520447517792988">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;легкая броня</a><br>
<a href="ashop.php?otdel=3&sid=&0.725667864710179">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;щиты</a><br>
<!--<a href="ashop.php?otdel=21&sid=&0.648260824682342">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;перчатки</a><br>-->
<a href="ashop.php?otdel=2&sid=&0.76205958316951">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;сапоги</a><br>
<b>Ювелирные товары:</b><br>
<!--<a href="ashop.php?otdel=4&sid=&0.321709306035984">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;серьги</a><br>
<a href="ashop.php?otdel=41&sid=&0.902093651333512">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ожерелья</a><br>-->
<a href="ashop.php?otdel=42&sid=&0.510210803380268">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;кольца</a><br>
<b>Магия:</b><br>
<!--<a href="ashop.php?otdel=51&sid=&0.722009624500359">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;боевые</a><br>-->
<a href="ashop.php?otdel=5&sid=&0.648834385828923">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;разные</a><br>
<b>Разное:</b><br>
<!--<a href="ashop.php?otdel=6&sid=&0.925798340638547">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;амуниция</a><br>-->
<a href="ashop.php?otdel=7&sid=&0.925798340638547">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;букеты</a><br>
</div>
<div id="hint3" class="ahint"></div>
</td>
</form>
</tr>
2018-01-28 16:40:49 +00:00
</table>
</body>
</html>