381 lines
27 KiB
PHP
381 lines
27 KiB
PHP
<?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();
|
||
}
|
||
|
||
$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();
|
||
}
|
||
|
||
$bank = mysql_fetch_array(mysql_query("SELECT * FROM `bank` WHERE `id`='" . $_SESSION['uid'] . "';"));
|
||
|
||
if (($_GET['set'] OR $_POST['set'])) {
|
||
if ($_GET['set']) {
|
||
$set = $_GET['set'];
|
||
}
|
||
if ($_POST['set']) {
|
||
$set = $_POST['set'];
|
||
}
|
||
if (!$_POST['count']) {
|
||
$_POST['count'] = 1;
|
||
}
|
||
if (!is_numeric($_POST['count']) || $_POST['count'] != ((int)$_POST['count'])) {
|
||
$_POST['count'] = 0;
|
||
$count_ok = 0;
|
||
} elseif ($_POST['count'] < 1) {
|
||
$_POST['count'] = 0;
|
||
$count_ok = 0;
|
||
} else $count_ok = 1;
|
||
|
||
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `ashop` WHERE `id`='" . $set . "' LIMIT 1;"));
|
||
if ($count_ok == 0) {
|
||
echo "<font color=red><b>Неправильно введено количество</b></font>";
|
||
//$good = 0;
|
||
} elseif (($dress['massa'] * $_POST['count'] + $itemWeight['m']) > (get_meshok())) {
|
||
echo "<font color=red><b>Недостаточно места в рюкзаке.</b></font>";
|
||
//$good = 0;
|
||
} elseif ($count_ok == 1 && ($bank['ekr'] >= ($dress['ecost'] * $_POST['count'])) && ($dress['count'] >= $_POST['count'])) {
|
||
for ($k = 1; $k <= $_POST['count']; $k++) {
|
||
if (mysql_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
|
||
('{$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']}','" . (($dress['goden']) ? ($dress['goden'] * 24 * 60 * 60 + time()) : "") . "','{$dress['goden']}','{$dress['razdel']}','{$dress['artefact']}', '{$dress['koll']}');")) {
|
||
$good = 1;
|
||
} else {
|
||
$good = 0;
|
||
}
|
||
}
|
||
if ($good) {
|
||
mysql_query("UPDATE `ashop` SET `count`=`count`-" . $_POST['count'] . " WHERE `id`='" . $set . "' LIMIT 1;");
|
||
$limit = $_POST['count'];
|
||
$invdb = mysql_query("SELECT `id` FROM `inventory` WHERE `name` = '" . $dress['name'] . "' ORDER by `id` DESC LIMIT " . $limit . ";");
|
||
if ($limit == 1) {
|
||
$dressinv = mysql_fetch_array($invdb);
|
||
$dressid = "cap" . $dressinv['id'];
|
||
$dresscount = " ";
|
||
} else {
|
||
$dressid = "";
|
||
while ($dressinv = mysql_fetch_array($invdb)) {
|
||
$dressid .= "cap" . $dressinv['id'] . ",";
|
||
}
|
||
$dresscount = "(x" . $_POST['count'] . ") ";
|
||
}
|
||
$allcost = $_POST['count'] * $dress['ecost'];
|
||
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$_SESSION['uid']}','\"" . $user['login'] . "\" купил товар: \"" . $dress['name'] . "\" " . $dresscount . "id:(" . $dressid . ") [0/" . $dress['maxdur'] . "] за " . $allcost . " екр. ',1,'" . time() . "');");
|
||
echo "<font color=red><b>Вы купили {$_POST['count']} шт. \"{$dress['name']}\".</b></font>";
|
||
mysql_query("UPDATE `bank` set `ekr`=`ekr`-'" . ($allcost) . "' WHERE `id`='" . $_SESSION['uid'] . "';");
|
||
$bank['ekr'] -= $allcost;
|
||
}
|
||
} else {
|
||
echo "<font color=red><b>Недостаточно денег или нет вещей в наличии.</b></font>";
|
||
}
|
||
}
|
||
?>
|
||
<html>
|
||
<head>
|
||
<link rel=stylesheet type="text/css" href="css/main.css">
|
||
<meta content="text/html; charset=utf-8" http-equiv=Content-type>
|
||
<meta Http-Equiv=Cache-Control Content=no-cache>
|
||
<meta http-equiv=PRAGMA content=NO-CACHE>
|
||
<meta Http-Equiv=Expires Content=0>
|
||
<script language="JavaScript">
|
||
function AddCount(name, txt) {
|
||
document.all("hint3").innerHTML = '<form method=post style="margin:0px; padding:0px;"><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();"><big><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%> <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";
|
||
}
|
||
</script>
|
||
</head>
|
||
<body leftmargin=5 topmargin=5 marginwidth=5 marginheight=5 bgcolor=#d4d4d4>
|
||
<table border=0 width=100% cellspacing="0" cellpadding="0">
|
||
<form action="city.php" method=GET>
|
||
<tr>
|
||
<td><h3>Магазин Берёзка</td>
|
||
<td align=right>
|
||
<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="Вернуться"></td>
|
||
</tr>
|
||
</form>
|
||
</table>
|
||
|
||
<table border=0 width=100% cellspacing="0" cellpadding="4">
|
||
<tr>
|
||
<form method=POST action="ashop.php">
|
||
<input type="hidden" name="sid" value="">
|
||
<input type="hidden" name="id" value="1">
|
||
<td valign=top align=left>
|
||
<!--Магазин-->
|
||
<table border=0 width=100% cellspacing="0" cellpadding="0" <? if (!$_REQUEST['present']) {
|
||
echo 'bgcolor="#A5A5A5"';
|
||
} ?>>
|
||
<tr>
|
||
<td align=center><b>
|
||
<?
|
||
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">
|
||
<?
|
||
if ($_REQUEST['present']) {
|
||
if ($_POST['to_login'] && $_POST['flower']) {
|
||
$to = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `login`='" . $_POST['to_login'] . "' LIMIT 1;"));
|
||
if ($_POST['to_login'] == $user['login']) {
|
||
echo "<b><font color=red>Очень щедро дарить что-то самому себе ;)</font></b>";
|
||
} elseif ($to['room'] > 500 && $to['room'] < 561) {
|
||
echo "<b><font color=red>Персонаж в данный момент участвует в турнире в Башне Смерти. Попробуйте позже.</font></b>";
|
||
} else {
|
||
if ($_POST['from'] == 1) {
|
||
$from = 'Аноним';
|
||
} elseif ($_POST['from'] == 2 && $user['klan']) {
|
||
$from = ' клана ' . $user['klan'];
|
||
} else {
|
||
$from = $user['login'];
|
||
}
|
||
if ($to) if (mysql_query("UPDATE `inventory` SET `owner`='" . $to['id'] . "', `present`='" . $from . "', `letter`='" . $_POST['podarok2'] . "' WHERE `present`='' AND `id`='" . $_POST['flower'] . "' AND `owner`='" . $_SESSION['uid'] . "' AND `dressed`=0 AND `setsale`=0;")) {
|
||
$res = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '" . $_POST['flower'] . "' LIMIT 1;"));
|
||
$buket_name = $res['name'];
|
||
mysql_query("INSERT INTO `delo`(`id`,`author`,`pers`,`text`,`type`,`date`) VALUES ('','0','" . $_SESSION['uid'] . "','Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $from . "\" к \"" . $to['login'] . "\"','1','" . time() . "');");
|
||
mysql_query("INSERT INTO `delo`(`id`,`author`,`pers`,`text`,`type`,`date`) VALUES ('','0','{$to['id']}','Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $from . "\" к \"" . $to['login'] . "\"','1','" . time() . "');");
|
||
if (($_POST['from'] == 1) || ($_POST['from'] == 2)) {
|
||
$action = "подарил";
|
||
mysql_query("INSERT INTO `delo`(`id`,`author`,`pers`,`text`,`type`,`date`) VALUES ('','0','" . $to['id'] . "','Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\"','5','" . time() . "');");
|
||
} else {
|
||
if ($user['sex'] == 0) {
|
||
$action = "подарила";
|
||
} else {
|
||
$action = "подарил";
|
||
}
|
||
}
|
||
$us = mysql_fetch_array(mysql_query("select `id` from `online` WHERE `date`>=" . (time() - 60) . " AND `id` = '" . $to['id'] . "' LIMIT 1;"));
|
||
if ($us[0]) {
|
||
addchp('<font color=red>Внимание!</font> <span oncontextmenu=OpenMenu()>' . $from . '</span> ' . $action . ' вам <b>' . $buket_name . '</b>. ', '{[]}' . $_POST['to_login'] . '{[]}');
|
||
} else {
|
||
// если в офе
|
||
mysql_query("INSERT INTO `telegraph` (`owner`,`date`,`text`) values ('" . $to['id'] . "','','" . '<font color=red>Внимание!</font> <span oncontextmenu=OpenMenu()>' . $from . '</span> ' . $action . ' вам <b>' . $buket_name . '</b>. ' . "');");
|
||
}
|
||
echo "<b><font color=red>Подарок удачно доставлен к \"", $_POST['to_login'], "\"</font></b>";
|
||
}
|
||
echo mysql_error();
|
||
}
|
||
}
|
||
?>
|
||
<!-- Подарить подарок -->
|
||
<form method="post">
|
||
<table cellspacing=0 cellpadding=0 width=100% bgcolor=#e0e0e2>
|
||
<td>
|
||
<input type=hidden name=present value=1>
|
||
Вы можете сделать подарок дорогому человеку. Ваш подарок будет
|
||
отображаться в информации о персонаже.
|
||
<ol>
|
||
<li>Укажите логин персонажа, которому хотите сделать подарок<br>
|
||
Login <input type=text name=to_login value="">
|
||
<li>Цель подарка. Будет отображаться в информации о персонаже (не
|
||
более 60 символов)<br>
|
||
<input type=text name=podarok2 value="" maxlength=60 size=50>
|
||
<li>Напишите текст сопроводительной записки (в информации о
|
||
персонаже не отображается)<br>
|
||
<textarea name=txt rows=6 cols=80></textarea>
|
||
<li>Выберите, от чьего имени подарок:<br>
|
||
<input type=radio name=from value=0
|
||
checked> <?= nick::id($user['id'])->full() ?><br>
|
||
<input type=radio name=from value=1> анонимно<br>
|
||
<input type=radio name=from value=2> от имени клана<br>
|
||
<li>Нажмите кнопку <b>Подарить</b> под предметом, который хотите
|
||
преподнести в подарок:<br>
|
||
</ol>
|
||
<input type="hidden" name="flower" id="flower" value="">
|
||
<table border=0 width=100% cellspacing="1" cellpadding="2"
|
||
bgcolor="#A5A5A5">
|
||
<?
|
||
//print_r($_POST);
|
||
$data = mysql_query("SELECT * FROM `inventory` WHERE `owner`='" . $_SESSION['uid'] . "' AND `dressed`=0 AND (`name` LIKE '%Букет%' OR `name` LIKE '%Сувенир%' OR `name` LIKE '%Подарок%' OR `name` LIKE '%Валентинка%' OR `name` LIKE '%Открытка%' OR `name` LIKE 'Ель%' OR `name` LIKE '%Медаль%' OR `name` LIKE '%Статуэтка%') AND `setsale`=0 AND `present` = '' ORDER by `id` DESC;");
|
||
while ($row = mysql_fetch_array($data)) {
|
||
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="Подарить">
|
||
</td>
|
||
<?
|
||
echo "<td valign=top>";
|
||
showitem($row);
|
||
echo "</td></tr>";
|
||
}
|
||
}
|
||
?>
|
||
</table>
|
||
</form>
|
||
<?
|
||
} else {
|
||
$data = mysql_query("SELECT * FROM `ashop` WHERE `count`>0 AND `razdel`='" . $_GET['otdel'] . "' AND `ecost`>0 ORDER by `ecost` ASC;");
|
||
while ($row = mysql_fetch_array($data)) {
|
||
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>
|
||
<center><b>Масса всех ваших вещей:
|
||
<?=$itemWeight['m']?>/<?=get_meshok()?><br>
|
||
У вас в наличии: <font color="#339900"><?=$bank['ekr']?></font> екр.</b></center>
|
||
<!--<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:1">
|
||
<center><font color="#oooo"><b>Отделы магазина</b></center>
|
||
</div>
|
||
<b>Оружие:</b><br>
|
||
<!--<a href="ashop.php?otdel=1&sid=&0.162486541405194"> кастеты,ножи</a><br>-->
|
||
<a href="ashop.php?otdel=11&sid=&0.337606814894404"> топоры</a><br>
|
||
<a href="ashop.php?otdel=12&sid=&0.286790872806733"> дубины,булавы</a><br>
|
||
<a href="ashop.php?otdel=13&sid=&0.0943516060419363"> мечи</a><br>
|
||
<b>Одежда:</b><br>
|
||
<a href="ashop.php?otdel=24&sid=&0.567932791291376"> шлемы</a><br>
|
||
<a href="ashop.php?otdel=23&sid=&0.99133839275569"> тяжелая броня</a><br>
|
||
<a href="ashop.php?otdel=22&sid=&0.520447517792988"> легкая броня</a><br>
|
||
<a href="ashop.php?otdel=3&sid=&0.725667864710179"> щиты</a><br>
|
||
<!--<a href="ashop.php?otdel=21&sid=&0.648260824682342"> перчатки</a><br>-->
|
||
<a href="ashop.php?otdel=2&sid=&0.76205958316951"> сапоги</a><br>
|
||
<b>Ювелирные товары:</b><br>
|
||
<!--<a href="ashop.php?otdel=4&sid=&0.321709306035984"> серьги</a><br>
|
||
<a href="ashop.php?otdel=41&sid=&0.902093651333512"> ожерелья</a><br>-->
|
||
<a href="ashop.php?otdel=42&sid=&0.510210803380268"> кольца</a><br>
|
||
<b>Магия:</b><br>
|
||
<!--<a href="ashop.php?otdel=51&sid=&0.722009624500359"> боевые</a><br>-->
|
||
<a href="ashop.php?otdel=5&sid=&0.648834385828923"> разные</a><br>
|
||
<b>Разное:</b><br>
|
||
<!--<a href="ashop.php?otdel=6&sid=&0.925798340638547"> амуниция</a><br>-->
|
||
<a href="ashop.php?otdel=7&sid=&0.925798340638547"> букеты</a><br>
|
||
</div>
|
||
<div id="hint3" class="ahint"></div>
|
||
</td>
|
||
</form>
|
||
</tr>
|
||
</table>
|
||
|
||
</body>
|
||
</html>
|