<?
define('PROTECTOR', 1);

$headmod = 'dress';//фикс. места

$textl='Инвентарь';
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
going();
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');

$req = mysql_query("SELECT * FROM `item` WHERE `usr` = '$log' and `tip`='$_GET[tip]' and `id`='$_GET[id]' and `image`='not'");

$avto=mysql_num_rows($req);
if($_GET[tip]=='kolco'){
$req1 = mysql_query("SELECT * FROM `item` WHERE `usr` = '$log' and `tip`='$_GET[tip]' and `image`='yes'");
$avto1=mysql_num_rows($req1);
if($avto1>=2){
echo'Сначала снимите то что на вас!';
include($path.'files/down.php');
exit;
}
}else{
$req1 = mysql_query("SELECT * FROM `item` WHERE `usr` = '$log' and `tip`='$_GET[tip]' and `image`='yes'");
$avto1=mysql_num_rows($req1);
if($avto1>=1){
echo'Сначала снимите то что на вас!';
include($path.'files/down.php');
exit;
}
}
if($avto==0){
echo'Ошибка, такой вещи нет!';
include($path.'files/down.php');
exit;
}
$mag = mysql_fetch_array($req);
if($mag[klas]!='not' and $mag[klas]!=$udata[klas]){
echo'Эта вещь не для вашего класса!';
include($path.'files/down.php');
exit;
}
if($mag[nsila] > $udata[sila] or $mag[num] > $udata[um] or $mag[nlovk] > $udata[lovk] or $mag[nlvl] > $udata[lvl]){
echo'Ващь неподходит по вашим скилам!';
include($path.'files/down.php');
exit;
}

$numin=$mag[umin]+$udata[umin];
$numax=$mag[umax]+$udata[umax];

$npgolova=$mag[pgolova]+$udata[pgolova];
$npbody=$mag[pbody]+$udata[pbody];
$npnogi=$mag[pnogi]+$udata[pnogi];


$nhp=$mag[hp]+$udata[hpall];
$nmp=$mag[mp]+$udata[mpall];
$nkrit=$mag[krit]+$udata[krit];
$nukrit=$mag[ukrit]+$udata[ukrit];

$nsila=$mag[sila]+$udata[sila];
$nlovk=$mag[lovk]+$udata[lovk];
$nprot=$mag[prot]+$udata[prot];
$num=$mag[um]+$udata[um];
$nanti=$mag[antikrit]+$udata[antikrit];

mysql_query("UPDATE `users` SET
         `umin` = '$numin',
         `umax` = '$numax',
         `pgolova` = '$npgolova',
         `pbody` = '$npbody',
         `pnogi` = '$npnogi',
         `hpall` = '$nhp',
         `mpall` = '$nmp',
         `krit` = '$nkrit',
         `ukrit` = '$nukrit',
         `antikrit` = '$nanti',
         `sila` = '$nsila',
         `lovk` = '$nlovk',
         `um` = '$num',
         `prot` = '$nprot'
          WHERE usr = '$log'");

mysql_query("UPDATE item SET image = 'yes' WHERE `usr` = '$log' and `tip`='$_GET[tip]' and `id`='$_GET[id]'");

echo"Вы одели $mag[name]!<br/>";
echo"<a href=\"inventar.php?\">Назад</a>";

include($path.'files/down.php');
?>