Файл: shopelexirs.php
Строк: 107
<?
define('PROTECTOR', 1);
$headmod = 'shopelexirs';//фикс. места
$textl='Торговая площадь';
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
going();
zasad();
ryd();
place_okr();
place_zamok();
place_tower();
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
if($mestouser[x]!='1000' or $mestouser[y]!='1003'){echo"Вы не находитесь на нужной локации..."; include('/files/down.php'); exit;}
echo '<div class="battle_result">Элексиры</div>
<div>
<div class="win"></div>
<div class="clear"></div>
</div>
';
switch($_GET[mod]){
default:
$req = mysql_query("SELECT * FROM `shopelexirs` WHERE `city` = '$udata[city]' and `tip`='elexir' order by `cena`");
////////////////////////////
$avto=mysql_num_rows($req);
While($mag = mysql_fetch_array($req))
{
echo"<div class='menu_li'><a href="shopelexirs.php?mod=info&id=$mag[id]">$mag[name]</a><br/> <img src='pic/money.png' width=16px height=16px>$mag[cena] <a href="shopelexirs.php?mod=sell&id=$mag[id]">[купить]</a></div>";
}
echo"<a href="torgs.php?">Назад</a>";
break;
case 'elexirs':
$req = mysql_query("SELECT * FROM `shopelexirs` WHERE `city` = '$udata[city]' and `tip`='elexir' order by `cena`");
////////////////////////////
$avto=mysql_num_rows($req);
While($mag = mysql_fetch_array($req))
{
echo"<a href="shopelexirs.php?mod=info&id=$mag[id]">$mag[name]</a> ($mag[cena] монет) [<a href="shopelexirs.php?mod=sell&id=$mag[id]">купить</a>]<br/>";
}
echo"<a href="torgs.php?">Назад</a>";
break;
case 'info':
$id=intval($_GET[id]);
$req = mysql_query("SELECT * FROM `shopelexirs` WHERE `city` = '$udata[city]' and `id`='$id'");
$avto=mysql_num_rows($req);
if($avto==0){
echo'Ошибка!';
include($path.'files/down.php');
exit;
}
$mag = mysql_fetch_array($req);
switch($mag[what]){
case 'hp':
$tip='жизнь';
break;
case 'mp':
$tip='ману';
break;
}
echo"$mag[name]<br/>";
//if($mag[what]=='mp' and $mag[give]<1000){echo'<img src="pic/elexir/mp3.gif">';}
//elseif($mag[what]=='mp' and $mag[give]<500){echo'<img src="pic/elexir/mp2.gif">';}
//elseif($mag[what]=='mp' and $mag[give]<100){echo'<img src="pic/elexir/mp1.gif">';}
//if($mag[what]=='hp' and $mag[give]<1000){echo'<img src="pic/elexir/hp3.gif">';}
//elseif($mag[what]=='hp' and $mag[give]<500){echo'<img src="pic/elexir/hp2.gif">';}
//elseif($mag[what]=='hp' and $mag[give]<100){echo'<img src="pic/elexir/hp1.gif">';}
echo"
Восстанавливает $tip
на $mag[give]<br/>
Цена: $mag[cena]<br/>
";
echo"<a href="shopelexirs.php?">Назад</a>";
break;
case 'sell':
$id=intval($_GET[id]);
$req = mysql_query("SELECT * FROM `shopelexirs` WHERE `city` = '$udata[city]' and `id`='$id'");
$avto=mysql_num_rows($req);
if($avto==0){
echo'Ошибка, такой вещи нет!';
include($path.'files/down.php');
exit;
}
$mag = mysql_fetch_array($req);
$req=mysql_query("SELECT * FROM domination WHERE id = '1'");
$dom = mysql_fetch_assoc($req);
if($dom['white']>$dom['black']){
$liders='white';
}elseif($dom['black']>$dom['white']){
$liders='black';
}else{
$liders='not';
}
if($udata['storona']==$liders){
$mag[cena]=round($mag[cena]-(($mag[cena]/100)*15));
}
$nmoney=$udata[money]-$mag[cena];
if($nmoney<0){
echo'Не хватает монет!';
include($path.'files/down.php');
exit;
}
$req1 = mysql_query("SELECT * FROM `res` WHERE `usr` = '$log' and `lat_name` = '$mag[lat_name]'");
$res = mysql_fetch_array($req1);
$avto1=mysql_num_rows($req1);
if($avto1==0){
mysql_query("INSERT INTO
`res` SET
`usr` = '$log',
`name` = '$mag[name]',
`lat_name` = '$mag[lat_name]',
`tip` = '$mag[tip]',
`what` = '$mag[what]',
`give` = '$mag[give]',
`kol` = '1',
`cena` = '$mag[cena]',
`image` = '$mag[image]'");
$req = mysql_query("SELECT * FROM `zamok` WHERE `city` = '$udata[city]' LIMIT 1");
////////////////////////////
$city = mysql_fetch_array($req);
if($city[clan]!='not' and $udata[clan]!=$city[clan]){
$req = mysql_query("SELECT * FROM `clan` WHERE `lider`='$city[clan]'");
////////////////////////////
$clan = mysql_fetch_array($req);
$clan[money]=$clan[money]+round(($mag[cena]/100)*2);
mysql_query("UPDATE `clan` SET `money` = '$clan[money]' WHERE `lider` = '$city[clan]'");
}
}else{
$nk=$res[kol]+1;
mysql_query("UPDATE `res` SET `kol` = '$nk' WHERE `usr` = '$log' and `lat_name` = '$mag[lat_name]'");
}
mysql_query("UPDATE users SET money = '$nmoney' WHERE usr = '$log'");
echo"
Вещь $mag[name] куплена и помещена в инвентарь!<br/>
Монет потрачено: $mag[cena]<br/>
Монет осталось: $nmoney<br/>
";
echo"<a href="shopelexirs.php?">Назад</a>";
break;
}
include($path.'files/down.php');
?>