1. finalize ekrshop

2. shop bying fixes
3. item class code clear
4. moved all gifts to separate file
5. removed artefact upgrade
This commit is contained in:
Igor Barkov [iwork] 2019-01-15 17:56:15 +02:00
parent a393f67ccd
commit 016e5a9ccd
7 changed files with 305 additions and 422 deletions

267
ashop.php
View File

@ -1,15 +1,13 @@
<?php
session_start();
if ($_SESSION['uid'] == null) header("Location: index.php");
include "config.php";
include "functions.php";
require_once 'functions.php';
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();
@ -17,25 +15,28 @@ if ($user['battle'] != 0) {
$bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id`=?i', $_SESSION['uid'])->fetch_assoc();
if (isset($_GET['set']) OR isset($_POST['set'])) {
$shopItems = db::c()->query('SELECT `ashop`.*,
`magic`.`name` AS `magic_name`,
`magic`.`chanse` AS `magic_chanse`,
`magic`.`time` AS `magic_time`,
`magic`.`file` AS `magic_file`,
`magic`.`targeted` AS `magic_targeted`,
`magic`.`needcharge` AS `magic_needcharge`,
`magic`.`img` AS `magic_img`
$set = empty($_GET['set']) ?: $_GET['set'];
$set = empty($_POST['set']) ?: $_POST['set'];
FROM `ashop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `count` > 0 AND `cost` > 0 AND `razdel` = ?i ORDER by `nlevel` ASC, `id` ASC', $_GET['otdel']);
$count = isset($_POST['count']) && is_numeric($_POST['count']) ? $_POST['count'] : 0;
$iteminfo = [];
while ($row = $shopItems->fetch_assoc()) {
$iteminfo[] = new ShopItem($row);
}
if ($count < 1) {
$count = 0;
$count_ok = 0;
} else $count_ok = 1;
if (!empty($_GET['buy'])) {
$dress = db::c()->query('SELECT * FROM `ashop` WHERE `id`=?i', $_GET['buy'])->fetch_assoc();
$itemWeight = db::c()->query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0', $user['id'])->fetch_assoc();
if (($dress['massa'] + $itemWeight['m']) > (get_meshok())) $status = 'Недостаточно места в рюкзаке.';
elseif ($bank['ekr'] >= $dress['ecost'] AND ($dress['count'] > 0 OR $dress['count'] == -1)) {
$dress = db::c()->query('SELECT * FROM `ashop` WHERE `id`=?i', $set)->fetch_assoc();
if ($count_ok == 0) {
err('Неправильно введено количество.');
} elseif (($dress['massa'] * $_POST['count'] + $itemWeight['m']) > (get_meshok())) {
err('Недостаточно места в рюкзаке.');
} elseif ($count_ok == 1 && ($bank['ekr'] >= ($dress['ecost'] * $_POST['count'])) && ($dress['count'] >= $_POST['count'])) {
for ($k = 1; $k <= $_POST['count']; $k++) {
$goden = '';
if (isset($dress['goden'])) $goden = $dress['goden'] * 24 * 60 * 60 + time(); // Ну вот нахуя?
db::c()->query('
@ -57,28 +58,19 @@ if (isset($_GET['set']) OR isset($_POST['set'])) {
$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();
$dressid = "cap" . $dressinv['id'];
$dresscount = " ";
$inventoryItemId = db::c()->getLastInsertId();
if ($dress['count'] != -1) db::c()->query('UPDATE `ashop` SET `count` = `count`- 1 WHERE `id` = ?i', $_GET['buy']);
$deloText = "{$user['login']} купил товар «{$dress['name']}» id:({$inventoryItemId}) в магазине «Берёзка» за {$dress['ecost']} екр.";
addToDelo($deloText);
$status = "Вы купили «{$dress['name']}» за {$dress['ecost']} екр.";
db::c()->query('UPDATE `bank` SET `ekr` = `ekr` - ?i WHERE `id` = ?i', $dress['ecost'], $_SESSION['uid']);
// Для обновления данных о деньгах на странице
$bank['ekr'] -= $dress['ecost'];
} else {
$dressid = "";
while ($dressinv = $invdb->fetch_assoc()) {
$dressid .= "cap" . $dressinv['id'] . ",";
}
$dresscount = "(x" . $_POST['count'] . ") ";
}
$allcost = $_POST['count'] * $dress['ecost'];
$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'] . '.');
db::c()->query('UPDATE `bank` SET `ekr` = `ekr` - ?i WHERE `id` = ?i', $allcost, $_SESSION['uid']);
$bank['ekr'] -= $allcost;
}
} else {
err('Недостаточно денег или нет вещей в наличии.');
$status = "Недостаточно денег или нет вещей в наличии.";
}
}
$shopCategory = '';
@ -146,202 +138,67 @@ if ($_REQUEST['compare'] && !$_REQUEST['common'] && !$_REQUEST['present']) {
break;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="css/main.css" rel="stylesheet"/>
<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>' +
'<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();
}
// Закрывает окно
function closehint3() {
document.all("hint3").style.visibility = "hidden";
}
function leave() {
top.frames['main'].location = 'city.php?cp'
}
</script>
<script src="js/main.js"></script>
</head>
<body>
<h1>Магазин Берёзка</h1>
<a href=# onclick=leave()> ← выйти на Центральную площадь</a>
<a href=# onclick=leave('city.php?cp')> ← выйти на Центральную площадь</a>
<div><?php if (!empty($status)) err($status); ?></div>
<table border=0 width=100% cellspacing="0" cellpadding="4">
<tr>
<td valign=top align=left>
<h3><?= $shopCategory ?></h3>
<!--Магазин-->
<table border=0 width=100% cellspacing="0" cellpadding="0">
<table class="zebra" width=100% cellspacing="1" cellpadding="2">
<?php foreach ($iteminfo as $ii): ?>
<tr>
<td>
<h3><?=$shopCategory?></h3>
</td>
</tr>
<tr>
<td><!--Рюкзак-->
<table border=0 width=100% cellspacing="1" cellpadding="2" bgcolor="#A5A5A5">
<?php
if ($_REQUEST['present']) {
if ($_POST['to_login'] && $_POST['flower']) {
$to = db::c()->query('SELECT `id`,`login`,`room` FROM `users` WHERE `login` = ?i', $_POST['to_login'])->fetch_assoc();
if ($_POST['to_login'] == $user['login']) {
err('Очень щедро - дарить что-то самому себе! ;)');
} elseif ($to['room'] > 500 && $to['room'] < 561) {
err('Персонаж в данный момент участвует в турнире в Башне Смерти. Попробуйте позже.');
} else {
if ($_POST['from'] == 1) {
$from = 'Аноним';
} elseif ($_POST['from'] == 2 && $user['klan']) {
$from = ' клана ' . $user['klan'];
} else {
$from = $user['login'];
}
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']);
$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` (receiver, text) VALUES (?i,"?s")', $to['id'], $telegraphText)->fetch_assoc();
err('Подарок удачно доставлен к ' . $_POST['to_login']);
}
}
?>
<!-- Подарить подарок -->
<table cellspacing=0 cellpadding=0 width=100% bgcolor=#e0e0e2>
<td>
<form method="post">
<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>
<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>
<li>Нажмите кнопку <b>Подарить</b> под предметом, который хотите
преподнести в подарок:<br>
</ol>
<input type="hidden" name="flower" id="flower" value="">
<table class="zebra" width=100% cellspacing="1" cellpadding="2"
bgcolor="#A5A5A5">
<?php
$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()) {
if (!in_array($row['id'], array_keys($_SESSION['flowers']))) {
$row['count'] = 1;
?>
<tr>
<td align=center style='width:150px'>
<img src="i/sh/<?= $row['img'] ?>">
<br><input type=submit
onClick="document.all['flower'].value="<?= $row['id']; ?>
value="Подарить">
</td>
<td valign=top>
<?php showitem($row); ?>
</td>
</tr>
<?php
}
}
?>
</form>
</td>
</table>
<?
} else {
$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']);
while ($row = $data->fetch_assoc()) {
?>
<tr>
<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>
<td valign=top>
<?php showitem($row); ?>
</td>
</tr>
<?php
}
}
?>
</table>
<td style='width: 150px; text-align: center;'>
<?php $ii->printImage();
$ii->printControls('ashop'); ?>
</td>
<td style='vertical-align: top;'>
<?php $ii->printInfo(); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</td>
<td valign=top width=280>
<b>Масса всех ваших вещей: <?= getItemsMassaInfo() ?>
<br>У вас в наличии: <span style="color: #339900;"><?= $bank['ekr'] ?></span> екр.</b>
<hr/>
<a href=upgrade_items.php>Улучшение Артефактов</a>
<hr>
<div style="background-color: #d2d0d0;padding: 1px; text-align: center; font-weight: bold;">
Отделы магазина
</div>
<div style="text-align: center; font-weight: bold;">Отделы магазина</div>
<dl>
<dt><b>Оружие:</b></dt>
<dd><a href="ashop.php?otdel=1&rnd=<?= mt_rand() ?>">кастеты,ножи</a></dd>
<dd><a href="ashop.php?otdel=11&rnd=<?= mt_rand() ?>">топоры</a></dd>
<dd><a href="ashop.php?otdel=12&rnd=<?= mt_rand() ?>">дубины,булавы</a></dd>
<dd><a href="ashop.php?otdel=13&rnd=<?= mt_rand() ?>">мечи</a></dd>
<dd><a href="?otdel=1&rnd=<?= mt_rand() ?>">кинжалы</a></dd>
<dd><a href="?otdel=11&rnd=<?= mt_rand() ?>">топоры</a></dd>
<dd><a href="?otdel=12&rnd=<?= mt_rand() ?>">дубины</a></dd>
<dd><a href="?otdel=13&rnd=<?= mt_rand() ?>">мечи</a></dd>
<dt><b>Одежда:</b></dt>
<dd><a href="ashop.php?otdel=24&rnd=<?= mt_rand() ?>">шлемы</a></dd>
<dd><a href="ashop.php?otdel=23&rnd=<?= mt_rand() ?>">тяжелая броня</a></dd>
<dd><a href="ashop.php?otdel=22&rnd=<?= mt_rand() ?>">легкая броня</a></dd>
<dd><a href="ashop.php?otdel=3&rnd=<?= mt_rand() ?>">щиты</a></dd>
<dd><a href="ashop.php?otdel=21&rnd=<?= mt_rand() ?>">перчатки</a></dd>
<dd><a href="ashop.php?otdel=2&rnd=<?= mt_rand() ?>">сапоги</a></dd>
<dd><a href="?otdel=24&rnd=<?= mt_rand() ?>">шлемы</a></dd>
<dd><a href="?otdel=23&rnd=<?= mt_rand() ?>">тяжелая броня</a></dd>
<dd><a href="?otdel=22&rnd=<?= mt_rand() ?>">легкая броня</a></dd>
<dd><a href="?otdel=3&rnd=<?= mt_rand() ?>">щиты</a></dd>
<dd><a href="?otdel=21&rnd=<?= mt_rand() ?>">перчатки</a></dd>
<dd><a href="?otdel=2&rnd=<?= mt_rand() ?>">сапоги</a></dd>
<dt><b>Ювелирные товары:</b></dt>
<dd><a href="ashop.php?otdel=4&rnd=<?= mt_rand() ?>">серьги</a></dd>
<dd><a href="ashop.php?otdel=41&rnd=<?= mt_rand() ?>">ожерелья</a></dd>
<dd><a href="ashop.php?otdel=42&rnd=<?= mt_rand() ?>">кольца</a></dd>
<dd><a href="?otdel=4&rnd=<?= mt_rand() ?>">серьги</a></dd>
<dd><a href="?otdel=41&rnd=<?= mt_rand() ?>">ожерелья</a></dd>
<dd><a href="?otdel=42&rnd=<?= mt_rand() ?>">кольца</a></dd>
<dt><b>Магия:</b></dt>
<dd><a href="ashop.php?otdel=51&rnd=<?= mt_rand() ?>">боевые</a></dd>
<dd><a href="ashop.php?otdel=5&rnd=<?= mt_rand() ?>">разные</a></dd>
<dd><a href="?otdel=51&rnd=<?= mt_rand() ?>">боевые</a></dd>
<dd><a href="?otdel=5&rnd=<?= mt_rand() ?>">разные</a></dd>
<dt><b>Разное:</b></dt>
<dd><a href="ashop.php?otdel=6&rnd=<?= mt_rand() ?>">амуниция</a></dd>
<dd><a href="ashop.php?otdel=7rnd=<?= mt_rand() ?>">букеты</a></dd>
<dd><a href="?otdel=6&rnd=<?= mt_rand() ?>">амуниция</a></dd>
<dd><a href="?otdel=7rnd=<?= mt_rand() ?>">букеты</a></dd>
</dl>
<div id="hint3" class="ahint"></div>
</td>
</tr>
</table>

View File

@ -98,64 +98,6 @@ abstract class Item
}
}
// ТА ЛААААДНО?!
// $this->name = $row['name'];
// $this->massa = $row['massa'];
// $this->maxdur = $row['maxdur'];
// $this->img = $row['img'];
//
// $this->type = $row['type'];
//
// $this->nlevel = $row['nlevel'];
// $this->nalign = $row['nalign'];
// $this->nsila = $row['nsila'];
// $this->nlovk = $row['nlovk'];
// $this->ninta = $row['ninta'];
// $this->nvinos = $row['nvinos'];
// $this->nintel = $row['nintel'];
// $this->nmudra = $row['nmudra'];
// $this->nnoj = $row['nnoj'];
// $this->ntopor = $row['ntopor'];
// $this->ndubina = $row['ndubina'];
// $this->nmech = $row['nmech'];
// $this->nfire = $row['nfire'];
// $this->nwater = $row['nwater'];
// $this->nair = $row['nair'];
// $this->nearth = $row['nearth'];
// $this->nlight = $row['nlight'];
// $this->ngray = $row['ngray'];
// $this->ndark = $row['ndark'];
//
// $this->minu = $row['minu'];
// $this->maxu = $row['maxu'];
//
// $this->gsila = $row['gsila'];
// $this->glovk = $row['glovk'];
// $this->ginta = $row['ginta'];
// $this->gintel = $row['gintel'];
// $this->gnoj = $row['gnoj'];
// $this->gtopor = $row['gtopor'];
// $this->gdubina = $row['gdubina'];
// $this->gmech = $row['gmech'];
// $this->gfire = $row['gfire'];
// $this->gwater = $row['gwater'];
// $this->gair = $row['gair'];
// $this->gearth = $row['gearth'];
// $this->glight = $row['glight'];
// $this->ggray = $row['ggray'];
// $this->gdark = $row['gdark'];
// $this->ghp = $row['ghp'];
//
// $this->bron1 = $row['bron1'];
// $this->bron2 = $row['bron2'];
// $this->bron3 = $row['bron3'];
// $this->bron4 = $row['bron4'];
//
// $this->mfkrit = $row['mfkrit'];
// $this->mfakrit = $row['mfakrit'];
// $this->mfuvorot = $row['mfuvorot'];
// $this->mfauvorot = $row['mfauvorot'];
switch ($this->type) {
case 1:
$this->typename = 'Серьги';

View File

@ -10,19 +10,46 @@ class ShopItem extends Item
parent::printMagic();
}
public function buyItem($owner)
{
if ($owner) {
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,?i,"?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,"?s",?i,?i)
', $this->id, $owner, $this->name, $this->type, $this->massa, $this->cost, $this->img, $this->maxdur,$this->isrep,$this->gsila,$this->glovk,$this->ginta,$this->gintel,
$this->ghp,$this->gnoj,$this->gtopor,$this->gdubina,$this->gmech,$this->gfire,$this->gwater,$this->gair,$this->gearth,$this->glight,$this->ggray,$this->gdark,
$this->needident,$this->nsila,$this->nlovk,$this->ninta,$this->nintel,$this->nmudra,$this->nvinos, $this->nnoj,$this->ntopor,$this->ndubina,$this->nmech,
$this->nfire,$this->nwater,$this->nair, $this->nearth,$this->nlight,$this->ngray,$this->ndark,$this->mfkrit,$this->mfakrit,$this->mfuvorot,$this->mfauvorot,
$this->bron1,$this->bron2,$this->bron3,$this->bron4,$this->maxu,$this->minu,$this->magic,$this->nlevel,$this->nalign,$this->dategoden,$this->goden,$this->razdel,
$this->artefact, $this->koll);
}
}
/**
* Для кнопок управления под картинкой прелмета в зависимости от ситуации.
*/
public function printControls($sell = false)
public function printControls($shopType = false)
{
if ($sell) {
$btnPrice = "Продать";
$btnLink = "/shop.php?sell={$this->id}&rnd=".mt_rand();
$this->maxdur = 0;
} else {
switch ($shopType) {
default:
$btnPrice = "Купить за " . intval($this->cost) . " кр.";
$btnLink = "/shop.php?buy={$this->id}&rnd=" . mt_rand();
break;
case 'ashop':
$btnPrice = "Купить за " . intval($this->ecost) . "р.";
$btnLink = "/ashop.php?buy={$this->id}&rnd=" . mt_rand();
break;
case 'sell':
$btnPrice = "Продать";
$btnLink = "/shop.php?sell={$this->id}&rnd=".mt_rand();
break;
}
echo <<<BTN
<p><input type="button" style="background: darkgrey; border: 1px solid grey; border-radius: 2px;" value="{$btnPrice}"
onclick="location='{$btnLink}'">

View File

@ -1612,7 +1612,7 @@ function showitem2()
* По ходу, главная функция отображения предметов.
*
* @param array $row - массив значений, передаваймый из запроса к таблице inventory
* @param int $type - тип предмета. Где бы их всех взять?
* @param int $type - тип предмета. Перечислены в /Classes/Item.php
* @param bool $returned
* @param bool $infOnly
*
@ -1688,8 +1688,6 @@ function showitem($row, $type = null, $returned = false, $infOnly = false)
$returnHTML .= '<br />ID: ' . $row['id'] . '<br />';
if ($row["koll"] > 1) $returnHTML .= "<a title=\"Разделить\" onclick=\"splitstack('$row[name]','main.php?edit=1&unstack=$row[id]', '$row[img]', 1);return false;\" href=\"javascript:void(0)\"><img border=\"0\" src=\"i/unstack.gif\"></a>&nbsp;";
$returnHTML .= "<img src=i/clear.gif style=\"cursor:hand;\" onclick=\"delItmsNo('Выкинуть предмет?','deleteItems',0,'','" . $row['img'] . "','" . $row['name'] . "','main.php?edit=1&destruct=" . $row['id'] . "');\"></TD><td>";
} else {
$returnHTML .= "<a href=upgrade_items.php?up=" . $row['id'] . ">Улучшить</a></td>";
}
}

125
presents.php Normal file
View File

@ -0,0 +1,125 @@
<?php
/**
* Created by PhpStorm.
* User: Lopar
* Date: 15.01.2019
* Time: 14:51
*/
/*
* Файл в котором буду аккумулироваться покупка и отправка подарков и сувениров, которые не будут являться предметами,
* а просто записями в базе и просто будут отображаться в инвентаре, как неосязаемая сущность со сроком годности или
* без и правом игрока скрыть или удалить любой подаренный подарок.
*
* На текущем этапе сюда сливаются все подарочные исходные коды из других мест.
*/
session_start();
if ($_SESSION['uid'] != 11263) header("Location: index.php");
require_once 'functions.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="css/main.css" rel="stylesheet"/>
<script src="js/main.js"></script>
</head>
<body>
<h1>Магазин подарков</h1>
<?php
if ($_REQUEST['present']) {
if ($_POST['to_login'] && $_POST['flower']) {
$to = db::c()->query('SELECT `id`,`login`,`room` FROM `users` WHERE `login` = ?i', $_POST['to_login'])->fetch_assoc();
if ($_POST['to_login'] == $user['login']) {
err('Очень щедро - дарить что-то самому себе! ;)');
} elseif ($to['room'] > 500 && $to['room'] < 561) {
err('Персонаж в данный момент участвует в турнире в Башне Смерти. Попробуйте позже.');
} else {
if ($_POST['from'] == 1) {
$from = 'Аноним';
} elseif ($_POST['from'] == 2 && $user['klan']) {
$from = ' клана ' . $user['klan'];
} else {
$from = $user['login'];
}
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']);
$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` (receiver, text) VALUES (?i,"?s")', $to['id'], $telegraphText)->fetch_assoc();
err('Подарок удачно доставлен к ' . $_POST['to_login']);
}
}
}
?>
<!-- Подарить подарок -->
<table cellspacing=0 cellpadding=0 width=100% bgcolor=#e0e0e2>
<td>
<form method="post">
<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>
<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>
<li>Нажмите кнопку <b>Подарить</b> под предметом, который хотите
преподнести в подарок:<br>
</ol>
<input type="hidden" name="flower" id="flower" value="">
<table class="zebra" width=100% cellspacing="1" cellpadding="2"
bgcolor="#A5A5A5">
<?php
$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()) {
if (!in_array($row['id'], array_keys($_SESSION['flowers']))) {
$row['count'] = 1;
?>
<tr>
<td align=center style='width:150px'>
<img src="i/sh/<?= $row['img'] ?>">
<br><input type=submit
onClick="document.all['flower'].value="<?= $row['id']; ?>
value="Подарить">
</td>
<td valign=top>
<?php showitem($row); ?>
</td>
</tr>
<?php
}
}
?>
</form>
</td>
</table>
</body>
</html>

View File

@ -2,7 +2,7 @@
ob_start();
session_start();
if ($_SESSION['uid'] == null) header("Location: index.php");
require_once("functions.php");
require_once 'functions.php';
if ($user['room'] != 22) {
header("Location: main.php");
@ -101,7 +101,10 @@ FROM `shop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `count` > 0 AND `c
`magic`.`img` AS `magic_img`,
0 AS `maxdur`
FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0 AND `setsale` = 0 AND `cost` > 0 AND `present` = "?s" AND `tradesale` = 0 AND `podzem` = 0 AND `goden` = 0 AND `owner` = ?i ORDER BY `update` DESC', null, $_SESSION['uid']);
FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE
`dressed` = 0 AND `setsale` = 0 AND `cost` > 0 AND `present` = "?s" AND
`tradesale` = 0 AND `podzem` = 0 AND `goden` = 0 AND `artefact` = 0 AND `owner` = ?i
ORDER BY `update` DESC', null, $_SESSION['uid']);
$iteminfo = [];
while ($row = $inventoryItems->fetch_assoc()) {
@ -113,14 +116,14 @@ FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0
$sellItemId = filter_input(INPUT_GET, 'sell');
if ($sellItemId) {
$dress = db::c()->query('SELECT `id`, `name`, `cost`, `koll` FROM `inventory` WHERE `dressed` = 0 AND `id` = ?i AND `owner` = ?i', $sellItemId, $user['id'])->fetch_assoc();
$dress = db::c()->query('SELECT `id`, `name`, `cost`, `koll` FROM `inventory` WHERE `dressed` = 0 AND `artefact` = 0 AND `id` = ?i AND `owner` = ?i', $sellItemId, $user['id'])->fetch_assoc();
$kols = '';
if ($dress['koll']) {
$dress['cost'] *= $dress['koll'];
$kols = " (x{$dress['koll']}) ";
}
$allcost = mt_rand(0,$dress['cost']/2);
$allcost = mt_rand(0, $dress['cost'] / 2);
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $dress['id']);
db::c()->query('UPDATE `users` SET `money` = `money` + ?i WHERE `id` = ?i', $allcost, $_SESSION['uid']);
if ($allcost == 0) $status = "После длительных и изнурительных торгов вы плюнули на всё и просто подарили ваш «{$dress['name']}» торговцу.";
@ -151,6 +154,7 @@ if (!empty($_GET['buy'])) {
'glovk' => $dress['glovk'],
'ginta' => $dress['ginta'],
'gintel' => $dress['gintel'],
'ghp' => $dress['ghp'],
'gnoj' => $dress['gnoj'],
'gtopor' => $dress['gtopor'],
@ -163,6 +167,7 @@ if (!empty($_GET['buy'])) {
'glight' => $dress['glight'],
'ggray' => $dress['ggray'],
'gdark' => $dress['gdark'],
'needident' => $dress['needident'],
'nsila' => $dress['nsila'],
'nlovk' => $dress['nlovk'],
@ -174,6 +179,19 @@ if (!empty($_GET['buy'])) {
'ntopor' => $dress['ntopor'],
'ndubina' => $dress['ndubina'],
'nmech' => $dress['nmech'],
'nfire' => $dress['nfire'],
'nwater' => $dress['nwater'],
'nair' => $dress['nair'],
'nearth' => $dress['nearth'],
'nlight' => $dress['nlight'],
'ngray' => $dress['ngray'],
'ndark' => $dress['ndark'],
'mfkrit' => $dress['mfkrit'],
'mfakrit' => $dress['mfakrit'],
'mfuvorot' => $dress['mfuvorot'],
'mfauvorot' => $dress['mfauvorot'],
'bron1' => $dress['bron1'],
'bron2' => $dress['bron2'],
'bron3' => $dress['bron3'],
@ -187,10 +205,10 @@ if (!empty($_GET['buy'])) {
'goden' => $dress['goden'],
'gmp' => $dress['gmp'],
'artefact' => $dress['artefact'],
'koll' => $dress['koll']
'koll' => $dress['koll'],
];
db::c()->query('INSERT INTO `inventory` SET ?A[?i,?i,"?s",?i,?i,?i,"?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]', $newItem);
db::c()->query('INSERT INTO `inventory` SET ?A[?i,?i,"?s",?i,?i,?i,"?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]', $newItem);
$inventoryItemId = db::c()->getLastInsertId();
if ($dress['count'] != -1) db::c()->query('UPDATE `shop` SET `count` = `count` - 1 WHERE `id` = ?i', $_GET['buy']);
$status = "Вы купили «{$dress['name']}» за {$dress['cost']} кр.";
@ -222,25 +240,18 @@ if (!empty($_GET['buy'])) {
<TABLE width=100% cellspacing="0" cellpadding="4">
<TR>
<TD valign=top align=left>
<!--Магазин-->
<TABLE border=0 width=100% cellspacing="0" cellpadding="0" bgcolor="#A5A5A5">
<TR>
<TD align=center>
<h3><?= $shopCategoryType ?></h3>
<?php if ($saleItems): ?>
Вы можете продать ваши предметы за сущие копейки.
<div style="text-align: center;">Вы можете продать ваши предметы за сущие копейки.</div>
<?php endif; ?>
</TD>
</TR>
<TR>
<TD>
<TABLE class="zebra" WIDTH=100% CELLSPACING="1" CELLPADDING="2" BGCOLOR="#A5A5A5">
<!--Магазин-->
<TABLE class="zebra" WIDTH=100% CELLSPACING="1" CELLPADDING="2">
<?php
if ($saleItems == true) {
foreach ($iteminfo as $ii) {
echo "<tr><td style='width: 150px; text-align: center;'>";
$ii->printImage();
$ii->printControls(true);
$ii->printControls('sell');
echo "</td>";
echo "<td style='vertical-align: top;'>";
$ii->printInfo();
@ -260,37 +271,35 @@ if (!empty($_GET['buy'])) {
?>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
<TD valign=top width=280>
<B>Масса всех ваших вещей: <?= getItemsMassaInfo() ?>
<BR>У вас в наличии: <span style="color: darkgreen;"><?= $user['money'] ?></span> кр.</B>
<hr>
<div style="text-align: center; font-weight: bold;">Отделы магазина</div>
<a href="shop.php?otdel=sale&rnd=<?= mt_rand() ?>">Продать вещи</a>
<dl>
<dt><b>Оружие:</b></dt>
<dd><a href="shop.php?otdel=1&rnd=<?= mt_rand() ?>">кинжалы</a></dd>
<dd><a href="shop.php?otdel=11&rnd=<?= mt_rand() ?>">топоры</a></dd>
<dd><a href="shop.php?otdel=12&rnd=<?= mt_rand() ?>">дубины</a></dd>
<dd><a href="shop.php?otdel=13&rnd=<?= mt_rand() ?>">мечи</a></dd>
<dd><a href="?otdel=1&rnd=<?= mt_rand() ?>">кинжалы</a></dd>
<dd><a href="?otdel=11&rnd=<?= mt_rand() ?>">топоры</a></dd>
<dd><a href="?otdel=12&rnd=<?= mt_rand() ?>">дубины</a></dd>
<dd><a href="?otdel=13&rnd=<?= mt_rand() ?>">мечи</a></dd>
<dt><b>Одежда:</b></dt>
<dd><a href="shop.php?otdel=24&rnd=<?= mt_rand() ?>">шлемы</a></dd>
<dd><a href="shop.php?otdel=23&rnd=<?= mt_rand() ?>">тяжелая броня</a></dd>
<dd><a href="shop.php?otdel=22&rnd=<?= mt_rand() ?>">легкая броня</a></dd>
<dd><a href="shop.php?otdel=3&rnd=<?= mt_rand() ?>">щиты</a></dd>
<dd><a href="shop.php?otdel=21&rnd=<?= mt_rand() ?>">перчатки</a></dd>
<dd><a href="shop.php?otdel=2&rnd=<?= mt_rand() ?>">сапоги</a></dd>
<dd><a href="?otdel=24&rnd=<?= mt_rand() ?>">шлемы</a></dd>
<dd><a href="?otdel=23&rnd=<?= mt_rand() ?>">тяжелая броня</a></dd>
<dd><a href="?otdel=22&rnd=<?= mt_rand() ?>">легкая броня</a></dd>
<dd><a href="?otdel=3&rnd=<?= mt_rand() ?>">щиты</a></dd>
<dd><a href="?otdel=21&rnd=<?= mt_rand() ?>">перчатки</a></dd>
<dd><a href="?otdel=2&rnd=<?= mt_rand() ?>">сапоги</a></dd>
<dt><b>Ювелирные товары:</b></dt>
<dd><a href="shop.php?otdel=4&rnd=<?= mt_rand() ?>">серьги</a></dd>
<dd><a href="shop.php?otdel=41&rnd=<?= mt_rand() ?>">ожерелья</a></dd>
<dd><a href="shop.php?otdel=42&rnd=<?= mt_rand() ?>">кольца</a></dd>
<dd><a href="?otdel=4&rnd=<?= mt_rand() ?>">серьги</a></dd>
<dd><a href="?otdel=41&rnd=<?= mt_rand() ?>">ожерелья</a></dd>
<dd><a href="?otdel=42&rnd=<?= mt_rand() ?>">кольца</a></dd>
<dt><b>Магия:</b></dt>
<dd><a href="shop.php?otdel=51&rnd=<?= mt_rand() ?>">боевые</a></dd>
<dd><a href="shop.php?otdel=5&rnd=<?= mt_rand() ?>">разные</a></dd>
<dd><a href="?otdel=51&rnd=<?= mt_rand() ?>">боевые</a></dd>
<dd><a href="?otdel=5&rnd=<?= mt_rand() ?>">разные</a></dd>
<dt><b>Разное:</b></dt>
<dd><a href="shop.php?otdel=6&rnd=<?= mt_rand() ?>">амуниция</a></dd>
<dd><a href="shop.php?otdel=52&rnd=<?= mt_rand() ?>">руны</a></dd>
<dd><a href="?otdel=6&rnd=<?= mt_rand() ?>">амуниция</a></dd>
<dd><a href="?otdel=52&rnd=<?= mt_rand() ?>">руны</a></dd>
</dl>
<div id="hint3" class="ahint"></div>
</TD>

View File

@ -1,75 +0,0 @@
<?php
session_start();
if ($_SESSION['uid'] == null) header("Location: index.php");
include "config.php";
include "functions.php";
if ($user['room'] != 50) {
header("Location: main.php");
die();
}
if ($user['battle'] != 0) {
header('location: fbattle.php');
die();
}
if (isset($_GET['up'])) {
$ids = $_GET['up'];
$cur = db::c()->query('SELECT `id`,`name`,`nlevel` FROM `inventory` WHERE `owner` = ?i AND `id`= ?i AND `artefact`=1', $user['id'], $ids)->fetch_assoc();
if ($cur['id']) {
$up_level = $cur['nlevel'] + 1;
$cur_up = db::c()->query('SELECT * FROM `ashop_up` WHERE `name` = "?s" AND `level_up` = ?i', $cur['name'], $up_level)->fetch_assoc();
if ($cur_up['id']) {
//mysql_query("UPDATE `inventory` SET `upgrade`='" . $cur_up['level_up'] . "',`nlevel`='" . $cur_up['level_up'] . "',`minu`='" . $cur_up['minu'] . "',`maxu`='" . $cur_up['maxu'] . "',`gsila`='" . $cur_up['gsila'] . "',`glovk`='" . $cur_up['glovk'] . "',`ginta`='" . $cur_up['ginta'] . "',`gintel`='" . $cur_up['gintel'] . "',`ghp`='" . $cur_up['ghp'] . "',`mfkrit`='" . $cur_up['mfkrit'] . "',`mfakrit`='" . $cur_up['mfakrit'] . "',`mfuvorot`='" . $cur_up['mfuvorot'] . "',`mfauvorot`='" . $cur_up['mfauvorot'] . "',`gnoj`='" . $cur_up['gnoj'] . "',`gtopor`='" . $cur_up['gtopor'] . "',`gdubina`='" . $cur_up['gdubina'] . "',`gmech`='" . $cur_up['gmech'] . "',`bron1`='" . $cur_up['bron1'] . "',`bron2`='" . $cur_up['bron2'] . "',`bron3`='" . $cur_up['bron3'] . "',`bron4`='" . $cur_up['bron4'] . "' WHERE `owner`='" . $user['id'] . "' AND `id`='" . $cur['id'] . "'");
err('Услуга недоступна!');
//echo "<font color=green><b>Артефакт успешно улучшен!</b></font>";
} else {
err('Артефакт достиг максимального уровня!');
}
}
}
$itemWeight = db::c()->query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $user['id'])->fetch_assoc();
$bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id`=?i', $_SESSION['uid'])->fetch_assoc();
$artefactsList = db::c()->query('SELECT * FROM `inventory` WHERE `owner`=?i AND `artefact`=1', $user['id']);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="css/main.css" rel="stylesheet"/>
</head>
<body>
<h1>Магазин Берёзка</h1>
<div style="text-align: center">Зал улучшения артефактов.</div>
<table border=0 width=100% cellspacing="0" cellpadding="4">
<tr>
<td valign=top align=left>
<table border=0 width=100% cellspacing="1" cellpadding="2" bgcolor="#A5A5A5">
<?php
while ($row = $artefactsList->fetch_assoc()) {
if ($i == 0) {
$i = 1;
$color = '#C7C7C7';
} else {
$i = 0;
$color = '#D5D5D5';
}
showitem($row, 10);
}
?>
</table>
</td>
<td valign=top width=280>
<b>Масса всех ваших вещей: <?= getItemsMassaInfo() ?>
<br>У вас в наличии: <span style="color: #339900;"><?= $bank['ekr'] ?></span> екр.</b>
<hr>
<a href=ashop.php>Магазин Берёзка</a>
<hr>
</td>
</tr>
</table>
</body>
</html>