<?php
define('PROTECTOR', 1);
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
$textl='Тумбочка';
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
if(isset($_GET['send'])){
$id=$_GET['id'];
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr` = '$log' AND `id`= '$id' ") OR die(mysql_error());
$avto=mysql_num_rows($req);
if($avto==1){
mysql_query("UPDATE `weapon` SET
`image` =  'sklad' WHERE `usr` = '$log' AND `id` = '$id'");
echo'<div class="main"><div class="block_zero center"><span style="color: #3c3;"><img src="image/icon/ok.png" alt="*"> Вещь положена в сейф!</span></div><div class="mini-line"></div></div>';
}else{
echo'<div class="main"><div class="block_zero center"><span style="color: #ff3434;"><img src="image/icon/error.png" alt="*"> Вещь не положена в сейф!</span></div><div class="mini-line"></div></div>';
}
}

switch($_GET['mod']){

default:
$artefact = mysql_result(mysql_query("SELECT COUNT(*) FROM `res` WHERE `usr` = '$log' AND `tip` = 'artefact'"),0);
$elex = mysql_result(mysql_query("SELECT COUNT(*) FROM `res` WHERE `usr` = '$log' AND `tip` = 'elexir'"),0);
$res = mysql_result(mysql_query("SELECT COUNT(*) FROM `res` WHERE `usr` = '$log' AND `tip` = 'res'"),0);
$aura = mysql_result(mysql_query("SELECT COUNT(*) FROM `item_aura` WHERE `usr` = '$log'"),0);
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr` =  '$log' AND `image` = 'not' ") OR die (mysql_error());
$avto=mysql_num_rows($req);
echo'<div class="main"><div class="block_zero"><a href="sklad.php?"><img src="image/icon/bag.png" alt="*"> Открыть сейф</a></div><div class="mini-line"></div>';
if($avto>0){
echo'<div class="main"><div class="block_zero"><a href="lambard.php?mod=item"><img src="image/icon/bag.png" alt="*"> Продажа шмоток</a></div><div class="mini-line"></div>';
}
if($avto==0){
echo'<div class="main"><div class="block_zero center">Тумбочка пуста</div></div>';
}else{
$am=0;
While($mag = mysql_fetch_array($req))
{
if($set['lvl']>=$mag['nlvl']){
$font="#9c9";
$pic="ok.png";
}
if($set['lvl']<$mag['nlvl']){
$font="#c66";
$pic="error.png";
}
$wep = mysql_query("SELECT * FROM `weapon` WHERE `image` = 'yes' AND `usr` = '$log' AND `tip` = '$mag[tip]'") OR die (mysql_error());
$wep = mysql_fetch_array($wep);
$stat = $wep['hp']+$wep['mp']+$wep['krit']+$wep['ukrit']+$wep['sila']+$wep['lovk']+$wep['prot'];
$statmag = $mag['hp']+$mag['mp']+$mag['krit']+$mag['ukrit']+$mag['sila']+$mag['lovk']+$mag['prot'];
if($stat==$statmag){
$tex=" +0";
}
if($statmag-$stat>0){
$sta=$statmag-$stat;
$tex="<font color='#9c9'> +$sta</font>";
}
if($statmag-$stat<0){
$sta=$statmag-$stat;
$tex="<font color='#c66'> $sta</font>";
}
$am=$am+$mag['cena'];
if(!empty($mag['img'])){
$patch="art/$mag[img]";
}else{
$patch="weapon/$mag[kompl]/$mag[tip].png";
}
switch($mag['tip']){
case 'weapon':
$tip='';
break;
case 'body':
$tip='';
break;
case 'golova':
$tip='';
break;
case 'nogi':
$tip='';
break;
case 'shit':
$tip='';
break;
}
echo'<div class="main"><div class="block_zero">';
echo'<img class="float-left" src="image/'.$patch.'" width="50" height="50" style="margin-left:10px; margin-right:10px;" alt="*"><a href="inventar.php?mod=info&id='.$mag['id'].'"><span style="color: '.$font.';"><img src="image/icon/'.$pic.'" alt="*"> '.$tip.' '.$mag['name'].' '.$tex.'</span></a>'; 
echo'<br><small>Небходимо бицухи: '.$mag['nlvl'].'<br>Бонус: '.$mag['proch'].'/10</small><div class="separ"></div>';
echo'<center><a href="dress.php?mod=nadet&tip='.$mag['tip'].'&id='.$mag['id'].'"><span class="btn"><span class="end"><input class="label" type="submit" value="Одеть"></span></span></a> <a href="inventar.php?send&id='.$mag['id'].'"><span class="btn"><span class="end"><input class="label" type="submit" value="В сундук"></span></span></a> <a href="kuznec.php?mod=razob&tip='.$mag['tip'].'&id='.$mag['id'].'"><span class="btn"><span class="end"><input class="label" type="submit" value="Разобрать"></span></span></a></center>';
echo'</div><div class="menuList"><li><li></li></li></div></div>';
}
}
echo'</div></div>';
break;
//-----
case 'res':
$req = mysql_query("SELECT * FROM `res` WHERE `usr` = '$log' AND `tip` = 'res' AND kol > '0'");
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req)){
$img = substr($mag['lat_name'],0,3);
echo'<div class="main"><div class="block_zero">';
echo'<img class="float-left" src="image/resurs/'.$img.'.png" width="50" height="50" style="margin-left:1px; margin-right:10px;" alt="*"><a href="inventar.php?mod=info&amp;act=res&amp;id='.$mag['id'].'">'.$mag['name'].'</a> ('.$mag['kol'].' <span style="color: #9CC;">шт.</span>)<br><small><span style="color: #999;">Используется для улучшения снаряжения<br><br></span></small></div></div>';
}
}else{
echo'<div class="main"><div class="block_zero">Нет ресурсов</div></div>';
}
echo'<div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div>';
break;
//-----
case 'elexir':
echo"<b>Элексиры</b> $div";
$req = mysql_query("SELECT * FROM `res` WHERE `usr` = '$log' and `tip`='elexir' and kol>'0'");
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req)){
echo"<img src=\"pic/main/$mag[what]e.png\" alt=\"*\"/> <a href=\"inventar.php?mod=info&act=elexir&id=$mag[id]\">$mag[name]</a>
 ($mag[kol] штук) [<a href=\"elexirs.php?id=$mag[id]\">использовать</a>]<br/>";
}echo"$div<a href=\"inventar.php?\">Назад</a>";
}else{
echo"<b>Нет элексиров</b><br/>";
}
break;
//-----
case 'artefact':
$req = mysql_query("SELECT * FROM `res` WHERE `usr` = '$log' AND `tip`='artefact' and kol>'0'");
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req)){
$img = substr($mag['lat_name'],0,3);
echo'<div class="main"><div class="block_zero">';
echo'<img class="float-left" src="image/resurs/'.$img.'.png" width="50" height="50" style="margin-left:1px; margin-right:10px;" alt="*"><a href="inventar.php?mod=info&amp;act=artefact&amp;id='.$mag['id'].'">'.$mag['name'].'</a> ('.$mag['kol'].' <span style="color: #9CC;">шт.</span>)<br><small><span style="color: #999;">Используется для улучшения снаряжения<br><br></span></small></div></div>';
}
}else{
echo'<div class="main"><div class="block_zero">Нет Инструментов</div></div>';
}
echo'<div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div>';
break;
//-----
case 'info':
if($_GET['act']=='res' OR $_GET['act']=='elexir' OR $_GET['act']=='artefact'){
$req = mysql_query("SELECT * FROM `res` WHERE `usr` = '$log' AND `id`='".mysql_real_escape_string($_GET['id'])."'");
$avto=mysql_num_rows($req);
if($avto==0){
echo'Ошибка!';
include($path.'files/down.php');exit;
}
$mag = mysql_fetch_array($req);
$img = substr($mag['lat_name'],0,3);
switch($mag['tip']){
case 'res':
$tip='Ресурс';
break;
case 'artefact':
$tip='Инструмент';
break;
case 'elexir':
$tip='Элексир';
break;
}
echo'<div class="main"><div class="block_zero">';
echo'<img class="float-left" src="image/resurs/'.$img.'.png" width="50" height="50" style="margin-left:1px; margin-right:10px;" alt="*">'.$mag['name'].'<br>Тип: '.$tip.'<br>Количество: '.$mag['kol'].'</div>';
echo'<div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div></div>';
break;
}
if(isset($i)){
$i++;
}
if(isset($b)){
$b++;
}
if(isset($mag['unknow'])){
if($mag['unknow']=='1'){
switch($mag['tip']){
case 'weapon':
$tip='';
break;
case 'body':
$tip='';
break;
case 'golova':
$tip='';
break;
case 'nogi':
$tip='';
break;
case 'shit':
$tip='';
break;
}

echo'Вещь: '.$mag['name_item'].'<br/>';

echo"Тип: $tip<br/>
<b>Характеристика</b><br/>

Жизнь: $mag[hp]<br/>
Мана: $mag[mp]<br/>
Сила: $mag[sila]<br/>
Ловкость: $mag[lovk]<br/>
Физ. защита: $mag[prot]<br/>
Крит: $mag[krit]%<br/>
Крит-урон: $mag[ukrit]%<br/>
<b>Требования:</b><br/>
Уровень: $mag[nlvl]<br/>";
}
}
elseif($_GET['act']=='aura'){
$req = mysql_query("SELECT * FROM `item_aura` WHERE `usr` = '$log' and `id`='".mysql_real_escape_string($_GET[id])."'");
$avto=mysql_num_rows($req);
if($avto==0){
echo'Ошибка!';
include('files/down.php');exit;}
$mag = mysql_fetch_array($req);
echo"<b>$mag[name]</b><br/>
Урон: $mag[umin]/$mag[umax]<br/>
Физ. защита: $mag[protect]<br/>
Жизнь: $mag[hp]<br/>
Мана: $mag[mp]<br/>
Крит: $mag[krit]%<br/>
Крит-урон: $mag[ukrit]%<br/>
<b>Требования:</b><br/>
Уровень: $mag[nlvl]<br/>
Время действия: $mag[actime] сек.<br/>";
}else{
if(!empty($_GET['usr'])){
$logs = htmlspecialchars(addslashes(stripslashes($_GET['usr'])));}else{$logs="$log";}
$req = mysql_query("SELECT * FROM `weapon` WHERE `id`='".mysql_real_escape_string($_GET['id'])."' and `usr`='$logs'");
$avto=mysql_num_rows($req);
$mag = mysql_fetch_array($req);
switch($mag['tip']){
case 'weapon':
$tip='';
break;
case 'body':
$tip='';
break;
case 'golova':
$tip='';
break;
case 'nogi':
$tip='';
break;
case 'shit':
$tip='';
break;
}
if($set['lvl']>=$mag['nlvl']){
$font="#9c9";
$pic="ok.png";
}
if($set['lvl']<$mag['nlvl']){
$font="#c66";
$pic="error.png";
}
if(!empty($mag['img'])){$patch="art/$mag[img]";}else{
$patch="image/weapon/$mag[kompl]/$mag[tip].png";}
echo'<div class="main"><div class="block_zero">';
echo'<img class="float-left" src="'.$patch.'" width="59" height="59" style="margin-left:10px; margin-right:10px;" alt="*">';
echo"<font color='#ffc22b'>$tip $mag[name]</font> ($mag[nlvl], $mag[proch]/10)<br></font>";

if(!empty($mag['hp'])){echo"<img src='image/icon/health.png' alt='*'> Жизнь: <font color='$font'><b>+ $mag[hp]<br/></font></b>";}
if(!empty($mag['mp'])){echo"<img src='image/icon/mana.png' alt='*'> Энергия: <font color='$font'><b>+ $mag[mp]<br/></b></font>";}
if(!empty($mag['sila'])){echo"<img src='image/icon/str.png' alt='*'> Сила: <font color='$font'><b>+ $mag[sila]<br/></b></font>";}
echo'<img class="float-left" src="image/weapon/0/0.png" width="59" height="59" style="margin-left:10px; margin-right:10px;" alt="*">';
if(!empty($mag['lovk'])){echo"<img src='image/icon/agi.png' alt='*'> Ловкость: <font color='$font'><b>+ $mag[lovk]<br/></b></font>";}
if(!empty($mag['prot'])){echo"<img src='image/icon/def.png' alt='*'> Защита: <font color='$font'><b>+ $mag[prot]<br/></b></font>";}
if(!empty($mag['krit'])){echo"<img src='image/icon/tournament.png' alt='*'> Крит-удар: <font color='$font'><b>+ $mag[krit]%<br/></b></font>";}
if(!empty($mag['ukrit'])){echo"<img src='image/icon/sumstat.png' alt='*'> Крит-урон: <font color='$font'><b>+ $mag[ukrit]%<br/></b></font>";}

echo'</div><div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div>';
}
echo'</div></div>';
break;
//-----
case 'aura':
$req = mysql_query("SELECT * FROM `item_aura` WHERE `usr` = '$log'");
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req)){
echo"<div class='dot'><img src=\"pic/pers/aurs/$mag[ava]\"  width='33' height='33' alt=\"*\" style=\"float:left;margin-right:5px;\"/>";
if($udata['lvl']>=$mag['nlvl']){$font="#71bb71";}else{$font="chocolate";}
echo"<font color='$font'>$mag[name] ($mag[nlvl] ур.)</font></br>"; 
if(!empty($mag['hp'])){echo'<img src="pic/hp.png" alt="*"/> <font color="71cc71">+'.$mag['hp'].' Жизни</font></br>';}
if(!empty($mag['mp'])){echo'<img src="pic/mp.png" alt="*"/> <font color="71cc71">+'.$mag['mp'].' Энергии</font></br>';}
if(!empty($mag['sila'])){echo'<img src="pic/pers/udar.png" alt="*"/> <font color="71cc71">+'.$mag['sila'].' Силы</font></br>';}
if(!empty($mag['protect'])){echo'<img src="pic/pers/verh.png" alt="*"/> <font color="71cc71">+'.$mag['protect'].' Защиты</font></br>';}
if(!empty($mag['lovk'])){echo'<img src="pic/pers/lovk.png" alt="*"/> <font color="71cc71">+'.$mag['lovk'].' Ловкости</font></br>';}
if(!empty($mag['krit'])){echo'<img src="pic/pers/krit.png" alt="*"/> <font color="71cc71">+'.$mag['krit'].' Бонус крит</font></br>';}
if(!empty($mag['ukrit'])){echo'<img src="pic/pers/krit.png" alt="*"/> <font color="71cc71">+'.$mag['ukrit'].' Бонус крит-урона</font></br>';}
$ark=round($mag['actime']/3600,1);
if($ark==1){$chas="час";}
if($ark>=2 and $ark<=4){$chas="часа";}
if($ark>=5){$chas="часов";}
echo"Длительность: <b>$ark</b> $chas</br>
[<a href=\"aura.php?id=$mag[id]\">активировать</a>]<br/></div>";
}
}else{
echo'<div class="main"><div class="block_zero center">Нет аур</div></div>';
}break;
}
include($path.'files/down.php');
?>