Просмотр файла dsgame_1303/inv.php

Размер файла: 27.46Kb
<?session_start();?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">

<head><meta http-equiv='content-type' content='application/xhtml+xml; charset=windows-1251'/>
<link rel="shortcut icon" href="ico1.ico" type="image/x-icon" />
<title>Инвентарь</title>
<link rel="stylesheet" href="styleN.css" type="text/css" />
</head>
<body>
<div class="inf">
<?
$d=date("H:i");
$p = $_GET['p'];
$key = $_GET['key'];
$no = $_GET['no'];
$to = $_GET['to'];
$NICK = $_GET['NICK'];
$pass = $_GET['pass'];
$menu = $_GET['menu'];
$use = $_GET['use'];
$c = $_GET['c'];
$u = $_GET['u'];
$sc = $_GET['sc'];
$d = $_GET['d'];
$p = @intval($_GET['p']);
$idT = $_GET['idT'];
$desc = $_GET['desc'];
$del = $_GET['del'];
$slot = $_GET['slot'];
$drp = $_GET['drp'];
$s=$_GET['s'];
//айпи игроков
$ip = $_SERVER['REMOTE_ADDR'];
$t = time();

include("db.php");

$db->openDB();
$vremya = time();
$nnick=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$nnick2=mysql_fetch_assoc($nnick);
if($vremya-$nnick2[gametime]>600){
echo"</div>";
include ("accaunt.php");
$AC->ACCAUNT();//Проверка Аккаунта
}
@include('effects.php');
$inv = mysql_query("SET NAMES cp1251");
$inv=mysql_query("SELECT * FROM inv WHERE ID_USERS=\"$_SESSION[s]\" AND IL_NO='0' AND ID_IL=\"$idT\"");
while($inv2=mysql_fetch_assoc($inv)){
if($inv2[IL_MIN_PROCH]<1 AND $menu == '1' AND $use!= 'i.arrow' AND !isset($drp) AND !isset($slot) ){
echo"<div class=\"top\" style=\"text-align:center\"><a href=\"inv.php\">
<b>
<font color=\"#FFE7BA\">в инвентарь</font></a>
</div>
<div class=\"main\">"."<div class=\"menu\" style=\"border:1px dotted\"><li><a href=\"inv.php\"><img src=\"img/inv.png\" width=\"24\" height=\"24\"> в инвентарь</a></li></div><center><font color=\"#A23232\">невозможно одеть сломанную вещь!</font></center>"."";
include("footer.php");
die;}}
$items = mysql_query("SET NAMES cp1251");
$items=mysql_query("SELECT * FROM inv WHERE ID_USERS='$_SESSION[s]' AND IL_VREME=\"0\"");
$items2 = mysql_query("SET NAMES cp1251");
$items2=mysql_query("SELECT * FROM inv WHERE ID_USERS='$_SESSION[s]' AND IL_NO=\"0\" AND NEVE!='1'");
$items_ves = mysql_query("SET NAMES cp1251");
$items_ves=mysql_query("SELECT * FROM users WHERE NICK='$_SESSION[s]'");
$items_count_ss = mysql_query("SET NAMES cp1251");
$items_count_ss=mysql_query("SELECT * FROM inv WHERE ID_USERS='$_SESSION[s]' AND IL_NO=\"0\"");
$items_count_sss=mysql_num_rows($items_count_ss);
$c_items=mysql_num_rows($items2);
$items_ves2 = mysql_fetch_assoc($items_ves);





// Переменная хранит число сообщений выводимых на станице  
$num = 10;  
// Извлекаем из URL текущую страницу  
$page = $_GET['page'];  
// Определяем общее число сообщений в базе данных  
$result = mysql_query("SELECT COUNT(*) FROM inv WHERE ID_USERS=\"$_SESSION[s]\" AND IL_NO=\"0\"");  
$posts = mysql_result($result, 0);  
// Находим общее число страниц  
$total = intval(($posts - 1) / $num) + 1;  
// Определяем начало сообщений для текущей страницы  
$page = intval($page);  
// Если значение $page меньше единицы или отрицательно  
// переходим на первую страницу  
// А если слишком большое, то переходим на последнюю  
if(empty($page) or $page < 0) $page = 1;  
  if($page > $total) $page = $total;  
// Вычисляем начиная к какого номера  
// следует выводить сообщения  
$start = $page * $num - $num;  
// Выбираем $num сообщений начиная с номера $start  
$result = mysql_query("SET NAMES cp1251");
$result = mysql_query("SELECT * FROM inv WHERE ID_USERS=\"$_SESSION[s]\" AND IL_NO=\"0\" LIMIT $start, $num");  

// В цикле переносим результаты запроса в массив $postrow  
while ( $postrow[] = mysql_fetch_array($result))  
?>






<style type="text/css">
body,td,th {
	color: #000000;
}
</style>
</head>
<body>


<table width="450" height="182" align="center">
  <tr>
  <td width="348" height="34" align="center" bgcolor="#a23232"><b><font color="#FFE7BA">Инвентарь</font></b>
  
  </td>
  
  </tr>
  
  <tr>
  
  <td width="348" height="20" align="left" valign="top" bgcolor="#FFE7BA">
  <div class="menu">
  <li><a href="game.php"><b><font color="#a23232"><img src="img/attck.png" /> В игру</font></b></a></li></div>
  </td>
  </tr>
   <tr>
  <td width="348" height="20" bgcolor="#FFE7BA" align="left">
  <div class="menu"><li><a href="pers.php"><b><font color="#a23232"><img src="img/grup.png" /> Персонаж</font></b></a></li></div>
  </td>
  </tr>
  <tr>
  <td width="348" height="20" bgcolor="#FFE7BA" align="left">
  <div class="menu"><li><a href="equip.php"><b><font color="#a23232"><img src="img/helm.png" /> Снаряжение</font></b></a></li></div>
  </td>
  </tr>
   <tr>
  <td width="348" height="20" bgcolor="#a23232" align="Center"><b><font color="#FFE7BA">Предметы <?echo" <font color=\"#FFE7BA\"> ($c_items/$items_ves2[MAX_VES])";?>
  </font></b>
  </td>
  </tr>
  <tr>
 
  <td width="348" height="10" align="center" valign="middle" bgcolor="#FFE7BA">
  <font color="#a23232"><B>
  <a href="pr">Все</a>|
  <a href="pr">оружие</a>|
  <a href="pr">Бижутерия</a>|
  <a href="pr">Броня</a>|
  <a href="pr">Зелья</a>|
  <a href="pr">Расходное</a>
  </font></B></td></tr>
  <tr>
  <td width="348" height="31" align="left" valign="middle" bgcolor="#FFE7BA">
<?
$trsm = time();
$inv_msg = mysql_query("SELECT * FROM inv_msg WHERE NICK=\"$_SESSION[s]\"");
$inv_msg2 = mysql_fetch_assoc($inv_msg);
if($inv_msg2[TIME]-$trsm>0){echo "

<div style=\"border 2px dotted;background:#a23232\">
<center>
<b>
<font color=\"#FFE7BA\"> 
$inv_msg2[TEXT]
</font>
</b>
</center></div>

</div>


";
$delinvm = mysql_query("DELETE FROM inv_msg WHERE NICK=\"$_SESSION[s]\"");
}
if(isset($drp)){
$del_it=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\"");
if(mysql_num_rows($del_it)>0){echo "

<div style=\"border 2px dotted;background:#a23232\">
<center>
<b>
<font color=\"#FFE7BA\"> 
вы действительно хотите уничтожить этот предмет?
</font>
</b>
</center></div>
<div class=\"menu\">
<li><a href=\"inv.php?drp=$aItems[IL_KEY]&idT=$idT&del=1\"><img src=\"img/success.png\" width=\"18\" height=\"18\"> ДА</a></li>
<li><a href=\"inv.php\"><img src=\"img/bad.png\" width=\"18\" height=\"18\"> НЕТ</a></li>
</div>
</div>


";
if($del==1){
while($del_it2=mysql_fetch_assoc($del_it)){
echo'<br/><font color="red">предмет '.$del_it2[IL_NAME].' уничтожен</font>';
$delITm=mysql_query("DELETE FROM inv WHERE ID_IL=\"$idT\" AND ID_USERS=\"$_SESSION[s]\"");}
//если предмета больше 1 ,то просим ввести количество
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
}}
}




  

$ItemsName=$aItems['IL_NAME'];
$ItemsNo=$aItems['IL_NO'];
$src=$aItems['SRC'];
//если кол-во предметов равно 0 ,то удаляем вещь из инвентаря
$delete_items=mysql_query("DELETE FROM inv WHERE IL_COUNT='0'");
//$items23=mysql_query("SELECT * FROM inv WHERE ID_USERS='$_SESSION[s]'");
//$count_items=mysql_num_rows($items23[IL_COUNT]);echo $count_items;echo $NICK;

?>

<?
for($i = 0; $i < $num; $i++)  
{  
 
         
echo"";
$resc = mysql_num_rows($result);
if($i<$resc){
$io = $postrow[$i]['ID_IL'];
$src = $postrow[$i]['IL_IMAGE'];
echo "<div style=\"border:1px dotted\"><div class=\"menu\"><li><a href=\"inv.php?p=0&idT=$io&page=$page\"><img src=\"$src\" width=\"42\" height=\"42\" alt=\"+\"> 
<b><font color=\"#a23232\">".$postrow[$i]['IL_NAME'].' ('.$postrow[$i]['IL_COUNT']." шт.)</a> </div></font></b>";
if($ItemsNo==0){




$odev = mysql_query("SELECT * FROM inv WHERE ID_USERS=\"$_SESSION[s]\" AND ID_IL=\"$idT\" LIMIT 1"); 
while($odev2 = mysql_fetch_assoc($odev)){
if($p == 0 AND $idT == $io){
if($odev2[IL_ALL_CLASS] == 'armor' OR $odev2[IL_ALL_CLASS] == 'weapon' OR $odev2[IL_SUBCLASS] == 'streli' AND $i<$resc){echo"

<div style=\"padding:5px\"><b>

<a href=\"inv.php?menu=1&use=$odev2[IL_KEY]&c=$odev2[IL_CLASS]&u=$odev2[IL_ALL_CLASS]&sc=$odev2[IL_SUBCLASS]&p=$p&idT=$odev2[ID_IL]&page=$page\">ОДЕТЬ</a> 
| <a href=\"game.php?li=$odev2[IL_KEY]&idT=$odev2[ID_IL]&page=$page\">ИНФО</a> |
<a href=\"inv.php?drp&idT=$odev2[ID_IL]&page=$page\">ВЫБРОСИТЬ</a></b></div>";}
if($odev2[IL_ALL_CLASS] != 'armor' OR $odev2[IL_ALL_CLASS] != 'weapon' OR $odev2[IL_SUBCLASS] != 'streli' AND $i<$resc){echo"

<div style=\"padding:5px\"><b>

 <a href=\"game.php?li=$odev2[IL_KEY]&idT=$odev2[ID_IL]&page=$page\">ИНФО</a> |
<a href=\"inv.php?drp&idT=$odev2[ID_IL]&page=$page\">ВЫБРОСИТЬ</a></b></div>";}
}
}

echo"</div>";
}

}
if(mysql_num_rows($result)<1 AND $i<1){echo"<div style=\"background:#a23232;height:30px;padding-bottom:0px\">
<center><b><font color=\"#FFE7BA\"><div style=\"padding:6px\">У вас нет не одного предмета</div></font></b></center></div>";}

}

?>

  </b></font>

  </td>
  
  </tr>
<tr>
 
  <td width="348" height="10" align="center" valign="middle" bgcolor="#FFE7BA">
  <b><font color="#a23232">
<? 
// Проверяем нужны ли стрелки назад  
if ($page != 1) $pervpage = '<a href= ./inv.php?page=1><<</a>  
                               <a href= ./inv.php?page='. ($page - 1) .'><</a> ';  
// Проверяем нужны ли стрелки вперед  
if ($page != $total) $nextpage = ' <a href= ./inv.php?page='. ($page + 1) .'>></a>  
                                   <a href= ./inv.php?page=' .$total. '>>></a>';  

// Находим две ближайшие станицы с обоих краев, если они есть  
if($page - 2 > 0) $page2left = ' <a href= ./inv.php?page='. ($page - 2) .'>'. ($page - 2) .'</a> | ';  
if($page - 1 > 0) $page1left = '<a href= ./inv.php?page='. ($page - 1) .'>'. ($page - 1) .'</a> | ';  
if($page + 2 <= $total) $page2right = ' | <a href= ./inv.php?page='. ($page + 2) .'>'. ($page + 2) .'</a>';  
if($page + 1 <= $total) $page1right = ' | <a href= ./inv.php?page='. ($page + 1) .'>'. ($page + 1) .'</a>'; 

// Вывод меню  
echo $pervpage.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$nextpage;  
?>
  </font></b></td></tr>
<tr><td width="348" height="31" align="left" valign="middle" bgcolor="#FFE7BA"
<?
       





include("footer.php");
@include("refresh.php");


?>

</td></tr>   
</table>
<?
if($u=='weapon' AND isset($u))
    {

#лучник
#жрец
#ассасин
#страж
#воин
#маг
#рыцарь тьмы
#некромант

	$weapon_lvl = mysql_query("SET NAMES cp1251");
	$weapon_lvl=mysql_query("SELECT * FROM users,inv WHERE ID_USERS='$_SESSION[s]' AND ID_IL='$idT'");
while(@$weapon_lvl2=mysql_fetch_assoc($weapon_lvl)){
 //include("skills/parametrs2.php"); 
    $weaponsC=mysql_query("SELECT * FROM inv WHERE IL_NO='1' AND ID_USERS='$_SESSION[s]'");


//если оружие такого типа уже одета то пишем что оружие данного типа уже одето :=)

$counts_equip = mysql_query("SET NAMES cp1251");
$counts_equip_weapons=mysql_query("SELECT * FROM inv WHERE ID_USERS='$_SESSION[s]' AND IL_NO=1");
$counts_equip=mysql_num_rows($counts_equip_weapons);
//баг при одевании вещей
$counts_equip_weapons2=mysql_fetch_assoc($counts_equip_weapons);
$usersD = mysql_query("SET NAMES cp1251");
$usersD=mysql_query("SELECT * FROM users WHERE NICK='$_SESSION[s]'");
$usersD2=mysql_fetch_assoc($usersD);
$DMGmin=$usersD2[DAMAGEmin]-$counts_equip_weapons2[IL_MIN_DMG];
$DMGmax=$usersD2[DAMAGEmax]-$counts_equip_weapons2[IL_MAX_DMG];
$weapon_DMG=mysql_query("SELECT * FROM inv WHERE ID_USERS='$_SESSION[s]' AND ID_IL='$idT'");
$weapon_DMG2=mysql_fetch_assoc($weapon_DMG);
$DMGmin2=round($weapon_DMG2[IL_MIN_DMG]+round($usersD2[SKILL_DEX]/5));
$DMGmax2=round($weapon_DMG2[IL_MAX_DMG]+round($usersD2[SKILL_DEX]/5));
$DMGmin3=round($weapon_DMG2[IL_MIN_DMG]+round($usersD2[SKILL_STR]/5));
$DMGmax4=round($weapon_DMG2[IL_MAX_DMG]+round($usersD2[SKILL_STR]/5));
$DMGmin5=round($weapon_DMG2[IL_MAGD_MIN]+round($usersD2[SKILL_INT]/5));
$DMGmax6=round($weapon_DMG2[IL_MAGD_MAX]+round($usersD2[SKILL_INT]/5));
if($usersD2[LVL_USERS]<$weapon_DMG2[IL_LVL]){
$uspr = mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$uspr2 = mysql_fetch_assoc($uspr);
$tism = time()+222;
$insms = mysql_query("INSERT INTO inv_msg (NICK,TEXT,TIME) VALUES ('$_SESSION[s]','Ваш уровень слишком мал чтобы носить это!','$tism')");

 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
die;}
if($weapon_DMG2[IL_STR]>$usersD2[SKILL_STR] OR $weapon_DMG2[IL_DEX]>$usersD2[SKILL_DEX] OR $weapon_DMG2[IL_INT]>$usersD2[SKILL_INT]){
if($weapon_DMG2[IL_STR]>$usersD2[SKILL_STR]){echo"<center><div class=\"main title\">не хватает силы!</div></center><br/>";}
if($weapon_DMG2[IL_DEX]>$usersD2[SKILL_DEX]){echo"<center><div class=\"main title\">не хватает ловкости!</div></center><br/>";}
if($weapon_DMG2[IL_INT]>$usersD2[SKILL_INT]){echo"<center><div class=\"main title\">не хватает интеллекта!</div></center>";}
die;}
//echo $DMGmin2.$DMGmax2;die;

//$usersD2=mysql_fetch_assoc($usersD)


$weapon_pr=mysql_query("SELECT * FROM inv WHERE IL_NO='1' AND IL_ALL_CLASS=\"weapon\" AND ID_USERS=\"$_SESSION[s]\"");
if($c!='legs' AND $c!='sapogi' AND $c!='naruchi' AND $c!='armor' AND $c!='plechi' AND $c!='helmet' AND $c!='shield' AND $c!='amulet' AND $c!='ring' AND $c!='braslet')
{

if(mysql_num_rows($weapon_pr)<1 ){

include("skills/bow.php");//точность для лука
include("skills/posox.php");//точность для посоха
include("skills/swords.php");//точность для меча

include("skills/use.php");} 

 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
}
 }
if($counts_equip>0 AND $counts_equip<2){
$db->openDB();
$pr_weapon = mysql_query("SET NAMES cp1251");
$pr_weapon=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\"");
while($pr_weapon2=mysql_fetch_assoc($pr_weapon))
{
$pr_weapon3 = mysql_query("SET NAMES cp1251");
$pr_weapon3=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
while($pr_weapon4=mysql_fetch_assoc($pr_weapon3))
{
if($pr_weapon2[IL_LVL]>$pr_weapon4[LVL_USERS]){echo"уровень слишком низок чтобы носить это!";die;}
}
}
//$weapon_query_o=mysql_query("UPDATE inv SET IL_NO='0' WHERE IL_NO=1");
//$weapon_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE IL_KEY='$use' AND ID_IL=\"$idT\"");
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');

}
//создаем запрос на одевание оружия
//$db->openDB();
//$weapon_lvl=mysql_query("SELECT * FROM users,inv WHERE NICK='$_SESSION[s]' AND IL_KEY='$use'");
//while($weapon_lvl2=mysql_fetch_assoc($weapon_lvl)){
//if($weapon_lvl2[LVL_USERS]<$weapon_lvl2[IL_LVL]){echo"<div style='border:2px dotted;border-color:red;'>
//ваш уровень слишком низок чтобы носить это!";die;}
//else
//$dmgmin=$weapon_lvl[DAMAGEmin]+$weapon_lvl[MIN_DMG];
  //  $dmgmax=$weapon_lvl[DAMAGEmax]+$weapon_lvl[MAX_DMG];    
 
//include("skills/str2.php");

//}
    }
    //одевание вещей

if($c=='helmet')
    {
	
//создаем запрос на одевание шлема
$counts_equip_helmet=mysql_query("SELECT * FROM inv WHERE IL_CLASS='helmet' AND ID_USERS='$_SESSION[s]' AND IL_NO=1");
//переодеваем шлем снимаем старый,одеваем новый
if(mysql_num_rows($counts_equip_helmet)>0){
$counts_equip_helmet21=mysql_fetch_assoc($counts_equip_helmet);

$usDEF=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$usDEF2=mysql_fetch_assoc($usDEF);
$defIT=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_CLASS='helmet' AND ID_USERS='$_SESSION[s]'");
$defIT2=mysql_fetch_assoc($defIT);
if(mysql_num_rows($counts_equip_helmet)>0){$pluDEF=$usDEF2[DEFENCE]-$counts_equip_helmet21[IL_DEF]+$defIT2[IL_DEF];}
$allDEF=$usDEF2[DEFENCE]-$defIT2[IL_DEF];

$counts_equip_helmet99=mysql_query("UPDATE users SET DEFENCE=\"$allDEF\" WHERE NICK=\"$_SESSION[s]\"");
if(mysql_num_rows($counts_equip_helmet)>0){$counts_equip_helmet33=mysql_query("UPDATE users SET DEFENCE=\"$pluDEF\" WHERE NICK=\"$_SESSION[s]\"");}
if(mysql_num_rows($defIT)>0){$counts_equip_helmet2=mysql_query("UPDATE inv  SET IL_NO=\"0\" WHERE IL_CLASS='helmet' AND IL_NO=1 AND ID_USERS='$_SESSION[s]'");}
$counts_equip_helmet3=mysql_query("UPDATE inv  SET IL_NO=\"1\" WHERE ID_IL=\"$idT\" AND IL_CLASS='helmet' AND ID_USERS='$_SESSION[s]'");

}
$DEF=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_KEY='$use'");
while($DEF2=mysql_fetch_assoc($DEF)){
$DDEF=$DEF2[IL_DEF];
}
$users=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$users2=mysql_fetch_assoc($users);
$DEF_H=$users2[DEFENCE]+$DDEF;
$defITg=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_CLASS='helmet' AND IL_NO='1' AND ID_USERS='$_SESSION[s]'");
if(mysql_num_rows($defITg)<1){
$helmet_DEF=mysql_query("UPDATE users SET DEFENCE=\"$DEF_H\" WHERE NICK=\"$_SESSION[s]\"");
}
$helmet_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE ID_IL=\"$idT\" AND IL_KEY='$use'");
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
    }
if($c=='amulet')
    {
//создаем запрос на одевание амулета
$amulet_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE IL_KEY='$use'");
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
    }
  
  
	
if($c=='armor')
    {
//создаем запрос на одевание доспеха
$counts_equip_armor=mysql_query("SELECT * FROM inv WHERE IL_CLASS='armor' AND ID_USERS='$_SESSION[s]' AND IL_NO=1");
//переодеваем доспех снимаем старый,одеваем новый
if(mysql_num_rows($counts_equip_armor)>0){
$counts_equip_armor21=mysql_fetch_assoc($counts_equip_armor);

$usDEF=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$usDEF2=mysql_fetch_assoc($usDEF);

$defIT=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_CLASS='armor' AND ID_USERS='$_SESSION[s]'");
$defIT2=mysql_fetch_assoc($defIT);
if(mysql_num_rows($counts_equip_armor)>0){$pluDEF=$usDEF2[DEFENCE]-$counts_equip_armor21[IL_DEF]+$defIT2[IL_DEF];}
$allDEF=$usDEF2[DEFENCE]-$defIT2[IL_DEF];

$counts_equip_armor99=mysql_query("UPDATE users SET DEFENCE=\"$allDEF\" WHERE NICK=\"$_SESSION[s]\"");
if(mysql_num_rows($counts_equip_armor)>0){$counts_equip_armor33=mysql_query("UPDATE users SET DEFENCE=\"$pluDEF\" WHERE NICK=\"$_SESSION[s]\"");}
if(mysql_num_rows($defIT)>0){$counts_equip_helmet2=mysql_query("UPDATE inv  SET IL_NO=\"0\" WHERE IL_CLASS='armor' AND IL_NO=1 AND ID_USERS='$_SESSION[s]'");}
$counts_equip_armor3=mysql_query("UPDATE inv  SET IL_NO=\"1\" WHERE ID_IL=\"$idT\" AND IL_CLASS='armor' AND ID_USERS='$_SESSION[s]'");

}
$DEF=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_KEY='$use'");
while($DEF2=mysql_fetch_assoc($DEF)){
$DDEF=$DEF2[IL_DEF];
}
$users=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$users2=mysql_fetch_assoc($users);
$DEF_H=$users2[DEFENCE]+$DDEF;
$defITg=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_CLASS='armor' AND IL_NO='1' AND ID_USERS='$_SESSION[s]'");
if(mysql_num_rows($defITg)<1){$armor_DEF=mysql_query("UPDATE users SET DEFENCE=\"$DEF_H\" WHERE NICK=\"$_SESSION[s]\"");}
$armor_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE ID_IL=\"$idT\" AND IL_KEY='$use'");
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
    }  

	
if($c=='naruchi')
    {
//создаем запрос на одевание наручи
$counts_equip_naruchi=mysql_query("SELECT * FROM inv WHERE IL_CLASS='naruchi' AND ID_USERS='$_SESSION[s]' AND IL_NO=1");
//переодеваем шлем снимаем старый,одеваем новый
if(mysql_num_rows($counts_equip_naruchi)>0){
$counts_equip_naruchi21=mysql_fetch_assoc($counts_equip_naruchi);

$usDEF=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$usDEF2=mysql_fetch_assoc($usDEF);

$defIT=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_CLASS='naruchi' AND ID_USERS='$_SESSION[s]'");
$defIT2=mysql_fetch_assoc($defIT);
if(mysql_num_rows($counts_equip_naruchi)>0){$pluDEF=$usDEF2[DEFENCE]-$counts_equip_naruchi21[IL_DEF]+$defIT2[IL_DEF];}
$allDEF=$usDEF2[DEFENCE]-$defIT2[IL_DEF];

$counts_equip_naruchi99=mysql_query("UPDATE users SET DEFENCE=\"$allDEF\" WHERE NICK=\"$_SESSION[s]\"");
if(mysql_num_rows($counts_equip_naruchi)>0){$counts_equip_naruchit33=mysql_query("UPDATE users SET DEFENCE=\"$pluDEF\" WHERE NICK=\"$_SESSION[s]\"");}
if(mysql_num_rows($defIT)>0){$counts_equip_naruchi2=mysql_query("UPDATE inv  SET IL_NO=\"0\" WHERE IL_CLASS='naruchi' AND IL_NO=1 AND ID_USERS='$_SESSION[s]'");}
$counts_equip_naruchi3=mysql_query("UPDATE inv  SET IL_NO=\"1\" WHERE ID_IL=\"$idT\" AND IL_CLASS='naruchi' AND ID_USERS='$_SESSION[s]'");

}
$DEF=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_KEY='$use'");
while($DEF2=mysql_fetch_assoc($DEF)){
$DDEF=$DEF2[IL_DEF];
}

$users=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$users2=mysql_fetch_assoc($users);
$DEF_H2=$users2[DEFENCE]+$DDEF;
$defITg=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_CLASS='naruchi' AND IL_NO='1' AND ID_USERS='$_SESSION[s]'");
if(mysql_num_rows($defITg)<1){$naruchi_DEF=mysql_query("UPDATE users SET DEFENCE=\"$DEF_H2\" WHERE NICK=\"$_SESSION[s]\"");
$naruchi_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE ID_IL=\"$idT\" AND IL_KEY='$use'");}
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
    }    
if($c=='legs')
    {
//создаем запрос на одевание поножи
$counts_equip_legs=mysql_query("SELECT * FROM inv WHERE IL_CLASS='legs' AND ID_USERS='$_SESSION[s]' AND IL_NO=1");
//переодеваем шлем снимаем старый,одеваем новый
if(mysql_num_rows($counts_equip_legs)>0){
$counts_equip_legs21=mysql_fetch_assoc($counts_equip_legs);

$usDEF=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$usDEF2=mysql_fetch_assoc($usDEF);

$defIT=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_CLASS='legs' AND ID_USERS='$_SESSION[s]'");
$defIT2=mysql_fetch_assoc($defIT);
if(mysql_num_rows($counts_equip_legs)>0){$pluDEF=$usDEF2[DEFENCE]-$counts_equip_legs21[IL_DEF]+$defIT2[IL_DEF];}
$allDEF=$usDEF2[DEFENCE]-$defIT2[IL_DEF];

$counts_equip_legs99=mysql_query("UPDATE users SET DEFENCE=\"$allDEF\" WHERE NICK=\"$_SESSION[s]\"");
if(mysql_num_rows($counts_equip_legs)>0){$counts_equip_legs33=mysql_query("UPDATE users SET DEFENCE=\"$pluDEF\" WHERE NICK=\"$_SESSION[s]\"");}
if(mysql_num_rows($defIT)>0){$counts_equip_legs2=mysql_query("UPDATE inv  SET IL_NO=\"0\" WHERE IL_CLASS='legs' AND IL_NO=1 AND ID_USERS='$_SESSION[s]'");}
$counts_equip_legs3=mysql_query("UPDATE inv  SET IL_NO=\"1\" WHERE ID_IL=\"$idT\" AND IL_CLASS='legs' AND ID_USERS='$_SESSION[s]'");

}
$DEF=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_KEY='$use'");
while($DEF2=mysql_fetch_assoc($DEF)){
$DDEF=$DEF2[IL_DEF];
}
$users=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$users2=mysql_fetch_assoc($users);
$DEF_H=$users2[DEFENCE]+$DDEF;
$defITg=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_CLASS='legs' AND IL_NO='1' AND ID_USERS='$_SESSION[s]'");
if(mysql_num_rows($defITg)<1){$legs_DEF=mysql_query("UPDATE users SET DEFENCE=\"$DEF_H\" WHERE NICK=\"$_SESSION[s]\"");}
$legs_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE ID_IL=\"$idT\" AND IL_KEY='$use'");
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
    }    
if($c=='sapogi')
    {
//создаем запрос на одевание сапоги
$counts_equip_sapogi=mysql_query("SELECT * FROM inv WHERE IL_CLASS='sapogi' AND ID_USERS='$_SESSION[s]' AND IL_NO=1");
//переодеваем шлем снимаем старый,одеваем новый
if(mysql_num_rows($counts_equip_sapogi)>0){
$counts_equip_sapogi21=mysql_fetch_assoc($counts_equip_sapogi);

$usDEF=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$usDEF2=mysql_fetch_assoc($usDEF);

$defIT=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_CLASS='sapogi' AND ID_USERS='$_SESSION[s]'");
$defIT2=mysql_fetch_assoc($defIT);
if(mysql_num_rows($counts_equip_sapogi)>0){$pluDEF=$usDEF2[DEFENCE]-$counts_equip_sapogi21[IL_DEF]+$defIT2[IL_DEF];}
$allDEF=$usDEF2[DEFENCE]-$defIT2[IL_DEF];

$counts_equip_sapogi99=mysql_query("UPDATE users SET DEFENCE=\"$allDEF\" WHERE NICK=\"$_SESSION[s]\"");
if(mysql_num_rows($counts_equip_sapogi)>0){$counts_equip_sapogi33=mysql_query("UPDATE users SET DEFENCE=\"$pluDEF\" WHERE NICK=\"$_SESSION[s]\"");}
if(mysql_num_rows($defIT)>0){$counts_equip_sapogi2=mysql_query("UPDATE inv  SET IL_NO=\"0\" WHERE IL_CLASS='sapogi' AND IL_NO=1 AND ID_USERS='$_SESSION[s]'");}
$counts_equip_sapogi3=mysql_query("UPDATE inv  SET IL_NO=\"1\" WHERE ID_IL=\"$idT\" AND IL_CLASS='sapogi' AND ID_USERS='$_SESSION[s]'");
}
$DEF=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_KEY='$use'");
while($DEF2=mysql_fetch_assoc($DEF)){
$DDEF=$DEF2[IL_DEF];
}
$users=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$users2=mysql_fetch_assoc($users);
$DEF_H=$users2[DEFENCE]+$DDEF;
$defITg=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$idT\" AND IL_CLASS='sapogi' AND IL_NO='1' AND ID_USERS='$_SESSION[s]'");
if(mysql_num_rows($defITg)<1){
$sapogi_DEF=mysql_query("UPDATE users SET DEFENCE=\"$DEF_H\" WHERE NICK=\"$_SESSION[s]\"");
$sapogi_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE ID_IL=\"$idT\" AND IL_KEY='$use'");
}
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');

    }       
if($c=='ringl')
    {
//создаем запрос на одевание кольцо
$ring_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE IL_KEY='$use'");
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
    }
if($c=='ringr')
    {
//создаем запрос на одевание кольцо
$ring_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE IL_KEY='$use'");
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
    }	
if($c=='shield')
    {
	$uspr = mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
	$uspr2 = mysql_fetch_assoc($uspr);
	if($uspr2[class_pers] != 4){ 
	$tism = time()+2;
	$insms = mysql_query("INSERT INTO inv_msg (NICK,TEXT,TIME) VALUES ('$_SESSION[s]','данная вещь не подходит вам по классу!','$tism')");
print('<SCRIPT>location.href="inv.php";</SCRIPT>');die;
	}

//создаем запрос на одевание щита
$ring_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE IL_KEY='$use'");
print('<SCRIPT>location.href="inv.php";</SCRIPT>');


    }
if($c=='rasxodnoe')
    {
//создаем запрос на одевание кольцо
$ring_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE IL_KEY='$use'");
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
    }
if($c=='sumka')
    {
$usersD = mysql_query("SET NAMES cp1251");
$usersD=mysql_query("SELECT * FROM users WHERE NICK='$_SESSION[s]'");
$usersD2=mysql_fetch_assoc($usersD);	
$weapon_DMG=mysql_query("SELECT * FROM inv WHERE ID_USERS='$_SESSION[s]' AND ID_IL='$idT'");
$weapon_DMG2=mysql_fetch_assoc($weapon_DMG);
if($usersD2[LVL_USERS]<30){echo"<font color=\"red\">ваш уровень слишком мал чтобы носить это</font>";die;}
if($weapon_DMG2[IL_STR]>$usersD2[SKILL_STR] OR $weapon_DMG2[IL_DEX]>$usersD2[SKILL_DEX] OR $weapon_DMG2[IL_INT]>$usersD2[SKILL_INT]){
if($weapon_DMG2[IL_STR]>$usersD2[SKILL_STR]){echo"<center><font color=\"red\">не хватает силы!</font></center>";}
if($weapon_DMG2[IL_DEX]>$usersD2[SKILL_DEX]){echo"<font color=\"red\">не хватает ловкости!</font><br/>";}
if($weapon_DMG2[IL_INT]>$usersD2[SKILL_INT]){echo"<font color=\"red\">не хватает интеллекта!</font>";}
die;}
//создаем запрос на одевание кольцо
$sum1=mysql_query("SELECT * FROM inv WHERE IL_CLASS=\"sumka\" AND ID_USERS=\"$_SESSION[s]\"");
$sum2=mysql_fetch_assoc($sum1);
$VES=15+$sum2[BONUS_VES];
$maxVES=mysql_query("UPDATE users SET MAX_VES=\"$VES\" WHERE NICK=\"$_SESSION[s]\"");
$sumka=mysql_query("UPDATE inv SET IL_NO='1' WHERE IL_KEY='$use'");
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
    } 	
if($c=='braslet')
    {
//создаем запрос на одевание браслет
$braslet_query_o=mysql_query("UPDATE inv SET IL_NO='1' WHERE IL_KEY='$use'");
 print('<SCRIPT>location.href="inv.php";</SCRIPT>');
    }
	include_once("LVL_table.php");
@include("refresh.php");
$pr = mysql_query("SET NAMES cp1251");
$pr = mysql_query("SELECT * FROM inv WHERE ID_USERS=\"$_SESSION[s]\" AND IL_NO=\"1\"");
$prC=mysql_num_rows($pr);
if($prC==0){@include_once("LVL_table.php");}
?>

</body>
</html>