<?php
define('PROTECTOR', 1);
//-----
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
$textl='Сумка';
going();
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
//-----
switch($_GET['mod']){
//-----
default:
echo'Ничего тут интересного нет';
break;
//-----
case 'nadet':
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr` = '$log' AND `tip` = '$_GET[tip]' AND `id` = '$_GET[id]' AND `image` = 'not'");
$mag = mysql_fetch_array($req);
$avto=mysql_num_rows($req);
$req1 = mysql_query("SELECT * FROM `weapon` 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;
}

if($mag['nlvl'] > $set['lvl']){
echo'Вещь можно надеть с <b>'.$mag['nlvl'].'</b> уровня!';
include($path.'files/down.php');exit;
}
$req1 = mysql_query("SELECT * FROM `weapon` WHERE `usr` = '$log' and `tip`='$_GET[tip]' and `image`='yes'");
$avto1=mysql_num_rows($req1);
if($avto1>=1){
mysql_query("UPDATE `weapon` SET `image` = 'not' WHERE `usr` = '$log' AND `tip` = '$_GET[tip]''");
}
$hp=$udata['hp'];
$mp=$udata['mp'];

$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'];
mysql_query("UPDATE `users` SET
`hp` = '$hp', `hpall` = '$nhp', `mp` = '$mp',
`mpall` = '$nmp', `krit` = '$nkrit',
`ukrit` = '$nukrit',
`sila` = '$nsila',
`lovk` = '$nlovk',
`prot` = '$nprot'
WHERE usr = '$log'");
mysql_query("UPDATE `weapon` SET `image` = 'yes' WHERE `usr` = '$log' AND `tip` = '$_GET[tip]' AND `id` = '$_GET[id]'");
header('Location: inventar.php?');exit;
break;
//-----
case 'snyat' :
if(empty($_GET['id'])){
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr` = '$log' AND `tip` = '$_GET[tip]' AND `image` = 'yes'");
}else{
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr` = '$log' AND `tip` = '$_GET[tip]' AND `image` = 'yes' AND `id` = '$_GET[id]'");
}
$avto=mysql_num_rows($req);
if($avto==0){
echo'Ошибка, на вас ничего не одето!';
include($path.'files/down.php');
exit;
}
$mag = mysql_fetch_array($req);
if($udata['hp']<$mag['hp']){
$hp=$udata['hp'];
}else{
$hp=$udata['hp']-$mag['hp'];
}
if($udata['mp']<$mag['mp']){
$mp=$udata['mp'];
}else{
$mp=$udata['mp']-$mag['mp'];
}
$nhp=$udata['hpall']-$mag['hp'];
$nmp=$udata['mpall']-$mag['mp'];
$nkrit=$udata['krit']-$mag['krit'];
$nukrit=$udata['ukrit']-$mag['ukrit'];
$nsila=$udata['sila']-$mag['sila'];
$nlovk=$udata['lovk']-$mag['lovk'];
$nprot=$udata['prot']-$mag['prot'];
mysql_query("UPDATE `users` SET `hp` = '$hp',
`hpall` = '$nhp', `mp` = '$mp', `mpall` = '$nmp', `krit` = '$nkrit', `ukrit` = '$nukrit', `sila` = '$nsila', `lovk` = '$nlovk', `prot` = '$nprot' WHERE `usr` = '$log'");if(empty($_GET['id'])){
mysql_query("UPDATE `weapon` SET `image` = 'not' WHERE `usr` = '$log' AND `tip` = '$_GET[tip]' AND `image` = 'yes'");
}else{
mysql_query("UPDATE `weapon` SET `image` = 'not' WHERE `usr` = '$log' AND `tip` = '$_GET[tip]' AND `image` = 'yes' AND `id` = '$_GET[id]'");
}
header('Location: pers.php?act=vooruzh');exit;
break;
}
include($path.'files/down.php');
?>