<b>
<div style="padding-left:10px">
<?
$up=$_GET['up'];
$WID=$_GET['WID'];

$upSEL=mysql_query("SET NAMES cp1251");
$upSEL=mysql_query("SELECT * FROM upgrade WHERE UP_KEY=\"$WID\"");
$upSEL2=mysql_fetch_assoc($upSEL);
$weadB=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$WID\" AND ID_USERS=\"$_SESSION[s]\"");
				$weadC=mysql_fetch_assoc($weadB);
							 if($weadC[IL_KEY]=='i.kirka'){echo'невозможно заточить данную вещь<br/><a href="game.php">в игру</a>';die;}
echo"
<a href=\"game.php\"><img src=\"img/al.png\" alt=\"x\"> в игру</a>
<br/>";
if(!isset($WID)){
echo"выбери вещь которую хочешь улучшить:<br/>";
                }
$weapon=mysql_query("SET NAMES cp1251");		
$weapon=mysql_query("SELECT * FROM inv WHERE IL_ALL_CLASS=\"weapon\" AND IL_KEY!=\"i.kirka\" AND ID_USERS=\"$_SESSION[s]\"");
if($up==1){
$weapon=mysql_query("SELECT * FROM inv WHERE IL_KEY=\"i.upgrade\"  AND ID_USERS=\"$_SESSION[s]\"");
$wead=mysql_query("SELECT * FROM inv WHERE ID_USERS=\"$_SESSION[s]\" AND ID_IL=\"$WID\" AND IL_NO=\"1\"");
if(mysql_num_rows($wead)>0){
echo'<div class="main_title"><center><font color="red"><img src="img/bad.png">  
для заточения вещи снимите ее с себя</font></center></div>';die;
                             }
				
if(mysql_num_rows($weapon)<1){
echo'у вас нету камня заточения';die;
                             }
if(mysql_num_rows($weapon)>0){
$weaponS=mysql_query("SELECT * FROM inv WHERE IL_ALL_CLASS=\"weapon\"  AND ID_USERS=\"$_SESSION[s]\" AND ID_IL=\"$WID\"");

while($weaponS2=mysql_fetch_assoc($weaponS)){
if($weaponS2[IL_UPGRADE]==0){$SHANS=80;}
if($weaponS2[IL_UPGRADE]==1){$SHANS=55;}
if($weaponS2[IL_UPGRADE]==2){$SHANS=40;}
if($weaponS2[IL_UPGRADE]==3){$SHANS=25;}
if($weaponS2[IL_UPGRADE]==4){$SHANS=10;}
if($weaponS2[IL_UPGRADE]==5){$SHANS=6;}
if($weaponS2[IL_UPGRADE]==6){$SHANS=3;}
if($weaponS2[IL_UPGRADE]==7){$SHANS=2;}
if($weaponS2[IL_UPGRADE]==8){$SHANS=1;}
if($weaponS2[IL_UPGRADE]==9){$SHANS=0.8;}
if($weaponS2[IL_UPGRADE]==10){$SHANS=0.5;}
if($weaponS2[IL_UPGRADE]==11){$SHANS=0.2;}
if($weaponS2[IL_UPGRADE]==12){$SHANS=0.1;}
$proSHAN=rand(0,100);
if($weaponS2[IL_UPGRADE]==12){
echo'невозможно заточить вещь т.к она на максимальном уровне';die;
                             }
if($proSHAN>$SHANS){
echo'камень заточения пропал<br/>';
echo'вам не удалось заточить вещь!';
$prov_co=mysql_query("SELECT * FROM inv WHERE IL_KEY=\"i.upgrade\" AND ID_USERS=\"$_SESSION[s]\"");
$prov_co2=mysql_fetch_assoc($prov_co);
if($prov_co2[IL_COUNT]==1){$del_sto=mysql_query("DELETE FROM inv WHERE IL_KEY=\"i.upgrade\" AND ID_USERS=\"$_SESSION[s]\"");}//удаляем камень
if($prov_co2[IL_COUNT]>1){
$count=$prov_co2[IL_COUNT]-1;
$upd_stone=mysql_query("UPDATE inv SET IL_COUNT=\"$count\" WHERE IL_KEY=\"i.upgrade\" AND ID_USERS=\"$_SESSION[s]\"");}//обновляем камень
die;
                         }
if($proSHAN<=$SHANS){
echo'камень заточения пропал<br/>';
$prov_co=mysql_query("SELECT * FROM inv WHERE IL_KEY=\"i.upgrade\" AND ID_USERS=\"$_SESSION[s]\"");
$prov_co2=mysql_fetch_assoc($prov_co);
if($prov_co2[IL_COUNT]==1){$del_sto=mysql_query("DELETE FROM inv WHERE IL_KEY=\"i.upgrade\" AND ID_USERS=\"$_SESSION[s]\"");}//удаляем камень
if($prov_co2[IL_COUNT]>1){$count=$prov_co2[IL_COUNT]-1;$upd_stone=mysql_query("UPDATE inv SET IL_COUNT=\"$count\" WHERE IL_KEY=\"i.upgrade\" AND ID_USERS=\"$_SESSION[s]\"");}//обновляем камень
$weapong=mysql_query("SELECT * FROM inv WHERE IL_ALL_CLASS=\"weapon\"  AND ID_USERS=\"$_SESSION[s]\" AND ID_IL=\"$WID\"");
$weapong2=mysql_fetch_assoc($weapong);
$cEND=$weapong2[IL_UPGRADE]+1;
echo'Вы успешно заточили вещь до +'.$cEND;
$weapon11=mysql_query("SELECT * FROM inv WHERE IL_ALL_CLASS=\"weapon\"  AND ID_USERS=\"$_SESSION[s]\" AND ID_IL=\"$WID\"");
$weapon22=mysql_fetch_assoc($weapon11);
if($weapon22[IL_ALL_CLASS]=='weapon'){
$to=$weapon22[IL_UPGRADE]+1;
if($to==1){$DMG=1;}//2
if($to==2){$DMG=2;}//4
if($to==3){$DMG=3;}//6
if($to==4){$DMG=4;}//8
if($to==5){$DMG=5;}//10
if($to==6){$DMG=6;}//12
if($to==7){$DMG=8;}//14
if($to==8){$DMG=10;}//16
if($to==9){$DMG=12;}//18
if($to==10){$DMG=14;}//20
if($to==11){$DMG=16;}//22
if($to==12){$DMG=18;}//25
$DMG1=round($weapon22[IL_MIN_DMG]*$DMG/100);
$DMG2=round($weapon22[IL_MAX_DMG]*$DMG/100);
$DMG3=$weapon22[IL_MIN_DMG]+$DMG1;
$DMG4=$weapon22[IL_MAX_DMG]+$DMG2;
//лук охотника
//i.w.r.b.hunbow
if(mysql_num_rows($wead)<1){

$weapon22[IL_NAME]=str_replace("+","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("_","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("1","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("2","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("3","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("4","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("5","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("6","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("7","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("8","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("9","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("0","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("+","",$weapon22[IL_NAME]);
$weapon22[IL_NAME]=str_replace("_","",$weapon22[IL_NAME]);

$weapon22[IL_KEY]=str_replace("+","",$weapon22[IL_KEY]);
$weapon22[IL_KEY]=str_replace("_","",$weapon22[IL_KEY]);
$weapon22[IL_KEY]=str_replace("1","",$weapon22[IL_KEY]);
$weapon22[IL_KEY]=str_replace("2","",$weapon22[IL_KEY]);
$weapon22[IL_KEY]=str_replace("3","",$weapon22[IL_KEY]);
$weapon22[IL_KEY]=str_replace("4","",$weapon22[IL_KEY]);
$weapon22[IL_KEY]=str_replace("5","",$weapon22[IL_KEY]);
$weapon22[IL_KEY]=str_replace("6","",$weapon22[IL_KEY]);
$weapon22[IL_KEY]=str_replace("7","",$weapon22[IL_KEY]);
$weapon22[IL_KEY]=str_replace("8","",$weapon22[IL_KEY]);
$weapon22[IL_KEY]=str_replace("9","",$weapon22[IL_KEY]);
$weapon22[IL_KEY]=str_replace("0","",$weapon22[IL_KEY]);
$delIT=mysql_query("DELETE FROM upgrade WHERE UP_NICK=\"$_SESSION[s]\"");

if($weapon22[IL_KEY]==$upSEL2[UP_KEY] AND mysql_num_rows($upSEL)>0){
$upg_WEAPON2=mysql_query("UPDATE inv SET IL_NAME=\"\",IL_KEY=\"\",IL_MIN_DMG=\"$DMG3\",IL_MAX_DMG=\"$DMG4\",IL_UPGRADE=\"$to\" WHERE  ID_IL=\"$WID\" AND ID_USERS=\"$_SESSION[s]\"");
$upg_WEAPON2=mysql_query("UPDATE inv SET IL_NAME=\"$upSEL2[UP_NAME] +$to\",IL_KEY=\"$upSEL2[UP_KEY]_$to\",IL_MIN_DMG=\"$DMG3\",IL_MAX_DMG=\"$DMG4\",IL_UPGRADE=\"$to\" WHERE  ID_IL=\"$WID\" AND ID_USERS=\"$_SESSION[s]\"");
}
if($weapon22[IL_KEY]!=$upSEL2[UP_KEY] OR mysql_num_rows($upSEL)<1){
$dele=mysql_query("DELETE FROM upgrade WHERE UP_KEY=\"$WID\" AND UP_NICK=\"$_SESSION[s]\"");
$upIN=mysql_query("INSERT INTO upgrade (UP_NAME,UP_KEY,UP_NICK) VALUES ('$weapon22[IL_NAME]','$weapon22[IL_KEY]','$_SESSION[s]')");
$upg_WEAPON2=mysql_query("UPDATE inv SET IL_NAME=\"\",IL_KEY=\"\",IL_MIN_DMG=\"$DMG3\",IL_MAX_DMG=\"$DMG4\",IL_UPGRADE=\"$to\" WHERE  ID_IL=\"$WID\" AND ID_USERS=\"$_SESSION[s]\"");
$upg_WEAPON2=mysql_query("UPDATE inv SET IL_NAME=\"$weapon22[IL_NAME] +$to\",IL_KEY=\"$weapon22[IL_KEY]_$to\",IL_MIN_DMG=\"$DMG3\",IL_MAX_DMG=\"$DMG4\",IL_UPGRADE=\"$to\" WHERE  ID_IL=\"$WID\" AND ID_USERS=\"$_SESSION[s]\"");

}
}



}
die;}
}
die;}

die;}
while($weapon2=mysql_fetch_assoc($weapon)){
echo "<a href=\"game.php?speak=stare&id=stare_upgrade&up=1&WID=$weapon2[ID_IL]\">".$weapon2[IL_NAME]."</a>";

if($weapon2[IL_UPGRADE]==0){echo' (шанс 80%)';}
if($weapon2[IL_UPGRADE]==1){echo' (шанс 65%)';}
if($weapon2[IL_UPGRADE]==2){echo' (шанс 50%)';}
if($weapon2[IL_UPGRADE]==3){echo' (шанс 40%)';}
if($weapon2[IL_UPGRADE]==4){echo' (шанс 25%)';}
if($weapon2[IL_UPGRADE]==5){echo' (шанс 10%)';}
if($weapon2[IL_UPGRADE]==6){echo' (шанс 5%)';}
if($weapon2[IL_UPGRADE]==7){echo' (шанс 2%)';}
if($weapon2[IL_UPGRADE]==8){echo' (шанс 1%)';}
if($weapon2[IL_UPGRADE]==9){echo' (шанс 0.8%)';}
if($weapon2[IL_UPGRADE]==10){echo' (шанс 0.5%)';}
if($weapon2[IL_UPGRADE]==11){echo' (шанс 0.2%)';}


       	   
}
die;
?>
</b>