Файл: shopscroll.php
Строк: 83
<?
define('PROTECTOR', 1);
$headmod = 'shopelexirs';//фикс. места
$textl='Свитки заточки';
include('files/path.php');
include('files/gzips.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
going();
ryd();
place_okr();
place_zamok();
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
switch($_GET[mod]){
default:
$req = mysql_query("SELECT * FROM `shopscroll` WHERE `city` = '$udata[city]' and `tip`='scroll'");
////////////////////////////
$avto=mysql_num_rows($req);
While($mag = mysql_fetch_array($req))
{
echo"<div class='menu_li'><img src="pic/scroll/$mag[lat_name].png" width=40> <a href="shopscroll.php?mod=info&id=$mag[id]">$mag[name]</a><br><img src='/pic/money.png' width='16'>$mag[cena] <a href="shopscroll.php?mod=sell&id=$mag[id]">[купить]</a> </div>";
}
echo "<a href="kuznica.php">Вернуться</a><br>";
break;
case 'info':
$req = mysql_query("SELECT * FROM `shopscroll` WHERE `city` = '$udata[city]' and `id`='".mysql_real_escape_string($_GET['id'])."'");
$avto=mysql_num_rows($req);
if($avto==0){
echo'Ошибка!';
include($path.'files/down.php');
include($path.'files/meny.php');
exit;
}
$mag = mysql_fetch_array($req);
switch($mag[what]){
case 'hp':
$tip='жизнь';
break;
case 'mp':
$tip='ману';
break;
}
echo"<center>
<img src="pic/scroll/$mag[lat_name].png"><br/>
<b>$mag[name]</b></center>
<img src='/pic/zeal.png' width=20> $mag[give]<br/>
<img src='/pic/money.png' width=20> $mag[cena]<br/>
";
echo " <a href="shopscroll.php">Вернуться</a><br>";
break;
case 'sell':
$req = mysql_query("SELECT * FROM `shopscroll` WHERE `city` = '$udata[city]' and `id`='".mysql_real_escape_string($_GET['id'])."'");
$avto=mysql_num_rows($req);
if($avto==0){
echo'Ошибка, такой вещи нет!';
include($path.'files/down.php');
include($path.'files/meny.php');
exit;
}
$mag = mysql_fetch_array($req);
$nmoney=$udata[money]-$mag[cena];
if($nmoney<0){
echo'Не хватает серебра!';
include($path.'files/down.php');
include($path.'files/meny.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]'");
}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="shopscroll.php">Вернуться</a><br>";
break;
}
include($path.'files/down.php');
include($path.'files/meny.php');
?>