276 lines
15 KiB
PHP
276 lines
15 KiB
PHP
|
<?php
|
|||
|
session_start();
|
|||
|
if ($_SESSION['uid'] == null) header("Location: index.php");
|
|||
|
include "config.php";
|
|||
|
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;"));
|
|||
|
$klans = mysql_fetch_array(mysql_query("SELECT * FROM `clans` WHERE `id` = '{$usrer['klan']}' LIMIT 1;"));
|
|||
|
include "functions.php";
|
|||
|
if ($user['room'] != 35){ header("Location: main.php"); die(); }
|
|||
|
$d = mysql_fetch_array(mysql_query("SELECT sum(`massa`) FROM `inventory` WHERE `owner` = '{$_SESSION['uid']}' AND `dressed` = 0; "));
|
|||
|
if ($user['battle'] != 0) { header('location: fbattle.php'); die(); }
|
|||
|
//$_GET['otdel'] = 1;
|
|||
|
|
|||
|
|
|||
|
if (($_GET['set'] OR $_POST['set'])) {
|
|||
|
if ($_GET['set']) { $set = $_GET['set']; }
|
|||
|
if ($_POST['set']) { $set = $_POST['set']; }
|
|||
|
if ($_POST['count'] < 1) { $_POST['count'] =1; }
|
|||
|
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `eshop` WHERE `id` = '{$set}' LIMIT 1;"));
|
|||
|
if (($dress['massa']*$_POST['count']+$d[0]) > (get_meshok())) {
|
|||
|
echo "<font color=red><b>Недостаточно места в рюкзаке.</b></font>";
|
|||
|
}
|
|||
|
elseif(($user['money']>= ($dress['cost']*$_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`
|
|||
|
)
|
|||
|
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']}'
|
|||
|
) ;"))
|
|||
|
{
|
|||
|
$good = 1;
|
|||
|
}
|
|||
|
else {
|
|||
|
$good = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
if ($good) {
|
|||
|
mysql_query("UPDATE `eshop` 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['cost'];
|
|||
|
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 `users` set `money` = `money`- '".($allcost)."' WHERE id = {$user['id']}");
|
|||
|
$user['money'] -=$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 = event.x+document.body.scrollLeft-20;
|
|||
|
document.all("hint3").style.top = event.y+document.body.scrollTop+5;
|
|||
|
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?zamk=1';" value="Вернуться" title="Вернуться"></td></tr>
|
|||
|
</FORM>
|
|||
|
</table>
|
|||
|
<?
|
|||
|
|
|||
|
?>
|
|||
|
<TABLE border=0 width=100% cellspacing="0" cellpadding="4">
|
|||
|
<TR>
|
|||
|
<FORM METHOD=POST ACTION="krshop.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><?php
|
|||
|
if ($_REQUEST['compare'] && !$_REQUEST['common'] && !$_REQUEST['present']) {
|
|||
|
echo "Составление подарочного букета";
|
|||
|
}
|
|||
|
elseif ($_REQUEST['present']) {
|
|||
|
//echo "Составление подарочного букета";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
switch ($_GET['otdel']) {
|
|||
|
case null:
|
|||
|
case 7:
|
|||
|
echo "Сувениры: открытки";
|
|||
|
break;
|
|||
|
case 71:
|
|||
|
echo "Сувениры: подарки";
|
|||
|
break;
|
|||
|
case 74:
|
|||
|
echo "Уникальные подарки";
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
?></B></TD>
|
|||
|
</TR>
|
|||
|
<TR><TD><!--Рюкзак-->
|
|||
|
<TABLE BORDER=0 WIDTH=100% CELLSPACING="1" CELLPADDING="2" BGCOLOR="#A5A5A5">
|
|||
|
<?
|
|||
|
if($_REQUEST['present']) {
|
|||
|
$_POST['to_login'] = htmlspecialchars($_POST['to_login'], NULL, 'cp1251');
|
|||
|
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 = ' клан '.$klans['name']; }
|
|||
|
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> <? nick2($user['id']);?><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 '%Статуэтка%' 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>
|
|||
|
<?php
|
|||
|
echo "<TD valign=top>";
|
|||
|
showitem ($row);
|
|||
|
echo "</TD></TR>";
|
|||
|
}
|
|||
|
}
|
|||
|
?>
|
|||
|
</table>
|
|||
|
</form>
|
|||
|
<?
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
$data = mysql_query("SELECT * FROM `eshop` WHERE `count` > 0 AND `razdel` = '{$_GET['otdel']}' and `ecost` = 0 ORDER by `cost` 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="krshop.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>
|
|||
|
<?php
|
|||
|
echo "<TD valign=top>";
|
|||
|
showitem ($row);
|
|||
|
echo "</TD></TR>";
|
|||
|
}
|
|||
|
}
|
|||
|
?>
|
|||
|
</TABLE>
|
|||
|
</TD></TR>
|
|||
|
</TABLE>
|
|||
|
|
|||
|
</TD>
|
|||
|
<TD valign=top width=280>
|
|||
|
|
|||
|
<CENTER><B>Масса всех ваших вещей: <?php
|
|||
|
|
|||
|
|
|||
|
echo $d[0];
|
|||
|
?>/<?=get_meshok()?><BR>
|
|||
|
У вас в наличии: <FONT COLOR="#339900"><?=$user['money']?></FONT> кр.</B>
|
|||
|
</CENTER>
|
|||
|
<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>
|
|||
|
<A HREF="krshop.php?otdel=7&sid=&0.925798340638547">Сувениры: открытки</A><BR>
|
|||
|
<A HREF="krshop.php?otdel=71&sid=&0.925798340638547">Подарки</A><BR>
|
|||
|
<A HREF="krshop.php?otdel=74&sid=&0.925798340638547">Уникальные подарки</A><BR>
|
|||
|
<A HREF="krshop.php?present=1">Сделать подарки</A><BR>
|
|||
|
<div id="hint3" class="ahint"></div>
|
|||
|
</TD>
|
|||
|
</FORM>
|
|||
|
</TR>
|
|||
|
</TABLE>
|
|||
|
</BODY>
|
|||
|
</HTML>
|