<?
define('INSIDE', true);
include("inc/db_connect.php");
$stat = mysql_fetch_array(mysql_query("SELECT user, id, level, rank, tribe, t_time, k_time, battle, room, credits, vitality, img_path FROM players WHERE user='".$_COOKIE['user']."' AND pass='".$_COOKIE['pass']."'"));
if ($stat['bloked']) echo"<script>top.location='index.php?action=logout'</script>";
$now = time();
if ($stat['t_time']) { header("Location: prison.php"); exit; }
elseif ($stat['k_time']) { header("Location: academy.php"); exit; }
elseif ($stat['w_time']) { header("Location: works.php"); exit; }
elseif ($stat['battle']) { header("Location: battle.php"); exit; }
elseif ($stat['room'] != 13) { header("Location: main.php"); exit; }
else {
if (@$present_submit) {
if ($present_who != 1 && $present_who != 2 && $present_who != 3) $present_who = 1;
if (!$stat['tribe'] && $present_who == 2) $present_who = 1;
if (empty($present_user)) $msg="Укажите логин персонажа, которому Вы хотите сделать подарок!";
else {
$CharInfo = mysql_fetch_array(mysql_query("SELECT user FROM players WHERE user='".addslashes($present_user)."'"));
if (empty($CharInfo['user'])) $msg="Персонаж [u]$present_user[/u] не найден!";
elseif ($CharInfo['user'] == $stat['user']) $msg="Нельзя подарить что-либо самому себе!";
else {
if (mysql_num_rows(mysql_query("SELECT id FROM objects WHERE id=".addslashes($present_id)." AND user='".$stat['user']."'"))) {
$ObjInfo = mysql_fetch_array(mysql_query("SELECT inf FROM objects WHERE id=".addslashes($present_id)." AND user='".$stat['user']."'"));
$ObjInfo = explode("|",$ObjInfo['inf']);
if (mysql_num_rows(mysql_query("SELECT * FROM prizes WHERE id=".addslashes($present_id).""))) $msg="Этот предмет уже был подарен ранее!";
elseif ($ObjInfo['5']) $msg="Вы не можете дарить артефакты!";
else {
switch ($present_who) {
case 1: $present_who = "user"; break;
case 2: $present_who = "tribe"; break;
case 3: $present_who = "anonim"; break;
}
$present_text = HtmlSpecialChars($present_text);
mysql_query("INSERT INTO prizes values('".$CharInfo['user']."','".$stat['tribe']."','".addslashes($present_who)."','".addslashes($present_id)."','".$stat['user']."','".addslashes($present_text)."')");
mysql_query("UPDATE objects SET user='".$CharInfo['user']."' WHERE id='".addslashes($present_id)."'");
$msg="Подарок передан к [u]".$CharInfo['user']."[/u]!";
}
}
}
}
}
if (!empty($buy)) {
switch ($otdel) {
case 1: $cat = 100; break;
case 2: $cat = 101; break;
case 4: $cat = 102; break;
}
$buyitem=mysql_fetch_array(mysql_query("SELECT * FROM items WHERE name='".addslashes($buy)."'"));
$shop_sost=mysql_fetch_array(mysql_query("SELECT * FROM shop WHERE otdel='".addslashes($cat)."' and name='".addslashes($buy)."'"));
if (empty($shop_sost['name'])) $msg="Предмет не найден в магазине!";
elseif ($buyitem[price]>$stat[credits]) $msg="У Вас недостаточно денег для покупки предмета [u]".$buyitem['title']."[/u]";
else {
if ($shop_sost['kol'] > 0) {
$stat['credits']-=$buyitem['price'];
if ($buyitem['tip'] == 17 && $buyitem['slot2'] == "w5") $secondary=1; else $secondary=0;
###ЛОЖИМ В ИНВЕНТАРЬ
$inf="$buyitem[name]|$buyitem[title]|$buyitem[price]|0|$secondary|$buyitem[art]|0|$buyitem[iznos]";
$min="$buyitem[min_level]|$buyitem[min_str]|$buyitem[min_dex]|$buyitem[min_ag]|$buyitem[min_vit]|$buyitem[min_razum]|$buyitem[min_rase]|$buyitem[min_proff]|$buyitem[min_user]";
$lifetime=$now+$buyitem['life'];
mysql_query("INSERT INTO objects (`user`, `inf`, `min`,`tip`,`br1`,`br2`,`br3`,`br4`,`br5`,`min_d`,`max_d`,`hp`,`energy`,`strength`,`dex`,`agility`,`vitality`,`razum`,`krit`,`unkrit`,`uv`,`unuv`,`time`,`life`) values ('$stat[user]','$inf','$min','$buyitem[tip]','$buyitem[br1]','$buyitem[br2]','$buyitem[br3]','$buyitem[br4]','$buyitem[br5]','$buyitem[min]','$buyitem[max]','$buyitem[hp]','$buyitem[energy]','$buyitem[strength]','$buyitem[dex]','$buyitem[agility]','$buyitem[vitality]','$buyitem[razum]','$buyitem[krit]','$buyitem[unkrit]','$buyitem[uv]','$buyitem[unuv]','$now','$lifetime')");
mysql_query("update shop, players set shop.kol=shop.kol-1, players.credits=players.credits-$buyitem[price] where shop.name='".addslashes($buy)."' && players.user='".$stat['user']."'");
$msg="Вы купили предмет [u]".$buyitem['title']."[/u] за [u]".$buyitem['price']."[/u] кр.";
}}
}
function show ($id) {
global $stat;
switch ($id) {
case 1: $cat = 100; break;
case 2: $cat = 101; break;
case 4: $cat = 102; break;
}
$item=mysql_query("SELECT items.*, shop.kol FROM items, shop WHERE shop.otdel=".addslashes($cat)." AND shop.kol>0 AND items.name=shop.name ORDER BY items.price");
echo "<TABLE border=1 width=130% cellspacing=0 cellpadding=5 bordercolor=A5A5A5>";
while ($iteminfo = mysql_fetch_array($item)) {
include("inc/main/items.php");
echo"<tr><td width=33% align=center valign=center>
[url="''"][b]".$iteminfo['title']."[/b][/url]
[b]Гос. цена: ".$iteminfo['price']." кр.[/b]
";
if ($id == 2) echo"Долговечность предмета: 0 [".$iteminfo['iznos']."]
";
echo"[b]<small style='COLOR: Red'>Предмет не подлежит ремонту</small>[/b]
";
echo"
Срок жизни: <b STYLE='COLOR: Red'>",$iteminfo['life']/86400," дн.[/b]
";
echo"
Количество: [u]".$iteminfo['kol']."[/u] шт.
</td>
<td width=34% align=center>
<img src='$stat[img_path]/i/items/".$iteminfo['name'].".gif' alt='$iteminfo[title]'>
<span onclick=\"if (confirm('Купить предмет "$iteminfo[title]"?')) window.location='gshop.php?otdel=$_GET[otdel]&buy=$iteminfo[name]'\" style='CURSOR: Hand'>[b]Купить[/b]</a>
</td>
<td width=33% valign=top align=left>";
if ($min_level || $min_str || $min_dex || $min_ag || $min_vit || $min_razum || $min_proff) echo"
[b][i]Минимальные требования:[/i][/b]
$min_level$min_str$min_dex$min_ag$min_vit$min_razum$min_proff
"; else echo"";
if ($hp || $energy || $min || $max || $strength || $dex || $agility || $vitality || $razum || $br1 || $br2 || $br5 || $br3 || $br4 || $krit || $unkrit || $uv || $unuv) echo"[b][i]Действие предмета:[/i][/b]
$hp$energy$min$max$strength$dex$agility$vitality$razum$br1$br2$br5$br3$br4$krit$unkrit$uv$unuv
";
echo"</td></tr>";
}
echo"</TABLE>";
}
$title = 'Магазин';
include("inc/html_header.php");
echo"
<body bgcolor=#dedede leftmargin=0 topmargin=0>
<DIV ID=hint1></DIV>
<script src='i/show_inf.js'></SCRIPT>
";
print"<table width=100% cellspacing=0 cellpadding=5 border=0>
<tr>
<td>[b]У Вас на счету:[/b] [u]".$stat['credits']."[/u] [b]кр.[/b]
</td>
<td align=right valign=top>
<img src='$stat[img_path]/i/refresh.gif' style='CURSOR: Hand' alt='Обновить' onclick='window.location.href=\"gshop.php?otdel=$_GET[otdel]&tmp=\"+Math.random();\"\"'>
<img src='$stat[img_path]/i/back.gif' style='CURSOR: Hand' alt='Вернуться' onclick='window.location.href=\"street1.php?room=101&tmp=\"+Math.random();\"\"'>
</td>
</tr>
</table>";
echo"
<table width=100% cellspacing=0 cellpadding=3 border=0>
<tr>
<td align=center>
<font class=title>Сувенирная лавка</font>
";
if (!empty($msg)) echo"<center><FONT COLOR=RED>[b]$msg[/b]</font></center>
";
echo"
<FIELDSET style='WIDTH: 98.6%'><legend>Отделы магазина</legend>
<table width=100% cellspacing=0 cellpadding=7 border=0>
<tr>
<td align=center width=25%><A"; if ($otdel == 1) echo" disabled>[b]"; else echo" HREF='gshop.php?otdel=1'>"; echo"Открытки[/b]</A></td><td width=1% align=center>[b]|[/b]</td>
<td align=center width=25%><A"; if ($otdel == 2) echo" disabled>[b]"; else echo" HREF='gshop.php?otdel=2'>"; echo"Букеты[/b]</A></td><td width=1% align=center>[b]|[/b]</td>
<td align=center width=25%><A"; if ($otdel == 4) echo" disabled>[b]"; else echo" HREF='gshop.php?otdel=4'>"; echo"Подарки[/b]</A></td><td width=1% align=center>[b]|[/b]</td>
<td align=center width=25%><A"; if ($otdel == 3) echo" disabled>[b]"; else echo" HREF='gshop.php?otdel=3'>"; echo"Подарить[/b]</A></td>
</tr>";
if (!empty($_GET['otdel'])) {
echo"<TR><TD COLSPAN=5 ALIGN=CENTER>";
switch ($_GET['otdel']) {
case 1: show(1); break;
case 2: show(2); break;
case 4: show(4); break;
case 3: include('inc/shop/gshop.php'); break;
default: echo"<B STYLE='COLOR: Red'>Что-то тут не так...[/B]"; break;
}
echo"</TD></TR>";
}
echo"
</table>
</FIELDSET>";
echo"</td>
</tr>
</table>";
}
?>
<BODY bgcolor=EBEDEC leftmargin=0 topmargin=0 background='<? print"$stat[img_path]"; ?>/i/backgrounds/gshop.jpg' style='background-attachment: fixed;'>