View file techno/scroll.php

File size: 8.95Kb
<?
define('PROTECTOR', 1);

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

$textl='Инвентарь';
@include('files/db.php');
@include('files/auth.php');
@include('files/func.php');
going();
@include('files/core.php');
@include('files/head.php');
@include('files/zag.php');
$sett = mysql_query("SELECT * FROM `set` WHERE `usr` = '$log'");
$set = mysql_fetch_array($sett);
$req = mysql_query("SELECT * FROM `res` WHERE `usr` = '$log' and `id`='$_GET[id]'");
$avto=mysql_num_rows($req);
if($avto==0){
echo'Ошибка, такого свитка нет!';
@include('files/down.php');exit;}
$mag = mysql_fetch_array($req);
if($mag[tip]!='scroll'){
echo'Ошибка, доступ закрыт!';
@include('files/down.php');exit;}
switch($mag[what]){
case 'scroll_weapon':
$req = mysql_query("SELECT * FROM `item` WHERE `usr` = '$log' and `tip`='weapon' and `image`='yes' LIMIT 1");
$avto=mysql_num_rows($req);
if($avto=='0'){
echo'Ошибка, сначала возьмите оружие!';
@include('files/down.php');exit;}
$it = mysql_fetch_array($req);
$u = explode("|",$mag[give]);
$numin=$u[0]+$udata[umin];
$numax=$u[1]+$udata[umax];
$w=explode("*",$it[name]);
if(empty($w[1])){
$nam="$w[0]*1";}else{
$kol=$w[1]+1;
$nam="$w[0]*$kol";}

if(empty($w[1])){$stavka=100+($set[kuznec]*1.5);}
if($w[1]==1){$stavka=89+($set[kuznec]*1.5);}
if($w[1]==2){$stavka=79+($set[kuznec]*1.5);}
if($w[1]==3){$stavka=69+($set[kuznec]*1.5);}
if($w[1]==4){$stavka=59+($set[kuznec]*1.5);}
if($w[1]==5){$stavka=49+($set[kuznec]*1.5);}
if($w[1]==6){$stavka=39+($set[kuznec]*1.5);}
if($w[1]==7){$stavka=29+($set[kuznec]*1.5);}
if($w[1]==8){$stavka=25+($set[kuznec]*1.5);}
if($w[1]==9){$stavka=20+($set[kuznec]*1.5);}
if($w[1]>=10){
echo'Вещь заточена на максимум!';
include('files/down.php');
exit;}

$priz=rand(1,100);

if($priz<$stavka){

$num=$u[0]+$it[umin];
$nux=$u[1]+$it[umax];

mysql_query("UPDATE `users` SET `umin` = '$numin',`umax` = '$numax' WHERE usr = '$log'");
mysql_query("UPDATE `item` SET
      `umin` = '$num',
      `umax` = '$nux',
      `name` = '$nam'
       WHERE `usr` = '$log' and `tip`='weapon' and `image`='yes'");
       
$msg="Оружие заточено!<br/>Новый урон: $numin/$numax. добавилось: $u[0]/$u[1]<br/>";
}else{
$req = mysql_query("SELECT * FROM `item` WHERE `usr` = '$log' and `tip`='weapon' and `image`='yes'");
$it = mysql_fetch_array($req);

$numin=$udata[umin]-$it[umin];
$numax=$udata[umax]-$it[umax];

$npgolova=$udata[pgolova]-$it[pgolova];
$npbody=$udata[pbody]-$it[pbody];
$npnogi=$udata[pnogi]-$it[pnogi];

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

$nsila=$udata[sila]-$it[sila];
$nlovk=$udata[lovk]-$it[lovk];
$nprot=$udata[prot]-$it[prot];
$num=$udata[um]-$it[um];
$nanti=$udata[antikrit]-$it[antikrit];
$lom = round($it[cena]/40);
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'");
$mlom = mysql_query("SELECT * FROM `res` WHERE `usr` = '$log' and `lat_name` = 'jelezo'");
$mlom = mysql_fetch_array($mlom);
mysql_query("UPDATE `res` SET `kol` = '$mlom[kol]'+'$lom' WHERE `usr` = '$log' and `lat_name`='jelezo'");
mysql_query("DELETE FROM `item` WHERE `usr` = '$log' and `tip`='weapon' and `image`='yes'");

$msg="Оружие $it[name] не выдержало очередного заряда магии из свитка!<br/><b>Оружие сломано, но вы получили +$lom железа!</b><br/>";
}
//////////////
if($mag[kol]==1){
mysql_query("DELETE FROM `res` WHERE `usr` = '$log' and `id`='$_GET[id]'");
}else{
$mag[kol]--;
mysql_query("UPDATE res SET kol = '$mag[kol]' WHERE `usr` = '$log' and `id`='$_GET[id]'");
}
break;
/////////////////////
case 'scroll_armor':
if(empty($_GET[tip])){
echo'<b>Заколдовать:</b><br/>';
echo"<a href=\"scroll.php?tip=golova&amp;id=$_GET[id]\">Шлем</a><br/>";
echo"<a href=\"scroll.php?tip=body&amp;id=$_GET[id]\">Доспехи</a><br/>";
echo"<a href=\"scroll.php?tip=shit&amp;id=$_GET[id]\">Щит</a><br/>";
echo"<a href=\"scroll.php?tip=plash&amp;id=$_GET[id]\">Плащ</a><br/>";
echo"<a href=\"scroll.php?tip=poyas&amp;id=$_GET[id]\">Пояс</a><br/>";
echo"<a href=\"scroll.php?tip=ruki&amp;id=$_GET[id]\">Рукавицы</a><br/>";
echo"<a href=\"scroll.php?tip=nogi&amp;id=$_GET[id]\">Сапоги</a><br/>- - -<br/>";
}elseif(isset($_GET[tip]) and empty($_GET[what])){
echo"<a href=\"scroll.php?tip=$_GET[tip]&amp;what=pgolova&amp;id=$_GET[id]\">Защиту головы</a><br/>";
echo"<a href=\"scroll.php?tip=$_GET[tip]&amp;what=pbody&amp;id=$_GET[id]\">Защиту тела</a><br/>";
echo"<a href=\"scroll.php?tip=$_GET[tip]&amp;what=pnogi&amp;id=$_GET[id]\">Защиту ног</a><br/>";}else{
if($_GET[tip]!=golova and $_GET[tip]!=body and $_GET[tip]!=nogi and $_GET[tip]!=shit and $_GET[tip]!=plash and $_GET[tip]!=ruki and $_GET[tip]!=poyas){
echo'Ошибка, доступ закрыт!';
@include('files/down.php');exit;}
if($_GET[what]!=pgolova and $_GET[what]!=pbody and $_GET[what]!=pnogi){
echo'Ошибка, доступ закрыт!';
@include('files/down.php');exit;}
$req = mysql_query("SELECT * FROM `item` WHERE `usr` = '$log' and `tip`='$_GET[tip]' and `image`='yes' LIMIT 1");
$avto=mysql_num_rows($req);
if($avto=='0'){
echo'Ошибка, сначала наденьте вещь!';
@include('files/down.php');exit;}
$it = mysql_fetch_array($req);

$nprotect=$mag[give]+$udata[$_GET[what]];
$w=explode("*",$it[name]);
if(empty($w[1])){
$nam="$w[0]*1";
}else{
$kol=$w[1]+1;
$nam="$w[0]*$kol";}

if(empty($w[1])){$stavka=100;}
if($w[1]==1){$stavka=89+$set[kuznec]*1.5;}
if($w[1]==2){$stavka=79+$set[kuznec]*1.5;}
if($w[1]==3){$stavka=69+$set[kuznec]*1.5;}
if($w[1]==4){$stavka=59+$set[kuznec]*1.5;}
if($w[1]==5){$stavka=49+$set[kuznec]*1.5;}
if($w[1]==6){$stavka=39+$set[kuznec]*1.5;}
if($w[1]==7){$stavka=29+$set[kuznec]*1.5;}
if($w[1]==8){$stavka=25+$set[kuznec]*1.5;}
if($w[1]==9){$stavka=20+$set[kuznec]*1.5;}
if($w[1]>=10){
echo'Вещь заточена на максимум!';
include('files/down.php');
exit;}

$priz=rand(1,100);

if($priz<=$stavka){

$num=$mag[give]+$it[$_GET[what]];

mysql_query("UPDATE `users` SET `$_GET[what]` = '$nprotect' WHERE usr = '$log'");
mysql_query("UPDATE `item` SET
      `$_GET[what]` = '$num',
      `name` = '$nam'
       WHERE `usr` = '$log' and `tip`='$_GET[tip]' and `image`='yes'");
       
$msg="Защита увеличена!<br/>Новая защита: $nprotect Прибавилось $mag[give]<br/>";
}else{
$req = mysql_query("SELECT * FROM `item` WHERE `usr` = '$log' and `tip`='$_GET[tip]' and `image`='yes'");
$it = mysql_fetch_array($req);

$numin=$udata[umin]-$it[umin];
$numax=$udata[umax]-$it[umax];
$npgolova=$udata[pgolova]-$it[pgolova];
$npbody=$udata[pbody]-$it[pbody];
$npnogi=$udata[pnogi]-$it[pnogi];
$nhp=$udata[hpall]-$it[hp];
$nmp=$udata[mpall]-$it[mp];
$nkrit=$udata[krit]-$it[krit];
$nukrit=$udata[ukrit]-$it[ukrit];

$nsila=$udata[sila]-$it[sila];
$nlovk=$udata[lovk]-$it[lovk];
$nprot=$udata[prot]-$it[prot];
$num=$udata[um]-$it[um];
$nanti=$udata[antikrit]-$it[antikrit];
$lom = round($it[cena]/40);
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'");
$mlom = mysql_query("SELECT * FROM `res` WHERE `usr` = '$log' and `lat_name` = 'jelezo'");
$mlom = mysql_fetch_array($mlom);
mysql_query("UPDATE `res` SET `kol` = '$mlom[kol]'+'$lom' WHERE `usr` = '$log' and `lat_name`='jelezo'");
mysql_query("DELETE FROM `item` WHERE `usr` = '$log' and `tip`='$_GET[tip]' and `image`='yes'");

$msg="Вещь не выдержала очередного заряда магии из свитка!<br/><b>Вещь $it[name] сломана, но вы получили +$lom железа!</b><br/>";
}
//////////////
if($mag[kol]==1){
mysql_query("DELETE FROM `res` WHERE `usr` = '$log' and `id`='$_GET[id]'");
}else{
$mag[kol]--;
mysql_query("UPDATE res SET kol = '$mag[kol]' WHERE `usr` = '$log' and `id`='$_GET[id]'");
}
///////////////
}
break;
}
///////
echo"$msg";
echo"<a href=\"inventar.php?\">Назад</a>";
include('files/down.php');
?>