<?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($set['kuznec']==0){
echo'<div class="main"><div class="block_zero center">У Вас нет профессии - Кузнец,<br>Вы не можете пользоваться кузницей!</div></div>';
include($path.'files/down.php');exit;
}

switch($_GET['mod']){

default:

echo'<div class="main"><div class="block_zero center"><span style="color: #9bc;">В кузнице можно улучшить свое вооружение</span></div><div class="mini-line"></div><div class="block_zero center"><img src="image/logo/smith.png" alt="logo"></div><div class="dot-line"></div>';

echo'<a href="kuznec.php?mod=runa"><div class="block_zero"><img src="image/icon/rune.png" alt="*"> Торговец рунами<br><small><span style="color: #ffffff;">Улучшение вещей с помощью рун</span></small></div></a><div class="dot-line"></div>';

echo'<a href="kuznec.php?mod=zakalka"><div class="block_zero"><img src="image/icon/smith.png" alt="*"> Закалка вооружения<br><small><span style="color: #ffffff;">Требуются специальные ресурсы</span></small></div></a><div class="dot-line"></div>';

echo'<a href="kuznec.php?mod=bonus"><div class="block_zero"><img src="image/icon/smith.png" alt="*"> Бонус вещей<br><small><span style="color: #ffffff;">Улучшение бонуса вещей</span></small></div></a><div class="dot-line"></div>';

echo'<a href="sunduki.php?"><div class="block_zero"><img src="image/icon/key.png" alt="*"> Тайник<br><small><span style="color: #ffffff;">Поиск сокровищ</span></small></div></a><div class="mini-line"></div>';

echo'<ul class="hint"><li>Ресурсы можно добыть на <img src="image/icon/train.png" alt="*"><a href="rydnik.php"> Руднике</a></li></ul></div>';

break;

case 'zakalka':
//ЗАКАЛКА ШМОТА
echo'<div class="main"><div class="block_zero center"><span style="color: #9bc;">Закалка улучшает все параметры вещи!</span></div><div class="mini-line"></div>';

if(empty($_GET['image'])){
$image="yes";
}else{
$image=$_GET['image'];
}
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `image`= '".mysql_real_escape_string($image)."' ");
$avto=mysql_num_rows($req);
if($avto==0){
echo'<div class="block_zero center">Ничего не одето</div>';
echo"<div class='mini-line'></div>";
}else{
While($mag = mysql_fetch_array($req))
{
if($udata['lvl']>$mag['nlvl']){
$font="#9c9";
$pic="ok.png";
}
if($udata['lvl']<$mag['nlvl']){
$font="#c66";
$pic="error.png";
}
$wep = mysql_query("SELECT * FROM `weapon` WHERE `image` = 'yes' AND `usr` = '$log' AND `tip` = '$mag[tip]'");
$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='<span style="color: #999;"> + 0</span>';
}
if($statmag-$stat>0){
$sta=$statmag-$stat;
$tex='<span style="color: #9c9;"> +'.$sta.'</span>';
}
if($statmag-$stat<0){
$sta=$statmag-$stat;
$tex='<span style="color: #c66;"> '.$sta.'</span>';
}
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="block_zero">';
echo'<img class="float-left" src="image/weapon/'.$mag['kompl'].'/'.$mag['tip'].'.png" width="60" height="60" style="margin-left:10px; margin-right:10px;" alt="*"><a href="inventar.php?mod=info&id='.$mag['id'].'"><span style="color: #fc6;"> '.$tip.' '.$mag['name'].'</a></span> +'.$wep['zakal'].'<br>+ '.$stat.' к параметрам<br>Бонус: '.$mag['proch'].'/10<br>';
echo"<span class='btn'><span class='end'><a href=\"kuznec.php?mod=zakal&id=$mag[id]\"><input class='label' type='submit' value='Выбрать'></span></span></a>";
echo'</div><div class="dot-line"></div>';
}
}
echo'<div class="dot-line"></div>';
echo'<div class="block_zero">';
echo'<a href="kuznec.php?"><img src="image/icon/arrow.png"> В кузницу</a></div></div>';
break;
//**********

case 'bonus':
// БОНУС ШМОТА
echo'<div class="main"><div class="block_zero center"><span style="color: #9bc;">Бонус улучшает все параметры вещи!</span></div><div class="mini-line"></div>';

if(empty($_GET['image'])){
$image="yes";
}else{
$image=$_GET['image'];
}
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `image`= '".mysql_real_escape_string($image)."' ");
$avto=mysql_num_rows($req);
if($avto==0){
echo'<div class="block_zero center">Ничего не одето</div>';
echo"<div class='mini-line'></div>";
}else{
While($mag = mysql_fetch_array($req))
{
if($udata['lvl']>$mag['nlvl']){
$font="#9c9";
$pic="ok.png";
}
if($udata['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='<span style="color: #999;"> + 0</span>';
}
if($statmag-$stat>0){
$sta=$statmag-$stat;
$tex='<span style="color: #9c9;"> +'.$sta.'</span>';
}
if($statmag-$stat<0){
$sta=$statmag-$stat;
$tex='<span style="color: #c66;"> '.$sta.'</span>';
}
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="block_zero">';
echo'<img class="float-left" src="image/weapon/'.$mag['kompl'].'/'.$mag['tip'].'.png" width="60" height="60" style="margin-left:10px; margin-right:10px;" alt="*"><a href="inventar.php?mod=info&id='.$mag['id'].'"><span style="color: #fc6;"> '.$tip.' '.$mag['name'].'</a></span> +'.$wep['zakal'].'<br>+ '.$stat.' к параметрам<br>Бонус: '.$mag['proch'].'/10<br>';
echo"<span class='btn'><span class='end'><a href=\"kuznec.php?mod=remont&id=$mag[id]\"><input class='label' type='submit' value='Выбрать'></span></span></a>";
echo'</div><div class="dot-line"></div>';
}
}
echo'<div class="dot-line"></div>';
echo'<div class="block_zero">';
echo'<a href="kuznec.php?"><img src="image/icon/arrow.png"> В кузницу</a></div></div>';
break;
//**********

case 'runa':
echo'<div class="main"><div class="block_zero center"><span style="color: #9bc;">Магические свойства рун улучшат ваши вещи!</span></div><div class="mini-line"></div><div class="block_zero center"><img src="image/logo/rune.png" alt="logo"></div><div class="dot-line"></div>';

if(empty($_GET['image'])){
$image="yes";
}else{
$image=$_GET['image'];
}
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `image`= '".mysql_real_escape_string($image)."' ");
$avto=mysql_num_rows($req);
if($avto==0){
echo'<div class="block_zero center">Ничего не одето</div>';
echo"<div class='mini-line'></div>";
}else{
While($mag = mysql_fetch_array($req))
{
if($udata['lvl']>$mag['nlvl']){
$font="#9c9";
$pic="ok.png";
}
if($udata['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='<span style="color: #999;"> + 0</span>';
}
if($statmag-$stat>0){
$sta=$statmag-$stat;
$tex='<span style="color: #9c9;"> +'.$sta.'</span>';
}
if($statmag-$stat<0){
$sta=$statmag-$stat;
$tex='<span style="color: #c66;"> '.$sta.'</span>';
}
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;
}
if($wep['runa']==1){
$runa='<img src="image/kachestvo/0.png" alt="*">';
}
elseif($wep['runa']==2){
$runa='<img src="image/kachestvo/1.png" alt="*">';
}
elseif($wep['runa']==3){
$runa='<img src="image/kachestvo/2.png" alt="*">';
}
elseif($wep['runa']==4){
$runa='<img src="image/kachestvo/3.png" alt="*">';
}
elseif($wep['runa']==5){
$runa='<img src="image/kachestvo/4.png" alt="*">';
}
elseif($wep['runa']==6){
$runa='<img src="image/kachestvo/5.png" alt="*">';
}else{
$runa=FALSE;
}
echo'<div class="block_zero">';
//if($wep['runa']<6){

echo'<img class="float-left" src="image/weapon/'.$mag['kompl'].'/'.$mag['tip'].'.png" width="60" height="60" style="margin-left:10px; margin-right:10px;" alt="*"><a href="inventar.php?mod=info&id='.$mag['id'].'"><span style="color: #fc6;">'.$runa.' '.$tip.' '.$mag['name'].'</a></span> +'.$wep['zakal'].'<br>+ '.$stat.' к параметрам<br>Бонус: '.$mag['proch'].'/10<br>';
echo"<span class='btn'><span class='end'><a href=\"kuznec.php?mod=run&id=$mag[id]\"><input class='label' type='submit' value='Выбрать'></span></span></a>";
echo'</div><div class="dot-line"></div>';
}
}
//}
echo'<div class="dot-line"></div>';
echo'<div class="block_zero">';
echo'<a href="kuznec.php?"><img src="image/icon/arrow.png"> В кузницу</a></div></div></div>';
break;






case 'run':

if(isset($_GET['nachat'])){

if($_GET['nachat']=='10'){

$id = $_GET['id'];
$ves = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `id`= '".mysql_real_escape_string($id)."' ");
$vesh = mysql_fetch_array($ves);
if($vesh['runa']>=6){
$_SESSION['err']="Установлена наилучшая руна!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}

$sila =10;
$lovk = 10;
$prot = 10;
$hp = 10;
$mp = 10;
$ukrit = 10;
$cena=($sila+$lovk+$prot+$hp+$mp+$ukrit)*15+$vesh['cena'];
$stoim=50;
$kach=1;
$avto=mysql_num_rows($ves);

if($avto==0){
$_SESSION['err']="Вещь не найдена!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}

if($udata['almaz']<50){
$_SESSION['err']="Не достаточно золота!";
header('Location: kuznec.php?mod=run&id='.$id.'');
break;
}

}
//++++++++
if($_GET['nachat']=='20'){

$id = $_GET['id'];
$ves = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `id`= '".mysql_real_escape_string($id)."' ");
$vesh = mysql_fetch_array($ves);
if($vesh['runa']>=6){
$_SESSION['err']="Установлена наилучшая руна!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}

if($vesh['runa']==1){
$run=10;
}else{
$run=FALSE;
}

$sila =20-$run;
$lovk = 20-$run;
$prot = 20-$run;
$hp = 20-$run;
$mp = 20-$run;
$ukrit = 20-$run;
$cena=($sila+$lovk+$prot+$hp+$mp+$ukrit)*15+$vesh['cena'];
$stoim=200;
$kach=2;
$avto=mysql_num_rows($ves);

if($avto==0){
$_SESSION['err']="Вещь не найдена!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}

if($udata['almaz']<200){
$_SESSION['err']="Не достаточно золота!";
header('Location: kuznec.php?mod=run&id='.$id.'');
break;
}

}
//++++++++
if($_GET['nachat']=='40'){

$id = $_GET['id'];
$ves = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `id`= '".mysql_real_escape_string($id)."' ");
$vesh = mysql_fetch_array($ves);
if($vesh['runa']>=6){
$_SESSION['err']="Установлена наилучшая руна!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}
if($vesh['runa']==1){
$run=10;
}
elseif($vesh['runa']==2){
$run=20;
}else{
$run=FALSE;
}
$sila =40-$run;
$lovk = 40-$run;
$prot = 40-$run;
$hp = 40-$run;
$mp = 40-$run;
$ukrit = 40-$run;
$cena=($sila+$lovk+$prot+$hp+$mp+$ukrit)*15+$vesh['cena'];
$stoim=800;
$kach=3;
$avto=mysql_num_rows($ves);

if($avto==0){
$_SESSION['err']="Вещь не найдена!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}

if($udata['almaz']<800){
$_SESSION['err']="Не достаточно золота!";
header('Location: kuznec.php?mod=run&id='.$id.'');
break;
}

}
//++++++++
if($_GET['nachat']=='60'){

$id = $_GET['id'];
$ves = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `id`= '".mysql_real_escape_string($id)."' ");
$vesh = mysql_fetch_array($ves);
if($vesh['runa']>=6){
$_SESSION['err']="Установлена наилучшая руна!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}
if($vesh['runa']==1){
$run=10;
}
elseif($vesh['runa']==2){
$run=20;
}
elseif($vesh['runa']==3){
$run=40;
}else{
$run=FALSE;
}
$sila =60-$run;
$lovk = 60-$run;
$prot = 60-$run;
$hp = 60-$run;
$mp = 60-$run;
$ukrit = 60-$run;
$cena=($sila+$lovk+$prot+$hp+$mp+$ukrit)*15+$vesh['cena'];
$stoim=3200;
$kach=4;
$avto=mysql_num_rows($ves);

if($avto==0){
$_SESSION['err']="Вещь не найдена!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}

if($udata['almaz']<3200){
$_SESSION['err']="Не достаточно золота!";
header('Location: kuznec.php?mod=run&id='.$id.'');
break;
}

}
//++++++++
if($_GET['nachat']=='80'){

$id = $_GET['id'];
$ves = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `id`= '".mysql_real_escape_string($id)."' ");
$vesh = mysql_fetch_array($ves);
if($vesh['runa']>=6){
$_SESSION['err']="Установлена наилучшая руна!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}
if($vesh['runa']==1){
$run=10;
}
elseif($vesh['runa']==2){
$run=20;
}
elseif($vesh['runa']==3){
$run=40;
}
elseif($vesh['runa']==4){
$run=60;
}else{
$run=FALSE;
}
$sila =80-$run;
$lovk = 80-$run;
$prot = 80-$run;
$hp = 80-$run;
$mp = 80-$run;
$ukrit = 80-$run;
$cena=($sila+$lovk+$prot+$hp+$mp+$ukrit)*15+$vesh['cena'];
$stoim=12500;
$kach=5;
$avto=mysql_num_rows($ves);

if($avto==0){
$_SESSION['err']="Вещь не найдена!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}

if($udata['almaz']<12500){
$_SESSION['err']="Не достаточно золота!";
header('Location: kuznec.php?mod=run&id='.$id.'');
break;
}

}
//++++++++
if($_GET['nachat']=='100'){

$id = $_GET['id'];
$ves = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `id`= '".mysql_real_escape_string($id)."' ");
$vesh = mysql_fetch_array($ves);
if($vesh['runa']>=6){
$_SESSION['err']="Установлена наилучшая руна!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}
if($vesh['runa']==1){
$run=10;
}
elseif($vesh['runa']==2){
$run=20;
}
elseif($vesh['runa']==3){
$run=40;
}
elseif($vesh['runa']==4){
$run=60;
}
elseif($vesh['runa']==5){
$run=80;
}else{
$run=FALSE;
}
$sila =100-$run;
$lovk = 100-$run;
$prot = 100-$run;
$hp = 100-$run;
$mp = 100-$run;
$ukrit = 100-$run;
$cena=($sila+$lovk+$prot+$hp+$mp+$ukrit)*15+$vesh['cena'];
$stoim=25000;
$kach=6;
$avto=mysql_num_rows($ves);

if($avto==0){
$_SESSION['err']="Вещь не найдена!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}

if($udata['almaz']<25000){
$_SESSION['err']="Не достаточно золота!";
header('Location: kuznec.php?mod=run&id='.$id.'');
break;
}

}
//++++++++

//++++++БОЖЕСТВЕННАЯ
$sh=$set['kuznec']/5;
$sh1=100-$sh;
//$sh=0;

$bog>=rand(0,100);

if($bog>=$sh1){

if($vesh['runa']==1){
$run=200;
}
elseif($vesh['runa']==2){
$stoim=800;
}
elseif($vesh['runa']==3){
$run=40;
$stoim=3200;
}
elseif($vesh['runa']==4){
$run=60;
$stoim=12500;
}
elseif($vesh['runa']==5){
$run=80;
$stoim=25000;
}else{
$run=FALSE;
}
$sila =100-$run;
$lovk = 100-$run;
$prot = 100-$run;
$hp = 100-$run;
$mp = 100-$run;
$ukrit = 100-$run;
$cena=($sila+$lovk+$prot+$hp+$mp+$ukrit)*15+$vesh['cena'];
$kach=6;

if($vesh['image']=='yes'){
mysql_query("UPDATE `users` SET `sila` = `sila`+'$sila', `lovk` = `lovk`+'$lovk', `prot` = `prot`+'$prot',
`ukrit` = `ukrit`+'$ukrit', `hpall` = `hpall`+'$hp', `mpall` = `mpall`+'$mp', `hp` = `hp`+'$hp',
`mp` = `mp`+'$mp' WHERE `usr` = '$log'");
}
mysql_query("UPDATE `weapon` SET `name` = `name`,
`cena` = '$cena',
`sila` = `sila`+'$sila',
`lovk` = `lovk`+'$lovk',
`runa` = '6',
`prot` = `prot`+'$prot',
`ukrit` = `ukrit`+'$ukrit',
`hp` = `hp`+'$hp',
`mp` = `mp`+'$mp' WHERE `usr` = '$log' AND `id` = '".mysql_real_escape_string($id)."'");
mysql_query("UPDATE `users` SET `almaz` = `almaz`-'$stoim' WHERE `usr` = '$log'");
$_SESSION['message']="Вам повезло, установлена руна Титанического качества!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}
//++++++БОЖЕСТВЕННАЯ

//++++++ПОКУПКА
if($vesh['image']=='yes'){
mysql_query("UPDATE `users` SET `sila` = `sila`+'$sila', `lovk` = `lovk`+'$lovk', `prot` = `prot`+'$prot',
`ukrit` = `ukrit`+'$ukrit', `hpall` = `hpall`+'$hp', `mpall` = `mpall`+'$mp', `hp` = `hp`+'$hp',
`mp` = `mp`+'$mp' WHERE `usr` = '$log'");
}
mysql_query("UPDATE `weapon` SET `name` = `name`,
`cena` = '$cena',
`sila` = `sila`+'$sila',
`lovk` = `lovk`+'$lovk',
`runa` = '$kach',
`prot` = `prot`+'$prot',
`ukrit` = `ukrit`+'$ukrit',
`hp` = `hp`+'$hp',
`mp` = `mp`+'$mp' WHERE `usr` = '$log' AND `id` = '".mysql_real_escape_string($id)."'");
mysql_query("UPDATE `users` SET `almaz` = `almaz`-'$stoim' WHERE `usr` = '$log'");
$_SESSION['message']="Руна успешно установлена!";
header('Location: kuznec.php?mod=run&id='.$id.'');
exit();
break;
}

if(empty($_GET['id'])){
echo"<img src='pic/no.png' alt='*'/> Не выбрана вещь!";
break;
}else{
$id = $_GET['id'];
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `id`= '".mysql_real_escape_string($id)."' AND `runa`<'6' ");

$avto=mysql_num_rows($req);
if($avto==0){
$_SESSION['err']="Установлена наилучшая руна!";
header('Location: kuznec.php?mod=runa');
exit();
break;
}else{
$mag = mysql_fetch_array($req);
if($udata['lvl']>$mag['nlvl']){
$font="#9c9";
$pic="ok.png";
}
if($udata['lvl']<$mag['nlvl']){
$font="#c66";
$pic="error.png";
}
$wep = mysql_fetch_array(mysql_query("SELECT * FROM `weapon` WHERE `image` = 'yes' AND `usr` = '$log' AND `tip` = '$mag[tip]'"));
$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='<span style="color: #999;"> + 0</span>';
}
if($statmag-$stat>0){
$sta=$statmag-$stat;
$tex='<span style="color: #9c9;"> +'.$sta.'</span>';
}
if($statmag-$stat<0){
$sta=$statmag-$stat;
$tex='<span style="color: #c66;"> '.$sta.'</span>';
}
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;
}

if($wep['runa']==1){
$run=10;
}
elseif($wep['runa']==2){
$run=20;
}
elseif($wep['runa']==3){
$run=40;
}
elseif($wep['runa']==4){
$run=60;
}
elseif($wep['runa']==5){
$run=80;
}else{
$run=FALSE;
}

if($wep['runa']==1){
$runa='<img src="image/kachestvo/0.png" alt="*">';
}
elseif($wep['runa']==2){
$runa='<img src="image/kachestvo/1.png" alt="*">';
}
elseif($wep['runa']==3){
$runa='<img src="image/kachestvo/2.png" alt="*">';
}
elseif($wep['runa']==4){
$runa='<img src="image/kachestvo/3.png" alt="*">';
}
elseif($wep['runa']==5){
$runa='<img src="image/kachestvo/4.png" alt="*">';
}
elseif($wep['runa']==6){
$runa='<img src="image/kachestvo/5.png" alt="*">';
}else{
$runa=FALSE;
}


echo'<div class="main"><div class="block_zero">';
echo'<img class="float-left" src="image/weapon/'.$mag['kompl'].'/'.$mag['tip'].'.png" width="60" height="60" style="margin-left:10px; margin-right:10px;" alt="*"><a href="inventar.php?mod=info&id='.$mag['id'].'"><span style="color: #fc6;"> '.$runa.' '.$tip.' '.$mag['name'].'</a></span> +'.$wep['zakal'].'<br>+ '.$stat.' к параметрам<br>Бонус: '.$mag['proch'].'/10<br><br>';

echo'</div><div class="mini-line"></div><div class="block_zero center">';

$proch=$set['kuznec']/5;

if($wep['runa']<5){
echo"Шанс установить <img src='image/kachestvo/5.png' alt='*'/><span style='color: #999;'> Титаническую</span>: $proch%</div><div class='dot-line'>";
}

echo'</div>';


if($wep['runa']<1){
$och=10-$run;
echo'<div class="block_zero"><img class="float-left" src="image/rune/str.png" width="50" height="50" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/0.png" alt="*"><span style="color: #837900;"> Обычное качество</span></a><br><small>Бонус: +'.$och.' к каждому параметру</small>';

echo'<a class="btn" href="kuznec.php?mod=run&nachat=10&id='.$mag['id'].'"><span class="end"><span class="label">Установить за <img src="image/icon/almaz.png" alt="*"> 50</span></span></a></div><div class="dot-line"></div>';
}

if($wep['runa']<2){
$och=20-$run;
echo'<div class="block_zero"><img class="float-left" src="image/rune/str.png" width="50" height="50" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/1.png" alt="*"><span style="color: #5cc25c;"> Редкое качество</span></a><br><small>Бонус: +'.$och.' к каждому параметру</small>';

echo'<a class="btn" href="kuznec.php?mod=run&nachat=20&id='.$mag['id'].'"><span class="end"><span class="label">Установить за <img src="image/icon/almaz.png" alt="*"> 200</span></span></a></div><div class="dot-line"></div>';
}

if($wep['runa']<3){
$och=40-$run;
echo'<div class="block_zero"><img class="float-left" src="image/rune/str.png" width="50" height="50" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/2.png" alt="*"><span style="color: #4f91ff;"> Эпическое качество</span></a><br><small> Бонус: +'.$och.' к каждому параметру</small>';

echo'<a class="btn" href="kuznec.php?mod=run&nachat=40&id='.$mag['id'].'"><span class="end"><span class="label">Установить за <img src="image/icon/almaz.png" alt="*"> 800</span></span></a></div><div class="dot-line"></div>';
}

if($wep['runa']<4){
$och=60-$run;
echo'<div class="block_zero"><img class="float-left" src="image/rune/str.png" width="50" height="50" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/3.png" alt="*"><span style="color: #cc6be2;"> Легендарное качество</span></a><br><small> Бонус: +'.$och.' к каждому параметру</small>';

echo'<a class="btn" href="kuznec.php?mod=run&nachat=60&id='.$mag['id'].'"><span class="end"><span class="label">Установить за <img src="image/icon/almaz.png" alt="*"> 3200</span></span></a></div><div class="dot-line"></div>';
}

if($wep['runa']<5){
$och=80-$run;
echo'<div class="block_zero"><img class="float-left" src="image/rune/str.png" width="50" height="50" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/4.png" alt="*"><span style="color: #f96;"> Божественное качество</span></a><br><small> Бонус: +'.$och.' к каждому параметру</small>';

echo'<a class="btn" href="kuznec.php?mod=run&nachat=80&id='.$mag['id'].'"><span class="end"><span class="label">Установить за <img src="image/icon/almaz.png" alt="*"> 12500</span></span></a></div><div class="dot-line"></div>';
}

if($wep['runa']<6){
$och=100-$run;
echo'<div class="block_zero"><img class="float-left" src="image/rune/str.png" width="50" height="50" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/5.png" alt="*"><span style="color: #999;"> Титаническое качество</span></a><br><small> Бонус: +'.$och.' к каждому параметру</small>';

echo'<a class="btn" href="kuznec.php?mod=run&nachat=100&id='.$mag['id'].'"><span class="end"><span class="label">Установить за <img src="image/icon/almaz.png" alt="*"> 25000</span></span></a></div><div class="dot-line"></div>';
}
}
}
echo'<ul class="hint"><li>При покупке руны есть шанс получить Титаническую руну за те же деньги. Шанс зависит от уровня профессии - Кузнец!<br>Пример: Вы устанавливаете руну обычного качества. Вам повезло и вместо руны обычного качества вы получаете руну Титанического качества!</li><li>При установке руны лучшего качества учитываются параметры уже установленной руны!</li></ul>';
echo'<div class="mini-line"></div>';
echo'<div class="block_zero"><a href="kuznec.php?mod=runa"><img src="image/icon/arrow.png"> К выбору вещей</a></div></div>';
break;








case 'razob':
if(isset($_GET[nachat])){
$id = $_GET['id'];
$r = $_GET['r'];
$jel = $r-2273;
$ves = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' and `id`= '".mysql_real_escape_string($id)."' ");
$avto=mysql_num_rows($ves);
if($avto==0){echo"Вещь разобрана";break;}
$vesh = mysql_fetch_array($ves);
if($vesh[image]==yes){
mysql_query("UPDATE `users` SET `sila` =  '$udata[sila]'-'$vesh[sila]',`lovk` =  '$udata[lovk]'-'$vesh[lovk]',`prot` = '$udata[prot]'-'$vesh[prot]',`krit` =  '$udata[krit]'-'$vesh[krit]',`ukrit` =  '$udata[ukrit]'-'$vesh[ukrit]',`hpall` =  '$udata[hpall]'-'$vesh[hp]',`mpall` =  '$udata[mpall]'-'$vesh[mp]' WHERE `usr` = '$log'") or die (mysql_error());
}
$resd = mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' and `lat_name`= 'jelezo' ") or die (mysql_error());
$avto=mysql_num_rows($resd);
if($avto==0){
$res = mysql_fetch_array($resd);
mysql_query("INSERT INTO
        `res` SET
        `usr` = '$log',
        `name` = 'Железо',
        `lat_name` = 'jelezo',
        `tip` = 'res',
        `what` = 'res',
        `give` = '0',
        `kol` = '$jel',
        `cena` = '9'");
        }else{
$res = mysql_fetch_array($resd);
$nkol=$jel+$res[kol];
mysql_query("UPDATE `res` SET `kol` = '$nkol' WHERE `usr` = '$log' and `lat_name`='jelezo'") or die (mysql_error());}
mysql_query("DELETE FROM `weapon` WHERE `usr` = '$log' and `id`='".mysql_real_escape_string($id)."' ");
echo"<font color='#71cc71'>Вещь успешно разобрана на $jel железа!</font></br><a href=\"kuznec.php?mod=weapon\">В кузницу</a>";break;
}
if(empty($_GET['id'])){
echo"<img src='pic/no.png' alt='*'/> Не выбрана вещь!";break;}else{
$id = $_GET['id'];
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' and `id`= '".mysql_real_escape_string($id)."' ");
$avto=mysql_num_rows($req);
if($avto==0){echo"<img src='pic/no.png' alt='*'/>Уже нет такой вещи!</br><a href=\"kuznec.php?mod=weapon\">В кузницу</a>";break;}else{
$mag = mysql_fetch_array($req);
$jel = round($mag[cena]/20);
echo"Ваша вещь $mag[name]$div Вы можете разобрать её на: </br>
<img src='pic/pers/jel.png' alt='*'/> <b>$jel</b> Железа";
$r=$jel+2273;
echo "<form action=\"kuznec.php?mod=razob&nachat&id=$mag[id]&r=$r\" method=\"post\">";
echo '<input class="button" type="submit" value="Приступить" /></form>';
}
}
break;








//**********ЗАКАЛКА
case 'zakal':
if(isset($_GET['nachat'])){
$id = $_GET['id'];
$ves = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `id`= '".mysql_real_escape_string($id)."' ");
$vesh = mysql_fetch_array($ves);
if($vesh['zakal']>=10){
$_SESSION['err']="Вещь закалена полностью!";
header('Location: kuznec.php?mod=zakalka');
exit();
break;
}
$sila = round($vesh['sila']/10);
$lovk = round($vesh['lovk']/10);
$prot = round($vesh['prot']/10);
$hp = round($vesh['hp']/10);
$mp = round($vesh['mp']/10);
$ukrit = round($vesh['ukrit']/10);
$cena=($sila+$lovk+$prot+$hp+$mp+$ukrit)*15+$vesh['cena'];
$avto=mysql_num_rows($ves);
if($avto==0){
echo"<img src='pic/no.png' alt='*'/>Вещь не найдена";
break;
}
$jel = mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'jelezo' AND `kol`>='10'");
$avto=mysql_num_rows($jel);
if($avto==0){
$_SESSION['err']="Не достаточно ресурсов!";
header('Location: kuznec.php?mod=zakal&id='.$id.'');
exit();
break;
}
$nef = mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'nefrit' AND `kol`>='10'");
$avto=mysql_num_rows($nef);
if($avto==0){
$_SESSION['err']="Не достаточно ресурсов!";
header('Location: kuznec.php?mod=zakal&id='.$id.'');
exit();
break;
}

$obs = mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'obsidian' AND `kol`>='10'");
$avto=mysql_num_rows($obs);
if($avto==0){
$_SESSION['err']="Не достаточно ресурсов!";
header('Location: kuznec.php?mod=zakal&id='.$id.'');
exit();
break;
}
$ser = mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'serebro' AND `kol`>='10'");
$avto=mysql_num_rows($ser);
if($avto==0){
$_SESSION['err']="Не достаточно ресурсов!";
header('Location: kuznec.php?mod=zakal&id='.$id.'');
exit();
break;
}
$resd = mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'zakal' AND `kol`>='1'");$avto=mysql_num_rows($resd);
if($avto==0){
$_SESSION['err']="Не достаточно ресурсов!";
header('Location: kuznec.php?mod=zakal&id='.$id.'');
exit();
break;
}
$polom=rand(0,100);
if($polom>$set['kuznec']+50){
mysql_query("UPDATE `res` SET `kol` = `kol`-'10' WHERE `usr` = '$log' AND `lat_name`= 'jelezo'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'10' WHERE `usr` = '$log' AND `lat_name`= 'nefrit'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'10' WHERE `usr` = '$log' AND `lat_name`= 'obsidian'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'10' WHERE `usr` = '$log' AND `lat_name`= 'serebro'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'1' WHERE `usr` = '$log' AND `lat_name`= 'zakal'");
$_SESSION['err']="Вам не повезло, вещь не закалена!<br>Прокачивайте профессию - Кузнец.";
header('Location: kuznec.php?mod=zakal&id='.$id.'');
exit();
break;
}
//----------ЗАКАЛКА
if($vesh['image']=='yes'){
mysql_query("UPDATE `users` SET `sila` = `sila`+'$sila', `lovk` = `lovk`+'$lovk', `prot` = `prot`+'$prot',
`ukrit` = `ukrit`+'$ukrit', `hpall` = `hpall`+'$hp', `mpall` = `mpall`+'$mp' WHERE `usr` = '$log'");
}
mysql_query("UPDATE `weapon` SET `name` = `name`,
`cena` = '$cena',
`sila` = `sila`+'$sila',
`lovk` = `lovk`+'$lovk',
`zakal` = `zakal`+'1',
`prot` = `prot`+'$prot',
`ukrit` = `ukrit`+'$ukrit',
`hp` = `hp`+'$hp',
`mp` = `mp`+'$mp' WHERE `usr` = '$log' AND `id` = '".mysql_real_escape_string($id)."'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'10' WHERE `usr` = '$log' AND `lat_name`= 'jelezo'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'10' WHERE `usr` = '$log' AND `lat_name`= 'nefrit'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'10' WHERE `usr` = '$log' AND `lat_name`= 'obsidian'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'10' WHERE `usr` = '$log' AND `lat_name`= 'serebro'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'1' WHERE `usr` = '$log' AND `lat_name`= 'zakal'");
$_SESSION['message']="Вещь успешно закалена!";
header('Location: kuznec.php?mod=zakal&id='.$id.'');
exit();
break;
}

if(empty($_GET['id'])){
echo"<img src='pic/no.png' alt='*'/> Не выбрана вещь!</br><a href=\"kuznec.php?mod=weapon\">В кузницу</a>";
break;

}else{
$id = $_GET['id'];
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `id`= '".mysql_real_escape_string($id)."' AND `zakal`<'10' ");
$avto=mysql_num_rows($req);

if($avto==0){
$_SESSION['err']="Вещь закалена полностью!";
header('Location: kuznec.php?mod=zakalka');
exit();
break;
}else{

$mag = mysql_fetch_array($req);
if($udata['lvl']>$mag['nlvl']){
$font="#9c9";
$pic="ok.png";
}
if($udata['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='<span style="color: #999;"> + 0</span>';
}
if($statmag-$stat>0){
$sta=$statmag-$stat;
$tex='<span style="color: #9c9;"> +'.$sta.'</span>';
}
if($statmag-$stat<0){
$sta=$statmag-$stat;
$tex='<span style="color: #c66;"> '.$sta.'</span>';
}
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/weapon/'.$mag['kompl'].'/'.$mag['tip'].'.png" width="60" height="60" style="margin-left:10px; margin-right:10px;" alt="*"><a href="inventar.php?mod=info&id='.$mag['id'].'"><span style="color: #fc6;"> '.$tip.' '.$mag['name'].'</a></span> +'.$wep['zakal'].'<br>+ '.$stat.' к параметрам<br>Бонус: '.$mag['proch'].'/10<br><br>';

echo'</div><div class="mini-line"></div><div class="block_zero center">';

$zak1=round($wep['hp']/10);
$zak2=round($wep['mp']/10);
$zak3=round($wep['ukrit']/10);
$zak4=round($wep['sila']/10);
$zak5=round($wep['lovk']/10);
$zak6=round($wep['prot']/10);

$zakal=$zak1+$zak2+$zak3+$zak4+$zak5+$zak6;

$szak=$set['kuznec']+50;

$zakall=$wep['zakal']+1;

echo"Шанс закалки на<span style='color: #9c9;'> +$zakall</span>: $szak%<br><span style='color: #9c9;'>+ $zakal</span> к параметрам вещи";

echo "<form action=\"kuznec.php?mod=zakal&nachat&id=$mag[id]\" method=\"POST\">";
echo '<span class="btn"><span class="end"><input class="label" type="submit" value="Закалить"></span></span></form>';

echo'</div><div class="block_zero">';

$resd = mysql_fetch_array(mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'zakal' LIMIT 1"));
$net=1-$resd['kol'];
if($resd['kol']<1){
$nett=' - <span style="color: #ff3434;">не хватает '.$net.'!</span>';
}else{
$nett=' - <span style="color: #9c9;">есть!</span>';
}
$jel = mysql_fetch_array(mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'jelezo' LIMIT 1"));
$net1=10-$jel['kol'];
if($jel['kol']<10){
$nett1=' - <span style="color: #ff3434;">не хватает '.$net1.'!</span>';
}else{
$nett1=' - <span style="color: #9c9;">есть!</span>';
}
$nef = mysql_fetch_array(mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'nefrit' LIMIT 1"));
$net2=10-$nef['kol'];
if($nef['kol']<10){
$nett2=' - <span style="color: #ff3434;">не хватает '.$net2.'!</span>';
}else{
$nett2=' - <span style="color: #9c9;">есть!</span>';
}
$obs = mysql_fetch_array(mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'obsidian' LIMIT 1"));
$net3=10-$obs['kol'];
if($obs['kol']<10){
$nett3=' - <span style="color: #ff3434;">не хватает '.$net3.'!</span>';
}else{
$nett3=' - <span style="color: #9c9;">есть!</span>';
}
$ser = mysql_fetch_array(mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'serebro' LIMIT 1"));
$net4=10-$ser['kol'];
if($ser['kol']<10){
$nett4=' - <span style="color: #ff3434;">не хватает '.$net4.'!</span>';
}else{
$nett4=' - <span style="color: #9c9;">есть!</span>';
}
echo"Для закалки Вам потребуется: </br>
<img src='image/resurs/zak.png' width='12' height='12' alt='*'/> Свиток Закалки, 1 <span style='color: #9bc;'>шт.</span>$nett</br>
<img src='image/resurs/jelezo.png' alt='*'/> Железа, 10 <span style='color: #9bc;'>шт.</span>$nett1</br>
<img src='image/resurs/nefrit.png' alt='*'/> Нефрита, 10 <span style='color: #9bc;'>шт.</span>$nett2</br>
<img src='image/resurs/obsidian.png' alt='*'/> Обсидиана, 10 <span style='color: #9bc;'>шт.</span>$nett3</br>
<img src='image/resurs/serebro.png' alt='*'/> Оникса, 10 <span style='color: #9bc;'>шт.</span>$nett4</br>";
}
}
echo'</div><div class="dot-line"></div>';
echo'<ul class="hint"><li>Ресурсы можно добыть на <img src="image/icon/train.png" alt="*"><a href=""> Руднике</a></li></ul>';
echo'<div class="mini-line"></div>';
echo'<div class="block_zero"><a href="kuznec.php?mod=weapon"><img src="image/icon/arrow.png"> В кузницу</a></div></div>';
break;
//***************************************
case 'remont':
if(isset($_GET['nachat'])){
$id = $_GET['id'];
$ves = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `id`= '".mysql_real_escape_string($id)."' ");
$vesh = mysql_fetch_array($ves);
if($vesh['proch']>=10){
$_SESSION['err']="Бонус вещи повышен полностью!";
header('Location: kuznec.php?mod=bonus');
exit();
break;
}

$sila = round($vesh['sila']/10);
$lovk = round($vesh['lovk']/10);
$prot = round($vesh['prot']/10);
$hp = round($vesh['hp']/10);
$mp = round($vesh['mp']/10);
$ukrit = round($vesh['ukrit']/10);
$cena=($sila+$lovk+$prot+$hp+$mp+$ukrit)*15+$vesh['cena'];

$avto=mysql_num_rows($ves);

if($avto==0){
echo"<img src='pic/no.png' alt='*'/>Вещь не найдена";
break;
}

if($udata['almaz']<100){
$_SESSION['err']="Не достаточно ресурсов!";
header('Location: kuznec.php?mod=remont&id='.$id.'');
break;
}

$resd = mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'kamen' AND `kol`>='$reso'");
$avto=mysql_num_rows($resd);
if($avto==0){
$_SESSION['err']="Не достаточно ресурсов!";
header('Location: kuznec.php?mod=remont&id='.$id.'');
break;
}

$resd = mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'remont' AND `kol`>='1'");
$avto=mysql_num_rows($resd);
if($avto==0){
$_SESSION['err']="Не достаточно ресурсов!";
header('Location: kuznec.php?mod=remont&id='.$id.'');
break;
}

$polom=rand(0,100);
if($polom>$set['kuznec']+50){
mysql_query("UPDATE `res` SET `kol` = `kol`-'10' WHERE `usr` = '$log' AND `lat_name`= 'kamen'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'1' WHERE `usr` = '$log' AND `lat_name`= 'remont'");
mysql_query("UPDATE `users` SET `almaz` = `almaz`-'100' WHERE `usr` = '$log'");
$_SESSION['err']="Вам не повезло, бонус не повышен!<br>Прокачивайте профессию - Кузнец.";
header('Location: kuznec.php?mod=remont&id='.$id.'');
exit();
break;
}
//----------БОНУС
if($vesh['image']=='yes'){
mysql_query("UPDATE `users` SET `sila` = `sila`+'$sila', `lovk` = `lovk`+'$lovk', `prot` = `prot`+'$prot',
`ukrit` = `ukrit`+'$ukrit', `hpall` = `hpall`+'$hp', `mpall` = `mpall`+'$mp' WHERE `usr` = '$log'");
}
mysql_query("UPDATE `weapon` SET `name` = `name`,
`cena` = '$cena',
`sila` = `sila`+'$sila',
`lovk` = `lovk`+'$lovk',
`proch` = `proch`+'1',
`prot` = `prot`+'$prot',
`ukrit` = `ukrit`+'$ukrit',
`hp` = `hp`+'$hp',
`mp` = `mp`+'$mp' WHERE `usr` = '$log' AND `id` = '".mysql_real_escape_string($id)."'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'10' WHERE `usr` = '$log' AND `lat_name`= 'kamen'");
mysql_query("UPDATE `res` SET `kol` = `kol`-'1' WHERE `usr` = '$log' AND `lat_name`= 'remont'");
mysql_query("UPDATE `users` SET `almaz` = `almaz`-'100' WHERE `usr` = '$log'");
$_SESSION['message']="Бонус вещи успешно повышен!";
header('Location: kuznec.php?mod=remont&id='.$id.'');
exit();
break;
}


if(empty($_GET['id'])){
echo"<img src='pic/no.png' alt='*'/> Не выбрана вещь!";
break;
}else{
$id = $_GET['id'];
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr`= '$log' AND `id`= '".mysql_real_escape_string($id)."' AND `proch`<'10' ") or die (mysql_error());
$avto=mysql_num_rows($req);
if($avto==0){
$_SESSION['err']="Бонус вещи повышен полностью!";
header('Location: kuznec.php?mod=bonus');
exit();
break;
}else{
$mag = mysql_fetch_array($req);
if($udata['lvl']>$mag['nlvl']){
$font="#9c9";
$pic="ok.png";
}
if($udata['lvl']<$mag['nlvl']){
$font="#c66";
$pic="error.png";
}
$wep = mysql_fetch_array(mysql_query("SELECT * FROM `weapon` WHERE `image` = 'yes' AND `usr` = '$log' AND `tip` = '$mag[tip]'"));
$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='<span style="color: #999;"> + 0</span>';
}
if($statmag-$stat>0){
$sta=$statmag-$stat;
$tex='<span style="color: #9c9;"> +'.$sta.'</span>';
}
if($statmag-$stat<0){
$sta=$statmag-$stat;
$tex='<span style="color: #c66;"> '.$sta.'</span>';
}
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/weapon/'.$mag['kompl'].'/'.$mag['tip'].'.png" width="60" height="60" style="margin-left:10px; margin-right:10px;" alt="*"><a href="inventar.php?mod=info&id='.$mag['id'].'"><span style="color: #fc6;"> '.$tip.' '.$mag['name'].'</a></span> +'.$wep['zakal'].'<br>+ '.$stat.' к параметрам<br>Бонус: '.$mag['proch'].'/10<br><br>';

echo'</div><div class="mini-line"></div><div class="block_zero center">';

$pro1=round($wep['hp']/10);
$pro2=round($wep['mp']/10);
$pro3=round($wep['ukrit']/10);
$pro4=round($wep['sila']/10);
$pro5=round($wep['lovk']/10);
$pro6=round($wep['prot']/10);

$pro=$pro1+$pro2+$pro3+$pro4+$pro5+$pro6;

$proch=$set['kuznec']+50;

$prochh=$wep['proch']+1;

echo"Шанс повысить бонус на<span style='color: #9c9;'> +$prochh</span>: $proch%<br><span style='color: #9c9;'>+ $pro</span> к параметрам вещи";

echo "<form action=\"kuznec.php?mod=remont&nachat&id=$mag[id]\" method=\"POST\">";
echo '<span class="btn"><span class="end"><input class="label" type="submit" value="Повысить"></span></span></form>';

echo'</div><div class="block_zero">';

$resd = mysql_fetch_array(mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'remont' LIMIT 1"));
$net=1-$resd['kol'];
if($resd['kol']<1){
$nett=' - <span style="color: #ff3434;">не хватает '.$net.'!</span>';
}else{
$nett=' - <span style="color: #9c9;">есть!</span>';
}

$kam = mysql_fetch_array(mysql_query("SELECT * FROM `res` WHERE `usr`= '$log' AND `lat_name`= 'kamen' LIMIT 1"));
$net5=10-$kam['kol'];
if($kam['kol']<10){
$nett5=' - <span style="color: #ff3434;">не хватает '.$net5.'!</span>';
}else{
$nett5=' - <span style="color: #9c9;">есть!</span>';
}

$zol = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `usr`= '$log' LIMIT 1"));
$net6=100-$zol['almaz'];
if($zol['almaz']<10){
$nett6=' - <span style="color: #ff3434;">не хватает '.$net6.'!</span>';
}else{
$nett6=' - <span style="color: #9c9;">есть!</span>';
}

echo"Для повышения бонуса Вам потребуется: </br>";

echo"<img src='image/resurs/rem.png' width='12' height='12' alt='*'/> Молоток ремонта, 1 <span style='color: #9bc;'>шт.</span>$nett</br>
<img src='image/resurs/kamen.png' alt='*'/> Камня, 10 <span style='color: #9bc;'>шт.</span>$nett5</br>
<img src='image/icon/almaz.png' alt='*'/> Золота, 100<span style='color: #9bc;'> шт.</span>$nett6";
}
}
echo'</div><div class="dot-line"></div>';
echo'<ul class="hint"><li>Ресурсы можно добыть на <img src="image/icon/train.png" alt="*"><a href=""> Руднике</a></li></ul>';
echo'<div class="mini-line"></div>';
echo'<div class="block_zero"><a href="kuznec.php?mod=weapon"><img src="image/icon/arrow.png"> В кузницу</a></div></div>';
break;
//***************************************
break;
}
include($path.'files/down.php');
?>